load URLs in the browser or in new windows or tabs. 315940, NOT PART OF BUILD.

This commit is contained in:
beng%bengoodger.com 2005-11-17 21:54:46 +00:00
Родитель 989c75c181
Коммит 9f4fc80b93
3 изменённых файлов: 77 добавлений и 6 удалений

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

@ -79,14 +79,14 @@ function PC_isCommandEnabled(command) {
PlacesController.prototype.supportsCommand =
function PC_supportsCommand(command) {
LOG("supportsCommand: " + command);
//LOG("supportsCommand: " + command);
return document.getElementById(command) != null;
};
PlacesController.prototype.doCommand =
function PC_doCommand(command) {
LOG("doCommand: " + command);
};
PlacesController.prototype.doCommandWithParams =

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

@ -148,3 +148,70 @@ PlacesPage._buildQuery = function PP__buildQuery(filterString) {
placeContent.view = result;
};
PlacesPage._getLoadFunctionForEvent =
function PP__getLoadFunctionForEvent(event) {
if (event.button != 0)
return null;
if (event.ctrlKey)
return this.openLinkInNewTab;
else if (event.shiftKey)
return this.openLinkInNewWindow;
return this.openLinkInCurrentWindow;
};
// XXXben this is actually an AVI interface method and should be defined as such.
PlacesPage._getSelectedURL = function PP__getSelectedURL() {
// Get the selected item
var placesContent = document.getElementById("placeContent");
var view = placesContent.view;
var selection = view.selection;
var rc = selection.getRangeCount();
if (rc != 1)
return null;
var min = { }, max = { };
selection.getRangeAt(0, min, max);
// Cannot load containers
if (view.isContainer(min.value) || view.isSeparator(min.value))
return null;
var result = view.QueryInterface(Ci.nsINavHistoryResult);
return result.nodeForTreeIndex(min.value).url;
};
/**
* Loads a URL in the appropriate tab or window, given the user's preference
* specified by modifier keys tracked by a DOM event
* @param event
* The DOM Mouse event with modifier keys set that track the user's
* preferred destination window or tab.
*/
PlacesPage.mouseLoadURIInBrowser = function PP_loadURIInBrowser(event) {
this._getLoadFunctionForEvent(event)();
};
/**
* Loads the selected URL in a new tab.
*/
PlacesPage.openLinkInNewTab = function PP_openLinkInNewTab() {
var url = this._getSelectedURL();
this._topWindow.openNewTabWith(url, null, null);
};
/**
* Loads the selected URL in a new window.
*/
PlacesPage.openLinkInNewWindow = function PP_openLinkInNewWindow() {
var url = this._getSelectedURL();
this._topWindow.openNewWindowWith(url, null, null);
};
/**
* Loads the selected URL in the current window, replacing the Places page.
*/
PlacesPage.openLinkInCurrentWindow = function PP_openLinkInCurrentWindow() {
var url = this._getSelectedURL();
this._topWindow.loadURI(url, null, null);
};

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

@ -35,9 +35,12 @@
<command id="placesCmd_rename" label="&cmd.rename.label;" accesskey="&cmd.rename.accesskey;"/>
</commandset>
<commandset type="link" readonly="true">
<command id="placesCmd_open" label="&cmd.open.label;" accesskey="&cmd.open.accesskey;"/>
<command id="placesCmd_open:window" label="&cmd.open_window.label;" accesskey="&cmd.open_window.accesskey;"/>
<command id="placesCmd_open:tab" label="&cmd.open_tab.label;" accesskey="&cmd.open_tab.accesskey;"/>
<command id="placesCmd_open" label="&cmd.open.label;" accesskey="&cmd.open.accesskey;"
oncommand="PlacesPage.openLinkInCurrentWindow();"/>
<command id="placesCmd_open:window" label="&cmd.open_window.label;" accesskey="&cmd.open_window.accesskey;"
oncommand="PlacesPage.openLinkInNewWindow();"/>
<command id="placesCmd_open:tab" label="&cmd.open_tab.label;" accesskey="&cmd.open_tab.accesskey;"
oncommand="PlacesPage.openLinkInNewTab();"/>
</commandset>
<commandset type="link">
</commandset>
@ -152,7 +155,8 @@
</hbox>
<deck id="content" flex="1">
<vbox flex="1">
<tree id="placeContent" class="placesTree" context="placesContext" flex="1">
<tree id="placeContent" class="placesTree" context="placesContext" flex="1"
ondblclick="PlacesPage.mouseLoadURIInBrowser(event);">
<treecols>
<treecol label="&col.title.label;" id="title" flex="1" primary="true"/>
<treecol label="&col.url.label;" id="url" flex="1"/>