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"); 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, _currentList: null,
show: function mn_show(aMenulist) { show: function mn_show(aMenulist) {
this._currentList = aMenulist; this._currentList = aMenulist;
this._container.setAttribute("for", aMenulist.id);
this._title.value = aMenulist.title || ""; this._title.value = aMenulist.title || "";
this._firePopupEvent("onpopupshowing");
let container = this._container; let container = this._container;
let listbox = this._popup.lastChild; let listbox = this._popup.lastChild;
@ -2430,6 +2440,11 @@ var MenuListHelperUI = {
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
let child = children[i]; let child = children[i];
let item = document.createElement("richlistitem"); 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 // 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 // by the richlistbox behavior (it sets the "current" and "selected" attribute
item.setAttribute("class", "menulist-command prompt-button" + (child.selected ? " selected" : "")); item.setAttribute("class", "menulist-command prompt-button" + (child.selected ? " selected" : ""));
@ -2453,6 +2468,7 @@ var MenuListHelperUI = {
hide: function mn_hide() { hide: function mn_hide() {
this._currentList = null; this._currentList = null;
this._container.removeAttribute("for");
this._container.hidden = true; this._container.hidden = true;
window.removeEventListener("resize", this, true); window.removeEventListener("resize", this, true);
BrowserUI.popPopup(this); BrowserUI.popPopup(this);

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

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

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

@ -235,6 +235,22 @@ var PreferencesView = {
options.value = value; 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() { updateHomePage: function updateHomePage() {
let options = document.getElementById("prefs-homepage-options"); let options = document.getElementById("prefs-homepage-options");
let value = options.selectedItem.value; let value = options.selectedItem.value;
@ -250,8 +266,14 @@ var PreferencesView = {
url = "about:home"; url = "about:home";
break; break;
case "currentpage": case "currentpage":
url = Browser.selectedBrowser.currentURI.spec; // If the selected page is the about:home page, emulate the default case
display = Browser.selectedBrowser.contentTitle || url; let currentURL = Browser.selectedBrowser.currentURI.spec;
if (currentURL == "about:home") {
value = "default";
} else {
url = currentURL;
display = Browser.selectedBrowser.contentTitle || currentURL;
}
break; break;
} }
@ -272,8 +294,11 @@ var PreferencesView = {
helper = options.appendItem(Elements.browserBundle.getString("homepage.custom2"), "custom"); helper = options.appendItem(Elements.browserBundle.getString("homepage.custom2"), "custom");
options.selectedItem = helper; options.selectedItem = helper;
} else if (helper) { } else {
if (helper)
options.menupopup.removeChild(helper); options.menupopup.removeChild(helper);
options.selectedItem = options.menupopup.getElementsByAttribute("value", value)[0];
} }
// Save the homepage URL to a preference // 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"); 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 ------------------------------------------------------- */ /* addons panel UI ------------------------------------------------------- */
@media (min-width: 500px) { @media (min-width: 500px) {
#addons-repo { #addons-repo {
@ -1031,6 +1036,12 @@ pageaction {
-moz-box-align: center; -moz-box-align: center;
} }
.prompt-button[disabled="true"],
.context-command[disabled="true"] {
pointer-events: none;
color: #aaa !important;
}
.prompt-button[selected="true"], .prompt-button[selected="true"],
.context-command[selected="true"] { .context-command[selected="true"] {
background: transparent; background: transparent;
@ -1066,7 +1077,7 @@ pageaction {
} }
.prompt-button:not([disabled]):hover:active, .prompt-button:not([disabled]):hover:active,
.context-command:hover:active, .context-command:not([disabled]):hover:active,
pageaction:not([disabled]):hover:active { pageaction:not([disabled]):hover:active {
background: url("chrome://browser/skin/images/popup-selected-item-hdpi.png") repeat-x !important; background: url("chrome://browser/skin/images/popup-selected-item-hdpi.png") repeat-x !important;
background-origin: border-box !important; background-origin: border-box !important;
@ -1397,7 +1408,7 @@ pageaction:not([image]) > hbox >.pageaction-image {
background-color: #8db8d8; background-color: #8db8d8;
} }
echrome-select-option[disabled="true"] { .chrome-select-option[disabled="true"] {
pointer-events: none; pointer-events: none;
color: #aaa !important; color: #aaa !important;
} }