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
Родитель bf09e3f6d9
Коммит 2f3ecd7036
7 изменённых файлов: 62 добавлений и 89 удалений

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

@ -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 \

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

@ -1,56 +0,0 @@
/* -*- Mode: C; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
Style rules specific to the Customize dialog.
*/
#main-box {
padding: 1px;
}
div.title {
font: 4mm tahoma,arial,helvetica,sans-serif;
margin: 2px;
}
box.box-group {
padding: 2px;
}
box.button-group {
padding: 1mm;
}
#selectList {
width: 12em;
}
#tree {
width: 17em;
}
titledbutton.up {
list-style-image:url(resource:/res/rdf/list-up.gif);
}
titledbutton.down {
list-style-image:url(resource:/res/rdf/list-down.gif);
}

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

@ -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";

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

@ -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>

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

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

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

@ -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 \