From b774672ec0be364c94e08fc532c748a68ff43edd Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Sat, 18 Oct 2014 21:56:50 +0200 Subject: [PATCH 1/3] Clicking an Extension Manager tab while still loading will show it --- src/extensibility/ExtensionManagerDialog.js | 13 +++++++++---- src/widgets/bootstrap-tab.js | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/extensibility/ExtensionManagerDialog.js b/src/extensibility/ExtensionManagerDialog.js index 7c322fea5a1..58e398af541 100644 --- a/src/extensibility/ExtensionManagerDialog.js +++ b/src/extensibility/ExtensionManagerDialog.js @@ -311,9 +311,11 @@ define(function (require, exports, module) { $searchClear = $(".search-clear", $dlg); function setActiveTab($tab) { - models[_activeTabIndex].scrollPos = $(".modal-body", $dlg).scrollTop(); + if (models[_activeTabIndex]) { + models[_activeTabIndex].scrollPos = $(".modal-body", $dlg).scrollTop(); + } $tab.tab("show"); - $(".modal-body", $dlg).scrollTop(models[_activeTabIndex].scrollPos || 0); + $(".modal-body", $dlg).scrollTop((models[_activeTabIndex] && models[_activeTabIndex].scrollPos) || 0); $searchClear.click(); } @@ -420,8 +422,11 @@ define(function (require, exports, module) { }); }); - // Open dialog to Installed tab if extension updates are available - if ($("#toolbar-extension-manager").hasClass('updatesAvailable')) { + var $activeTab = $dlg.find(".nav-tabs li.active a"); + if ($activeTab.length) { // If there's already a tab selected, show it + $activeTab.tab("show"); + } else if ($("#toolbar-extension-manager").hasClass('updatesAvailable')) { + // Open dialog to Installed tab if extension updates are available $dlg.find(".nav-tabs a.installed").tab("show"); } else { // Otherwise show the first tab $dlg.find(".nav-tabs a:first").tab("show"); diff --git a/src/widgets/bootstrap-tab.js b/src/widgets/bootstrap-tab.js index 1d23df6c641..847e5bf5901 100644 --- a/src/widgets/bootstrap-tab.js +++ b/src/widgets/bootstrap-tab.js @@ -46,8 +46,10 @@ selector = $this.attr('href') selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } + + $target = $(selector) - if ( $this.parent('li').hasClass('active') ) return + if ( $target.hasClass('active') ) return previous = $ul.find('.active:last a')[0] @@ -59,8 +61,6 @@ if (e.isDefaultPrevented()) return - $target = $(selector) - this.activate($this.parent('li'), $ul) this.activate($target, $target.parent(), function () { $this.trigger({ From de80ba8a3121db97c54ef5cb189a7c7cf3d171df Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Sun, 19 Oct 2014 00:11:49 +0200 Subject: [PATCH 2/3] Use function to clear search --- src/extensibility/ExtensionManagerDialog.js | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/extensibility/ExtensionManagerDialog.js b/src/extensibility/ExtensionManagerDialog.js index 58e398af541..54948f1cb79 100644 --- a/src/extensibility/ExtensionManagerDialog.js +++ b/src/extensibility/ExtensionManagerDialog.js @@ -291,6 +291,17 @@ define(function (require, exports, module) { return searchDisabled; } + function clearSearch() { + $search.val(""); + views.forEach(function (view, index) { + view.filter(""); + }); + + if (!updateSearchDisabled()) { + $search.focus(); + } + } + // Open the dialog dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(dialogTemplate, context)); @@ -316,7 +327,7 @@ define(function (require, exports, module) { } $tab.tab("show"); $(".modal-body", $dlg).scrollTop((models[_activeTabIndex] && models[_activeTabIndex].scrollPos) || 0); - $searchClear.click(); + clearSearch(); } // Dialog tabs @@ -402,16 +413,7 @@ define(function (require, exports, module) { views.forEach(function (view) { view.filter(query); }); - }).on("click", ".search-clear", function (e) { - $search.val(""); - views.forEach(function (view, index) { - view.filter(""); - }); - - if (!updateSearchDisabled()) { - $search.focus(); - } - }); + }).on("click", ".search-clear", clearSearch); // Disable the search field when there are no items in the model models.forEach(function (model, index) { From e6ccd1bf85a11c0d70f59f4c05f102e9ae0606a4 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Fri, 23 Jan 2015 20:08:55 +0100 Subject: [PATCH 3/3] Code review changes --- src/extensibility/ExtensionManagerDialog.js | 7 +++++-- src/widgets/bootstrap-tab.js | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/extensibility/ExtensionManagerDialog.js b/src/extensibility/ExtensionManagerDialog.js index d6428378dd9..b0a6367bf6b 100644 --- a/src/extensibility/ExtensionManagerDialog.js +++ b/src/extensibility/ExtensionManagerDialog.js @@ -326,8 +326,10 @@ define(function (require, exports, module) { models[_activeTabIndex].scrollPos = $(".modal-body", $dlg).scrollTop(); } $tab.tab("show"); - $(".modal-body", $dlg).scrollTop((models[_activeTabIndex] && models[_activeTabIndex].scrollPos) || 0); - clearSearch(); + if (models[_activeTabIndex]) { + $(".modal-body", $dlg).scrollTop(models[_activeTabIndex].scrollPos || 0); + clearSearch(); + } } // Dialog tabs @@ -426,6 +428,7 @@ define(function (require, exports, module) { var $activeTab = $dlg.find(".nav-tabs li.active a"); if ($activeTab.length) { // If there's already a tab selected, show it + $activeTab.parent().removeClass("active"); // workaround for bootstrap-tab $activeTab.tab("show"); } else if ($("#toolbar-extension-manager").hasClass('updatesAvailable')) { // Open dialog to Installed tab if extension updates are available diff --git a/src/widgets/bootstrap-tab.js b/src/widgets/bootstrap-tab.js index 847e5bf5901..1d23df6c641 100644 --- a/src/widgets/bootstrap-tab.js +++ b/src/widgets/bootstrap-tab.js @@ -46,10 +46,8 @@ selector = $this.attr('href') selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } - - $target = $(selector) - if ( $target.hasClass('active') ) return + if ( $this.parent('li').hasClass('active') ) return previous = $ul.find('.active:last a')[0] @@ -61,6 +59,8 @@ if (e.isDefaultPrevented()) return + $target = $(selector) + this.activate($this.parent('li'), $ul) this.activate($target, $target.parent(), function () { $this.trigger({