www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f3f1c848cc9bb99d3a2d011a81b261a460a47c81
parent 3bd954e3da8528600f96733cddbbc00511c88e93
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun,  9 Aug 2009 23:57:01 +0000

Don't show Add and remove buttons for related items in read-only mode


Diffstat:
Mchrome/content/zotero/bindings/relatedbox.xml | 50++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/chrome/content/zotero/bindings/relatedbox.xml b/chrome/content/zotero/bindings/relatedbox.xml @@ -28,6 +28,35 @@ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <binding id="seealso-box"> <implementation> + <!-- Modes are predefined settings groups for particular tasks --> + <field name="_mode">"view"</field> + <property name="mode" onget="return this._mode;"> + <setter> + <![CDATA[ + this.clickable = false; + this.editable = false; + + switch (val) { + case 'view': + break; + + case 'edit': + this.clickable = true; + this.editable = true; + //this.clickHandler = this.showEditor; + //this.blurHandler = this.hideEditor; + break; + + default: + throw ("Invalid mode '" + val + "' in relatedbox.xml"); + } + + this._mode = val; + document.getAnonymousNodes(this)[0].setAttribute('mode', val); + ]]> + </setter> + </property> + <field name="itemRef"/> <property name="item" onget="return this.itemRef;"> <setter> @@ -60,6 +89,9 @@ <method name="reload"> <body> <![CDATA[ + var addButton = this.id('addButton'); + addButton.hidden = !this.editable; + var rows = this.id('seeAlsoRows'); while(rows.hasChildNodes()) rows.removeChild(rows.firstChild); @@ -106,13 +138,15 @@ box.setAttribute('flex','1'); box.appendChild(icon); box.appendChild(label); - - var remove = document.createElement("label"); - remove.setAttribute('value','-'); - remove.setAttribute('onclick', - "document.getBindingParent(this).remove('" + related[i].id + "');"); - remove.setAttribute('class','zotero-clicky'); - + + if (this.editable) { + var remove = document.createElement("label"); + remove.setAttribute('value','-'); + remove.setAttribute('onclick', + "document.getBindingParent(this).remove('" + related[i].id + "');"); + remove.setAttribute('class','zotero-clicky'); + } + var row = document.createElement("row"); row.appendChild(box); row.appendChild(remove); @@ -246,7 +280,7 @@ <xul:vbox xbl:inherits="flex"> <xul:hbox align="center"> <xul:label id="seeAlsoNum"/> - <xul:button label="&zotero.item.add;" oncommand="this.parentNode.parentNode.parentNode.add();"/> + <xul:button id="addButton" label="&zotero.item.add;" oncommand="this.parentNode.parentNode.parentNode.add();" hidden="true"/> </xul:hbox> <xul:grid flex="1"> <xul:columns>