зеркало из https://github.com/mozilla/gecko-dev.git
Move bookmarks javascript code into separate file. Add initial browser sidebar code and data.
This commit is contained in:
Родитель
10f2ab7832
Коммит
0b49be0ae6
|
@ -35,6 +35,7 @@ FILES = \
|
|||
bookmark-folder-open.gif \
|
||||
bookmark-item.gif \
|
||||
bookmarks.css \
|
||||
bookmarks.js \
|
||||
bookmarks.xul \
|
||||
document.gif \
|
||||
dom-test-1.css \
|
||||
|
@ -59,14 +60,16 @@ FILES = \
|
|||
remote-flash-2.rdf \
|
||||
remote-flash-3.rdf \
|
||||
sidebar.css \
|
||||
sidebar.js \
|
||||
sidebar.xul \
|
||||
sidebar-browser.rdf \
|
||||
sidebar-browser.xul \
|
||||
sidebarcontainer.xul \
|
||||
stock.gif \
|
||||
unread.gif \
|
||||
xpidl-test-1.xul \
|
||||
$(NULL)
|
||||
|
||||
|
||||
FILES := $(addprefix $(srcdir)/, $(FILES))
|
||||
|
||||
install::
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
// -*- Mode: Java -*-
|
||||
|
||||
function BookmarksNewWindow()
|
||||
{
|
||||
var toolkitCore = XPAppCoresManager.Find("toolkitCore");
|
||||
if (!toolkitCore) {
|
||||
toolkitCore = new ToolkitCore();
|
||||
if (toolkitCore) {
|
||||
toolkitCore.Init("toolkitCore");
|
||||
}
|
||||
}
|
||||
if (toolkitCore) {
|
||||
toolkitCore.ShowWindow("resource://res/rdf/bookmarks.xul",window);
|
||||
}
|
||||
}
|
||||
|
||||
function BookmarkProperties()
|
||||
{
|
||||
var tree = document.getElementById('bookmarksTree');
|
||||
var select_list = tree.getElementsByAttribute("selected", "true");
|
||||
|
||||
if (select_list.length >= 1) {
|
||||
dump("Bookmark Properties: Have selection\n");
|
||||
var propsCore = XPAppCoresManager.Find(select_list[0].id);
|
||||
if (!propsCore) {
|
||||
dump("Bookmark Properties: no existing appcore\n");
|
||||
var propsCore = new DOMPropsCore();
|
||||
if (propsCore) {
|
||||
dump("Bookmark Properties: initing new appcore\n");
|
||||
propsCore.Init(select_list[0].id);
|
||||
} else {
|
||||
dump("Bookmark Properties: failed to create new appcore\n");
|
||||
}
|
||||
}
|
||||
if (propsCore) {
|
||||
dump("Bookmark Properties: opening new window\n");
|
||||
propsCore.showProperties("resource://res/rdf/bm-props.xul",
|
||||
window, select_list[0]);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
dump("nothing selected!\n");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function OpenURL(event,node)
|
||||
{
|
||||
if (node.getAttribute('type') !=
|
||||
"http://home.netscape.com/NC-rdf#Bookmark") {
|
||||
return false;
|
||||
}
|
||||
url = node.getAttribute('id');
|
||||
|
||||
// Ignore "NC:" urls.
|
||||
if (url.substring(0, 3) == "NC:") {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*window.open(url,'bookmarks');*/
|
||||
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
|
||||
if (!toolkitCore) {
|
||||
toolkitCore = new ToolkitCore();
|
||||
if (toolkitCore) {
|
||||
toolkitCore.Init("ToolkitCore");
|
||||
}
|
||||
}
|
||||
if (toolkitCore) {
|
||||
toolkitCore.ShowWindow(url,window);
|
||||
}
|
||||
|
||||
dump("OpenURL(" + url + ")\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function doSort(sortColName)
|
||||
{
|
||||
var node = document.getElementById(sortColName);
|
||||
// determine column resource to sort on
|
||||
var sortResource = node.getAttribute('resource');
|
||||
if (!node) return(false);
|
||||
|
||||
var sortDirection="ascending";
|
||||
var isSortActive = node.getAttribute('sortActive');
|
||||
if (isSortActive == "true") {
|
||||
var currentDirection = node.getAttribute('sortDirection');
|
||||
if (currentDirection == "ascending")
|
||||
sortDirection = "descending";
|
||||
else if (currentDirection == "descending")
|
||||
sortDirection = "natural";
|
||||
else
|
||||
sortDirection = "ascending";
|
||||
}
|
||||
|
||||
// get RDF Core service
|
||||
var rdfCore = XPAppCoresManager.Find("RDFCore");
|
||||
if (!rdfCore) {
|
||||
rdfCore = new RDFCore();
|
||||
if (!rdfCore) {
|
||||
return(false);
|
||||
}
|
||||
rdfCore.Init("RDFCore");
|
||||
XPAppCoresManager.Add(rdfCore);
|
||||
}
|
||||
// sort!!!
|
||||
rdfCore.doSort(node, sortResource, sortDirection);
|
||||
return(false);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<!-- -*- Mode: SGML -*- -->
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:NC="http://home.netscape.com/NC-rdf#">
|
||||
|
||||
<RDF:Seq ID="NC:BrowserSidebarRoot">
|
||||
<RDF:li>
|
||||
<RDF:Description ID="bookmarks">
|
||||
<NC:title>Bookmarks</NC:title>
|
||||
<NC:content>chrome://res/rdf/bm-panel.xul</NC:content>
|
||||
<NC:customize>chrome://res/rdf/bm-panel-cust.xul</NC:customize>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
<RDF:li>
|
||||
<RDF:Description ID="flash">
|
||||
<NC:title>Flashes</NC:title>
|
||||
<NC:content>chrome://res/rdf/flash.xul</NC:content>
|
||||
<NC:customize>chrome://res/rdf/flash-cust.xul</NC:customize>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
<RDF:li>
|
||||
<RDF:Description ID="tinderbox">
|
||||
<NC:title>Mozilla Tinderbox</NC:title>
|
||||
<NC:content>http://cvs-mirror.mozilla.org/webtools/tinderbox/showbuilds.cgi?tree=SeaMonkey&panel=1</NC:content>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</RDF:RDF>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
|
||||
|
||||
<window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<html:style>
|
||||
iframe {
|
||||
height: 100;
|
||||
border: 0;
|
||||
}
|
||||
</html:style>
|
||||
|
||||
<html:script src="sidebar.js" />
|
||||
|
||||
</window>
|
|
@ -0,0 +1,127 @@
|
|||
// -*- Mode: Java -*-
|
||||
|
||||
// the rdf service
|
||||
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
|
||||
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
|
||||
// the current profile directory
|
||||
// XXX obviously, this shouldn't be hard-coded
|
||||
var profiledir = 'resource:/res/rdf/';
|
||||
|
||||
// the location of the flash registry.
|
||||
var sidebardb = profiledir + 'panels-browser.rdf';
|
||||
var sidebar_resource = 'NC:BrowserSidebarRoot';
|
||||
|
||||
function Init(sidebardb, sidebar_resource)
|
||||
{
|
||||
// Initialize the Sidebar
|
||||
dump('Sidebar Init('+sidebardb+','+sidebar_resource+')\n');
|
||||
|
||||
//var tree = document.getElementById('tree');
|
||||
|
||||
// Install all the datasources named in the Flash Registry into
|
||||
// the tree control. Datasources are listed as members of the
|
||||
// NC:FlashDataSources sequence, and are loaded in the order that
|
||||
// they appear in that sequence.
|
||||
var registry = RDF.GetDataSource(sidebardb);
|
||||
|
||||
// Add it to the tree control's composite datasource.
|
||||
//tree.database.AddDataSource(registry);
|
||||
|
||||
// Create a 'container' wrapper around the sidebar_resources
|
||||
// resource so we can use some utility routines that make access a
|
||||
// bit easier.
|
||||
var sb_datasource = Components.classes['component://netscape/rdf/container'].createInstance();
|
||||
sb_datasource = sb_datasource.QueryInterface(Components.interfaces.nsIRDFContainer);
|
||||
|
||||
sb_datasource.Init(registry, RDF.GetResource(sidebar_resource));
|
||||
|
||||
// Now enumerate all of the flash datasources.
|
||||
var enumerator = sb_datasource.GetElements();
|
||||
|
||||
while (enumerator.HasMoreElements()) {
|
||||
var service = enumerator.GetNext();
|
||||
service = service.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
var new_panel = createPanel(registry, service);
|
||||
if (new_panel) {
|
||||
document.documentElement.appendChild(new_panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createPanel(registry, service) {
|
||||
var panel_title = getAttr(registry, service, 'title');
|
||||
var panel_content = getAttr(registry, service, 'content');
|
||||
var panel_customize = getAttr(registry, service, 'customize');
|
||||
|
||||
dump('Adding...' + panel_title + '\n');
|
||||
var div = document.createElement('div');
|
||||
var title = document.createElement('titlebutton');
|
||||
var customize = document.createElement('titlebutton');
|
||||
var toolbar = document.createElement('toolbar');
|
||||
var iframe = document.createElement('html:iframe');
|
||||
var newline = document.createElement('html:br');
|
||||
title.setAttribute('value', panel_title);
|
||||
customize.setAttribute('value', 'Customize');
|
||||
iframe.setAttribute('src', panel_content);
|
||||
|
||||
toolbar.appendChild(title);
|
||||
toolbar.appendChild(customize);
|
||||
div.appendChild(toolbar);
|
||||
div.appendChild(iframe);
|
||||
div.appendChild(newline);
|
||||
return div;
|
||||
}
|
||||
|
||||
function getAttr(registry,service,attr_name) {
|
||||
var attr = registry.GetTarget(service,
|
||||
RDF.GetResource('http://home.netscape.com/NC-rdf#' + attr_name),
|
||||
true);
|
||||
if (attr)
|
||||
attr = attr.QueryInterface(
|
||||
Components.interfaces.nsIRDFLiteral);
|
||||
if (attr)
|
||||
attr = attr.Value;
|
||||
return attr;
|
||||
}
|
||||
|
||||
function Reload(url, pollInterval)
|
||||
{
|
||||
// Reload the specified datasource and reschedule.
|
||||
dump('Reload(' + url + ', ' + pollInterval + ')\n');
|
||||
|
||||
var datasource = RDF.GetDataSource(url);
|
||||
datasource = datasource.QueryInterface(Components.interfaces.nsIRDFXMLDataSource);
|
||||
|
||||
// Reload, asynchronously.
|
||||
datasource.Open(false);
|
||||
|
||||
// Reschedule
|
||||
Schedule(url, pollInterval);
|
||||
}
|
||||
|
||||
function Schedule(url, pollInterval)
|
||||
{
|
||||
setTimeout('Reload("' + url + '", ' + pollInterval + ')', pollInterval * 1000);
|
||||
}
|
||||
|
||||
function OpenURL(node)
|
||||
{
|
||||
dump("open-url(" + node + ")\n");
|
||||
}
|
||||
|
||||
|
||||
// To get around "window.onload" not working in viewer.
|
||||
function Boot()
|
||||
{
|
||||
var root = document.documentElement;
|
||||
if (root == null) {
|
||||
setTimeout(Boot, 0);
|
||||
}
|
||||
else {
|
||||
Init(sidebardb, sidebar_resource);
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout('Boot()', 0);
|
Загрузка…
Ссылка в новой задаче