Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

For #5852: Clicking an Extension Manager tab while still loading will show it #9594

Merged
merged 4 commits into from
Jan 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions src/extensibility/ExtensionManagerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -311,10 +322,14 @@ 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);
$searchClear.click();
if (models[_activeTabIndex]) {
$(".modal-body", $dlg).scrollTop(models[_activeTabIndex].scrollPos || 0);
clearSearch();
}
}

// Dialog tabs
Expand Down Expand Up @@ -400,16 +415,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) {
Expand All @@ -420,8 +426,12 @@ 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.parent().removeClass("active"); // workaround for bootstrap-tab
$activeTab.tab("show");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than making changes to the bootstrap-tab widget, you could put this line of code above the show statement:

$activeTab.parent().removeClass("active");

I think this is cleaner because this way you don't have to modify bootstrap which could be hard to maintain and could have side effects for other parts of the app.

} 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");
Expand Down