Bug 606548 - Start page options > Custom vs Current pages is redundant [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2010-11-05 10:10:00 -04:00
Родитель 3a420ae3a3
Коммит 3944358582
4 изменённых файлов: 61 добавлений и 9 удалений

Просмотреть файл

@ -2416,10 +2416,20 @@ var MenuListHelperUI = {
return this._title = document.getElementById("menulist-title");
},
_firePopupEvent: function firePopupEvent(aEventName) {
let menupopup = this._currentList.menupopup;
if (menupopup.hasAttribute(aEventName)) {
let func = new Function("event", menupopup.getAttribute(aEventName));
func.call(this);
}
},
_currentList: null,
show: function mn_show(aMenulist) {
this._currentList = aMenulist;
this._container.setAttribute("for", aMenulist.id);
this._title.value = aMenulist.title || "";
this._firePopupEvent("onpopupshowing");
let container = this._container;
let listbox = this._popup.lastChild;
@ -2430,6 +2440,11 @@ var MenuListHelperUI = {
for (let i = 0; i < children.length; i++) {
let child = children[i];
let item = document.createElement("richlistitem");
if (child.disabled)
item.setAttribute("disabled", "true");
if (child.hidden)
item.setAttribute("hidden", "true");
// Add selected as a class name instead of an attribute to not being overidden
// by the richlistbox behavior (it sets the "current" and "selected" attribute
item.setAttribute("class", "menulist-command prompt-button" + (child.selected ? " selected" : ""));
@ -2453,6 +2468,7 @@ var MenuListHelperUI = {
hide: function mn_hide() {
this._currentList = null;
this._container.removeAttribute("for");
this._container.hidden = true;
window.removeEventListener("resize", this, true);
BrowserUI.popPopup(this);

Просмотреть файл

@ -436,7 +436,7 @@
</setting>
<setting id="prefs-homepage" title="&homepage.title;" type="control">
<menulist id="prefs-homepage-options" oncommand="PreferencesView.updateHomePage();">
<menupopup>
<menupopup onpopupshowing="PreferencesView.updateHomePageList();">
<menuitem id="prefs-homepage-default" label="&homepage.default;" value="default"/>
<menuitem id="prefs-homepage-none" label="&homepage.none;" value="none"/>
<menuitem id="prefs-homepage-currentpage" label="&homepage.currentpage;" value="currentpage"/>

Просмотреть файл

@ -170,7 +170,7 @@ var PreferencesView = {
if (localeCount == 1)
document.getElementById("prefs-uilanguage").hidden = true;
},
updateLocale: function updateLocale() {
// Which locale did the user select?
let newLocale = this._languages.selectedItem.value;
@ -223,7 +223,7 @@ var PreferencesView = {
// Show or hide the title or URL of the custom homepage
this._showHomePageHint(display);
// Add the helper "Custom Page" item in the menulist, if needed
let options = document.getElementById("prefs-homepage-options");
if (value == "custom") {
@ -235,6 +235,22 @@ var PreferencesView = {
options.value = value;
},
updateHomePageList: function updateHomePageMenuList() {
// Update the "Use Current Page" item in the menulist by disabling it if
// the current page is already the user homepage
let currentUrl = Browser.selectedBrowser.currentURI.spec;
let currentHomepage = Browser.getHomePage();
let isHomepage = (currentHomepage == currentUrl);
let itemRow = document.getElementById("prefs-homepage-currentpage");
if (currentHomepage == "about:home") {
itemRow.disabled = isHomepage;
itemRow.hidden = false;
} else {
itemRow.hidden = isHomepage;
itemRow.disabled = false;
}
},
updateHomePage: function updateHomePage() {
let options = document.getElementById("prefs-homepage-options");
let value = options.selectedItem.value;
@ -250,8 +266,14 @@ var PreferencesView = {
url = "about:home";
break;
case "currentpage":
url = Browser.selectedBrowser.currentURI.spec;
display = Browser.selectedBrowser.contentTitle || url;
// If the selected page is the about:home page, emulate the default case
let currentURL = Browser.selectedBrowser.currentURI.spec;
if (currentURL == "about:home") {
value = "default";
} else {
url = currentURL;
display = Browser.selectedBrowser.contentTitle || currentURL;
}
break;
}
@ -272,8 +294,11 @@ var PreferencesView = {
helper = options.appendItem(Elements.browserBundle.getString("homepage.custom2"), "custom");
options.selectedItem = helper;
} else if (helper) {
options.menupopup.removeChild(helper);
} else {
if (helper)
options.menupopup.removeChild(helper);
options.selectedItem = options.menupopup.getElementsByAttribute("value", value)[0];
}
// Save the homepage URL to a preference

Просмотреть файл

@ -437,6 +437,11 @@ toolbarbutton.choice-remotetabs {
list-style-image: url("chrome://browser/skin/images/console-default-64.png");
}
/* preferences panel UI -----------------------------------------------------*/
#menulist-container[for="prefs-homepage-options"] .menulist-command.selected {
pointer-events: none;
}
/* addons panel UI ------------------------------------------------------- */
@media (min-width: 500px) {
#addons-repo {
@ -1031,6 +1036,12 @@ pageaction {
-moz-box-align: center;
}
.prompt-button[disabled="true"],
.context-command[disabled="true"] {
pointer-events: none;
color: #aaa !important;
}
.prompt-button[selected="true"],
.context-command[selected="true"] {
background: transparent;
@ -1066,7 +1077,7 @@ pageaction {
}
.prompt-button:not([disabled]):hover:active,
.context-command:hover:active,
.context-command:not([disabled]):hover:active,
pageaction:not([disabled]):hover:active {
background: url("chrome://browser/skin/images/popup-selected-item-hdpi.png") repeat-x !important;
background-origin: border-box !important;
@ -1397,7 +1408,7 @@ pageaction:not([image]) > hbox >.pageaction-image {
background-color: #8db8d8;
}
echrome-select-option[disabled="true"] {
.chrome-select-option[disabled="true"] {
pointer-events: none;
color: #aaa !important;
}