171101 - new toolbar customization features

git-svn-id: svn://10.0.0.236/trunk@130568 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hewitt%netscape.com
2002-09-27 04:06:56 +00:00
parent eaca9a2e25
commit df2ace3a21
26 changed files with 1380 additions and 801 deletions

View File

@@ -2592,7 +2592,24 @@ function BrowserToolbarChanged()
function BrowserCustomizeToolbar()
{
window.openDialog("chrome://browser/content/customizeToolbar.xul", "Customize Toolbar", "modal,chrome,resizable=yes");
var cmd = document.getElementById("cmd_CustomizeToolbars");
cmd.setAttribute("disabled", "true");
var iframe = document.createElement("iframe");
iframe.flex = 1;
iframe.setAttribute("src", "chrome://global/content/customizeToolbar.xul");
gBrowser.parentNode.insertBefore(iframe, gBrowser);
gBrowser.collapsed = true;
}
function onToolbarCustomizeComplete()
{
var cmd = document.getElementById("cmd_CustomizeToolbars");
cmd.removeAttribute("disabled");
var iframe = gBrowser.previousSibling;
iframe.parentNode.removeChild(iframe);
gBrowser.collapsed = false;
}
var FullScreen =
@@ -3000,6 +3017,48 @@ nsBrowserStatusHandler.prototype =
}
}
function onViewToolbarsPopupShowing(aEvent)
{
var popup = aEvent.target;
// Empty the menu
for (var i = popup.childNodes.length-1; i >= 0; --i) {
var deadItem = popup.childNodes[i];
if (deadItem.hasAttribute("toolbarindex"))
popup.removeChild(deadItem);
}
var firstMenuItem = popup.firstChild;
var toolbox = document.getElementById("navigator-toolbox");
for (var i = 0; i < toolbox.childNodes.length; ++i) {
var toolbar = toolbox.childNodes[i];
var toolbarName = toolbar.getAttribute("toolbarname");
if (toolbarName) {
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("toolbarindex", i);
menuItem.setAttribute("type", "checkbox");
menuItem.setAttribute("label", toolbarName);
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
menuItem.setAttribute("checked", toolbar.getAttribute("collapsed") != "true");
popup.insertBefore(menuItem, firstMenuItem);
menuItem.addEventListener("command", onViewToolbarCommand, false);
}
toolbar = toolbar.nextSibling;
}
}
function onViewToolbarCommand(aEvent)
{
var toolbox = document.getElementById("navigator-toolbox");
var index = aEvent.originalTarget.getAttribute("toolbarindex");
var toolbar = toolbox.childNodes[index];
toolbar.collapsed = aEvent.originalTarget.getAttribute("checked") != "true";
document.persist(toolbar.id, "collapsed");
}
function displayPageInfo()
{
window.openDialog("chrome://navigator/content/pageInfo.xul", "_blank",

View File

@@ -118,7 +118,8 @@ Contributor(s):
<command id="cmd_quit"/>
<command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
<command id="cmd_closeWindow" oncommand="BrowserCloseWindow()"/>
<command id="cmd_CustomizeToolbars" oncommand="BrowserCustomizeToolbar()"/>
<command id="cmd_copyLink"
oncommand="goDoCommand('cmd_copyLink')"
disabled="false"/>
@@ -228,7 +229,7 @@ Contributor(s):
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);"/>
<popup id="toolbar-context-menu">
<menuitem oncommand="BrowserCustomizeToolbar()"
<menuitem command="cmd_CustomizeToolbars"
label="&viewCustomizeToolbar.label;"
accesskey="&viewCustomizeToolbar.accesskey;"/>
</popup>
@@ -396,7 +397,7 @@ Contributor(s):
oncommand="gContextMenu.showMetadata();"/>
</popup>
<toolbox id="navigator-toolbox" class="toolbox-top">
<toolbox id="navigator-toolbox" class="toolbox-top" mode="icons">
<!-- Menu -->
<menubar id="main-menubar" class="chromeclass-menubar">
<menu label="&fileMenu.label;"
@@ -467,15 +468,14 @@ Contributor(s):
<menu label="&viewMenu.label;" accesskey="&viewMenu.accesskey;">
<menupopup>
<menu label="&viewToolbarsMenu.label;" accesskey="&viewToolbarsMenu.accesskey;">
<menu label="&viewToolbarsMenu.label;" accesskey="&viewToolbarsMenu.accesskey;"
onpopupshowing="onViewToolbarsPopupShowing(event);">
<menupopup onpopupshowing="updateToolbarStates(this);">
<menuitem id="toggle_navbar" label="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;" type="checkbox" oncommand="goToggleToolbar( 'nav-bar','toggle_navbar');" checked="true" />
<menuitem id="toggle_ptoolbar" label="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;" type="checkbox" oncommand="goToggleToolbar('PersonalToolbar','toggle_ptoolbar');" checked="true" />
<menuitem id="toggle_taskbar" label="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" type="checkbox" oncommand="goToggleToolbar('status-bar','toggle_taskbar');" checked="true" />
</menupopup>
</menu>
<menuitem label="&viewCustomizeToolbar.label;" accesskey="&viewCustomizeToolbar.accesskey;"
oncommand="BrowserCustomizeToolbar()"/>
command="cmd_CustomizeToolbars"/>
<menuitem accesskey="&fullScreenCmd.accesskey;"
label="&fullScreenCmd.label;" key="key_fullScreen"
command="View:FullScreen"/>
@@ -683,104 +683,115 @@ Contributor(s):
</menu>
</menubar>
<toolbar class="toolbar-primary chromeclass-toolbar" id="nav-bar"
fullscreentoolbar="true" mode="icons"
defaultset="back-button,forward-button,reload-button,stop-button,urlbar-container,throbber-box"
<toolbarpalette>
<toolbarbutton id="back-button" type="menu-button" class="toolbarbutton-1"
label="&backCmd.label;"
command="Browser:Back"
context="backMenu"
tooltiptext="&backButton.tooltip;">
<menupopup context="" onpopupshowing="BrowserBackMenu(event);"
oncommand="gotoHistoryIndex(event); event.preventBubble();"/>
</toolbarbutton>
<toolbarbutton id="forward-button" type="menu-button" class="toolbarbutton-1"
label="&forwardCmd.label;"
command="Browser:Forward"
context="forwardMenu"
tooltiptext="&forwardButton.tooltip;">
<menupopup context="" oncommand="gotoHistoryIndex(event); event.preventBubble()"
onpopupshowing="BrowserForwardMenu(event);"/>
</toolbarbutton>
<toolbarbutton id="reload-button" class="toolbarbutton-1"
label="&reloadCmd.label;"
oncommand="if (event.shiftKey) BrowserReloadSkipCache(); else BrowserReload();"
tooltiptext="&reloadButton.tooltip;"/>
<toolbarbutton id="stop-button" class="toolbarbutton-1"
label="&stopCmd.label;"
command="Browser:Stop"
tooltiptext="&stopButton.tooltip;"/>
<toolbarbutton id="home-button" class="toolbarbutton-1"
label="&homeButton.label;"
ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);"
ondragdrop="nsDragAndDrop.drop(event, homeButtonObserver);"
ondragexit="nsDragAndDrop.dragExit(event, homeButtonObserver);"
oncommand="BrowserHome();"/>
<toolbaritem id="urlbar-container" align="center" flex="1"
class="chromeclass-location">
<textbox id="urlbar" flex="1"
type="autocomplete" searchSessions="history"
timeout="50" maxrows="6" alwaysopenpopup="true"
disablehistory="false"
defaultSearchEngine="true" tabScrolling="true"
showCommentColumn="true"
inputtooltiptext="&locationBar.tooltip;"
oninput="window.XULBrowserWindow.userTyped.value=true;"
ontextcommand="return handleURLBarCommand(eventParam, domEvent);"
ontextrevert="return handleURLBarRevert();"
onfocus="URLBarFocusHandler(event);"
onmousedown="URLBarMouseDownHandler(event);"
onclick="URLBarClickHandler(event);">
<deck id="page-proxy-deck">
<image id="page-proxy-button"
ondraggesture="PageProxyDragGesture(event);"
tooltiptext="&proxyIcon.tooltip;"/>
<image id="page-proxy-favicon" validate="never"
ondraggesture="PageProxyDragGesture(event);"
onload="this.parentNode.selectedIndex = 1;
event.stopPropagation();
event.preventBubble();
HandleBookmarkIcon(this.src, true);"
onerror="gBrowser.addToMissedIconCache(this.src); HandleBookmarkIcon(this.src, false);"
tooltiptext="&proxyIcon.tooltip;"/>
</deck>
<menupopup class="autocomplete-history-popup"
popupalign="topleft" popupanchor="bottomleft"
onpopupshowing="createUBHistoryMenu(event.target);"
oncommand="executeUrlBarHistoryCommand(event.target);"/>
</textbox>
</toolbaritem>
<toolbaritem id="search-container" align="center" class="chromeclass-location">
<textbox id="search-bar" flex="1"/>
</toolbaritem>
<toolbaritem id="go-container" align="center" class="chromeclass-location">
<button id="go-button" class="button-toolbar"
label="&goButton.label;"
oncommand="addToUrlbarHistory(); BrowserLoadURL();"
ondragover="nsDragAndDrop.dragOver(event, goButtonObserver);"
ondragdrop="nsDragAndDrop.drop(event, goButtonObserver);"
ondragexit="nsDragAndDrop.dragExit(event, goButtonObserver);"
tooltiptext="&goButton.tooltip;"/>
</toolbaritem>
<toolbarbutton id="print-button" class="toolbarbutton-1"
label="&printButton.label;"
oncommand="BrowserPrint();"
tooltiptext="&printButton.tooltip;"/>
<toolbaritem id="throbber-box" align="center" pack="center">
<button id="navigator-throbber" oncommand="goClickThrobber('browser.throbber.url')"
tooltiptext="&throbber.tooltip;"/>
</toolbaritem>
<toolbaritem id="personal-bookmarks" flex="1">
<bookmarks-toolbar id="bookmarks-toolbar" flex="1"/>
</toolbaritem>
</toolbarpalette>
<toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar"
toolbarname="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;"
fullscreentoolbar="true"
customizable="true" mode="icons"
defaultset="back-button,forward-button,urlbar-container,reload-button,stop-button,throbber-box"
context="toolbar-context-menu">
<toolbarpalette>
<toolbarbutton id="back-button" type="menu-button" class="toolbarbutton-1"
label="&backCmd.label;"
command="Browser:Back"
context="backMenu"
tooltiptext="&backButton.tooltip;">
<menupopup context="" onpopupshowing="BrowserBackMenu(event);"
oncommand="gotoHistoryIndex(event); event.preventBubble();"/>
</toolbarbutton>
<toolbarbutton id="forward-button" type="menu-button" class="toolbarbutton-1"
label="&forwardCmd.label;"
command="Browser:Forward"
context="forwardMenu"
tooltiptext="&forwardButton.tooltip;">
<menupopup context="" oncommand="gotoHistoryIndex(event); event.preventBubble()"
onpopupshowing="BrowserForwardMenu(event);"/>
</toolbarbutton>
<toolbarbutton id="reload-button" class="toolbarbutton-1"
label="&reloadCmd.label;"
oncommand="if (event.shiftKey) BrowserReloadSkipCache(); else BrowserReload();"
tooltiptext="&reloadButton.tooltip;"/>
<toolbarbutton id="stop-button" class="toolbarbutton-1"
label="&stopCmd.label;"
command="Browser:Stop"
tooltiptext="&stopButton.tooltip;"/>
<toolbarbutton id="home-button" class="toolbarbutton-1"
label="&homeButton.label;"
ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);"
ondragdrop="nsDragAndDrop.drop(event, homeButtonObserver);"
ondragexit="nsDragAndDrop.dragExit(event, homeButtonObserver);"
oncommand="BrowserHome();"/>
<toolbaritem id="urlbar-container" align="center" flex="1"
class="chromeclass-location">
<textbox id="urlbar" flex="1"
type="autocomplete" searchSessions="history"
timeout="50" maxrows="6" alwaysopenpopup="true"
disablehistory="false"
defaultSearchEngine="true" tabScrolling="true"
showCommentColumn="true"
inputtooltiptext="&locationBar.tooltip;"
oninput="window.XULBrowserWindow.userTyped.value=true;"
ontextcommand="return handleURLBarCommand(eventParam, domEvent);"
ontextrevert="return handleURLBarRevert();"
onfocus="URLBarFocusHandler(event);"
onmousedown="URLBarMouseDownHandler(event);"
onclick="URLBarClickHandler(event);">
<deck id="page-proxy-deck">
<image id="page-proxy-button"
ondraggesture="PageProxyDragGesture(event);"
tooltiptext="&proxyIcon.tooltip;"/>
<image id="page-proxy-favicon" validate="never"
ondraggesture="PageProxyDragGesture(event);"
onload="this.parentNode.selectedIndex = 1;
event.stopPropagation();
event.preventBubble();
HandleBookmarkIcon(this.src, true);"
onerror="gBrowser.addToMissedIconCache(this.src); HandleBookmarkIcon(this.src, false);"
tooltiptext="&proxyIcon.tooltip;"/>
</deck>
<menupopup class="autocomplete-history-popup"
popupalign="topleft" popupanchor="bottomleft"
onpopupshowing="createUBHistoryMenu(event.target);"
oncommand="executeUrlBarHistoryCommand(event.target);"/>
</textbox>
</toolbaritem>
<toolbaritem id="go-container" align="center" class="chromeclass-location">
<button id="go-button" class="button-toolbar"
label="&goButton.label;"
oncommand="addToUrlbarHistory(); BrowserLoadURL();"
ondragover="nsDragAndDrop.dragOver(event, goButtonObserver);"
ondragdrop="nsDragAndDrop.drop(event, goButtonObserver);"
ondragexit="nsDragAndDrop.dragExit(event, goButtonObserver);"
tooltiptext="&goButton.tooltip;"/>
</toolbaritem>
<toolbarbutton id="print-button" class="toolbarbutton-1"
label="&printButton.label;"
oncommand="BrowserPrint();"
tooltiptext="&printButton.tooltip;"/>
<toolbaritem id="throbber-box" align="center" pack="center">
<button id="navigator-throbber" oncommand="goClickThrobber('browser.throbber.url')"
tooltiptext="&throbber.tooltip;"/>
</toolbaritem>
</toolbarpalette>
<hbox id="window-controls" hidden="true" fullscreencontrol="true">
<hbox id="window-controls" hidden="true" fullscreencontrol="true">
<toolbarbutton id="minimize-button" class="toolbarbutton-1"
oncommand="window.minimize();"/>
@@ -791,12 +802,13 @@ Contributor(s):
oncommand="window.close();"/>
</hbox>
</toolbar>
<!-- Bookmarks in the personal toolbar folder -->
<toolbar id="PersonalToolbar" class="chromeclass-directories">
<bookmarks-toolbar id="bookmarks-toolbar" flex="1"/>
</toolbar>
<toolbarset id="customToolbars" context="toolbar-context-menu"/>
<toolbar id="PersonalToolbar" class="chromeclass-directories"
customizable="true" defaultset="personal-bookmarks"
toolbarname="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;"/>
</toolbox>
<!-- we only need to handle |ondragdrop| because everything else is

