Use single clicks to open folders, but double clicks to launch items.

Bug #14998. r=mcafee
This commit is contained in:
slamm%netscape.com 1999-11-30 00:56:44 +00:00
Родитель 8bad710b4e
Коммит 83518d92b7
8 изменённых файлов: 146 добавлений и 30 удалений

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

@ -0,0 +1,39 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Stephen Lamm <slamm@netscape.com>
*/
/*
Code for the Bookmarks Sidebar Panel
*/
function clicked(event, target) {
if (target.getAttribute('container') == 'true') {
if (target.getAttribute('open') == 'true') {
target.removeAttribute('open');
} else {
target.setAttribute('open','true');
}
} else {
if (event.clickCount == 2) {
top.OpenBookmarkURL(target, 'bookmarksTree');
}
}
}

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

@ -22,7 +22,6 @@
-->
<!-- <?xml-stylesheet href="chrome://sidebar/skin/" type="text/css"?> -->
<?xml-stylesheet href="chrome://bookmarks/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://bookmarks/skin/bm-panel.css" type="text/css"?>
@ -32,6 +31,8 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical">
<html:script src="chrome://bookmarks/content/bm-panel.js" />
<html:div style="width:100px;height:100px" flex="1">
<popup id="contextual" oncreate="return fillContextMenu('contextual');" >
@ -41,7 +42,7 @@
<tree id="bookmarksTree" context="contextual" ref="NC:BookmarksRoot"
style="height: 100%; width:100%;"
datasources="rdf:bookmarks rdf:files rdf:localsearch rdf:internetsearch"
onclick="if (event.clickCount == 2) return top.OpenBookmarkURL(event.target.parentNode.parentNode, 'bookmarksTree');">
onclick="clicked(event, event.target.parentNode.parentNode)">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">

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

