Add disabled up/down buttons. Update selection on move up/down.

This commit is contained in:
slamm%netscape.com 1999-07-14 17:18:21 +00:00
parent 4984bea6a5
commit 2534879fc8
8 changed files with 70 additions and 46 deletions

View File

@ -50,7 +50,9 @@ FILES = \
folder-open.gif \
ignore-test.xul \
list-down.gif \
list-down-dis.gif \
list-up.gif \
list-up-dis.gif \
loading.gif \
online.gif \
sidebar.css \

View File

@ -50,7 +50,15 @@ titledbutton.up {
list-style-image:url(resource:/res/rdf/list-up.gif);
}
titledbutton.up[disabled="true"] {
list-style-image:url(resource:/res/rdf/list-up-dis.gif);
}
titledbutton.down {
list-style-image:url(resource:/res/rdf/list-down.gif);
}
titledbutton.down[disabled="true"] {
list-style-image:url(resource:/res/rdf/list-down-dis.gif);
}

View File

@ -57,6 +57,7 @@ function Init()
sideoption.appendChild(new_option);
}
}
enableUpDown();
}
function createOption(registry, service) {
@ -120,60 +121,83 @@ function Reload(url, pollInterval)
Schedule(url, pollInterval);
}
function selectChange() {
enableUpDown();
}
function moveUp() {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
dump('selected=' + list.selectedIndex + '\n');
if (list.selectedIndex > 0) {
var listOption = list.childNodes.item(listSelect).cloneNode(true);
var listOptionBefore = list.childNodes.item(listSelect-1);
list.remove(listSelect);
var index = list.selectedIndex;
if (index > 0) {
var listOption = list.childNodes.item(index).cloneNode(true);
var listOptionBefore = list.childNodes.item(index-1);
list.remove(index);
list.insertBefore(listOption, listOptionBefore);
dump("\n" + listOption + "\n");
list.selectedIndex = index - 1;
enableUpDown();
}
}
function moveDown() {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
dump('list\n' + listSelect);
dump('selected=' + list.selectedIndex + '\n');
if (list.selectedIndex != -1) {
var listOption = list.childNodes.item(listSelect);
var listOptionBefore = list.childNodes.item(listSelect+1).cloneNode(true);
list.remove(listSelect+1);
list.insertBefore(listOptionBefore, listOption);
var index = list.selectedIndex;
if (index != -1 &&
index != list.options.length - 1) {
var listOption = list.childNodes.item(index);
var listOptionAfter = list.childNodes.item(index+1).cloneNode(true);
list.remove(index+1);
list.insertBefore(listOptionAfter, listOption);
dump("\n" + listOption + "\n");
enableUpDown();
}
}
function enableUpDown() {
var up = document.getElementById('up');
var down = document.getElementById('down');
var list = document.getElementById('selectList');
var isFirst = list.selectedIndex == 0;
var isLast = list.selectedIndex == list.options.length - 1;
if (isFirst) {
up.setAttribute('disabled', 'true');
} else {
up.setAttribute('disabled', '');
}
if (isLast) {
down.setAttribute('disabled', 'true');
} else {
down.setAttribute('disabled', '');
}
}
function deleteOption()
{
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
dump("selected=" + list.selectedIndex +"\n");
if (list.selectedIndex != -1) {
var list = document.getElementById('selectList');
var listSelect = list.selectedIndex;
list.remove(listSelect);
var list = document.getElementById('selectList');
var index = list.selectedIndex;
if (index != -1) {
//list.remove(index);
// XXX prompt user
list.options[index] = null;
}
}
function DumpIt() {
var list = document.getElementById('selectList');
var listLen = list.childNodes.length;
var list = document.getElementById('selectList');
var listLen = list.childNodes.length;
for (var i=0;i<listLen; ++i) {
dump('length:' + listLen + '\n');
dump(list.childNodes.item(i).getAttribute('title') + '\n');
for (var i=0;i<listLen; ++i) {
dump('length:' + listLen + '\n');
dump(list.childNodes.item(i).getAttribute('title') + '\n');
writeRDF(list.childNodes.item(i).getAttribute('title'),list.childNodes.item(i).getAttribute('content'),list.childNodes.item(i).getAttribute('customize'),0);
}
writeRDF(list.childNodes.item(i).getAttribute('title'),list.childNodes.item(i).getAttribute('content'),list.childNodes.item(i).getAttribute('customize'),0);
}
}
function save() {
self.close();
}
self.close();
}
// Note that there is a bug with resource: URLs right now.
var FileURL = "file:///C:/matt/rdf/sidebar-browser.rdf";

View File

@ -23,13 +23,14 @@
<box align="vertical">
<spring flex="50%"/>
<titledbutton onclick="moveUp();" class="borderless up" />
<titledbutton onclick="moveDown();" class="borderless down" />
<titledbutton onclick="moveUp();" id="up" class="borderless up" />
<titledbutton onclick="moveDown();" id="down" class="borderless down" />
<spring flex="50%"/>
</box>
<html:form name="one" >
<html:select name="two" id="selectList" size="10">
<html:select name="two" id="selectList" size="10"
onchange="selectChange();">
</html:select>
</html:form>

View File

@ -1,13 +0,0 @@
<html>
<FRAMESET ROWS="50%,50%">
<FRAME SRC="dialogSidebar.xul">
<FRAME SRC="dialogWindow.xul">
</FRAMESET>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 B

View File

@ -45,7 +45,9 @@ FILES=\
folder-open.gif \
ignore-test.xul \
list-down.gif \
list-down-dis.gif \
list-up.gif \
list-up-dis.gif \
loading.gif \
online.gif \
sidebar.css \