View File

@@ -1,566 +0,0 @@
/*
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is David Hyatt.
Portions created by David Hyatt are
Copyright (C) 2002 David Hyatt. All
Rights Reserved.
Contributor(s):
David Hyatt (hyatt@apple.com)
Blake Ross (blaker@netscape.com)
*/
var gToolbarChanged = false;
var gCurrentDragOverItem = null;
var gDraggingFromPalette = false;
function addItemToToolbar(newItem, newToolbar)
{
var enclosure = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarpaletteitem");
if (newItem.getAttribute("flex"))
enclosure.setAttribute("flex", newItem.getAttribute("flex"));
// Set a draggesture handler to allow drag-rearrange within the clone toolbar.
enclosure.setAttribute("ondraggesture", "gDraggingFromPalette = false; nsDragAndDrop.startDrag(event, dragObserver)");
enclosure.appendChild(newItem);
cleanUpItemForAdding(newItem);
newToolbar.appendChild(enclosure);
}
function buildDialog()
{
var toolbar = window.opener.document.getElementById("nav-bar");
var useSmallIcons = document.getElementById("smallicons");
var iconSize = toolbar.getAttribute("iconsize");
useSmallIcons.checked = (iconSize == "small");
var modeList = document.getElementById("modelist");
var modeValue = toolbar.getAttribute("mode");
if (!modeValue)
modeValue = "full";
modeList.value = modeValue;
if (modeValue == "text") {
useSmallIcons.disabled = true;
useSmallIcons.checked = false;
}
var cloneToolbarBox = document.getElementById("cloned-bar-container");
var paletteBox = document.getElementById("palette-box");
var currentSet = toolbar.getAttribute("currentset");
if (!currentSet)
currentSet = toolbar.getAttribute("defaultset");
currentSet = currentSet.split(",");
// Create a new toolbar that will model the one the user is trying to customize.
// We won't just cloneNode() because we want to wrap each element on the toolbar in a
// <toolbarpaletteitem/>, to prevent them from getting events (so they aren't styled on
// hover, etc.) and to allow us to style them in the new nsITheme world.
var newToolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbar");
newToolbar.id = "cloneToolbar";
if (useSmallIcons.checked)
newToolbar.setAttribute("iconsize", "small");
newToolbar.setAttribute("mode", modeValue);
// Walk through and manually clone the children of the to-be-customized toolbar.
// Make sure all buttons look enabled (and that textboxes are disabled).
var toolbarItem = toolbar.firstChild;
while (toolbarItem) {
var newItem = toolbarItem.cloneNode(true);
addItemToToolbar(newItem, newToolbar);
toolbarItem = toolbarItem.nextSibling;
}
cloneToolbarBox.appendChild(newToolbar);
// Now build up a palette of items.
buildPalette(paletteBox, toolbar, currentSet);
// Set a min height on the new toolbar so it doesn't shrink if all the buttons are removed.
newToolbar.setAttribute("minheight", newToolbar.boxObject.height);
}
function createEnclosure(paletteItem, currentRow)
{
// Create an enclosure for the item.
var enclosure = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarpaletteitem");
enclosure.setAttribute("flex", "1");
if (paletteItem.localName != "toolbarseparator")
enclosure.setAttribute("align", "center");
enclosure.setAttribute("pack", "center");
enclosure.setAttribute("width", "0");
enclosure.setAttribute("minheight", "0");
enclosure.setAttribute("minwidth", "0");
enclosure.setAttribute("ondraggesture", "gDraggingFromPalette = true; nsDragAndDrop.startDrag(event, dragObserver)");
enclosure.appendChild(paletteItem);
currentRow.appendChild(enclosure);
}
function buildPalette(paletteBox, toolbar, currentSet)
{
var currentRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
currentRow.setAttribute("class", "paletteRow");
var rowSlot = 1;
var rowMax = 4;
// Add the toolbar separator first.
var node = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarseparator");
node.setAttribute("id", "separator");
createEnclosure(node, currentRow);
node = toolbar.palette.firstChild;
var isOnToolbar = false;
while (node) {
for (var i = 0; i < currentSet.length; ++i) {
if (currentSet[i] == node.id) {
isOnToolbar = true;
break;
}
}
if (isOnToolbar) {
node = node.nextSibling;
isOnToolbar = false;
continue;
}
var paletteItem = node.cloneNode(true);
cleanUpItemForAdding(paletteItem);
if (rowSlot == rowMax) {
// Append the old row.
paletteBox.appendChild(currentRow);
// Make a new row.
currentRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
currentRow.setAttribute("class", "paletteRow");
rowSlot = 0;
}
rowSlot++;
createEnclosure(paletteItem, currentRow);
node = node.nextSibling;
}
if (currentRow) {
// Remaining flex
var remainingFlex = rowMax - rowSlot;
if (remainingFlex > 0) {
var spring = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
spring.setAttribute("flex", remainingFlex);
currentRow.appendChild(spring);
}
paletteBox.appendChild(currentRow);
}
}
var dragObserver = {
onDragStart: function (aEvent, aXferData, aDragAction) {
aXferData.data = new TransferDataSet();
var data = new TransferData();
data.addDataForFlavour("text/toolbaritem-id", aEvent.target.firstChild.id);
aXferData.data.push(data);
}
}
var toolbarDNDObserver = {
onDragOver: function (aEvent, aFlavour, aDragSession)
{
if (gCurrentDragOverItem)
gCurrentDragOverItem.removeAttribute("dragactive");
var dropTargetWidth = aEvent.target.boxObject.width;
var dropTargetX = aEvent.target.boxObject.x;
if (aEvent.clientX > (dropTargetX + (dropTargetWidth / 2)))
gCurrentDragOverItem = aEvent.target.nextSibling;
else
gCurrentDragOverItem = aEvent.target;
gCurrentDragOverItem.setAttribute("dragactive", "true");
aDragSession.canDrop = true;
},
onDrop: function (aEvent, aXferData, aDragSession)
{
var newButtonId = aXferData.data;
if (gCurrentDragOverItem.firstChild.id == newButtonId)
return;
var toolbar = document.getElementById("cloneToolbar");
var item = null;
if (gDraggingFromPalette) {
var palette = document.getElementById("palette-box");
var paletteItems = palette.getElementsByTagName("toolbarpaletteitem");
var paletteItem;
for (var i = 0; i < paletteItems.length; ++i) {
paletteItem = paletteItems[i];
if (paletteItem.firstChild.id == newButtonId) {
item = paletteItem;
break;
}
}
}
else {
// If drag-rearranging within the toolbar, we want to move it to
// the new location, so remove it here and we'll add it in the correct spot further down.
var toolbarItem = toolbar.firstChild;
while (toolbarItem) {
if (toolbarItem.firstChild.id == newButtonId) {
item = toolbarItem;
break;
}
toolbarItem = toolbarItem.nextSibling;
}
}
if (!item)
return;
// If we're a separator and dragging from the palette, do a clone so that the
// separator always stays in the palette.
var isSeparator = false;
if (gDraggingFromPalette && item.firstChild.localName == "toolbarseparator") {
item = item.cloneNode(true);
isSeparator = true;
}
// We have to remove the funky flex and width attributes that were set on
// the item to space it properly in the palette.
item.removeAttribute("flex");
item.removeAttribute("width");
item.removeAttribute("minwidth");
item.removeAttribute("minheight");
item.removeAttribute("align");
item.removeAttribute("pack");
// Set whatever flex the item in our enclosure has on the enclosure,
// so that we flex properly.
if (item.firstChild.getAttribute("flex"))
item.setAttribute("flex", item.firstChild.getAttribute("flex"));
item.setAttribute("ondraggesture", "gDraggingFromPalette = false; nsDragAndDrop.startDrag(event, dragObserver);");
var currentRow;
if (gDraggingFromPalette && !isSeparator)
currentRow = item.parentNode;
if (gCurrentDragOverItem.id == "cloneToolbar")
toolbar.appendChild(item);
else
toolbar.insertBefore(item, gCurrentDragOverItem);
gCurrentDragOverItem.removeAttribute("dragactive");
gCurrentDragOverItem = null;
gToolbarChanged = true;
while (currentRow) {
// Pull the first child of the next row up
// into this row.
var nextRow = currentRow.nextSibling;
if (!nextRow) {
var last = currentRow.lastChild;
var first = currentRow.firstChild;
if (first == last) {
// Kill the row.
currentRow.parentNode.removeChild(currentRow);
return;
}
if (last.localName == "spacer") {
var flex = last.getAttribute("flex");
flex++;
last.setAttribute("flex", flex);
// Reflow doesn't happen for some reason. Trigger it with a hide/show. ICK! -dwh
last.hidden = true;
last.hidden = false;
return;
}
else {
// Make a spacer and give it a flex of 1.
var spring = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
spring.setAttribute("flex", "1");
currentRow.appendChild(spring);
}
return;
}
currentRow.appendChild(nextRow.firstChild);
currentRow = currentRow.nextSibling;
}
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
this._flavourSet.appendFlavour("text/toolbaritem-id");
}
return this._flavourSet;
}
}
var paletteDNDObserver = {
onDragOver: function(aEvent, aFlavour, aDragSession)
{
aDragSession.canDrop = !gDraggingFromPalette && aEvent.target.localName != "hbox";
},
onDrop: function(aEvent, aXferData, aDragSession)
{
var itemID = aXferData.data;
var item = null;
var palette = document.getElementById("palette-box");
var toolbar = document.getElementById("cloneToolbar");
var toolbarItem = toolbar.firstChild;
while (toolbarItem) {
if (toolbarItem.firstChild.id == itemID) {
item = toolbarItem;
break;
}
toolbarItem = toolbarItem.nextSibling;
}
if (!item) {
return;
}
gToolbarChanged = true;
if (itemID == "separator") {
item.parentNode.removeChild(item);
return;
}
// We're going back in the palette now, so we have to readd the flex
// and width which we removed when moving the item to the toolbar.
// (These attributes help space the items properly in the palette.)
item.setAttribute("flex", "1");
item.setAttribute("width", "0");
item.setAttribute("align", "center");
item.setAttribute("pack", "center");
item.setAttribute("flex", "1");
item.setAttribute("width", "0");
item.setAttribute("minheight", "0");
item.setAttribute("minwidth", "0");
item.setAttribute("ondraggesture", "gDraggingFromPalette = true; nsDragAndDrop.startDrag(event, dragObserver)");
// Now insertBefore |item| in the right place.
var target = aEvent.target;
if (target == palette) {
target = palette.lastChild.lastChild;
if (target.localName != "spacer") {
// Create a new row, insert, create the spring and bail.
// Now build up a palette of items.
var newRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
newRow.setAttribute("class", "paletteRow");
newRow.appendChild(item);
var spring = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
spring.setAttribute("flex", "3");
newRow.appendChild(spring);
palette.appendChild(newRow);
return;
}
}
target.parentNode.insertBefore(item, target);
// Now walk all of the parent rows and take the last child of the row and shove it down to the next
// row. If we hit the spring as the last child, then reduce its flex by 1.
var currentRow = target.parentNode;
var nextRow = currentRow.nextSibling;
while (currentRow) {
var last = currentRow.lastChild;
if (last.localName == "spacer") {
var flex = last.getAttribute("flex");
if (flex > 1) {
flex--;
last.setAttribute("flex", flex);
}
else
currentRow.removeChild(last);
break;
}
if (nextRow) {
nextRow.insertBefore(currentRow.lastChild, nextRow.firstChild);
}
else {
// Create a new row. Add the item and a spring and break.
var newRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
newRow.setAttribute("class", "paletteRow");
newRow.appendChild(currentRow.lastChild);
var spring = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
spring.setAttribute("flex", "3");
newRow.appendChild(spring);
palette.appendChild(newRow);
break;
}
currentRow = nextRow;
nextRow = currentRow.nextSibling;
}
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
this._flavourSet.appendFlavour("text/toolbaritem-id");
}
return this._flavourSet;
}
}
// Make sure all buttons look enabled (and that textboxes are disabled).
// Hey, you try to come up with a better name.
function cleanUpItemForAdding(aPaletteItem)
{
aPaletteItem.removeAttribute("observes");
aPaletteItem.removeAttribute("disabled");
aPaletteItem.removeAttribute("type");
if (aPaletteItem.localName == "toolbaritem" &&
aPaletteItem.firstChild) {
aPaletteItem.firstChild.removeAttribute("observes");
// So the throbber doesn't throb in the dialog,
// cute as that may be...
aPaletteItem.firstChild.removeAttribute("busy");
}
}
// Save the changes to the toolbar and update all windows
function updateToolbar()
{
if (!gToolbarChanged)
return;
var toolbar = document.getElementById("cloneToolbar");
var node = toolbar.firstChild;
var newSet = "";
while (node) {
newSet += node.firstChild.id;
node = node.nextSibling;
if (node)
newSet += ",";
}
var newToolbar = window.opener.document.getElementById("nav-bar");
newToolbar.setAttribute("currentset", newSet);
var icons = toolbar.getAttribute("iconsize");
if (icons)
newToolbar.setAttribute("iconsize", icons);
else
newToolbar.removeAttribute("iconsize");
var mode = toolbar.getAttribute("mode");
newToolbar.setAttribute("mode", mode);
window.opener.document.persist("nav-bar", "currentset");
window.opener.document.persist("nav-bar", "iconsize");
window.opener.document.persist("nav-bar", "mode");
newToolbar.rebuild();
}
// Revert back to the default set.
function resetToDefault()
{
var toolbar = window.opener.document.getElementById("nav-bar");
var toolbarPalette = toolbar.palette;
var defaultSet = toolbar.getAttribute("defaultset");
var cloneToolbar = document.getElementById("cloneToolbar");
while (cloneToolbar.firstChild)
cloneToolbar.removeChild(cloneToolbar.firstChild);
var items = defaultSet.split(",");
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (!item) continue;
// Attempt to locate the item within the palette's list of children.
var paletteItem = toolbarPalette.firstChild;
while (paletteItem) {
var paletteID = paletteItem.getAttribute("id");
if (paletteID == item) {
var newItem = paletteItem.cloneNode(true);
newItem.hidden = true;
addItemToToolbar(newItem, cloneToolbar);
newItem.hidden = false;
break;
}
paletteItem = paletteItem.nextSibling;
}
}
// Now rebuild the palette
var paletteBox = document.getElementById("palette-box");
while (paletteBox.firstChild)
paletteBox.removeChild(paletteBox.firstChild);
buildPalette(paletteBox, toolbar, items);
gToolbarChanged = true;
}
function updateIconSize(useSmallIcons)
{
var toolbar = document.getElementById("cloneToolbar");
if (useSmallIcons)
toolbar.setAttribute("iconsize", "small");
else
toolbar.removeAttribute("iconsize");
toolbar.removeAttribute("minheight");
gToolbarChanged = true;
}
function updateToolbarMode(modeValue)
{
var toolbar = document.getElementById("cloneToolbar");
toolbar.setAttribute("mode", modeValue);
toolbar.removeAttribute("minheight");
gToolbarChanged = true;
var iconSizeCheckbox = document.getElementById("smallicons");
if (modeValue == "text") {
iconSizeCheckbox.disabled = true;
iconSizeCheckbox.checked = false;
updateIconSize(false);
}
else {
iconSizeCheckbox.disabled = false;
}
}

