Landing of the bookmarks rewrite TBOOKMARKS_20030320_BRANCH (bug 196756) part one.

It includes:
- bug 160019: Robust bookmarks handling.
- bug 53422: Bookmarks Transaction Manager
- bug 36339: top level bookmark root
- bug 114962: spring loaded bookmark menu in menubar
Thanks to Jan for the great help, bug fixing and testing.

Jan's fixes include:
- bug 51683: unique URI for bookmarks
- bug 99860: new file bookmarks dialog
- bug 121053: optional labels for separators

r=jag, sr=bryner
This commit is contained in:
chanial%noos.fr 2007-05-05 04:36:05 +00:00
Родитель c3fdb2fd8f
Коммит a757c14cc7
16 изменённых файлов: 4193 добавлений и 319 удалений

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

@ -96,6 +96,7 @@
var gFld_Name = null;
var gFld_URL = null;
var gFld_ShortcutURL = null;
var gFolderTree = null;
var gCB_AddGroup = null;
@ -113,6 +114,7 @@ function Startup()
{
gFld_Name = document.getElementById("name");
gFld_URL = document.getElementById("url");
gFld_ShortcutURL = document.getElementById("shortcutUrl");
gCB_AddGroup = document.getElementById("addgroup");
var bookmarkView = document.getElementById("bookmarks-view");
@ -130,9 +132,10 @@ function Startup()
case "selectFolder":
// If we're being opened as a folder selection window
document.getElementById("bookmarknamegrid").hidden = true;
document.getElementById("createinseparator").hidden = true;
document.getElementById("showaddgroup").hidden = true;
document.getElementById("destinationSeparator").hidden = true;
document.getElementById("nameseparator").hidden = true;
dialogElement.setAttribute("title", dialogElement.getAttribute("title-selectFolder"));
dialogElement.setAttribute("title", dialogElement.getAttribute("selectFolderTitle"));
shouldSetOKButton = false;
if (window.arguments[2])
folderItem = bookmarkView.rdf.GetResource(window.arguments[2]);
@ -143,10 +146,11 @@ function Startup()
break;
case "newBookmark":
document.getElementById("showaddgroup").hidden = true;
document.getElementById("destinationSeparator").hidden = true;
document.getElementById("folderbox").hidden = true;
setupFields();
if (window.arguments[2])
gCreateInFolder = window.arguments[2];
document.getElementById("folderbox").hidden = true;
break;
case "addGroup":
setupFields();
@ -217,8 +221,9 @@ function onOK()
}
// In Select Folder Mode, do nothing but tell our caller what
// folder was selected.
if (window.arguments.length > 4 && window.arguments[4] == "selectFolder")
window.arguments[5].selectedFolder = gCreateInFolder;
if (window.arguments.length > 4 && window.arguments[4] == "selectFolder") {
window.arguments[5].target = BookmarksUtils.getTargetFromFolder(bookmarkView.treeBuilder.getResourceAtIndex(currentIndex));
}
else {
// Otherwise add a bookmark to the selected folder.
@ -245,12 +250,12 @@ function onOK()
const groups = window.arguments[5];
for (var i = 0; i < groups.length; ++i) {
url = getNormalizedURL(groups[i].url);
kBMS.createBookmarkInContainer(groups[i].name, url,
kBMS.createBookmarkInContainer(groups[i].name, url, null, null,
groups[i].charset, group, -1);
}
} else if (gFld_URL.value) {
url = getNormalizedURL(gFld_URL.value);
var newBookmark = kBMS.createBookmarkInContainer(gFld_Name.value, url, gBookmarkCharset, rFolder, -1);
var newBookmark = kBMS.createBookmarkInContainer(gFld_Name.value, url, gFld_ShortcutURL.value, null, gBookmarkCharset, rFolder, -1);
if (window.arguments.length > 4 && window.arguments[4] == "newBookmark") {
window.arguments[5].newBookmark = newBookmark;
}
@ -282,28 +287,17 @@ function getNormalizedURL(url)
}
var gBookmarksShell = null;
function createNewFolder ()
function createNewFolder()
{
var bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.createNewFolder();
}
function useDefaultFolder ()
{
var bookmarkView = document.getElementById("bookmarks-view");
var folder = BookmarksUtils.getNewBookmarkFolder();
var ind = bookmarkView.treeBuilder.getIndexOfResource(folder);
if (ind != -1) {
bookmarkView.tree.focus();
bookmarkView.treeBoxObject.selection.select(ind);
} else {
bookmarkView.treeBoxObject.selection.clearSelection();
}
gCreateInFolder = folder.Value;
var resource = bookmarksView.treeBuilder.getResourceAtIndex(bookmarksView.currentIndex);
var target = BookmarksUtils.getTargetFromFolder(resource);
BookmarksCommand.createNewFolder(target);
}
var gOldNameValue = "";
var gOldURLValue = "";
var gOldShortcutURLValue = "";
function toggleGroup()
{
@ -318,18 +312,13 @@ function toggleGroup()
gFld_URL.value = temp;
gFld_URL.disabled = gCB_AddGroup.checked;
// swap between single bookmark and group shortcut url
temp = gOldShortcutURLValue;
gOldShortcutURLValue = gFld_ShortcutURL.value;
gFld_ShortcutURL.value = temp;
gFld_ShortcutURL.disabled = gCB_AddGroup.checked;
gFld_Name.select();
gFld_Name.focus();
onFieldInput();
}
function persistTreeSize()
{
if (!document.getElementById("folderbox").hidden) {
var bookmarkView = document.getElementById("bookmarks-view");
bookmarkView.setAttribute("height", bookmarkView.boxObject.height);
document.persist("bookmarks-view", "height");
bookmarkView.setAttribute("width", bookmarkView.boxObject.width);
document.persist("bookmarks-view", "width");
}
}

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

@ -22,7 +22,7 @@
Contributor(s):
Ben Goodger <ben@netscape.com> (Original Author)
Gervase Markham <gerv@gerv.net>
-->
<?xml-stylesheet href="chrome://communicator/skin/"?>
@ -39,18 +39,17 @@
<dialog id="newBookmarkDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
ondialogaccept="return onOK(event)"
title="&newBookmark.title;" title-selectFolder="&selectFolder.label;"
title="&newBookmark.title;" selectFolderTitle="&selectFolder.title;"
onload="Startup();"
onunload="persistTreeSize();"
persist="screenX screenY"
screenX="24" screenY="24">
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/addBookmark.js"/>
<stringbundle id="bookmarksbundle"
src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
src="chrome://communicator/locale/bookmarks/bookmarks.properties"/>
<broadcaster id="showaddgroup"/>
@ -59,60 +58,53 @@
<grid id="bookmarknamegrid">
<columns>
<column/>
<column flex="5"/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&name.label;" accesskey="&name.accesskey;" control="name"/>
<hbox pack="end">
<label value="&name.label;" accesskey="&name.accesskey;" control="name"/>
</hbox>
<textbox id="name" oninput="onFieldInput();"/>
<spacer/>
</row>
<row>
<separator class="thin"/>
<separator class="thin"/>
<spacer/>
</row>
<row align="center">
<label value="&url.label;" accesskey="&url.accesskey;" control="url"/>
<textbox id="url" oninput="onFieldInput();"/>
<spacer/>
</row>
<row observes="showaddgroup">
<separator class="thin"/>
<separator class="thin"/>
<spacer/>
</row>
<row observes="showaddgroup">
<spacer/>
<hbox pack="start">
<checkbox id="addgroup" label="&addGroup.label;"
accesskey="&addGroup.accesskey;" oncommand="toggleGroup();"/>
<hbox pack="end">
<label value="&url.label;" accesskey="&url.accesskey;" control="url"/>
</hbox>
<spacer/>
<textbox id="url" oninput="onFieldInput();"/>
</row>
<row align="center">
<hbox pack="end">
<label value="&shortcutURL.label;" accesskey="&shortcutURL.accesskey;" control="shortcutURL"/>
</hbox>
<textbox id="shortcutUrl"/>
</row>
</rows>
</grid>
<separator id="createinseparator"/>
<separator class="thin" observes="showaddgroup"/>
<hbox observes="showaddgroup">
<checkbox id="addgroup" label="&addGroup.label;"
accesskey="&addGroup.accesskey;"
oncommand="toggleGroup();"/>
</hbox>
<separator id="destinationSeparator"/>
<vbox id="folderbox" flex="1">
<separator/>
<hbox flex="1">
<label id="createinlabel" value="&createin.label;"/>
<hbox flex="1">
<bookmarks-tree id="bookmarks-view" flex="1" type="folders"/>
<vbox>
<button label="&button.newfolder.label;" accesskey="&button.newfolder.accesskey;"
oncommand="createNewFolder();"/>
<button label="&button.defaultfolder.label;"
accesskey="&button.defaultfolder.accesskey;"
oncommand="useDefaultFolder();"/>
</vbox>
</hbox>
<label id="destinationLabel" value="&destination.label;"/>
<bookmarks-tree id="bookmarks-view" flex="1" type="folders"
rows="10" seltype="single"/>
<separator id="folderbuttonseparator" class="thin"/>
<hbox pack="end">
<button label="&newFolder.label;"
accesskey="&newFolder.accesskey;"
oncommand="createNewFolder();"/>
</hbox>
</vbox>
<separator style="width: 36em;"/>
<separator style="width: 36em"/>
</dialog>

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

@ -0,0 +1,64 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
////////////////////////////////////////////////////////////////////////////////
// Get the two bookmarks utility libraries running, attach controllers, focus
// tree widget, etc.
function Startup()
{
var bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.treeBoxObject.selection.select(0);
}
function manageBookmarks() {
openDialog("chrome://communicator/content/bookmarks/bookmarksManager.xul", "", "chrome,dialog=no,resizable=yes");
}
function addBookmark() {
var contentArea = top.document.getElementById('content');
if (contentArea) {
const browsers = contentArea.browsers;
if (browsers.length > 1)
BookmarksUtils.addBookmarkForTabBrowser(contentArea);
else
BookmarksUtils.addBookmarkForBrowser(contentArea.webNavigation, true);
}
else
BookmarksUtils.addBookmark(null, null, undefined, true);
}

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

@ -20,6 +20,7 @@
Contributor(s):
Ben Goodger <ben@netscape.com> (Original Author, v2.0)
Pierre Chanial <chanial@noos.fr>
-->
@ -46,8 +47,8 @@
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<!-- Bookmarks Shell -->
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksPanel.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bm-panel.js"/>
<!-- Bookmarks Panel Drag & Drop -->
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
@ -77,16 +78,19 @@
<spacer flex="1"/>
<toolbarseparator/>
<toolbarbutton id="btnFindBookmarks" label="&command.findBookmarks.label;"
oncommand="document.getElementById('bookmarks-view').openFindDialog();"/>
oncommand="BookmarksCommand.findBookmark();"/>
</hbox>
<hbox id="search-bar" class="toolbar" align="center">
<label value="&find.label;" accesskey="&find.accesskey;" control="search-box"/>
<label value="&search.label;" accesskey="&search.accesskey;" control="search-box"/>
<textbox id="search-box" flex="1"
type="timed" timeout="500"
callback="document.getElementById('bookmarks-view').searchBookmarks(document.getElementById('search-box').value)"/>
</hbox>
<bookmarks-tree id="bookmarks-view" class="sidebar" type="single-column" flex="1"/>
<bookmarks-tree id="bookmarks-view" type="single-column" flex="1"
onkeypress="if (event.keyCode == 13) this.openItemKey();"
ondraggesture="if (event.originalTarget.localName == 'treechildren') nsDragAndDrop.startDrag(event, this.DNDObserver);"
onclick="this.openItemClick(event, 1);"/>
</page>

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

@ -38,11 +38,11 @@
ondialogaccept="return Commit();">
<stringbundleset>
<stringbundle id="bundle_bookmarks" src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
<stringbundle id="bundle_bookmarks" src="chrome://communicator/locale/bookmarks/bookmarks.properties"/>
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
</stringbundleset>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bm-props.js"/>
<keyset id="keyset"/>
@ -83,7 +83,7 @@
<label value="&bookmarks.shortcut.label;" control="shortcut"/>
<textbox id="shortcut" />
</row>
<row>
<row id="descriptionrow">
<label value="&bookmarks.description.label;" control="description"/>
<textbox multiline="true" wrap="virtual" id="description" flex="1"/>
</row>

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

@ -1,14 +1,14 @@
bookmarks-tree, bookmarks-tree[type="multi-column"]
{
-moz-binding : url("chrome://communicator/content/bookmarks/bookmarks.xml#bookmarks-tree-full");
-moz-binding : url("chrome://communicator/content/bookmarks/bookmarksTree.xml#bookmarks-tree-full");
}
bookmarks-tree[type="single-column"]
{
-moz-binding : url("chrome://communicator/content/bookmarks/bookmarks.xml#bookmarks-tree-name");
-moz-binding : url("chrome://communicator/content/bookmarks/bookmarksTree.xml#bookmarks-tree-name");
}
bookmarks-tree[type="folders"]
{
-moz-binding : url("chrome://communicator/content/bookmarks/bookmarks.xml#bookmarks-tree-folders");
-moz-binding : url("chrome://communicator/content/bookmarks/bookmarksTree.xml#bookmarks-tree-folders");
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,207 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author, v3.0)
*/
////////////////////////////////////////////////////////////////////////////////
// Initialize the command controllers, set focus, tree root,
// window title state, etc.
function Startup()
{
const windowNode = document.getElementById("bookmark-window");
const bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.treeBoxObject.selection.select(0);
var titleString;
// If we've been opened with a parameter, root the tree on it.
if ("arguments" in window && window.arguments[0]) {
var title;
var uri = window.arguments[0];
bookmarksView.tree.setAttribute("ref", uri);
document.getElementById("bookmarks-search").setAttribute("hidden","true")
if (uri.substring(0,5) == "find:") {
title = BookmarksUtils.getLocaleString("search_results_title");
// Update the windowtype so that future searches are directed
// there and the window is not re-used for bookmarks.
windowNode.setAttribute("windowtype", "bookmarks:searchresults");
}
else
title = BookmarksUtils.getProperty(window.arguments[0], NC_NS+"Name");
titleString = BookmarksUtils.getLocaleString("window_title", title);
}
else {
titleString = BookmarksUtils.getLocaleString("bookmarks_title", title);
// always open the bookmark top root folder
if (!bookmarksView.treeBoxObject.view.isContainerOpen(0))
bookmarksView.treeBoxObject.view.toggleOpenState(0);
}
windowNode.setAttribute("title", titleString);
gBMtxmgr = BookmarksUtils.getTransactionManager();
document.getElementById("CommandUpdate_Bookmarks").setAttribute("commandupdater","true");
bookmarksView.tree.focus();
}
function Shutdown ()
{
// Store current window position and size in window attributes (for persistence).
var win = document.getElementById("bookmark-window");
win.setAttribute("x", screenX);
win.setAttribute("y", screenY);
win.setAttribute("height", outerHeight);
win.setAttribute("width", outerWidth);
}
var gConstructedViewMenuSortItems = false;
function fillViewMenu(aEvent)
{
var adjacentElement = document.getElementById("fill-before-this-node");
var popupElement = aEvent.target;
var bookmarksView = document.getElementById("bookmarks-view");
var columns = bookmarksView.columns;
if (!gConstructedViewMenuSortItems) {
for (var i = 0; i < columns.length; ++i) {
var accesskey = columns[i].accesskey;
var menuitem = document.createElement("menuitem");
var name = BookmarksUtils.getLocaleString("SortMenuItem", columns[i].label);
menuitem.setAttribute("label", name);
menuitem.setAttribute("accesskey", columns[i].accesskey);
menuitem.setAttribute("resource", columns[i].resource);
menuitem.setAttribute("id", "sortMenuItem:" + columns[i].resource);
menuitem.setAttribute("checked", columns[i].sortActive);
menuitem.setAttribute("name", "sortSet");
menuitem.setAttribute("type", "radio");
popupElement.insertBefore(menuitem, adjacentElement);
}
gConstructedViewMenuSortItems = true;
}
const kPrefSvcContractID = "@mozilla.org/preferences;1";
const kPrefSvcIID = Components.interfaces.nsIPrefService;
var prefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
var bookmarksSortPrefs = prefSvc.getBranch("browser.bookmarks.sort.");
if (gConstructedViewMenuSortItems) {
var resource = bookmarksSortPrefs.getCharPref("resource");
var element = document.getElementById("sortMenuItem:" + resource);
if (element)
element.setAttribute("checked", "true");
}
var sortAscendingMenu = document.getElementById("ascending");
var sortDescendingMenu = document.getElementById("descending");
var noSortMenu = document.getElementById("natural");
sortAscendingMenu.setAttribute("checked", "false");
sortDescendingMenu.setAttribute("checked", "false");
noSortMenu.setAttribute("checked", "false");
var direction = bookmarksSortPrefs.getCharPref("direction");
if (direction == "natural")
sortAscendingMenu.setAttribute("checked", "true");
else if (direction == "ascending")
sortDescendingMenu.setAttribute("checked", "true");
else
noSortMenu.setAttribute("checked", "true");
}
function onViewMenuSortItemSelected(aEvent)
{
var resource = aEvent.target.getAttribute("resource");
const kPrefSvcContractID = "@mozilla.org/preferences;1";
const kPrefSvcIID = Components.interfaces.nsIPrefService;
var prefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
var bookmarksSortPrefs = prefSvc.getBranch("browser.bookmarks.sort.");
switch (resource) {
case "":
break;
case "direction":
var dirn = bookmarksSortPrefs.getCharPref("direction");
if (aEvent.target.id == "ascending")
bookmarksSortPrefs.setCharPref("direction", "natural");
else if (aEvent.target.id == "descending")
bookmarksSortPrefs.setCharPref("direction", "ascending");
else
bookmarksSortPrefs.setCharPref("direction", "descending");
break;
default:
bookmarksSortPrefs.setCharPref("resource", resource);
var direction = bookmarksSortPrefs.getCharPref("direction");
if (direction == "descending")
bookmarksSortPrefs.setCharPref("direction", "natural");
break;
}
aEvent.preventCapture();
}
var gConstructedColumnsMenuItems = false;
function fillColumnsMenu(aEvent)
{
var bookmarksView = document.getElementById("bookmarks-view");
var columns = bookmarksView.columns;
var i;
if (!gConstructedColumnsMenuItems) {
for (i = 0; i < columns.length; ++i) {
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", columns[i].label);
menuitem.setAttribute("resource", columns[i].resource);
menuitem.setAttribute("id", "columnMenuItem:" + columns[i].resource);
menuitem.setAttribute("type", "checkbox");
menuitem.setAttribute("checked", columns[i].hidden != "true");
aEvent.target.appendChild(menuitem);
}
gConstructedColumnsMenuItems = true;
}
else {
for (i = 0; i < columns.length; ++i) {
var element = document.getElementById("columnMenuItem:" + columns[i].resource);
if (element && columns[i].hidden != "true")
element.setAttribute("checked", "true");
}
}
aEvent.preventBubble();
}
function onViewMenuColumnItemSelected(aEvent)
{
var resource = aEvent.target.getAttribute("resource");
if (resource != "") {
var bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.toggleColumnVisibility(resource);
}
aEvent.preventBubble();
}

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

@ -0,0 +1,265 @@
<?xml version="1.0"?>
<!-- -*- Mode: HTML; indent-tabs-mode: nil; -*- -->
<!--
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.org code.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s):
Ben Goodger <ben@netscape.com>
Blake Ross <blakeross@telocity.com>
Dean Tessman <dean_tessman@hotmail.com>
Mike Kowalski <mikejk@ameritech.net>
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/bookmarks/bookmarksWindow.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/content/bookmarks/bookmarks.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/bookmarks/bookmarksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % utilDTD SYSTEM "chrome://communicator/locale/utilityOverlay.dtd" >
%utilDTD;
<!ENTITY % bmDTD SYSTEM "chrome://communicator/locale/bookmarks/bookmarks.dtd">
%bmDTD;
]>
<window id="bookmark-window" windowtype="bookmarks:manager"
title="&bookmarksWindowTitle.label;"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:web="http://home.netscape.com/WEB-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="630" height="400" screenX="20" screenY="20"
persist="width height screenX screenY sizemode"
onload="Startup();" onunload="Shutdown();">
<!-- The order of loading of these script files is IMPORTANT -->
<!-- Shared Libraries -->
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
<!-- XXX - This should SO become an XBL widget -->
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<!-- Shared Bookmarks Utility Library -->
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"/>
<!-- Bookmarks Window -->
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksManager.js"/>
<!-- Bookmarks Window Drag & Drop -->
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<popupset id="bookmarksPopupset"/>
<commands id="commands">
<commandset id="CommandUpdate_Bookmarks"
events="focus,tree-select"
oncommandupdate="document.getElementById('bookmarks-view').onCommandUpdate();">
</commandset>
<commandset id="tasksCommands"/>
<!-- File Menu -->
<command id="cmd_close" oncommand="close()"/>
<command id="cmd_quit"/>
<!-- Edit Menu -->
<command id="cmd_undo"/>
<command id="cmd_redo"/>
</commands>
<stringbundleset id="stringbundleset"/>
<keyset id="tasksKeys">
<!-- File Menu -->
<key id="key_close"/>
<key id="key_quit"/>
<!-- Edit Menu -->
<key id="key_undo"/>
<key id="key_redo"/>
<!-- These keybindings do not have a command specified in the overlay,
which is good, but we need to specify it ourselves here -->
<key id="key_cut" command="cmd_bm_cut"/>
<key id="key_copy" command="cmd_bm_copy"/>
<key id="key_paste" command="cmd_bm_paste"/>
<key id="key_selectAll" command="cmd_bm_selectAll"/>
<!-- We need to provide our own delete key binding because the key_delete
handler in platformGlobalOverlay.xul maps command to "cmd_delete" which
is NOT what we want! -->
<key id="key_bm_delete" keycode="VK_DELETE" command="cmd_bm_delete"/>
<key id="bm_key_find"
key="&edit.find.keybinding;"
command="cmd_bm_find" modifiers="accel"/>
<key id="bm_key_properties"
key="&edit.properties.keybinding;"
command="cmd_bm_properties" modifiers="accel"/>
</keyset>
<toolbox id="bookmarks-toolbox">
<menubar id="main-menubar" grippytooltiptext="&menuBar.tooltip;">
<menu id="menu_File">
<menupopup id="menu_FilePopup">
<menu id="menu_New">
<menupopup>
<menuitem label="&menuitem.newBookmark.label;"
accesskey="&command.newBookmark.accesskey;"
observes="cmd_bm_newbookmark"/>
<menuitem label="&menuitem.newFolder.label;"
accesskey="&command.newFolder.accesskey;"
observes="cmd_bm_newfolder"/>
<menuitem label="&menuitem.newSeparator.label;"
accesskey="&command.newSeparator.accesskey;"
observes="cmd_bm_newseparator"/>
</menupopup>
</menu>
<menuitem id="menu_close"/>
</menupopup>
</menu>
<menu id="menu_Edit">
<menupopup>
<menuitem id="menu_undo" disabled="true"/>
<menuitem id="menu_redo" disabled="true"/>
<menuseparator/>
<menuitem id="menu_bm_cut"
label="&cutCmd.label;" accesskey="&cutCmd.accesskey;"
key="key_cut" command="cmd_bm_cut"/>
<menuitem id="menu_bm_copy"
label="&copyCmd.label;" accesskey="&copyCmd.accesskey;"
key="key_copy" command="cmd_bm_copy"/>
<menuitem id="menu_bm_paste"
label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;"
key="key_paste" command="cmd_bm_paste"/>
<menuitem id="menu_bm_delete"
label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;"
key="key_bm_delete" command="cmd_bm_delete"/>
<menuseparator/>
<menuitem id="menu_bm_selectAll"
label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;"
key="key_selectAll" command="cmd_bm_selectAll"/>
<menuseparator/>
<menuitem label="&command.moveBookmark.label;"
accesskey="&command.moveBookmark.accesskey;"
command="cmd_bm_movebookmark"/>
<menuseparator/>
<menuitem observes="cmd_bm_properties" key="bm_key_properties"
label="&command.properties.label;"
accesskey="&command.properties.accesskey;" />
</menupopup>
</menu>
<menu id="menu_View">
<menupopup onpopupshowing="fillViewMenu(event)"
oncommand="onViewMenuSortItemSelected(event);">
<menuitem id="viewCommandToolbar" type="checkbox" class="menuitem-iconic"
label="&menuitem.view.command.toolbar.label;"
accesskey="&menuitem.view.command.toolbar.accesskey;"
oncommand="goToggleToolbar('command-toolbar', 'viewCommandToolbar'); event.preventBubble();"
persist="checked"/>
<menuseparator id="fill-after-this-node"/>
<menuitem id="natural" label="&menuitem.view.unsorted.label;"
accesskey="&menuitem.view.unsorted.accesskey;"
type="radio"
resource="direction" name="sortSet"/>
<menuseparator id="fill-before-this-node"/>
<menuitem id="ascending" label="&menuitem.view.ascending.label;"
accesskey="&menuitem.view.ascending.accesskey;"
type="radio"
resource="direction" name="sortDirectionSet"/>
<menuitem id="descending" label="&menuitem.view.descending.label;"
accesskey="&menuitem.view.descending.accesskey;"
type="radio"
resource="direction" name="sortDirectionSet"/>
<menuseparator/>
<menu id="descending" label="&menuitem.view.show_columns.label;"
accesskey="&menuitem.view.show_columns.accesskey;">
<menupopup id="columnsPopup" onpopupshowing="fillColumnsMenu(event);"
oncommand="onViewMenuColumnItemSelected(event);"/>
</menu>
<menuseparator/>
<menuitem label="&menuitem.newbookmarkfolder.label;"
command="cmd_bm_setnewbookmarkfolder"
accesskey="&menuitem.newbookmarkfolder.accesskey;"/>
<menuitem label="&menuitem.newinternetsearchfolder.label;"
command="cmd_bm_setnewsearchfolder"
accesskey="&menuitem.newinternetsearchfolder.accesskey;"/>
<menuitem label="&menuitem.personaltoolbarfolder.label;"
command="cmd_bm_setpersonaltoolbarfolder"
accesskey="&menuitem.personaltoolbarfolder.accesskey;"/>
</menupopup>
</menu>
<menu id="tasksMenu">
<menupopup id="taskPopup">
<menuitem command="cmd_bm_find" key="bm_key_find"
label="&menuitem.find.label;"
accesskey="&menuitem.find.accesskey;"/>
<menuitem label="&menuitem.import.label;"
accesskey="&menuitem.import.accesskey;"
observes="cmd_bm_import"/>
<menuitem label="&menuitem.export.label;"
accesskey="&menuitem.export.accesskey;"
observes="cmd_bm_export"/>
<menuseparator/>
</menupopup>
</menu>
<menu id="windowMenu"/>
<menu id="menu_Help"/>
</menubar>
<toolbar id="command-toolbar" tbalign="stretch" grippytooltiptext="&bookmarkToolbar.tooltip;">
<toolbarbutton id="newfolder" label="&button.newFolder.label;"
accesskey="&button.newFolder.accesskey;"
command="cmd_bm_newfolder"/>
<toolbarbutton id="newseparator" label="&button.newSeparator.label;"
accesskey="&button.newSeparator.accesskey;"
command="cmd_bm_newseparator"/>
<toolbarseparator/>
<toolbarbutton id="moveBookmark" label="&command.moveBookmarkShort.label;"
accesskey="&command.moveBookmark.accesskey;"
command="cmd_bm_movebookmark"/>
<toolbarseparator/>
<toolbarbutton id="properties" label="&command.properties.label;"
accesskey="&button.properties.accesskey;"
command="cmd_bm_properties"/>
<toolbarbutton id="rename" label="&command.rename.label;"
accesskey="&button.rename.accesskey;"
command="cmd_bm_rename"/>
<toolbarbutton id="delete" label="&command.delete.label;"
accesskey="&button.delete.accesskey;"
command="cmd_bm_delete"/>
</toolbar>
<toolbar id="bookmarks-search" grippytooltiptext="&bookmarksSearch.tooltip;">
<label value="&search.label;" accesskey="&search.accesskey;" control="search-box"/>
<textbox id="search-box" flex="1"
type="timed" timeout="500"
callback="document.getElementById('bookmarks-view').searchBookmarks(document.getElementById('search-box').value)"/>
</toolbar>
</toolbox>
<bookmarks-tree id="bookmarks-view" flex="1"/>
</window>

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

