commit c589cd11e7760703f547f3e6103cc905925872e6
parent 3ea54df059d5974d56ebde65c615875b0f0d4028
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 10 Feb 2011 01:06:28 +0000
don't try to call non-existent onLoad function
Diffstat:
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -89,6 +89,7 @@ var ZoteroPane = new function()
var self = this;
var _loaded = false;
+ var _onVisibleHandlers = [];
var titlebarcolorState, titleState;
// Also needs to be changed in collectionTreeView.js
@@ -114,6 +115,7 @@ var ZoteroPane = new function()
}
_loaded = true;
+ ZoteroPane.restoreSavedState();
Zotero.setFontSize(document.getElementById('zotero-pane'))
if (Zotero.isMac) {
@@ -311,6 +313,8 @@ var ZoteroPane = new function()
return;
}
+ this.saveCurrentState();
+
var tagSelector = document.getElementById('zotero-tag-selector');
tagSelector.unregister();
@@ -335,7 +339,7 @@ var ZoteroPane = new function()
ps.alert(null, "", msg);
return false;
}
- ZoteroPane.onLoad();
+ ZoteroPane.init();
}
// If Zotero could not be initialized, display an error message and return
@@ -405,6 +409,8 @@ var ZoteroPane = new function()
}
}
+ for each(var handler in _onVisibleHandlers) handler();
+
return true;
}
@@ -3414,4 +3420,49 @@ var ZoteroPane = new function()
}
}
+ /**
+ * Saves all attributes labeled as zotero-persist
+ */
+ this.restoreSavedState = function() {
+ // load all z-persist attributes
+ var savedData = Zotero.Prefs.get("overlay.persist");
+ if(savedData != "") {
+ savedData = JSON.parse(savedData);
+ for(var id in savedData) {
+ var el = document.getElementById(id);
+ if(el) {
+ var savedDataEl = savedData[id];
+ for(var attr in savedDataEl) {
+ Zotero.debug(attr+" = "+savedDataEl[attr]);
+ try {
+ el.setAttribute(attr, savedDataEl[attr]);
+ } catch(e) {}
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Restores all attributes labeled as zotero-persist
+ */
+ this.saveCurrentState = function() {
+ var data = {};
+
+ var zPersists = document.evaluate('//*[@zotero-persist]', document.getElementById('zotero-pane'), null,
+ XPathResult.ANY_TYPE, null);
+ var el;
+ while(el = zPersists.iterateNext()) {
+ var id = el.getAttribute('id');
+ if(id) {
+ data[id] = {};
+
+ for each(var attr in el.getAttribute("zotero-persist").split(/[\s,]/)) {
+ data[id][attr] = el.getAttribute(attr);
+ }
+ }
+ }
+
+ Zotero.Prefs.set("overlay.persist", JSON.stringify(data));
+ }
}
\ No newline at end of file