View File

@@ -3,9 +3,6 @@ browser.jar:
content/browser/browser.xul (content/browser.xul)
content/browser/browser.js (content/browser.js)
content/browser/utilityOverlay.js (content/utilityOverlay.js)
content/browser/customizeToolbar.xul (content/customizeToolbar.xul)
content/browser/customizeToolbar.js (content/customizeToolbar.js)
content/browser/customizeToolbar.css (content/customizeToolbar.css)
content/browser/about.gif (content/about.gif)
content/browser/aboutDialog.xul (content/aboutDialog.xul)
content/browser/viewPartialSource.xul (content/viewPartialSource.xul)
@@ -32,9 +29,9 @@ classic.jar:
skin/classic/browser/home-small.png (skin/home-small.png)
skin/classic/browser/print-small.png (skin/print-small.png)
skin/classic/browser/bookmarks.png (skin/bookmarks.png)
skin/classic/browser/bookmark-large.png (skin/bookmark-large.png)
skin/classic/browser/dropmarker.png (skin/dropmarker.png)
skin/classic/browser/close.png (skin/close.png)
skin/classic/browser/customizeToolbar.css (skin/customizeToolbar.css)
skin/classic/browser/browser.xml (skin/browser.xml)
skin/classic/browser/throbber-stopped.gif (skin/throbber-stopped.gif)
skin/classic/browser/throbber.gif (skin/throbber.gif)
@@ -48,7 +45,6 @@ en-US.jar:
locale/en-US/browser/contents.rdf (locale/contents.rdf)
locale/en-US/browser/browser.dtd (locale/browser.dtd)
locale/en-US/browser/browser.properties (locale/browser.properties)
locale/en-US/browser/customizeToolbar.dtd (locale/customizeToolbar.dtd)
locale/en-US/browser/aboutDialog.dtd (locale/aboutDialog.dtd)
locale/en-US/browser/viewSource.dtd (locale/viewSource.dtd)
locale/en-US/browser/openLocation.dtd (locale/openLocation.dtd)

