Merge branch 'swapCreatorNames' into 3.1

Closes #132, Menu item to swap creator first/last names
Closes #163, Frank's patch: Menu item to swap creator first/last names
This commit is contained in:
Dan Stillman 2013-03-05 15:47:02 -05:00
commit a27d57d7b9
2 changed files with 36 additions and 1 deletions

View file

@ -741,6 +741,11 @@
if (creator.fieldMode) {
firstlast.lastChild.setAttribute('hidden', true);
}
if (this.editable) {
firstlast.setAttribute('contextmenu', 'zotero-creator-transform-menu');
}
this._tabIndexMaxCreators = Math.max(this._tabIndexMaxCreators, tabindex);
hbox.appendChild(firstlast);
@ -2214,6 +2219,21 @@
</method>
<method name="swapNames">
<body><![CDATA[
var row = Zotero.getAncestorByTagName(document.popupNode, 'row');
var typeBox = row.getElementsByAttribute('popup', 'creator-type-menu')[0];
var creatorIndex = parseInt(typeBox.getAttribute('fieldname').split('-')[1]);
var fields = this.getCreatorFields(row);
var lastName = fields.lastName;
var firstName = fields.firstName;
fields.lastName = firstName;
fields.firstName = lastName;
this.modifyCreator(creatorIndex, fields);
this.item.save();
]]></body>
</method>
<method name="moveCreator">
<parameter name="index"/>
<parameter name="moveUp"/>
@ -2481,7 +2501,21 @@
oncommand="document.getBindingParent(this).textTransform(document.popupNode, 'sentence')"/>
</menupopup>
</menu>
</menupopup>
</menupopup>
<menupopup id="zotero-creator-transform-menu"
onpopupshowing="var row = Zotero.getAncestorByTagName(document.popupNode, 'row');
var typeBox = row.getElementsByAttribute('popup', 'creator-type-menu')[0];
var index = parseInt(typeBox.getAttribute('fieldname').split('-')[1]);
var item = document.getBindingParent(this).item;
var exists = item.hasCreatorAt(index);
if (exists) {
var fieldMode = item.getCreator(index).ref.fieldMode;
}
var hideTransforms = !exists || !!fieldMode;
return !hideTransforms;">
<menuitem label="&zotero.item.creatorTransform.nameSwap;"
oncommand="document.getBindingParent(this).swapNames();"/>
</menupopup>
<zoteroguidancepanel id="zotero-author-guidance" about="authorMenu" position="after_end" x="-25"/>
</popupset>
<grid flex="1">

View file

@ -121,6 +121,7 @@
<!ENTITY zotero.item.textTransform "Transform Text">
<!ENTITY zotero.item.textTransform.titlecase "Title Case">
<!ENTITY zotero.item.textTransform.sentencecase "Sentence case">
<!ENTITY zotero.item.creatorTransform.nameSwap "Swap first/last names">
<!ENTITY zotero.toolbar.newNote "New Note">
<!ENTITY zotero.toolbar.note.standalone "New Standalone Note">