@ -0,0 +1,717 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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.org code.
*
* The Initial Developer of the Original Code is
* Pierre Chanial <chanial@noos.fr>
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var BookmarksMenu = {
_selection:null,
_target:null,
_orientation:null,
//////////////////////////////////////////////////////////////////////////
// Fill a context menu popup with menuitems appropriate for the current
// selection.
createContextMenu: function (aEvent)
{
var target = document.popupNode;
target.focus() // buttons in the pt have -moz-user-focus: ignore -->
this._selection = this.getBTSelection(target);
this._orientation = this.getBTOrientation(aEvent, target);
this._target = this.getBTTarget(target, this._orientation);
BookmarksCommand.createContextMenu(aEvent, this._selection);
this.onCommandUpdate();
aEvent.target.addEventListener("mousemove", BookmarksMenuController.onMouseMove, false)
},
/////////////////////////////////////////////////////////////////////////
// Clean up after closing the context menu popup
destroyContextMenu: function (aEvent)
{
if (content)
content.focus()
BookmarksMenuDNDObserver.onDragRemoveFeedBack(document.popupNode); // needed on cancel
aEvent.target.removeEventListener("mousemove", BookmarksMenuController.onMouseMove, false)
},
/////////////////////////////////////////////////////////////////////////////
// returns the formatted selection from aNode
getBTSelection: function (aNode)
{
var item;
switch (aNode.id) {
case "bookmarks-ptf":
item = "NC:PersonalToolbarFolder";
break;
case "BookmarksMenu":
item = "NC:BookmarksRoot";
break;
default:
item = aNode.id;
}
if (!this.isBTBookmark(item))
return {length:0};
var parent = this.getBTContainer(aNode);
var isExpanded = aNode.hasAttribute("open") && aNode.open;
var selection = {};
selection.item = [RDF.GetResource(item)];
selection.parent = [RDF.GetResource(parent)];
selection.isExpanded = [isExpanded];
selection.length = selection.item.length;
BookmarksUtils.checkSelection(selection);
return selection;
},
/////////////////////////////////////////////////////////////////////////
// returns the insertion target from aNode
getBTTarget: function (aNode, aOrientation)
{
var item, parent, index;
switch (aNode.id) {
case "bookmarks-ptf":
parent = "NC:PersonalToolbarFolder";
break;
case "BookmarksMenu":
parent = "NC:BookmarksRoot";
break;
default:
if (aOrientation == BookmarksUtils.DROP_ON)
parent = aNode.id
else {
parent = this.getBTContainer(aNode);
item = aNode;
}
}
parent = RDF.GetResource(parent);
if (aOrientation == BookmarksUtils.DROP_ON)
return BookmarksUtils.getTargetFromFolder(parent);
item = RDF.GetResource(item.id);
RDFC.Init(BMDS, parent);
index = RDFC.IndexOf(item);
if (aOrientation == BookmarksUtils.DROP_AFTER)
++index;
return { parent: parent, index: index };
},
/////////////////////////////////////////////////////////////////////////
// returns the parent resource of a node in the personal toolbar.
// this is determined by inspecting the source element and walking up the
// DOM tree to find the appropriate containing node.
getBTContainer: function (aNode)
{
var parent;
var item = aNode.id;
if (!this.isBTBookmark(item))
return "NC:BookmarksRoot"
parent = aNode.parentNode.parentNode;
parent = parent.id;
switch (parent) {
case "BookmarksMenu":
return "NC:BookmarksRoot";
case "PersonalToolbar":
return "NC:PersonalToolbarFolder";
case "bookmarks-button":
return "NC:BookmarksRoot";
default:
return parent;
}
},
///////////////////////////////////////////////////////////////////////////
// returns true if the node is a bookmark, a folder or a bookmark separator
isBTBookmark: function (aURI)
{
if (!aURI)
return false;
var type = BookmarksUtils.resolveType(aURI);
return (type == "BookmarkSeparator" ||
type == "Bookmark" ||
type == "Folder" ||
type == "FolderGroup" ||
type == "PersonalToolbarFolder")
},
/////////////////////////////////////////////////////////////////////////
// returns true if the node is a container. -->
isBTContainer: function (aTarget)
{
return aTarget.localName == "menu" || (aTarget.localName == "toolbarbutton" &&
(aTarget.getAttribute("container") == "true" || aTarget.getAttribute("group") == "true"));
},
/////////////////////////////////////////////////////////////////////////
// returns BookmarksUtils.DROP_BEFORE, DROP_ON or DROP_AFTER accordingly
// to the event coordinates. Skin authors could break us, we'll cross that
// bridge when they turn us 90degrees. -->
getBTOrientation: function (aEvent, aTarget)
{
var target
if (!aTarget)
target = aEvent.target;
else
target = aTarget;
if (target.localName == "menu" &&
target.parentNode.localName != "menupopup")
return BookmarksUtils.DROP_ON;
if (target.id == "bookmarks-ptf") {
return BookmarksUtils.DROP_ON;
}
var overButtonBoxObject = target.boxObject.QueryInterface(Components.interfaces.nsIBoxObject);
var overParentBoxObject = target.parentNode.boxObject.QueryInterface(Components.interfaces.nsIBoxObject);
var size, border;
var coordValue, clientCoordValue;
switch (target.localName) {
case "toolbarseparator":
case "toolbarbutton":
size = overButtonBoxObject.width;
coordValue = overButtonBoxObject.x;
clientCoordValue = aEvent.clientX;
break;
case "menuseparator":
case "menu":
case "menuitem":
size = overButtonBoxObject.height;
coordValue = overButtonBoxObject.y-overParentBoxObject.y;
clientCoordValue = aEvent.clientY;
break;
default: return BookmarksUtils.DROP_ON;
}
if (this.isBTContainer(target))
if (target.localName == "toolbarbutton") {
// the DROP_BEFORE area excludes the label
var iconNode = document.getAnonymousElementByAttribute(target, "class", "toolbarbutton-icon");
border = parseInt(document.defaultView.getComputedStyle(target,"").getPropertyValue("padding-left")) +
parseInt(document.defaultView.getComputedStyle(iconNode ,"").getPropertyValue("width"));
border = Math.min(size/5,Math.max(border,4));
} else
border = size/5;
else
border = size/2;
// in the first region?
if (clientCoordValue-coordValue < border)
return BookmarksUtils.DROP_BEFORE;
// in the last region?
if (clientCoordValue-coordValue >= size-border)
return BookmarksUtils.DROP_AFTER;
// must be in the middle somewhere
return BookmarksUtils.DROP_ON;
},
/////////////////////////////////////////////////////////////////////////
// expand the folder targeted by the context menu.
expandBTFolder: function ()
{
var target = document.popupNode.lastChild;
if (document.popupNode.open)
target.hidePopup();
else
target.showPopup(document.popupNode);
},
onCommandUpdate: function ()
{
var selection = this._selection;
var target = this._target;
BookmarksController.onCommandUpdate(selection, target);
if (document.popupNode.id == "bookmarks-ptf") {
// disabling 'cut' and 'copy' on the empty area of the personal toolbar
var commandNode = document.getElementById("cmd_bm_cut");
commandNode.setAttribute("disabled", "true");
commandNode = document.getElementById("cmd_bm_copy");
commandNode.setAttribute("disabled", "true");
}
},
loadBookmark: function (aTarget, aDS)
{
// Check for invalid bookmarks (most likely a static menu item like "Manage Bookmarks")
if (!this.isBTBookmark(aTarget.id))
return;
var rSource = RDF.GetResource(aTarget.id);
var selection = BookmarksUtils.getSelectionFromResource(rSource);
BookmarksCommand.openBookmark(selection, "current", aDS)
}
}
var BookmarksMenuController = {
supportsCommand: BookmarksController.supportsCommand,
isCommandEnabled: function (aCommand)
{
// warning: this is not the function called in BookmarksController.onCommandUpdate
var selection = BookmarksMenu._selection;
var target = BookmarksMenu._target;
if (selection)
return BookmarksController.isCommandEnabled(aCommand, selection, target);
return false;
},
doCommand: function (aCommand)
{
BookmarksMenuDNDObserver.onDragRemoveFeedBack(document.popupNode);
var selection = BookmarksMenu._selection;
var target = BookmarksMenu._target;
switch (aCommand) {
case "cmd_bm_expandfolder":
BookmarksMenu.expandBTFolder();
break;
default:
BookmarksController.doCommand(aCommand, selection, target);
}
},
onMouseMove: function (aEvent)
{
var command = aEvent.target.getAttribute("command");
var isDisabled = aEvent.target.getAttribute("disabled")
if (isDisabled != "true" && (command == "cmd_bm_newfolder" || command == "cmd_bm_paste")) {
BookmarksMenuDNDObserver.onDragSetFeedBack(document.popupNode, BookmarksMenu._orientation);
} else {
BookmarksMenuDNDObserver.onDragRemoveFeedBack(document.popupNode);
}
}
}
var BookmarksMenuDNDObserver = {
////////////////////
// Public methods //
////////////////////
onDragStart: function (aEvent, aXferData, aDragAction)
{
var target = aEvent.target;
// Prevent dragging from an invalid region
if (!this.canDrop(aEvent))
return;
// Prevent dragging out of menupopups on non Win32 platforms.
// a) on Mac drag from menus is generally regarded as being satanic
// b) on Linux, this causes an X-server crash, (bug 151336)
// c) on Windows, there is no hang or crash associated with this, so we'll leave
// the functionality there.
if (navigator.platform != "Win32" && target.localName != "toolbarbutton")
return;
// bail if dragging from the empty area of the bookmarks toolbar
if (target.id == "bookmarks-ptf")
return
// a drag start is fired when leaving an open toolbarbutton(type=menu)
// (see bug 143031)
if (this.isContainer(target) &&
target.getAttribute("group") != "true") {
if (this.isPlatformNotSupported)
return;
if (!aEvent.shiftKey && !aEvent.altKey && !aEvent.ctrlKey)
return;
// menus open on mouse down
target.firstChild.hidePopup();
}
var selection = BookmarksMenu.getBTSelection(target);
aXferData.data = BookmarksUtils.getXferDataFromSelection(selection);
},
onDragOver: function(aEvent, aFlavour, aDragSession)
{
var orientation = BookmarksMenu.getBTOrientation(aEvent)
if (aDragSession.canDrop)
this.onDragSetFeedBack(aEvent.target, orientation);
if (orientation != this.mCurrentDropPosition) {
// emulating onDragExit and onDragEnter events since the drop region
// has changed on the target.
this.onDragExit(aEvent, aDragSession);
this.onDragEnter(aEvent, aDragSession);
}
if (this.isPlatformNotSupported)
return;
if (this.isTimerSupported)
return;
this.onDragOverCheckTimers();
},
onDragEnter: function (aEvent, aDragSession)
{
var target = aEvent.target;
var orientation = BookmarksMenu.getBTOrientation(aEvent);
if (target.localName == "menupopup" || target.id == "bookmarks-ptf")
target = target.parentNode;
if (aDragSession.canDrop) {
this.onDragSetFeedBack(target, orientation);
this.onDragEnterSetTimer(target, aDragSession);
}
this.mCurrentDragOverTarget = target;
this.mCurrentDropPosition = orientation;
},
onDragExit: function (aEvent, aDragSession)
{
var target = aEvent.target;
if (target.localName == "menupopup" || target.id == "bookmarks-ptf")
target = target.parentNode;
this.onDragRemoveFeedBack(target);
this.onDragExitSetTimer(target, aDragSession);
this.mCurrentDragOverTarget = null;
this.mCurrentDropPosition = null;
},
onDrop: function (aEvent, aXferData, aDragSession)
{
var target = aEvent.target;
this.onDragRemoveFeedBack(target);
var selection = BookmarksUtils.getSelectionFromXferData(aDragSession);
var orientation = BookmarksMenu.getBTOrientation(aEvent);
var selTarget = BookmarksMenu.getBTTarget(target, orientation);
const kDSIID = Components.interfaces.nsIDragService;
const kCopyAction = kDSIID.DRAGDROP_ACTION_COPY + kDSIID.DRAGDROP_ACTION_LINK;
// hide the 'open in tab' menuseparator because bookmarks
// can be inserted after it if they are dropped after the last bookmark
// a more comprehensive fix would be in the menupopup template builder
var menuTarget = (target.localName == "toolbarbutton" ||
target.localName == "menu") &&
orientation == BookmarksUtils.DROP_ON?
target.lastChild:target.parentNode;
if (menuTarget.hasChildNodes() &&
menuTarget.lastChild.id == "openintabs-menuitem") {
menuTarget.removeChild(menuTarget.lastChild.previousSibling);
}
// disabling ctrl-DND for now bookmarks are not cloned
if (aDragSession.dragAction & kCopyAction)
SOUND.beep();
//BookmarksUtils.insertSelection("drag", selection, selTarget, true);
else
BookmarksUtils.moveSelection("drag", selection, selTarget);
// show again the menuseparator
if (menuTarget.hasChildNodes() &&
menuTarget.lastChild.id == "openintabs-menuitem") {
var element = document.createElementNS(XUL_NS, "menuseparator");
menuTarget.insertBefore(element, menuTarget.lastChild);
}
},
canDrop: function (aEvent, aDragSession)
{
var target = aEvent.target;
return BookmarksMenu.isBTBookmark(target.id) &&
target.id != "NC:SystemBookmarksStaticRoot" &&
target.id.substring(0,5) != "find:" ||
target.id == "BookmarksMenu" ||
target.id == "bookmarks-button" ||
target.id == "bookmarks-ptf";
},
canHandleMultipleItems: true,
getSupportedFlavours: function ()
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("moz/rdfitem");
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
flavourSet.appendFlavour("text/unicode");
return flavourSet;
},
////////////////////////////////////
// Private methods and properties //
////////////////////////////////////
springLoadedMenuDelay: 350, // milliseconds
isPlatformNotSupported: navigator.platform.indexOf("Mac") != -1, // see bug 136524
isTimerSupported: navigator.platform.indexOf("Win") == -1,
mCurrentDragOverTarget: null,
mCurrentDropPosition: null,
loadTimer : null,
closeTimer : null,
loadTarget : null,
closeTarget: null,
_observers : null,
get mObservers ()
{
if (!this._observers) {
this._observers = [
document.getElementById("bookmarks-ptf"),
document.getElementById("BookmarksMenu").parentNode,
document.getElementById("PersonalToolbar")
]
}
return this._observers;
},
getObserverForNode: function (aNode)
{
if (!aNode)
return null;
var node = aNode;
var observer;
do {
for (var i=0; i < this.mObservers.length; i++) {
observer = this.mObservers[i];
if (observer == node)
return observer;
}
node = node.parentNode;
} while (node != document)
return null;
},
onDragCloseMenu: function (aNode)
{
var children = aNode.childNodes;
for (var i = 0; i < children.length; i++) {
if (this.isContainer(children[i]) &&
children[i].getAttribute("open") == "true") {
this.onDragCloseMenu(children[i].lastChild);
if (children[i] != this.mCurrentDragOverTarget || this.mCurrentDropPosition != BookmarksUtils.DROP_ON)
children[i].lastChild.hidePopup();
}
}
},
onDragCloseTarget: function ()
{
var currentObserver = this.getObserverForNode(this.mCurrentDragOverTarget);
// close all the menus not hovered by the mouse
for (var i=0; i < this.mObservers.length; i++) {
if (currentObserver != this.mObservers[i])
this.onDragCloseMenu(this.mObservers[i]);
else
this.onDragCloseMenu(this.mCurrentDragOverTarget.parentNode);
}
},
onDragLoadTarget: function (aTarget)
{
if (!this.mCurrentDragOverTarget)
return;
// Load the current menu
if (this.mCurrentDropPosition == BookmarksUtils.DROP_ON &&
this.isContainer(aTarget) &&
aTarget.getAttribute("group") != "true")
aTarget.lastChild.showPopup(aTarget);
},
onDragOverCheckTimers: function ()
{
var now = new Date().getTime();
if (this.closeTimer && now-this.springLoadedMenuDelay>this.closeTimer) {
this.onDragCloseTarget();
this.closeTimer = null;
}
if (this.loadTimer && (now-this.springLoadedMenuDelay>this.loadTimer)) {
this.onDragLoadTarget(this.loadTarget);
this.loadTimer = null;
}
},
onDragEnterSetTimer: function (aTarget, aDragSession)
{
if (this.isPlatformNotSupported)
return;
if (this.isTimerSupported) {
var targetToBeLoaded = aTarget;
clearTimeout(this.loadTimer);
if (aTarget == aDragSession.sourceNode)
return;
var This = this;
this.loadTimer=setTimeout(function () {This.onDragLoadTarget(targetToBeLoaded)}, This.springLoadedMenuDelay);
} else {
var now = new Date().getTime();
this.loadTimer = now;
this.loadTarget = aTarget;
}
},
onDragExitSetTimer: function (aTarget, aDragSession)
{
if (this.isPlatformNotSupported)
return;
var This = this;
if (this.isTimerSupported) {
clearTimeout(this.closeTimer)
this.closeTimer=setTimeout(function () {This.onDragCloseTarget()}, This.springLoadedMenuDelay);
} else {
var now = new Date().getTime();
this.closeTimer = now;
this.closeTarget = aTarget;
this.loadTimer = null;
// If user isn't rearranging within the menu, close it
// To do so, we exploit a Mac bug: timeout set during
// drag and drop on Windows and Mac are fired only after that the drop is released.
// timeouts will pile up, we may have a better approach but for the moment, this one
// correctly close the menus after a drop/cancel outside the personal toolbar.
// The if statement in the function has been introduced to deal with rare but reproducible
// missing Exit events.
if (aDragSession.sourceNode.localName != "menuitem" && aDragSession.sourceNode.localName != "menu")
setTimeout(function () { if (This.mCurrentDragOverTarget) {This.onDragRemoveFeedBack(This.mCurrentDragOverTarget); This.mCurrentDragOverTarget=null} This.loadTimer=null; This.onDragCloseTarget() }, 0);
}
},
onDragSetFeedBack: function (aTarget, aOrientation)
{
switch (aTarget.localName) {
case "toolbarseparator":
case "toolbarbutton":
switch (aOrientation) {
case BookmarksUtils.DROP_BEFORE:
aTarget.setAttribute("dragover-left", "true");
break;
case BookmarksUtils.DROP_AFTER:
aTarget.setAttribute("dragover-right", "true");
break;
case BookmarksUtils.DROP_ON:
aTarget.setAttribute("dragover-top" , "true");
aTarget.setAttribute("dragover-bottom", "true");
aTarget.setAttribute("dragover-left" , "true");
aTarget.setAttribute("dragover-right" , "true");
break;
}
break;
case "menuseparator":
case "menu":
case "menuitem":
switch (aOrientation) {
case BookmarksUtils.DROP_BEFORE:
aTarget.setAttribute("dragover-top", "true");
break;
case BookmarksUtils.DROP_AFTER:
aTarget.setAttribute("dragover-bottom", "true");
break;
case BookmarksUtils.DROP_ON:
break;
}
break;
case "toolbar":
var newTarget = document.getElementById("bookmarks-ptf").lastChild;
if (newTarget)
newTarget.setAttribute("dragover-right", "true");
break;
case "hbox":
case "menupopup": break;
default: dump("No feedback for: "+aTarget.localName+"\n");
}
},
onDragRemoveFeedBack: function (aTarget)
{
var newTarget;
var bt;
if (aTarget.id == "PersonalToolbar" || aTarget.id == "bookmarks-ptf") {
newTarget = document.getElementById("bookmarks-ptf").lastChild;
if (newTarget)
newTarget.removeAttribute("dragover-right");
} else {
aTarget.removeAttribute("dragover-left");
aTarget.removeAttribute("dragover-right");
aTarget.removeAttribute("dragover-top");
aTarget.removeAttribute("dragover-bottom");
}
},
onDropSetFeedBack: function (aTarget)
{
//XXX Not yet...
},
isContainer: function (aTarget)
{
return aTarget.localName == "menu" ||
aTarget.localName == "toolbarbutton" &&
aTarget.getAttribute("type") == "menu";
}
}
var BookmarksToolbar =
{
////////////////////////////////////////////////
// loads a bookmark with the mouse middle button
loadBookmarkMiddleClick: function (aEvent, aDS)
{
if (aEvent.button != 1)
return;
// unlike for command events, we have to close the menus manually
BookmarksMenuDNDObserver.mCurrentDragOverTarget = null;
BookmarksMenuDNDObserver.onDragCloseTarget();
BookmarksUtils.loadBookmarkBrowser(aEvent, aEvent.target, aDS);
},
// Fill in tooltips for personal toolbar
fillInBTTooltip: function (tipElement)
{
var title = tipElement.label;
var url = tipElement.statusText;
if (!title && !url) {
// bail out early if there is nothing to show
return false;
}
var tooltipTitle = document.getElementById("btTitleText");
var tooltipUrl = document.getElementById("btUrlText");
if (title && title != url) {
tooltipTitle.removeAttribute("hidden");
tooltipTitle.setAttribute("value", title);
} else {
tooltipTitle.setAttribute("hidden", "true");
}
if (url) {
tooltipUrl.removeAttribute("hidden");
tooltipUrl.setAttribute("value", url);
} else {
tooltipUrl.setAttribute("hidden", "true");
}
return true; // show tooltip
}
}

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