View File

@@ -146,7 +146,7 @@
<!ENTITY viewMenu.accesskey "V">
<!ENTITY viewToolbarsMenu.label "Show/Hide">
<!ENTITY viewToolbarsMenu.accesskey "w">
<!ENTITY viewCustomizeToolbar.label "Customize Toolbar...">
<!ENTITY viewCustomizeToolbar.label "Customize Toolbars...">
<!ENTITY viewCustomizeToolbar.accesskey "t">
<!ENTITY showTaskbarCmd.label "Status Bar">
<!ENTITY showTaskbarCmd.accesskey "S">

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -78,11 +78,21 @@ toolbarbutton.bookmark-item:not([container="true"]):hover:active {
height: 16px;
}
/* Prevent [mode="icons"] from hiding the label */
.bookmark-item > .toolbarbutton-text {
display: -moz-box !important;
}
.bookmark-item > .toolbarbutton-menu-dropmarker {
display: none;
}
toolbarpaletteitem[type="bookmarks"] {
background: url("chrome://browser/skin/bookmark-large.png") no-repeat center;
}
/* ::::: bookmark menus ::::: */
menu.bookmark-item,
menuitem.bookmark-item {
min-width: 0;
@@ -466,6 +476,10 @@ toolbar[iconsize="small"] #print-button[disabled="true"] {
margin: 2px 3px;
}
#search-bar {
width: 12em;
}
/* ::::: page proxy icon ::::: */
#page-proxy-deck,
@@ -503,11 +517,8 @@ toolbar[iconsize="small"] #print-button[disabled="true"] {
}
/* ::::: autocomplete ::::: */
.autocomplete-outlinerbody:-moz-outliner-cell-text(value) {
padding-left: 15px;
}
.autocomplete-outlinerbody:-moz-outliner-cell-text(comment) {
.autocomplete-treebody:-moz-outliner-cell-text(treecolAutoCompleteComment) {
color: #555566;
}
@@ -615,10 +626,12 @@ toolbar[iconsize="small"] #print-button[disabled="true"] {
/* ::::: throbber ::::: */
#navigator-throbber {
-moz-appearance: none;
-moz-user-focus: ignore;
padding: 0px !important;
border: none !important;
margin: 2px 4px !important;
border: none !important;
padding: 0px !important;
min-width: 0;
background-color: transparent;
list-style-image: url("chrome://browser/skin/throbber-stopped.gif");
}

View File

@@ -26,25 +26,9 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
@namespace html url("http://www.w3.org/1999/xhtml"); /* namespace for HTML elements */
toolbarpaletteitem html|input {
display: none;
}
#cloned-bar-container {
margin: 5px;
}
#palette-box {
overflow:auto;
margin:0px 15px 10px 15px;
}
#cloneToolbar > toolbarpaletteitem {
border-left: 2px solid transparent;
}
#cloneToolbar > toolbarpaletteitem[dragactive] {
border-left: 2px solid black;
overflow: auto;
margin: 0px 15px 10px 15px;
}
#palette-box > hbox > toolbarpaletteitem {

View File

@@ -0,0 +1,910 @@
/*
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is David Hyatt.
Portions created by David Hyatt are
Copyright (C) 2002 David Hyatt. All
Rights Reserved.
Contributor(s):
David Hyatt (hyatt@apple.com)
Blake Ross (blaker@netscape.com)
Joe Hewitt (hewitt@netscape.com)
*/
const kRowMax = 4;
var gToolboxDocument = null;
var gToolbox = null;
var gCurrentDragOverItem = null;
var gToolboxChanged = false;
var gPreviousSets = {};
var gPreviousMode = null;
var gPreviousIconSize = null;
function onLoad()
{
gToolboxDocument = window.opener ? window.opener.document : window.parent.document;
gToolbox = gToolboxDocument.getElementsByTagName("toolbox")[0];
gToolbox.addEventListener("draggesture", onToolbarDragGesture, false);
gToolbox.addEventListener("dragover", onToolbarDragOver, false);
gToolbox.addEventListener("dragexit", onToolbarDragExit, false);
gToolbox.addEventListener("dragdrop", onToolbarDragDrop, false);
var mode = gToolbox.getAttribute("mode");
document.getElementById("modelist").value = mode;
var iconSize = gToolbox.getAttribute("iconsize");
document.getElementById("smallicons").checked = iconSize == "small";
// The dialog version has the option to position/size itself.
if (window.opener) {
var cover = window.arguments ? window.arguments[0] : null;
if (cover) {
document.documentElement.setAttribute("hidechrome", "true");
window.screenX = cover.boxObject.screenX;
window.screenY = cover.boxObject.screenY;
window.outerWidth = cover.boxObject.width;
window.outerHeight = cover.boxObject.height;
} else {
// Position the dialog just after the toolbox.
window.screenY = gToolbox.boxObject.screenY + gToolbox.boxObject.height;
}
}
cacheCurrentState();
// Build up the palette of other items.
buildPalette();
// Wrap all the items on the toolbar in toolbarpaletteitems.
wrapToolbarItems();
}
function onAccept(aEvent)
{
removeToolboxListeners();
unwrapToolbarItems();
persistCurrentSets();
notifyParentComplete();
}
function onCancel(aEvent)
{
removeToolboxListeners();
reverToPreviousState();
unwrapToolbarItems();
notifyParentComplete();
}
function removeToolboxListeners()
{
gToolbox.removeEventListener("draggesture", onToolbarDragGesture, false);
gToolbox.removeEventListener("dragover", onToolbarDragOver, false);
gToolbox.removeEventListener("dragexit", onToolbarDragExit, false);
gToolbox.removeEventListener("dragdrop", onToolbarDragDrop, false);
}
/**
* Invoke a callback on our parent window to notify it that
* the dialog is done and going away.
*/
function notifyParentComplete()
{
var parent = window.parent ? window.parent : window.opener;
if (parent && "onToolbarCustomizeComplete" in parent.top)
parent.top.onToolbarCustomizeComplete();
}
/**
* Cache the current state of all customizable toolbars so
* that we can undo changes.
*/
function cacheCurrentState()
{
gPreviousMode = gToolbox.getAttribute("mode");
gPreviousIconSize = gToolbox.getAttribute("iconsize");
var currentIndex = 0;
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
var currentSet = toolbar.getAttribute("currentset");
if (!currentSet)
currentSet = toolbar.getAttribute("defaultset");
gPreviousSets[toolbar.id] = currentSet;
}
}
}
/**
* Revert the currentset of each customizable toolbar to the value
* that we cached when first opening the dialog and remove toolbars
* that were added.
*/
function reverToPreviousState()
{
updateIconSize(gPreviousIconSize);
updateToolbarMode(gPreviousMode);
if (!gToolboxChanged)
return;
var currentIndex = 0;
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
if (toolbar.id in gPreviousSets) {
// Restore the currentset of previously existing toolbars.
toolbar.currentSet = gPreviousSets[toolbar.id];
} else {
// Remove toolbars that have been added.
gToolbox.removeChild(toolbar);
}
}
}
// Add back toolbars that have been removed.
for (var toolbarId in gPreviousSets) {
var toolbar = gToolboxDocument.getElementById(toolbarId);
if (!toolbar)
gToolbox.appendCustomToolbar("", gPreviousSets[toolbarId]);
}
}
/**
* Persist the current set of buttons in all customizable toolbars to
* localstore.
*/
function persistCurrentSets()
{
if (!gToolboxChanged)
return;
var customCount = 0;
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
// Look for customizable toolbars that need to be persisted.
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
// Calculate currentset and store it in the attribute.
var currentSet = toolbar.currentSet;
toolbar.setAttribute("currentset", currentSet);
var customIndex = toolbar.hasAttribute("customindex");
if (customIndex) {
if (!toolbar.firstChild) {
// Remove custom toolbars whose contents have been removed.
gToolbox.removeChild(toolbar);
--i;
} else {
// Persist custom toolbar info on the <toolbarset/>
gToolbox.toolbarset.setAttribute("toolbar"+(++customCount),
toolbar.toolbarName + ":" + currentSet);
gToolboxDocument.persist(gToolbox.toolbarset.id, "toolbar"+customCount);
}
}
if (!customIndex) {
// Persist the currentset attribute directly on hardcoded toolbars.
gToolboxDocument.persist(toolbar.id, "currentset");
}
}
}
// Remove toolbarX attributes for removed toolbars.
while (gToolbox.toolbarset.hasAttribute("toolbar"+(++customCount))) {
dump(customCount + " gone\n");
gToolbox.toolbarset.removeAttribute("toolbar"+customCount);
gToolboxDocument.persist(gToolbox.toolbarset.id, "toolbar"+customCount);
}
}
/**
* Wraps all items in all customizable toolbars in a toolbox.
*/
function wrapToolbarItems()
{
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
for (var k = 0; k < toolbar.childNodes.length; ++k) {
var item = toolbar.childNodes[k];
if (isToolbarItem(item)) {
var nextSibling = item.nextSibling;
var wrapper = wrapToolbarItem(item);
if (nextSibling)
toolbar.insertBefore(wrapper, nextSibling);
else
toolbar.appendChild(wrapper);
}
}
}
}
}
/**
* Unwraps all items in all customizable toolbars in a toolbox.
*/
function unwrapToolbarItems()
{
var paletteItems = gToolbox.getElementsByTagName("toolbarpaletteitem");
for (var i = 0; i < paletteItems.length; ++i) {
var paletteItem = paletteItems[i];
var toolbarItem = paletteItem.firstChild;
if (paletteItem.hasAttribute("itemdisabled"))
toolbarItem.disabled = true;
if (paletteItem.hasAttribute("itemcommand"))
toolbarItem.setAttribute("command", paletteItem.getAttribute("itemcommand"));
paletteItem.removeChild(toolbarItem);
paletteItem.parentNode.replaceChild(toolbarItem, paletteItem);
}
}
/**
* Creates a wrapper that can be used to contain a toolbaritem and prevent
* it from receiving UI events.
*/
function createWrapper(aId)
{
var wrapper = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarpaletteitem");
wrapper.id = "wrapper-"+aId;
return wrapper;
}
/**
* Wraps an item that has been cloned from a template and adds
* it to the end of a row in the palette.
*/
function wrapPaletteItem(aPaletteItem, aCurrentRow, aSpacer)
{
var wrapper = createWrapper(aPaletteItem.id);
if (aPaletteItem.localName == "toolbarseparator") {
wrapper.setAttribute("type", "separator");
} else if (aPaletteItem.localName == "spacer") {
wrapper.setAttribute("type", "spacer");
} else {
wrapper.setAttribute("align", "center");
}
wrapper.setAttribute("flex", 1);
wrapper.setAttribute("pack", "center");
wrapper.setAttribute("minheight", "0");
wrapper.setAttribute("minwidth", "0");
wrapper.appendChild(aPaletteItem);
// XXX We need to call this AFTER the palette item has been appended
// to the wrapper or else we crash dropping certain buttons on the
// palette due to removal of the command and disabled attributes - JRH
cleanUpItemForPalette(aPaletteItem, wrapper);
if (aSpacer)
aCurrentRow.insertBefore(wrapper, aSpacer);
else
aCurrentRow.appendChild(wrapper);
}
/**
* Wraps an item that is currently on a toolbar and replaces the item
* with the wrapper.
*/
function wrapToolbarItem(aToolbarItem)
{
var wrapper = createWrapper(aToolbarItem.id);
cleanupItemForToolbar(aToolbarItem, wrapper);
wrapper.flex = aToolbarItem.flex;
if (aToolbarItem.parentNode)
aToolbarItem.parentNode.removeChild(aToolbarItem);
wrapper.appendChild(aToolbarItem);
return wrapper;
}
/**
* Get the list of ids for the current set of items on each toolbar.
*/
function getCurrentItemIds()
{
var currentItems = {};
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
var currentSet = toolbar.getAttribute("currentset");
if (currentSet == "__empty")
continue;
else if (!currentSet)
currentSet = toolbar.getAttribute("defaultset");
var ids = currentSet.split(",");
for (var k = 0; k < ids.length; ++k)
currentItems[ids[k]] = 1;
}
}
return currentItems;
}
/**
* Builds the palette of draggable items that are not yet in a toolbar.
*/
function buildPalette()
{
// Empty the palette first.
var paletteBox = document.getElementById("palette-box");
while (paletteBox.firstChild)
paletteBox.removeChild(paletteBox.firstChild);
var currentRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
currentRow.setAttribute("class", "paletteRow");
// Add the toolbar separator item.
var templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarseparator");
templateNode.id = "separator";
wrapPaletteItem(templateNode, currentRow, null);
// Add the toolbar spacer item.
templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
templateNode.id = "spacer";
templateNode.flex = 1;
wrapPaletteItem(templateNode, currentRow, null);
var rowSlot = 2;
var currentItems = getCurrentItemIds();
templateNode = gToolbox.palette.firstChild;
while (templateNode) {
// Check if the item is already in a toolbar before adding it to the palette.
if (!(templateNode.id in currentItems)) {
var paletteItem = templateNode.cloneNode(true);
if (rowSlot == kRowMax) {
// Append the old row.
paletteBox.appendChild(currentRow);
// Make a new row.
currentRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
currentRow.setAttribute("class", "paletteRow");
rowSlot = 0;
}
++rowSlot;
wrapPaletteItem(paletteItem, currentRow, null);
}
templateNode = templateNode.nextSibling;
}
if (currentRow) {
fillRowWithFlex(currentRow);
paletteBox.appendChild(currentRow);
}
}
/**
* Creates a new palette item for a cloned template node and
* adds it to the last slot in the palette.
*/
function appendPaletteItem(aItem)
{
var paletteBox = document.getElementById("palette-box");
var lastRow = paletteBox.lastChild;
var lastSpacer = lastRow.lastChild;
if (lastSpacer.localName != "spacer") {
// The current row is full, so we have to create a new row.
lastRow = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"hbox");
lastRow.setAttribute("class", "paletteRow");
paletteBox.appendChild(lastRow);
wrapPaletteItem(aItem, lastRow, null);
fillRowWithFlex(lastRow);
} else {
// Decrement the flex of the last spacer or remove it entirely.
var flex = lastSpacer.getAttribute("flex");
if (flex == 1) {
lastRow.removeChild(lastSpacer);
lastSpacer = null;
} else
lastSpacer.setAttribute("flex", --flex);
// Insert the wrapper where the last spacer was.
wrapPaletteItem(aItem, lastRow, lastSpacer);
}
}
function fillRowWithFlex(aRow)
{
var remainingFlex = kRowMax - aRow.childNodes.length;
if (remainingFlex > 0) {
var spacer = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
spacer.setAttribute("flex", remainingFlex);
aRow.appendChild(spacer);
}
}
/**
* Makes sure that an item that has been cloned from a template
* is stripped of all properties that may adversely affect it's
* appearance in the palette.
*/
function cleanUpItemForPalette(aItem, aWrapper)
{
// Mark special types of palette items so we can style them.
if (aItem.localName == "toolbarseparator") {
aWrapper.setAttribute("type", "separator");
} else if (aItem.localName == "spacer") {
aWrapper.setAttribute("type", "spacer");
} else if (aItem.firstChild && aItem.firstChild.localName == "bookmarks-toolbar") {
aWrapper.setAttribute("type", "bookmarks");
}
// Remove attributes that screw up our appearance.
aItem.removeAttribute("command");
aItem.removeAttribute("observes");
aItem.removeAttribute("disabled");
aItem.removeAttribute("type");
if (aItem.localName == "toolbaritem" && aItem.firstChild) {
aItem.firstChild.removeAttribute("observes");
// So the throbber doesn't throb in the dialog,
// cute as that may be...
aItem.firstChild.removeAttribute("busy");
}
}
/**
* Makes sure that an item that has been cloned from a template
* is stripped of all properties that may adversely affect it's
* appearance in the toolbar. Store critical properties on the
* wrapper so they can be put back on the item when we're done.
*/
function cleanupItemForToolbar(aItem, aWrapper)
{
if (aItem.localName == "toolbarseparator") {
aWrapper.setAttribute("type", "separator");
} else if (aItem.localName == "spacer") {
aWrapper.setAttribute("type", "spacer");
}
if (aItem.hasAttribute("command")) {
aWrapper.setAttribute("itemcommand", aItem.getAttribute("command"));
aItem.removeAttribute("command");
}
if (aItem.disabled) {
aWrapper.setAttribute("itemdisabled", "true");
aItem.disabled = false;
}
}
function setDragActive(aItem, aValue)
{
var node = aItem;
var value = "left";
if (aItem.localName == "toolbar") {
node = aItem.lastChild;
value = "right";
}
if (!node)
return;
if (aValue) {
if (!node.hasAttribute("dragover"))
node.setAttribute("dragover", value);
} else {
node.removeAttribute("dragover");
}
}
function addNewToolbar()
{
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var stringBundle = document.getElementById("stringBundle");
var message = stringBundle.getString("enterToolbarName");
var title = stringBundle.getString("enterToolbarTitle");
var name = {};
while (1) {
if (!promptService.prompt(window, title, message, name, null, {})) {
return;
} else {
// Check for an existing toolbar with the same name and prompt again
// if a conflict is found
var nameToId = "__customToolbar_" + name.value.replace(" ", "");
var existingToolbar = gToolboxDocument.getElementById(nameToId);
if (existingToolbar) {
message = stringBundle.getFormattedString("enterToolbarDup", [name.value]);
} else {
break;
}
}
}
gToolbox.appendCustomToolbar(name.value, "");
gToolboxChanged = true;
}
/**
* Restore the default set of buttons to fixed toolbars,
* remove all custom toolbars, and rebuild the palette.
*/
function restoreDefaultSet()
{
// Restore the defaultset for fixed toolbars.
var toolbar = gToolbox.firstChild;
while (toolbar) {
if (isCustomizableToolbar(toolbar)) {
if (!toolbar.hasAttribute("customindex")) {
var defaultSet = toolbar.getAttribute("defaultset");
if (defaultSet)
toolbar.currentSet = defaultSet;
}
}
toolbar = toolbar.nextSibling;
}
// Remove all of the customized toolbars.
var child = gToolbox.lastChild;
while (child) {
if (child.hasAttribute("customindex")) {
var thisChild = child;
child = child.previousSibling;
gToolbox.removeChild(thisChild);
} else {
child = child.previousSibling;
}
}
// Now re-wrap the items on the toolbar.
wrapToolbarItems();
// Now rebuild the palette.
buildPalette();
gToolboxChanged = true;
}
function updateIconSize(aUseSmallIcons)
{
var val = aUseSmallIcons ? "small" : null;
setAttribute(gToolbox, "iconsize", val);
gToolboxDocument.persist(gToolbox.id, "iconsize");
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
setAttribute(toolbar, "iconsize", val);
gToolboxDocument.persist(toolbar.id, "iconsize");
}
}
}
function updateToolbarMode(aModeValue)
{
setAttribute(gToolbox, "mode", aModeValue);
gToolboxDocument.persist(gToolbox.id, "mode");
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = gToolbox.childNodes[i];
if (isCustomizableToolbar(toolbar)) {
setAttribute(toolbar, "mode", aModeValue);
gToolboxDocument.persist(toolbar.id, "mode");
}
}
var iconSizeCheckbox = document.getElementById("smallicons");
if (aModeValue == "text") {
iconSizeCheckbox.disabled = true;
iconSizeCheckbox.checked = false;
updateIconSize(false);
}
else {
iconSizeCheckbox.disabled = false;
}
}
function setAttribute(aElt, aAttr, aVal)
{
if (aVal)
aElt.setAttribute(aAttr, aVal);
else
aElt.removeAttribute(aAttr);
}
function isCustomizableToolbar(aElt)
{
return aElt.localName == "toolbar" &&
aElt.getAttribute("customizable") == "true";
}
function isToolbarItem(aElt) {
return aElt.localName == "toolbarbutton" ||
aElt.localName == "toolbaritem" ||
aElt.localName == "toolbarseparator" ||
aElt.localName == "spacer";
}
///////////////////////////////////////////////////////////////////////////
//// Drag and Drop observers
function onToolbarDragGesture(aEvent)
{
nsDragAndDrop.startDrag(aEvent, dragStartObserver);
}
function onToolbarDragOver(aEvent)
{
nsDragAndDrop.dragOver(aEvent, toolbarDNDObserver);
}
function onToolbarDragDrop(aEvent)
{
nsDragAndDrop.drop(aEvent, toolbarDNDObserver);
}
function onToolbarDragExit(aEvent)
{
if (gCurrentDragOverItem)
setDragActive(gCurrentDragOverItem, false);
}
var dragStartObserver =
{
onDragStart: function (aEvent, aXferData, aDragAction) {
var documentId = gToolboxDocument.documentElement.id;
var item = aEvent.target;
while (item && item.localName != "toolbarpaletteitem")
item = item.parentNode;
item.setAttribute("dragactive", "true");
aXferData.data = new TransferDataSet();
var data = new TransferData();
data.addDataForFlavour("text/toolbarwrapper-id/"+documentId, item.firstChild.id);
aXferData.data.push(data);
}
}
var toolbarDNDObserver =
{
onDragOver: function (aEvent, aFlavour, aDragSession)
{
var toolbar = aEvent.target;
while (toolbar && toolbar.localName != "toolbar")
toolbar = toolbar.parentNode;
var previousDragItem = gCurrentDragOverItem;
// Make sure we are dragging over a customizable toolbar.
if (!isCustomizableToolbar(toolbar)) {
gCurrentDragOverItem = null;
return;
}
if (aEvent.target.localName == "toolbar") {
gCurrentDragOverItem = aEvent.target;
} else {
var dropTargetWidth = aEvent.target.boxObject.width;
var dropTargetX = aEvent.target.boxObject.x;
gCurrentDragOverItem = null;
if (aEvent.clientX > (dropTargetX + (dropTargetWidth / 2))) {
gCurrentDragOverItem = aEvent.target.nextSibling;
if (!gCurrentDragOverItem)
gCurrentDragOverItem = toolbar;
} else
gCurrentDragOverItem = aEvent.target;
}
if (previousDragItem && gCurrentDragOverItem != previousDragItem) {
setDragActive(previousDragItem, false);
}
setDragActive(gCurrentDragOverItem, true);
aDragSession.canDrop = true;
},
onDrop: function (aEvent, aXferData, aDragSession)
{
if (!gCurrentDragOverItem)
return;
setDragActive(gCurrentDragOverItem, false);
var draggedItemId = aXferData.data;
if (gCurrentDragOverItem.id == draggedItemId)
return;
var toolbar = aEvent.target;
while (toolbar.localName != "toolbar")
toolbar = toolbar.parentNode;
var draggedPaletteWrapper = document.getElementById("wrapper-"+draggedItemId);
if (!draggedPaletteWrapper) {
// The wrapper has been dragged from the toolbar.
// Get the wrapper from the toolbar document and make sure that
// it isn't being dropped on itself.
var wrapper = gToolboxDocument.getElementById("wrapper-"+draggedItemId);
if (wrapper == gCurrentDragOverItem)
return;
// Remove the item from it's place in the toolbar.
wrapper.parentNode.removeChild(wrapper);
// Determine which toolbar we are dropping on.
var dropToolbar = null;
if (gCurrentDragOverItem.localName == "toolbar")
dropToolbar = gCurrentDragOverItem;
else
dropToolbar = gCurrentDragOverItem.parentNode;
// Insert the item into the toolbar.
if (gCurrentDragOverItem != dropToolbar)
dropToolbar.insertBefore(wrapper, gCurrentDragOverItem);
else
dropToolbar.appendChild(wrapper);
} else {
// The item has been dragged from the palette
// Create a new wrapper for the item. We don't know the id yet.
var wrapper = createWrapper("");
// Ask the toolbar to clone the item's template, place it inside the wrapper, and insert it in the toolbar.
var newItem = toolbar.insertItem(draggedItemId, gCurrentDragOverItem == toolbar ? null : gCurrentDragOverItem, wrapper);
// Prepare the item and wrapper to look good on the toolbar.
cleanupItemForToolbar(newItem, wrapper);
wrapper.id = "wrapper-"+newItem.id;
wrapper.flex = newItem.flex;
// Remove the wrapper from the palette.
var currentRow = draggedPaletteWrapper.parentNode;
if (draggedItemId != "separator" &&
draggedItemId != "spacer")
{
currentRow.removeChild(draggedPaletteWrapper);
while (currentRow) {
// Pull the first child of the next row up
// into this row.
var nextRow = currentRow.nextSibling;
if (!nextRow) {
var last = currentRow.lastChild;
var first = currentRow.firstChild;
if (first == last) {
// Kill the row.
currentRow.parentNode.removeChild(currentRow);
break;
}
if (last.localName == "spacer") {
var flex = last.getAttribute("flex");
last.setAttribute("flex", ++flex);
// Reflow doesn't happen for some reason. Trigger it with a hide/show. ICK! -dwh
last.hidden = true;
last.hidden = false;
break;
} else {
// Make a spacer and give it a flex of 1.
var spacer = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
spacer.setAttribute("flex", "1");
currentRow.appendChild(spacer);
}
break;
}
currentRow.appendChild(nextRow.firstChild);
currentRow = currentRow.nextSibling;
}
}
}
gToolboxChanged = true;
gCurrentDragOverItem = null;
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
var documentId = gToolboxDocument.documentElement.id;
this._flavourSet.appendFlavour("text/toolbarwrapper-id/"+documentId);
}
return this._flavourSet;
}
}
var paletteDNDObserver =
{
onDragOver: function (aEvent, aFlavour, aDragSession)
{
aDragSession.canDrop = true;
},
onDrop: function(aEvent, aXferData, aDragSession)
{
var itemId = aXferData.data;
var wrapper = gToolboxDocument.getElementById("wrapper-"+itemId);
if (wrapper) {
// The item was dragged out of the toolbar.
wrapper.parentNode.removeChild(wrapper);
var wrapperType = wrapper.getAttribute("type");
if (wrapperType != "separator" && wrapperType != "spacer") {
// Find the template node in the toolbox palette
var templateNode = gToolbox.palette.firstChild;
while (templateNode) {
if (templateNode.id == itemId)
break;
templateNode = templateNode.nextSibling;
}
if (!templateNode)
return;
// Clone the template and add it to our palette.
var paletteItem = templateNode.cloneNode(true);
appendPaletteItem(paletteItem);
}
}
gToolboxChanged = true;
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
var documentId = gToolboxDocument.documentElement.id;
this._flavourSet.appendFlavour("text/toolbarwrapper-id/"+documentId);
}
return this._flavourSet;
}
}

