www

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

commit 47f57509e53216a1d2fc110f3c7c7dfb37135bec
parent c7e92b6e1607dcd3d294cc7bed71d6c8e2887aea
Author: Simon Kornblith <simon@simonster.com>
Date:   Fri, 11 Feb 2011 22:16:32 +0000

make column and position information persist between tab and overlay


Diffstat:
Mchrome/content/zotero/overlay.js | 2++
Mchrome/content/zotero/zoteroPane.js | 49++++++++++++++++++++++++++++++++++++++++++++++++-
Mchrome/content/zotero/zoteroPane.xul | 40++++++++++++++++++++--------------------
Mdefaults/preferences/zotero.js | 3+++
4 files changed, 73 insertions(+), 21 deletions(-)

diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -212,6 +212,8 @@ var ZoteroOverlay = new function() // Make sure tags splitter isn't missing for people upgrading from <2.0b7 document.getElementById('zotero-tags-splitter').collapsed = false; } else { + ZoteroPane.makeHidden(); + // Collapse pane zoteroPane.setAttribute('collapsed', true); zoteroPane.height = 0; diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -317,6 +317,8 @@ var ZoteroPane = new function() this.collectionsView.unregister(); if (this.itemsView) this.itemsView.unregister(); + + _serializePersist(); } /** @@ -344,6 +346,8 @@ var ZoteroPane = new function() return false; } + _unserializePersist(); + this.updateTagSelectorSize(); // Focus the quicksearch on pane open @@ -379,6 +383,12 @@ var ZoteroPane = new function() return true; } + /** + * Function to be called before ZoteroPane is hidden. Does not actually hide the Zotero pane. + */ + this.makeHidden = function() { + _serializePersist(); + } function isShowing() { var zoteroPane = document.getElementById('zotero-pane-stack'); @@ -3424,5 +3434,42 @@ var ZoteroPane = new function() } } } - + + /** + * Unserializes zotero-persist elements from preferences + */ + function _unserializePersist() { + var serializedValues = Zotero.Prefs.get("pane.persist"); + if(!serializedValues) return; + serializedValues = JSON.parse(serializedValues); + for(var id in serializedValues) { + var el = document.getElementById(id); + if(!el) return; + var elValues = serializedValues[id]; + for(var attr in elValues) { + el.setAttribute(attr, elValues[attr]); + } + } + + if(this.itemsView) this.itemsView.sort(); + } + + /** + * Serializes zotero-persist elements to preferences + */ + function _serializePersist() { + var serializedValues = {}; + for each(var el in document.getElementsByAttribute("zotero-persist", "*")) { + if(!el.getAttribute) continue; + var id = el.getAttribute("id"); + if(!id) continue; + var elValues = {}; + for each(var attr in el.getAttribute("zotero-persist").split(/[\s,]+/)) { + var attrValue = el.getAttribute(attr); + elValues[attr] = attrValue; + } + serializedValues[id] = elValues; + } + Zotero.Prefs.set("pane.persist", JSON.stringify(serializedValues)); + } } \ No newline at end of file diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul @@ -126,7 +126,7 @@ </menupopup> </popupset> - <vbox id="zotero-collections-pane" persist="width" flex="1"> + <vbox id="zotero-collections-pane" zotero-persist="width" flex="1"> <!-- This extra vbox prevents the toolbar from getting compressed when resizing the tag selector to max height --> <vbox flex="1"> @@ -181,7 +181,7 @@ <splitter id="zotero-tags-splitter" onmouseup="ZoteroPane.updateTagSelectorSize()" collapse="after"> <grippy oncommand="ZoteroPane.toggleTagSelector()"/> </splitter> - <zoterotagselector id="zotero-tag-selector" persist="height,collapsed,showAutomatic,filterToScope" + <zoterotagselector id="zotero-tag-selector" zotero-persist="height,collapsed,showAutomatic,filterToScope" oncommand="ZoteroPane.updateTagFilter()"/> </vbox> @@ -190,7 +190,7 @@ <grippy/> </splitter> - <vbox id="zotero-items-pane" persist="width" flex="1"> + <vbox id="zotero-items-pane" zotero-persist="width" flex="1"> <hbox class="toolbar" id="zotero-items-toolbar" align="center"> <toolbarbutton id="zotero-tb-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newItem.label;" type="menu"> <!-- New Item drop-down built in overlay.js::onLoad() --> @@ -246,82 +246,82 @@ <treecol id="zotero-items-column-title" primary="true" label="&zotero.items.title_column;" - flex="4" persist="width ordinal hidden sortActive sortDirection"/> + flex="4" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-firstCreator" label="&zotero.items.creator_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-type" hidden="true" label="&zotero.items.type_column;" - width="40" persist="width ordinal hidden sortActive sortDirection"/> + width="40" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-date" hidden="true" label="&zotero.items.date_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-year" hidden="true" label="&zotero.items.year_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-publisher" hidden="true" label="&zotero.items.publisher_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-publicationTitle" hidden="true" label="&zotero.items.publication_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-journalAbbreviation" hidden="true" label="&zotero.items.journalAbbr_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-language" hidden="true" label="&zotero.items.language_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-accessDate" hidden="true" label="&zotero.items.accessDate_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-libraryCatalog" hidden="true" label="&zotero.items.libraryCatalog_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-callNumber" hidden="true" label="&zotero.items.callNumber_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-rights" hidden="true" label="&zotero.items.rights_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-dateAdded" hidden="true" label="&zotero.items.dateAdded_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-dateModified" hidden="true" label="&zotero.items.dateModified_column;" - flex="1" persist="width ordinal hidden sortActive sortDirection"/> + flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/> <splitter class="tree-splitter"/> <treecol id="zotero-items-column-numChildren" label="&zotero.items.numChildren_column;" - persist="width ordinal hidden sortActive sortDirection"/> + zotero-persist="width ordinal hidden sortActive sortDirection"/> </treecols> <treechildren/> </tree> @@ -334,7 +334,7 @@ <splitter id="zotero-view-splitter" resizebefore="closest" resizeafter="closest"/> - <vbox id="zotero-item-pane" persist="width"> + <vbox id="zotero-item-pane" zotero-persist="width"> <hbox class="toolbar" align="center"> <hbox align="center" pack="start" flex="1"> <toolbarbutton id="zotero-tb-locate" class="zotero-tb-button" tooltiptext="&zotero.toolbar.openURL.label;" type="menu"> diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js @@ -147,3 +147,6 @@ pref("extensions.zotero.purge.creators", false); pref("extensions.zotero.purge.fulltext", false); pref("extensions.zotero.purge.items", false); pref("extensions.zotero.purge.tags", false); + +// Zotero pane persistent data +pref("extensions.zotero.pane.persist", '');