mirror of https://gitee.com/karson/fastadmin.git
优化代码
parent
0a5484b738
commit
aec4efe9e0
|
|
@ -135,6 +135,10 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
|
|||
url = Fast.api.fixurl(url);
|
||||
url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
|
||||
var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
|
||||
var success = options && typeof options.success === 'function' ? options.success : $.noop;
|
||||
if (options && typeof options.success === 'function') {
|
||||
delete options.success;
|
||||
}
|
||||
options = $.extend({
|
||||
type: 2,
|
||||
title: title,
|
||||
|
|
@ -188,6 +192,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
|
|||
height: $(window).height()
|
||||
});
|
||||
}
|
||||
success.call(this, layero, index);
|
||||
}
|
||||
}, options ? options : {});
|
||||
if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
|
||||
|
|
|
|||
|
|
@ -91,8 +91,10 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
$(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
|
||||
//自定义关闭按钮事件
|
||||
form.on("click", ".layer-close", function () {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
parent.Layer.close(index);
|
||||
if (window.name) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
parent.Layer.close(index);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
|
@ -216,7 +218,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
};
|
||||
var origincallback = function (start, end) {
|
||||
$(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
|
||||
$(this.element).trigger('blur');
|
||||
$(this.element).trigger('change');
|
||||
};
|
||||
$(".datetimerange", form).each(function () {
|
||||
var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
|
||||
|
|
@ -224,7 +226,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
callback.call(picker, picker.startDate, picker.endDate);
|
||||
});
|
||||
$(this).on('cancel.daterangepicker', function (ev, picker) {
|
||||
$(this).val('').trigger('blur');
|
||||
$(this).val('').trigger('change');
|
||||
});
|
||||
$(this).daterangepicker($.extend(true, {}, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
|
||||
});
|
||||
|
|
@ -288,7 +290,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
}
|
||||
var result = urlArr.join(",");
|
||||
inputObj.val(result).trigger("change").trigger("validate");
|
||||
} else {
|
||||
} else if (input_id) {
|
||||
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
|
||||
$("#" + input_id).val(url).trigger("change").trigger("validate");
|
||||
}
|
||||
|
|
@ -326,7 +328,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
if (keys.indexOf("value") > -1 && (keys.length === 1 || (keys.length === 2 && keys.indexOf("key") > -1))) {
|
||||
if (keys.length === 2) {
|
||||
if (j.key != '') {
|
||||
result[j.key] = j.value;
|
||||
result['__PLACEHOLDKEY__' + j.key] = j.value;
|
||||
}
|
||||
} else {
|
||||
result.push(j.value);
|
||||
|
|
@ -336,7 +338,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
}
|
||||
}
|
||||
});
|
||||
textarea.val(JSON.stringify(result));
|
||||
textarea.val(JSON.stringify(result).replace(/__PLACEHOLDKEY__/g, ''));
|
||||
};
|
||||
//追加一行数据
|
||||
var append = function (container, row, initial) {
|
||||
|
|
@ -410,11 +412,12 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
$("[fieldlist-item]", container).remove();
|
||||
var json = {};
|
||||
try {
|
||||
json = JSON.parse(textarea.val());
|
||||
var val = textarea.val().replace(/"(\d+)"\:/g, "\"__PLACEHOLDERKEY__$1\":");
|
||||
json = JSON.parse(val);
|
||||
} catch (e) {
|
||||
}
|
||||
$.each(json, function (i, j) {
|
||||
append(container, {key: i, value: j}, true);
|
||||
append(container, {key: i.toString().replace("__PLACEHOLDERKEY__", ""), value: j}, true);
|
||||
});
|
||||
});
|
||||
//拖拽排序
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
$(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
|
||||
var that = this;
|
||||
var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
|
||||
var row = Fast.api.getrowbyindex(table, $(that).data("row-index"));
|
||||
var row = Table.api.getrowbyindex(table, $(that).data("row-index"));
|
||||
Fast.api.ajax({
|
||||
url: url,
|
||||
data: {ids: row[options.pk]}
|
||||
|
|
@ -562,7 +562,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
var target = $(".autocontent-item", this).get(0);
|
||||
if (!target) return;
|
||||
if (e.type === 'mouseenter') {
|
||||
if (target.scrollWidth > target.offsetWidth) {
|
||||
if (target.scrollWidth > target.offsetWidth && $(".autocontent-caret", this).length === 0) {
|
||||
$(this).append("<div class='autocontent-caret'><i class='fa fa-chevron-down'></div>");
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
|
|||
if ($(button).data("multiple") && inputObj.val() !== "") {
|
||||
urlArr.push(inputObj.val());
|
||||
}
|
||||
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
|
||||
var url = Config.upload.fullmode ? (data.fullurl ? data.fullurl : Fast.api.cdnurl(data.url)) : data.url;
|
||||
urlArr.push(url);
|
||||
inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
|
||||
}
|
||||
|
|
@ -351,9 +351,10 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
|
|||
$(document.body).on("keyup change", "#" + input_id, function (e) {
|
||||
var inputStr = $("#" + input_id).val();
|
||||
var inputArr = inputStr.split(/\,/);
|
||||
$("#" + preview_id).empty();
|
||||
var tpl = $("#" + preview_id).data("template") ? $("#" + preview_id).data("template") : "";
|
||||
var extend = $("#" + preview_id).next().is("textarea") ? $("#" + preview_id).next("textarea").val() : "{}";
|
||||
var previewObj = $("#" + preview_id);
|
||||
previewObj.empty();
|
||||
var tpl = previewObj.data("template") ? previewObj.data("template") : "";
|
||||
var extend = previewObj.next().is("textarea") ? previewObj.next("textarea").val() : "{}";
|
||||
var json = {};
|
||||
try {
|
||||
json = JSON.parse(extend);
|
||||
|
|
@ -365,13 +366,15 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
|
|||
}
|
||||
var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
|
||||
suffix = suffix ? suffix[1] : 'file';
|
||||
j = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
|
||||
var btnData = $(that).data();
|
||||
var fullurl = typeof btnData.cdnurl!=='undefined' ? Fast.api.cdnurl(j, btnData.cdnurl) : Fast.api.cdnurl(j);
|
||||
j = Config.upload.fullmode ? fullurl : j;
|
||||
var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
|
||||
var data = {url: j, fullurl: Fast.api.cdnurl(j), data: $(that).data(), key: i, index: i, value: value, row: value, suffix: suffix};
|
||||
var data = {url: j, fullurl: fullurl, data: btnData, key: i, index: i, value: value, row: value, suffix: suffix};
|
||||
var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
|
||||
$("#" + preview_id).append(html);
|
||||
previewObj.append(html);
|
||||
});
|
||||
refresh($("#" + preview_id).data("name"));
|
||||
refresh(previewObj.data("name"));
|
||||
});
|
||||
$("#" + input_id).trigger("change");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue