function
addTab(options) {
var
exists = checkTabIsExists(options.tabMainName, options.tabName);
if
(exists){
$(
"#tab_a_"
+options.tabName).click();
}
else
{
$(
"#"
+options.tabMainName).append(
'<li id="tab_li_'
+options.tabName+
'"><a href="#tab_content_'
+options.tabName+
'" data-toggle="tab" id="tab_a_'
+options.tabName+
'"><button class="close closeTab" type="button" onclick="closeTab(this);">×</button>'
+options.tabTitle+
'</a></li>'
);
mainHeight = $(document.body).height() - 5;
var
content =
''
;
if
(options.content){
content = option.content;
}
else
{
content =
'<iframe src="'
+ options.tabUrl +
'" width="100%" height="'
+mainHeight+
'px" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes" allowtransparency="yes"></iframe>'
;
}
$(
"#"
+options.tabContentMainName).append(
'<div id="tab_content_'
+options.tabName+
'" role="tabpanel" class="tab-pane" id="'
+options.tabName+
'">'
+content+
'</div>'
);
$(
"#tab_a_"
+options.tabName).click();
}
}
function
closeTab (button) {
var
li_id = $(button).parent().parent().attr(
'id'
);
var
id = li_id.replace(
"tab_li_"
,
""
);
if
($(
"li.active"
).attr(
'id'
) == li_id) {
$(
"li.active"
).prev().find(
"a"
).click();
}
$(
"#"
+ li_id).remove();
$(
"#tab_content_"
+ id).remove();
};
function
checkTabIsExists(tabMainName, tabName){
var
tab = $(
"#"
+tabMainName+
" > #tab_li_"
+tabName);
return
tab.length > 0;
}