Bug 425851: 'Most Visited', 'Recently Bookmarked', and 'Recent Tags' should be treated as folders, patch by Marco Bonardo <mak77@supereva.it>, r=mano, a=mconnor

This commit is contained in:
gavin%gavinsharp.com 2008-04-28 09:41:18 +00:00
Родитель 93812c3d0b
Коммит e2aa00f693
5 изменённых файлов: 83 добавлений и 114 удалений

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

@ -22,6 +22,7 @@
* Joe Hughes <jhughes@google.com>
* Dietrich Ayala <dietrich@mozilla.com>
* Asaf Romano <mano@mozilla.com>
* Marco Bonardo <mak77@supereva.it>
*
* 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
@ -70,9 +71,9 @@
* - "edit" - for editing a bookmark item or a folder.
* @ type (String). Possible values:
* - "bookmark"
* @ bookmarkId (Integer) - the id of the bookmark item.
* @ itemId (Integer) - the id of the bookmark item.
* - "folder" (also applies to livemarks)
* @ folderId (Integer) - the id of the folder.
* @ itemId (Integer) - the id of the folder.
* @ hiddenRows (Strings array) - optional, list of rows to be hidden
* regardless of the item edited or added by the dialog.
* Possible values:
@ -80,7 +81,7 @@
* - "location"
* - "description"
* - "keyword"
* - "load in sidebar"
* - "loadInSidebar"
* - "feedURI"
* - "siteURI"
* - "folder picker" - hides both the tree and the menu.
@ -115,9 +116,8 @@ var BookmarkPropertiesPanel = {
_action: null,
_itemType: null,
_folderId: null,
_bookmarkId: -1,
_bookmarkURI: null,
_itemId: -1,
_uri: null,
_loadBookmarkInSidebar: false,
_itemTitle: "",
_itemDescription: "",
@ -201,14 +201,14 @@ var BookmarkPropertiesPanel = {
if ("uri" in dialogInfo) {
NS_ASSERT(dialogInfo.uri instanceof Ci.nsIURI,
"uri property should be a uri object");
this._bookmarkURI = dialogInfo.uri;
this._uri = dialogInfo.uri;
}
if (typeof(this._itemTitle) != "string") {
if (this._bookmarkURI) {
if (this._uri) {
this._itemTitle =
this._getURITitleFromHistory(this._bookmarkURI);
this._getURITitleFromHistory(this._uri);
if (!this._itemTitle)
this._itemTitle = this._bookmarkURI.spec;
this._itemTitle = this._uri.spec;
}
else
this._itemTitle = this._strings.getString("newBookmarkDefault");
@ -268,47 +268,45 @@ var BookmarkPropertiesPanel = {
switch (dialogInfo.type) {
case "bookmark":
NS_ASSERT("bookmarkId" in dialogInfo);
NS_ASSERT("itemId" in dialogInfo);
this._action = ACTION_EDIT;
this._itemType = BOOKMARK_ITEM;
this._bookmarkId = dialogInfo.bookmarkId;
this._itemId = dialogInfo.itemId;
this._bookmarkURI = bookmarks.getBookmarkURI(this._bookmarkId);
this._itemTitle = bookmarks.getItemTitle(this._bookmarkId);
this._uri = bookmarks.getBookmarkURI(this._itemId);
this._itemTitle = bookmarks.getItemTitle(this._itemId);
// keyword
this._bookmarkKeyword =
bookmarks.getKeywordForBookmark(this._bookmarkId);
bookmarks.getKeywordForBookmark(this._itemId);
// Load In Sidebar
this._loadBookmarkInSidebar =
annos.itemHasAnnotation(this._bookmarkId, LOAD_IN_SIDEBAR_ANNO);
annos.itemHasAnnotation(this._itemId, LOAD_IN_SIDEBAR_ANNO);
break;
case "folder":
NS_ASSERT("folderId" in dialogInfo);
NS_ASSERT("itemId" in dialogInfo);
this._action = ACTION_EDIT;
this._folderId = dialogInfo.folderId;
this._itemId = dialogInfo.itemId;
const livemarks = PlacesUtils.livemarks;
if (livemarks.isLivemark(this._folderId)) {
if (livemarks.isLivemark(this._itemId)) {
this._itemType = LIVEMARK_CONTAINER;
this._feedURI = livemarks.getFeedURI(this._folderId);
this._siteURI = livemarks.getSiteURI(this._folderId);
this._feedURI = livemarks.getFeedURI(this._itemId);
this._siteURI = livemarks.getSiteURI(this._itemId);
}
else
this._itemType = BOOKMARK_FOLDER;
this._itemTitle = bookmarks.getItemTitle(this._folderId);
this._itemTitle = bookmarks.getItemTitle(this._itemId);
break;
}
// Description
// XXXmano: unify the two id fields
var itemId = dialogInfo.type == "bookmark" ? this._bookmarkId : this._folderId;
if (annos.itemHasAnnotation(itemId, DESCRIPTION_ANNO)) {
this._itemDescription = annos.getItemAnnotation(itemId,
if (annos.itemHasAnnotation(this._itemId, DESCRIPTION_ANNO)) {
this._itemDescription = annos.getItemAnnotation(this._itemId,
DESCRIPTION_ANNO);
}
}
@ -339,7 +337,6 @@ var BookmarkPropertiesPanel = {
onDialogLoad: function BPP_onDialogLoad() {
this._determineItemInfo();
this._populateProperties();
this._forceHideRows();
this.validateChanges();
this._folderMenuList = this._element("folderMenuList");
@ -453,30 +450,35 @@ var BookmarkPropertiesPanel = {
},
/**
* Hides fields which were explicitly set hidden by the the dialog opener
* (see documentation at the top of this file).
* Show or hides fields based on item type.
*/
_forceHideRows: function BPP__forceHideRows() {
var hiddenRows = window.arguments[0].hiddenRows;
if (!hiddenRows)
return;
_showHideRows: function BPP__showHideRows() {
var hiddenRows = window.arguments[0].hiddenRows || new Array();
if (hiddenRows.indexOf("title") != -1)
this._element("namePicker").hidden = true;
if (hiddenRows.indexOf("location") != -1)
this._element("locationRow").hidden = true;
if (hiddenRows.indexOf("keyword") != -1)
this._element("keywordRow").hidden = true;
if (hiddenRows.indexOf("description")!= -1)
this._element("descriptionRow").hidden = true;
if (hiddenRows.indexOf("folder picker") != -1)
this._element("folderRow").hidden = true;
if (hiddenRows.indexOf("feedURI") != -1)
this._element("livemarkFeedLocationRow").hidden = true;
if (hiddenRows.indexOf("siteURI") != -1)
this._element("livemarkSiteLocationRow").hidden = true;
if (hiddenRows.indexOf("load in sidebar") != -1)
this._element("loadInSidebarCheckbox").hidden = true;
var isBookmark = this._itemType == BOOKMARK_ITEM;
var isLivemark = this._itemType == LIVEMARK_CONTAINER;
var isQuery = false;
if (this._uri)
isQuery = this._uri.schemeIs("place");
this._element("namePicker").hidden =
hiddenRows.indexOf("title") != -1;
this._element("locationRow").hidden =
hiddenRows.indexOf("location") != -1 || isQuery || !isBookmark;
this._element("keywordRow").hidden =
hiddenRows.indexOf("location") != -1 || isQuery || !isBookmark;
this._element("descriptionRow").hidden =
hiddenRows.indexOf("description")!= -1
this._element("folderRow").hidden =
hiddenRows.indexOf("folder picker") != -1 || isQuery ||
isLivemark || this._action == ACTION_EDIT;
this._element("livemarkFeedLocationRow").hidden =
hiddenRows.indexOf("feedURI") != -1 || !isLivemark;
this._element("livemarkSiteLocationRow").hidden =
hiddenRows.indexOf("siteURI") != -1 || !isLivemark;
this._element("loadInSidebarCheckbox").hidden =
hiddenRows.indexOf("loadInSidebar") != -1 || isQuery || !isBookmark;
},
/**
@ -490,8 +492,8 @@ var BookmarkPropertiesPanel = {
this._element("descriptionTextfield").value = this._itemDescription;
if (this._itemType == BOOKMARK_ITEM) {
if (this._bookmarkURI)
this._element("editURLBar").value = this._bookmarkURI.spec;
if (this._uri)
this._element("editURLBar").value = this._uri.spec;
if (typeof(this._bookmarkKeyword) == "string")
this._element("keywordTextfield").value = this._bookmarkKeyword;
@ -499,11 +501,6 @@ var BookmarkPropertiesPanel = {
if (this._loadBookmarkInSidebar)
this._element("loadInSidebarCheckbox").checked = true;
}
else {
this._element("locationRow").hidden = true;
this._element("keywordRow").hidden = true;
this._element("loadInSidebarCheckbox").hidden = true;
}
if (this._itemType == LIVEMARK_CONTAINER) {
if (this._feedURI)
@ -511,13 +508,8 @@ var BookmarkPropertiesPanel = {
if (this._siteURI)
this._element("feedSiteLocationTextfield").value = this._siteURI.spec;
}
else {
this._element("livemarkFeedLocationRow").hidden = true;
this._element("livemarkSiteLocationRow").hidden = true;
}
if (this._action == ACTION_EDIT)
this._element("folderRow").hidden = true;
this._showHideRows();
},
_createMicrosummaryMenuItem:
@ -554,15 +546,15 @@ var BookmarkPropertiesPanel = {
var namePicker = this._element("namePicker");
const annos = PlacesUtils.annotations;
if (annos.itemHasAnnotation(this._bookmarkId, STATIC_TITLE_ANNO)) {
userEnteredNameField.label = annos.getItemAnnotation(this._bookmarkId,
if (annos.itemHasAnnotation(this._itemId, STATIC_TITLE_ANNO)) {
userEnteredNameField.label = annos.getItemAnnotation(this._itemId,
STATIC_TITLE_ANNO);
}
else
userEnteredNameField.label = this._itemTitle;
// Non-bookmark items always use the item-title itself
if (this._itemType != BOOKMARK_ITEM || !this._bookmarkURI) {
if (this._itemType != BOOKMARK_ITEM || !this._uri) {
namePicker.selectedItem = userEnteredNameField;
return;
}
@ -570,8 +562,8 @@ var BookmarkPropertiesPanel = {
var itemToSelect = userEnteredNameField;
try {
this._microsummaries =
PlacesUIUtils.microsummaries.getMicrosummaries(this._bookmarkURI,
this._bookmarkId);
PlacesUIUtils.microsummaries.getMicrosummaries(this._uri,
this._itemId);
}
catch(ex) {
// getMicrosummaries will throw an exception if the page to which the URI
@ -594,7 +586,7 @@ var BookmarkPropertiesPanel = {
if (this._action == ACTION_EDIT &&
PlacesUIUtils.microsummaries
.isMicrosummary(this._bookmarkId, microsummary))
.isMicrosummary(this._itemId, microsummary))
itemToSelect = menuItem;
menupopup.appendChild(menuItem);
@ -800,11 +792,7 @@ var BookmarkPropertiesPanel = {
* was open.
*/
_saveChanges: function BPP__saveChanges() {
var itemId;
if (this._itemType == BOOKMARK_ITEM)
itemId = this._bookmarkId;
else
itemId = this._folderId;
var itemId = this._itemId;
var transactions = [];
@ -824,7 +812,7 @@ var BookmarkPropertiesPanel = {
if (this._itemType == BOOKMARK_ITEM) {
// location
var url = PlacesUIUtils.createFixedURI(this._element("editURLBar").value);
if (!this._bookmarkURI.equals(url))
if (!this._uri.equals(url))
transactions.push(PlacesUIUtils.ptm.editBookmarkURI(itemId, url));
// keyword transactions
@ -864,7 +852,7 @@ var BookmarkPropertiesPanel = {
var feedURI = PlacesUIUtils.createFixedURI(feedURIString);
if (!this._feedURI.equals(feedURI)) {
transactions.push(
PlacesUIUtils.ptm.editLivemarkFeedURI(this._folderId, feedURI));
PlacesUIUtils.ptm.editLivemarkFeedURI(this._itemId, feedURI));
}
// Site Location is empty, we can set its URI to null
@ -876,7 +864,7 @@ var BookmarkPropertiesPanel = {
if ((!newSiteURI && this._siteURI) ||
(newSiteURI && (!this._siteURI || !this._siteURI.equals(newSiteURI)))) {
transactions.push(
PlacesUIUtils.ptm.editLivemarkSiteURI(this._folderId, newSiteURI));
PlacesUIUtils.ptm.editLivemarkSiteURI(this._itemId, newSiteURI));
}
}
@ -940,7 +928,7 @@ var BookmarkPropertiesPanel = {
}
if (this._charSet)
PlacesUtils.history.setCharsetForURI(this._bookmarkURI, this._charSet);
PlacesUtils.history.setCharsetForURI(this._uri, this._charSet);
var transactions = [PlacesUIUtils.ptm.createItem(uri, aContainer, aIndex,
title, keyword,

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

@ -164,6 +164,8 @@ PlacesController.prototype = {
var selectedNode = this._view.selectedNode;
if (selectedNode) {
if (PlacesUtils.nodeIsFolder(selectedNode) ||
(PlacesUtils.nodeIsQuery(selectedNode) &&
selectedNode.itemId != -1) ||
(PlacesUtils.nodeIsBookmark(selectedNode) &&
!PlacesUtils.nodeIsLivemarkItem(selectedNode)))
return true;
@ -646,9 +648,10 @@ PlacesController.prototype = {
return;
if (PlacesUtils.nodeIsFolder(node))
PlacesUIUtils.showFolderProperties(node.itemId);
else if (PlacesUtils.nodeIsBookmark(node))
PlacesUIUtils.showBookmarkProperties(node.itemId);
PlacesUIUtils.showItemProperties(node.itemId, "folder");
else if (PlacesUtils.nodeIsBookmark(node) ||
PlacesUtils.nodeIsQuery(node))
PlacesUIUtils.showItemProperties(node.itemId, "bookmark");
},
/**

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

@ -655,7 +655,7 @@ var PlacesOrganizer = {
forceReadOnly: true });
}
else {
var itemId = aSelectedNode.itemId;
var itemId = PlacesUtils.getConcreteItemId(aSelectedNode);
gEditItemOverlay.initPanel(itemId != -1 ? itemId :
PlacesUtils._uri(aSelectedNode.uri),
{ hiddenRows: ["folderPicker"] });
@ -1437,14 +1437,6 @@ var PlacesQueryBuilder = {
// update collection type and get folders
var folders = [];
switch (id) {
case "scopeBarToolbar":
PlacesSearchBox.filterCollection = "collection";
folders.push(PlacesUtils.toolbarFolderId);
break;
case "scopeBarMenu":
PlacesSearchBox.filterCollection = "collection";
folders.push(PlacesUtils.bookmarksMenuFolderId);
break;
case "scopeBarHistory":
PlacesSearchBox.filterCollection = "history";
folders = [];

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

@ -205,7 +205,7 @@
command="placesCmd_show:info"
label="&cmd.properties.label;"
accesskey="&cmd.properties.accesskey;"
selection="bookmark|folder"
selection="bookmark|folder|query"
forcehideselection="livemarkChild"/>
</popup>

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

@ -425,7 +425,7 @@ var PlacesUIUtils = {
* @return true if any transaction has been performed.
*
* Notes:
* - the location, description and "load in sidebar" fields are
* - the location, description and "loadInSidebar" fields are
* visible only if there is no initial URI (aURI is null).
* - When aDefaultInsertionPoint is not set, the dialog defaults to the
* bookmarks root folder.
@ -493,7 +493,7 @@ var PlacesUIUtils = {
var info = {
action: "add",
type: "bookmark",
hiddenRows: ["location", "description", "load in sidebar"]
hiddenRows: ["location", "description", "loadInSidebar"]
};
if (aURI)
info.uri = aURI;
@ -640,33 +640,19 @@ var PlacesUIUtils = {
},
/**
* Opens the bookmark properties panel for a given bookmark identifier.
* Opens the properties dialog for a given item identifier.
*
* @param aId
* bookmark identifier for which the properties are to be shown
* @param aItemId
* item identifier for which the properties are to be shown
* @param aType
* item type, either "bookmark" or "folder"
* @return true if any transaction has been performed.
*/
showBookmarkProperties: function PU_showBookmarkProperties(aId) {
showItemProperties: function PU_showItemProperties(aItemId, aType) {
var info = {
action: "edit",
type: "bookmark",
bookmarkId: aId
};
return this._showBookmarkDialog(info);
},
/**
* Opens the folder properties panel for a given folder ID.
*
* @param aId
* an integer representing the ID of the folder to edit
* @return true if any transaction has been performed.
*/
showFolderProperties: function PU_showFolderProperties(aId) {
var info = {
action: "edit",
type: "folder",
folderId: aId
type: aType,
itemId: aItemId
};
return this._showBookmarkDialog(info);
},