Bug 882306 - Use CSS to make buttons look enabled when customizing; don't change buttons' disabled states, r=dao

This commit is contained in:
Gijs Kruitbosch 2013-06-13 13:40:41 +02:00
parent 7c0ca8057b
commit 62e0db599e
6 changed files with 31 additions and 48 deletions

View File

@ -118,15 +118,8 @@ var FeedHandler = {
var haveFeeds = feeds && feeds.length > 0;
var feedButton = document.getElementById("feed-button");
// Don't disable the button for customization mode. We check the URL
// here rather than the window's [customizing] attribute because they
// do not change at the same time, and the browser's feed info pertains
// to the selected page's browser, so using the location ensures
// this check is always correct:
let contentLoc = window.content && window.content.location.href;
let areCustomizing = contentLoc == "about:customizing";
if (feedButton)
feedButton.disabled = !areCustomizing && !haveFeeds;
feedButton.disabled = !haveFeeds;
if (!haveFeeds) {
this._feedMenuitem.setAttribute("disabled", "true");

View File

@ -450,10 +450,9 @@ const CustomizableWidgets = [{
},
onCreated: function(node) {
let win = node.ownerDocument.defaultView;
let browser = win.gBrowser.selectedBrowser;
let feeds = browser && browser.feeds && browser.feeds.length;
let contentURL = browser && browser.currentURI && browser.currentURI.spec;
if (contentURL != "about:customizing" && !feeds) {
let selectedBrowser = win.gBrowser.selectedBrowser;
let feeds = selectedBrowser && selectedBrowser.feeds;
if (!feeds || !feeds.length) {
node.setAttribute("disabled", "true");
}
}

View File

@ -413,11 +413,6 @@ CustomizeMode.prototype = {
aNode.checked = false;
}
if (aNode.disabled) {
wrapper.setAttribute("itemdisabled", "true");
aNode.disabled = false;
}
if (aNode.hasAttribute("id")) {
wrapper.setAttribute("id", "wrapper-" + aNode.getAttribute("id"));
}
@ -455,10 +450,6 @@ CustomizeMode.prototype = {
let toolbarItem = aWrapper.firstChild;
if (aWrapper.hasAttribute("itemdisabled")) {
toolbarItem.disabled = true;
}
if (aWrapper.hasAttribute("itemchecked")) {
toolbarItem.checked = true;
}

View File

@ -645,7 +645,7 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
#print-button {
list-style-image: url("moz-icon://stock/gtk-print?size=toolbar");
}
#print-button[disabled="true"] {
:not(toolbarpaletteitem) > #print-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-print?size=toolbar&state=disabled");
}
@ -660,21 +660,21 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
#cut-button {
list-style-image: url("moz-icon://stock/gtk-cut?size=toolbar") !important;
}
#cut-button[disabled="true"] {
:not(toolbarpaletteitem) > #edit-controls > #cut-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-cut?size=toolbar&state=disabled") !important;
}
#copy-button {
list-style-image: url("moz-icon://stock/gtk-copy?size=toolbar") !important;
}
#copy-button[disabled="true"] {
:not(toolbarpaletteitem) > #edit-controls > #copy-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-copy?size=toolbar&state=disabled") !important;
}
#paste-button {
list-style-image: url("moz-icon://stock/gtk-paste?size=toolbar") !important;
}
#paste-button[disabled="true"] {
:not(toolbarpaletteitem) > #edit-controls > #paste-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-paste?size=toolbar&state=disabled") !important;
}
@ -702,7 +702,7 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
-moz-image-region: rect(0px 168px 24px 144px);
}
#feed-button[disabled] > .toolbarbutton-icon {
:not(toolbarpaletteitem) > #feed-button[disabled] > .toolbarbutton-icon {
opacity: .4;
}
@ -725,7 +725,7 @@ toolbar > .customization-target > toolbarpaletteitem > #history-panelmenu {
#home-button.bookmark-item {
list-style-image: url("moz-icon://stock/gtk-home?size=menu");
}
#home-button.bookmark-item[disabled="true"] {
:not(toolbarpaletteitem) > #home-button.bookmark-item[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-home?size=menu&state=disabled");
}
@ -1373,11 +1373,11 @@ toolbar[iconsize="small"] #bookmarks-menu-button[starred],
-moz-image-region: rect(16px 144px 32px 128px);
}
#bookmarks-menu-button[disabled] > .toolbarbutton-icon,
#bookmarks-menu-button[disabled] > .toolbarbutton-menu-dropmarker,
#bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-dropmarker,
#bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
#bookmarks-menu-button > .toolbarbutton-menubutton-button[disabled] > .toolbarbutton-icon {
:not(toolbarpaletteitem) > #bookmarks-menu-button[disabled] > .toolbarbutton-icon,
:not(toolbarpaletteitem) > #bookmarks-menu-button[disabled] > .toolbarbutton-menu-dropmarker,
:not(toolbarpaletteitem) > #bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-dropmarker,
:not(toolbarpaletteitem) > #bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
:not(toolbarpaletteitem) > #bookmarks-menu-button > .toolbarbutton-menubutton-button[disabled] > .toolbarbutton-icon {
opacity: .4;
}

View File

@ -450,20 +450,20 @@ toolbarbutton.bookmark-item > menupopup {
margin: 2px;
}
.toolbarbutton-1[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
.toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1[disabled="true"] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#restore-button[disabled="true"] > .toolbarbutton-icon {
opacity: .4;
}
@media (-moz-mac-lion-theme) {
.toolbarbutton-1[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
.toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1[disabled="true"] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#restore-button[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-menu-dropmarker,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-menubutton-dropmarker,
#main-window:not([customizing]) .toolbarbutton-1[disabled="true"] > .toolbarbutton-menu-dropmarker,
#main-window:not([customizing]) .toolbarbutton-1[disabled="true"] > .toolbarbutton-menubutton-dropmarker,
.toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-icon,
.toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-badge-container > .toolbarbutton-icon,
#restore-button:not(:hover):-moz-window-inactive > .toolbarbutton-icon,
@ -473,9 +473,9 @@ toolbarbutton.bookmark-item > menupopup {
opacity: .5;
}
.toolbarbutton-1:-moz-window-inactive[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1:-moz-window-inactive[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
.toolbarbutton-1:-moz-window-inactive > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1:-moz-window-inactive[disabled="true"] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1:-moz-window-inactive[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1:-moz-window-inactive > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#restore-button:-moz-window-inactive[disabled="true"] > .toolbarbutton-icon {
opacity: .25;
}

View File

@ -343,11 +343,11 @@ menuitem.bookmark-item {
list-style-image: url("chrome://browser/skin/Toolbar-inverted.png");
}
.toolbarbutton-1[disabled=true] > .toolbarbutton-icon,
.toolbarbutton-1[disabled=true] > .toolbarbutton-menu-dropmarker,
.toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-dropmarker,
.toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
.toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled] > .toolbarbutton-icon {
#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-menu-dropmarker,
#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-dropmarker,
#main-window:not([customizing]) .toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
#main-window:not([customizing]) .toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled] > .toolbarbutton-icon,
opacity: .4;
}