зеркало из https://github.com/mozilla/pjs.git
332495 - grouping by site is not preserved when searching + various other search/sort fixes. r=annie.sullivan@gmail.com, brettw@gmail.com (history pieces)
This commit is contained in:
Родитель
56e0778f65
Коммит
ece247f035
|
@ -1,3 +1,39 @@
|
|||
# ***** 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 Places Organizer Query Builder.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Google Inc.
|
||||
# Portions created by the Initial Developer are Copyright (C) 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 *****
|
||||
|
||||
<vbox id="advancedSearch" collapsed="true">
|
||||
<grid flex="1">
|
||||
<columns>
|
||||
|
|
|
@ -436,9 +436,7 @@ var BookmarkPropertiesPanel = {
|
|||
|
||||
|
||||
/**
|
||||
* This method initializes the folder tree. It currently uses ._load()
|
||||
* because the tree binding doesn't allow for the setting of query options
|
||||
* to suppress non-assignable containers.
|
||||
* This method initializes the folder tree.
|
||||
*/
|
||||
|
||||
_initFolderTree: function BPP__initFolderTree() {
|
||||
|
@ -454,7 +452,7 @@ var BookmarkPropertiesPanel = {
|
|||
options.setGroupingMode([Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER], 1);
|
||||
options.excludeReadOnlyFolders = true;
|
||||
options.excludeQueries = true;
|
||||
this._folderTree._load([query], options);
|
||||
this._folderTree.load([query], options);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,39 @@
|
|||
# ***** 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 Shared Places Commands.
|
||||
#
|
||||
# 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):
|
||||
# Ben Goodger <beng@google.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 *****
|
||||
|
||||
<commandset id="placesCommands"
|
||||
commandupdater="true" events="focus,select,mousedown,click,keypress"
|
||||
oncommandupdate="PlacesController.onCommandUpdate()">
|
||||
|
|
|
@ -1,3 +1,39 @@
|
|||
# ***** 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 Shared Places Context Menu.
|
||||
#
|
||||
# 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):
|
||||
# Ben Goodger <beng@google.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 *****
|
||||
|
||||
<!-- if you make changes to this file you need to rebuild in both browser/base
|
||||
and browser/components/places for the effect to appear in both the toolbar/
|
||||
menu and the places organizer. -->
|
||||
|
|
|
@ -114,81 +114,6 @@ InsertionPoint.prototype.toString = function IP_toString() {
|
|||
return "[object InsertionPoint(folder:" + this.folderId + ",index:" + this.index + ",orientation:" + this.orientation + ")]";
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages grouping options for a particular view type.
|
||||
* @param pref
|
||||
* The preference that stores these grouping options.
|
||||
* @param defaultGroupings
|
||||
* The default groupings to be used for views of this type.
|
||||
* @param serializable
|
||||
* An object bearing a serialize and deserialize method that
|
||||
* read and write the object's string representation from/to
|
||||
* preferences.
|
||||
* @constructor
|
||||
*/
|
||||
function PrefHandler(pref, defaultValue, serializable) {
|
||||
this._pref = pref;
|
||||
this._defaultValue = defaultValue;
|
||||
this._serializable = serializable;
|
||||
|
||||
this._pb =
|
||||
Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch2);
|
||||
this._pb.addObserver(this._pref, this, false);
|
||||
}
|
||||
PrefHandler.prototype = {
|
||||
/**
|
||||
* Clean up when the window is going away to avoid leaks.
|
||||
*/
|
||||
destroy: function PC_PH_destroy() {
|
||||
this._pb.removeObserver(this._pref, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Observes changes to the preferences.
|
||||
* @param subject
|
||||
* @param topic
|
||||
* The preference changed notification
|
||||
* @param data
|
||||
* The preference that changed
|
||||
*/
|
||||
observe: function PC_PH_observe(subject, topic, data) {
|
||||
if (topic == "nsPref:changed" && data == this._pref)
|
||||
this._value = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* The cached value, null if it needs to be rebuilt from preferences.
|
||||
*/
|
||||
_value: null,
|
||||
|
||||
/**
|
||||
* Get the preference value, reading from preferences if necessary.
|
||||
*/
|
||||
get value() {
|
||||
if (!this._value) {
|
||||
if (this._pb.prefHasUserValue(this._pref)) {
|
||||
var valueString = this._pb.getCharPref(this._pref);
|
||||
this._value = this._serializable.deserialize(valueString);
|
||||
}
|
||||
else
|
||||
this._value = this._defaultValue;
|
||||
}
|
||||
return this._value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stores a value in preferences.
|
||||
* @param value
|
||||
* The data to be stored.
|
||||
*/
|
||||
set value(value) {
|
||||
if (value != this._value)
|
||||
this._pb.setCharPref(this._pref, this._serializable.serialize(value));
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
function QI_node(node, iid) {
|
||||
var result = null;
|
||||
try {
|
||||
|
@ -1973,12 +1898,12 @@ var PlacesController = {
|
|||
addData(TYPE_X_MOZ_PLACE_SEPARATOR, psString);
|
||||
if (placeString)
|
||||
addData(TYPE_X_MOZ_PLACE, placeString);
|
||||
if (mozURLString)
|
||||
addData(TYPE_X_MOZ_URL, mozURLString);
|
||||
if (unicodeString)
|
||||
addData(TYPE_UNICODE, unicodeString);
|
||||
if (htmlString)
|
||||
addData(TYPE_HTML, htmlString);
|
||||
if (mozURLString)
|
||||
addData(TYPE_X_MOZ_URL, mozURLString);
|
||||
|
||||
if (pcString || psString || placeString || unicodeString || htmlString ||
|
||||
mozURLString) {
|
||||
|
|
|
@ -1,5 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
# ***** 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 Places Menupopup View.
|
||||
#
|
||||
# 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>
|
||||
# Ben Goodger <beng@google.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 *****
|
||||
|
||||
<bindings id="placesMenuBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <beng@google.com>
|
||||
* 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
|
||||
|
@ -35,9 +36,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const PREF_PLACES_GROUPING_GENERIC = "browser.places.grouping.generic";
|
||||
const PREF_PLACES_GROUPING_BOOKMARK = "browser.places.grouping.bookmark";
|
||||
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
/**
|
||||
|
@ -54,10 +52,11 @@ var PlacesOrganizer = {
|
|||
_places: null,
|
||||
_content: null,
|
||||
|
||||
init: function PP_init() {
|
||||
init: function PO_init() {
|
||||
this._places = document.getElementById("placesList");
|
||||
this._content = document.getElementById("placeContent");
|
||||
|
||||
OptionsFilter.init(Groupers);
|
||||
Groupers.init();
|
||||
|
||||
// Select the specified place in the places list.
|
||||
|
@ -86,15 +85,21 @@ var PlacesOrganizer = {
|
|||
* @param filterString
|
||||
* The text to search for.
|
||||
*/
|
||||
search: function PP_applyFilter(filterString) {
|
||||
search: function PO_search(filterString) {
|
||||
// Do not search for "" since it will match all history. Assume if the user
|
||||
// deleted everything that they want to type something else and don't
|
||||
// update the view.
|
||||
if (filterString == "")
|
||||
return;
|
||||
|
||||
switch (PlacesSearchBox.filterCollection) {
|
||||
case "collection":
|
||||
var folder = this._content.getResult().root.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
|
||||
this._content.applyFilter(filterString, true, folder);
|
||||
var folderId = asFolder(this._content.getResult().root).folderId;
|
||||
this._content.applyFilter(filterString, true, folderId, OptionsFilter);
|
||||
this.setHeaderText(this.HEADER_TYPE_SEARCH, filterString);
|
||||
break;
|
||||
case "all":
|
||||
this._content.filterString = filterString;
|
||||
this._content.applyFilter(filterString, false, 0, OptionsFilter);
|
||||
this.setHeaderText(this.HEADER_TYPE_SEARCH, filterString);
|
||||
break;
|
||||
}
|
||||
|
@ -130,17 +135,18 @@ var PlacesOrganizer = {
|
|||
/**
|
||||
* Called when a place folder is selected in the left pane.
|
||||
*/
|
||||
onPlaceSelected: function PP_onPlaceSelected(event) {
|
||||
onPlaceSelected: function PO_onPlaceSelected() {
|
||||
if (!this._places.hasSelection)
|
||||
return;
|
||||
var node = asQuery(this._places.selectedNode);
|
||||
LOG("NODEURI: " + node.uri);
|
||||
this._content.place = node.uri;
|
||||
|
||||
Groupers.setGroupingOptions();
|
||||
LOG("Node URI: " + node.uri);
|
||||
var queries = node.getQueries({});
|
||||
this._content.load(queries,
|
||||
OptionsFilter.filter(queries, node.queryOptions, null));
|
||||
|
||||
// Make sure the query builder is hidden.
|
||||
PlacesQueryBuilder.hide();
|
||||
PlacesSearchBox.reset();
|
||||
|
||||
this.setHeaderText(this.HEADER_TYPE_SHOWING, node.title);
|
||||
},
|
||||
|
@ -152,7 +158,13 @@ var PlacesOrganizer = {
|
|||
* @param event
|
||||
* The mouse event.
|
||||
*/
|
||||
onTreeClick: function PP_onURLClicked(event) {
|
||||
onTreeClick: function PO_onTreeClicked(event) {
|
||||
// If the user clicked on a tree column header, update the sorting
|
||||
// preferences to reflect their choices.
|
||||
if (event.target.localName == "treecol") {
|
||||
OptionsFilter.update(this._content.getResult());
|
||||
return;
|
||||
}
|
||||
var v = PlacesController.activeView;
|
||||
if (v.hasSingleSelection && event.button == 1) {
|
||||
if (PlacesController.nodeIsURI(v.selectedNode))
|
||||
|
@ -166,22 +178,12 @@ var PlacesOrganizer = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the query array associated with the query currently loaded in
|
||||
* the main places pane.
|
||||
*/
|
||||
getCurrentQueries: function PP_getCurrentQueries() {
|
||||
var result = this._content.getResult();
|
||||
return result.root.QueryInterface(Ci.nsINavHistoryQueryResultNode).getQueries({});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the options associated with the query currently loaded in the
|
||||
* main places pane.
|
||||
*/
|
||||
getCurrentOptions: function PP_getCurrentOptions() {
|
||||
var result = this._content.getResult();
|
||||
return result.root.QueryInterface(Ci.nsINavHistoryQueryResultNode).queryOptions;
|
||||
getCurrentOptions: function PO_getCurrentOptions() {
|
||||
return asQuery(this._content.getResult().root).queryOptions;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -214,7 +216,7 @@ var PlacesSearchBox = {
|
|||
/**
|
||||
* Focus the search box
|
||||
*/
|
||||
focus: function PS_focus() {
|
||||
focus: function PSB_focus() {
|
||||
var searchFilter = document.getElementById("searchFilter");
|
||||
searchFilter.focus();
|
||||
},
|
||||
|
@ -223,7 +225,7 @@ var PlacesSearchBox = {
|
|||
* When the field is activated, if the contents are the gray text, clear
|
||||
* the field, otherwise select the contents.
|
||||
*/
|
||||
onFocus: function PS_onFocus() {
|
||||
onFocus: function PSB_onFocus() {
|
||||
var searchFilter = document.getElementById("searchFilter");
|
||||
var placeBundle = document.getElementById("placeBundle");
|
||||
|
||||
|
@ -240,26 +242,35 @@ var PlacesSearchBox = {
|
|||
* When the field is deactivated, reset the gray text if the value is
|
||||
* empty or has the gray text value.
|
||||
*/
|
||||
onBlur: function PS_onBlur() {
|
||||
onBlur: function PSB_onBlur() {
|
||||
var placeBundle = document.getElementById("placeBundle");
|
||||
var searchDefault = placeBundle.getString("searchDefault");
|
||||
var searchFilter = document.getElementById("searchFilter");
|
||||
|
||||
if (searchFilter.value == searchDefault || !searchFilter.value) {
|
||||
searchFilter.setAttribute("empty", "true");
|
||||
searchFilter.value = searchDefault;
|
||||
}
|
||||
if (searchFilter.value == searchDefault || !searchFilter.value)
|
||||
this.reset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the search box to its default state (showing "Search" grey
|
||||
* text.
|
||||
*/
|
||||
reset: function PSB_reset() {
|
||||
var placeBundle = document.getElementById("placeBundle");
|
||||
var searchDefault = placeBundle.getString("searchDefault");
|
||||
var searchFilter = document.getElementById("searchFilter");
|
||||
searchFilter.setAttribute("empty", "true");
|
||||
searchFilter.value = searchDefault;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set up the gray text in the search bar as the Places View loads.
|
||||
*/
|
||||
init: function PS_init() {
|
||||
init: function PSB_init() {
|
||||
var placeBundle = document.getElementById("placeBundle");
|
||||
var searchDefault = placeBundle.getString("searchDefault");
|
||||
var searchFilter = document.getElementById("searchFilter");
|
||||
searchFilter.value = searchDefault;
|
||||
searchFilter.setAttribute("empty", "true");
|
||||
this.reset();
|
||||
searchFilter.focus();
|
||||
},
|
||||
|
||||
|
@ -351,8 +362,8 @@ var PlacesQueryBuilder = {
|
|||
// Need to collapse the advanced search box.
|
||||
advancedSearch.collapsed = true;
|
||||
|
||||
var matchUI = document.getElementById("titlebarMatch");
|
||||
matchUI.hidden = true;
|
||||
var titleDeck = document.getElementById("titleDeck");
|
||||
titleDeck.setAttribute("selectedIndex", 0);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -383,10 +394,10 @@ var PlacesQueryBuilder = {
|
|||
|
||||
_updateUIForRowChange: function PQB__updateUIForRowChange() {
|
||||
// Titlebar should show "match any/all" iff there are > 1 queries visible.
|
||||
var matchUI = document.getElementById("titlebarMatch");
|
||||
matchUI.hidden = (this._numRows <= 1);
|
||||
var titleDeck = document.getElementById("titleDeck");
|
||||
titleDeck.setAttribute("selectedIndex", (this._numRows <= 1) ? 0 : 1);
|
||||
const asType = PlacesOrganizer.HEADER_TYPE_ADVANCED_SEARCH;
|
||||
PlacesOrganizer.setHeaderText(asType, this._numRows <= 1 ? "" : ",");
|
||||
PlacesOrganizer.setHeaderText(asType, "");
|
||||
|
||||
// Update the "can add more criteria" command to make sure various +
|
||||
// buttons are disabled.
|
||||
|
@ -740,7 +751,8 @@ var PlacesQueryBuilder = {
|
|||
options.resultType = options.RESULT_TYPE_URI;
|
||||
|
||||
// XXXben - find some public way of doing this!
|
||||
PlacesOrganizer._content._load(queries, options);
|
||||
PlacesOrganizer._content.load(queries,
|
||||
OptionsFilter.filter(queries, options, null));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -987,8 +999,110 @@ var ViewMenu = {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages options for a particular view type.
|
||||
* @param pref
|
||||
* The preference that stores these options.
|
||||
* @param defaultValue
|
||||
* The default value to be used for views of this type.
|
||||
* @param serializable
|
||||
* An object bearing a serialize and deserialize method that
|
||||
* read and write the object's string representation from/to
|
||||
* preferences.
|
||||
* @constructor
|
||||
*/
|
||||
function PrefHandler(pref, defaultValue, serializable) {
|
||||
this._pref = pref;
|
||||
this._defaultValue = defaultValue;
|
||||
this._serializable = serializable;
|
||||
|
||||
this._pb =
|
||||
Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch2);
|
||||
this._pb.addObserver(this._pref, this, false);
|
||||
}
|
||||
PrefHandler.prototype = {
|
||||
/**
|
||||
* Clean up when the window is going away to avoid leaks.
|
||||
*/
|
||||
destroy: function PC_PH_destroy() {
|
||||
this._pb.removeObserver(this._pref, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Observes changes to the preferences.
|
||||
* @param subject
|
||||
* @param topic
|
||||
* The preference changed notification
|
||||
* @param data
|
||||
* The preference that changed
|
||||
*/
|
||||
observe: function PC_PH_observe(subject, topic, data) {
|
||||
if (topic == "nsPref:changed" && data == this._pref)
|
||||
this._value = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* The cached value, null if it needs to be rebuilt from preferences.
|
||||
*/
|
||||
_value: null,
|
||||
|
||||
/**
|
||||
* Get the preference value, reading from preferences if necessary.
|
||||
*/
|
||||
get value() {
|
||||
if (!this._value) {
|
||||
if (this._pb.prefHasUserValue(this._pref)) {
|
||||
var valueString = this._pb.getCharPref(this._pref);
|
||||
this._value = this._serializable.deserialize(valueString);
|
||||
}
|
||||
else
|
||||
this._value = this._defaultValue;
|
||||
}
|
||||
return this._value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stores a value in preferences.
|
||||
* @param value
|
||||
* The data to be stored.
|
||||
*/
|
||||
set value(value) {
|
||||
if (value != this._value) {
|
||||
this._pb.setCharPref(this._pref, this._serializable.serialize(value));
|
||||
var ps = this._pb.QueryInterface(Ci.nsIPrefService);
|
||||
ps.savePrefFile(null);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A "Configuration" set for a class of history query results. Some results
|
||||
* will require that the grouping UI be labeled differently from the standard
|
||||
* so this object is provided to allow those results to configure the UI when
|
||||
* they are displayed.
|
||||
* @param substr
|
||||
* A prefix substring of an annotation that the result's query
|
||||
* matches.
|
||||
* @param onLabel
|
||||
* The label for the "Grouping On" command
|
||||
* @param onAccesskey
|
||||
* The accesskey for the "Grouping On" command
|
||||
* @param offLabel
|
||||
* The label for the "Grouping Off" command
|
||||
* @param offAccesskey
|
||||
* The accesskey for the "Grouping Off" command
|
||||
* @param onOncommand
|
||||
* The "oncommand" attribute of the "Grouping On" command
|
||||
* @param offOncommand
|
||||
* The "oncommand" attribute of the "Grouping Off" command
|
||||
* @param disabled
|
||||
* Whether or not grouping is disabled for results that match this
|
||||
* config.
|
||||
*/
|
||||
function GroupingConfig(substr, onLabel, onAccesskey, offLabel, offAccesskey,
|
||||
onOncommand, offOncommand) {
|
||||
onOncommand, offOncommand, disabled) {
|
||||
this.substr = substr;
|
||||
this.onLabel = onLabel;
|
||||
this.onAccesskey = onAccesskey;
|
||||
|
@ -996,6 +1110,7 @@ function GroupingConfig(substr, onLabel, onAccesskey, offLabel, offAccesskey,
|
|||
this.offAccesskey = offAccesskey;
|
||||
this.onOncommand = onOncommand;
|
||||
this.offOncommand = offOncommand;
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1016,28 +1131,60 @@ var Groupers = {
|
|||
placeBundle.getString("defaultGroupOffLabel"),
|
||||
placeBundle.getString("defaultGroupOffAccesskey"),
|
||||
"Groupers.groupBySite()",
|
||||
"Groupers.groupByPage()");
|
||||
"Groupers.groupByPage()", false);
|
||||
var subscriptionConfig =
|
||||
new GroupingConfig("livemark/", placeBundle.getString("livemarkGroupOnLabel"),
|
||||
placeBundle.getString("livemarkGroupOnAccesskey"),
|
||||
placeBundle.getString("livemarkGroupOffLabel"),
|
||||
placeBundle.getString("livemarkGroupOffAccesskey"),
|
||||
"Groupers.groupByFeed()",
|
||||
"Groupers.groupByPost()");
|
||||
"Groupers.groupByPost()", false);
|
||||
this.annotationGroupers.push(subscriptionConfig);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the grouping broadcasters for the given result.
|
||||
* Get the most appropriate GroupingConfig for the set of queries that are
|
||||
* about to be executed.
|
||||
* @param queries
|
||||
* An array of queries that are about to be executed.
|
||||
* @param handler
|
||||
* Optionally specify which handler to use to filter the options.
|
||||
* If null, the default handler for the queries will be used.
|
||||
*/
|
||||
setGroupingOptions: function G_setGroupingOptions() {
|
||||
var result = PlacesOrganizer._content.getResult();
|
||||
var query = asQuery(result.root);
|
||||
var groupingsCountRef = { };
|
||||
query.queryOptions.getGroupingMode(groupingsCountRef);
|
||||
|
||||
var node = asQuery(result.root);
|
||||
_getConfig: function G__getConfig(queries, handler) {
|
||||
if (!handler)
|
||||
handler = OptionsFilter.getHandler(queries);
|
||||
|
||||
// If the queries will generate a bookmarks folder, there is no "grouper
|
||||
// config" since all of the grouping UI should be hidden (there is only one
|
||||
// grouping mode - group by folder).
|
||||
if (handler == OptionsFilter.bookmarksHandler)
|
||||
return null;
|
||||
|
||||
var query = queries[0];
|
||||
for (var i = 0; i < this.annotationGroupers.length; ++i) {
|
||||
var config = this.annotationGroupers[i];
|
||||
if (query.annotation.substr(0, config.substr.length) == config.substr &&
|
||||
!config.disabled)
|
||||
return config;
|
||||
}
|
||||
|
||||
return this.defaultGrouper;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the grouping broadcasters for the given result.
|
||||
* @param queries
|
||||
* An array of queries that are going to be executed.
|
||||
* @param options
|
||||
* The options that are being used to generate the forthcoming
|
||||
* result.
|
||||
* @param handler
|
||||
* Optionally specify which handler to use to filter the options.
|
||||
* If null, the default handler for the queries will be used.
|
||||
* @param
|
||||
*/
|
||||
updateGroupingUI: function G_updateGroupingUI(queries, options, handler) {
|
||||
var separator = document.getElementById("placesBC_grouping:separator");
|
||||
var groupOff = document.getElementById("placesBC_grouping:off");
|
||||
var groupOn = document.getElementById("placesBC_grouping:on");
|
||||
|
@ -1047,44 +1194,33 @@ var Groupers = {
|
|||
|
||||
// Walk the list of registered annotationGroupers, determining what are
|
||||
// available and notifying the broadcaster
|
||||
var disabled = false;
|
||||
var query = node.getQueries({})[0];
|
||||
var config = null;
|
||||
for (var i = 0; i < this.annotationGroupers.length; ++i) {
|
||||
config = this.annotationGroupers[i];
|
||||
var substr = config.substr;
|
||||
if (query.annotation.substr(0, substr.length) == substr) {
|
||||
if (config.disabled)
|
||||
disabled = true;
|
||||
break;
|
||||
}
|
||||
config = null;
|
||||
}
|
||||
|
||||
if (disabled || PlacesController.nodeIsFolder(node)) {
|
||||
var config = this._getConfig(queries, handler);
|
||||
if (!config) {
|
||||
// Generic Bookmarks Folder or custom container that disables grouping.
|
||||
separator.setAttribute("hidden", "true");
|
||||
groupOff.setAttribute("hidden", "true");
|
||||
groupOn.setAttribute("hidden", "true");
|
||||
}
|
||||
else {
|
||||
if (!config)
|
||||
config = this.defaultGrouper;
|
||||
groupOn.setAttribute("label", config.onLabel);
|
||||
groupOn.setAttribute("accesskey", config.onAccesskey);
|
||||
groupOn.setAttribute("oncommand", config.onOncommand);
|
||||
groupOff.setAttribute("label", config.offLabel);
|
||||
groupOff.setAttribute("accesskey", config.offAccesskey);
|
||||
groupOff.setAttribute("oncommand", config.offOncommand);
|
||||
// Update the checked state of the UI
|
||||
this.updateBroadcasters(groupingsCountRef.value > 0);
|
||||
// Update the checked state of the UI:
|
||||
// Grouping UI is "enabled" if there is at least one set of grouping
|
||||
// options.
|
||||
var groupingsCountRef = { };
|
||||
options.getGroupingMode(groupingsCountRef);
|
||||
this._updateBroadcasters(groupingsCountRef.value > 0);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the visual state of UI that controls grouping.
|
||||
*/
|
||||
updateBroadcasters: function PO_updateGroupingBroadcasters(on) {
|
||||
_updateBroadcasters: function G__updateGroupingBroadcasters(on) {
|
||||
var groupingOn = document.getElementById("placesBC_grouping:on");
|
||||
var groupingOff = document.getElementById("placesBC_grouping:off");
|
||||
if (on) {
|
||||
|
@ -1100,37 +1236,39 @@ var Groupers = {
|
|||
/**
|
||||
* Shows visited pages grouped by site.
|
||||
*/
|
||||
groupBySite: function PO_groupBySite() {
|
||||
groupBySite: function G_groupBySite() {
|
||||
var query = asQuery(PlacesOrganizer._content.getResult().root);
|
||||
var queries = query.getQueries({ });
|
||||
var options = query.queryOptions;
|
||||
var newOptions = options.clone();
|
||||
const NHQO = Ci.nsINavHistoryQueryOptions;
|
||||
newOptions.setGroupingMode([NHQO.GROUP_BY_DOMAIN], 1);
|
||||
PlacesOrganizer._content._load(queries, newOptions);
|
||||
|
||||
this.updateBroadcasters(true);
|
||||
var content = PlacesOrganizer._content;
|
||||
content.load(queries, newOptions);
|
||||
this._updateBroadcasters(true);
|
||||
OptionsFilter.update(content.getResult());
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows visited pages without grouping.
|
||||
*/
|
||||
groupByPage: function PO_groupByPage() {
|
||||
groupByPage: function G_groupByPage() {
|
||||
var query = asQuery(PlacesOrganizer._content.getResult().root);
|
||||
var queries = query.getQueries({ });
|
||||
var options = query.queryOptions;
|
||||
var newOptions = options.clone();
|
||||
newOptions.setGroupingMode([], 0);
|
||||
PlacesOrganizer._content._load(queries, newOptions);
|
||||
|
||||
this.updateBroadcasters(false);
|
||||
var content = PlacesOrganizer._content;
|
||||
content.load(queries, newOptions);
|
||||
this._updateBroadcasters(false);
|
||||
OptionsFilter.update(content.getResult());
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows all subscribed feeds (Live Bookmarks) grouped under their parent
|
||||
* feed.
|
||||
*/
|
||||
groupByFeed: function PP_groupByFeed() {
|
||||
groupByFeed: function G_groupByFeed() {
|
||||
var groupings = [Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER];
|
||||
var sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
|
||||
PlacesController.groupByAnnotation("livemark/feedURI", [], 0);
|
||||
|
@ -1139,13 +1277,11 @@ var Groupers = {
|
|||
/**
|
||||
* Shows all subscribed feed (Live Bookmarks) content in a flat list
|
||||
*/
|
||||
groupByPost: function PP_groupByPost() {
|
||||
groupByPost: function G_groupByPost() {
|
||||
var groupings = [Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER];
|
||||
var sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING;
|
||||
PlacesController.groupByAnnotation("livemark/bookmarkFeedURI", [], 0);
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#include ../../../../toolkit/content/debug.js
|
||||
|
|
|
@ -1,5 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
# ***** 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 Places Organizer.
|
||||
#
|
||||
# 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):
|
||||
# Ben Goodger <beng@google.com>
|
||||
# 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/content/places/places.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/places/organizer.css"?>
|
||||
|
||||
|
@ -19,6 +56,8 @@
|
|||
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://browser/content/places/controller.js"/>
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://browser/content/places/treeHelpers.js"/>
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://browser/content/places/places.js"/>
|
||||
<!-- ew. -->
|
||||
|
@ -65,6 +104,11 @@
|
|||
<!-- Instantiation Keys -->
|
||||
<key id="placesKey_close" key="&cmd.close.key;" modifiers="accel"
|
||||
oncommand="close();"/>
|
||||
|
||||
<key id="placesKey_edit:undo" key="&cmd.edit_undo.key;" modifiers="accel"
|
||||
command="cmd_undo"/>
|
||||
<key id="placesKey_edit:redo" key="&cmd.edit_redo.key;" modifiers="accel"
|
||||
command="cmd_redo"/>
|
||||
|
||||
<!-- Command Keys -->
|
||||
<key id="placesKey_find" command="placesCmd_find" key="&cmd.find.key;" modifiers="accel"/>
|
||||
|
@ -103,29 +147,36 @@
|
|||
<menuitem id="properties" command="placesCmd_show:info"/>
|
||||
#endif
|
||||
<menuseparator/>
|
||||
<menuitem id="fileClose"
|
||||
<menuitem id="fileClose" key="placesKey_close"
|
||||
label="&file.close.label;" accesskey="&file.close.accesskey;"
|
||||
oncommand="close();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="editMenu" label="&edit.label;" accesskey="&edit.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem id="editUndo" command="cmd_undo"/>
|
||||
<menuitem id="editRedo" command="cmd_redo"/>
|
||||
<menuitem id="editUndo" command="cmd_undo" key="placesKey_edit:undo"/>
|
||||
<menuitem id="editRedo" command="cmd_redo" key="placesKey_edit:redo"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="editCut" command="placesCmd_edit:cut"/>
|
||||
<menuitem id="editCopy" command="placesCmd_edit:copy"/>
|
||||
<menuitem id="editPaste" command="placesCmd_edit:paste"/>
|
||||
<menuitem id="editDelete" command="placesCmd_edit:delete"/>
|
||||
<menuitem id="editCut" command="placesCmd_edit:cut"
|
||||
key="placesKey_edit:cut"/>
|
||||
<menuitem id="editCopy" command="placesCmd_edit:copy"
|
||||
key="placesKey_edit:copy"/>
|
||||
<menuitem id="editPaste" command="placesCmd_edit:paste"
|
||||
key="placesKey_edit:paste"/>
|
||||
<menuitem id="editDelete" command="placesCmd_edit:delete"
|
||||
key="placesKey_edit:delete"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="editSelectAll" command="placesCmd_select:all"/>
|
||||
<menuitem id="editSelectAll" command="placesCmd_select:all"
|
||||
key="placesKey_select:all"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="editSortByName" command="placesCmd_sortby:name"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="editFind" command="placesCmd_find"/>
|
||||
<menuitem id="editFind" command="placesCmd_find"
|
||||
key="placesKey_find"/>
|
||||
#ifdef XP_MACOSX
|
||||
<menuseparator/>
|
||||
<menuitem id="properties" command="placesCmd_show:info"/>
|
||||
<menuitem id="properties" command="placesCmd_show:info"
|
||||
key="placesKey_show:info"/>
|
||||
#endif
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
@ -133,7 +184,8 @@
|
|||
onpopupshowing="ViewMenu.populate(event);"
|
||||
oncommand="ViewMenu.setSortColumn(event.target, null);">
|
||||
<menupopup>
|
||||
<menuitem id="viewReload" command="placesCmd_reload"/>
|
||||
<menuitem id="viewReload" command="placesCmd_reload"
|
||||
key="placesKey_reload"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewToolbar" type="checkbox"
|
||||
label="&view.toolbar.label;" accesskey="&view.toolbar.accesskey;"/>
|
||||
|
@ -213,19 +265,20 @@
|
|||
<vbox flex="1">
|
||||
<hbox id="titlebar" align="center">
|
||||
<label id="showingPrefix"/>
|
||||
<label id="contentTitle"/>
|
||||
<hbox align="center" id="titlebarMatch" hidden="true">
|
||||
<label value="&advancedSearch.match.label;"/>
|
||||
<menulist id="advancedSearchType"
|
||||
oncommand="PlacesQueryBuilder.doSearch();">
|
||||
<menupopup>
|
||||
<menuitem value="and" label="&advancedSearch.all.label;"/>
|
||||
<menuitem value="or" label="&advancedSearch.any.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<label value="&advancedSearch.rules.label;"/>
|
||||
</hbox>
|
||||
<spacer flex="1"/>
|
||||
<deck id="titleDeck" flex="1">
|
||||
<label id="contentTitle" flex="1" crop="right"/>
|
||||
<hbox align="center" id="titlebarMatch" hidden="true">
|
||||
<label value="&advancedSearch.match.label;"/>
|
||||
<menulist id="advancedSearchType"
|
||||
oncommand="PlacesQueryBuilder.doSearch();">
|
||||
<menupopup>
|
||||
<menuitem value="and" label="&advancedSearch.all.label;"/>
|
||||
<menuitem value="or" label="&advancedSearch.any.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<label value="&advancedSearch.rules.label;"/>
|
||||
</hbox>
|
||||
</deck>
|
||||
<hbox id="searchModifiers" hidden="true" align="center">
|
||||
<button id="saveSearch" class="small"
|
||||
label="&saveSearch.label;" accesskey="&saveSearch.accesskey;"
|
||||
|
|
|
@ -1,5 +1,43 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
# ***** 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 Places Toolbar View.
|
||||
#
|
||||
# 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>
|
||||
# Ben Goodger <beng@google.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 *****
|
||||
|
||||
|
||||
<!DOCTYPE bindings [
|
||||
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
|
||||
%browserDTD;
|
||||
|
|
|
@ -1,5 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
# ***** 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 Places Tree View.
|
||||
#
|
||||
# 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):
|
||||
# Ben Goodger <beng@google.com>
|
||||
# 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 *****
|
||||
|
||||
<bindings id="placesTreeBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
|
@ -47,44 +84,45 @@
|
|||
return options;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="filterString">
|
||||
<getter><![CDATA[
|
||||
var queries = this.getResult().getQueries({ });
|
||||
if (queries[i].hasSearchTerms)
|
||||
return queries[i].searchTerms;
|
||||
return null;
|
||||
]]></getter>
|
||||
<setter><![CDATA[
|
||||
var query = this.history.getNewQuery();
|
||||
query.searchTerms = val;
|
||||
|
||||
this._load([query], this.getBestOptions());
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
|
||||
<method name="applyFilter">
|
||||
<parameter name="filterString"/>
|
||||
<parameter name="onlyBookmarks"/>
|
||||
<parameter name="folderRestrict"/>
|
||||
<parameter name="optionsFilter"/>
|
||||
<body><![CDATA[
|
||||
// preserve grouping
|
||||
var options = this.getResult().queryOptions;
|
||||
if (!options)
|
||||
options = this.history.getNewQueryOptions();
|
||||
var queryNode = asQuery(this.getResult().root);
|
||||
var options = queryNode.queryOptions.clone();
|
||||
if (optionsFilter)
|
||||
options = optionsFilter.filter(queryNode.getQueries({}), options,
|
||||
optionsFilter.historyHandler);
|
||||
|
||||
var query = this.history.getNewQuery();
|
||||
query.searchTerms = filterString;
|
||||
query.onlyBookmarked = onlyBookmarks;
|
||||
//if (onlyBookmarks)
|
||||
// query.setFolders(folderRestrict, folderRestrict.length);
|
||||
this._load([query], this.getBestOptions());
|
||||
|
||||
// If we're searching over everything, or this is not an exclusively
|
||||
// bookmarks search, we need to make sure that we remove "group by
|
||||
// folder" from the options list, because otherwise we will end up
|
||||
// with _no_ results if the user searches while a bookmarks folder
|
||||
// is selected, since the options for the current view say group by
|
||||
// folder and none of the results will match!
|
||||
if (!onlyBookmarks) {
|
||||
var groupings = options.getGroupingMode({});
|
||||
function isFolderGrouping(grouping, index, ary) {
|
||||
return grouping != Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER;
|
||||
}
|
||||
var folderGroupings = groupings.filter(isFolderGrouping);
|
||||
options.setGroupingMode(folderGroupings, folderGroupings.length);
|
||||
}
|
||||
if (onlyBookmarks)
|
||||
query.setFolders(folderRestrict, folderRestrict.length);
|
||||
this.load([query], options);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- XXXben I would like to remove this method from the "public" interface -->
|
||||
<method name="_load">
|
||||
<method name="load">
|
||||
<parameter name="queries"/>
|
||||
<parameter name="options"/>
|
||||
<body><![CDATA[
|
||||
|
@ -222,7 +260,7 @@
|
|||
if (!optionsRef.value)
|
||||
optionsRef.value = this.history.getNewQueryOptions();
|
||||
|
||||
this._load(queriesRef.value, optionsRef.value);
|
||||
this.load(queriesRef.value, optionsRef.value);
|
||||
|
||||
return val;
|
||||
]]></setter>
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
//* -*- 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 the Places Tree View Utilities.
|
||||
*
|
||||
* 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):
|
||||
* Ben Goodger <beng@google.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 ***** */
|
||||
|
||||
// The preferences where the OptionsFilter stores user settings for different
|
||||
// view types:
|
||||
const PREF_PLACES_ORGANIZER_OPTIONS_HISTORY =
|
||||
"browser.places.organizer.options.history";
|
||||
const PREF_PLACES_ORGANIZER_OPTIONS_BOOKMARKS =
|
||||
"browser.places.organizer.options.bookmarks";
|
||||
const PREF_PLACES_ORGANIZER_OPTIONS_SUBSCRIPTIONS =
|
||||
"browser.places.organizer.options.subscriptions";
|
||||
|
||||
/**
|
||||
* OptionsFilter is an object that handles persistence of certain
|
||||
* user-controlled options wrt. the content view. For instance, if the user
|
||||
* sorts a view of a certain type, the sort state should be persisted across
|
||||
* all instances of that view type, and across browser sessions. Same story for
|
||||
* grouping.
|
||||
*
|
||||
* The OptionsFilter is called by any function that is going to load a new
|
||||
* result in the content view, by calling |filter| on the options that are to
|
||||
* be passed into load():
|
||||
*
|
||||
* this._content.load(queries, OptionsFilter.filter(queries, options, null));
|
||||
*
|
||||
* The OptionsFilter overrides any options specified by the caller with the
|
||||
* last user values.
|
||||
*
|
||||
* When an event happens in the user interface that causes the view to change
|
||||
* outside the control of the OptionsFilter, e.g. the user clicks the sort
|
||||
* headers to sort a column, the caller can update the state held by the
|
||||
* OptionsFilter by calling update:
|
||||
*
|
||||
* OptionsFilter.update(this._content.getResult());
|
||||
*
|
||||
*/
|
||||
var OptionsFilter = {
|
||||
/**
|
||||
* Deserializes query options from a place: URI stored in preferences
|
||||
* @param string
|
||||
* The serialized options in place: URI format from preferences
|
||||
* @returns A nsINavHistoryQueryOptions object representing the last saved
|
||||
* options
|
||||
*/
|
||||
deserialize: function OF_deserialize(string) {
|
||||
var optionsRef = { };
|
||||
PlacesController.history.queryStringToQueries(string, {}, {}, optionsRef);
|
||||
return optionsRef.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Serializes query options to a place: URI stored in preferences
|
||||
* @param options
|
||||
* A nsINavHistoryQueryOptions object representing the options to
|
||||
* serialize.
|
||||
* @returns A place: URI string that can be stored in preferences.
|
||||
*/
|
||||
serialize: function OF_serialize(options) {
|
||||
var query = PlacesController.history.getNewQuery();
|
||||
return PlacesController.history.queriesToQueryString([query], 1, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler for History and other generic queries
|
||||
*/
|
||||
historyHandler: null,
|
||||
|
||||
/**
|
||||
* Handler for Bookmark Folders
|
||||
*/
|
||||
bookmarksHandler: null,
|
||||
|
||||
/**
|
||||
* Substring->PrefHandler hash for results that show content with specific
|
||||
* annotations to register custom handlers under.
|
||||
*/
|
||||
overrideHandlers: { },
|
||||
|
||||
/**
|
||||
* A grouping utility object that is notified when the view is filtered.
|
||||
*/
|
||||
_grouper: null,
|
||||
|
||||
/**
|
||||
* Initializes the OptionsFilter, sets up the default handlers.
|
||||
*/
|
||||
init: function OF_init(grouper) {
|
||||
this._grouper = grouper;
|
||||
|
||||
var history = PlacesController.history;
|
||||
const NHQO = Ci.nsINavHistoryQueryOptions;
|
||||
|
||||
var defaultHistoryOptions = history.getNewQueryOptions();
|
||||
defaultHistoryOptions.sortingMode = NHQO.SORT_BY_DATE_DESCENDING;
|
||||
var defaultBookmarksOptions = history.getNewQueryOptions();
|
||||
defaultBookmarksOptions.setGroupingMode([NHQO.GROUP_BY_FOLDER], 1);
|
||||
var defaultSubscriptionsOptions = history.getNewQueryOptions();
|
||||
defaultSubscriptionsOptions.setGroupingMode([NHQO.GROUP_BY_FOLDER], 1);
|
||||
|
||||
this.historyHandler =
|
||||
new PrefHandler(PREF_PLACES_ORGANIZER_OPTIONS_HISTORY,
|
||||
defaultHistoryOptions, this);
|
||||
this.bookmarksHandler =
|
||||
new PrefHandler(PREF_PLACES_ORGANIZER_OPTIONS_BOOKMARKS,
|
||||
defaultBookmarksOptions, this);
|
||||
this.overrideHandlers["livemark/"] =
|
||||
new PrefHandler(PREF_PLACES_ORGANIZER_OPTIONS_SUBSCRIPTIONS,
|
||||
defaultSubscriptionsOptions, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the handler best able to store options for a set of queries that are
|
||||
* about to be executed.
|
||||
* @param queries
|
||||
* An array of queries that are about to be executed
|
||||
* @returns A PrefHandler object that is the best handler to load/save options
|
||||
* for the given queries.
|
||||
*/
|
||||
getHandler: function OF_getHandler(queries) {
|
||||
var countRef = { };
|
||||
queries[0].getFolders(countRef);
|
||||
if (countRef.value > 0 || queries[0].onlyBookmarks)
|
||||
return this.bookmarksHandler;
|
||||
for (var substr in this.overrideHandlers) {
|
||||
if (queries[0].annotation.substr(0, substr.length) == substr)
|
||||
return this.overrideHandlers[substr];
|
||||
}
|
||||
return this.historyHandler;
|
||||
},
|
||||
|
||||
/**
|
||||
* Filters a set of queryOptions according to the rules for the type of
|
||||
* result that will be generated.
|
||||
* @param queries
|
||||
* The set of queries that is about to be executed.
|
||||
* @param options
|
||||
* The set of query options for the queries that need to be
|
||||
* filtered.
|
||||
* @param handler
|
||||
* Optionally specify which handler to use to filter the options.
|
||||
* If null, the default handler for the queries will be used.
|
||||
*/
|
||||
filter: function OF_filter(queries, options, handler) {
|
||||
if (!handler)
|
||||
handler = this.getHandler(queries);
|
||||
var overrideOptions = handler.value;
|
||||
|
||||
var overrideGroupings = overrideOptions.getGroupingMode({});
|
||||
options.setGroupingMode(overrideGroupings, overrideGroupings.length);
|
||||
|
||||
options.sortingMode = overrideOptions.sortingMode;
|
||||
options.resultType = overrideOptions.resultType;
|
||||
options.excludeItems = overrideOptions.excludeItems;
|
||||
options.excludeQueries = overrideOptions.excludeQueries;
|
||||
options.excludeReadOnlyFolders = overrideOptions.excludeReadOnlyFolders;
|
||||
options.expandQueries = overrideOptions.expandQueries;
|
||||
options.forceOriginalTitle = overrideOptions.forceOriginalTitle;
|
||||
options.includeHidden = overrideOptions.includeHidden;
|
||||
options.maxResults = overrideOptions.maxResults;
|
||||
|
||||
this._grouper.updateGroupingUI(queries, options, handler);
|
||||
|
||||
return options;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates an override state with preferences so that it is shared across
|
||||
* views/sessions.
|
||||
* @param result
|
||||
* The nsINavHistoryResult to update options for
|
||||
*/
|
||||
update: function OF_update(result) {
|
||||
var queryNode = asQuery(result.root);
|
||||
var queries = queryNode.getQueries({});
|
||||
|
||||
var options = queryNode.queryOptions.clone();
|
||||
options.sortingMode = result.sortingMode;
|
||||
this.getHandler(queries).value = options;
|
||||
},
|
||||
};
|
|
@ -4,11 +4,12 @@ browser.jar:
|
|||
content/browser/places/places.xml (content/places.xml)
|
||||
content/browser/places/places.css (content/places.css)
|
||||
content/browser/places/organizer.css (content/organizer.css)
|
||||
content/browser/places/bookmarkProperties.xul (content/bookmarkProperties.xul)
|
||||
* content/browser/places/bookmarkProperties.xul (content/bookmarkProperties.xul)
|
||||
* content/browser/places/bookmarkProperties.js (content/bookmarkProperties.js)
|
||||
* content/browser/places/toolbar.xml (content/toolbar.xml)
|
||||
* content/browser/places/menu.xml (content/menu.xml)
|
||||
content/browser/places/tree.xml (content/tree.xml)
|
||||
* content/browser/places/tree.xml (content/tree.xml)
|
||||
* content/browser/places/controller.js (content/controller.js)
|
||||
* content/browser/places/treeHelpers.js (content/treeHelpers.js)
|
||||
* content/browser/places/placesPopup.xul (content/placesPopup.xul)
|
||||
* content/browser/places/placesPopup.js (content/placesPopup.js)
|
||||
* content/browser/places/placesPopup.js (content/placesPopup.js)
|
||||
|
|
|
@ -665,7 +665,7 @@ interface nsINavHistoryResult : nsISupports
|
|||
* options for this result, so that re-using the current options/queries will
|
||||
* always give you the current view.
|
||||
*/
|
||||
void sortAll(in PRUint32 aSortingMode);
|
||||
attribute PRUint32 sortingMode;
|
||||
|
||||
/**
|
||||
* The viewer for this result (see comment for the class for how these
|
||||
|
|
|
@ -576,7 +576,7 @@ nsNavHistoryContainerResultNode::GetSortingComparator(PRUint32 aSortType)
|
|||
|
||||
// nsNavHistoryContainerResultNode::RecursiveSort
|
||||
//
|
||||
// This is used by Result::SortAll and QueryResultNode::FillChildren to sort
|
||||
// This is used by Result::SetSortingMode and QueryResultNode::FillChildren to sort
|
||||
// the child list.
|
||||
//
|
||||
// This does NOT update any visibility or tree information. The caller will
|
||||
|
@ -2572,7 +2572,11 @@ NS_IMETHODIMP
|
|||
nsNavHistoryFolderResultNode::GetQueryOptions(
|
||||
nsINavHistoryQueryOptions** aQueryOptions)
|
||||
{
|
||||
return mOptions->Clone(aQueryOptions);
|
||||
NS_ASSERTION(mOptions, "Options invalid");
|
||||
|
||||
*aQueryOptions = mOptions;
|
||||
NS_ADDREF(*aQueryOptions);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3374,11 +3378,19 @@ nsNavHistoryResult::BookmarkObserversForId(PRInt64 aFolderId, PRBool aCreate)
|
|||
return list;
|
||||
}
|
||||
|
||||
|
||||
// nsNavHistoryResult::SortAll (nsINavHistoryResult)
|
||||
// nsNavHistoryResult::GetSortingMode (nsINavHistoryResult)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistoryResult::SortAll(PRUint32 aSortingMode)
|
||||
nsNavHistoryResult::GetSortingMode(PRUint32* aSortingMode)
|
||||
{
|
||||
*aSortingMode = mSortingMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsNavHistoryResult::SetSortingMode (nsINavHistoryResult)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistoryResult::SetSortingMode(PRUint32 aSortingMode)
|
||||
{
|
||||
if (aSortingMode > nsINavHistoryQueryOptions::SORT_BY_VISITCOUNT_DESCENDING)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -3387,6 +3399,7 @@ nsNavHistoryResult::SortAll(PRUint32 aSortingMode)
|
|||
|
||||
// keep everything in sync
|
||||
NS_ASSERTION(mOptions, "Options should always be present for a root query");
|
||||
|
||||
mSortingMode = aSortingMode;
|
||||
|
||||
// actually do sorting
|
||||
|
@ -5107,7 +5120,7 @@ nsNavHistoryResultTreeViewer::CycleHeader(nsITreeColumn* col)
|
|||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
return mResult->SortAll(newSort);
|
||||
return mResult->SetSortingMode(newSort);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -95,10 +95,14 @@
|
|||
"Undo">
|
||||
<!ENTITY cmd.edit_undo.accesskey
|
||||
"U">
|
||||
<!ENTITY cmd.edit_undo.key
|
||||
"z">
|
||||
<!ENTITY cmd.edit_redo.label
|
||||
"Redo">
|
||||
<!ENTITY cmd.edit_redo.accesskey
|
||||
"R">
|
||||
<!ENTITY cmd.edit_redo.key
|
||||
"y">
|
||||
<!ENTITY cmd.open.label
|
||||
"Open">
|
||||
<!ENTITY cmd.open.accesskey
|
||||
|
@ -174,7 +178,7 @@
|
|||
<!ENTITY col.url.label
|
||||
"Location">
|
||||
<!ENTITY col.lastvisit.label
|
||||
"Last Visit Date">
|
||||
"Visit Date">
|
||||
<!ENTITY col.visitcount.label
|
||||
"Visit Count">
|
||||
<!ENTITY search.label
|
||||
|
|
|
@ -107,6 +107,7 @@ treechildren::-moz-tree-cell-text(title, separator, selected, focus) {
|
|||
#contentTitle {
|
||||
margin: 5px 8px 5px 0px;
|
||||
font-weight: bold;
|
||||
width: 0px;
|
||||
}
|
||||
|
||||
/* Search Bar */
|
||||
|
@ -232,4 +233,3 @@ treechildren::-moz-tree-cell-text(title, separator, selected, focus) {
|
|||
#searchModifiers {
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче