移除select/selectval方法,统一使用dropdown-menu下拉菜单方式
This commit is contained in:
parent
aad6021c79
commit
2f6b489032
|
@ -1,4 +1,8 @@
|
|||
.logfile {
|
||||
.lgbDropdown {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.logfile {
|
||||
color: #d41404;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
@ -74,7 +78,7 @@
|
|||
outline: none !important;
|
||||
}
|
||||
|
||||
.btn span {
|
||||
.btn span:last-child {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ a, a:hover, a:focus {
|
|||
outline: none;
|
||||
}
|
||||
|
||||
.btn .caret {
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.176);
|
||||
}
|
||||
|
|
|
@ -324,30 +324,25 @@
|
|||
}).insertBefore($('div.bootstrap-table > div.fixed-table-toolbar > div.bs-bars'));
|
||||
$(settings.toolbar).removeClass('hidden');
|
||||
},
|
||||
select: function () {
|
||||
lgbDropdown: function (options) {
|
||||
var $this = $(this);
|
||||
$this.each(function (index, element) {
|
||||
var $element = $(element);
|
||||
var $select = $element.find('button').first();
|
||||
var $options = $element.find('.dropdown-menu > li > a');
|
||||
$select.addClass('select').data('options', $options);
|
||||
$options.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $op = $(this);
|
||||
$select.text($op.text()).attr('data-val', $op.attr('data-val'));
|
||||
});
|
||||
});
|
||||
},
|
||||
selectval: function (value) {
|
||||
var $this = $(this);
|
||||
if (value == undefined) return $this.attr('data-val');
|
||||
$this.data('options').each(function (index, element) {
|
||||
var $op = $(element);
|
||||
var val = $op.attr('data-val');
|
||||
if (value == val) {
|
||||
$this.text($op.text()).attr('data-val', val);
|
||||
var op = typeof options == 'object' && options;
|
||||
if (/val/.test(options)) {
|
||||
if (arguments.length == 1)
|
||||
return $this.first().children('a').val();
|
||||
else {
|
||||
$this.first().children(':first').children(':first').text($this.find('[data-val="' + arguments[1] + '"]').text())
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$this.each(function () {
|
||||
$(this).on('click', '.dropdown-menu a', { $parent: $(this) }, function (event) {
|
||||
event.preventDefault();
|
||||
var $op = $(this);
|
||||
event.data.$parent.children('a').val($op.attr('data-val')).children(':first').text($op.text());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
@ -85,6 +85,8 @@ $(function () {
|
|||
}
|
||||
});
|
||||
|
||||
$('.lgbDropdown').lgbDropdown();
|
||||
|
||||
// load widget data
|
||||
$.bc({
|
||||
url: Notifications.url,
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
load: function (value) {
|
||||
for (name in this.options.map) {
|
||||
var ctl = $("#" + this.options.map[name]);
|
||||
if (ctl.hasClass('select')) ctl.selectval(value[name]);
|
||||
else ctl.val(value[name]);
|
||||
ctl.val(value[name]);
|
||||
if (ctl.attr('data-toggle') == "dropdown") {
|
||||
ctl.children(':first').text(ctl.next().find('[data-val="' + value[name] + '"]').text());
|
||||
}
|
||||
}
|
||||
},
|
||||
reset: function () {
|
||||
|
@ -20,22 +22,19 @@
|
|||
var ctl = $("#" + this.options.map[name]);
|
||||
var dv = ctl.attr("data-default-val");
|
||||
if (dv === undefined) dv = "";
|
||||
if (ctl.hasClass('select')) ctl.selectval(dv);
|
||||
else ctl.val(dv);
|
||||
ctl.val(dv);
|
||||
if (ctl.attr('data-toggle') == "dropdown") {
|
||||
ctl.children(':first').text(ctl.next().find('[data-val="' + dv + '"]').text());
|
||||
}
|
||||
}
|
||||
},
|
||||
get: function () {
|
||||
var target = {};
|
||||
for (name in this.options.map) {
|
||||
var ctl = $("#" + this.options.map[name]);
|
||||
if (ctl.hasClass('select')) {
|
||||
target[name] = ctl.selectval();
|
||||
}
|
||||
else {
|
||||
var dv = ctl.attr('data-default-val');
|
||||
if (dv !== undefined && ctl.val().trim() === "") target[name] = dv;
|
||||
else target[name] = ctl.val();
|
||||
}
|
||||
var dv = ctl.attr('data-default-val');
|
||||
if (dv !== undefined && ctl.val().trim() === "") target[name] = dv;
|
||||
else target[name] = ctl.val();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
$('table').smartTable({
|
||||
url: Dicts.url,
|
||||
sortName: 'Category',
|
||||
queryParams: function (params) { return $.extend(params, { category: $('#txt_dict_cate').val(), name: $("#txt_dict_name").val(), define: $("#txt_dict_define").selectval() }); },
|
||||
queryParams: function (params) { return $.extend(params, { category: $('#txt_dict_cate').val(), name: $("#txt_dict_name").val(), define: $("#txt_dict_define").val() }); },
|
||||
columns: [{ checkbox: true },
|
||||
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
|
||||
{ title: "字典分项", field: "Category", sortable: true },
|
||||
|
@ -45,8 +45,6 @@
|
|||
maxlength: 50
|
||||
}
|
||||
});
|
||||
// select
|
||||
$('.btn-select').select();
|
||||
|
||||
// autocomplete
|
||||
$.bc({
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
$('table').smartTable({
|
||||
url: Menu.url, //请求后台的URL(*)
|
||||
sortName: 'Order',
|
||||
queryParams: function (params) { return $.extend(params, { parentName: $('#txt_parent_menus_name').val(), name: $("#txt_menus_name").val(), category: $('#sel_menus_category').selectval() }); }, //传递参数(*)
|
||||
queryParams: function (params) { return $.extend(params, { parentName: $('#txt_parent_menus_name').val(), name: $("#txt_menus_name").val(), category: $('#sel_menus_category').val() }); }, //传递参数(*)
|
||||
columns: [{ checkbox: true },
|
||||
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
|
||||
{ title: "父级菜单", field: "ParentName", sortable: true },
|
||||
|
@ -115,6 +115,11 @@
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "菜单类型", field: "IsResource", sortable: true, formatter: function (value, row, index) {
|
||||
return value == 0 ? "菜单" : "资源";
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
@ -224,8 +229,6 @@
|
|||
});
|
||||
|
||||
$nestMenu.nestMenu(initNestMenu);
|
||||
// select
|
||||
$('.btn-select').select();
|
||||
|
||||
$.bc({
|
||||
url: Menu.iconView,
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
}, {
|
||||
id: 'cssSave',
|
||||
click: function (row, data) {
|
||||
var cssDefine = $('#dictCssDefine').attr('data-val');
|
||||
var cssDefine = $('#dictCssDefine').val();
|
||||
if (cssDefine) {
|
||||
$.bc({
|
||||
url: Profiles.url, data: { name: '使用样式', code: cssDefine, category: '当前样式' }, title: '网站样式',
|
||||
|
@ -168,12 +168,11 @@
|
|||
callback: function (result) {
|
||||
var html = result.map(function (ele, index) { return $.format('<li><a href="#" data-val="{1}">{0}</a></li>', ele.Name, ele.Code); }).join('');
|
||||
$('#cssContainer').html(html);
|
||||
$('.btn-select').select();
|
||||
$.bc({
|
||||
Id: 1, url: Dicts.url, data: { type: 'activeCss' }, swal: false,
|
||||
callback: function (result) {
|
||||
if (result.length > 0)
|
||||
$('#dictCssDefine').selectval(result[0].Code);
|
||||
$('.lgbDropdown').lgbDropdown('val', result[0].Code);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,12 +20,11 @@
|
|||
</div>
|
||||
<div class="form-group col-sm-6 col-lg-3">
|
||||
<label class="control-label" for="txt_dict_define">字典类别</label>
|
||||
<div class="btn-group btn-select">
|
||||
<button id="txt_dict_define" type="button" class="btn btn-success" data-val="">全部</button>
|
||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="dropdown lgbDropdown">
|
||||
<a id="txt_dict_define" class="btn btn-success" data-toggle="dropdown">
|
||||
<span>全部</span>
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">下拉菜单</span>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" data-val="">全部</a></li>
|
||||
<li class="divider"></li>
|
||||
|
@ -35,7 +34,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6 col-lg-3">
|
||||
<button type="button" id="btn_query" class="btn btn-primary form-control"><span class="fa fa-search" aria-hidden="true"></span>查询</button>
|
||||
<button type="button" id="btn_query" class="btn btn-primary form-control"><i class="fa fa-search" aria-hidden="true"></i><span>查询</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -71,12 +70,10 @@
|
|||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="control-label" for="dictDefine">字典类别</label>
|
||||
<div class="btn-group dropup btn-select">
|
||||
<button id="dictDefine" type="button" class="btn btn-success" data-default-val="1" data-val="">全部</button>
|
||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">下拉菜单</span>
|
||||
</button>
|
||||
<div class="dropdown lgbDropdown dropup">
|
||||
<a id="dictDefine" class="btn btn-success" data-toggle="dropdown" data-default-val="1">
|
||||
<span>全部</span><span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" data-val="0">系统使用</a></li>
|
||||
<li><a href="#" data-val="1">自定义</a></li>
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
</div>
|
||||
<div class="form-group col-sm-6 col-lg-3">
|
||||
<label class="control-label" for="sel_menus_category">菜单类别</label>
|
||||
<div class="btn-group btn-select">
|
||||
<button id="sel_menus_category" type="button" class="btn btn-success" data-val="">全部</button>
|
||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="dropdown lgbDropdown">
|
||||
<a id="sel_menus_category" class="btn btn-success" data-toggle="dropdown">
|
||||
<span>全部</span>
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">下拉菜单</span>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" data-val="">全部</a></li>
|
||||
<li class="divider"></li>
|
||||
|
@ -107,12 +106,11 @@
|
|||
</div>
|
||||
<div class="form-group col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="category">菜单类别</label>
|
||||
<div class="btn-group dropup btn-select">
|
||||
<button id="category" type="button" class="btn btn-success" data-default-val="1" data-val="1">外部菜单</button>
|
||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="dropdown lgbDropdown dropup">
|
||||
<a id="category" class="btn btn-success" data-toggle="dropdown" data-default-val="1">
|
||||
<span>外部菜单</span>
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">下拉菜单</span>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" data-val="0">系统菜单</a></li>
|
||||
<li><a href="#" data-val="1">外部菜单</a></li>
|
||||
|
@ -121,12 +119,11 @@
|
|||
</div>
|
||||
<div class="form-group col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="target">目标</label>
|
||||
<div class="btn-group dropup btn-select">
|
||||
<button id="target" type="button" class="btn btn-info" data-default-val="_self" data-val="_self">本窗口</button>
|
||||
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="dropdown lgbDropdown dropup">
|
||||
<a id="target" class="btn btn-info" data-toggle="dropdown" data-default-val="_self">
|
||||
<span>本窗口</span>
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">下拉菜单</span>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" data-val="_self">本窗口</a></li>
|
||||
<li><a href="#" data-val="_blank">新窗口</a></li>
|
||||
|
@ -137,12 +134,11 @@
|
|||
</div>
|
||||
<div class="form-group col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="isRes">菜单类型</label>
|
||||
<div class="btn-group dropup btn-select">
|
||||
<button id="isRes" type="button" class="btn btn-success" data-default-val="0" data-val="0">菜单</button>
|
||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="dropdown lgbDropdown dropup">
|
||||
<a id="isRes" class="btn btn-success" data-toggle="dropdown" data-default-val="0">
|
||||
<span>菜单</span>
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">下拉菜单</span>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#" data-val="0">菜单</a></li>
|
||||
<li><a href="#" data-val="1">资源</a></li>
|
||||
|
|
|
@ -47,12 +47,11 @@
|
|||
<div class="row">
|
||||
<div class="form-group col-xs-12">
|
||||
<label class="control-label" for="dictDefine">网站样式</label>
|
||||
<div class="btn-group btn-select">
|
||||
<button id="dictCssDefine" type="button" class="btn btn-success" data-default-val="site.css" data-val="site.css">默认样式</button>
|
||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="dropdown lgbDropdown">
|
||||
<a id="dictCssDefine" class="btn btn-success" data-toggle="dropdown" data-default-val="site.css">
|
||||
<span>默认样式</span>
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">网站样式</span>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu" id="cssContainer">
|
||||
<li><a href="#" data-val="site.css">默认样式</a></li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue