From 340e2202878b7d1608da447db66df1371ddefc5a Mon Sep 17 00:00:00 2001 From: "dietrich%mozilla.com" Date: Wed, 28 Mar 2007 20:32:51 +0000 Subject: [PATCH] Bug 329281 'Add Keyword for this Search' does not work w/ Places (r=mano) git-svn-id: svn://10.0.0.236/trunk@222554 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/browser.js | 5 ++-- .../places/content/bookmarkProperties.js | 8 +++++-- .../components/places/content/utils.js | 23 +++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index f85d6388cd8..0fc2ecd97e3 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -1976,7 +1976,7 @@ function getShortcutOrURI(aURL, aPostDataRef) var cmd = aURL.substr(0, aOffset); var text = aURL.substr(aOffset+1); #ifdef MOZ_PLACES_BOOKMARKS - shortcutURI = bookmarkService.getURIForKeyword(cmd); + shortcutURI = PlacesUtils.bookmarks.getURIForKeyword(cmd); if (shortcutURI) shortcutURL = shortcutURI.spec; #else @@ -5188,7 +5188,8 @@ function AddKeywordForSearchField() openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "", BROWSER_ADD_BM_FEATURES, dialogArgs); #else - dump("*** IMPLEMENT ME: Bug 329281\n"); + var description = PlacesUtils.getDescriptionFromDocument(node.ownerDocument); + PlacesUtils.showAddBookmarkUI(makeURI(spec), "", description, null, null, null, ""); #endif } diff --git a/mozilla/browser/components/places/content/bookmarkProperties.js b/mozilla/browser/components/places/content/bookmarkProperties.js index 7bcade9a507..dc5acc8ffff 100755 --- a/mozilla/browser/components/places/content/bookmarkProperties.js +++ b/mozilla/browser/components/places/content/bookmarkProperties.js @@ -58,6 +58,7 @@ * item. * @ defaultInsertionPoint (InsertionPoint JS object) - optional, the * default insertion point for the new item. + * @ keyword (String) - optional, the default keyword for the new item. * Notes: * 1) If |uri| is set for a bookmark/livemark item and |title| isn't, * the dialog will query the history tables for the title associated @@ -213,7 +214,7 @@ var BookmarkPropertiesPanel = { "uri property should be a uri object"); this._bookmarkURI = dialogInfo.uri; } - if (!this._itemTitle) { + if (typeof(this._itemTitle) != "string") { if (this._bookmarkURI) { this._itemTitle = this._getURITitleFromHistory(this._bookmarkURI); @@ -227,6 +228,9 @@ var BookmarkPropertiesPanel = { if ("loadBookmarkInSidebar" in dialogInfo) this._loadBookmarkInSidebar = dialogInfo.loadBookmarkInSidebar; + if ("keyword" in dialogInfo) + this._bookmarkKeyword = dialogInfo.keyword; + break; case "folder": this._action = ACTION_ADD; @@ -488,7 +492,7 @@ var BookmarkPropertiesPanel = { if (this._bookmarkURI) this._element("editURLBar").value = this._bookmarkURI.spec; - if (this._bookmarkKeyword) + if (typeof(this._bookmarkKeyword) == "string") this._element("keywordTextfield").value = this._bookmarkKeyword; if (this._loadBookmarkInSidebar) diff --git a/mozilla/browser/components/places/content/utils.js b/mozilla/browser/components/places/content/utils.js index 3a4bac3cce1..a22b77e37f3 100644 --- a/mozilla/browser/components/places/content/utils.js +++ b/mozilla/browser/components/places/content/utils.js @@ -698,7 +698,7 @@ var PlacesUtils = { /** * Methods to show the bookmarkProperties dialog in its various modes. * - * The showMinimialAdd* methods open the dialog by its alternative URI. Thus + * The showMinimalAdd* methods open the dialog by its alternative URI. Thus * they persist the dialog dimensions separately from the showAdd* methods. */ @@ -722,10 +722,13 @@ var PlacesUtils = { * @param [optional] aLoadInSidebar * If true, the dialog will default to load the new item in the * sidebar (as a web panel). + * @param [optional] aKeyword + * The default keyword for the new bookmark. The keyword field + * will be shown in the dialog if this is used. * @return true if any transaction has been performed. * * Notes: - * - the location, description, keyword and "load in sidebar" fields are + * - the location, description and "load in sidebar" 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. @@ -735,7 +738,8 @@ var PlacesUtils = { aDescription, aDefaultInsertionPoint, aShowPicker, - aLoadInSidebar) { + aLoadInSidebar, + aKeyword) { var info = { action: "add", type: "bookmark" @@ -760,6 +764,9 @@ var PlacesUtils = { if (aLoadInSidebar) info.loadBookmarkInSidebar = true; + if (typeof(aKeyword) == "string") + info.keyword = aKeyword; + return this._showBookmarkDialog(info); }, @@ -770,11 +777,14 @@ var PlacesUtils = { * * You can still pass in the various paramaters as the default properties * for the new bookmark. + * + * The keyword field will be visible only if the aKeyword parameter + * was used. */ showMinimalAddBookmarkUI: function PU_showMinimalAddBookmarkUI(aURI, aTitle, aDescription, aDefaultInsertionPoint, aShowPicker, - aLoadInSidebar) { + aLoadInSidebar, aKeyword) { var info = { action: "add", type: "bookmark", @@ -799,6 +809,11 @@ var PlacesUtils = { if (aLoadInSidebar) info.loadBookmarkInSidebar = true; + if (typeof(aKeyword) == "string") + info.keyword = aKeyword; + else + info.hiddenRows.push("keyword"); + return this._showBookmarkDialog(info, true); },