This commit is contained in:
annie.sullivan%gmail.com 2006-04-13 00:48:00 +00:00
Родитель fdf31f9992
Коммит 75776cd3b1
10 изменённых файлов: 411 добавлений и 6 удалений

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

@ -99,6 +99,57 @@ BrowserController.events[BrowserController.EVENT_TABCHANGE] =
[BookmarkAllTabsCommand.NAME];
var PlacesCommandHook = {
/**
* Keeps a reference to the places popup window when it is open
*/
_placesPopup: null,
/**
* Shows the places popup
* @param event
* DOMEvent for the button command that opens the popup.
*/
showPlacesPopup: function PCH_showPlacesPopup(event) {
if (!this._placesPopup) {
// XXX - the button might not exist, need to handle this case.
var button = document.getElementById("bookmarksBarShowPlaces");
var top = button.boxObject.screenY;
#ifndef XP_MACOSX
top += button.boxObject.height;
#endif
var left = button.boxObject.screenX;
var openArguments = "chrome,dependent,";
openArguments += "top=" + top + ",left=" + left;
openArguments += ",titlebar=no"
this._placesPopup = window.openDialog("chrome://browser/content/places/placesPopup.xul", "placesPopup", openArguments, ORGANIZER_ROOT_BOOKMARKS);
}
},
/**
* Hides the places popup
* @param event
* DOMEvent for the button command that closes the popup.
*/
hidePlacesPopup: function PCH_hidePlacesPopup(event) {
if (this._placesPopup) {
this._placesPopup.close();
this._placesPopup = null;
}
},
/**
* Toggles the places popup
* @param event
* DOMEvent for the button command that opens the popup.
*/
togglePlacesPopup: function PCH_togglePlacesPopup(event) {
if (this._placesPopup)
this.hidePlacesPopup();
else
this.showPlacesPopup();
},
/**
* Adds a bookmark to the page loaded in the current tab.
*/

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

@ -193,7 +193,7 @@
<broadcasterset id="mainBroadcasterSet">
#ifdef MOZ_PLACES
<broadcaster id="viewHistoryPlaces" autoCheck="false" label="&historyButton.label;"
oncommand="PlacesBrowserShim.showHistory();"/>
oncommand="PlacesCommandHook.showPlacesPopup(event);"/>
#else
<broadcaster id="viewBookmarksSidebar" autoCheck="false" label="&bookmarksButton.label;"
type="checkbox" group="sidebar" sidebarurl="chrome://browser/content/bookmarks/bookmarksPanel.xul"

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

@ -287,7 +287,7 @@
class="toolbarbutton-1 chromeclass-toolbar-additional"
label="&placesToolbarButton.label;"
tooltiptext="&placesToolbarButton.tooltip;"
oncommand="PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_HISTORY);"/>
oncommand="PlacesCommandHook.togglePlacesPopup(event);"/>
<toolbaritem flex="1" id="personal-bookmarks" title="&bookmarksItem.title;">
<hbox id="bookmarksBarContent" flex="1" type="places"
place="place:&amp;folder=3&amp;group=3&amp;expandQueries=1"

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

@ -10,6 +10,8 @@
extends="chrome://global/content/bindings/popup.xml#popup">
<implementation>
<constructor><![CDATA[
this.history = PlacesController.history;
// Support an asyncinit attribute that causes the view to populate
// itself only after the window has been shown. This is to ensure we
// do not regress browser window show time (Ts/Txul)
@ -19,8 +21,6 @@
}
else
this._init();
this.history = PlacesController.history;
]]></constructor>
<destructor><![CDATA[
@ -148,7 +148,10 @@
this._resultNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
else
return; // Nothing to do if this menu isn't a container.
// Keep track of whether to make submenus for children
var noSubmenus = (this.getAttribute("nosubmenus") == "true");
// Container should always be open while rebuilding.
var wasOpen = this._resultNode.containerOpen;
this._resultNode.containerOpen = true;
@ -171,7 +174,7 @@
for (var i = 0; i < cc; ++i) {
var child = this._resultNode.getChild(i);
var element = null;
if (PlacesController.nodeIsURI(child)) {
if (PlacesController.nodeIsURI(child) || noSubmenus) {
element = document.createElementNS(XULNS, "menuitem");
element.setAttribute("label", child.title);
element.setAttribute("url", child.uri);

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

@ -0,0 +1,218 @@
//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Mozilla Places Popup.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005-2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Annie Sullivan <annie.sullivan@gmail.com>
*
* 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 ***** */
/**
* Sets the place URI in the tree and menulist.
* This function is global so it can be easily accessed by openers.
* @param placeURI
* A place: URI string to select
*/
function setPlaceURI(placeURI) {
// Set the place for the tree.
PlacesPopup._tree.place = placeURI;
// Set the selected item in the menulist.
for (var i = 0; i < PlacesPopup._popup.childNodes.length; i++) {
if (PlacesPopup._popup.childNodes[i].getAttribute("url") == placeURI) {
PlacesPopup._menulist.selectedIndex = i;
break;
}
}
}
/**
* Functions for handling events related to the places button and its popup.
*/
var PlacesPopup = {
/**
* UI Text Strings
*/
__strings: null,
get _strings() {
if (!this.__strings)
this.__strings = document.getElementById("stringBundle");
return this.__strings;
},
/**
* Places tree
*/
__tree: null,
get _tree() {
if (!this.__tree)
this.__tree = document.getElementById("placesPopupTree");
return this.__tree;
},
/**
* Search results tree
*/
__searchTree: null,
get _searchTree() {
if (!this.__searchTree)
this.__searchTree = document.getElementById("placesPopupSearchTree");
return this.__searchTree;
},
/**
* Places menulist popup
*/
__popup: null,
get _popup() {
if (!this.__popup)
this.__popup = document.getElementById("placesPopupViewMenuPopup");
return this.__popup;
},
/**
* Places menulist
*/
__menulist: null,
get _menulist() {
if (!this.__menulist)
this.__menulist = document.getElementById("placesPopupView");
return this.__menulist;
},
/**
* Result used to populate drop-down menu.
*/
_menuResult: null,
/**
* Initializes the popup
*/
init: function() {
// Select the correct place to view in the menulist and tree.
this._popup._rebuild();
setPlaceURI(window.arguments[0]);
},
/**
* Called when the text in the search textbox changes.
* Show or hide the search results depending on whether text was typed.
* If text was typed, run a query to get new search results.
* @param event
* DOMEvent for the textbox command.
*/
onSearchTextChanged: function PP_onSearchTextChanged(event) {
var searchbox = document.getElementById("placesPopupSearch");
var searchResults = document.getElementById("placesPopupSearchResults");
if (searchbox.value == "") {
// Empty searchbox, hide search results
searchResults.hidden = true;
}
else {
// New text in the searchbox, show search results
searchResults.hidden = false;
// Tree view shouldn't show at the same time as search results.
var expandButton = document.getElementById("placesPopupExpand");
this.expandTreeView(false, expandButton);
// Set filter string to search.
this._searchTree.filterString = searchbox.value;
}
// Update the window size.
window.sizeToContent();
},
/**
* Called when the menuitem in the place menulist is selected.
*/
onPlaceMenuitemSelected: function PP_onPlaceMenuitemSelected(event) {
this._tree.place = event.target.getAttribute("url");
},
/**
* Called when the expand button is pressed. Toggles whether the
* places tree, menulist, and organize button are showing.
*/
onExpandButtonCommand: function PP_onExpandButtonCommand(event) {
var expandButton = document.getElementById("placesPopupExpand");
this.expandTreeView(expandButton.getAttribute("expanded") == "false", expandButton);
// Update the window size.
window.sizeToContent();
},
/**
* Utility function to expand or collapse tree view
* @param expand
* boolean, expand if true or collapse if false
* @param expandButton
* XULElement for the expand/collapse button
*/
expandTreeView: function PP_expandTreeView(expand, expandButton) {
var treeContainer = document.getElementById("placesPopupTreeContainer");
var organizeButton = document.getElementById("placesPopupOrganize");
if (expand) {
// Expand the tree view.
treeContainer.hidden = false;
organizeButton.hidden = false;
expandButton.setAttribute("label", this._strings.getString("collapseButtonLabel"));
expandButton.setAttribute("expanded", "true");
// Search results should be collapsed while tree view is visible.
var searchResults = document.getElementById("placesPopupSearchResults");
searchResults.hidden = true;
}
else {
// Collapse the tree view.
treeContainer.hidden = true;
organizeButton.hidden = true;
expandButton.setAttribute("label", this._strings.getString("expandButtonLabel"));
expandButton.setAttribute("expanded", "false");
}
},
/**
* Handles double-clicking of a link in the places tree.
* @param event
* DOMEvent for the double click.
*/
onLinkDoubleClicked: function PP_onLinkDoubleClicked(event) {
// Load the link and hide the places window.
PlacesController.mouseLoadURI(event);
window.opener.PlacesCommandHook.hidePlacesPopup();
}
};
#include ../../../../toolkit/content/debug.js

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

@ -0,0 +1,121 @@
<?xml version="1.0"?>
# -*- Mode: HTML -*-
#
# ***** 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 Mozilla Communicator client code, released
# March 31, 1998.
#
# The Initial Developer of the Original Code is
# Google.
# Portions created by the Initial Developer are Copyright (C) 1998-2000
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Annie Sullivan <annie.sullivan@gmail.com>
#
# 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 *****
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/places/places.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://browser/locale/places/placesPopup.dtd">
<window id="places-popup"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="PlacesPopup.init();"
hidechrome="true"
windowtype="Places:Popup" >
<stringbundleset id="stringbundleset">
<stringbundle id="stringBundle"
src="chrome://browser/locale/places/placesPopup.properties"/>
</stringbundleset>
<script type="application/x-javascript"
src="chrome://browser/content/places/controller.js"/>
<script type="application/x-javascript"
src="chrome://browser/content/places/placesPopup.js"/>
<script type="application/x-javascript"
src="chrome://global/content/nsDragAndDrop.js"/>
<hbox>
<label value="Search:"/>
<textbox flex="1"
id="placesPopupSearch"
type="timed"
timeout="50"
oncommand="PlacesPopup.onSearchTextChanged(event);"/>
</hbox>
<vbox id="placesPopupSearchResults" hidden="true">
<!-- XXX set rows=height of screen -->
<tree id="placesPopupSearchTree" class="placesTree" flex="1" type="places"
ondblclick="PlacesPopup.onLinkDoubleClicked(event);"
hidecolumnpicker="true" context="placesContext"
place="place:&amp;folder=1&amp;group=3&amp;excludeItems=1"
rows="20"
seltype="single">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="placesPopupSearchTreeChildren" view="placesPopupSearchTree" flex="1"/>
</tree>
</vbox>
<vbox id="placesPopupTreeContainer" hidden="true">
<!-- XXX set rows=height of screen -->
<tree id="placesPopupTree" class="placesTree" flex="1" type="places"
ondblclick="PlacesPopup.onLinkDoubleClicked(event);"
hidecolumnpicker="true" context="placesContext"
rows="20"
seltype="single">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="placesPopupTreeChildren" view="placesPopupTree" flex="1"/>
</tree>
<hbox>
<label value="&placespopup.menulist.label;"/>
<menulist flex="1" id="placesPopupView">
<menupopup id="placesPopupViewMenuPopup"
oncommand="PlacesPopup.onPlaceMenuitemSelected(event);"
nosubmenus="true"
type="places"
place="place:&amp;folder=1&amp;group=3&amp;excludeItems=1">
</menupopup>
</menulist>
</hbox>
</vbox>
<hbox>
<button id="placesPopupOrganize"
label="&placespopup.organizebutton.label;"
hidden="true"
oncommand="window.opener.PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_HISTORY);"/>
<spacer flex="1"/>
<button id="placesPopupExpand"
label="&placespopup.expandbutton.label;"
expanded="false"
oncommand="PlacesPopup.onExpandButtonCommand(event);"/>
</hbox>
</window>

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

@ -10,3 +10,5 @@ browser.jar:
* content/browser/places/menu.xml (content/menu.xml)
content/browser/places/tree.xml (content/tree.xml)
* content/browser/places/controller.js (content/controller.js)
* content/browser/places/placesPopup.xul (content/placesPopup.xul)
* content/browser/places/placesPopup.js (content/placesPopup.js)

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

@ -0,0 +1,6 @@
<!ENTITY placespopup.menulist.label
"Showing:">
<!ENTITY placespopup.organizebutton.label
"Organize...">
<!ENTITY placespopup.expandbutton.label
"&gt;&gt;">

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

@ -0,0 +1,2 @@
collapseButtonLabel=<<
expandButtonLabel=>>

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

@ -27,6 +27,8 @@
locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)
locale/browser/places/places.properties (%chrome/browser/places/places.properties)
locale/browser/places/default_places.html (%chrome/browser/places/default_places.html)
locale/browser/places/placesPopup.dtd (%chrome/browser/places/placesPopup.dtd)
locale/browser/places/placesPopup.properties (%chrome/browser/places/placesPopup.properties)
locale/browser/preferences/selectBookmark.dtd (%chrome/browser/preferences/selectBookmark.dtd)
#else
* locale/browser/bookmarks/bookmarks.dtd (%chrome/browser/bookmarks/bookmarks.dtd)