@ -26,6 +26,12 @@
*/
function debug(msg)
{
// uncomment for noise
//dump(msg);
}
// The content window that we're supposed to be observing.
var ContentWindow = window.content;
@ -36,7 +42,7 @@ Handler = Handler.QueryInterface(Components.interfaces.nsIRelatedLinksHandler);
// Our observer object
var Observer = {
Observe: function(subject, topic, data) {
// dump("Observer.Observe(" + subject + ", " + topic + ", " + data + ")\n");
// debug("Observer.Observe(" + subject + ", " + topic + ", " + data + ")\n");
if (subject != ContentWindow)
return;
@ -93,7 +99,7 @@ function refetchRelatedLinks(Handler, data)
if (theOffset >= 0) currentSite = currentSite.substr(0, theOffset );
}
dump("Related Links: Current top-level: " + currentSite + " new top-level: " + newSite + "\n");
debug("Related Links: Current top-level: " + currentSite + " new top-level: " + newSite + "\n");
// only request new related links data if we've got a new web site (hostname change)
if (currentSite != newSite)
@ -123,23 +129,35 @@ function Init()
// Install the observer so we'll be notified when new content is loaded.
var ObserverService = Components.classes["component://netscape/observer-service"].getService();
ObserverService = ObserverService.QueryInterface(Components.interfaces.nsIObserverService);
dump("got observer service\n");
debug("got observer service\n");
ObserverService.AddObserver(Observer, "EndDocumentLoad");
dump("added observer\n");
debug("added observer\n");
}
function clicked(event, target) {
if (target.getAttribute('container') == 'true') {
if (target.getAttribute('open') == 'true') {
target.removeAttribute('open');
} else {
target.setAttribute('open','true');
// First, see if they're opening the related links node. If so,
// we'll need to go out and fetch related links _now_.
if (target.getAttribute('id') == 'NC:RelatedLinks') {
refetchRelatedLinks(Handler, ContentWindow.location);
return;
}
}
} else {
if (event.clickCount == 2) {
openURL(target, 'Tree');
}
}
}
function openURL(treeitem, root)
{
// First, see if they're opening the related links node. If so,
// we'll need to go out and fetch related links _now_.
if (treeitem.getAttribute('id') == 'NC:RelatedLinks' &&
treeitem.getAttribute('open') == 'true') {
refetchRelatedLinks(Handler, ContentWindow.location);
return;
}
// Next, check to see if it's a container. If so, then just let
// the tree do its open and close stuff.

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

@ -44,7 +44,7 @@
<tree id="Tree"
style="width: 100%; height: 100%"
datasources="rdf:internetsearch"
onclick="if (event.clickCount == 2) return openURL(event.target.parentNode.parentNode, 'Tree')">
onclick="clicked(event,event.target.parentNode.parentNode)">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
@ -61,7 +61,7 @@
<rule>
<treechildren>
<treeitem uri="..."
<treeitem uri="..." persist="open"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
<treerow>

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

@ -0,0 +1,39 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Stephen Lamm <slamm@netscape.com>
*/
/*
Code for the Bookmarks Sidebar Panel
*/
function clicked(event, target) {
if (target.getAttribute('container') == 'true') {
if (target.getAttribute('open') == 'true') {
target.removeAttribute('open');
} else {
target.setAttribute('open','true');
}
} else {
if (event.clickCount == 2) {
top.OpenBookmarkURL(target, 'bookmarksTree');
}
}
}

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

@ -22,7 +22,6 @@
-->
<!-- <?xml-stylesheet href="chrome://sidebar/skin/" type="text/css"?> -->
<?xml-stylesheet href="chrome://bookmarks/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://bookmarks/skin/bm-panel.css" type="text/css"?>
@ -32,6 +31,8 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical">
<html:script src="chrome://bookmarks/content/bm-panel.js" />
<html:div style="width:100px;height:100px" flex="1">
<popup id="contextual" oncreate="return fillContextMenu('contextual');" >
@ -41,7 +42,7 @@
<tree id="bookmarksTree" context="contextual" ref="NC:BookmarksRoot"
style="height: 100%; width:100%;"
datasources="rdf:bookmarks rdf:files rdf:localsearch rdf:internetsearch"
onclick="if (event.clickCount == 2) return top.OpenBookmarkURL(event.target.parentNode.parentNode, 'bookmarksTree');">
onclick="clicked(event, event.target.parentNode.parentNode)">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">

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

@ -26,6 +26,12 @@
*/
function debug(msg)
{
// uncomment for noise
//dump(msg);
}
// The content window that we're supposed to be observing.
var ContentWindow = window.content;
@ -36,7 +42,7 @@ Handler = Handler.QueryInterface(Components.interfaces.nsIRelatedLinksHandler);
// Our observer object
var Observer = {
Observe: function(subject, topic, data) {
// dump("Observer.Observe(" + subject + ", " + topic + ", " + data + ")\n");
// debug("Observer.Observe(" + subject + ", " + topic + ", " + data + ")\n");
if (subject != ContentWindow)
return;
@ -93,7 +99,7 @@ function refetchRelatedLinks(Handler, data)
if (theOffset >= 0) currentSite = currentSite.substr(0, theOffset );
}
dump("Related Links: Current top-level: " + currentSite + " new top-level: " + newSite + "\n");
debug("Related Links: Current top-level: " + currentSite + " new top-level: " + newSite + "\n");
// only request new related links data if we've got a new web site (hostname change)
if (currentSite != newSite)
@ -123,23 +129,35 @@ function Init()
// Install the observer so we'll be notified when new content is loaded.
var ObserverService = Components.classes["component://netscape/observer-service"].getService();
ObserverService = ObserverService.QueryInterface(Components.interfaces.nsIObserverService);
dump("got observer service\n");
debug("got observer service\n");
ObserverService.AddObserver(Observer, "EndDocumentLoad");
dump("added observer\n");
debug("added observer\n");
}
function clicked(event, target) {
if (target.getAttribute('container') == 'true') {
if (target.getAttribute('open') == 'true') {
target.removeAttribute('open');
} else {
target.setAttribute('open','true');
// First, see if they're opening the related links node. If so,
// we'll need to go out and fetch related links _now_.
if (target.getAttribute('id') == 'NC:RelatedLinks') {
refetchRelatedLinks(Handler, ContentWindow.location);
return;
}
}
} else {
if (event.clickCount == 2) {
openURL(target, 'Tree');
}
}
}
function openURL(treeitem, root)
{
// First, see if they're opening the related links node. If so,
// we'll need to go out and fetch related links _now_.
if (treeitem.getAttribute('id') == 'NC:RelatedLinks' &&
treeitem.getAttribute('open') == 'true') {
refetchRelatedLinks(Handler, ContentWindow.location);
return;
}
// Next, check to see if it's a container. If so, then just let
// the tree do its open and close stuff.

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

@ -44,7 +44,7 @@
<tree id="Tree"
style="width: 100%; height: 100%"
datasources="rdf:internetsearch"
onclick="if (event.clickCount == 2) return openURL(event.target.parentNode.parentNode, 'Tree')">
onclick="clicked(event,event.target.parentNode.parentNode)">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
@ -61,7 +61,7 @@
<rule>
<treechildren>
<treeitem uri="..."
<treeitem uri="..." persist="open"
loading="rdf:http://home.netscape.com/NC-rdf#loading"
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
<treerow>