@ -30,22 +30,17 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_bookmarks" src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
<stringbundle id="bundle_bookmarks" src="chrome://communicator/locale/bookmarks/bookmarks.properties"/>
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
</stringbundleset>
<popupset id="bookmarksPopupset">
<!-- the toolbar buttons in the personal toolbar have -moz-user-focus:ignore
we have to focus them manually -->
<popup id="bmContext"
onpopupshowing="gBookmarksShell.doFocus(); gBookmarksShell.createContextMenu(event);"
onpopuphidden="if (content) content.focus()"/>
</popupset>
<commands id="commands">
<commandset id="bookmarksItems">
<command id="cmd_bm_open" oncommand="goDoCommand('cmd_bm_open');"/>
<command id="cmd_bm_openfolder" oncommand="goDoCommand('cmd_bm_openfolder');"/>
<command id="cmd_bm_openinnewwindow" oncommand="goDoCommand('cmd_bm_openinnewwindow');"/>
<command id="cmd_bm_openinnewtab" oncommand="goDoCommand('cmd_bm_openinnewtab');"/>
<command id="cmd_bm_expandfolder" oncommand="goDoCommand('cmd_bm_expandfolder');"/>
<command id="cmd_bm_managefolder" oncommand="goDoCommand('cmd_bm_managefolder');"/>
<command id="cmd_bm_newfolder" oncommand="goDoCommand('cmd_bm_newfolder');"/>
<command id="cmd_bm_newbookmark" oncommand="goDoCommand('cmd_bm_newbookmark');"/>
<command id="cmd_bm_newseparator" oncommand="goDoCommand('cmd_bm_newseparator');"/>
@ -55,11 +50,9 @@
<command id="cmd_bm_setnewsearchfolder" oncommand="goDoCommand('cmd_bm_setnewsearchfolder');"/>
<command id="cmd_bm_properties" oncommand="goDoCommand('cmd_bm_properties');"/>
<command id="cmd_bm_rename" oncommand="goDoCommand('cmd_bm_rename');"/>
<command id="cmd_bm_openinnewwindow" oncommand="goDoCommand('cmd_bm_openinnewwindow');"/>
<command id="cmd_bm_openinnewtab" oncommand="goDoCommand('cmd_bm_openinnewtab');"/>
<command id="cmd_bm_import" oncommand="goDoCommand('cmd_bm_import');"/>
<command id="cmd_bm_export" oncommand="goDoCommand('cmd_bm_export');"/>
<command id="cmd_bm_fileBookmark" oncommand="goDoCommand('cmd_bm_fileBookmark');"/>
<command id="cmd_bm_movebookmark" oncommand="goDoCommand('cmd_bm_movebookmark');"/>
<command id="cmd_bm_cut" oncommand="goDoCommand('cmd_bm_cut');"/>
<command id="cmd_bm_copy" oncommand="goDoCommand('cmd_bm_copy');"/>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -37,9 +37,9 @@
onload="Startup();"
ondialogaccept="return find();">
<stringbundle id="bookmarksBundle" src="chrome://communicator/locale/bookmarks/bookmark.properties"/>
<stringbundle id="bookmarksBundle" src="chrome://communicator/locale/bookmarks/bookmarks.properties"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/findBookmark.js"/>
<label value="&search.for.label;"/>

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

