New sidebar ui. One panel open at a time. No bug (yet...). r=pavlov

This commit is contained in:
slamm%netscape.com 1999-10-26 05:46:00 +00:00
Родитель 187c666c05
Коммит b0a5a95a11
6 изменённых файлов: 164 добавлений и 304 удалений

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

@ -41,8 +41,7 @@ splitter#sidebar-splitter grippy:active {
/**/
box#sidebar-box
{
box#sidebar-box {
margin-top: 2px;
width: 200px;
min-height: 0px;
@ -52,26 +51,16 @@ box#sidebar-box
border-bottom: 8px solid #003366;
}
box#sidebar-box[hidden="true"]
{
box#sidebar-box[hidden="true"] {
display: none;
}
splitter#sidebar-splitter[hidden="true"]
{
splitter#sidebar-splitter[hidden="true"] {
display: none;
}
box#sidebar-panels
{
overflow: auto;
}
iframe.panel-frame
{
width: 100px;
height: 125px;
border: 0px;
iframe.panel-frame[collapsed="true"] {
display: none;
}
/*
@ -98,7 +87,7 @@ splitter.sidebar-main-header titledbutton:hover {
color: white;
}
splitter.panel-bar {
titledbutton.panel-bar {
padding: 0px;
border-top: 1px solid white;
background-color: #CCCCCC;
@ -107,75 +96,3 @@ splitter.panel-bar {
padding-right: 5px;
font-size: smaller;
}
splitter.panel-bar div {
margin: 2px;
}
splitter.panel-bar titledbutton {
padding: 0px;
}
splitter > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-collapse.gif);
}
splitter[state="collapsed"] > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-expand.gif);
}
/*
* Alerts
*/
splitter#alerts-splitter
{
color: #CCFFFF;
background-color: #003366;
}
splitter#alerts-splitter > div
{
font-weight: bold;
padding-left: 5px;
padding-top: 2px;
padding-bottom: 3px;
}
box#alerts-panel
{
min-width:5px;
}
box#alerts-panel > div
{
width:10px;
height:50px;
}
box#alerts-panel > div > tree
{
width: 100%;
height: 100%;
}
treeitem[type="http://www.mozilla.org/RDF#TinderboxFlash"] > treerow > treecell > titledbutton
{
list-style-image: url("chrome://sidebar/skin/flames.gif");
}
treeitem[type="http://home.netscape.com/NC-rdf#MsgNewMessages"] > treerow > treecell > titledbutton
{
list-style-image: url("chrome://messenger/skin/folder-hasmail.gif");
}
treeitem[type="http://www.mozilla.org/rdf#XPInstallNotification"] > treerow > treecell > titledbutton
{
list-style-image: url("resource:/res/xpinstall/notification.gif");
}

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

@ -51,6 +51,8 @@ function sidebarOverlayInit()
else {
// XXX What we should _really_ do here is copy the default panels
// into the profile directory and then try again.
sidebar.db = 'chrome://sidebar/content/default-panels.rdf'
debug("using " + sidebar.db + " because " + sidebar_url.URLString + " does not exist\n");
}
@ -79,20 +81,63 @@ function sidebarOverlayInit()
// XXX This is a hack to force re-display
panels.setAttribute('ref', 'urn:sidebar:current-panel-list');
sidebarOpenDefaultPanel(1, 0);
}
function sidebarOpenClosePanel(splitter) {
var state = splitter.getAttribute("state")
var resizeafter = splitter.getAttribute("resizeafter")
var hasOlderSibling = splitter.previousSibling
function sidebarOpenDefaultPanel(wait, tries) {
var parent = document.getElementById('sidebar-panels');
var target = parent.getAttribute('open-panel-src');
var children = parent.childNodes;
if (!hasOlderSibling && resizeafter != 'grow') {
return
debug("~~~~~~~~~~~opening default panel\n");
if (children.length < 3) {
debug("~~~~~~~~~~~not enough kids yet\n");
if (tries < 5) {
// No children yet, try again later
setTimeout('sidebarOpenDefaultPanel('+(wait*2+1)+','+(tries+1)+')',wait);
}
return;
}
if (state == "" || state == "open") {
splitter.setAttribute("state", "collapsed")
} else {
splitter.setAttribute("state", "")
for (var ii=0; ii < children.length; ii++) {
debug("~~ child " + ii + "\n");
dumpAttributes(children.item(ii));
}
if (target && target != '') {
for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('src') == target) {
children.item(ii).removeAttribute('collapsed');
return;
}
}
}
// Pick the first one
debug("~~~~~~~~~~~picking first one\n");
var first_iframe = children.item(2);
if (first_iframe) {
first_iframe.removeAttribute('collapsed');
parent.setAttribute('open-panel-src',first_iframe.getAttribute('src'));
}
}
function sidebarOpenClosePanel(titledbutton) {
var target = titledbutton.getAttribute('iframe-src');
var last_src = titledbutton.parentNode.getAttribute('open-panel-src');
var children = titledbutton.parentNode.childNodes;
if (target == last_src) {
return;
}
for (var ii=0; ii < children.length; ii++) {
var src = children.item(ii).getAttribute('src')
if (src == target) {
children.item(ii).removeAttribute('collapsed');
titledbutton.parentNode.setAttribute('open-panel-src',target);
}
if (src == last_src) {
children.item(ii).setAttribute('collapsed','true');
}
}
}
@ -102,7 +147,7 @@ function sidebarReload() {
function sidebarCustomize() {
var newWin = window.openDialog('chrome://sidebar/content/customize.xul',
'New','chrome',
'_blank','chrome,modal',
sidebar.db, sidebar.resource)
return newWin
}
@ -116,7 +161,7 @@ function sidebarShowHide() {
debug("Showing the sidebar\n")
sidebar.setAttribute('hidden','')
sidebar_splitter.setAttribute('hidden','')
sidebarOverlayInit()
//sidebarOverlayInit()
} else {
debug("Hiding the sidebar\n")
sidebar.setAttribute('hidden','true')
@ -128,7 +173,7 @@ function dumpAttributes(node) {
var attributes = node.attributes
if (!attributes || attributes.length == 0) {
debug("no attributes")
debug("no attributes\n")
}
for (var ii=0; ii < attributes.length; ii++) {
var attr = attributes.item(ii)

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

@ -21,66 +21,29 @@
onclick="sidebarCustomize();" />
</splitter>
<box id="sidebar-panels" align="vertical" flex="100%"
<box id="sidebar-panels" align="vertical" flex="1*"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:current-panel-list">
ref="urn:sidebar:current-panel-list"
persist='open-panel-src'>
<template>
<rule>
<splitter class="panel-bar" uri="rdf:*"
collapse="after" resizeafter="grow" persist="state">
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar plain"/>
<spring flex="100%"/>
<titledbutton class="borderless show-hide"
onclick="sidebarOpenClosePanel(this.parentNode)"/>
</splitter>
<html:iframe class="panel-frame" uri="rdf:*" persist="height"
src="rdf:http://home.netscape.com/NC-rdf#content"/>
<titledbutton uri="rdf:*" align="left"
value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar borderless"
onclick="sidebarOpenClosePanel(this)"
iframe-src="rdf:http://home.netscape.com/NC-rdf#content" />
<html:iframe uri="rdf:*"
src="rdf:http://home.netscape.com/NC-rdf#content"
class="panel-frame" collapsed='true' flex='1*'/>
</rule>
</template>
</box>
<splitter id="alerts-splitter" class="sidebar-main-header" persist="state"
collapse="after" chromeclass="extrachrome"
onclick="sidebarOpenClosePanel(this)">
<html:div class="panel-bar">
&sidebar.alerts.label;
</html:div>
</splitter>
<box id="alerts-panel" align="vertical" chromeclass="extrachrome"
persist="height">
<html:div flex="1">
<tree id="flash-tree"
ref="NC:FlashRoot"
datasources="rdf:null"
rdf:containment="http://home.netscape.com/NC-rdf#child"
onclick="OpenURL(event.target.parentNode.parentNode);">
<template>
<treechildren>
<treeitem uri="rdf:*"
type="rdf:http://home.netscape.com/NC-rdf#type">
<treerow>
<treecell indent="true" align="left"
value="rdf:http://home.netscape.com/NC-rdf#description"/>
</treerow>
</treeitem>
</treechildren>
</template>
</tree>
</html:div>
</box>
</box>
<!-- Splitter on the right of sidebar -->
<splitter id="sidebar-splitter" collapse="before" persist="state hidden"
chromeclass="extrachrome" onclick="sidebarSaveState(this)">
<!-- Scripts go last, because they peek at state to tweak menus -->
<html:script language="JavaScript"
src="chrome://sidebar/content/sidebarOverlay.js"/>
<html:script language="JavaScript" src="chrome://sidebar/content/flash.js"/>
chromeclass="extrachrome" onclick="dumpStats();">
<box id="topright-cap" align="vertical">
<spring flex="100%"/>
</box>
@ -91,5 +54,10 @@
<spring flex="100%"/>
</box>
</splitter>
<!-- Scripts go last, because they peek at state to tweak menus -->
<html:script language="JavaScript"
src="chrome://sidebar/content/sidebarOverlay.js"/>
</overlay>

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

@ -41,8 +41,7 @@ splitter#sidebar-splitter grippy:active {
/**/
box#sidebar-box
{
box#sidebar-box {
margin-top: 2px;
width: 200px;
min-height: 0px;
@ -52,26 +51,16 @@ box#sidebar-box
border-bottom: 8px solid #003366;
}
box#sidebar-box[hidden="true"]
{
box#sidebar-box[hidden="true"] {
display: none;
}
splitter#sidebar-splitter[hidden="true"]
{
splitter#sidebar-splitter[hidden="true"] {
display: none;
}
box#sidebar-panels
{
overflow: auto;
}
iframe.panel-frame
{
width: 100px;
height: 125px;
border: 0px;
iframe.panel-frame[collapsed="true"] {
display: none;
}
/*
@ -98,7 +87,7 @@ splitter.sidebar-main-header titledbutton:hover {
color: white;
}
splitter.panel-bar {
titledbutton.panel-bar {
padding: 0px;
border-top: 1px solid white;
background-color: #CCCCCC;
@ -107,75 +96,3 @@ splitter.panel-bar {
padding-right: 5px;
font-size: smaller;
}
splitter.panel-bar div {
margin: 2px;
}
splitter.panel-bar titledbutton {
padding: 0px;
}
splitter > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-collapse.gif);
}
splitter[state="collapsed"] > titledbutton.show-hide
{
padding: 0px;
margin: 0px;
list-style-image:url(chrome://sidebar/skin/panel-expand.gif);
}
/*
* Alerts
*/
splitter#alerts-splitter
{
color: #CCFFFF;
background-color: #003366;
}
splitter#alerts-splitter > div
{
font-weight: bold;
padding-left: 5px;
padding-top: 2px;
padding-bottom: 3px;
}
box#alerts-panel
{
min-width:5px;
}
box#alerts-panel > div
{
width:10px;
height:50px;
}
box#alerts-panel > div > tree
{
width: 100%;
height: 100%;
}
treeitem[type="http://www.mozilla.org/RDF#TinderboxFlash"] > treerow > treecell > titledbutton
{
list-style-image: url("chrome://sidebar/skin/flames.gif");
}
treeitem[type="http://home.netscape.com/NC-rdf#MsgNewMessages"] > treerow > treecell > titledbutton
{
list-style-image: url("chrome://messenger/skin/folder-hasmail.gif");
}
treeitem[type="http://www.mozilla.org/rdf#XPInstallNotification"] > treerow > treecell > titledbutton
{
list-style-image: url("resource:/res/xpinstall/notification.gif");
}

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

@ -51,6 +51,8 @@ function sidebarOverlayInit()
else {
// XXX What we should _really_ do here is copy the default panels
// into the profile directory and then try again.
sidebar.db = 'chrome://sidebar/content/default-panels.rdf'
debug("using " + sidebar.db + " because " + sidebar_url.URLString + " does not exist\n");
}
@ -79,20 +81,63 @@ function sidebarOverlayInit()
// XXX This is a hack to force re-display
panels.setAttribute('ref', 'urn:sidebar:current-panel-list');
sidebarOpenDefaultPanel(1, 0);
}
function sidebarOpenClosePanel(splitter) {
var state = splitter.getAttribute("state")
var resizeafter = splitter.getAttribute("resizeafter")
var hasOlderSibling = splitter.previousSibling
function sidebarOpenDefaultPanel(wait, tries) {
var parent = document.getElementById('sidebar-panels');
var target = parent.getAttribute('open-panel-src');
var children = parent.childNodes;
if (!hasOlderSibling && resizeafter != 'grow') {
return
debug("~~~~~~~~~~~opening default panel\n");
if (children.length < 3) {
debug("~~~~~~~~~~~not enough kids yet\n");
if (tries < 5) {
// No children yet, try again later
setTimeout('sidebarOpenDefaultPanel('+(wait*2+1)+','+(tries+1)+')',wait);
}
return;
}
if (state == "" || state == "open") {
splitter.setAttribute("state", "collapsed")
} else {
splitter.setAttribute("state", "")
for (var ii=0; ii < children.length; ii++) {
debug("~~ child " + ii + "\n");
dumpAttributes(children.item(ii));
}
if (target && target != '') {
for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('src') == target) {
children.item(ii).removeAttribute('collapsed');
return;
}
}
}
// Pick the first one
debug("~~~~~~~~~~~picking first one\n");
var first_iframe = children.item(2);
if (first_iframe) {
first_iframe.removeAttribute('collapsed');
parent.setAttribute('open-panel-src',first_iframe.getAttribute('src'));
}
}
function sidebarOpenClosePanel(titledbutton) {
var target = titledbutton.getAttribute('iframe-src');
var last_src = titledbutton.parentNode.getAttribute('open-panel-src');
var children = titledbutton.parentNode.childNodes;
if (target == last_src) {
return;
}
for (var ii=0; ii < children.length; ii++) {
var src = children.item(ii).getAttribute('src')
if (src == target) {
children.item(ii).removeAttribute('collapsed');
titledbutton.parentNode.setAttribute('open-panel-src',target);
}
if (src == last_src) {
children.item(ii).setAttribute('collapsed','true');
}
}
}
@ -102,7 +147,7 @@ function sidebarReload() {
function sidebarCustomize() {
var newWin = window.openDialog('chrome://sidebar/content/customize.xul',
'New','chrome',
'_blank','chrome,modal',
sidebar.db, sidebar.resource)
return newWin
}
@ -116,7 +161,7 @@ function sidebarShowHide() {
debug("Showing the sidebar\n")
sidebar.setAttribute('hidden','')
sidebar_splitter.setAttribute('hidden','')
sidebarOverlayInit()
//sidebarOverlayInit()
} else {
debug("Hiding the sidebar\n")
sidebar.setAttribute('hidden','true')
@ -128,7 +173,7 @@ function dumpAttributes(node) {
var attributes = node.attributes
if (!attributes || attributes.length == 0) {
debug("no attributes")
debug("no attributes\n")
}
for (var ii=0; ii < attributes.length; ii++) {
var attr = attributes.item(ii)

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

@ -21,66 +21,29 @@
onclick="sidebarCustomize();" />
</splitter>
<box id="sidebar-panels" align="vertical" flex="100%"
<box id="sidebar-panels" align="vertical" flex="1*"
datasources="chrome://sidebar/content/local-panels.rdf
chrome://sidebar/content/remote-panels.rdf"
ref="urn:sidebar:current-panel-list">
ref="urn:sidebar:current-panel-list"
persist='open-panel-src'>
<template>
<rule>
<splitter class="panel-bar" uri="rdf:*"
collapse="after" resizeafter="grow" persist="state">
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar plain"/>
<spring flex="100%"/>
<titledbutton class="borderless show-hide"
onclick="sidebarOpenClosePanel(this.parentNode)"/>
</splitter>
<html:iframe class="panel-frame" uri="rdf:*" persist="height"
src="rdf:http://home.netscape.com/NC-rdf#content"/>
<titledbutton uri="rdf:*" align="left"
value="rdf:http://home.netscape.com/NC-rdf#title"
class="panel-bar borderless"
onclick="sidebarOpenClosePanel(this)"
iframe-src="rdf:http://home.netscape.com/NC-rdf#content" />
<html:iframe uri="rdf:*"
src="rdf:http://home.netscape.com/NC-rdf#content"
class="panel-frame" collapsed='true' flex='1*'/>
</rule>
</template>
</box>
<splitter id="alerts-splitter" class="sidebar-main-header" persist="state"
collapse="after" chromeclass="extrachrome"
onclick="sidebarOpenClosePanel(this)">
<html:div class="panel-bar">
&sidebar.alerts.label;
</html:div>
</splitter>
<box id="alerts-panel" align="vertical" chromeclass="extrachrome"
persist="height">
<html:div flex="1">
<tree id="flash-tree"
ref="NC:FlashRoot"
datasources="rdf:null"
rdf:containment="http://home.netscape.com/NC-rdf#child"
onclick="OpenURL(event.target.parentNode.parentNode);">
<template>
<treechildren>
<treeitem uri="rdf:*"
type="rdf:http://home.netscape.com/NC-rdf#type">
<treerow>
<treecell indent="true" align="left"
value="rdf:http://home.netscape.com/NC-rdf#description"/>
</treerow>
</treeitem>
</treechildren>
</template>
</tree>
</html:div>
</box>
</box>
<!-- Splitter on the right of sidebar -->
<splitter id="sidebar-splitter" collapse="before" persist="state hidden"
chromeclass="extrachrome" onclick="sidebarSaveState(this)">
<!-- Scripts go last, because they peek at state to tweak menus -->
<html:script language="JavaScript"
src="chrome://sidebar/content/sidebarOverlay.js"/>
<html:script language="JavaScript" src="chrome://sidebar/content/flash.js"/>
chromeclass="extrachrome" onclick="dumpStats();">
<box id="topright-cap" align="vertical">
<spring flex="100%"/>
</box>
@ -91,5 +54,10 @@
<spring flex="100%"/>
</box>
</splitter>
<!-- Scripts go last, because they peek at state to tweak menus -->
<html:script language="JavaScript"
src="chrome://sidebar/content/sidebarOverlay.js"/>
</overlay>