diff --git a/chrome/content/zotero/bindings/customcolorpicker.xml b/chrome/content/zotero/bindings/customcolorpicker.xml new file mode 100644 index 0000000000..a420691369 --- /dev/null +++ b/chrome/content/zotero/bindings/customcolorpicker.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + [ + 'L#FFFFFF','L#FFCCCC','L#FFCC99','L#FFFF99','L#FFFFCC','L#99FF99','L#99FFFF','L#CCFFFF','L#CCCCFF','L#FFCCFF', + '#CCCCCC','#FF6666','#FF9966','L#FFFF66','L#FFFF33','L#66FF99','L#33FFFF','L#66FFFF','#9999FF','#FF99FF', + '#C0C0C0','#FF0000','#FF9900','#FFCC66','L#FFFF00','L#33FF33','#66CCCC','#33CCFF','#6666CC','#CC66CC', + '#999999','#CC0000','#FF6600','#FFCC33','#FFCC00','#33CC00','#00CCCC','#3366FF','#6633FF','#CC33CC', + '#666666','#990000','#CC6600','#CC9933','#999900','#009900','#339999','#3333FF','#6600CC','#993399', + '#333333','#660000','#993300','#996633','#666600','#006600','#336666','#000099','#333399','#663366', + '#000000','#330000','#663300','#663333','#333300','#003300','#003333','#000066','#330099','#330033' + ] + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml index 45f7677fd3..a6c7017216 100644 --- a/chrome/content/zotero/bindings/tagsbox.xml +++ b/chrome/content/zotero/bindings/tagsbox.xml @@ -37,6 +37,7 @@ + "view" @@ -109,38 +110,64 @@ if (this.hasAttribute('mode')) { this.mode = this.getAttribute('mode'); } + + this._notifierID = Zotero.Notifier.registerObserver(this, ['setting']); ]]> + + + + + + + + + + + + + + + + @@ -264,8 +291,13 @@ } // Tag color - if (color = this._tagColors[valueText]) { - valueElement.setAttribute('style', 'color:' + this._tagColors[valueText]); + let color = this._tagColors[valueText]; + if (color) { + valueElement.setAttribute( + 'style', + 'color:' + this._tagColors[valueText].color + '; ' + + 'font-weight: bold' + ); } return valueElement; diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index 8cfe3b6daf..45d63bccf7 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -27,8 +27,7 @@ + xmlns:xbl="http://www.mozilla.org/xbl"> @@ -77,6 +76,9 @@ @@ -215,211 +217,211 @@ var empty = true; var tagsToggleBox = this.id('tags-toggle'); - - if (fetch || this._dirty) { - this._tags = Zotero.Tags.getAll(this._types, this.libraryID); - - // Remove children - tagsToggleBox.textContent = ""; - - var me = this, - onTagClick = function(event) { me.handleTagClick(event, this) }, - lastTag; - for (var tagID in this._tags) { - var tagInfo = this._tags[tagID], - tagName = tagInfo.name; - // If the last tag was the same, add this tagID and tagType to it - if(lastTag && lastTag.value === tagName) { - lastTag.setAttribute('tagID', lastTag.getAttribute('tagID') + '-' + tagID); - lastTag.setAttribute('tagType', lastTag.getAttribute('tagType') + '-' + tagName.type); - continue; - } + var self = this; + Zotero.Tags.getColors(this.libraryID) + .then(function (tagColors) { + if (fetch || self._dirty) { + self._tags = Zotero.Tags.getAll(self._types, self.libraryID); - lastTag = document.createElement('label'); - lastTag.addEventListener('click', onTagClick, false); - lastTag.className = 'zotero-clicky'; + // Remove children + tagsToggleBox.textContent = ""; - - lastTag.setAttribute('value', tagName); - lastTag.setAttribute('tagID', tagID); - lastTag.setAttribute('tagType', tagInfo.type); - if (this.editable) { - lastTag.setAttribute('context', 'tag-menu'); - lastTag.addEventListener('dragover', this.dragObserver.onDragOver, false); - lastTag.addEventListener('dragexit', this.dragObserver.onDragExit, false); - lastTag.addEventListener('drop', this.dragObserver.onDrop, true); - } - tagsToggleBox.appendChild(lastTag); - } - this._dirty = false; - } - - // Set attributes - var labels = tagsToggleBox.getElementsByTagName('label'); - var tagColors = Zotero.Tags.getColors(); - for (var i=0; i=0; i--) { + tagsToggleBox.insertBefore(colorTags[positions[i]], tagsToggleBox.firstChild); + } + + //start tag cloud code + + var tagCloud = Zotero.Prefs.get('tagCloud'); + + if(tagCloud) { + var labels = tagsToggleBox.getElementsByTagName('label'); + + //loop through displayed labels and find number of linked items + var numlinked= []; + for (var i=0; i @@ -437,6 +439,7 @@ + @@ -719,43 +733,84 @@ - + + + + + + + + + + + - = Zotero.Tags.MAX_COLORED_TAGS && !tagColors[io.name]) { + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + ps.alert(null, "", Zotero.getString('pane.tagSelector.maxColoredTags', Zotero.Tags.MAX_COLORED_TAGS)); + return; } - } + + window.openDialog( + 'chrome://zotero/content/tagColorChooser.xul', + "zotero-tagSelector-colorChooser", + "chrome,modal,centerscreen", io + ); + + // Dialog cancel + if (typeof io.color == 'undefined') { + return; + } + + return Zotero.Tags.setColor(self.libraryID, io.name, io.color, io.position); + }) + .done(); ]]> + - - - - - - - + + + + + + - - - + + - + - - + + - - - - - + + - - + - - - - - - + + + + + diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 5434ad503f..4a1d0b576a 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -46,6 +46,7 @@ var Zotero_Browser = new function() { this.toggleCollapsed = toggleCollapsed; this.chromeLoad = chromeLoad; this.contentLoad = contentLoad; + this.itemUpdated = itemUpdated; this.contentHide = contentHide; this.tabClose = tabClose; this.resize = resize; @@ -306,7 +307,7 @@ var Zotero_Browser = new function() { if(isHTML) { var contentWin = doc.defaultView; if(!contentWin.haveZoteroEventListener) { - contentWin.addEventListener("ZoteroItemUpdated", itemUpdated, false); + contentWin.addEventListener("ZoteroItemUpdated", function(event) { itemUpdated(event.originalTarget) }, false); contentWin.haveZoteroEventListener = true; } } @@ -342,14 +343,13 @@ var Zotero_Browser = new function() { /** * Called when item should be updated due to a DOM event */ - function itemUpdated(event) { + function itemUpdated(doc) { try { - var doc = event.originalTarget; - var rootDoc = (doc instanceof HTMLDocument ? doc.defaultView.top.document : doc); - var browser = Zotero_Browser.tabbrowser.getBrowserForDocument(rootDoc); - var tab = _getTabObject(browser); - if(doc == tab.page.document || doc == rootDoc) tab.clear(); - tab.detectTranslators(rootDoc, doc); + var rootDoc = (doc instanceof HTMLDocument ? doc.defaultView.top.document : doc); + var browser = Zotero_Browser.tabbrowser.getBrowserForDocument(rootDoc); + var tab = _getTabObject(browser); + if(doc == tab.page.document || doc == rootDoc) tab.clear(); + tab.detectTranslators(rootDoc, doc); } catch(e) { Zotero.debug(e); } @@ -694,6 +694,7 @@ Zotero_Browser.Tab.prototype.detectTranslators = function(rootDoc, doc) { var translate = new Zotero.Translate.Web(); translate.setDocument(doc); translate.setHandler("translators", function(obj, item) { me._translatorsAvailable(obj, item) }); + translate.setHandler("pageModified", function(translate, doc) { Zotero_Browser.itemUpdated(doc) }); translate.getTranslators(true); } else if(doc.documentURI.substr(0, 7) == "file://") { this._attemptLocalFileImport(doc); diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index 9086f0dbbd..56968d3ef6 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -371,38 +371,84 @@ function verifyStorageServer() { abortButton.hidden = false; progressMeter.hidden = false; - var requestHolder = Zotero.Sync.Storage.WebDAV.checkServer(function (uri, status, callback) { + var request = null; + var onDone = false; + + Zotero.Sync.Storage.WebDAV.checkServer() + // Get the XMLHttpRequest for possible cancelling + .progress(function (obj) { + request = obj.xmlhttp; + }) + .finally(function () { verifyButton.hidden = false; abortButton.hidden = true; progressMeter.hidden = true; - + }) + .spread(function (uri, status) { switch (status) { case Zotero.Sync.Storage.ERROR_NO_URL: - setTimeout(function () { + onDone = function () { urlField.focus(); - }, 1); + }; break; case Zotero.Sync.Storage.ERROR_NO_USERNAME: - setTimeout(function () { + onDone = function () { usernameField.focus(); - }, 1); + }; break; case Zotero.Sync.Storage.ERROR_NO_PASSWORD: - setTimeout(function () { + case Zotero.Sync.Storage.ERROR_AUTH_FAILED: + onDone = function () { passwordField.focus(); - }, 1); + }; break; } - Zotero.Sync.Storage.WebDAV.checkServerCallback(uri, status, window); - }); + return Zotero.Sync.Storage.WebDAV.checkServerCallback(uri, status, window); + }) + .then(function (success) { + if (success) { + Zotero.debug("WebDAV verification succeeded"); + + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + promptService.alert( + window, + Zotero.getString('sync.storage.serverConfigurationVerified'), + Zotero.getString('sync.storage.fileSyncSetUp') + ); + Zotero.Prefs.set("sync.storage.verified", true); + } + else { + Zotero.debug("WebDAV verification failed"); + if (onDone) { + setTimeout(function () { + onDone(); + }, 1); + } + } + }) + .catch(function (e) { + Zotero.debug("WebDAV verification failed"); + Zotero.debug(e, 1); + Components.utils.reportError(e); + Zotero.Utilities.Internal.errorPrompt(Zotero.getString('general.error'), e); + + if (onDone) { + setTimeout(function () { + onDone(); + }, 1); + } + }) + .done(); abortButton.onclick = function () { - if (requestHolder.request) { - requestHolder.request.onreadystatechange = undefined; - requestHolder.request.abort(); + if (request) { + Zotero.debug("Cancelling verification request"); + request.onreadystatechange = undefined; + request.abort(); verifyButton.hidden = false; abortButton.hidden = true; progressMeter.hidden = true; @@ -1971,4 +2017,257 @@ function openInViewer(uri, newTab) { var win = ww.openWindow(null, uri, null, features + ",width=775,height=575", null); } } +} + + +Zotero_Preferences.Attachment_Base_Directory = { + choosePath: function () { + // Get existing base directory + var oldBasePath = Zotero.Prefs.get('baseAttachmentPath'); + if (oldBasePath) { + var oldBasePathFile = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + try { + oldBasePathFile.persistentDescriptor = oldBasePath; + } + catch (e) { + Zotero.debug(e, 1); + Components.utils.reportError(e); + oldBasePathFile = null; + } + } + + //Prompt user to choose new base path + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); + if (oldBasePathFile) { + fp.displayDirectory = oldBasePathFile; + } + fp.init(window, Zotero.getString('attachmentBasePath.selectDir'), nsIFilePicker.modeGetFolder); + fp.appendFilters(nsIFilePicker.filterAll); + if (fp.show() != nsIFilePicker.returnOK) { + return false; + } + var newBasePathFile = fp.file; + + if (oldBasePathFile && oldBasePathFile.equals(newBasePathFile)) { + Zotero.debug("Base directory hasn't changed"); + return false; + } + + // Find all current attachments with relative attachment paths + var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE '" + + Zotero.Attachments.BASE_PATH_PLACEHOLDER + "%'"; + var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE]; + var oldRelativeAttachmentIDs = Zotero.DB.columnQuery(sql, params) || []; + + //Find all attachments on the new base path + var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=?"; + var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE]; + var allAttachments = Zotero.DB.columnQuery(sql,params); + var newAttachmentPaths = {}; + var numNewAttachments = 0; + var numOldAttachments = 0; + var attachmentFile = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + for (let i=0; i - + @@ -564,8 +564,9 @@ To add a new preference: helpTopic="cite"> - + + @@ -611,6 +612,8 @@ To add a new preference: + + @@ -716,6 +719,7 @@ To add a new preference: image="chrome://zotero/skin/prefs-advanced.png" helpTopic="advanced"> + @@ -725,98 +729,139 @@ To add a new preference: - - + + + + + + - - - - - -