View File

@@ -25,57 +25,49 @@
-->
<!DOCTYPE dialog [
<!ENTITY % customizeToolbarDTD SYSTEM "chrome://browser/locale/customizeToolbar.dtd">
<!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
%customizeToolbarDTD;
]>
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/customizeToolbar.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/customizeToolbar.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/content/customizeToolbar.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/customizeToolbar.css" type="text/css"?>
<dialog id="main-window"
title="&window.title;"
onload="buildDialog()"
ondialogaccept="updateToolbar()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="700" height="465">
<dialog id="CustomizeToolbarWindow"
onload="onLoad();"
ondialogaccept="onAccept();"
ondialogcancel="onCancel();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://browser/content/customizeToolbar.js"/>
<script type="application/x-javascript" src="chrome://global/content/customizeToolbar.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<description>
&removeinstructions.description;
</description>
<toolbox id="cloned-bar-container"
ondragover="nsDragAndDrop.dragOver(event, toolbarDNDObserver)"
ondragdrop="nsDragAndDrop.drop(event, toolbarDNDObserver);"
ondragexit="gCurrentDragOverItem.removeAttribute('dragactive');"/>
<separator class="groove"/>
<stringbundle id="stringBundle" src="chrome://global/locale/customizeToolbar.properties"/>
<description>
&instructions.description;
</description>
<vbox flex="1" id="palette-box"
ondraggesture="gDraggingFromPalette = true; nsDragAndDrop.startDrag(event, dragStartObserver);"
ondragover="nsDragAndDrop.dragOver(event, paletteDNDObserver);"
ondragdrop="nsDragAndDrop.drop(event, paletteDNDObserver);"/>
<separator class="groove"/>
<box align="center">
<label value="&show.label;"/>
<menulist id="modelist" oncommand="updateToolbarMode(this.value)">
<menulist id="modelist" value="icons" oncommand="updateToolbarMode(this.value);">
<menupopup>
<menuitem value="full" label="&iconsAndText.label;"/>
<menuitem value="icons" label="&icons.label;"/>
<menuitem value="text" label="&text.label;"/>
</menupopup>
</menulist>
<checkbox id="smallicons" oncommand="updateIconSize(this.checked);" label="&useSmallIcons.label;"/>
<button label="&restoreDefaultSet.label;" oncommand="resetToDefault()"/>
<button label="&addNewToolbar.label;" oncommand="addNewToolbar();"/>
<button label="&restoreDefaultSet.label;" oncommand="restoreDefaultSet();"/>
</box>
<separator class="groove"/>

