diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index e7cb40d1437..73adb977bdb 100755 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -35,15 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -// Abstract View Interface: -/* - - get selection() { - - }, - -*/ - const PLACES_URI = "chrome://browser/content/places/places.xul"; function LOG(str) { @@ -62,61 +53,30 @@ const SELECTION_IS_CHANGEABLE = 0x10; const SELECTION_IS_REMOVABLE = 0x20; const SELECTION_IS_MOVABLE = 0x40; -/** - * Implements nsIController, nsICommandController... - * @param elements - * A list of elements that this controller applies to - * @param commandSet - * A XUL that contains the commands supported by this - * controller - * @constructor - */ -function PlacesController(elements, commandSet) { - if (!commandSet || !elements) - throw Cr.NS_ERROR_NULL_POINTER; - - for (var i = 0; i < elements.length; ++i) - elements[i].controllers.appendController(this); -} +var PlacesController = { +}; -PlacesController.prototype.isCommandEnabled = -function PC_isCommandEnabled(command) { +PlacesController.isCommandEnabled = function PC_isCommandEnabled(command) { LOG("isCommandEnabled: " + command); }; -PlacesController.prototype.supportsCommand = -function PC_supportsCommand(command) { +PlacesController.supportsCommand = function PC_supportsCommand(command) { //LOG("supportsCommand: " + command); return document.getElementById(command) != null; }; -PlacesController.prototype.doCommand = -function PC_doCommand(command) { +PlacesController.doCommand = function PC_doCommand(command) { LOG("doCommand: " + command); }; -PlacesController.prototype.doCommandWithParams = -function PC_doCommandWithParams(command) { - LOG("doCommandWithParams: " + command); - -}; - -PlacesController.prototype.getCommandStateWithParams = -function PC_getCommandStateWithParams(command, params) { - LOG("getCommandStateWithParams: " + command); - -}; - -PlacesController.prototype.onEvent = -function PC_onEvent(eventName) { +PlacesController.onEvent = function PC_onEvent(eventName) { LOG("onEvent: " + eventName); }; -PlacesController.prototype.buildContextMenu = -function PC_buildContextMenu(popup) { +PlacesController.buildContextMenu = function PC_buildContextMenu(popup) { return true; }; @@ -140,20 +100,6 @@ function PC_buildContextMenu(popup) { SELECTION_CONTAINS_REMOVABLE SELECTION_CONTAINS_MOVABLE -*/ - -PlacesController.prototype.QueryInterface = -function PC_QueryInterface(iid) { - if (!iid.equals(Ci.nsIController) && - !iid.equals(Ci.nsICommandController)) - throw Cr.NS_ERROR_NO_INTERFACE; - return this; -}; - -var PlacesUtils = {}; - -/* - Given a: - view, via AVI - query diff --git a/browser/components/places/content/places.css b/browser/components/places/content/places.css index 17290cc49b4..7cd945d2594 100644 --- a/browser/components/places/content/places.css +++ b/browser/components/places/content/places.css @@ -1,4 +1,9 @@ .calendar { - -moz-binding:url("chrome://browser/content/places/places.xml#calendar"); - display:-moz-box; + -moz-binding: url("chrome://browser/content/places/places.xml#calendar"); + display: -moz-box; } + +tree { + -moz-binding: url("chrome://browser/content/places/places.xml#places-tree"); +} + diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 1c33c0e7f41..3854a4a074e 100755 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -40,7 +40,6 @@ var PlacesPage = { _tabbrowser: null, _topWindow: null, _topDocument: null, - _populators: { }, _bmsvc : null, }; @@ -52,40 +51,29 @@ PlacesPage.init = function PP_init() { this._topDocument = this._topWindow.document; this._tabbrowser = this._topWindow.getBrowser(); + // Hook into the tab strip to get notifications about when the Places Page is + // selected so that the browser UI can be modified. var self = this; function onTabSelect(event) { self.onTabSelect(event); } this._tabbrowser.mTabContainer.addEventListener("select", onTabSelect, false); + // Attach the Command Controller to the Places Views. var placesList = document.getElementById("placesList"); - var placeContent = document.getElementById("placeContent"); - var placesCommands = document.getElementById("placesCommands"); - - this.controller = - new PlacesController([placesList, placeContent], placesCommands); + var placeContent = document.getElementById("placeContent"); + placeContent.controllers.appendController(PlacesController); + placesList.controllers.appendController(PlacesController); - const NH = Ci.nsINavHistory; - const NHQO = Ci.nsINavHistoryQueryOptions; - const TV = Ci.nsITreeView; - var places = - Cc["@mozilla.org/browser/nav-history;1"].getService(NH); - var query = places.getNewQuery(); - var date = new Date(); - var options = places.getNewQueryOptions(); - options.setGroupingMode([NHQO.GROUP_BY_HOST], 1); - options.setSortingMode(NHQO.SORT_BY_NONE); - options.setResultType(NHQO.RESULT_TYPE_URL); - var result = places.executeQuery(query, options); - result.QueryInterface(TV); - var placeContent = document.getElementById("placeContent"); - placeContent.view = result; + // Attach the History model to the Content View + placeContent.queryString = "group=1"; + // Attach the Places model to the Place View const BS = Ci.nsINavBookmarksService; this._bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(BS); var children = this._bmsvc.getFolderChildren(this._bmsvc.placesRoot, BS.FOLDER_CHILDREN); - document.getElementById("placesList").view = children.QueryInterface(TV); + document.getElementById("placesList").view = children.QueryInterface(Ci.nsITreeView); this._showPlacesUI(); }; @@ -136,28 +124,11 @@ PlacesPage.applyFilter = function PP_applyFilter(filterString) { this.setFilterCollection("all"); } else if (collectionName == "all") { - this._buildQuery(filterString); + var placeContent = document.getElementById("placeContent"); + placeContent.filterString = filterString; } }; -PlacesPage._buildQuery = function PP__buildQuery(filterString) { - const NH = Ci.nsINavHistory; - const NHQO = Ci.nsINavHistoryQueryOptions; - var places = Cc["@mozilla.org/browser/nav-history;1"].getService(NH); - var query = places.getNewQuery(); - query.searchTerms = filterString; - var options = places.getNewQueryOptions(); - options.setGroupingMode([NHQO.GROUP_BY_HOST], 1); - options.setSortingMode(NHQO.SORT_BY_NONE); - options.setResultType(NHQO.RESULT_TYPE_URL); - var result = places.executeQuery(query, options); - result.QueryInterface(Ci.nsITreeView); - var placeContent = document.getElementById("placeContent"); - placeContent.view = result; - placeContent.query = query; - placeContent.options = options; -}; - PlacesPage._getLoadFunctionForEvent = function PP__getLoadFunctionForEvent(event) { if (event.button != 0) diff --git a/browser/components/places/content/places.xml b/browser/components/places/content/places.xml index d1c16b93fc6..24bf10a7b40 100755 --- a/browser/components/places/content/places.xml +++ b/browser/components/places/content/places.xml @@ -22,50 +22,73 @@ - - + + + + + + + + + + + + = 1; ]]> - - - return this.view.selection.getRangeCount() >= 1; - - - - + - + ]]> @@ -113,10 +135,13 @@ ]]> + + + - - diff --git a/browser/components/places/jar.mn b/browser/components/places/jar.mn index 94ae18518a5..e20d2dcc7a8 100755 --- a/browser/components/places/jar.mn +++ b/browser/components/places/jar.mn @@ -3,6 +3,7 @@ browser.jar: * content/browser/places/places.xul (content/places.xul) * content/browser/places/places.js (content/places.js) * content/browser/places/places.xml (content/places.xml) +* content/browser/places/places.css (content/places.css) * content/browser/places/controller.js (content/controller.js) * content/browser/places/browserShim.js (content-shim/browserShim.js) * content/browser/places/browserShim.xul (content-shim/browserShim.xul)