新增普通搜索bootstrap-table-commonsearch
正在显示
10 个修改的文件
包含
440 行增加
和
146 行删除
@@ -36,6 +36,7 @@ return [ | @@ -36,6 +36,7 @@ return [ | ||
36 | 'Reset' => '重置', | 36 | 'Reset' => '重置', |
37 | 'Execute' => '执行', | 37 | 'Execute' => '执行', |
38 | 'Close' => '关闭', | 38 | 'Close' => '关闭', |
39 | + 'Choose' => '选择', | ||
39 | 'Search' => '搜索', | 40 | 'Search' => '搜索', |
40 | 'Refresh' => '刷新', | 41 | 'Refresh' => '刷新', |
41 | 'First' => '首页', | 42 | 'First' => '首页', |
@@ -82,6 +83,7 @@ return [ | @@ -82,6 +83,7 @@ return [ | ||
82 | 'Network error' => '网络错误!', | 83 | 'Network error' => '网络错误!', |
83 | 'Issues & Wiki' => '问题交流', | 84 | 'Issues & Wiki' => '问题交流', |
84 | 'Advanced search' => '高级搜索', | 85 | 'Advanced search' => '高级搜索', |
86 | + 'Common search' => '普通搜索', | ||
85 | '%d second%s ago' => '%d秒前', | 87 | '%d second%s ago' => '%d秒前', |
86 | '%d minute%s ago' => '%d分钟前', | 88 | '%d minute%s ago' => '%d分钟前', |
87 | '%d hour%s ago' => '%d小时前', | 89 | '%d hour%s ago' => '%d小时前', |
@@ -35,7 +35,10 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'config'], function ( | @@ -35,7 +35,10 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'config'], function ( | ||
35 | {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, | 35 | {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, |
36 | {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 36 | {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
37 | ] | 37 | ] |
38 | - ] | 38 | + ], |
39 | + //普通搜索 | ||
40 | + commonSearch: true, | ||
41 | + titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索 | ||
39 | }); | 42 | }); |
40 | 43 | ||
41 | // 为表格绑定事件 | 44 | // 为表格绑定事件 |
@@ -23,25 +23,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -23,25 +23,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
23 | columns: [ | 23 | columns: [ |
24 | [ | 24 | [ |
25 | {field: 'state', checkbox: true}, | 25 | {field: 'state', checkbox: true}, |
26 | - {field: 'id', title: __('Id')}, | ||
27 | - {field: 'category_id', title: __('Category_id')}, | ||
28 | - {field: 'title', title: __('Title')}, | ||
29 | - {field: 'keywords', title: __('Keywords')}, | ||
30 | - {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag}, | ||
31 | - {field: 'image', title: __('Image'), formatter: Table.api.formatter.image}, | ||
32 | - {field: 'icon', title: __('Icon'), formatter: Table.api.formatter.icon}, | ||
33 | - {field: 'views', title: __('Views')}, | ||
34 | - {field: 'comments', title: __('Comments')}, | ||
35 | - {field: 'weigh', title: __('Weigh')}, | 26 | + {field: 'id', title: __('Id'), operate: false}, |
27 | + {field: 'category_id', title: __('Category_id'), operate: '='}, | ||
28 | + {field: 'title', title: __('Title'), operate: 'LIKE %...%'}, | ||
29 | + {field: 'keywords', title: __('Keywords'), operate: 'LIKE %...%'}, | ||
30 | + {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag, operate: false}, | ||
31 | + {field: 'image', title: __('Image'), formatter: Table.api.formatter.image, operate: false}, | ||
32 | + {field: 'icon', title: __('Icon'), formatter: Table.api.formatter.icon, operate: false}, | ||
33 | + {field: 'views', title: __('Views'), operate: false}, | ||
34 | + {field: 'comments', title: __('Comments'), operate: false}, | ||
35 | + {field: 'weigh', title: __('Weigh'), operate: false}, | ||
36 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, | 36 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, |
37 | {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 37 | {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
38 | ] | 38 | ] |
39 | - ] | 39 | + ], |
40 | + //普通搜索 | ||
41 | + commonSearch: true, | ||
42 | + titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索 | ||
40 | }); | 43 | }); |
41 | 44 | ||
42 | // 为表格绑定事件 | 45 | // 为表格绑定事件 |
43 | Table.api.bindevent(table); | 46 | Table.api.bindevent(table); |
44 | - parent.window.Backend.api.sidebar({'auth/admin':44}); | ||
45 | }, | 47 | }, |
46 | add: function () { | 48 | add: function () { |
47 | Controller.api.bindevent(); | 49 | Controller.api.bindevent(); |
@@ -152,19 +152,19 @@ | @@ -152,19 +152,19 @@ | ||
152 | }); | 152 | }); |
153 | $.extend($.fn.bootstrapTable.locales, { | 153 | $.extend($.fn.bootstrapTable.locales, { |
154 | formatAdvancedSearch: function () { | 154 | formatAdvancedSearch: function () { |
155 | - return 'Advanced search'; | 155 | + return __('Advanced search'); |
156 | }, | 156 | }, |
157 | formatAdvancedSubmitButton: function () { | 157 | formatAdvancedSubmitButton: function () { |
158 | - return "Submit"; | 158 | + return __("Submit"); |
159 | }, | 159 | }, |
160 | formatAdvancedResetButton: function () { | 160 | formatAdvancedResetButton: function () { |
161 | - return "Reset"; | 161 | + return __("Reset"); |
162 | }, | 162 | }, |
163 | formatAdvancedCloseButton: function () { | 163 | formatAdvancedCloseButton: function () { |
164 | - return "Close"; | 164 | + return __("Close"); |
165 | }, | 165 | }, |
166 | formatAdvancedChoose: function () { | 166 | formatAdvancedChoose: function () { |
167 | - return "Choose"; | 167 | + return __("Choose"); |
168 | } | 168 | } |
169 | }); | 169 | }); |
170 | 170 |
1 | +/** | ||
2 | + * @author: pppscn <35696959@qq.com> | ||
3 | + * @version: v0.0.1 | ||
4 | + * | ||
5 | + * @update 2017-05-07 <http://git.oschina.net/pp/fastadmin> | ||
6 | + */ | ||
7 | + | ||
8 | +!function ($) { | ||
9 | + 'use strict'; | ||
10 | + | ||
11 | + var firstLoad = false; | ||
12 | + | ||
13 | + var sprintf = $.fn.bootstrapTable.utils.sprintf; | ||
14 | + | ||
15 | + var showCommonSearch = function (pColumns, that) { | ||
16 | + | ||
17 | + var vFormCommon = createFormCommon(pColumns, that), timeoutId = 0; | ||
18 | + | ||
19 | + var vModal = sprintf("<div id=\"commonSearchModalContent_%s\" class=\"well bs-component\">", that.options.idTable); | ||
20 | + vModal += vFormCommon.join(''); | ||
21 | + vModal += "</div>"; | ||
22 | + $("#myTabContent").before($(vModal)); | ||
23 | + | ||
24 | + if (that.options.sidePagination != 'server' || !that.options.url) { | ||
25 | + $('#' + that.options.idForm).off('keyup blur', 'input').on('keyup blur', 'input', function (event) { | ||
26 | + clearTimeout(timeoutId); | ||
27 | + timeoutId = setTimeout(function () { | ||
28 | + that.onColumnCommonSearch(event); | ||
29 | + }, that.options.searchTimeOut); | ||
30 | + }); | ||
31 | + } | ||
32 | + | ||
33 | + // 提交搜索 | ||
34 | + $("#btnSubmitCommon" + "_" + that.options.idTable).click(function (event) { | ||
35 | + that.onColumnCommonSearch(); | ||
36 | + }); | ||
37 | + | ||
38 | + // 重置搜索 | ||
39 | + $("#btnResetCommon" + "_" + that.options.idTable).click(function () { | ||
40 | + $("#commonSearchModalContent" + "_" + that.options.idTable + " form")[0].reset(); | ||
41 | + that.onColumnCommonSearch(); | ||
42 | + }); | ||
43 | + | ||
44 | + }; | ||
45 | + | ||
46 | + var createFormCommon = function (pColumns, that) { | ||
47 | + var htmlForm = []; | ||
48 | + var opList = ['=', '>', '>=', '<', '<=', '!=', 'LIKE', 'LIKE %...%', 'NOT LIKE', 'IN(...)', 'NOT IN(...)', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL']; | ||
49 | + //var selectList = []; | ||
50 | + //for (var i = 0; i < opList.length; i++) { | ||
51 | + // selectList.push("<option value='" + opList[i] + "'>" + opList[i] + "</option>"); | ||
52 | + //} | ||
53 | + //var selectHtml = selectList.join(''); | ||
54 | + htmlForm.push(sprintf('<form class="form-inline" id="%s" action="%s" >', that.options.idForm, that.options.actionForm)); | ||
55 | + htmlForm.push('<fieldset>'); | ||
56 | + if (that.options.titleForm.length > 0) | ||
57 | + htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm)); | ||
58 | + for (var i in pColumns) { | ||
59 | + var vObjCol = pColumns[i]; | ||
60 | + if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.visible && vObjCol.searchable && vObjCol.operate !== false) { | ||
61 | + htmlForm.push('<div class="form-group" style="margin:0 5px;">'); | ||
62 | + htmlForm.push(sprintf('<label for="%s" class="control-label" style="padding:0 10px">%s</label>', vObjCol.field, vObjCol.title)); | ||
63 | + if (that.options.sidePagination == 'server' && that.options.url) { | ||
64 | + //htmlForm.push('<div class="col-sm-2">'); | ||
65 | + //htmlForm.push(sprintf('<select class="form-control" name="field-%s" data-name="%s">%s</select>', vObjCol.field, vObjCol.field, selectHtml)); | ||
66 | + vObjCol.operate = (typeof vObjCol.operate === 'undefined' || $.inArray(vObjCol.operate, opList) === -1) ? '=' : vObjCol.operate; | ||
67 | + htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="field-%s" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate)); | ||
68 | + //htmlForm.push('</div>'); | ||
69 | + } | ||
70 | + | ||
71 | + //htmlForm.push('<div class="col-sm-8">'); | ||
72 | + if (vObjCol.searchList) { | ||
73 | + if (typeof vObjCol.searchList == 'function') { | ||
74 | + htmlForm.push(vObjCol.searchList.call(this, vObjCol)); | ||
75 | + } else { | ||
76 | + var isArray = vObjCol.searchList.constructor === Array; | ||
77 | + var searchList = []; | ||
78 | + searchList.push(sprintf('<option value="">%s</option>', $.fn.bootstrapTable.locales.formatCommonChoose())); | ||
79 | + $.each(vObjCol.searchList, function (key, value) { | ||
80 | + searchList.push("<option value='" + (isArray ? value : key) + "'>" + value + "</option>"); | ||
81 | + }); | ||
82 | + htmlForm.push(sprintf('<select class="form-control" name="%s">%s</select>', vObjCol.field, searchList.join(''))); | ||
83 | + } | ||
84 | + } else { | ||
85 | + htmlForm.push(sprintf('<input type="text" class="form-control" name="%s" placeholder="%s" id="%s">', vObjCol.field, vObjCol.title, vObjCol.field)); | ||
86 | + } | ||
87 | + | ||
88 | + //htmlForm.push('</div>'); | ||
89 | + htmlForm.push('</div>'); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + htmlForm.push('<div class="form-group" style="margin:0 5px;">'); | ||
94 | + htmlForm.push(createFormBtn(that).join('')); | ||
95 | + htmlForm.push('</div>'); | ||
96 | + htmlForm.push('</fieldset>'); | ||
97 | + htmlForm.push('</form>'); | ||
98 | + | ||
99 | + return htmlForm; | ||
100 | + }; | ||
101 | + | ||
102 | + var createFormBtn = function (that) { | ||
103 | + var htmlBtn = []; | ||
104 | + var searchSubmit = that.options.formatCommonSubmitButton(); | ||
105 | + var searchReset = that.options.formatCommonResetButton(); | ||
106 | + var searchClose = that.options.formatCommonCloseButton(); | ||
107 | + htmlBtn.push('<div class="form-group">'); | ||
108 | + htmlBtn.push('<div class="col-sm-12 text-center">'); | ||
109 | + if (that.options.sidePagination == 'server' && that.options.url) { | ||
110 | + htmlBtn.push(sprintf('<button type="button" id="btnSubmitCommon%s" class="btn btn-success" >%s</button> ', "_" + that.options.idTable, searchSubmit)); | ||
111 | + htmlBtn.push(sprintf('<button type="button" id="btnResetCommon%s" class="btn btn-default" >%s</button> ', "_" + that.options.idTable, searchReset)); | ||
112 | + } else { | ||
113 | + htmlBtn.push(sprintf('<button type="button" id="btnCloseCommon%s" data-dismiss="modal" class="btn btn-default" >%s</button> ', "_" + that.options.idTable, searchClose)); | ||
114 | + } | ||
115 | + htmlBtn.push('</div>'); | ||
116 | + htmlBtn.push('</div>'); | ||
117 | + return htmlBtn; | ||
118 | + }; | ||
119 | + | ||
120 | + $.extend($.fn.bootstrapTable.defaults, { | ||
121 | + commonSearch: false, | ||
122 | + idForm: 'commonSearch', | ||
123 | + titleForm: __("Common search"), | ||
124 | + actionForm: '', | ||
125 | + idTable: undefined, | ||
126 | + onColumnCommonSearch: function (field, text) { | ||
127 | + return false; | ||
128 | + } | ||
129 | + }); | ||
130 | + | ||
131 | + $.extend($.fn.bootstrapTable.defaults.icons, { | ||
132 | + commonSearchIcon: 'glyphicon-search' | ||
133 | + }); | ||
134 | + | ||
135 | + $.extend($.fn.bootstrapTable.Constructor.EVENTS, { | ||
136 | + 'column-common-search.bs.table': 'onColumnCommonSearch' | ||
137 | + }); | ||
138 | + | ||
139 | + $.extend($.fn.bootstrapTable.locales, { | ||
140 | + formatCommonSearch: function () { | ||
141 | + return __("Common search"); | ||
142 | + }, | ||
143 | + formatCommonSubmitButton: function () { | ||
144 | + return __("Submit"); | ||
145 | + }, | ||
146 | + formatCommonResetButton: function () { | ||
147 | + return __("Reset"); | ||
148 | + }, | ||
149 | + formatCommonCloseButton: function () { | ||
150 | + return __("Close"); | ||
151 | + }, | ||
152 | + formatCommonChoose: function () { | ||
153 | + return __("Choose"); | ||
154 | + } | ||
155 | + }); | ||
156 | + | ||
157 | + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); | ||
158 | + | ||
159 | + var BootstrapTable = $.fn.bootstrapTable.Constructor, | ||
160 | + _initToolbar = BootstrapTable.prototype.initToolbar, | ||
161 | + _load = BootstrapTable.prototype.load, | ||
162 | + _initSearch = BootstrapTable.prototype.initSearch; | ||
163 | + | ||
164 | + BootstrapTable.prototype.initToolbar = function () { | ||
165 | + _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); | ||
166 | + | ||
167 | + if (!this.options.search) { | ||
168 | + return; | ||
169 | + } | ||
170 | + | ||
171 | + if (!this.options.commonSearch) { | ||
172 | + return; | ||
173 | + } | ||
174 | + | ||
175 | + if (!this.options.idTable) { | ||
176 | + return; | ||
177 | + } | ||
178 | + | ||
179 | + var that = this; | ||
180 | + | ||
181 | + showCommonSearch(that.columns, that); | ||
182 | + }; | ||
183 | + | ||
184 | + BootstrapTable.prototype.load = function (data) { | ||
185 | + _load.apply(this, Array.prototype.slice.apply(arguments)); | ||
186 | + | ||
187 | + if (!this.options.commonSearch) { | ||
188 | + return; | ||
189 | + } | ||
190 | + | ||
191 | + if (typeof this.options.idTable === 'undefined') { | ||
192 | + return; | ||
193 | + } else { | ||
194 | + if (!firstLoad) { | ||
195 | + var height = parseInt($(".bootstrap-table").height()); | ||
196 | + height += 10; | ||
197 | + $("#" + this.options.idTable).bootstrapTable("resetView", {height: height}); | ||
198 | + firstLoad = true; | ||
199 | + } | ||
200 | + } | ||
201 | + }; | ||
202 | + | ||
203 | + BootstrapTable.prototype.initSearch = function () { | ||
204 | + _initSearch.apply(this, Array.prototype.slice.apply(arguments)); | ||
205 | + | ||
206 | + if (!this.options.commonSearch) { | ||
207 | + return; | ||
208 | + } | ||
209 | + | ||
210 | + var that = this; | ||
211 | + var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial; | ||
212 | + this.data = fp ? $.grep(this.data, function (item, i) { | ||
213 | + for (var key in fp) { | ||
214 | + var fval = fp[key].toLowerCase(); | ||
215 | + var value = item[key]; | ||
216 | + value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header, | ||
217 | + that.header.formatters[$.inArray(key, that.header.fields)], | ||
218 | + [value, item, i], value); | ||
219 | + | ||
220 | + if (!($.inArray(key, that.header.fields) !== -1 && | ||
221 | + (typeof value === 'string' || typeof value === 'number') && | ||
222 | + (value + '').toLowerCase().indexOf(fval) !== -1)) { | ||
223 | + return false; | ||
224 | + } | ||
225 | + } | ||
226 | + return true; | ||
227 | + }) : this.data; | ||
228 | + }; | ||
229 | + | ||
230 | + BootstrapTable.prototype.onColumnCommonSearch = function (event) { | ||
231 | + if (typeof event === 'undefined') { | ||
232 | + var op = {}; | ||
233 | + var filter = {}; | ||
234 | + $("#commonSearchModalContent_" + this.options.idTable + " input.operate").each(function () { | ||
235 | + var name = $(this).data("name"); | ||
236 | + var sym = $(this).val(); | ||
237 | + var obj = $("[name='" + name + "']"); | ||
238 | + if (obj.size() == 0) | ||
239 | + return true; | ||
240 | + var value = obj.size() > 1 ? $("[name='" + name + "']:checked").val() : obj.val(); | ||
241 | + if (value == '' && sym.indexOf("NULL") == -1) { | ||
242 | + return true; | ||
243 | + } | ||
244 | + | ||
245 | + op[name] = sym; | ||
246 | + filter[name] = value; | ||
247 | + }); | ||
248 | + // 追加查询关键字 | ||
249 | + this.options.pageNumber = 1; | ||
250 | + this.refresh({query: {filter: JSON.stringify(filter), op: JSON.stringify(op)}}); | ||
251 | + | ||
252 | + } else { | ||
253 | + var text = $.trim($(event.currentTarget).val()); | ||
254 | + var $field = $(event.currentTarget)[0].id; | ||
255 | + | ||
256 | + if ($.isEmptyObject(this.filterColumnsPartial)) { | ||
257 | + this.filterColumnsPartial = {}; | ||
258 | + } | ||
259 | + if (text) { | ||
260 | + this.filterColumnsPartial[$field] = text; | ||
261 | + } else { | ||
262 | + delete this.filterColumnsPartial[$field]; | ||
263 | + } | ||
264 | + this.options.pageNumber = 1; | ||
265 | + this.onSearch(event); | ||
266 | +// this.updatePagination(); | ||
267 | + this.trigger('column-common-search', $field, text); | ||
268 | + } | ||
269 | + }; | ||
270 | +}(jQuery); |
@@ -34,6 +34,7 @@ require.config({ | @@ -34,6 +34,7 @@ require.config({ | ||
34 | 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min', | 34 | 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min', |
35 | 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile', | 35 | 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile', |
36 | 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch', | 36 | 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch', |
37 | + 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch', | ||
37 | 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN', | 38 | 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN', |
38 | 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min', | 39 | 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min', |
39 | 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min', | 40 | 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min', |
@@ -78,6 +79,10 @@ require.config({ | @@ -78,6 +79,10 @@ require.config({ | ||
78 | deps: ['bootstrap-table'], | 79 | deps: ['bootstrap-table'], |
79 | exports: '$.fn.bootstrapTable.defaults' | 80 | exports: '$.fn.bootstrapTable.defaults' |
80 | }, | 81 | }, |
82 | + 'bootstrap-table-commonsearch': { | ||
83 | + deps: ['bootstrap-table'], | ||
84 | + exports: '$.fn.bootstrapTable.defaults' | ||
85 | + }, | ||
81 | 'tableexport': { | 86 | 'tableexport': { |
82 | deps: ['jquery'], | 87 | deps: ['jquery'], |
83 | exports: '$.fn.extend' | 88 | exports: '$.fn.extend' |
此 diff 太大无法显示。
@@ -34,6 +34,7 @@ require.config({ | @@ -34,6 +34,7 @@ require.config({ | ||
34 | 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min', | 34 | 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min', |
35 | 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile', | 35 | 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile', |
36 | 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch', | 36 | 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch', |
37 | + 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch', | ||
37 | 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN', | 38 | 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN', |
38 | 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min', | 39 | 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min', |
39 | 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min', | 40 | 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min', |
@@ -78,6 +79,10 @@ require.config({ | @@ -78,6 +79,10 @@ require.config({ | ||
78 | deps: ['bootstrap-table'], | 79 | deps: ['bootstrap-table'], |
79 | exports: '$.fn.bootstrapTable.defaults' | 80 | exports: '$.fn.bootstrapTable.defaults' |
80 | }, | 81 | }, |
82 | + 'bootstrap-table-commonsearch': { | ||
83 | + deps: ['bootstrap-table'], | ||
84 | + exports: '$.fn.bootstrapTable.defaults' | ||
85 | + }, | ||
81 | 'tableexport': { | 86 | 'tableexport': { |
82 | deps: ['jquery'], | 87 | deps: ['jquery'], |
83 | exports: '$.fn.extend' | 88 | exports: '$.fn.extend' |
@@ -51,6 +51,7 @@ require.config({ | @@ -51,6 +51,7 @@ require.config({ | ||
51 | 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min', | 51 | 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min', |
52 | 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile', | 52 | 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile', |
53 | 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch', | 53 | 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch', |
54 | + 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch', | ||
54 | 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN', | 55 | 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN', |
55 | 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min', | 56 | 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min', |
56 | 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min', | 57 | 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min', |
@@ -95,6 +96,10 @@ require.config({ | @@ -95,6 +96,10 @@ require.config({ | ||
95 | deps: ['bootstrap-table'], | 96 | deps: ['bootstrap-table'], |
96 | exports: '$.fn.bootstrapTable.defaults' | 97 | exports: '$.fn.bootstrapTable.defaults' |
97 | }, | 98 | }, |
99 | + 'bootstrap-table-commonsearch': { | ||
100 | + deps: ['bootstrap-table'], | ||
101 | + exports: '$.fn.bootstrapTable.defaults' | ||
102 | + }, | ||
98 | 'tableexport': { | 103 | 'tableexport': { |
99 | deps: ['jquery'], | 104 | deps: ['jquery'], |
100 | exports: '$.fn.extend' | 105 | exports: '$.fn.extend' |
@@ -203,7 +208,7 @@ define('../libs/require-css/css.min',[],function(){if("undefined"==typeof window | @@ -203,7 +208,7 @@ define('../libs/require-css/css.min',[],function(){if("undefined"==typeof window | ||
203 | @Author:贤心 | 208 | @Author:贤心 |
204 | @Site:http://layer.layui.com | 209 | @Site:http://layer.layui.com |
205 | @License:LGPL | 210 | @License:LGPL |
206 | - | 211 | + |
207 | */ | 212 | */ |
208 | 213 | ||
209 | ;!function(window, undefined){ | 214 | ;!function(window, undefined){ |
@@ -239,39 +244,39 @@ var layer = { | @@ -239,39 +244,39 @@ var layer = { | ||
239 | layer.cache = ready.config = $.extend({}, ready.config, options); | 244 | layer.cache = ready.config = $.extend({}, ready.config, options); |
240 | layer.path = ready.config.path || layer.path; | 245 | layer.path = ready.config.path || layer.path; |
241 | typeof options.extend === 'string' && (options.extend = [options.extend]); | 246 | typeof options.extend === 'string' && (options.extend = [options.extend]); |
242 | - | 247 | + |
243 | if(ready.config.path) layer.ready(); | 248 | if(ready.config.path) layer.ready(); |
244 | - | 249 | + |
245 | if(!options.extend) return this; | 250 | if(!options.extend) return this; |
246 | - | ||
247 | - isLayui | 251 | + |
252 | + isLayui | ||
248 | ? layui.addcss('modules/layer/' + options.extend) | 253 | ? layui.addcss('modules/layer/' + options.extend) |
249 | : layer.link('skin/' + options.extend); | 254 | : layer.link('skin/' + options.extend); |
250 | - | 255 | + |
251 | return this; | 256 | return this; |
252 | }, | 257 | }, |
253 | - | 258 | + |
254 | //载入CSS配件 | 259 | //载入CSS配件 |
255 | link: function(href, fn, cssname){ | 260 | link: function(href, fn, cssname){ |
256 | - | 261 | + |
257 | //未设置路径,则不主动加载css | 262 | //未设置路径,则不主动加载css |
258 | if(!layer.path) return; | 263 | if(!layer.path) return; |
259 | - | 264 | + |
260 | var head = $('head')[0], link = document.createElement('link'); | 265 | var head = $('head')[0], link = document.createElement('link'); |
261 | if(typeof fn === 'string') cssname = fn; | 266 | if(typeof fn === 'string') cssname = fn; |
262 | var app = (cssname || href).replace(/\.|\//g, ''); | 267 | var app = (cssname || href).replace(/\.|\//g, ''); |
263 | var id = 'layuicss-'+app, timeout = 0; | 268 | var id = 'layuicss-'+app, timeout = 0; |
264 | - | 269 | + |
265 | link.rel = 'stylesheet'; | 270 | link.rel = 'stylesheet'; |
266 | link.href = layer.path + href; | 271 | link.href = layer.path + href; |
267 | link.id = id; | 272 | link.id = id; |
268 | - | 273 | + |
269 | if(!$('#'+ id)[0]){ | 274 | if(!$('#'+ id)[0]){ |
270 | head.appendChild(link); | 275 | head.appendChild(link); |
271 | } | 276 | } |
272 | - | 277 | + |
273 | if(typeof fn !== 'function') return; | 278 | if(typeof fn !== 'function') return; |
274 | - | 279 | + |
275 | //轮询css是否加载完毕 | 280 | //轮询css是否加载完毕 |
276 | (function poll() { | 281 | (function poll() { |
277 | if(++timeout > 8 * 1000 / 100){ | 282 | if(++timeout > 8 * 1000 / 100){ |
@@ -280,14 +285,14 @@ var layer = { | @@ -280,14 +285,14 @@ var layer = { | ||
280 | parseInt($('#'+id).css('width')) === 1989 ? fn() : setTimeout(poll, 100); | 285 | parseInt($('#'+id).css('width')) === 1989 ? fn() : setTimeout(poll, 100); |
281 | }()); | 286 | }()); |
282 | }, | 287 | }, |
283 | - | 288 | + |
284 | ready: function(callback){ | 289 | ready: function(callback){ |
285 | var cssname = 'skinlayercss', ver = '1110'; | 290 | var cssname = 'skinlayercss', ver = '1110'; |
286 | isLayui ? layui.addcss('modules/layer/default/layer.css?v='+layer.v+ver, callback, cssname) | 291 | isLayui ? layui.addcss('modules/layer/default/layer.css?v='+layer.v+ver, callback, cssname) |
287 | : layer.link('skin/default/layer.css?v='+layer.v+ver, callback, cssname); | 292 | : layer.link('skin/default/layer.css?v='+layer.v+ver, callback, cssname); |
288 | return this; | 293 | return this; |
289 | }, | 294 | }, |
290 | - | 295 | + |
291 | //各种快捷引用 | 296 | //各种快捷引用 |
292 | alert: function(content, options, yes){ | 297 | alert: function(content, options, yes){ |
293 | var type = typeof options === 'function'; | 298 | var type = typeof options === 'function'; |
@@ -296,9 +301,9 @@ var layer = { | @@ -296,9 +301,9 @@ var layer = { | ||
296 | content: content, | 301 | content: content, |
297 | yes: yes | 302 | yes: yes |
298 | }, type ? {} : options)); | 303 | }, type ? {} : options)); |
299 | - }, | ||
300 | - | ||
301 | - confirm: function(content, options, yes, cancel){ | 304 | + }, |
305 | + | ||
306 | + confirm: function(content, options, yes, cancel){ | ||
302 | var type = typeof options === 'function'; | 307 | var type = typeof options === 'function'; |
303 | if(type){ | 308 | if(type){ |
304 | cancel = yes; | 309 | cancel = yes; |
@@ -311,7 +316,7 @@ var layer = { | @@ -311,7 +316,7 @@ var layer = { | ||
311 | btn2: cancel | 316 | btn2: cancel |
312 | }, type ? {} : options)); | 317 | }, type ? {} : options)); |
313 | }, | 318 | }, |
314 | - | 319 | + |
315 | msg: function(content, options, end){ //最常用提示层 | 320 | msg: function(content, options, end){ //最常用提示层 |
316 | var type = typeof options === 'function', rskin = ready.config.skin; | 321 | var type = typeof options === 'function', rskin = ready.config.skin; |
317 | var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg'; | 322 | var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg'; |
@@ -336,9 +341,9 @@ var layer = { | @@ -336,9 +341,9 @@ var layer = { | ||
336 | options.skin = skin + ' ' + (options.skin||'layui-layer-hui'); | 341 | options.skin = skin + ' ' + (options.skin||'layui-layer-hui'); |
337 | } | 342 | } |
338 | return options; | 343 | return options; |
339 | - }())); | 344 | + }())); |
340 | }, | 345 | }, |
341 | - | 346 | + |
342 | load: function(icon, options){ | 347 | load: function(icon, options){ |
343 | return layer.open($.extend({ | 348 | return layer.open($.extend({ |
344 | type: 3, | 349 | type: 3, |
@@ -346,8 +351,8 @@ var layer = { | @@ -346,8 +351,8 @@ var layer = { | ||
346 | resize: false, | 351 | resize: false, |
347 | shade: 0.01 | 352 | shade: 0.01 |
348 | }, options)); | 353 | }, options)); |
349 | - }, | ||
350 | - | 354 | + }, |
355 | + | ||
351 | tips: function(content, follow, options){ | 356 | tips: function(content, follow, options){ |
352 | return layer.open($.extend({ | 357 | return layer.open($.extend({ |
353 | type: 4, | 358 | type: 4, |
@@ -362,7 +367,7 @@ var layer = { | @@ -362,7 +367,7 @@ var layer = { | ||
362 | } | 367 | } |
363 | }; | 368 | }; |
364 | 369 | ||
365 | -var Class = function(setings){ | 370 | +var Class = function(setings){ |
366 | var that = this; | 371 | var that = this; |
367 | that.index = ++layer.index; | 372 | that.index = ++layer.index; |
368 | that.config = $.extend({}, that.config, ready.config, setings); | 373 | that.config = $.extend({}, that.config, ready.config, setings); |
@@ -388,7 +393,7 @@ Class.pt.config = { | @@ -388,7 +393,7 @@ Class.pt.config = { | ||
388 | area: 'auto', | 393 | area: 'auto', |
389 | closeBtn: 1, | 394 | closeBtn: 1, |
390 | time: 0, //0表示不自动关闭 | 395 | time: 0, //0表示不自动关闭 |
391 | - zIndex: 19891014, | 396 | + zIndex: 19891014, |
392 | maxWidth: 360, | 397 | maxWidth: 360, |
393 | anim: 0, | 398 | anim: 0, |
394 | icon: -1, | 399 | icon: -1, |
@@ -403,15 +408,15 @@ Class.pt.vessel = function(conType, callback){ | @@ -403,15 +408,15 @@ Class.pt.vessel = function(conType, callback){ | ||
403 | var that = this, times = that.index, config = that.config; | 408 | var that = this, times = that.index, config = that.config; |
404 | var zIndex = config.zIndex + times, titype = typeof config.title === 'object'; | 409 | var zIndex = config.zIndex + times, titype = typeof config.title === 'object'; |
405 | var ismax = config.maxmin && (config.type === 1 || config.type === 2); | 410 | var ismax = config.maxmin && (config.type === 1 || config.type === 2); |
406 | - var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">' | ||
407 | - + (titype ? config.title[0] : config.title) | 411 | + var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">' |
412 | + + (titype ? config.title[0] : config.title) | ||
408 | + '</div>' : ''); | 413 | + '</div>' : ''); |
409 | - | 414 | + |
410 | config.zIndex = zIndex; | 415 | config.zIndex = zIndex; |
411 | callback([ | 416 | callback([ |
412 | //遮罩 | 417 | //遮罩 |
413 | config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '', | 418 | config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '', |
414 | - | 419 | + |
415 | //主体 | 420 | //主体 |
416 | '<div class="'+ doms[0] + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fixed ? '' : ';position:absolute;') +'">' | 421 | '<div class="'+ doms[0] + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fixed ? '' : ';position:absolute;') +'">' |
417 | + (conType && config.type != 2 ? '' : titleHTML) | 422 | + (conType && config.type != 2 ? '' : titleHTML) |
@@ -446,22 +451,22 @@ Class.pt.creat = function(){ | @@ -446,22 +451,22 @@ Class.pt.creat = function(){ | ||
446 | ,content = config.content | 451 | ,content = config.content |
447 | ,conType = typeof content === 'object' | 452 | ,conType = typeof content === 'object' |
448 | ,body = $('body'); | 453 | ,body = $('body'); |
449 | - | 454 | + |
450 | if($('#'+config.id)[0]) return; | 455 | if($('#'+config.id)[0]) return; |
451 | 456 | ||
452 | if(typeof config.area === 'string'){ | 457 | if(typeof config.area === 'string'){ |
453 | config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; | 458 | config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; |
454 | } | 459 | } |
455 | - | 460 | + |
456 | //anim兼容旧版shift | 461 | //anim兼容旧版shift |
457 | if(config.shift){ | 462 | if(config.shift){ |
458 | config.anim = config.shift; | 463 | config.anim = config.shift; |
459 | } | 464 | } |
460 | - | 465 | + |
461 | if(layer.ie == 6){ | 466 | if(layer.ie == 6){ |
462 | config.fixed = false; | 467 | config.fixed = false; |
463 | } | 468 | } |
464 | - | 469 | + |
465 | switch(config.type){ | 470 | switch(config.type){ |
466 | case 0: | 471 | case 0: |
467 | config.btn = ('btn' in config) ? config.btn : ready.btn[0]; | 472 | config.btn = ('btn' in config) ? config.btn : ready.btn[0]; |
@@ -486,7 +491,7 @@ Class.pt.creat = function(){ | @@ -486,7 +491,7 @@ Class.pt.creat = function(){ | ||
486 | config.tipsMore || layer.closeAll('tips'); | 491 | config.tipsMore || layer.closeAll('tips'); |
487 | break; | 492 | break; |
488 | } | 493 | } |
489 | - | 494 | + |
490 | //建立容器 | 495 | //建立容器 |
491 | that.vessel(conType, function(html, titleHTML, moveElem){ | 496 | that.vessel(conType, function(html, titleHTML, moveElem){ |
492 | body.append(html[0]); | 497 | body.append(html[0]); |
@@ -516,12 +521,12 @@ Class.pt.creat = function(){ | @@ -516,12 +521,12 @@ Class.pt.creat = function(){ | ||
516 | config.type == 4 && that.tips(); | 521 | config.type == 4 && that.tips(); |
517 | }); | 522 | }); |
518 | } | 523 | } |
519 | - | 524 | + |
520 | config.time <= 0 || setTimeout(function(){ | 525 | config.time <= 0 || setTimeout(function(){ |
521 | layer.close(that.index) | 526 | layer.close(that.index) |
522 | }, config.time); | 527 | }, config.time); |
523 | that.move().callback(); | 528 | that.move().callback(); |
524 | - | 529 | + |
525 | //为兼容jQuery3.0的css动画影响元素尺寸计算 | 530 | //为兼容jQuery3.0的css动画影响元素尺寸计算 |
526 | if(doms.anim[config.anim]){ | 531 | if(doms.anim[config.anim]){ |
527 | that.layero.addClass(doms.anim[config.anim]).data('anim', true); | 532 | that.layero.addClass(doms.anim[config.anim]).data('anim', true); |
@@ -546,7 +551,7 @@ Class.pt.auto = function(index){ | @@ -546,7 +551,7 @@ Class.pt.auto = function(index){ | ||
546 | elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding'))|0)); | 551 | elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding'))|0)); |
547 | } | 552 | } |
548 | switch(config.type){ | 553 | switch(config.type){ |
549 | - case 2: | 554 | + case 2: |
550 | setHeight('iframe'); | 555 | setHeight('iframe'); |
551 | break; | 556 | break; |
552 | default: | 557 | default: |
@@ -570,12 +575,12 @@ Class.pt.offset = function(){ | @@ -570,12 +575,12 @@ Class.pt.offset = function(){ | ||
570 | var type = typeof config.offset === 'object'; | 575 | var type = typeof config.offset === 'object'; |
571 | that.offsetTop = (win.height() - area[1])/2; | 576 | that.offsetTop = (win.height() - area[1])/2; |
572 | that.offsetLeft = (win.width() - area[0])/2; | 577 | that.offsetLeft = (win.width() - area[0])/2; |
573 | - | 578 | + |
574 | if(type){ | 579 | if(type){ |
575 | that.offsetTop = config.offset[0]; | 580 | that.offsetTop = config.offset[0]; |
576 | that.offsetLeft = config.offset[1]||that.offsetLeft; | 581 | that.offsetLeft = config.offset[1]||that.offsetLeft; |
577 | } else if(config.offset !== 'auto'){ | 582 | } else if(config.offset !== 'auto'){ |
578 | - | 583 | + |
579 | if(config.offset === 't'){ //上 | 584 | if(config.offset === 't'){ //上 |
580 | that.offsetTop = 0; | 585 | that.offsetTop = 0; |
581 | } else if(config.offset === 'r'){ //右 | 586 | } else if(config.offset === 'r'){ //右 |
@@ -599,20 +604,20 @@ Class.pt.offset = function(){ | @@ -599,20 +604,20 @@ Class.pt.offset = function(){ | ||
599 | } else { | 604 | } else { |
600 | that.offsetTop = config.offset; | 605 | that.offsetTop = config.offset; |
601 | } | 606 | } |
602 | - | 607 | + |
603 | } | 608 | } |
604 | - | 609 | + |
605 | if(!config.fixed){ | 610 | if(!config.fixed){ |
606 | - that.offsetTop = /%$/.test(that.offsetTop) ? | 611 | + that.offsetTop = /%$/.test(that.offsetTop) ? |
607 | win.height()*parseFloat(that.offsetTop)/100 | 612 | win.height()*parseFloat(that.offsetTop)/100 |
608 | : parseFloat(that.offsetTop); | 613 | : parseFloat(that.offsetTop); |
609 | - that.offsetLeft = /%$/.test(that.offsetLeft) ? | 614 | + that.offsetLeft = /%$/.test(that.offsetLeft) ? |
610 | win.width()*parseFloat(that.offsetLeft)/100 | 615 | win.width()*parseFloat(that.offsetLeft)/100 |
611 | : parseFloat(that.offsetLeft); | 616 | : parseFloat(that.offsetLeft); |
612 | that.offsetTop += win.scrollTop(); | 617 | that.offsetTop += win.scrollTop(); |
613 | that.offsetLeft += win.scrollLeft(); | 618 | that.offsetLeft += win.scrollLeft(); |
614 | } | 619 | } |
615 | - | 620 | + |
616 | if(layero.attr('minLeft')){ | 621 | if(layero.attr('minLeft')){ |
617 | that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0); | 622 | that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0); |
618 | that.offsetLeft = layero.css('left'); | 623 | that.offsetLeft = layero.css('left'); |
@@ -632,10 +637,10 @@ Class.pt.tips = function(){ | @@ -632,10 +637,10 @@ Class.pt.tips = function(){ | ||
632 | top: follow.offset().top, | 637 | top: follow.offset().top, |
633 | left: follow.offset().left | 638 | left: follow.offset().left |
634 | }, tipsG = layero.find('.layui-layer-TipsG'); | 639 | }, tipsG = layero.find('.layui-layer-TipsG'); |
635 | - | 640 | + |
636 | var guide = config.tips[0]; | 641 | var guide = config.tips[0]; |
637 | config.tips[1] || tipsG.remove(); | 642 | config.tips[1] || tipsG.remove(); |
638 | - | 643 | + |
639 | goal.autoLeft = function(){ | 644 | goal.autoLeft = function(){ |
640 | if(goal.left + layArea[0] - win.width() > 0){ | 645 | if(goal.left + layArea[0] - win.width() > 0){ |
641 | goal.tipLeft = goal.left + goal.width - layArea[0]; | 646 | goal.tipLeft = goal.left + goal.width - layArea[0]; |
@@ -644,16 +649,16 @@ Class.pt.tips = function(){ | @@ -644,16 +649,16 @@ Class.pt.tips = function(){ | ||
644 | goal.tipLeft = goal.left; | 649 | goal.tipLeft = goal.left; |
645 | }; | 650 | }; |
646 | }; | 651 | }; |
647 | - | 652 | + |
648 | //辨别tips的方位 | 653 | //辨别tips的方位 |
649 | - goal.where = [function(){ //上 | 654 | + goal.where = [function(){ //上 |
650 | goal.autoLeft(); | 655 | goal.autoLeft(); |
651 | goal.tipTop = goal.top - layArea[1] - 10; | 656 | goal.tipTop = goal.top - layArea[1] - 10; |
652 | tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); | 657 | tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); |
653 | }, function(){ //右 | 658 | }, function(){ //右 |
654 | goal.tipLeft = goal.left + goal.width + 10; | 659 | goal.tipLeft = goal.left + goal.width + 10; |
655 | goal.tipTop = goal.top; | 660 | goal.tipTop = goal.top; |
656 | - tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); | 661 | + tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); |
657 | }, function(){ //下 | 662 | }, function(){ //下 |
658 | goal.autoLeft(); | 663 | goal.autoLeft(); |
659 | goal.tipTop = goal.top + goal.height + 10; | 664 | goal.tipTop = goal.top + goal.height + 10; |
@@ -664,7 +669,7 @@ Class.pt.tips = function(){ | @@ -664,7 +669,7 @@ Class.pt.tips = function(){ | ||
664 | tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); | 669 | tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); |
665 | }]; | 670 | }]; |
666 | goal.where[guide-1](); | 671 | goal.where[guide-1](); |
667 | - | 672 | + |
668 | /* 8*2为小三角形占据的空间 */ | 673 | /* 8*2为小三角形占据的空间 */ |
669 | if(guide === 1){ | 674 | if(guide === 1){ |
670 | goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2](); | 675 | goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2](); |
@@ -677,11 +682,11 @@ Class.pt.tips = function(){ | @@ -677,11 +682,11 @@ Class.pt.tips = function(){ | ||
677 | } | 682 | } |
678 | 683 | ||
679 | layero.find('.'+doms[5]).css({ | 684 | layero.find('.'+doms[5]).css({ |
680 | - 'background-color': config.tips[1], | 685 | + 'background-color': config.tips[1], |
681 | 'padding-right': (config.closeBtn ? '30px' : '') | 686 | 'padding-right': (config.closeBtn ? '30px' : '') |
682 | }); | 687 | }); |
683 | layero.css({ | 688 | layero.css({ |
684 | - left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0), | 689 | + left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0), |
685 | top: goal.tipTop - (config.fixed ? win.scrollTop() : 0) | 690 | top: goal.tipTop - (config.fixed ? win.scrollTop() : 0) |
686 | }); | 691 | }); |
687 | } | 692 | } |
@@ -695,7 +700,7 @@ Class.pt.move = function(){ | @@ -695,7 +700,7 @@ Class.pt.move = function(){ | ||
695 | ,moveElem = layero.find(config.move) | 700 | ,moveElem = layero.find(config.move) |
696 | ,resizeElem = layero.find('.layui-layer-resize') | 701 | ,resizeElem = layero.find('.layui-layer-resize') |
697 | ,dict = {}; | 702 | ,dict = {}; |
698 | - | 703 | + |
699 | if(config.move){ | 704 | if(config.move){ |
700 | moveElem.css('cursor', 'move'); | 705 | moveElem.css('cursor', 'move'); |
701 | } | 706 | } |
@@ -711,7 +716,7 @@ Class.pt.move = function(){ | @@ -711,7 +716,7 @@ Class.pt.move = function(){ | ||
711 | ready.moveElem.css('cursor', 'move').show(); | 716 | ready.moveElem.css('cursor', 'move').show(); |
712 | } | 717 | } |
713 | }); | 718 | }); |
714 | - | 719 | + |
715 | resizeElem.on('mousedown', function(e){ | 720 | resizeElem.on('mousedown', function(e){ |
716 | e.preventDefault(); | 721 | e.preventDefault(); |
717 | dict.resizeStart = true; | 722 | dict.resizeStart = true; |
@@ -722,7 +727,7 @@ Class.pt.move = function(){ | @@ -722,7 +727,7 @@ Class.pt.move = function(){ | ||
722 | ]; | 727 | ]; |
723 | ready.moveElem.css('cursor', 'se-resize').show(); | 728 | ready.moveElem.css('cursor', 'se-resize').show(); |
724 | }); | 729 | }); |
725 | - | 730 | + |
726 | _DOC.on('mousemove', function(e){ | 731 | _DOC.on('mousemove', function(e){ |
727 | 732 | ||
728 | //拖拽移动 | 733 | //拖拽移动 |
@@ -730,35 +735,35 @@ Class.pt.move = function(){ | @@ -730,35 +735,35 @@ Class.pt.move = function(){ | ||
730 | var X = e.clientX - dict.offset[0] | 735 | var X = e.clientX - dict.offset[0] |
731 | ,Y = e.clientY - dict.offset[1] | 736 | ,Y = e.clientY - dict.offset[1] |
732 | ,fixed = layero.css('position') === 'fixed'; | 737 | ,fixed = layero.css('position') === 'fixed'; |
733 | - | 738 | + |
734 | e.preventDefault(); | 739 | e.preventDefault(); |
735 | - | 740 | + |
736 | dict.stX = fixed ? 0 : win.scrollLeft(); | 741 | dict.stX = fixed ? 0 : win.scrollLeft(); |
737 | dict.stY = fixed ? 0 : win.scrollTop(); | 742 | dict.stY = fixed ? 0 : win.scrollTop(); |
738 | 743 | ||
739 | //控制元素不被拖出窗口外 | 744 | //控制元素不被拖出窗口外 |
740 | if(!config.moveOut){ | 745 | if(!config.moveOut){ |
741 | var setRig = win.width() - layero.outerWidth() + dict.stX | 746 | var setRig = win.width() - layero.outerWidth() + dict.stX |
742 | - ,setBot = win.height() - layero.outerHeight() + dict.stY; | 747 | + ,setBot = win.height() - layero.outerHeight() + dict.stY; |
743 | X < dict.stX && (X = dict.stX); | 748 | X < dict.stX && (X = dict.stX); |
744 | - X > setRig && (X = setRig); | 749 | + X > setRig && (X = setRig); |
745 | Y < dict.stY && (Y = dict.stY); | 750 | Y < dict.stY && (Y = dict.stY); |
746 | Y > setBot && (Y = setBot); | 751 | Y > setBot && (Y = setBot); |
747 | } | 752 | } |
748 | - | 753 | + |
749 | layero.css({ | 754 | layero.css({ |
750 | left: X | 755 | left: X |
751 | ,top: Y | 756 | ,top: Y |
752 | }); | 757 | }); |
753 | } | 758 | } |
754 | - | 759 | + |
755 | //Resize | 760 | //Resize |
756 | if(config.resize && dict.resizeStart){ | 761 | if(config.resize && dict.resizeStart){ |
757 | var X = e.clientX - dict.offset[0] | 762 | var X = e.clientX - dict.offset[0] |
758 | ,Y = e.clientY - dict.offset[1]; | 763 | ,Y = e.clientY - dict.offset[1]; |
759 | - | 764 | + |
760 | e.preventDefault(); | 765 | e.preventDefault(); |
761 | - | 766 | + |
762 | layer.style(that.index, { | 767 | layer.style(that.index, { |
763 | width: dict.area[0] + X | 768 | width: dict.area[0] + X |
764 | ,height: dict.area[1] + Y | 769 | ,height: dict.area[1] + Y |
@@ -776,7 +781,7 @@ Class.pt.move = function(){ | @@ -776,7 +781,7 @@ Class.pt.move = function(){ | ||
776 | ready.moveElem.hide(); | 781 | ready.moveElem.hide(); |
777 | } | 782 | } |
778 | }); | 783 | }); |
779 | - | 784 | + |
780 | return that; | 785 | return that; |
781 | }; | 786 | }; |
782 | 787 | ||
@@ -793,7 +798,7 @@ Class.pt.callback = function(){ | @@ -793,7 +798,7 @@ Class.pt.callback = function(){ | ||
793 | } | 798 | } |
794 | } | 799 | } |
795 | layer.ie == 6 && that.IE6(layero); | 800 | layer.ie == 6 && that.IE6(layero); |
796 | - | 801 | + |
797 | //按钮 | 802 | //按钮 |
798 | layero.find('.'+ doms[6]).children('a').on('click', function(){ | 803 | layero.find('.'+ doms[6]).children('a').on('click', function(){ |
799 | var index = $(this).index(); | 804 | var index = $(this).index(); |
@@ -810,29 +815,29 @@ Class.pt.callback = function(){ | @@ -810,29 +815,29 @@ Class.pt.callback = function(){ | ||
810 | close === false || layer.close(that.index); | 815 | close === false || layer.close(that.index); |
811 | } | 816 | } |
812 | }); | 817 | }); |
813 | - | 818 | + |
814 | //取消 | 819 | //取消 |
815 | function cancel(){ | 820 | function cancel(){ |
816 | var close = config.cancel && config.cancel(that.index, layero); | 821 | var close = config.cancel && config.cancel(that.index, layero); |
817 | close === false || layer.close(that.index); | 822 | close === false || layer.close(that.index); |
818 | } | 823 | } |
819 | - | 824 | + |
820 | //右上角关闭回调 | 825 | //右上角关闭回调 |
821 | layero.find('.'+ doms[7]).on('click', cancel); | 826 | layero.find('.'+ doms[7]).on('click', cancel); |
822 | - | 827 | + |
823 | //点遮罩关闭 | 828 | //点遮罩关闭 |
824 | if(config.shadeClose){ | 829 | if(config.shadeClose){ |
825 | $('#layui-layer-shade'+ that.index).on('click', function(){ | 830 | $('#layui-layer-shade'+ that.index).on('click', function(){ |
826 | layer.close(that.index); | 831 | layer.close(that.index); |
827 | }); | 832 | }); |
828 | - } | ||
829 | - | 833 | + } |
834 | + | ||
830 | //最小化 | 835 | //最小化 |
831 | layero.find('.layui-layer-min').on('click', function(){ | 836 | layero.find('.layui-layer-min').on('click', function(){ |
832 | var min = config.min && config.min(layero); | 837 | var min = config.min && config.min(layero); |
833 | - min === false || layer.min(that.index, config); | 838 | + min === false || layer.min(that.index, config); |
834 | }); | 839 | }); |
835 | - | 840 | + |
836 | //全屏/还原 | 841 | //全屏/还原 |
837 | layero.find('.layui-layer-max').on('click', function(){ | 842 | layero.find('.layui-layer-max').on('click', function(){ |
838 | if($(this).hasClass('layui-layer-maxmin')){ | 843 | if($(this).hasClass('layui-layer-maxmin')){ |
@@ -854,11 +859,11 @@ ready.reselect = function(){ | @@ -854,11 +859,11 @@ ready.reselect = function(){ | ||
854 | $.each($('select'), function(index , value){ | 859 | $.each($('select'), function(index , value){ |
855 | var sthis = $(this); | 860 | var sthis = $(this); |
856 | if(!sthis.parents('.'+doms[0])[0]){ | 861 | if(!sthis.parents('.'+doms[0])[0]){ |
857 | - (sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show(); | 862 | + (sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show(); |
858 | } | 863 | } |
859 | sthis = null; | 864 | sthis = null; |
860 | }); | 865 | }); |
861 | -}; | 866 | +}; |
862 | 867 | ||
863 | Class.pt.IE6 = function(layero){ | 868 | Class.pt.IE6 = function(layero){ |
864 | //隐藏select | 869 | //隐藏select |
@@ -874,7 +879,7 @@ Class.pt.IE6 = function(layero){ | @@ -874,7 +879,7 @@ Class.pt.IE6 = function(layero){ | ||
874 | //需依赖原型的对外方法 | 879 | //需依赖原型的对外方法 |
875 | Class.pt.openLayer = function(){ | 880 | Class.pt.openLayer = function(){ |
876 | var that = this; | 881 | var that = this; |
877 | - | 882 | + |
878 | //置顶当前窗口 | 883 | //置顶当前窗口 |
879 | layer.zIndex = that.config.zIndex; | 884 | layer.zIndex = that.config.zIndex; |
880 | layer.setTop = function(layero){ | 885 | layer.setTop = function(layero){ |
@@ -892,7 +897,7 @@ ready.record = function(layero){ | @@ -892,7 +897,7 @@ ready.record = function(layero){ | ||
892 | var area = [ | 897 | var area = [ |
893 | layero.width(), | 898 | layero.width(), |
894 | layero.height(), | 899 | layero.height(), |
895 | - layero.position().top, | 900 | + layero.position().top, |
896 | layero.position().left + parseFloat(layero.css('margin-left')) | 901 | layero.position().left + parseFloat(layero.css('margin-left')) |
897 | ]; | 902 | ]; |
898 | layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); | 903 | layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); |
@@ -917,7 +922,7 @@ window.layer = layer; | @@ -917,7 +922,7 @@ window.layer = layer; | ||
917 | //获取子iframe的DOM | 922 | //获取子iframe的DOM |
918 | layer.getChildFrame = function(selector, index){ | 923 | layer.getChildFrame = function(selector, index){ |
919 | index = index || $('.'+doms[4]).attr('times'); | 924 | index = index || $('.'+doms[4]).attr('times'); |
920 | - return $('#'+ doms[0] + index).find('iframe').contents().find(selector); | 925 | + return $('#'+ doms[0] + index).find('iframe').contents().find(selector); |
921 | }; | 926 | }; |
922 | 927 | ||
923 | //得到当前iframe层的索引,子iframe时使用 | 928 | //得到当前iframe层的索引,子iframe时使用 |
@@ -949,24 +954,24 @@ layer.style = function(index, options, limit){ | @@ -949,24 +954,24 @@ layer.style = function(index, options, limit){ | ||
949 | ,titHeight = layero.find(doms[1]).outerHeight() || 0 | 954 | ,titHeight = layero.find(doms[1]).outerHeight() || 0 |
950 | ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 | 955 | ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 |
951 | ,minLeft = layero.attr('minLeft'); | 956 | ,minLeft = layero.attr('minLeft'); |
952 | - | 957 | + |
953 | if(type === ready.type[3] || type === ready.type[4]){ | 958 | if(type === ready.type[3] || type === ready.type[4]){ |
954 | return; | 959 | return; |
955 | } | 960 | } |
956 | - | 961 | + |
957 | if(!limit){ | 962 | if(!limit){ |
958 | if(parseFloat(options.width) <= 260){ | 963 | if(parseFloat(options.width) <= 260){ |
959 | options.width = 260; | 964 | options.width = 260; |
960 | }; | 965 | }; |
961 | - | 966 | + |
962 | if(parseFloat(options.height) - titHeight - btnHeight <= 64){ | 967 | if(parseFloat(options.height) - titHeight - btnHeight <= 64){ |
963 | options.height = 64 + titHeight + btnHeight; | 968 | options.height = 64 + titHeight + btnHeight; |
964 | }; | 969 | }; |
965 | } | 970 | } |
966 | - | 971 | + |
967 | layero.css(options); | 972 | layero.css(options); |
968 | btnHeight = layero.find('.'+doms[6]).outerHeight(); | 973 | btnHeight = layero.find('.'+doms[6]).outerHeight(); |
969 | - | 974 | + |
970 | if(type === ready.type[2]){ | 975 | if(type === ready.type[2]){ |
971 | layero.find('iframe').css({ | 976 | layero.find('iframe').css({ |
972 | height: parseFloat(options.height) - titHeight - btnHeight | 977 | height: parseFloat(options.height) - titHeight - btnHeight |
@@ -986,16 +991,16 @@ layer.min = function(index, options){ | @@ -986,16 +991,16 @@ layer.min = function(index, options){ | ||
986 | ,titHeight = layero.find(doms[1]).outerHeight() || 0 | 991 | ,titHeight = layero.find(doms[1]).outerHeight() || 0 |
987 | ,left = layero.attr('minLeft') || (181*ready.minIndex)+'px' | 992 | ,left = layero.attr('minLeft') || (181*ready.minIndex)+'px' |
988 | ,position = layero.css('position'); | 993 | ,position = layero.css('position'); |
989 | - | 994 | + |
990 | ready.record(layero); | 995 | ready.record(layero); |
991 | - | 996 | + |
992 | if(ready.minLeft[0]){ | 997 | if(ready.minLeft[0]){ |
993 | left = ready.minLeft[0]; | 998 | left = ready.minLeft[0]; |
994 | ready.minLeft.shift(); | 999 | ready.minLeft.shift(); |
995 | } | 1000 | } |
996 | - | 1001 | + |
997 | layero.attr('position', position); | 1002 | layero.attr('position', position); |
998 | - | 1003 | + |
999 | layer.style(index, { | 1004 | layer.style(index, { |
1000 | width: 180 | 1005 | width: 180 |
1001 | ,height: titHeight | 1006 | ,height: titHeight |
@@ -1008,7 +1013,7 @@ layer.min = function(index, options){ | @@ -1008,7 +1013,7 @@ layer.min = function(index, options){ | ||
1008 | layero.find('.layui-layer-min').hide(); | 1013 | layero.find('.layui-layer-min').hide(); |
1009 | layero.attr('type') === 'page' && layero.find(doms[4]).hide(); | 1014 | layero.attr('type') === 'page' && layero.find(doms[4]).hide(); |
1010 | ready.rescollbar(index); | 1015 | ready.rescollbar(index); |
1011 | - | 1016 | + |
1012 | if(!layero.attr('minLeft')){ | 1017 | if(!layero.attr('minLeft')){ |
1013 | ready.minIndex++; | 1018 | ready.minIndex++; |
1014 | } | 1019 | } |
@@ -1020,9 +1025,9 @@ layer.restore = function(index){ | @@ -1020,9 +1025,9 @@ layer.restore = function(index){ | ||
1020 | var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(','); | 1025 | var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(','); |
1021 | var type = layero.attr('type'); | 1026 | var type = layero.attr('type'); |
1022 | layer.style(index, { | 1027 | layer.style(index, { |
1023 | - width: parseFloat(area[0]), | ||
1024 | - height: parseFloat(area[1]), | ||
1025 | - top: parseFloat(area[2]), | 1028 | + width: parseFloat(area[0]), |
1029 | + height: parseFloat(area[1]), | ||
1030 | + top: parseFloat(area[2]), | ||
1026 | left: parseFloat(area[3]), | 1031 | left: parseFloat(area[3]), |
1027 | position: layero.attr('position'), | 1032 | position: layero.attr('position'), |
1028 | overflow: 'visible' | 1033 | overflow: 'visible' |
@@ -1085,16 +1090,16 @@ layer.close = function(index){ | @@ -1085,16 +1090,16 @@ layer.close = function(index){ | ||
1085 | layero.remove(); | 1090 | layero.remove(); |
1086 | } | 1091 | } |
1087 | }; | 1092 | }; |
1088 | - | 1093 | + |
1089 | if(layero.data('anim')){ | 1094 | if(layero.data('anim')){ |
1090 | layero.addClass(closeAnim); | 1095 | layero.addClass(closeAnim); |
1091 | } | 1096 | } |
1092 | - | 1097 | + |
1093 | $('#layui-layer-moves, #layui-layer-shade' + index).remove(); | 1098 | $('#layui-layer-moves, #layui-layer-shade' + index).remove(); |
1094 | layer.ie == 6 && ready.reselect(); | 1099 | layer.ie == 6 && ready.reselect(); |
1095 | ready.rescollbar(index); | 1100 | ready.rescollbar(index); |
1096 | typeof ready.end[index] === 'function' && ready.end[index](); | 1101 | typeof ready.end[index] === 'function' && ready.end[index](); |
1097 | - delete ready.end[index]; | 1102 | + delete ready.end[index]; |
1098 | if(layero.attr('minLeft')){ | 1103 | if(layero.attr('minLeft')){ |
1099 | ready.minIndex--; | 1104 | ready.minIndex--; |
1100 | ready.minLeft.push(layero.attr('minLeft')); | 1105 | ready.minLeft.push(layero.attr('minLeft')); |
@@ -1114,7 +1119,7 @@ layer.closeAll = function(type){ | @@ -1114,7 +1119,7 @@ layer.closeAll = function(type){ | ||
1114 | }); | 1119 | }); |
1115 | }; | 1120 | }; |
1116 | 1121 | ||
1117 | -/** | 1122 | +/** |
1118 | 1123 | ||
1119 | 拓展模块,layui开始合并在一起 | 1124 | 拓展模块,layui开始合并在一起 |
1120 | 1125 | ||
@@ -1122,15 +1127,15 @@ layer.closeAll = function(type){ | @@ -1122,15 +1127,15 @@ layer.closeAll = function(type){ | ||
1122 | 1127 | ||
1123 | var cache = layer.cache||{}, skin = function(type){ | 1128 | var cache = layer.cache||{}, skin = function(type){ |
1124 | return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); | 1129 | return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); |
1125 | -}; | ||
1126 | - | 1130 | +}; |
1131 | + | ||
1127 | //仿系统prompt | 1132 | //仿系统prompt |
1128 | layer.prompt = function(options, yes){ | 1133 | layer.prompt = function(options, yes){ |
1129 | var style = ''; | 1134 | var style = ''; |
1130 | options = options || {}; | 1135 | options = options || {}; |
1131 | - | 1136 | + |
1132 | if(typeof options === 'function') yes = options; | 1137 | if(typeof options === 'function') yes = options; |
1133 | - | 1138 | + |
1134 | if(options.area){ | 1139 | if(options.area){ |
1135 | var area = options.area; | 1140 | var area = options.area; |
1136 | style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"'; | 1141 | style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"'; |
@@ -1139,7 +1144,7 @@ layer.prompt = function(options, yes){ | @@ -1139,7 +1144,7 @@ layer.prompt = function(options, yes){ | ||
1139 | var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input"' + style +'>' + (options.value||'') +'</textarea>' : function(){ | 1144 | var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input"' + style +'>' + (options.value||'') +'</textarea>' : function(){ |
1140 | return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">'; | 1145 | return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">'; |
1141 | }(); | 1146 | }(); |
1142 | - | 1147 | + |
1143 | return layer.open($.extend({ | 1148 | return layer.open($.extend({ |
1144 | type: 1 | 1149 | type: 1 |
1145 | ,btn: ['确定','取消'] | 1150 | ,btn: ['确定','取消'] |
@@ -1215,7 +1220,7 @@ layer.photos = function(options, loop, key){ | @@ -1215,7 +1220,7 @@ layer.photos = function(options, loop, key){ | ||
1215 | var photos = type ? options.photos : {}, data = photos.data || []; | 1220 | var photos = type ? options.photos : {}, data = photos.data || []; |
1216 | var start = photos.start || 0; | 1221 | var start = photos.start || 0; |
1217 | dict.imgIndex = (start|0) + 1; | 1222 | dict.imgIndex = (start|0) + 1; |
1218 | - | 1223 | + |
1219 | options.img = options.img || 'img'; | 1224 | options.img = options.img || 'img'; |
1220 | 1225 | ||
1221 | if(!type){ //页面直接获取 | 1226 | if(!type){ //页面直接获取 |
@@ -1232,13 +1237,13 @@ layer.photos = function(options, loop, key){ | @@ -1232,13 +1237,13 @@ layer.photos = function(options, loop, key){ | ||
1232 | }); | 1237 | }); |
1233 | }) | 1238 | }) |
1234 | }; | 1239 | }; |
1235 | - | 1240 | + |
1236 | pushData(); | 1241 | pushData(); |
1237 | - | 1242 | + |
1238 | if (data.length === 0) return; | 1243 | if (data.length === 0) return; |
1239 | - | 1244 | + |
1240 | loop || parent.on('click', options.img, function(){ | 1245 | loop || parent.on('click', options.img, function(){ |
1241 | - var othis = $(this), index = othis.attr('layer-index'); | 1246 | + var othis = $(this), index = othis.attr('layer-index'); |
1242 | layer.photos($.extend(options, { | 1247 | layer.photos($.extend(options, { |
1243 | photos: { | 1248 | photos: { |
1244 | start: index, | 1249 | start: index, |
@@ -1249,14 +1254,14 @@ layer.photos = function(options, loop, key){ | @@ -1249,14 +1254,14 @@ layer.photos = function(options, loop, key){ | ||
1249 | }), true); | 1254 | }), true); |
1250 | pushData(); | 1255 | pushData(); |
1251 | }) | 1256 | }) |
1252 | - | 1257 | + |
1253 | //不直接弹出 | 1258 | //不直接弹出 |
1254 | if(!loop) return; | 1259 | if(!loop) return; |
1255 | - | 1260 | + |
1256 | } else if (data.length === 0){ | 1261 | } else if (data.length === 0){ |
1257 | return layer.msg('没有图片'); | 1262 | return layer.msg('没有图片'); |
1258 | } | 1263 | } |
1259 | - | 1264 | + |
1260 | //上一张 | 1265 | //上一张 |
1261 | dict.imgprev = function(key){ | 1266 | dict.imgprev = function(key){ |
1262 | dict.imgIndex--; | 1267 | dict.imgIndex--; |
@@ -1265,7 +1270,7 @@ layer.photos = function(options, loop, key){ | @@ -1265,7 +1270,7 @@ layer.photos = function(options, loop, key){ | ||
1265 | } | 1270 | } |
1266 | dict.tabimg(key); | 1271 | dict.tabimg(key); |
1267 | }; | 1272 | }; |
1268 | - | 1273 | + |
1269 | //下一张 | 1274 | //下一张 |
1270 | dict.imgnext = function(key,errorMsg){ | 1275 | dict.imgnext = function(key,errorMsg){ |
1271 | dict.imgIndex++; | 1276 | dict.imgIndex++; |
@@ -1275,7 +1280,7 @@ layer.photos = function(options, loop, key){ | @@ -1275,7 +1280,7 @@ layer.photos = function(options, loop, key){ | ||
1275 | } | 1280 | } |
1276 | dict.tabimg(key) | 1281 | dict.tabimg(key) |
1277 | }; | 1282 | }; |
1278 | - | 1283 | + |
1279 | //方向键 | 1284 | //方向键 |
1280 | dict.keyup = function(event){ | 1285 | dict.keyup = function(event){ |
1281 | if(!dict.end){ | 1286 | if(!dict.end){ |
@@ -1290,7 +1295,7 @@ layer.photos = function(options, loop, key){ | @@ -1290,7 +1295,7 @@ layer.photos = function(options, loop, key){ | ||
1290 | } | 1295 | } |
1291 | } | 1296 | } |
1292 | } | 1297 | } |
1293 | - | 1298 | + |
1294 | //切换 | 1299 | //切换 |
1295 | dict.tabimg = function(key){ | 1300 | dict.tabimg = function(key){ |
1296 | if(data.length <= 1) return; | 1301 | if(data.length <= 1) return; |
@@ -1298,7 +1303,7 @@ layer.photos = function(options, loop, key){ | @@ -1298,7 +1303,7 @@ layer.photos = function(options, loop, key){ | ||
1298 | layer.close(dict.index); | 1303 | layer.close(dict.index); |
1299 | layer.photos(options, true, key); | 1304 | layer.photos(options, true, key); |
1300 | } | 1305 | } |
1301 | - | 1306 | + |
1302 | //一些动作 | 1307 | //一些动作 |
1303 | dict.event = function(){ | 1308 | dict.event = function(){ |
1304 | dict.bigimg.hover(function(){ | 1309 | dict.bigimg.hover(function(){ |
@@ -1306,24 +1311,24 @@ layer.photos = function(options, loop, key){ | @@ -1306,24 +1311,24 @@ layer.photos = function(options, loop, key){ | ||
1306 | }, function(){ | 1311 | }, function(){ |
1307 | dict.imgsee.hide(); | 1312 | dict.imgsee.hide(); |
1308 | }); | 1313 | }); |
1309 | - | 1314 | + |
1310 | dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){ | 1315 | dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){ |
1311 | event.preventDefault(); | 1316 | event.preventDefault(); |
1312 | dict.imgprev(); | 1317 | dict.imgprev(); |
1313 | - }); | ||
1314 | - | ||
1315 | - dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ | 1318 | + }); |
1319 | + | ||
1320 | + dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ | ||
1316 | event.preventDefault(); | 1321 | event.preventDefault(); |
1317 | dict.imgnext(); | 1322 | dict.imgnext(); |
1318 | }); | 1323 | }); |
1319 | - | 1324 | + |
1320 | $(document).on('keyup', dict.keyup); | 1325 | $(document).on('keyup', dict.keyup); |
1321 | }; | 1326 | }; |
1322 | - | 1327 | + |
1323 | //图片预加载 | 1328 | //图片预加载 |
1324 | - function loadImage(url, callback, error) { | 1329 | + function loadImage(url, callback, error) { |
1325 | var img = new Image(); | 1330 | var img = new Image(); |
1326 | - img.src = url; | 1331 | + img.src = url; |
1327 | if(img.complete){ | 1332 | if(img.complete){ |
1328 | return callback(img); | 1333 | return callback(img); |
1329 | } | 1334 | } |
@@ -1334,9 +1339,9 @@ layer.photos = function(options, loop, key){ | @@ -1334,9 +1339,9 @@ layer.photos = function(options, loop, key){ | ||
1334 | img.onerror = function(e){ | 1339 | img.onerror = function(e){ |
1335 | img.onerror = null; | 1340 | img.onerror = null; |
1336 | error(e); | 1341 | error(e); |
1337 | - }; | 1342 | + }; |
1338 | }; | 1343 | }; |
1339 | - | 1344 | + |
1340 | dict.loadi = layer.load(1, { | 1345 | dict.loadi = layer.load(1, { |
1341 | shade: 'shade' in options ? false : 0.9, | 1346 | shade: 'shade' in options ? false : 0.9, |
1342 | scrollbar: false | 1347 | scrollbar: false |
@@ -1348,7 +1353,7 @@ layer.photos = function(options, loop, key){ | @@ -1348,7 +1353,7 @@ layer.photos = function(options, loop, key){ | ||
1348 | area: function(){ | 1353 | area: function(){ |
1349 | var imgarea = [img.width, img.height]; | 1354 | var imgarea = [img.width, img.height]; |
1350 | var winarea = [$(window).width() - 100, $(window).height() - 100]; | 1355 | var winarea = [$(window).width() - 100, $(window).height() - 100]; |
1351 | - | 1356 | + |
1352 | //如果 实际图片的宽或者高比 屏幕大(那么进行缩放) | 1357 | //如果 实际图片的宽或者高比 屏幕大(那么进行缩放) |
1353 | if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){ | 1358 | if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){ |
1354 | var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例 | 1359 | var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例 |
@@ -1360,8 +1365,8 @@ layer.photos = function(options, loop, key){ | @@ -1360,8 +1365,8 @@ layer.photos = function(options, loop, key){ | ||
1360 | imgarea[1] = imgarea[1]/wh[1]; | 1365 | imgarea[1] = imgarea[1]/wh[1]; |
1361 | } | 1366 | } |
1362 | } | 1367 | } |
1363 | - | ||
1364 | - return [imgarea[0]+'px', imgarea[1]+'px']; | 1368 | + |
1369 | + return [imgarea[0]+'px', imgarea[1]+'px']; | ||
1365 | }(), | 1370 | }(), |
1366 | title: false, | 1371 | title: false, |
1367 | shade: 0.9, | 1372 | shade: 0.9, |
@@ -1393,8 +1398,8 @@ layer.photos = function(options, loop, key){ | @@ -1393,8 +1398,8 @@ layer.photos = function(options, loop, key){ | ||
1393 | }, function(){ | 1398 | }, function(){ |
1394 | layer.close(dict.loadi); | 1399 | layer.close(dict.loadi); |
1395 | layer.msg('当前图片地址异常<br>是否继续查看下一张?', { | 1400 | layer.msg('当前图片地址异常<br>是否继续查看下一张?', { |
1396 | - time: 30000, | ||
1397 | - btn: ['下一张', '不看了'], | 1401 | + time: 30000, |
1402 | + btn: ['下一张', '不看了'], | ||
1398 | yes: function(){ | 1403 | yes: function(){ |
1399 | data.length > 1 && dict.imgnext(true,true); | 1404 | data.length > 1 && dict.imgnext(true,true); |
1400 | } | 1405 | } |
1 | -define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstrap-table', 'bootstrap-table-lang', 'bootstrap-table-mobile', 'bootstrap-table-export', 'bootstrap-table-advancedsearch'], function ($, undefined, Backend, Config, Toastr, Moment) { | 1 | +define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstrap-table', 'bootstrap-table-lang', 'bootstrap-table-mobile', 'bootstrap-table-export', 'bootstrap-table-advancedsearch', 'bootstrap-table-commonsearch'], function ($, undefined, Backend, Config, Toastr, Moment) { |
2 | 2 | ||
3 | var Table = { | 3 | var Table = { |
4 | list: {}, | 4 | list: {}, |
@@ -10,7 +10,9 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstr | @@ -10,7 +10,9 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'toastr', 'moment', 'bootstr | ||
10 | toolbar: "#toolbar", | 10 | toolbar: "#toolbar", |
11 | search: true, | 11 | search: true, |
12 | cache: false, | 12 | cache: false, |
13 | - advancedSearch: true, | 13 | + advancedSearch: false, |
14 | + commonSearch: false, | ||
15 | + titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索 | ||
14 | idTable: 'advancedTable', | 16 | idTable: 'advancedTable', |
15 | showExport: true, | 17 | showExport: true, |
16 | exportDataType: "all", | 18 | exportDataType: "all", |
-
请 注册 或 登录 后发表评论