diff -uNr mozilla/xpfe/components/sidebar/resources/sidebar.css.bak mozilla/xpfe/components/sidebar/resources/sidebar.css --- mozilla/xpfe/components/sidebar/resources/sidebar.css.bak 1970年01月01日 09:00:00.000000000 +0900 +++ mozilla/xpfe/components/sidebar/resources/sidebar.css 2002年07月25日 03:42:40.000000000 +0900 @@ -0,0 +1,45 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Sidebar Window. + * + * The Initial Developer of the Original Code is SHIMODA Hiroshi. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): SHIMODA Hiroshi + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#sidebar-panels-splitter, +#undock-ctx-item, +#sidebar-undock-button { + display: none; +} + +#dock-ctx-item, +#sidebar-dock-button { + display: -moz-box; +} diff -uNr mozilla/xpfe/components/sidebar/resources/sidebar.js.bak mozilla/xpfe/components/sidebar/resources/sidebar.js --- mozilla/xpfe/components/sidebar/resources/sidebar.js.bak 1970年01月01日 09:00:00.000000000 +0900 +++ mozilla/xpfe/components/sidebar/resources/sidebar.js 2002年07月25日 03:42:40.000000000 +0900 @@ -0,0 +1,151 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Sidebar Window. + * + * The Initial Developer of the Original Code is SHIMODA Hiroshi. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): SHIMODA Hiroshi + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gPanelBoxHeight = 0; + +function toggleSidebarWindowCollapsed(aNotToSave) +{ + var panelBox = document.getElementById("sidebar-panels"); + + if (panelBox.boxObject.height) + // Save the height of the panel box + gPanelBoxHeight = panelBox.boxObject.height; + + if (!aNotToSave) { + nsPreferences.setBoolPref("sidebar.collapsed", !panelBox.collapsed); + nsPreferences.setIntPref("sidebar.panelBoxHeight", gPanelBoxHeight); + nsPreferences.setIntPref("sidebar.width", window.outerWidth); + nsPreferences.setIntPref("sidebar.height", window.outerHeight); + } + + window.resizeBy( + 0, + (panelBox.collapsed ? gPanelBoxHeight : -gPanelBoxHeight ) + ); + panelBox.collapsed = !panelBox.collapsed; +} + +function onLoad() +{ + toggleSidebarWindowCheck(true); + + // Bind reference to navigator windows to "window._content", etc. + OverrideFunctions(); + + nsPreferences.setBoolPref("sidebar.show", true); + + try { + if (nsPreferences.getBoolPref("sidebar.collapsed")) { + gPanelBoxHeight = nsPreferences.getIntPref("sidebar.panelBoxHeight", gPanelBoxHeight); + window.resizeTo( + nsPreferences.getIntPref("sidebar.width"), + nsPreferences.getIntPref("sidebar.height") + ); + toggleSidebarWindowCollapsed(); + } + } + catch(e) { + } +} + +function onUnload() +{ + toggleSidebarWindowCheck(false); + if (document.getElementById("sidebar-panels").collapsed) + toggleSidebarWindowCollapsed(true); + + nsPreferences.setBoolPref("sidebar.show", false); +} + + + +function OverrideFunctions() +{ + + window.__defineGetter__("_content", function() + { + var contentWindow = getSidebarHostWindow()._content; + if (contentWindow) { + contentWindow.framesSelf = contentWindow.frames; + contentWindow.framesSum = [].concat(contentWindow.framesSelf).concat(window.frames); + contentWindow.__defineGetter__("frames", function() { return this.framesSum; }); + } + return contentWindow; + }); + + // The method "isDocumentFrame(frame)" of "_content.frames" checks + // whether the handed frame is contained in _content.frames, so, + // it is failed in the Sidebar Window. + window.__defineGetter__("_content.frames", function() + { + var contentWindow = window._content; + if (contentWindow) + return [].concat(contentWindow.frames).concat(window.frames); + else + return window.frames; + }); + + + window.getBrowser = function() + { + if (getSidebarHostWindow()) + return getSidebarHostWindow().getBrowser(); + else + return window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no"); + }; + + window.loadURI = function(aURI, aReferrer) + { + if (getSidebarHostWindow()) + getSidebarHostWindow().loadURI(aURI, aReferrer); + else + window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", aURI, "", aReferrer); + }; + + + window.SidebarShowHide = window.close; + + + if (window.openNewTabWith.toString().match(/navigator:browser/)) + window.openNewTabWith = function(aURI) + { + urlSecurityCheck(aURI, document); + var browser = getBrowser(); + var tab = browser.addTab(url, getReferrer(document)); + if (!nsPreferences.getBoolPref("browser.tabs.loadInBackground")) + browser.selectedTab = tab; + }; + +} diff -uNr mozilla/xpfe/components/sidebar/resources/sidebar.xul.bak mozilla/xpfe/components/sidebar/resources/sidebar.xul --- mozilla/xpfe/components/sidebar/resources/sidebar.xul.bak 1970年01月01日 09:00:00.000000000 +0900 +++ mozilla/xpfe/components/sidebar/resources/sidebar.xul 2002年07月25日 03:42:40.000000000 +0900 @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + +%sidebarOverlayDTD; +]> + + + + type="application/x-javascript" src="chrome://global/content/nsClipboard.js"/> + type="application/x-javascript" src="chrome://global/content/strres.js"/> + + type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/> + type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/> + type="application/x-javascript" src="chrome://communicator/content/contentAreaUtils.js"/> + + type="application/x-javascript" src="chrome://navigator/content/navigator.js"/> + type="application/x-javascript" src="chrome://navigator/content/viewsource.js"/> + type="application/x-javascript" src="chrome://navigator/content/browser.js"/> + + type="application/x-javascript" src="chrome://communicator/content/sidebar/sidebar.js"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -uNr mozilla/xpfe/components/sidebar/resources/sidebarOverlay.js.bak mozilla/xpfe/components/sidebar/resources/sidebarOverlay.js --- mozilla/xpfe/components/sidebar/resources/sidebarOverlay.js.bak 2002年07月16日 18:36:38.000000000 +0900 +++ mozilla/xpfe/components/sidebar/resources/sidebarOverlay.js 2002年07月25日 03:42:40.000000000 +0900 @@ -17,6 +17,8 @@ * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998-1999 Netscape Communications Corporation. All * Rights Reserved. + * + * Contributor(s): SHIMODA Hiroshi */ // xul/id summary: @@ -785,6 +787,34 @@ sidebarObj.collapsed = false; } + var root = document.documentElement; + if (root.getAttribute("windowtype") != "communicator:sidebar") { + // Open undocked sidebar window + try { + if (nsPreferences.getBoolPref("sidebar.enabled")) { + if (!sidebar_is_hidden()) + SidebarShowHide(); + if (nsPreferences.getBoolPref('sidebar.show')) + showSidebarWindow(); + } + } + catch(e) { + } + + root.setAttribute('ondragdrop', + 'nsDragAndDrop.drop(event, SidebarWindowDNDObserver);'+ + (root.getAttribute('ondragdrop') || '') + ); + root.setAttribute('ondragexit', + 'nsDragAndDrop.dragExit(event, SidebarWindowDNDObserver);'+ + (root.getAttribute('ondragexit') || '') + ); + root.setAttribute('ondragover', + 'nsDragAndDrop.dragOver(event, SidebarWindowDNDObserver);'+ + (root.getAttribute('ondragover') || '') + ); + } + sidebar_open_default_panel(100, 0); } } @@ -1129,6 +1159,24 @@ // Show/Hide the entire sidebar. // Invoked by the "View / Sidebar" menu option. function SidebarShowHide() { + // Open/Close Sidebar Window + try { + if (nsPreferences.getBoolPref("sidebar.enabled")) { + if (getTopWinOf("communicator:sidebar")) + hideSidebarWindow(); + else + showSidebarWindow(); + + return; + } + } + catch(e) { + } + + SidebarShowHideInWindow(); +} + +function SidebarShowHideInWindow() { var sidebar_box = document.getElementById('sidebar-box'); var title_box = document.getElementById('sidebar-title-box'); var sidebar_panels_splitter = document.getElementById('sidebar-panels-splitter'); @@ -1476,28 +1524,74 @@ function SidebarInitContextMenu(aMenu, aPopupNode) { var panel = sidebarObj.panels.get_panel_from_header_node(aPopupNode); + var panelBox = document.getElementById("sidebar-panels"); + var switchItem = document.getElementById("switch-ctx-item"); var reloadItem = document.getElementById("reload-ctx-item"); var stopItem = document.getElementById("stop-ctx-item"); + var hideItem = document.getElementById("hide-ctx-item"); + var raisedItem = document.getElementById("raised-ctx-item"); + var collapseItem = document.getElementById("collapse-ctx-item"); + var expandItem = document.getElementById("expand-ctx-item"); + + var operateSep = document.getElementById("operate-ctx-sep"); + var hideSep = document.getElementById("hide-ctx-sep"); - // the current panel can be reloaded, but other panels are not showing - // any content, so we only allow you to switch to other panels - if (panel.is_selected()) + var windowtype = document.documentElement.getAttribute("windowtype"); + + if (!panel) { - switchItem.setAttribute("collapsed", "true"); - reloadItem.removeAttribute("disabled"); - } - else + switchItem.setAttribute("hidden", "true"); + reloadItem.setAttribute("hidden", "true"); + stopItem.setAttribute("hidden", "true"); + hideItem.setAttribute("hidden", "true"); + operateSep.setAttribute("hidden", "true"); + hideSep.setAttribute("hidden", "true"); + } else { - switchItem.removeAttribute("collapsed"); - reloadItem.setAttribute("disabled", "true"); + reloadItem.removeAttribute("hidden"); + stopItem.removeAttribute("hidden"); + hideItem.removeAttribute("hidden"); + operateSep.removeAttribute("hidden"); + hideSep.removeAttribute("hidden"); + + // the current panel can be reloaded, but other panels are not showing + // any content, so we only allow you to switch to other panels + if (panel.is_selected()) + { + switchItem.setAttribute("hidden", "true"); + reloadItem.removeAttribute("disabled"); + } + else + { + switchItem.removeAttribute("hidden"); + reloadItem.setAttribute("disabled", "true"); + } + + // only if a panel is currently loading enable the ``Stop'' item + if (panel.get_iframe().getAttribute("loadstate") == "loading") + stopItem.removeAttribute("disabled"); + else + stopItem.setAttribute("disabled", "true"); + + if (panel) + hideItem.removeAttribute("disabled"); + else + hideItem.setAttribute("disabled", "true"); + } - // only if a panel is currently loading enable the ``Stop'' item - if (panel.get_iframe().getAttribute("loadstate") == "loading") - stopItem.removeAttribute("disabled"); + // check the item "Always Raised" when the feature is enabled + if (nsPreferences.getBoolPref("sidebar.alwaysRaised", true)) + raisedItem.setAttribute("checked", "true"); else - stopItem.setAttribute("disabled", "true"); + raisedItem.removeAttribute("checked"); + + if (windowtype == "communicator:sidebar") + { + collapseItem.setAttribute("hidden", panelBox.collapsed); + expandItem.setAttribute("hidden", !panelBox.collapsed); + } } /////////////////////////////////////////////////////////////// @@ -1548,6 +1642,205 @@ } ////////////////////////////////////////////////////////////// +// Implementations for Undockable Sidebar (Sidebar Window) +////////////////////////////////////////////////////////////// + +// Undock Sidebar +function undockSidebar() +{ + if (isSidebarFloatable()) return; + + enableSidebarWindow(true); + showSidebarWindow(); + hideAllSidebar(); +} + +// Dock Sidebar +function dockSidebar() +{ + if (!isSidebarFloatable()) return; + + enableSidebarWindow(false); + var nav = getSidebarHostWindow(); + if (nav) nav.setTimeout("hideSidebarWindow(); showSidebar();", 10); +} + +// Open Sidebar Window +function showSidebarWindow() +{ + var sidebar = getTopWinOf("communicator:sidebar"); + if (sidebar) { + sidebar.focus(); + return sidebar; + } else { + return window.openDialog( + "chrome://communicator/content/sidebar/sidebar.xul", + "_blank", + "chrome,all,dialog"+ + (nsPreferences.getBoolPref("sidebar.alwaysRaised", true) ? ",lwaysRaised" : "" ) + ); + } +} + +// Close Sidebar Window +function hideSidebarWindow() +{ + var sidebar = getTopWinOf("communicator:sidebar"); + if (sidebar) sidebar.close(); +} + +// Show Sidebar in this window +function showSidebar() +{ + if (sidebar_is_hidden()) + SidebarShowHideInWindow(); +} + +// Hide Sidebars in all windows +function hideAllSidebar() +{ + var targets; + var target; + var menuitem; + var manager = Components.classes["@mozilla.org/appshell/window-mediator;1"].etService(Components.interfaces.nsIWindowMediator); + targets = manager.getEnumerator(null); + while (targets.hasMoreElements()) + { + target = targets.getNext().QueryInterface(Components.interfaces.sIDOMWindowInternal); + + if (target.sidebar_is_hidden && !target.sidebar_is_hidden()) + target.SidebarShowHideInWindow(); + } +} + +// Toggle to Rise Sidebar Window +function toggleSidebarAlwaysRaised() +{ + try { + nsPreferences.setBoolPref("sidebar.alwaysRaised", !nsPreferences.etBoolPref("sidebar.alwaysRaised", true)); + + var nav = getSidebarHostWindow(); + if (getTopWinOf("communicator:sidebar") && nav) + nav.setTimeout("hideSidebarWindow(); showSidebarWindow();", 10); + } + catch(e) { + } +} + +// Enable/Disable to Undock Sidebar +function enableSidebarWindow(aFloatingFlag) +{ + try { + if (nsPreferences.getBoolPref("sidebar.enabled") == aFloatingFlag) return; + } + catch(e) { + } + nsPreferences.setBoolPref("sidebar.enabled", aFloatingFlag); +} + + +// Check/Uncheck menuitems of all windows +function toggleSidebarWindowCheck(aToCheck) +{ + var targets; + var target; + var menuitem; + var manager = Components.classes['@mozilla.org/appshell/window-mediator;1'].etService(Components.interfaces.nsIWindowMediator); + targets = manager.getEnumerator(null); + while (targets.hasMoreElements()) + { + target = targets.getNext().QueryInterface(Components.interfaces.sIDOMWindowInternal); + menuitem = target.document.getElementById("sidebar-menu"); + if (menuitem) menuitem.setAttribute("checked", aToCheck); + } +} + +const SidebarWindowDNDObserver = +{ + canHandleMultipleItems : false, + + onDragStart : function(aEvent, aTransferData, aDragAction) + { + if (aEvent.target != document.getElementById("sidebar-title-box")) return alse; + + aTransferData.data = new TransferData(); + aTransferData.data.addDataForFlavour( + "xul/sidebar", + 'sidebar\n'+ + 'hostwindow='+document.documentElement.getAttribute("windowtype") + ); + }, + + // When Sidebar dropped into a host window, then disable Sidebar Window + // and enable Sidebar. + onDrop : function(aEvent, aTransferData, aSession) + { + if (aTransferData.flavour.contentType == "xul/sidebar" && // When dock idebar + document.documentElement.getAttribute("windowtype") != + "communicator:sidebar" && // When operate Sidebar Window + aTransferData.data.split('\n')[1] == 'hostwindow=communicator:sidebar') + dockSidebar(); + }, + + // When Sidebar dragged to out of host windows, then open Sidebar Window. + onDragExit : function(aEvent, aSession) + { + var data = nsTransferable.get( + this.getSupportedFlavours(), + nsDragAndDrop.getDragData, + true + ); + if (!data.first || + !data.first.first || + data.first.first.flavour.contentType != "xul/sidebar") return; + + // When operate Sidebar Window + if (document.documentElement.getAttribute("windowtype") != "communicator:idebar" && + !getTopWinOf("communicator:sidebar")) + undockSidebar(); + }, + + onDragOver : function(aEvent, aFlavour, aSession) + { + }, + + getSupportedFlavours : function () + { + var flavours = new FlavourSet(); + flavours.appendFlavour("xul/sidebar"); + return flavours; + } +}; + + +function getTopWinOf(aWindowType) +{ + var manager = Components.classes["@mozilla.org/appshell/window-mediator;1"].etService(Components.interfaces.nsIWindowMediator); + var topWindowOfType = manager.getMostRecentWindow(aWindowType); + + return topWindowOfType || null ; +} + +// Get top window which hosts sidebar +function getSidebarHostWindow() +{ + return getTopWinOf("navigator:browser") || + getTopWinOf("composer:html") || + getTopWinOf("mail:3pane"); +} + +function isSidebarFloatable() +{ + try { + return nsPreferences.getBoolPref("sidebar.enabled"); + } + catch(e) { + } + return false; +} + + +////////////////////////////////////////////////////////////// // Install the load/unload handlers ////////////////////////////////////////////////////////////// addEventListener("load", sidebar_overlay_init, false); diff -uNr mozilla/xpfe/components/sidebar/resources/sidebarOverlay.xul.bak mozilla/xpfe/components/sidebar/resources/sidebarOverlay.xul --- mozilla/xpfe/components/sidebar/resources/sidebarOverlay.xul.bak 2002年06月27日 18:55:42.000000000 +0900 +++ mozilla/xpfe/components/sidebar/resources/sidebarOverlay.xul 2002年07月25日 03:42:40.000000000 +0900 @@ -16,6 +16,8 @@ Copyright (C) 1999 Netscape Communications Corporation. All Rights Reserved. + Contributor(s): SHIMODA Hiroshi + --> @@ -30,6 +32,12 @@ + type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/> + type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/> + type="application/x-javascript" src="chrome://global/content/nsJSSupportsUtils.js"/> + type="application/x-javascript" src="chrome://global/content/nsJSComponentManager.js"/> + type="application/x-javascript" src="chrome://global/content/nsUserSettings.js"/> + - + + +