704 lines
25 KiB
XML
704 lines
25 KiB
XML
<?xml version="1.0"?>
|
|
<!-- ***** BEGIN LICENSE BLOCK *****
|
|
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
-
|
|
- 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 the Initial Developer are Copyright (C) 2001
|
|
- the Initial Developer. All Rights Reserved.
|
|
-
|
|
- Contributor(s):
|
|
- Brian Ryner <bryner@netscape.com>
|
|
-
|
|
- Alternatively, the contents of this file may be used under the terms of
|
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- of those above. If you wish to allow use of your version of this file only
|
|
- under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- use your version of this file under the terms of the MPL, indicate your
|
|
- decision by deleting the provisions above and replace them with the notice
|
|
- and other provisions required by the LGPL or the GPL. If you do not delete
|
|
- the provisions above, a recipient may use your version of this file under
|
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
|
-
|
|
- ***** END LICENSE BLOCK ***** -->
|
|
|
|
<bindings id="selectBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<binding id="select-outlinerbody">
|
|
<implementation>
|
|
<field name="_lastSelectedRow">
|
|
-1
|
|
</field>
|
|
</implementation>
|
|
<handlers>
|
|
<!-- If there is no modifier key, we select on mousedown, not
|
|
click, so that drags work correctly. -->
|
|
<handler event="mousedown">
|
|
<![CDATA[
|
|
if (!event.ctrlKey && !event.shiftKey && !event.metaKey) {
|
|
var row = {};
|
|
var col = {};
|
|
var obj = {};
|
|
var select = this.parentNode.parentNode.parentNode;
|
|
var box = select.outlinerBoxObject;
|
|
var selection = box.selection;
|
|
box.getCellAt(event.clientX, event.clientY, row, col, obj);
|
|
|
|
// save off the last selected row
|
|
this._lastSelectedRow = row.value;
|
|
|
|
if (row.value == -1)
|
|
return;
|
|
|
|
if (!selection.isSelected(row.value)) {
|
|
selection.select(row.value);
|
|
select.selectElement.setOptionsSelectedByIndex(row.value, row.value,
|
|
true, true, false, false);
|
|
if ("onchange" in select)
|
|
select.onchange();
|
|
}
|
|
}
|
|
]]>
|
|
</handler>
|
|
|
|
<!-- On a click (up+down on the same item), deselect everything
|
|
except this item. -->
|
|
<handler event="click">
|
|
<![CDATA[
|
|
if (event.button != 0) return;
|
|
var row = {};
|
|
var col = {};
|
|
var obj = {};
|
|
var select = this.parentNode.parentNode.parentNode;
|
|
var box = select.outlinerBoxObject;
|
|
select = select.selectElement;
|
|
var selection = box.selection;
|
|
box.getCellAt(event.clientX, event.clientY, row, col, obj);
|
|
|
|
if (row.value == -1)
|
|
return;
|
|
|
|
var augment = event.ctrlKey || event.metaKey;
|
|
if (event.shiftKey) {
|
|
selection.rangedSelect(-1, row.value, augment);
|
|
var start = selection.shiftSelectPivot;
|
|
if (start == -1)
|
|
start = selection.currentIndex;
|
|
select.setOptionsSelectedByIndex(start, row.value, true, !augment, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
}
|
|
else if (augment) {
|
|
selection.toggleSelect(row.value);
|
|
select.setOptionsSelectedByIndex(row.value, row.value,
|
|
selection.isSelected(row.value), false, false, false);
|
|
selection.currentIndex = row.value;
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
}
|
|
else {
|
|
/* We want to deselect all the selected items except what was
|
|
clicked, UNLESS it was a right-click. We have to do this
|
|
in click rather than mousedown so that you can drag a
|
|
selected group of items */
|
|
|
|
// if the last row has changed in between the time we
|
|
// mousedown and the time we click, don't fire the select handler.
|
|
// see bug #92366
|
|
if (this._lastSelectedRow == row.value) {
|
|
selection.select(row.value);
|
|
select.setOptionsSelectedByIndex(row.value, row.value,
|
|
true, true, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
}
|
|
}
|
|
]]>
|
|
</handler>
|
|
|
|
</handlers>
|
|
</binding>
|
|
|
|
<binding id="select-size" extends="xul:outliner">
|
|
<content>
|
|
<xul:outlinercols class="select-outlinercols">
|
|
<xul:outlinercol class="select-outlinercol" flex="1"/>
|
|
</xul:outlinercols>
|
|
<xul:outlinerrows class="select-outlinerrows outliner-rows" flex="1">
|
|
<xul:hbox flex="1" class="outliner-bodybox">
|
|
<xul:outlinerchildren class="select-outlinerbody">
|
|
<children/>
|
|
</xul:outlinerchildren>
|
|
</xul:hbox>
|
|
<xul:scrollbar orient="vertical" class="outliner-scrollbar" collapsed="true"/>
|
|
</xul:outlinerrows>
|
|
</content>
|
|
|
|
<implementation>
|
|
<property name="outlinerBoxObject"
|
|
onget="return this.boxObject.QueryInterface(Components.interfaces.nsIOutlinerBoxObject);"
|
|
readonly="true"/>
|
|
<property name="selectElement"
|
|
onget="return this.QueryInterface(Components.interfaces.nsISelectElement);"
|
|
readonly="true"/>
|
|
<property name="currentIndex"
|
|
onget="return this.outlinerBoxObject.selection.currentIndex;"
|
|
onset="return this.outlinerBoxObject.selection.currentIndex=val;"/>
|
|
<property name="singleSelection"
|
|
onget="return this.getAttribute('seltype') == 'single'"
|
|
readonly="true"/>
|
|
<field name="selectionHead">
|
|
-1
|
|
</field>
|
|
<field name="selectionTail">
|
|
-1
|
|
</field>
|
|
</implementation>
|
|
|
|
<handlers>
|
|
<handler event="focus" action="this.outlinerBoxObject.focused = true;"/>
|
|
<handler event="blur" action="this.outlinerBoxObject.focused = false;"/>
|
|
|
|
<handler event="keypress" keycode="vk_up">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
if (c == -1 || c == 0)
|
|
return;
|
|
this.selectionHead = -1;
|
|
this.selectionTail = -1;
|
|
this.outlinerBoxObject.selection.timedSelect(c-1, 500);
|
|
this.outlinerBoxObject.ensureRowIsVisible(c-1);
|
|
this.selectElement.setOptionsSelectedByIndex(c-1, c-1, true, true, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_down">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
try { if (c+1 == this.outlinerBoxObject.view.rowCount)
|
|
return;
|
|
} catch (e) {}
|
|
this.selectionHead = -1;
|
|
this.selectionTail = -1;
|
|
this.outlinerBoxObject.selection.timedSelect(c+1, 500);
|
|
this.outlinerBoxObject.ensureRowIsVisible(c+1);
|
|
this.selectElement.setOptionsSelectedByIndex(c+1, c+1, true, true, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_up" modifiers="shift">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.singleSelection)
|
|
return;
|
|
var c = this.currentIndex;
|
|
if (c == -1 || c == 0)
|
|
return;
|
|
var selection = this.outlinerBoxObject.selection;
|
|
var select = this.selectElement;
|
|
if (c == this.selectionTail) {
|
|
if (this.selectionHead < this.selectionTail) {
|
|
selection.toggleSelect(c);
|
|
select.setOptionsSelectedByIndex(c, c, selection.isSelected(c),
|
|
false, false, false);
|
|
this.currentIndex = c - 1;
|
|
}
|
|
else {
|
|
selection.toggleSelect(c - 1);
|
|
select.setOptionsSelectedByIndex(c, c, true, false, false, false);
|
|
}
|
|
}
|
|
else {
|
|
selection.clearSelection();
|
|
this.selectionHead = c;
|
|
selection.rangedSelect(c, c - 1, true);
|
|
select.setOptionsSelectedByIndex(c, c-1, true, true, false, false);
|
|
}
|
|
this.selectionTail = c - 1;
|
|
this.outlinerBoxObject.ensureRowIsVisible(c - 1);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_down" modifiers="shift">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.singleSelection)
|
|
return;
|
|
var c = this.currentIndex;
|
|
try { if (c+1 == this.outlinerBoxObject.view.rowCount)
|
|
return;
|
|
} catch (e) {}
|
|
var selection = this.outlinerBoxObject.selection;
|
|
var select = this.selectElement;
|
|
if (c == this.selectionTail) {
|
|
if (this.selectionHead > this.selectionTail) {
|
|
selection.toggleSelect(c);
|
|
select.setOptionsSelectedByIndex(c, c, selection.isSelected(c), false, false, false);
|
|
this.currentIndex = c + 1;
|
|
}
|
|
else {
|
|
selection.toggleSelect(c + 1);
|
|
select.setOptionsSelectedByIndex(c+1, c+1, selection.isSelected(c), false, false, false);
|
|
}
|
|
}
|
|
else {
|
|
selection.clearSelection();
|
|
this.selectionHead = c;
|
|
selection.rangedSelect(c, c + 1, true);
|
|
select.setOptionsSelectedByIndex(c, c+1, true, true, false, false);
|
|
}
|
|
this.selectionTail = c + 1;
|
|
this.outlinerBoxObject.ensureRowIsVisible(c + 1);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_up" modifiers="control">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
if (c == -1 || c == 0)
|
|
return;
|
|
this.currentIndex = c-1;
|
|
this.outlinerBoxObject.ensureRowIsVisible(c-1);
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_down" modifiers="control">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
try { if (c+1 == this.outlinerBoxObject.view.rowCount)
|
|
return;
|
|
} catch (e) {}
|
|
this.currentIndex = c+1;
|
|
this.outlinerBoxObject.ensureRowIsVisible(c+1);
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_page_up">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
if (c == 0)
|
|
return;
|
|
this.selectionHead = -1;
|
|
this.selectionTail = -1;
|
|
var f = this.outlinerBoxObject.getFirstVisibleRow();
|
|
var i = 0;
|
|
if (f > 0) {
|
|
var p = this.outlinerBoxObject.getPageCount();
|
|
if (f - p >= 0)
|
|
i = c - p;
|
|
else
|
|
i = c - f;
|
|
this.outlinerBoxObject.scrollByPages(-1);
|
|
}
|
|
this.outlinerBoxObject.selection.timedSelect(i, 500);
|
|
this.selectElement.setOptionsSelectedByIndex(i, i, true, true, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_page_down">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
var l = this.outlinerBoxObject.view.rowCount - 1;
|
|
if (c == l)
|
|
return;
|
|
this.selectionHead = -1;
|
|
this.selectionTail = -1;
|
|
var f = this.outlinerBoxObject.getFirstVisibleRow();
|
|
var p = this.outlinerBoxObject.getPageCount();
|
|
var i = l;
|
|
var lastTopRowIndex = l - p;
|
|
if (f <= lastTopRowIndex) {
|
|
if (f + p <= lastTopRowIndex)
|
|
i = c + p;
|
|
else
|
|
i = lastTopRowIndex + c - f + 1;
|
|
this.outlinerBoxObject.scrollByPages(1);
|
|
}
|
|
this.outlinerBoxObject.selection.timedSelect(i, 500);
|
|
this.selectElement.setOptionsSelectdByIndex(i, i, true, true, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_page_up" modifiers="shift">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.singleSelection)
|
|
return;
|
|
var c = this.currentIndex;
|
|
if (c == 0)
|
|
return;
|
|
var box = this.outlinerBoxObject;
|
|
var selection = box.selection;
|
|
var select = this.selectElement;
|
|
var f = box.getFirstVisibleRow();
|
|
var i = 0;
|
|
if (f > 0) {
|
|
var p = box.getPageCount();
|
|
if (f - p >= 0)
|
|
i = c - p;
|
|
else
|
|
i = c - f;
|
|
box.scrollByPages(-1);
|
|
}
|
|
if (c == this.selectionTail) {
|
|
if (this.selectionHead < this.selectionTail) {
|
|
if (i < this.selectionHead) {
|
|
selection.clearRange(c, this.selectionHead + 1);
|
|
selection.rangedSelect(this.selectionHead - 1, i, true);
|
|
select.setOptionsSelectedByIndex(c, this.selectionHead + 1, false, false, false, false);
|
|
select.setOptionsSelectedByIndex(this.selectionHead - 1, i, true, false, false, false);
|
|
}
|
|
else {
|
|
selection.clearRange(c, i + 1);
|
|
select.setOptionsSelectedByIndex(c, i+1, false, false, false, false);
|
|
this.currentIndex = i;
|
|
}
|
|
}
|
|
else {
|
|
selection.rangedSelect(c - 1, i, true);
|
|
select.setOptionsSelectedByIndex(c-1, i, true, false, false, false);
|
|
}
|
|
}
|
|
else {
|
|
selection.clearSelection();
|
|
this.selectionHead = c;
|
|
selection.rangedSelect(c, i, true);
|
|
select.setOptionsSelectedByIndex(c, i, true, true, false, false);
|
|
}
|
|
this.selectionTail = i;
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_page_down" modifiers="shift">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.singleSelection)
|
|
return;
|
|
var c = this.currentIndex;
|
|
var box = this.outlinerBoxObject;
|
|
var l = box.view.rowCount - 1;
|
|
if (c == l)
|
|
return;
|
|
var f = box.getFirstVisibleRow();
|
|
var p = box.getPageCount();
|
|
var i = l;
|
|
var lastTopRowIndex = l - p;
|
|
if (f <= lastTopRowIndex) {
|
|
if (f + p <= lastTopRowIndex)
|
|
i = c + p;
|
|
else
|
|
i = lastTopRowIndex + c - f + 1;
|
|
box.scrollByPages(1);
|
|
}
|
|
var selection = box.selection;
|
|
var select = this.selectElement;
|
|
if (c == this.selectionTail) {
|
|
if (this.selectionHead > this.selectionTail) {
|
|
if (i > this.selectionHead) {
|
|
selection.clearRange(c, this.selectionHead - 1);
|
|
selection.rangedSelect(this.selectionHead + 1, i, true);
|
|
select.setOptionsSelectedByIndex(c, this.selectionHead - 1, false, false, false, false);
|
|
select.setOptionsSelectedByIndex(this.selectionHead + 1, i, true, false, false, false);
|
|
}
|
|
else {
|
|
selection.clearRange(c, i - 1);
|
|
select.setOptionsSelectedByIndex(c, i-1, false, false, false, false);
|
|
this.currentIndex = i;
|
|
}
|
|
}
|
|
else {
|
|
selection.rangedSelect(c + 1, i, true);
|
|
select.setOptionsSelectedByIndex(c+1, i, true, false, false, false);
|
|
}
|
|
}
|
|
else {
|
|
selection.clearSelection();
|
|
this.selectionHead = c;
|
|
selection.rangedSelect(c, i, true);
|
|
select.setOptionsSelectedByIndex(c, i, true, true, false, false);
|
|
}
|
|
this.selectionTail = i;
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_page_up" modifiers="control">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
if (c == 0)
|
|
return;
|
|
var f = this.outlinerBoxObject.getFirstVisibleRow();
|
|
var i = 0;
|
|
if (f > 0) {
|
|
var p = this.outlinerBoxObject.getPageCount();
|
|
if (f - p >= 0)
|
|
i = c - p;
|
|
else
|
|
i = c - f;
|
|
this.outlinerBoxObject.scrollByPages(-1);
|
|
}
|
|
this.currentIndex = i;
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_page_down" modifiers="control">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
var l = this.outlinerBoxObject.view.rowCount - 1;
|
|
if (c == l)
|
|
return;
|
|
var f = this.outlinerBoxObject.getFirstVisibleRow();
|
|
var p = this.outlinerBoxObject.getPageCount();
|
|
var i = l;
|
|
var lastTopRowIndex = l - p;
|
|
if (f <= lastTopRowIndex) {
|
|
if (f + p <= lastTopRowIndex)
|
|
i = c + p;
|
|
else
|
|
i = lastTopRowIndex + c - f + 1;
|
|
this.outlinerBoxObject.scrollByPages(1);
|
|
}
|
|
this.currentIndex = i;
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_home">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.currentIndex == 0)
|
|
return;
|
|
this.selectionHead = -1;
|
|
this.selectionTail = -1;
|
|
var box = this.outlinerBoxObject;
|
|
box.selection.timedSelect(0, 500);
|
|
this.selectElement.setOptionsSelectedByIndex(0, 0, true, true, false, false);
|
|
box.ensureRowIsVisible(0);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_end">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var box = this.outlinerBoxObject;
|
|
var l = box.view.rowCount - 1;
|
|
if (this.currentIndex == l)
|
|
return;
|
|
this.selectionHead = -1;
|
|
this.selectionTail = -1;
|
|
box.selection.timedSelect(l, 500);
|
|
this.selectElement.setOptionsSelectedByIndex(l, l, true, true, false, false);
|
|
box.ensureRowIsVisible(l);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_home" modifiers="shift">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.singleSelection)
|
|
return;
|
|
var c = this.currentIndex;
|
|
if (c == 0)
|
|
return;
|
|
var box = this.outlinerBoxObject;
|
|
var selection = box.selection;
|
|
var select = this.selectElement;
|
|
if (c != this.selectionTail) {
|
|
selection.clearSelection();
|
|
select.setOptionsSelectedByIndex(-1, -1, true, true, false, false);
|
|
this.selectionHead = c;
|
|
}
|
|
selection.rangedSelect(c, 0, true);
|
|
select.setOptionsSelectedByIndex(c, 0, true, false, false, false);
|
|
this.selectionTail = 0;
|
|
box.ensureRowIsVisible(0);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_end" modifiers="shift">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.singleSelection)
|
|
return;
|
|
var c = this.currentIndex;
|
|
var box = this.outlinerBoxObject;
|
|
var l = box.view.rowCount - 1;
|
|
if (c == l)
|
|
return;
|
|
var selection = box.selection;
|
|
var select = this.selectElement;
|
|
if (c != this.selectionTail) {
|
|
selection.clearSelection();
|
|
select.setOptionsSelectedByIndex(-1, -1, true, true, false, false);
|
|
this.selectionHead = c;
|
|
}
|
|
selection.rangedSelect(c, l, true);
|
|
select.setOptionsSelectedByIndex(c, l, true, false, false, false);
|
|
this.selectionTail = l;
|
|
box.ensureRowIsVisible(l);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_home" modifiers="control">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
if (this.currentIndex == 0)
|
|
return;
|
|
this.currentIndex = 0;
|
|
this.outlinerBoxObject.ensureRowIsVisible(0);
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress" keycode="vk_end" modifiers="control">
|
|
<![CDATA[
|
|
event.preventDefault();
|
|
var l = this.outlinerBoxObject.view.rowCount - 1;
|
|
if (this.currentIndex == l)
|
|
return;
|
|
this.currentIndex = l;
|
|
this.outlinerBoxObject.ensureRowIsVisible(l);
|
|
]]>
|
|
</handler>
|
|
<handler event="keypress">
|
|
<![CDATA[
|
|
if (event.keyCode == ' ') {
|
|
event.preventDefault();
|
|
var c = this.currentIndex;
|
|
var selection = this.outlinerBoxObject.selection;
|
|
if (!selection.isSelected(c)) {
|
|
selection.toggleSelect(c);
|
|
this.selectElement.setOptionsSelectedByIndex(c, c, true, false, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
}
|
|
}
|
|
]]>
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
<binding id="select-outlinerrows">
|
|
<handlers>
|
|
<handler event="underflow">
|
|
<![CDATA[
|
|
this.childNodes[1].collapsed = true;
|
|
event.preventBubble();
|
|
]]>
|
|
</handler>
|
|
<handler event="overflow">
|
|
<![CDATA[
|
|
this.childNodes[1].collapsed = false;
|
|
event.preventBubble();
|
|
]]>
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
<!-- select size=1 -->
|
|
|
|
<binding id="select" extends="xul:menu">
|
|
<implementation>
|
|
<property name="selectElement" readonly="true"
|
|
onget="return this.QueryInterface(Components.interfaces.nsISelectElement);"/>
|
|
<method name="updateLabel">
|
|
<body>
|
|
<![CDATA[
|
|
var selectedIndex = this.selectedIndex;
|
|
if (selectedIndex >= 0 && selectedIndex < this.childNodes.length) {
|
|
var item = this.childNodes[selectedIndex];
|
|
var newLabel = item.label;
|
|
if (!newLabel)
|
|
newLabel = item.text;
|
|
this.setAttribute('label', newLabel);
|
|
}
|
|
]]>
|
|
</body>
|
|
</method>
|
|
|
|
<constructor>
|
|
<![CDATA[
|
|
this.updateLabel();
|
|
]]>
|
|
</constructor>
|
|
</implementation>
|
|
<content sizetopopup="true">
|
|
<xul:hbox class="select-label-box" flex="1">
|
|
<xul:label flex="1" value=" " inherits="value=label"/>
|
|
</xul:hbox>
|
|
<xul:dropmarker class="select-dropmarker" type="menu"/>
|
|
<xul:menupopup style="display:-moz-popup!important">
|
|
<children/>
|
|
</xul:menupopup>
|
|
</content>
|
|
<handlers>
|
|
<handler event="command" phase="capturing">
|
|
<![CDATA[
|
|
if (event.originalTarget.localName != 'OPTION')
|
|
return;
|
|
|
|
// Notify the select element that the selected item has changed.
|
|
// It will then give us a selectedItemChanged event.
|
|
var itemIndex = 0;
|
|
for (itemIndex = 0; itemIndex < this.childNodes.length; ++itemIndex) {
|
|
if (this.childNodes[itemIndex] == event.originalTarget)
|
|
break;
|
|
}
|
|
|
|
if (itemIndex == this.childNodes.length) // not found
|
|
return;
|
|
|
|
if (itemIndex == this.selectedIndex) // nothing was changed
|
|
return;
|
|
|
|
this.selectElement.setOptionsSelectedByIndex(itemIndex, itemIndex, true,
|
|
true, false, false);
|
|
if ("onchange" in this)
|
|
this.onchange();
|
|
]]>
|
|
</handler>
|
|
|
|
<handler event="selectedItemChanged" action="this.updateLabel();"/>
|
|
</handlers>
|
|
</binding>
|
|
|
|
<binding id="select-option" extends="xul:menuitem">
|
|
<content>
|
|
<xul:label inherits="value=label" class="select-menuitem">
|
|
<children/>
|
|
</xul:label>
|
|
</content>
|
|
</binding>
|
|
|
|
</bindings>
|