2006-09-14 05:59:50 +00:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2006-09-14 05:48:12 +00:00
|
|
|
*
|
2006-09-14 05:59:50 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
2006-09-14 05:48:12 +00:00
|
|
|
*
|
2006-09-14 05:59:50 +00:00
|
|
|
* 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.
|
2006-09-14 05:48:12 +00:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2006-09-14 05:59:50 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2006-09-14 05:48:12 +00:00
|
|
|
*
|
2006-09-14 05:56:42 +00:00
|
|
|
* Contributor(s):
|
2006-09-14 05:49:24 +00:00
|
|
|
* - Kevin Puetz (puetzk@iastate.edu)
|
2006-09-14 05:57:26 +00:00
|
|
|
* - Ben Goodger <ben@netscape.com>
|
2006-09-14 06:03:40 +00:00
|
|
|
* - Blake Ross <blaker@netscape.com>
|
2006-09-14 06:04:12 +00:00
|
|
|
* - Pierre Chanial <pierrechanial@netscape.net>
|
2006-09-14 05:59:50 +00:00
|
|
|
*
|
|
|
|
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-09-14 05:51:24 +00:00
|
|
|
|
2006-09-14 05:56:42 +00:00
|
|
|
function _RDF(aType)
|
2006-09-14 05:51:24 +00:00
|
|
|
{
|
|
|
|
return "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + aType;
|
|
|
|
}
|
|
|
|
function NC_RDF(aType)
|
|
|
|
{
|
2006-09-14 05:56:42 +00:00
|
|
|
return "http://home.netscape.com/NC-rdf#" + aType;
|
2006-09-14 05:51:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var RDFUtils = {
|
|
|
|
getResource: function(aString)
|
|
|
|
{
|
2006-09-14 06:01:17 +00:00
|
|
|
return this.rdf.GetResource(aString, true);
|
2006-09-14 05:51:24 +00:00
|
|
|
},
|
2006-09-14 05:56:42 +00:00
|
|
|
|
2006-09-14 05:51:24 +00:00
|
|
|
getTarget: function(aDS, aSourceID, aPropertyID)
|
|
|
|
{
|
|
|
|
var source = this.getResource(aSourceID);
|
|
|
|
var property = this.getResource(aPropertyID);
|
|
|
|
return aDS.GetTarget(source, property, true);
|
|
|
|
},
|
2006-09-14 05:56:42 +00:00
|
|
|
|
2006-09-14 05:51:24 +00:00
|
|
|
getValueFromResource: function(aResource)
|
|
|
|
{
|
|
|
|
aResource = aResource.QueryInterface(Components.interfaces.nsIRDFResource);
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
return aResource ? aResource.Value : null;
|
2006-09-14 06:01:17 +00:00
|
|
|
},
|
|
|
|
_rdf: null,
|
|
|
|
get rdf() {
|
|
|
|
if (!this._rdf) {
|
|
|
|
this._rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIRDFService);
|
2006-09-14 05:53:30 +00:00
|
|
|
}
|
2006-09-14 06:01:17 +00:00
|
|
|
return this._rdf;
|
|
|
|
}
|
2006-09-14 06:04:12 +00:00
|
|
|
}
|
2006-09-14 05:48:12 +00:00
|
|
|
|
2006-09-14 05:50:34 +00:00
|
|
|
var proxyIconDNDObserver = {
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
onDragStart: function (aEvent, aXferData, aDragAction)
|
2006-09-14 05:50:34 +00:00
|
|
|
{
|
|
|
|
var urlBar = document.getElementById("urlbar");
|
2006-09-14 05:56:42 +00:00
|
|
|
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
// XXX - do we want to allow the user to set a blank page to their homepage?
|
2006-09-14 05:56:42 +00:00
|
|
|
// if so then we want to modify this a little to set about:blank as
|
|
|
|
// the homepage in the event of an empty urlbar.
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
if (!urlBar.value) return;
|
|
|
|
|
|
|
|
var urlString = urlBar.value + "\n" + window._content.document.title;
|
2006-09-14 05:50:34 +00:00
|
|
|
var htmlString = "<a href=\"" + urlBar.value + "\">" + urlBar.value + "</a>";
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
|
|
|
|
aXferData.data = new TransferData();
|
|
|
|
aXferData.data.addDataForFlavour("text/x-moz-url", urlString);
|
|
|
|
aXferData.data.addDataForFlavour("text/unicode", urlBar.value);
|
|
|
|
aXferData.data.addDataForFlavour("text/html", htmlString);
|
2006-09-14 05:50:34 +00:00
|
|
|
}
|
2006-09-14 06:04:12 +00:00
|
|
|
}
|
2006-09-14 05:49:14 +00:00
|
|
|
|
2006-09-14 05:50:34 +00:00
|
|
|
var homeButtonObserver = {
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
onDragStart: function (aEvent, aXferData, aDragAction)
|
|
|
|
{
|
|
|
|
var homepage = nsPreferences.getLocalizedUnicharPref("browser.startup.homepage", "about:blank");
|
|
|
|
|
|
|
|
if (homepage)
|
|
|
|
{
|
|
|
|
// XXX find a readable title string for homepage, perhaps do a history lookup.
|
|
|
|
var htmlString = "<a href=\"" + homepage + "\">" + homepage + "</a>";
|
|
|
|
aXferData.data = new TransferData();
|
|
|
|
aXferData.data.addDataForFlavour("text/x-moz-url", homepage + "\n" + homepage);
|
|
|
|
aXferData.data.addDataForFlavour("text/html", htmlString);
|
|
|
|
aXferData.data.addDataForFlavour("text/unicode", homepage);
|
|
|
|
}
|
|
|
|
},
|
2006-09-14 05:56:42 +00:00
|
|
|
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
onDrop: function (aEvent, aXferData, aDragSession)
|
2006-09-14 05:50:34 +00:00
|
|
|
{
|
2006-09-14 06:04:37 +00:00
|
|
|
var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
|
2006-09-14 06:03:28 +00:00
|
|
|
setTimeout(openHomeDialog, 0, url);
|
2006-09-14 05:50:34 +00:00
|
|
|
},
|
2006-09-14 05:56:42 +00:00
|
|
|
|
2006-09-14 05:52:10 +00:00
|
|
|
onDragOver: function (aEvent, aFlavour, aDragSession)
|
2006-09-14 05:50:34 +00:00
|
|
|
{
|
2006-09-14 05:54:50 +00:00
|
|
|
var statusTextFld = document.getElementById("statusbar-display");
|
2006-09-14 05:56:42 +00:00
|
|
|
statusTextFld.label = gNavigatorBundle.getString("droponhomebutton");
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
|
2006-09-14 05:50:34 +00:00
|
|
|
},
|
2006-09-14 05:56:42 +00:00
|
|
|
|
2006-09-14 05:52:10 +00:00
|
|
|
onDragExit: function (aEvent, aDragSession)
|
2006-09-14 05:50:34 +00:00
|
|
|
{
|
2006-09-14 05:57:14 +00:00
|
|
|
var statusTextFld = document.getElementById("statusbar-display");
|
2006-09-14 05:56:42 +00:00
|
|
|
statusTextFld.label = "";
|
2006-09-14 05:50:34 +00:00
|
|
|
},
|
2006-09-14 05:56:42 +00:00
|
|
|
|
2006-09-14 05:50:34 +00:00
|
|
|
getSupportedFlavours: function ()
|
|
|
|
{
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-09-14 05:56:00 +00:00
|
|
|
var flavourSet = new FlavourSet();
|
|
|
|
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
|
|
|
|
flavourSet.appendFlavour("text/x-moz-url");
|
|
|
|
flavourSet.appendFlavour("text/unicode");
|
|
|
|
return flavourSet;
|
2006-09-14 05:53:30 +00:00
|
|
|
}
|
2006-09-14 06:04:12 +00:00
|
|
|
}
|
2006-09-14 05:59:14 +00:00
|
|
|
|
2006-09-14 06:03:28 +00:00
|
|
|
function openHomeDialog(aURL)
|
|
|
|
{
|
|
|
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
|
|
|
var promptTitle = gNavigatorBundle.getString("droponhometitle");
|
|
|
|
var promptMsg = gNavigatorBundle.getString("droponhomemsg");
|
|
|
|
var okButton = gNavigatorBundle.getString("droponhomeokbutton");
|
2006-09-14 06:03:44 +00:00
|
|
|
var pressedVal = promptService.confirmEx(window, promptTitle, promptMsg,
|
2006-09-14 06:03:28 +00:00
|
|
|
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) +
|
|
|
|
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
|
2006-09-14 06:03:44 +00:00
|
|
|
okButton, null, null, null, {value:0});
|
2006-09-14 06:03:28 +00:00
|
|
|
|
2006-09-14 06:03:44 +00:00
|
|
|
if (pressedVal == 0) {
|
2006-09-14 06:03:28 +00:00
|
|
|
nsPreferences.setUnicharPref("browser.startup.homepage", aURL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-14 05:59:14 +00:00
|
|
|
var goButtonObserver = {
|
|
|
|
onDragOver: function(aEvent, aFlavour, aDragSession)
|
|
|
|
{
|
|
|
|
aEvent.target.setAttribute("dragover", "true");
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
onDragExit: function (aEvent, aDragSession)
|
|
|
|
{
|
|
|
|
aEvent.target.removeAttribute("dragover");
|
|
|
|
},
|
|
|
|
onDrop: function (aEvent, aXferData, aDragSession)
|
|
|
|
{
|
|
|
|
var xferData = aXferData.data.split("\n");
|
|
|
|
var uri = xferData[0] ? xferData[0] : xferData[1];
|
|
|
|
if (uri)
|
|
|
|
loadURI(uri);
|
|
|
|
},
|
|
|
|
getSupportedFlavours: function ()
|
|
|
|
{
|
|
|
|
var flavourSet = new FlavourSet();
|
|
|
|
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
|
|
|
|
flavourSet.appendFlavour("text/x-moz-url");
|
|
|
|
flavourSet.appendFlavour("text/unicode");
|
|
|
|
return flavourSet;
|
|
|
|
}
|
2006-09-14 06:04:12 +00:00
|
|
|
}
|
2006-09-14 05:59:14 +00:00
|
|
|
|
|
|
|
var searchButtonObserver = {
|
|
|
|
onDragOver: function(aEvent, aFlavour, aDragSession)
|
|
|
|
{
|
|
|
|
aEvent.target.setAttribute("dragover", "true");
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
onDragExit: function (aEvent, aDragSession)
|
|
|
|
{
|
|
|
|
aEvent.target.removeAttribute("dragover");
|
|
|
|
},
|
|
|
|
onDrop: function (aEvent, aXferData, aDragSession)
|
|
|
|
{
|
|
|
|
var xferData = aXferData.data.split("\n");
|
|
|
|
var uri = xferData[1] ? xferData[1] : xferData[0];
|
|
|
|
if (uri)
|
|
|
|
OpenSearch('internet',false, uri);
|
|
|
|
},
|
|
|
|
getSupportedFlavours: function ()
|
|
|
|
{
|
|
|
|
var flavourSet = new FlavourSet();
|
|
|
|
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
|
|
|
|
flavourSet.appendFlavour("text/x-moz-url");
|
|
|
|
flavourSet.appendFlavour("text/unicode");
|
|
|
|
return flavourSet;
|
|
|
|
}
|
2006-09-14 06:04:12 +00:00
|
|
|
}
|