[优化]去除冗余load-open事件绑定,统一使用data-load处理加载

This commit is contained in:
邹景立 2017-04-21 11:44:33 +08:00
parent b7cdd380dc
commit c45b3f2c7a
7 changed files with 12 additions and 15 deletions

View File

@ -50,7 +50,7 @@
{/if}
{if auth("$classuri/apply")}
<span class="text-explode">|</span>
<a data-open='{:url("$classuri/apply")}?id={$vo.id}' href="javascript:void(0)">授权</a>
<a data-load='{:url("$classuri/apply")}?id={$vo.id}' href="javascript:void(0)">授权</a>
{/if}
{if $vo.status eq 1 and auth("$classuri/forbid")}
<span class="text-explode">|</span>

View File

@ -12,7 +12,7 @@
{empty name='menu.sub'}
<ul class="sidebar-trans">
<li class="nav-item">
<a data-menu-node='m-{$pmenu.id}-{$menu.id}' data-open="{$menu.url}"
<a data-menu-node='m-{$pmenu.id}-{$menu.id}' data-load="{$menu.url}"
class="sidebar-trans">
<div class="nav-icon sidebar-trans">
<span class="{$menu.icon|default='fa fa-link'} transition-min"></span>
@ -31,7 +31,7 @@
<ul class="sidebar-trans" style="display:none" data-menu-node='m-{$pmenu.id}-{$menu.id}'>
{volist name='menu.sub' id='submenu'}
<li class="nav-item">
<a data-menu-node='m-{$pmenu.id}-{$submenu.id}' data-open="{$submenu.url}"
<a data-menu-node='m-{$pmenu.id}-{$submenu.id}' data-load="{$submenu.url}"
class="sidebar-trans">
<div class="nav-icon sidebar-trans">
<span class="{$submenu.icon|default='fa fa-link'} transition-min"></span>

View File

@ -8,7 +8,7 @@
</div>
{volist name='menus' id='pmenu'}
{empty name='pmenu.sub'}
<a data-menu-node='m-{$pmenu.id}' data-open="{$pmenu.url}"
<a data-menu-node='m-{$pmenu.id}' data-load="{$pmenu.url}"
class="topbar-home-link topbar-btn topbar-left">
<span>{notempty name='$pmenu.icon'}<i class="{$pmenu.icon}"></i>{/notempty} {$pmenu.title}</span>
</a>

View File

@ -241,6 +241,9 @@
<div class="text-center" style="padding-bottom:30px">
<button class="layui-btn menu-submit">保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-load="{:url('index')}"
data-confirm="确定要取消编辑吗?">取消编辑
</button>
</div>
{if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}

View File

@ -2,7 +2,7 @@
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
<button data-open="{:url('add')}" class='layui-btn layui-btn-small'>添加规则</button>
<button data-load="{:url('add')}" class='layui-btn layui-btn-small'>添加规则</button>
</div>
{/block}
@ -48,7 +48,7 @@
<td class='text-center nowrap'>
{if auth("$classuri/edit")}
<span class="text-explode">|</span>
<a data-open='{:url("@wechat/keys/edit")}?id={$vo.id}'>编辑</a>
<a data-load='{:url("@wechat/keys/edit")}?id={$vo.id}'>编辑</a>
{/if}
{if auth("$classuri/del")}
<span class="text-explode">|</span>

View File

@ -147,7 +147,7 @@ class BasicAdmin extends Controller {
cookie('rows', $row_page >= 10 ? $row_page : 20);
$page = $db->paginate($row_page, $total, ['query' => $this->request->get()]);
$result['list'] = $page->all();
$result['page'] = preg_replace(['|href="(.*?)"|', '|pagination|'], ['data-open="$1" href="javascript:void(0);"', 'pagination pull-right'], $page->render());
$result['page'] = preg_replace(['|href="(.*?)"|', '|pagination|'], ['data-load="$1" href="javascript:void(0);"', 'pagination pull-right'], $page->render());
} else {
$result['list'] = $db->select();
}

View File

@ -45,12 +45,6 @@ define(['jquery', 'admin.plugs'], function () {
return $.form.modal($(this).attr('data-modal'), 'open_type=modal', $(this).attr('data-title') || '编辑');
});
/*! 注册 data-open 事件行为 */
this.$body.on('click', '[data-open]', function () {
var url = $(this).attr('data-open');
$.form.href(url, this);
});
/*! 注册 data-reload 事件行为 */
this.$body.on('click', '[data-reload]', function () {
$.form.reload();
@ -191,7 +185,7 @@ define(['jquery', 'admin.plugs'], function () {
function showLeftMenu(menuNode, $openNode) {
var $leftmenu = $('[data-menu-box=' + menuNode + ']').removeClass('hide');
$("[data-menu-box]").not($leftmenu).addClass('hide');
$openNode ? $openNode.trigger('click') : $leftmenu.find('[data-open]:first').trigger('click');
$openNode ? $openNode.trigger('click') : $leftmenu.find('[data-load]:first').trigger('click');
}
var $menutarget = $('[data-menu-target]').on('click', function () {
@ -234,7 +228,7 @@ define(['jquery', 'admin.plugs'], function () {
};
/*! 通过URI查询最有可能的菜单NODE */
function queryNode(url) {
var $menu = $('[data-menu-node][data-open*="_URL_"]'.replace('_URL_', url.replace(/\.html$/ig, '')));
var $menu = $('[data-menu-node][data-load*="_URL_"]'.replace('_URL_', url.replace(/\.html$/ig, '')));
if ($menu.size()) {
return $menu.get(0).getAttribute('data-menu-node');
}