www

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

commit a921c57d5d220190d986eef7a279ea93cca093e1
parent f932f312ebbc08559b62e90a469781eea4d78a77
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat,  9 Mar 2013 03:15:01 -0500

Remove old tags box code from itembox.xml

Diffstat:
Mchrome/content/zotero/bindings/itembox.xml | 266++++++++++++++++---------------------------------------------------------------
1 file changed, 54 insertions(+), 212 deletions(-)

diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml @@ -256,8 +256,7 @@ <field name="_tabIndexMinCreators" readonly="true">10</field> <field name="_tabIndexMaxCreators">0</field> <field name="_tabIndexMinFields" readonly="true">1000</field> - <field name="_tabIndexMaxInfoFields">0</field> - <field name="_tabIndexMaxTagsFields">0</field> + <field name="_tabIndexMaxFields">0</field> <property name="_defaultFirstName" onget="return '(' + Zotero.getString('pane.item.defaultFirstName') + ')'"/> @@ -364,7 +363,7 @@ // Start tabindex at 1001 after creators var tabindex = fieldIsClickable ? (i>0 ? this._tabIndexMinFields + i : 1) : 0; - this._tabIndexMaxInfoFields = Math.max(this._tabIndexMaxInfoFields, tabindex); + this._tabIndexMaxFields = Math.max(this._tabIndexMaxFields, tabindex); if (fieldIsClickable && !Zotero.Items.isPrimaryField(fieldName) @@ -568,7 +567,7 @@ // Move to next or previous field if (shift-)tab was pressed if (this._lastTabIndex && this._tabDirection) { - this._focusNextField('info', this._dynamicFields, this._lastTabIndex, this._tabDirection == -1); + this._focusNextField(this._dynamicFields, this._lastTabIndex, this._tabDirection == -1); } ]]> </body> @@ -1239,10 +1238,6 @@ valueText = Zotero.ItemTypes.getLocalizedString(valueText); break; - case 'tag': - this._tabIndexMaxTagsFields = Math.max(this._tabIndexMaxTagsFields, tabindex); - break; - // Convert dates from UTC case 'dateAdded': case 'dateModified': @@ -1371,11 +1366,6 @@ var value = c ? c.ref[creatorField] : ''; var itemID = this.item.id; } - else if (fieldName=='tag') { - var tagID = elem.parentNode.getAttribute('id').split('-')[1]; - var value = tagID ? Zotero.Tags.getName(tagID) : ''; - var itemID = Zotero.getAncestorByTagName(elem, 'tagsbox').item.id; - } else { var value = this.item.getField(fieldName); var itemID = this.item.id; @@ -1423,8 +1413,7 @@ else { // Add auto-complete for certain fields if (Zotero.ItemFields.isAutocompleteField(fieldName) - || fieldName == 'creator' - || fieldName == 'tag') { + || fieldName == 'creator') { t.setAttribute('type', 'autocomplete'); t.setAttribute('autocompletesearch', 'zotero'); var suffix = itemID ? itemID : ''; @@ -1556,24 +1545,14 @@ // DEBUG: what happens if this isn't present? event.preventDefault(); - if (fieldname == 'tag') - { - // If last tag row, create new one - var row = target.parentNode.parentNode; - if (row == row.parentNode.lastChild) - { - this._tabDirection = 1; - var lastTag = true; - } - } // Shift-enter adds new creator row - else if (fieldname.indexOf('creator-') == 0 && event.shiftKey) { + if (fieldname.indexOf('creator-') == 0 && event.shiftKey) { // Value hasn't changed if (target.getAttribute('value') == target.value) { Zotero.debug("Value hasn't changed"); // If + button is disabled, just focus next creator row if (Zotero.getAncestorByTagName(target, 'row').lastChild.lastChild.disabled) { - this._focusNextField('info', this._dynamicFields, this._lastTabIndex, false); + this._focusNextField(this._dynamicFields, this._lastTabIndex, false); } else { // TODO: should use current creator type @@ -1591,11 +1570,9 @@ focused.blur(); // Return focus to items pane - if (!lastTag) { - var tree = document.getElementById('zotero-items-tree'); - if (tree) { - tree.focus(); - } + var tree = document.getElementById('zotero-items-tree'); + if (tree) { + tree.focus(); } return false; @@ -1604,14 +1581,8 @@ // Reset field to original value target.value = target.getAttribute('value'); - var tagsbox = Zotero.getAncestorByTagName(focused, 'tagsbox'); - focused.blur(); - if (tagsbox) { - tagsbox.closePopup(); - } - // Return focus to items pane var tree = document.getElementById('zotero-items-tree'); if (tree) { @@ -1639,7 +1610,7 @@ <body> <![CDATA[ if (!event.shiftKey) { - this.focusFirstField('info'); + this.focusFirstField(); event.preventDefault(); } // Shift-tab @@ -1770,83 +1741,6 @@ ); } - // Tags - else if (fieldName=='tag') { - var tagsbox = Zotero.getAncestorByTagName(textbox, 'tagsbox'); - if (!tagsbox) - { - Zotero.debug('Tagsbox not found', 1); - return; - } - - var row = textbox.parentNode; - var rows = row.parentNode; - - // Tag id encoded as 'tag-1234' - var id = row.getAttribute('id').split('-')[1]; - - if (saveChanges) { - if (id) { - if (value) { - // If trying to replace with another existing tag - // (which causes a delete of the row), - // clear the tab direction so we don't advance - // when the notifier kicks in - var existing = Zotero.Tags.getID(value, 0); - if (existing && id != existing) - { - this._tabDirection = false; - } - var changed = tagsbox.replace(id, value); - if (changed) - { - return; - } - } - else { - tagsbox.remove(id); - return; - } - } - // New tag - else { - // If this is an existing automatic tag, it's going to be - // deleted and the number of rows will stay the same, - // so we have to compensate - var existingTypes = Zotero.Tags.getTypes(value); - if (existingTypes && existingTypes.indexOf(1) != -1) { - this._lastTabIndex--; - } - var id = tagsbox.add(value); - } - } - - if (id) { - elem = this.createValueElement( - value, - 'tag', - tabindex - ); - } - else { - // Just remove the row - // - // If there's an open popup, this throws NODE CANNOT BE FOUND - try { - var row = rows.removeChild(row); - } - catch (e) {} - tagsbox.fixPopup(); - tagsbox.closePopup(); - - this._tabDirection = false; - return; - } - - var focusMode = 'tags'; - var focusBox = tagsbox; - } - // Fields else { // Access date needs to be parsed and converted to UTC @@ -1932,11 +1826,8 @@ } if (this._tabDirection) { - if (!focusMode) { - var focusMode = 'info'; - var focusBox = this._dynamicFields; - } - this._focusNextField(focusMode, focusBox, this._lastTabIndex, this._tabDirection == -1); + var focusBox = this._dynamicFields; + this._focusNextField(focusBox, this._lastTabIndex, this._tabDirection == -1); } } // Thrown errors don't seem to show up within XBL without explicit logging @@ -2280,14 +2171,9 @@ <method name="focusFirstField"> - <parameter name="mode"/> <body> <![CDATA[ - switch (mode) { - case 'info': - this._focusNextField('info', this._dynamicFields, 0, false); - break; - } + this._focusNextField(this._dynamicFields, 0, false); ]]> </body> </method> @@ -2302,7 +2188,6 @@ completes, so it doesn't know where it's supposed to go next.) --> <method name="_focusNextField"> - <parameter name="mode"/> <parameter name="box"/> <parameter name="tabindex"/> <parameter name="back"/> @@ -2312,102 +2197,59 @@ if (back) { - if (mode=='info') + switch (tabindex) { - switch (tabindex) - { - case 1: - //Zotero.debug('At beginning'); - document.getElementById('item-type-menu').focus(); - return false; - - case this._tabIndexMinCreators: + case 1: + //Zotero.debug('At beginning'); + document.getElementById('item-type-menu').focus(); + return false; + + case this._tabIndexMinCreators: + var nextIndex = 1; // Title field + break; + + case this._tabIndexMinFields: + // No creators + if (this._tabIndexMaxCreators == 0) { var nextIndex = 1; // Title field - break; - - case this._tabIndexMinFields: - // No creators - if (this._tabIndexMaxCreators == 0) { - var nextIndex = 1; // Title field - } - else { - var nextIndex = this._tabIndexMaxCreators; - } - break; - - default: - var nextIndex = tabindex - 1; - } - } - else if (mode=='tags') - { - switch (tabindex) - { - case 1: - return false; - - default: - var nextIndex = tabindex - 1; - } + } + else { + var nextIndex = this._tabIndexMaxCreators; + } + break; + + default: + var nextIndex = tabindex - 1; } } else { - if (mode=='info') - { - switch (tabindex) - { - case 1: - var nextIndex = this._tabIndexMinCreators; - break; - - case this._tabIndexMaxCreators: - var nextIndex = this._tabIndexMinFields; - break; - - case this._tabIndexMaxInfoFields: - //Zotero.debug('At end'); - return false; - - default: - var nextIndex = tabindex + 1; - } - } - else if (mode=='tags') + switch (tabindex) { - switch (tabindex) - { - case this._tabIndexMaxTagsFields: - // In tags box, keep going to create new row - var nextIndex = tabindex + 1; - break; - - default: - var nextIndex = tabindex + 1; - } + case 1: + var nextIndex = this._tabIndexMinCreators; + break; + + case this._tabIndexMaxCreators: + var nextIndex = this._tabIndexMinFields; + break; + + case this._tabIndexMaxFields: + //Zotero.debug('At end'); + return false; + + default: + var nextIndex = tabindex + 1; } } Zotero.debug('Looking for tabindex ' + nextIndex, 4); - switch (mode) + + var next = box.getElementsByAttribute('ztabindex', nextIndex); + if (!next[0]) { - case 'info': - var next = box.getElementsByAttribute('ztabindex', nextIndex); - if (!next[0]) - { - //Zotero.debug("Next field not found"); - return this._focusNextField(mode, box, nextIndex, back); - } - break; - - // Tags pane - case 'tags': - var next = document.getAnonymousNodes(box)[0]. - getElementsByAttribute('ztabindex', nextIndex); - if (!next[0]) { - next[0] = box.addDynamicRow(); - } - break; + //Zotero.debug("Next field not found"); + return this._focusNextField(box, nextIndex, back); } next[0].click();