@ -20,27 +20,17 @@
- Ben Goodger <ben@netscape.com> (Original Author)
-->
<!ENTITY newBookmark.title "Add Bookmark">
<!ENTITY newbookmark.label "&brandShortName; will add a bookmark to this page.">
<!ENTITY newBookmark.title "File Bookmark">
<!ENTITY selectFolder.title "Choose Folder">
<!ENTITY name.label "Name:">
<!ENTITY name.accesskey "n">
<!ENTITY name.accesskey "N">
<!ENTITY url.label "Location:">
<!ENTITY url.accesskey "l">
<!ENTITY button.createin.label "Create In &gt;&gt;">
<!ENTITY button.createin.accesskey "c">
<!ENTITY button.createin2.label "Create In &lt;&lt;">
<!ENTITY createin.label "Create in:">
<!ENTITY createin.accesskey "i">
<!ENTITY button.newfolder.label "New Folder...">
<!ENTITY button.newfolder.accesskey "w">
<!ENTITY alwayscreateinfolder.label "Don't show this dialog again">
<!ENTITY alwayscreateinfolder.accesskey "a">
<!ENTITY dontshowmessage.tooltip "When this option is selected, new Bookmarks will be added using the title provided by the page.">
<!ENTITY button.defaultfolder.label "Use Default">
<!ENTITY button.defaultfolder.accesskey "d">
<!ENTITY selectFolder.label "Choose Folder">
<!ENTITY url.accesskey "L">
<!ENTITY shortcutURL.label "Keyword:">
<!ENTITY shortcutURL.accesskey "K">
<!ENTITY destination.label "Destination:">
<!ENTITY destination.accesskey "D">
<!ENTITY newFolder.label "New Folder...">
<!ENTITY newFolder.accesskey "w">
<!ENTITY addGroup.label "Bookmark this group of tabs">
<!ENTITY addGroup.accesskey "B">

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

