作者 Karson

修复后台关闭当前选项卡未激活前一选项卡的BUG

修复在移动端包含tooltip需要点击两次的BUG
... ... @@ -104,7 +104,7 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
refreshmenu: function () {
top.window.$(".sidebar-menu").trigger("refresh");
},
gettablecolumnbutton: function(options){
gettablecolumnbutton: function (options) {
if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
if (tableOptions) {
... ... @@ -226,8 +226,10 @@ define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
});
}
//tooltip和popover
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
$('body').tooltip({selector: '[data-toggle="popover"]'});
if (!('ontouchstart' in document.documentElement)) {
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
}
$('body').popover({selector: '[data-toggle="popover"]'});
}
};
Backend.api = $.extend(Fast.api, Backend.api);
... ...
... ... @@ -50,8 +50,10 @@ define(['fast', 'template'], function (Fast, Template) {
return false;
});
//tooltip和popover
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
$('body').tooltip({selector: '[data-toggle="popover"]'});
if (!('ontouchstart' in document.documentElement)) {
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
}
$('body').popover({selector: '[data-toggle="popover"]'});
}
};
Frontend.api = $.extend(Fast.api, Frontend.api);
... ...
... ... @@ -5330,7 +5330,7 @@ define('backend',['fast', 'template', 'moment'], function (Fast, Template, Momen
refreshmenu: function () {
top.window.$(".sidebar-menu").trigger("refresh");
},
gettablecolumnbutton: function(options){
gettablecolumnbutton: function (options) {
if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
if (tableOptions) {
... ... @@ -5452,8 +5452,10 @@ define('backend',['fast', 'template', 'moment'], function (Fast, Template, Momen
});
}
//tooltip和popover
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
$('body').tooltip({selector: '[data-toggle="popover"]'});
if (!('ontouchstart' in document.documentElement)) {
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
}
$('body').popover({selector: '[data-toggle="popover"]'});
}
};
Backend.api = $.extend(Fast.api, Backend.api);
... ... @@ -10389,14 +10391,14 @@ define("drop", function(){});
var title = $(this).attr('title') ? $(this).attr('title') : $.trim($(this).text());
var url = $(this).attr('url');
var content = options.content ? options.content : $(this).attr('content');
var ajax = $(this).attr('ajax') ? true : false;
var ajax = $(this).attr('ajax') === '1' || $(this).attr('ajax') === 'true';
var state = ({
url: url, title: title, id: id, content: content, ajax: ajax
});
document.title = title;
if (history.pushState && !$(this).data("pushstate")) {
var pushurl = url.indexOf("ref=addtabs") == -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
var pushurl = url.indexOf("ref=addtabs") === -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
try {
window.history.pushState(state, title, pushurl);
} catch (e) {
... ... @@ -10414,27 +10416,27 @@ define("drop", function(){});
}
});
navobj.on('click', '.close-tab', function (e) {
id = $(this).prev("a").attr("aria-controls");
navobj.on('click', '.close-tab', function () {
var id = $(this).prev("a").attr("aria-controls");
_close(id);
return false;
});
navobj.on('dblclick', 'li[role=presentation]', function (e) {
navobj.on('dblclick', 'li[role=presentation]', function () {
$(this).find(".close-tab").trigger("click");
});
navobj.on('click', 'li[role=presentation]', function (e) {
navobj.on('click', 'li[role=presentation]', function () {
$("a[addtabs=" + $("a", this).attr("node-id") + "]").trigger("click");
});
$(window).resize(function () {
if (typeof options.nav == 'object') {
if (typeof options.nav === 'object') {
var siblingsWidth = 0;
navobj.siblings().each(function () {
siblingsWidth += $(this).outerWidth();
});
navobj.width(navobj.parent().width() - siblingsWidth);
} else {
$("#nav").width($("#header > .navbar").width() - $(".sidebar-toggle").outerWidth() - $(".navbar-custom-menu").outerWidth() - 20);
$("#nav").width($("#header").find("> .navbar").width() - $(".sidebar-toggle").outerWidth() - $(".navbar-custom-menu").outerWidth() - 20);
}
_drop();
});
... ... @@ -10446,36 +10448,41 @@ define("drop", function(){});
conid = 'con_' + opts.id;
url = opts.url;
url += (opts.url.indexOf("?") > -1 ? "&addtabs=1" : "?addtabs=1");
var tabitem = $('#' + tabid, navobj);
var conitem = $('#' + conid, tabobj);
navobj.find("[role='presentation']").removeClass('active');
tabobj.find("[role='tabpanel']").removeClass('active');
//如果TAB不存在,创建一个新的TAB
if ($("#" + tabid).size() == 0) {
if (tabitem.size() === 0) {
//创建新TAB的title
title = $('<li role="presentation" id="' + tabid + '"><a href="#' + conid + '" node-id="' + opts.id + '" aria-controls="' + id + '" role="tab" data-toggle="tab">' + opts.title + '</a></li>');
tabitem = $('<li role="presentation" id="' + tabid + '"><a href="#' + conid + '" node-id="' + opts.id + '" aria-controls="' + id + '" role="tab" data-toggle="tab">' + opts.title + '</a></li>');
//是否允许关闭
if (options.close && $("li", navobj).size() > 0) {
title.append(' <i class="close-tab fa fa-remove"></i>');
tabitem.append(' <i class="close-tab fa fa-remove"></i>');
}
//创建新TAB的内容
content = $('<div role="tabpanel" class="tab-pane" id="' + conid + '"></div>');
conitem = $('<div role="tabpanel" class="tab-pane" id="' + conid + '"></div>');
//是否指定TAB内容
if (opts.content) {
content.append(opts.content);
conitem.append(opts.content);
} else if (options.iframeUse && !opts.ajax) {//没有内容,使用IFRAME打开链接
var height = options.iframeHeight;
content.append('<iframe src="' + url + '" width="100%" height="' + height + '" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe></div>');
conitem.append('<iframe src="' + url + '" width="100%" height="' + height + '" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe></div>');
} else {
$.get(url, function (data) {
content.append(data);
conitem.append(data);
});
}
//加入TABS
if ($('.tabdrop li').size() > 0) {
$('.tabdrop ul').append(title);
if ($('.tabdrop li', navobj).size() > 0) {
$('.tabdrop ul', navobj).append(tabitem);
} else {
navobj.append(title);
navobj.append(tabitem);
}
tabobj.append(content);
tabobj.append(conitem);
} else {
//强制刷新iframe
if (options.iframeForceRefresh) {
... ... @@ -10486,27 +10493,31 @@ define("drop", function(){});
}
localStorage.setItem("addtabs", $(this).prop('outerHTML'));
//激活TAB
$("#" + tabid).addClass('active');
$("#" + conid).addClass("active");
tabitem.addClass('active');
conitem.addClass("active");
_drop();
};
var _close = function (id) {
var tabid = 'tab_' + id;
var conid = 'con_' + id;
var tabitem = $('#' + tabid, navobj);
var conitem = $('#' + conid, tabobj);
//如果关闭的是当前激活的TAB,激活他的前一个TAB
if (obj.find("li.active").not('.tabdrop').attr('id') == tabid) {
if ($("#" + tabid).prev().not(".tabdrop").size() > 0) {
$("#" + tabid).prev().not(".tabdrop").find("a").trigger("click");
} else if ($("#" + tabid).next().size() > 0) {
$("#" + tabid).next().trigger("click");
if (obj.find("li.active").not('.tabdrop').attr('id') === tabid) {
var prev = tabitem.prev().not(".tabdrop");
var next = tabitem.next().not(".tabdrop");
if (prev.size() > 0) {
prev.find('a').trigger("click");
} else if (next.size() > 0) {
next.find('a').trigger("click");
} else {
$(">li:last > a", navobj).trigger('click');
$(">li:not(.tabdrop):last > a", navobj).trigger('click');
}
}
//关闭TAB
$("#" + tabid).remove();
$("#" + conid).remove();
tabitem.remove();
conitem.remove();
_drop();
options.callback();
};
... ... @@ -10519,11 +10530,11 @@ define("drop", function(){});
$.fn.refreshAddtabs = function () {
var navobj = $(this);
var dropdown = $(".tabdrop", navobj);
if (dropdown.size() == 0) {
var dropdown = $('<li class="dropdown pull-right hide tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;">' +
if (dropdown.size() === 0) {
dropdown = $('<li class="dropdown pull-right hide tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;">' +
'<i class="glyphicon glyphicon-align-justify"></i>' +
' <b class="caret"></b></a><ul class="dropdown-menu"></ul></li>');
dropdown.appendTo(navobj);
dropdown.prependTo(navobj);
}
//检测是否有下拉样式
... ... @@ -10538,11 +10549,11 @@ define("drop", function(){});
//检查超过一行的标签页
var litabs = navobj.append(dropdown.find('li')).find('>li').not('.tabdrop');
var totalwidth = 0;
litabs.each(function (i, j) {
litabs.each(function () {
totalwidth += $(this).outerWidth(true);
});
if (navobj.width() < totalwidth) {
litabs.each(function (i, j) {
litabs.each(function () {
liwidth += $(this).outerWidth(true);
if (liwidth > maxwidth) {
dropdown.find('ul').append($(this));
... ... @@ -10551,7 +10562,7 @@ define("drop", function(){});
});
if (collection > 0) {
dropdown.removeClass('hide');
if (dropdown.find('.active').length == 1) {
if (dropdown.find('.active').length === 1) {
dropdown.addClass('active');
} else {
dropdown.removeClass('active');
... ...
... ... @@ -1040,8 +1040,10 @@ define('frontend',['fast', 'template'], function (Fast, Template) {
return false;
});
//tooltip和popover
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
$('body').tooltip({selector: '[data-toggle="popover"]'});
if (!('ontouchstart' in document.documentElement)) {
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
}
$('body').popover({selector: '[data-toggle="popover"]'});
}
};
Frontend.api = $.extend(Fast.api, Frontend.api);
... ...