View File

@@ -11,96 +11,212 @@
</resources>
</binding>
<binding id="toolbar" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base">
<binding id="toolbox" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base">
<implementation>
<field name="palette">
null
</field>
<field name="afterPalette">
<field name="toolbarset">
null
</field>
<field name="toolbarChanged">
null
<field name="customToolbarCount">
0
</field>
<method name="rebuild">
<body>
<![CDATA[
while (this.firstChild != this.afterPalette) {
this.removeChild(this.firstChild);
<constructor>
<![CDATA[
// Look to see if there is a toolbarset.
this.toolbarset = this.firstChild;
while (this.toolbarset && this.toolbarset.localName != "toolbarset")
this.toolbarset = toolbarset.nextSibling;
if (this.toolbarset) {
// Create each toolbar described by the toolbarset.
var index = 0;
while (toolbarset.hasAttribute("toolbar"+(++index))) {
var toolbarInfo = toolbarset.getAttribute("toolbar"+index);
var infoSplit = toolbarInfo.split(":");
this.appendCustomToolbar(infoSplit[0], infoSplit[1]);
}
this.buildItemsFromPalette();
this.toolbarChanged();
}
]]>
</constructor>
<method name="appendCustomToolbar">
<parameter name="aName"/>
<parameter name="aCurrentSet"/>
<body>
<![CDATA[
var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbar");
toolbar.id = "__customToolbar_" + aName.replace(" ", "");
toolbar.setAttribute("customizable", "true");
toolbar.setAttribute("customindex", ++this.customToolbarCount);
toolbar.setAttribute("toolbarname", aName);
toolbar.setAttribute("currentset", aCurrentSet);
toolbar.setAttribute("mode", this.getAttribute("mode"));
toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
this.insertBefore(toolbar, this.toolbarset);
return toolbar;
]]>
</body>
</method>
<method name="buildItemsFromPalette">
<body>
<![CDATA[
var currentSet = this.getAttribute("currentset");
if (!currentSet)
currentSet = this.getAttribute("defaultset");
if (!currentSet)
return;
var node = this.palette ? this.palette : this.firstChild;
if (!this.palette) {
while (node) {
if (node.localName == "toolbarpalette")
break;
node = node.nextSibling;
}
if (!node)
return;
this.afterPalette = node.nextSibling;
this.palette = node;
this.removeChild(node);
</implementation>
</binding>
<binding id="toolbar" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base">
<implementation>
<field name="lastPermanentChild">
null
</field>
<property name="toolbarName"
onget="return this.getAttribute('toolbarname');"
onset="this.setAttribute('toolbarname', val); return val;"/>
<constructor>
<![CDATA[
this.lastPermanentChild = this.firstChild;
// Searching for the toolbox palette in the toolbar binding because
// toolbars are constructed first.
var toolbox = this.parentNode;
if (!toolbox.palette) {
// Look to see if there is a toolbarpalette.
var node = toolbox.firstChild;
while (node) {
if (node.localName == "toolbarpalette")
break;
node = node.nextSibling;
}
var items = currentSet.split(",");
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (!item) continue;
if (!node)
return;
if (item == "separator") {
var sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarseparator");
sep.id = "separator";
this.insertBefore(sep, this.afterPalette);
continue;
// Hold on to the palette but remove it from the document.
toolbox.palette = node;
toolbox.removeChild(node);
}
// Build up our contents from the palette.
var currentSet = this.getAttribute("currentset");
if (!currentSet)
currentSet = this.getAttribute("defaultset");
if (currentSet)
this.currentSet = currentSet;
]]>
</constructor>
<property name="currentSet">
<getter>
<![CDATA[
var node = this.firstChild;
var currentSet = "";
while (node) {
if (node.id &&
node.localName == "toolbaritem" ||
node.localName == "toolbarbutton" ||
node.localName == "toolbarseparator" ||
node.localName == "spacer")
{
if (currentSet)
currentSet += ",";
if (node.localName == "toolbarseparator")
currentSet += "separator";
else if (node.localName == "spacer")
currentSet += "spacer";
else
currentSet += node.id;
}
node = node.nextSibling;
}
return currentSet ? currentSet : "__empty";
]]>
</getter>
<setter>
<![CDATA[
// Remove all items before the last permanent child.
if (this.lastPermanentChild) {
while (this.lastPermanentChild.previousSibling)
this.removeChild(this.lastPermanentChild.previousSibling);
} else {
while (this.lastChild)
this.removeChild(this.lastChild);
}
if (val == "__empty")
return;
// Attempt to locate the item within the palette's list of children.
var paletteItem = node.firstChild;
if (val) {
var itemIds = val.split(",");
for (var i = 0; i < itemIds.length; i++)
this.insertItem(itemIds[i], null);
}
]]>
</setter>
</property>
<method name="insertItem">
<parameter name="aId"/>
<parameter name="aBeforeElt"/>
<parameter name="aWrapper"/>
<body>
<![CDATA[
var newItem = null;
// Create special cases of palette items.
if (aId == "separator") {
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarseparator");
var uniqueId = (new Date()).getTime();
newItem.id = "separator" + uniqueId;
} else if (aId == "spacer") {
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
var uniqueId = (new Date()).getTime();
newItem.flex = 1;
newItem.id = "spacer" + uniqueId;
} else {
// Attempt to locate an item with a matching id within palette.
var paletteItem = this.parentNode.palette.firstChild;
while (paletteItem) {
var paletteID = paletteItem.getAttribute("id");
if (paletteID == item) {
var newItem = paletteItem.cloneNode(true);
newItem.hidden = true;
this.insertBefore(newItem, this.afterPalette);
newItem.hidden = false;
var paletteId = paletteItem.id;
if (paletteId == aId) {
newItem = paletteItem.cloneNode(true);
break;
}
paletteItem = paletteItem.nextSibling;
}
}
var insertItem = newItem;
// Wrap the item in another node if so inclined.
if (aWrapper) {
aWrapper.appendChild(newItem);
insertItem = aWrapper;
}
// Insert the palette item into the toolbar.
if (aBeforeElt || this.lastPermanentChild)
this.insertBefore(insertItem, aBeforeElt ? aBeforeElt : this.lastPermanentChild);
else
this.appendChild(insertItem);
return newItem;
]]>
</body>
</method>
<constructor>
<![CDATA[
this.buildItemsFromPalette();
]]>
</constructor>
</method>
</implementation>
</binding>
<binding id="toolbox" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base"/>
<binding id="menubar" extends="xul:menubar">
<resources>
<stylesheet src="chrome://global/skin/toolbar.css"/>
@@ -121,6 +237,7 @@
<binding id="toolbarseparator" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base"/>
<binding id="toolbarpaletteitem" extends="xul:button"/>
<binding id="toolbarpaletteitem" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base" display="xul:button"/>
</bindings>

View File

@@ -51,7 +51,7 @@ data,
xbl|children,
commands, commandset, command,
broadcasterset, broadcaster, observes,
keyset, key, toolbarpalette,
keyset, key, toolbarpalette, toolbarset,
template, rule, conditions, action,
bindings, binding, content, member, triple,
treechildren, treeitem, treeseparator, treerow, treecell {

View File

@@ -6,6 +6,9 @@ toolkit.jar:
+ content/global/finddialog.xul (content/finddialog.xul)
+ content/global/finddialog.js (content/finddialog.js)
content/global/charset.js (content/charset.js)
content/global/customizeToolbar.xul (content/customizeToolbar.xul)
content/global/customizeToolbar.js (content/customizeToolbar.js)
content/global/customizeToolbar.css (content/customizeToolbar.css)
+ content/global/viewZoomOverlay.js (content/viewZoomOverlay.js)
+ content/global/widgets/tabbrowser.xml (content/widgets/tabbrowser.xml)
+ content/global/widgets/tabbox.xml (content/widgets/tabbox.xml)
@@ -18,3 +21,5 @@ en-US.jar:
+ locale/en-US/global/brand.dtd (locale/brand.dtd)
+ locale/en-US/global/brand.properties (locale/brand.properties)
+ locale/en-US/global/about.xhtml (locale/about.xhtml)
+ locale/en-US/global/customizeToolbar.dtd (locale/customizeToolbar.dtd)
+ locale/en-US/global/customizeToolbar.properties (locale/customizeToolbar.properties)

View File

@@ -1,9 +1,8 @@
<!ENTITY removeinstructions.description "Drag an item from the toolbar into the space below to remove it.">
<!ENTITY instructions.description "Drag an item into the toolbar above to add it.">
<!ENTITY instructions.description "Drag an item into the toolbars above to add it. Drag an item from the toolbars into the space below to remove it.">
<!ENTITY show.label "Show:">
<!ENTITY iconsAndText.label "Icons and Text">
<!ENTITY icons.label "Icons">
<!ENTITY text.label "Text">
<!ENTITY useSmallIcons.label "Use Small Icons">
<!ENTITY restoreDefaultSet.label "Restore Default Set">
<!ENTITY window.title "Customize Toolbar">
<!ENTITY addNewToolbar.label "Add New Toolbar">

View File

@@ -0,0 +1,3 @@
enterToolbarTitle=New Toolbar
enterToolbarName=Enter a name for this toolbar:
enterToolbarDup=There is already a toolbar with the name "%S". Please enter a different name.

View File

@@ -107,3 +107,9 @@ textbox {
.autocomplete-treebody:-moz-tree-cell-text(menuactive) {
color: HighlightText !important;
}
/* ::::: textboxes inside toolbarpaletteitems ::::: */
toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input {
visibility: hidden;
}

View File

@@ -19,7 +19,6 @@
Contributor(s):
Blake Ross (blaker@netscape.com)
Joe Hewitt (hewitt@netscape.com)
*/

View File

@@ -47,6 +47,10 @@ menulist > menupopup,
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist-compact");
}
toolbarpaletteitem[type="spacer"] {
-moz-binding: url("chrome://global/skin/globalBindings.xml#toolbarpaletteitem-spacer");
}
/* ::::: root elements ::::: */
window,

View File

@@ -20,4 +20,12 @@
</content>
</binding>
<binding id="toolbarpaletteitem-spacer" extends="chrome://global/content/widgets/toolbar.xml#toolbarpaletteitem">
<content>
<xul:spacer class="spacer-left"/>
<children/>
<xul:spacer class="spacer-right"/>
</content>
</binding>
</bindings>

View File

@@ -3,6 +3,7 @@ classic.jar:
+ skin/classic/global/browser.css
+ skin/classic/global/checkbox.css
+ skin/classic/global/colorpicker.css
+ skin/classic/global/customizeToolbar.css
+ skin/classic/global/console.css
+ skin/classic/global/contents.rdf
+ skin/classic/global/dialog.css
@@ -52,3 +53,6 @@ classic.jar:
+ skin/classic/global/tree/twisty-open.gif (tree/twisty-open.gif)
+ skin/classic/global/tree/twisty-clsd.gif (tree/twisty-clsd.gif)
+ skin/classic/global/progressmeter/progressmeter-busy.gif (progressmeter/progressmeter-busy.gif)
+ skin/classic/global/toolbar/spacer-lft.gif (toolbar/spacer-lft.gif)
+ skin/classic/global/toolbar/spacer-mid.gif (toolbar/spacer-mid.gif)
+ skin/classic/global/toolbar/spacer-rit.gif (toolbar/spacer-rit.gif)

View File

@@ -25,8 +25,6 @@
== Styles used by the XUL textbox element.
======================================================================= */
@import url("chrome://global/content/autocomplete.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");
@@ -81,3 +79,9 @@ textbox.plain {
border: none !important;
}
/* ::::: textboxes inside toolbarpaletteitems ::::: */
toolbarpaletteitem > toolbaritem > textbox > .textbox-input-box > html|*.textbox-input {
visibility: hidden;
}

View File

@@ -42,6 +42,7 @@ toolbox {
toolbar,
menubar {
min-width: 1px;
min-height: 20px;
border-left: 1px solid ThreeDHighlight;
border-top: 1px solid ThreeDHighlight;
border-right: 1px solid ThreeDShadow;
@@ -57,3 +58,32 @@ toolbarseparator {
width : 2px;
}
/* ::::: drag and drop feedback ::::: */
toolbarpaletteitem {
margin-left: -2px;
border-left: 2px solid transparent;
}
toolbarpaletteitem[dragover="left"] {
border-left: 2px solid black;
}
toolbarpaletteitem[dragover="right"] {
border-right: 2px solid black;
}
toolbarpaletteitem[type="spacer"] {
background: url("chrome://global/skin/toolbar/spacer-mid.gif") repeat-x center;
}
.spacer-left {
width: 8px;
background: url("chrome://global/skin/toolbar/spacer-lft.gif") no-repeat center;
}
.spacer-right {
width: 8px;
background: url("chrome://global/skin/toolbar/spacer-rit.gif") no-repeat center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B