mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-07-12 02:24:48 +08:00
Compare commits
2 Commits
5159fc32cc
...
37ffe19737
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37ffe19737 | ||
|
|
aa7ec322de |
@ -14,25 +14,25 @@
|
||||
|
||||
/*! 数组兼容处理 */
|
||||
if (typeof Array.prototype.some !== 'function') {
|
||||
Array.prototype.some = function (callable) {
|
||||
for (var i in this) if (callable(this[i], i, this) === true) {
|
||||
Array.prototype.some = function (callback) {
|
||||
for (var i in this) if (callback(this[i], i, this) === true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
if (typeof Array.prototype.every !== 'function') {
|
||||
Array.prototype.every = function (callable) {
|
||||
for (var i in this) if (callable(this[i], i, this) === false) {
|
||||
Array.prototype.every = function (callback) {
|
||||
for (var i in this) if (callback(this[i], i, this) === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
if (typeof Array.prototype.forEach !== 'function') {
|
||||
Array.prototype.forEach = function (callable, context) {
|
||||
Array.prototype.forEach = function (callback, context) {
|
||||
typeof context === "undefined" ? context = window : null;
|
||||
for (var i in this) callable.call(context, this[i], i, this)
|
||||
for (var i in this) callback.call(context, this[i], i, this)
|
||||
};
|
||||
}
|
||||
|
||||
@ -92,18 +92,18 @@ $(function () {
|
||||
window.$body = $('body');
|
||||
|
||||
/*! 注册单次事件 */
|
||||
function onEvent(event, select, callable) {
|
||||
return $body.off(event, select).on(event, select, callable);
|
||||
function onEvent(event, select, callback) {
|
||||
return $body.off(event, select).on(event, select, callback);
|
||||
}
|
||||
|
||||
/*! 注册确认回调 */
|
||||
function onConfirm(confirm, callable) {
|
||||
confirm ? $.msg.confirm(confirm, callable) : callable();
|
||||
function onConfirm(confirm, callback) {
|
||||
confirm ? $.msg.confirm(confirm, callback) : callback();
|
||||
}
|
||||
|
||||
/*! 获取加载回调 */
|
||||
onConfirm.getLoadCallable = function (tabldId, callable) {
|
||||
typeof callable === 'function' && callable();
|
||||
onConfirm.getLoadCallback = function (tabldId, callback) {
|
||||
typeof callback === 'function' && callback();
|
||||
return tabldId ? function (ret, time) {
|
||||
if (ret.code > 0) {
|
||||
if (time === 'false') $.layTable.reload(tabldId);
|
||||
@ -271,7 +271,7 @@ $(function () {
|
||||
that.reInit($(this.selecter).html(html));
|
||||
};
|
||||
/*! 异步加载的数据 */
|
||||
this.load = function (url, data, method, callable, loading, tips, time, headers) {
|
||||
this.load = function (url, data, method, callback, loading, tips, time, headers) {
|
||||
// 如果主页面 loader 显示中,绝对不显示 loading 图标
|
||||
loading = $('.layui-page-loader').is(':visible') ? false : loading;
|
||||
var loadidx = loading !== false ? $.msg.loading(tips) : 0;
|
||||
@ -300,7 +300,7 @@ $(function () {
|
||||
}
|
||||
}, success: function (ret) {
|
||||
time = time || ret.wait || undefined;
|
||||
if (typeof callable === 'function' && callable.call(that, ret, time) === false) return false;
|
||||
if (typeof callback === 'function' && callback.call(that, ret, time) === false) return false;
|
||||
return typeof ret === 'object' ? $.msg.auto(ret, time) : that.show(ret);
|
||||
}, complete: function () {
|
||||
$.msg.page.done();
|
||||
@ -434,7 +434,7 @@ $(function () {
|
||||
};
|
||||
|
||||
/*! 表单验证组件 */
|
||||
$.vali = function (form, callable) {
|
||||
$.vali = function (form, callback) {
|
||||
return $(form).data('validate') || new Validate();
|
||||
|
||||
function Validate() {
|
||||
@ -494,14 +494,14 @@ $(function () {
|
||||
}).data('validate', this).bind("submit", function (evt) {
|
||||
evt.button = that.form.find('button[type=submit],button:not([type=button])');
|
||||
/* 检查所有表单元素是否通过H5的规则验证 */
|
||||
if (that.checkAllInput() && typeof callable === 'function') {
|
||||
if (that.checkAllInput() && typeof callback === 'function') {
|
||||
if (typeof CKEDITOR === 'object' && typeof CKEDITOR.instances === 'object') {
|
||||
for (var i in CKEDITOR.instances) CKEDITOR.instances[i].updateElement();
|
||||
}
|
||||
/* 触发表单提交后,锁定三秒不能再次提交表单 */
|
||||
if (that.form.attr('submit-locked')) return false;
|
||||
that.form.attr('submit-locked', 1), evt.button.addClass('submit-button-loading');
|
||||
callable.call(this, that.form.formToJson(), []), setTimeout(function () {
|
||||
callback.call(this, that.form.formToJson(), []), setTimeout(function () {
|
||||
that.form.removeAttr('submit-locked'), evt.button.removeClass('submit-button-loading');
|
||||
}, 3000);
|
||||
}
|
||||
@ -521,7 +521,7 @@ $(function () {
|
||||
$(this).vali(function (data) {
|
||||
var emap = form.dataset, type = form.method || 'POST', href = form.action || location.href;
|
||||
var tips = emap.tips || undefined, time = emap.time || undefined, taid = emap.tableId || false;
|
||||
var call = window[emap.callable || '_default_callable'] || (taid ? function (ret) {
|
||||
var call = window[emap.callback || '_default_callback'] || (taid ? function (ret) {
|
||||
if (typeof ret === 'object' && ret.code > 0 && $('#' + taid).size() > 0) {
|
||||
return $.msg.success(ret.info, 3, function () {
|
||||
(typeof ret.data === 'string' && ret.data) ? location.href = ret.data : $.layTable.reload(taid);
|
||||
@ -537,9 +537,9 @@ $(function () {
|
||||
};
|
||||
|
||||
/*! 注册对象到JqFn */
|
||||
$.fn.vali = function (callable) {
|
||||
$.fn.vali = function (callback) {
|
||||
return this.each(function () {
|
||||
$.vali(this, callable);
|
||||
$.vali(this, callback);
|
||||
});
|
||||
};
|
||||
|
||||
@ -566,12 +566,12 @@ $(function () {
|
||||
};
|
||||
|
||||
/*! 全局文件上传插件 */
|
||||
$.fn.uploadFile = function (callable, initialize) {
|
||||
$.fn.uploadFile = function (callback, initialize) {
|
||||
return this.each(function () {
|
||||
if ($(this).data('inited')) return false;
|
||||
var that = $(this), mult = '|one|btn|'.indexOf(that.data('file') || 'one') > -1 ? 0 : 1;
|
||||
that.data('inited', true).data('multiple', mult), require(['upload'], function (apply) {
|
||||
apply(that, callable), (typeof initialize === 'function' && setTimeout(initialize, 100));
|
||||
apply(that, callback), (typeof initialize === 'function' && setTimeout(initialize, 100));
|
||||
});
|
||||
});
|
||||
};
|
||||
@ -680,9 +680,10 @@ $(function () {
|
||||
var option = params || {}, data = option.where || {}, sort = option.initSort || option.sort || {};
|
||||
option.id = table.id, option.elem = table, option.url = params.url || table.dataset.url || location.href;
|
||||
option.page = params.page !== false ? (params.page || true) : false, option.limit = params.limit || 20;
|
||||
option.loading = !!params.loading, option.autoSort = params.autoSort === true, option.cols = params.cols || [[]];
|
||||
option.loading = params.loading !== false, option.autoSort = params.autoSort === true, option.cols = params.cols || [[]];
|
||||
// 初始化不显示头部
|
||||
option.css = (option.css || '') + '.layui-table-box{opacity:0}.layui-table-page{opacity:0}';
|
||||
var cls = ['.layui-table-header', '.layui-table-fixed', '.layui-table-body', '.layui-table-page'];
|
||||
option.css = (option.css || '') + cls.join('{opacity:0}') + '{opacity:0}';
|
||||
// 默认动态设置页数, 动态设置最大高度
|
||||
if (option.page === true) option.page = {curr: layui.sessionData('pages')[option.id] || 1};
|
||||
if (option.height === 'full') if ($table.parents('.iframe-pagination').size()) {
|
||||
@ -693,7 +694,7 @@ $(function () {
|
||||
}
|
||||
// 动态计算最大页数
|
||||
option.done = function () {
|
||||
$table.data('that', this).next().find('.layui-table-box,.layui-table-page').animate({opacity: 1});
|
||||
$table.data('that', this).next().find(cls.join(',')).animate({opacity: 1});
|
||||
(option.loading = this.loading = true) && layui.sessionData('pages', {key: table.id, value: this.page.curr || 1});
|
||||
$.form.reInit($table.next()).find('[data-load],[data-queue],[data-action],[data-iframe]').not('[data-table-id]').attr('data-table-id', table.id);
|
||||
}, option.parseData = function (res) {
|
||||
@ -875,7 +876,7 @@ $(function () {
|
||||
onEvent('click', '[data-load]', function () {
|
||||
var emap = this.dataset, data = {};
|
||||
if (emap.rule && (applyRuleValue(this, data)) === false) return false; else onConfirm(emap.confirm, function () {
|
||||
$.form.load(emap.load, data, 'get', onConfirm.getLoadCallable(emap.tableId), true, emap.tips, emap.time);
|
||||
$.form.load(emap.load, data, 'get', onConfirm.getLoadCallback(emap.tableId), true, emap.tips, emap.time);
|
||||
});
|
||||
});
|
||||
|
||||
@ -939,7 +940,7 @@ $(function () {
|
||||
var emap = this.dataset, data = {'_token_': emap.token || emap.csrf || '--'};
|
||||
var load = emap.loading !== 'false', tips = typeof load === 'string' ? load : undefined;
|
||||
if ((applyRuleValue(this, data)) === false) return false; else onConfirm(emap.confirm, function () {
|
||||
$.form.load(emap.action, data, emap.method || 'post', onConfirm.getLoadCallable(emap.tableId), load, tips, emap.time)
|
||||
$.form.load(emap.action, data, emap.method || 'post', onConfirm.getLoadCallback(emap.tableId), load, tips, emap.time)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user