Feature #4363: Fix remove tab events

This commit is contained in:
Daniel Molina committed 2016-03-14 18:09:08 +01:00
1 parent 1a864b7315
commit ce9343b7ff
4 files changed
+94 -91

No files matched your search

@@ -136,27 +136,6 @@ define(function(require) {
return false;
});
// close icon: removing the tab on click
$("#roles_tabs", context).on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var dd = $(this).closest('dd');
var dl = $(this).closest('dl');
var content = $(target);
var role_id = content.attr("role_id");
dd.remove();
content.remove();
if (dd.attr("class") == 'is-active') {
$('a', dl.children('dd').last()).click();
}
delete that.roleTabObjects[role_id];
return false;
});
// Fill parents table
// Each time a tab is clicked the table is filled with existing tabs (roles)
// Selected roles are kept
@@ -430,10 +409,11 @@ define(function(require) {
}
function _add_role_tab(role_id, dialog) {
var that = this;
var html_role_id = 'role' + role_id;
var role_tab = new RoleTab(html_role_id);
this.roleTabObjects[role_id] = role_tab;
that.roleTabObjects[role_id] = role_tab;
// Append the new div containing the tab and add the tab to the list
var role_section = $('<div id="'+html_role_id+'Tab" class="tabs-panel role_content wizard_internal_tab" role_id="'+role_id+'">'+
@@ -456,6 +436,27 @@ define(function(require) {
Foundation.reInit($("ul#roles_tabs", dialog));
$("a", a).trigger("click");
// close icon: removing the tab on click
a.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
var role_id = content.attr("role_id");
li.remove();
content.remove();
if (li.hasClass('is-active')) {
$('a', ul.children('li').last()).click();
}
delete that.roleTabObjects[role_id];
return false;
});
role_tab.setup(role_section);
role_tab.onShow();
}
@@ -364,25 +364,6 @@ define(function(require) {
Foundation.reflow(context, 'tabs');
that.numberOfProviders = 0;
// close icon: removing the tab on click
context.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
li.remove();
content.remove();
if (li.attr("class") == 'active') {
$('a', ul.children('li').last()).click();
}
$("ul#template_create_hybrid_tabs li", context).each(function(index) {
$("a", this).html(Locale.tr("Provider") + ' ' + index + " <i class='fa fa-times-circle remove-tab'></i>");
})
});
context.on("click", "#tf_btn_hybrid", function() {
that.addProviderTab(that.numberOfProviders, context);
that.numberOfProviders++;
@@ -488,6 +469,25 @@ define(function(require) {
$("a", a).trigger("click");
// close icon: removing the tab on click
a.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
li.remove();
content.remove();
if (li.hasClass('is-active')) {
$('a', ul.children('li').last()).click();
}
$("ul#template_create_hybrid_tabs li", context).each(function(index) {
$("a", this).html(Locale.tr("Provider") + ' ' + index + " <i class='fa fa-times-circle remove-tab'></i>");
})
});
var providerSection = $('#' + htmlId + 'Tab', context);
providerSection.on("change", "input.hybridRadio", function() {
@@ -88,26 +88,6 @@ define(function(require) {
Foundation.reflow(context, 'tabs');
// close icon: removing the tab on click
context.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
li.remove();
content.remove();
var nicId = content.attr("nicId");
delete that.nicTabObjects[nicId];
if (li.attr("class") == 'active') {
$('a', ul.children('li').last()).click();
}
that.renameTabLinks(context);
});
context.on("click", "#tf_btn_nics", function() {
that.addNicTab(context);
return false;
@@ -171,8 +151,9 @@ define(function(require) {
}
function _addNicTab(context) {
this.numberOfNics++;
var nicTab = new NicTab(this.numberOfNics);
var that = this;
that.numberOfNics++;
var nicTab = new NicTab(that.numberOfNics);
var content = $('<div id="' + nicTab.nicTabId + '" class="nic wizard_internal_tab tabs-panel">' +
nicTab.html() +
@@ -187,10 +168,30 @@ define(function(require) {
$("a", a).trigger("click");
nicTab.setup(content);
content.attr("nicId", this.numberOfNics);
content.attr("nicId", that.numberOfNics);
this.renameTabLinks(context);
this.nicTabObjects[this.numberOfNics] = nicTab;
that.renameTabLinks(context);
that.nicTabObjects[that.numberOfNics] = nicTab;
// close icon: removing the tab on click
a.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
li.remove();
content.remove();
var nicId = content.attr("nicId");
delete that.nicTabObjects[nicId];
if (li.hasClass('is-active')) {
$('a', ul.children('li').last()).click();
}
that.renameTabLinks(context);
});
}
function _renameTabLinks(context) {
@@ -88,26 +88,6 @@ define(function(require) {
Foundation.reflow(context, 'tabs');
// close icon: removing the tab on click
context.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
li.remove();
content.remove();
var diskId = content.attr("diskId");
delete that.diskTabObjects[diskId];
if (li.attr("class") == 'is-active') {
$('a', ul.children('li').last()).click();
}
that.renameTabLinks(context);
});
context.on("click", "#tf_btn_disks", function() {
that.addDiskTab(context);
return false;
@@ -155,8 +135,9 @@ define(function(require) {
}
function _addDiskTab(context) {
this.numberOfDisks++;
var diskTab = new DiskTab(this.numberOfDisks);
var that = this;
that.numberOfDisks++;
var diskTab = new DiskTab(that.numberOfDisks);
var content = $('<div id="' + diskTab.diskTabId + '" class="disk wizard_internal_tab tabs-panel">' +
diskTab.html() +
@@ -171,10 +152,30 @@ define(function(require) {
$("a", a).trigger("click");
diskTab.setup(content);
content.attr("diskId", this.numberOfDisks);
content.attr("diskId", that.numberOfDisks);
this.renameTabLinks(context);
this.diskTabObjects[this.numberOfDisks] = diskTab;
that.renameTabLinks(context);
that.diskTabObjects[that.numberOfDisks] = diskTab;
// close icon: removing the tab on click
a.on("click", "i.remove-tab", function() {
var target = $(this).parent().attr("href");
var li = $(this).closest('li');
var ul = $(this).closest('ul');
var content = $(target);
li.remove();
content.remove();
var diskId = content.attr("diskId");
delete that.diskTabObjects[diskId];
if (li.hasClass('is-active')) {
$('a', ul.children('li').last()).click();
}
that.renameTabLinks(context);
});
}
function _renameTabLinks(context) {