mirror of https://gitee.com/karson/fastadmin.git
优化size判断
parent
0b4eceea54
commit
9400aa6e4e
|
|
@ -476,7 +476,7 @@ function _init() {
|
|||
//Get the parent menu
|
||||
var parent = $this.parents('ul').first();
|
||||
// modified by FastAdmin
|
||||
if ($(".show-submenu", menu).size() == 0) {
|
||||
if ($(".show-submenu", menu).length == 0) {
|
||||
//Close all open menus within the parent
|
||||
var ul = parent.find('ul:visible').slideUp(animationSpeed);
|
||||
//Remove the menu-open class from the parent
|
||||
|
|
@ -501,7 +501,7 @@ function _init() {
|
|||
// $this.parent().addClass("active");
|
||||
}
|
||||
// modified by FastAdmin
|
||||
if ($(".show-submenu", menu).size() == 0 && $this.parent().parent().hasClass("sidebar-menu")) {
|
||||
if ($(".show-submenu", menu).length == 0 && $this.parent().parent().hasClass("sidebar-menu")) {
|
||||
$this.parent().siblings().find("ul.menu-open").slideUp();
|
||||
$this.parent().siblings("li.treeview-open").removeClass("treeview-open");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,25 +31,25 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
|||
addtabs: function (url, title, icon) {
|
||||
var dom = "a[url='{url}']"
|
||||
var leftlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (leftlink.size() > 0) {
|
||||
if (leftlink.length > 0) {
|
||||
leftlink.trigger("click");
|
||||
} else {
|
||||
url = Fast.api.fixurl(url);
|
||||
leftlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (leftlink.size() > 0) {
|
||||
if (leftlink.length > 0) {
|
||||
var event = leftlink.parent().hasClass("active") ? "dblclick" : "click";
|
||||
leftlink.trigger(event);
|
||||
} else {
|
||||
var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
|
||||
leftlink = top.window.$(dom.replace(/\{url\}/, baseurl));
|
||||
//能找到相对地址
|
||||
if (leftlink.size() > 0) {
|
||||
if (leftlink.length > 0) {
|
||||
icon = typeof icon !== 'undefined' ? icon : leftlink.find("i").attr("class");
|
||||
title = typeof title !== 'undefined' ? title : leftlink.find("span:first").text();
|
||||
leftlink.trigger("fa.event.toggleitem");
|
||||
}
|
||||
var navnode = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
|
||||
if (navnode.size() > 0) {
|
||||
if (navnode.length > 0) {
|
||||
navnode.trigger("click");
|
||||
} else {
|
||||
//追加新的tab
|
||||
|
|
@ -70,20 +70,20 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
|||
} else {
|
||||
var dom = "a[url='{url}']"
|
||||
var navlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (navlink.size() === 0) {
|
||||
if (navlink.length === 0) {
|
||||
url = Fast.api.fixurl(url);
|
||||
navlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (navlink.size() === 0) {
|
||||
if (navlink.length === 0) {
|
||||
} else {
|
||||
var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
|
||||
navlink = top.window.$(dom.replace(/\{url\}/, baseurl));
|
||||
//能找到相对地址
|
||||
if (navlink.size() === 0) {
|
||||
if (navlink.length === 0) {
|
||||
navlink = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (navlink.size() > 0 && navlink.attr('addtabs')) {
|
||||
if (navlink.length > 0 && navlink.attr('addtabs')) {
|
||||
top.window.$("ul.nav-addtabs li#tab_" + navlink.attr('addtabs') + " .close-tab").trigger("click");
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
|||
if (url.indexOf("{ids}") > -1) {
|
||||
var ids = 0;
|
||||
var tableId = $(elem).data("table-id");
|
||||
if (tableId && $("#" + tableId).size() > 0 && $("#" + tableId).data("bootstrap.table")) {
|
||||
if (tableId && $("#" + tableId).length > 0 && $("#" + tableId).data("bootstrap.table")) {
|
||||
var Table = require("table");
|
||||
ids = Table.api.selectedids($("#" + tableId)).join(",");
|
||||
}
|
||||
|
|
@ -233,11 +233,11 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
|||
return false;
|
||||
});
|
||||
//修复含有fixed-footer类的body边距
|
||||
if ($(".fixed-footer").size() > 0) {
|
||||
if ($(".fixed-footer").length > 0) {
|
||||
$(document.body).css("padding-bottom", $(".fixed-footer").outerHeight());
|
||||
}
|
||||
//修复不在iframe时layer-footer隐藏的问题
|
||||
if ($(".layer-footer").size() > 0 && self === top) {
|
||||
if ($(".layer-footer").length > 0 && self === top) {
|
||||
$(".layer-footer").show();
|
||||
}
|
||||
//tooltip和popover
|
||||
|
|
@ -257,4 +257,4 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
|||
|
||||
Backend.init();
|
||||
return Backend;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -180,11 +180,11 @@
|
|||
var name = $(this).data("name");
|
||||
var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
|
||||
var obj = $("[name='" + name + "']", that.$commonsearch);
|
||||
if (obj.size() == 0)
|
||||
if (obj.length == 0)
|
||||
return true;
|
||||
var vObjCol = ColumnsForSearch[i];
|
||||
var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
|
||||
if (obj.size() > 1) {
|
||||
if (obj.length > 1) {
|
||||
if (/BETWEEN$/.test(sym)) {
|
||||
var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
|
||||
value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
|
||||
|
|
@ -315,7 +315,7 @@
|
|||
html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon))
|
||||
html.push('</button></div>');
|
||||
}
|
||||
if (that.$toolbar.find(".pull-right").size() > 0) {
|
||||
if (that.$toolbar.find(".pull-right").length > 0) {
|
||||
$(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
|
||||
} else {
|
||||
that.$toolbar.append(html.join(''));
|
||||
|
|
@ -338,10 +338,10 @@
|
|||
return;
|
||||
}
|
||||
var obj = $("form [name='" + field + "']", that.$commonsearch);
|
||||
if (obj.size() > 0) {
|
||||
if (obj.length > 0) {
|
||||
if (obj.is("select")) {
|
||||
$("option[value='" + value + "']", obj).prop("selected", true);
|
||||
} else if (obj.size() > 1) {
|
||||
} else if (obj.length > 1) {
|
||||
$("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
|
||||
} else {
|
||||
obj.val(value + "");
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
|
|||
Fast.api.layerfooter(layero, index, that);
|
||||
|
||||
//绑定事件
|
||||
if (layerfooter.size() > 0) {
|
||||
if (layerfooter.length > 0) {
|
||||
// 监听窗口内的元素及属性变化
|
||||
// Firefox和Chrome早期版本中带有前缀
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||
|
|
@ -186,7 +186,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
|
|||
}
|
||||
}
|
||||
}, options ? options : {});
|
||||
if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").size() > 0)) {
|
||||
if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
|
||||
if (top.$(".tab-pane.active").length > 0) {
|
||||
options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
|
||||
options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
|
||||
|
|
@ -211,11 +211,11 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
|
|||
layerfooter: function (layero, index, that) {
|
||||
var frame = Layer.getChildFrame('html', index);
|
||||
var layerfooter = frame.find(".layer-footer");
|
||||
if (layerfooter.size() > 0) {
|
||||
if (layerfooter.length > 0) {
|
||||
$(".layui-layer-footer", layero).remove();
|
||||
var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
|
||||
footer.html(layerfooter.html());
|
||||
if ($(".row", footer).size() === 0) {
|
||||
if ($(".row", footer).length === 0) {
|
||||
$(">", footer).wrapAll("<div class='row'></div>");
|
||||
}
|
||||
footer.insertAfter(layero.find('.layui-layer-content'));
|
||||
|
|
@ -330,7 +330,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
|
|||
// 绑定ESC关闭窗口事件
|
||||
$(window).keyup(function (e) {
|
||||
if (e.keyCode == 27) {
|
||||
if ($(".layui-layer").size() > 0) {
|
||||
if ($(".layui-layer").length > 0) {
|
||||
var index = 0;
|
||||
$(".layui-layer").each(function () {
|
||||
index = Math.max(index, parseInt($(this).attr("times")));
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
target: function (input) {
|
||||
var target = $(input).data("target");
|
||||
if (target && $(target).size() > 0) {
|
||||
if (target && $(target).length > 0) {
|
||||
return $(target);
|
||||
}
|
||||
var $formitem = $(input).closest('.form-group'),
|
||||
|
|
@ -96,7 +96,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
selectpicker: function (form) {
|
||||
//绑定select元素事件
|
||||
if ($(".selectpicker", form).size() > 0) {
|
||||
if ($(".selectpicker", form).length > 0) {
|
||||
require(['bootstrap-select', 'bootstrap-select-lang'], function () {
|
||||
$('.selectpicker', form).selectpicker();
|
||||
$(form).on("reset", function () {
|
||||
|
|
@ -109,7 +109,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
selectpage: function (form) {
|
||||
//绑定selectpage元素事件
|
||||
if ($(".selectpage", form).size() > 0) {
|
||||
if ($(".selectpage", form).length > 0) {
|
||||
require(['selectpage'], function () {
|
||||
$('.selectpage', form).selectPage({
|
||||
eAjaxSuccess: function (data) {
|
||||
|
|
@ -135,7 +135,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
cxselect: function (form) {
|
||||
//绑定cxselect元素事件
|
||||
if ($("[data-toggle='cxselect']", form).size() > 0) {
|
||||
if ($("[data-toggle='cxselect']", form).length > 0) {
|
||||
require(['cxselect'], function () {
|
||||
$.cxSelect.defaults.jsonName = 'name';
|
||||
$.cxSelect.defaults.jsonValue = 'value';
|
||||
|
|
@ -146,7 +146,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
citypicker: function (form) {
|
||||
//绑定城市远程插件
|
||||
if ($("[data-toggle='city-picker']", form).size() > 0) {
|
||||
if ($("[data-toggle='city-picker']", form).length > 0) {
|
||||
require(['citypicker'], function () {
|
||||
$(form).on("reset", function () {
|
||||
setTimeout(function () {
|
||||
|
|
@ -158,7 +158,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
datetimepicker: function (form) {
|
||||
//绑定日期时间元素事件
|
||||
if ($(".datetimepicker", form).size() > 0) {
|
||||
if ($(".datetimepicker", form).length > 0) {
|
||||
require(['bootstrap-datetimepicker'], function () {
|
||||
var options = {
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
|
|
@ -185,7 +185,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
daterangepicker: function (form) {
|
||||
//绑定日期时间元素事件
|
||||
if ($(".datetimerange", form).size() > 0) {
|
||||
if ($(".datetimerange", form).length > 0) {
|
||||
require(['bootstrap-daterangepicker'], function () {
|
||||
var ranges = {};
|
||||
ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
|
||||
|
|
@ -239,13 +239,13 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
*/
|
||||
faupload: function (form) {
|
||||
//绑定上传元素事件
|
||||
if ($(".plupload,.faupload", form).size() > 0) {
|
||||
if ($(".plupload,.faupload", form).length > 0) {
|
||||
Upload.api.upload($(".plupload,.faupload", form));
|
||||
}
|
||||
},
|
||||
faselect: function (form) {
|
||||
//绑定fachoose选择附件事件
|
||||
if ($(".faselect,.fachoose", form).size() > 0) {
|
||||
if ($(".faselect,.fachoose", form).length > 0) {
|
||||
$(".faselect,.fachoose", form).off('click').on('click', function () {
|
||||
var that = this;
|
||||
var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
|
||||
|
|
@ -294,7 +294,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
fieldlist: function (form) {
|
||||
//绑定fieldlist
|
||||
if ($(".fieldlist", form).size() > 0) {
|
||||
if ($(".fieldlist", form).length > 0) {
|
||||
require(['dragsort', 'template'], function (undefined, Template) {
|
||||
//刷新隐藏textarea的值
|
||||
var refresh = function (container) {
|
||||
|
|
@ -432,7 +432,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
var switcher = $.proxy(function () {
|
||||
var input = $(this).prev("input");
|
||||
input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
|
||||
if (input.size() > 0) {
|
||||
if (input.length > 0) {
|
||||
var yes = $(this).data("yes");
|
||||
var no = $(this).data("no");
|
||||
if (input.val() == yes) {
|
||||
|
|
@ -461,7 +461,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
|
||||
},
|
||||
slider: function (form) {
|
||||
if ($(".slider", form).size() > 0) {
|
||||
if ($(".slider", form).length > 0) {
|
||||
require(['bootstrap-slider'], function () {
|
||||
$('.slider').removeClass('hidden').css('width', function (index, value) {
|
||||
return $(this).parents('.form-control').width();
|
||||
|
|
@ -475,14 +475,14 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
}
|
||||
},
|
||||
tagsinput: function (form) {
|
||||
if ($("[data-role='tagsinput']", form).size() > 0) {
|
||||
if ($("[data-role='tagsinput']", form).length > 0) {
|
||||
require(['tagsinput', 'autocomplete'], function () {
|
||||
$("[data-role='tagsinput']").tagsinput();
|
||||
});
|
||||
}
|
||||
},
|
||||
autocomplete: function (form) {
|
||||
if ($("[data-role='autocomplete']", form).size() > 0) {
|
||||
if ($("[data-role='autocomplete']", form).length > 0) {
|
||||
require(['autocomplete'], function () {
|
||||
$("[data-role='autocomplete']").autocomplete();
|
||||
});
|
||||
|
|
@ -512,9 +512,12 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
}
|
||||
};
|
||||
// @formatter:on
|
||||
var dataArr = form.serializeArray(), dataObj = {};
|
||||
var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
|
||||
$(dataArr).each(function (i, field) {
|
||||
dataObj[field.name] = field.value;
|
||||
fieldName = field.name;
|
||||
fieldValue = field.value;
|
||||
fieldName = fieldName.substr(-2) === '[]' ? fieldName.substr(0, fieldName.length - 2) : fieldName;
|
||||
dataObj[fieldName] = typeof dataObj[fieldName] !== 'undefined' ? [dataObj[fieldName], fieldValue].join(',') : fieldValue;
|
||||
});
|
||||
|
||||
$.each(conditionArr, function (i, item) {
|
||||
|
|
@ -536,6 +539,9 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
return false;
|
||||
}
|
||||
var objvalue = dataObj[chkname];
|
||||
if ($.isArray(objvalue)) {
|
||||
objvalue = dataObj[chkname].join(",");
|
||||
}
|
||||
if (['>', '>=', '<', '<='].indexOf(operator) > -1) {
|
||||
objvalue = parseFloat(objvalue);
|
||||
value = parseFloat(value);
|
||||
|
|
@ -574,7 +580,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
},
|
||||
api: {
|
||||
submit: function (form, success, error, submit) {
|
||||
if (form.size() === 0) {
|
||||
if (form.length === 0) {
|
||||
Toastr.error("表单未初始化完成,无法提交");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -590,7 +596,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
|
|||
//修复当存在多选项元素时提交的BUG
|
||||
var params = {};
|
||||
var multipleList = $("[name$='[]']", form);
|
||||
if (multipleList.size() > 0) {
|
||||
if (multipleList.length > 0) {
|
||||
var postFields = form.serializeArray().map(function (obj) {
|
||||
return $(obj).prop("name");
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -158,7 +158,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
var toolbar = $(options.toolbar, parenttable);
|
||||
//跨页提示按钮
|
||||
var tipsBtn = $(".btn-selected-tips", parenttable);
|
||||
if (tipsBtn.size() === 0) {
|
||||
if (tipsBtn.length === 0) {
|
||||
tipsBtn = $('<a href="javascript:" class="btn btn-warning-light btn-selected-tips hide" data-animation="false" data-toggle="tooltip" data-title="' + __("Click to uncheck all") + '"><i class="fa fa-info-circle"></i> ' + __("Multiple selection mode: %s checked", "<b>0</b>") + '</a>').appendTo(toolbar);
|
||||
}
|
||||
//点击提示按钮
|
||||
|
|
@ -217,7 +217,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
//当内容渲染完成后
|
||||
table.on('post-body.bs.table', function (e, data) {
|
||||
$(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin");
|
||||
if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").size() > 0) {
|
||||
if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").length > 0) {
|
||||
// 拖拽选择,需要重新绑定事件
|
||||
require(['drag', 'drop'], function () {
|
||||
var checkboxtd = $(Table.config.checkboxtd, table);
|
||||
|
|
@ -320,7 +320,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
|
||||
});
|
||||
// 导入按钮事件
|
||||
if ($(Table.config.importbtn, toolbar).size() > 0) {
|
||||
if ($(Table.config.importbtn, toolbar).length > 0) {
|
||||
require(['upload'], function (Upload) {
|
||||
Upload.api.upload($(Table.config.importbtn, toolbar), function (data, ret) {
|
||||
Fast.api.ajax({
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
|
|||
addedfiles: function (files) {
|
||||
if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
|
||||
var inputObj = $("#" + this.options.inputId);
|
||||
if (inputObj.size() > 0) {
|
||||
if (inputObj.length > 0) {
|
||||
var value = $.trim(inputObj.val());
|
||||
var nums = value === '' ? 0 : value.split(/\,/).length;
|
||||
var remain = this.options.maxFiles - nums;
|
||||
|
|
|
|||
Loading…
Reference in New Issue