@ -52,13 +52,12 @@
<!ENTITY button.rename.accesskey "R">
<!ENTITY command.delete.label "Delete">
<!ENTITY button.delete.accesskey "D">
<!ENTITY command.fileBookmark.label "File Bookmark(s)...">
<!ENTITY button.fileBookmark.accesskey "B">
<!ENTITY command.fileBookmark.accesskey "l">
<!ENTITY command.moveBookmark.label "Move Bookmark(s)...">
<!ENTITY command.moveBookmarkShort.label "Move...">
<!ENTITY command.moveBookmark.accesskey "M">
<!ENTITY command.addBookmark.label "Add...">
<!ENTITY command.manageBookmarks.label "Manage">
<!ENTITY menuitem.view.command.toolbar.label "Toolbar">
<!ENTITY menuitem.view.command.toolbar.accesskey "t">
<!ENTITY menuitem.view.unsorted.label "Unsorted">
@ -93,5 +92,5 @@
<!ENTITY bookmarksWindowTitle.label "Bookmark Manager">
<!ENTITY find.label "Search">
<!ENTITY find.accesskey "S">
<!ENTITY search.label "Search">
<!ENTITY search.accesskey "S">

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

@ -0,0 +1,92 @@
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
description_Bookmark = %brandShortName% can remember web page locations for you. Type the page name and location in the fields below, then click OK. Select the page from the Bookmarks menu or your Bookmarks Sidebar tab to visit the page.
description_Folder = %brandShortName% can organize your bookmarks into specific folders. Type the folder name and an optional comment below, then click OK.
description_FolderGroup = %brandShortName% can bookmark a group of web pages. Type a group name and an optional comment in the field below, then click OK. Select the group from the Bookmark menu or your Bookmarks Sidebar tab to open each page in a separate Navigator tab.
description_PersonalToolbarFolder = Folders and bookmarks in this folder appear on the Personal Toolbar.
description_NewBookmarkFolder = Newly created bookmarks will be stored here by default.
description_NewSearchFolder = Search results will be stored here by default.
description_NewBookmarkAndSearchFolder = Newly created bookmarks and search results will be stored here by default.
description_BookmarkSeparator = %brandShortName% can organize your bookmarks by putting separators between them. Type an optional separator name below, then click OK.
cmd_bm_open = Open
cmd_bm_expandfolder = Expand
cmd_bm_collapsefolder = Collapse
cmd_bm_managefolder = Open in New Window
cmd_bm_find = Find a Bookmark...
cmd_bm_cut = Cut
cmd_bm_copy = Copy
cmd_bm_paste = Paste
cmd_bm_delete = Delete
cmd_bm_movebookmark = Move Bookmark(s)...
cmd_bm_selectAll = Select All
cmd_bm_rename = Rename...
cmd_bm_renamebookmark2 = Change Location...
cmd_bm_properties = Properties
cmd_bm_openinnewwindow = Open in New Window
cmd_bm_openinnewtab = Open in New Tab
cmd_bm_newfolder = New Folder...
cmd_bm_newbookmark = New Bookmark...
cmd_bm_newseparator = New Separator
cmd_bm_setnewbookmarkfolder = Set as New Bookmark folder
cmd_bm_setpersonaltoolbarfolder = Set as Personal Toolbar folder
cmd_bm_setnewsearchfolder = Set as Saved Search Results folder
ile_newfolder = New Folder
ile_newbookmark = New Bookmark
newfolder_dialog_title = Create New Folder
newfolder_dialog_msg = Create a New Folder named:
window_title = %S - Bookmarks
search_results_title = Search Results
file_in = File in "%S"
bookmarks_root = Bookmarks for %S
bookmarks_title = Bookmark Manager
status_foldercount = %S object(s)
WebPageUpdated = The following web page has been updated:
WebPageTitle = Title:
WebPageURL = URL:
WebPageAskDisplay = Would you like to display it?
WebPageAskStopOption = Stop checking for updates on this web page
pleaseEnterALocation = Please enter a location
pleaseEnterADuration = Please enter a duration.
pleaseSelectANotification = Please enter at least one notification method.
SortMenuItem = Sorted by %S
ShortFindTitle = Find: '%S'
FindTitle = Find: %S %S '%S' in %S
ImportedIEFavorites = Imported IE Favorites
ImportedIEStaticFavorites = Imported IE Favorites
ImportedNetPositiveBookmarks = Imported NetPositive Bookmarks
DefaultPersonalToolbarFolder = Personal Toolbar Folder
SelectImport = Import bookmark file:
EnterExport = Export bookmark file:
search_button_label = Find