/*
选项卡
id easyui标签的ID
maxlength 设置选项卡最大个数
*/
jeasyui.Tabs = function (id, maxlength) {
this.id = id;
this.maxlength = maxlength;
this.currTabCount = 1;
//自动关闭选项卡函数
this.autoCloseTab = function () {
$('#' + this.id).tabs('close', 1);
};
//关闭指定选项卡函数
this.CloseTab = function (title) {
$('#' + this.id).tabs('close', title);
};
//关闭除选中外所有选项卡函数
this.CloseAllTabExceptThis = function (title) {
var alltabs = $('#' + this.id).tabs('tabs');
var currtab = $('#' + this.id).tabs("getTab", title);
var titlelist = new Array();
var listcount = 0;
for (var i = 0; i < alltabs.length; i++) {
if (alltabs[i] != currtab && alltabs[i].panel('options').title != "首页") {
titlelist[listcount] = alltabs[i].panel('options').title;
listcount++;
}
}
for (var j = 0; j < listcount; j++) {
$('#' + this.id).tabs('close', titlelist[j]);
}
};
};
//添加一个选项卡
jeasyui.Tabs.prototype.addTab = function (titleName, url) {
if (!this.exists(titleName)) {
//var iframe = $('');
$('#' + this.id).tabs('add', {
title: titleName,
//content: iframe,
href:url,
closable: true,
cache: true,
fit: true
});
//iframe.attr('src', url);
} else {
this.selectTab(titleName);
}
};
//选中指定选项卡(参数titleName:选项卡标题名)
jeasyui.Tabs.prototype.selectTab = function (titleName) {
$('#'+this.id).tabs('select', titleName);
};
//获取当前选项卡
jeasyui.Tabs.prototype.getSelected = function () {
return $('#' + this.id).tabs('getSelected');
};
//刷新选项卡(参数tab:选项卡)
jeasyui.Tabs.prototype.refresh = function (tab) {
tab.panel('refresh', tab.panel('options').href);
};
//验证选项卡是否存在(参数titleName:选项卡标题名)
jeasyui.Tabs.prototype.exists = function (titleName) {
var tab = $('#' + this.id).tabs('exists', titleName);
return tab;
};
阅读(938) | 评论(0) | 转发(0) |