treestyletab/content/treestyletab/group.xul
2010-02-01 04:26:33 +00:00

108 lines
2.7 KiB
XML

<?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
<?xml-stylesheet type="text/css" href="chrome://treestyletab/skin/group/group.css"?>
<!DOCTYPE page SYSTEM "chrome://treestyletab/locale/treestyletab.dtd">
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onclick="onClick(event)"
ondblclick="onDblClick(event)"
title="&group.default;">
<stack flex="1">
<box class="background-image-container">
<image class="icon background-image"/>
</box>
<vbox class="label-container" flex="1">
<deck id="deck">
<hbox align="center">
<image class="icon"/>
<label id="label"
flex="1"
crop="end"
value="&group.default;"
tooltiptext="&group.default;"/>
</hbox>
<hbox align="center">
<image class="icon"/>
<textbox id="editor"
flex="1"
onkeypress="onKeyPress(event)"
value="&group.default;"/>
</hbox>
</deck>
</vbox>
</stack>
<link xmlns="http://www.w3.org/1999/xhtml" rel="icon"
href="chrome://treestyletab/skin/group/group-icon"/>
<script type="application/javascript"><![CDATA[
var gIcon = document.getElementById('icon');
var gLabel = document.getElementById('label');
var gEdit = document.getElementById('editor');
var gDeck = document.getElementById('deck');
function trim(aString)
{
return aString.replace(/^\s+|\s+$/g, '');
}
var title = location.href.split('?')[1];
if (location.href.indexOf('?') > -1 && title) {
title = trim(decodeURIComponent(title));
document.title = title;
document.documentElement.setAttribute('title', title);
gLabel.value = title;
gLabel.setAttribute('tooltiptext', title);
gEdit.value = title;
}
function enterEdit()
{
gEdit.value = gLabel.value;
gDeck.selectedIndex = 1;
gEdit.focus();
}
function exitEdit()
{
if (gDeck.selectedIndex == 0) return;
var old = trim(gLabel.value);
var value = trim(gEdit.value);
document.title = gLabel.value = value;
gLabel.setAttribute('tooltiptext', value);
document.documentElement.setAttribute('title', value);
if (value != old)
location.replace(location.href.split('?')[0]+'?'+encodeURIComponent(value));
gEdit.blur();
gDeck.selectedIndex = 0;
}
function onClick(aEvent)
{
if (aEvent.target == gEdit) return;
if (aEvent.target == gLabel)
enterEdit();
else
exitEdit();
}
function onDblClick(aEvent)
{
if (aEvent.target == gEdit) return;
if (gDeck.selectedIndex == 0)
enterEdit();
else
exitEdit();
}
function onKeyPress(aEvent)
{
if (aEvent.keyCode == aEvent.DOM_VK_ENTER ||
aEvent.keyCode == aEvent.DOM_VK_RETURN ||
aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
exitEdit();
}
]]></script>
</page>