From 8ad23d7eea79f19676a199fc48d1966326d6d2a3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 29 Dec 2008 06:18:41 +0000 Subject: [PATCH] - Abstract attachment info pane into XBL binding - Add attachment conflict resolution --- .../content/zotero/bindings/attachmentbox.xml | 430 ++++++++++++++++++ chrome/content/zotero/bindings/merge.xml | 34 ++ chrome/content/zotero/bindings/noteeditor.xml | 8 +- .../zotero/bindings/styled-textbox.xml | 68 +-- chrome/content/zotero/merge.js | 32 +- chrome/content/zotero/overlay.js | 291 ++---------- chrome/content/zotero/overlay.xul | 20 +- chrome/content/zotero/xpcom/data/item.js | 89 ++-- chrome/content/zotero/xpcom/sync.js | 6 - .../default/zotero/bindings/attachmentbox.css | 36 ++ chrome/skin/default/zotero/overlay.css | 46 -- chrome/skin/default/zotero/zotero.css | 6 + 12 files changed, 675 insertions(+), 391 deletions(-) create mode 100644 chrome/content/zotero/bindings/attachmentbox.xml create mode 100644 chrome/skin/default/zotero/bindings/attachmentbox.css diff --git a/chrome/content/zotero/bindings/attachmentbox.xml b/chrome/content/zotero/bindings/attachmentbox.xml new file mode 100644 index 000000000..113827c93 --- /dev/null +++ b/chrome/content/zotero/bindings/attachmentbox.xml @@ -0,0 +1,430 @@ + + + + + + + + + + + + + + + + false + false + false + false + + + + + + "view" + + + + + + + + + + + + + + + + + + + + 29 ) || firstSpace > 29) { + title.setAttribute('crop', 'end'); + title.setAttribute('value', val); + } + // Create a element, essentially + else { + title.removeAttribute('value'); + title.appendChild(document.createTextNode(val)); + } + + if (this.editable) { + title.className = 'zotero-clicky'; + + // For the time being, use a silly little popup + title.addEventListener('click', this.editTitle, false); + } + + // View and Show buttons + if (this.displayGoButtons) { + goButtons.hidden = false; + + var itemID = this.item.id; + var noLocateOnMissing = !this.editable; + viewButton.onclick = function (event) { + ZoteroPane.viewAttachment(itemID, event, noLocateOnMissing) + } + showButton.onclick = function (event) { + ZoteroPane.showAttachmentInFilesystem(itemID, noLocateOnMissing) + } + } + else { + goButtons.hidden = true; + } + + var isImportedURL = this.item.attachmentLinkMode == + Zotero.Attachments.LINK_MODE_IMPORTED_URL; + + // Metadata for URL's + if (this.item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL + || isImportedURL) { + // "View Page"/"View Snapshot" label + if (isImportedURL) { + var str = Zotero.getString('pane.item.attachments.view.snapshot'); + } + else { + var str = Zotero.getString('pane.item.attachments.view.link'); + } + + showButton.setAttribute('hidden', !isImportedURL); + + // URL + var urlSpec = this.item.getField('url'); + urlField.setAttribute('value', urlSpec); + urlField.setAttribute('hidden', false); + if (this.clickableLink) { + urlField.onclick = function (event) { + ZoteroPane.loadURI(this.value, event) + }; + urlField.className = 'text-link'; + } + else { + urlField.className = ''; + } + + // Access date + accessed.setAttribute('value', + Zotero.getString('itemFields.accessDate') + ': ' + + Zotero.Date.sqlToDate(this.item.getField('accessDate'), true).toLocaleString()); + accessed.setAttribute('hidden', false); + } + // Metadata for files + else { + var str = Zotero.getString('pane.item.attachments.view.file'); + showButton.setAttribute('hidden', false); + urlField.setAttribute('hidden', true); + accessed.setAttribute('hidden', true); + } + + viewButton.setAttribute('label', str); + + // Page count + if (this.displayPages) { + var pages = Zotero.Fulltext.getPages(this.item.id); + var pages = pages ? pages.total : null; + if (pages) { + var str = Zotero.getString('itemFields.pages') + ': ' + pages; + pagesRow.setAttribute('value', str); + pagesRow.setAttribute('hidden', false); + } + else { + pagesRow.setAttribute('hidden', true); + } + } + else { + pagesRow.setAttribute('hidden', true); + } + + // Full-text index information + if (this.displayIndexed) { + this.updateItemIndexedState(); + indexBox.hidden = false; + } + else { + indexBox.hidden = true; + } + + // Note editor + var noteEditor = this._id('note-editor'); + // Don't make note editable (at least for now) + if (this.mode == 'merge' || this.mode == 'mergeedit') { + noteEditor.mode = 'merge'; + noteEditor.displayButton = false; + } + else { + noteEditor.mode = this.mode; + } + noteEditor.parent = null; + noteEditor.item = this.item; + + if (this.displayButton) { + selectButton.label = this.buttonCaption; + selectButton.hidden = false; + selectButton.setAttribute('oncommand', + 'document.getBindingParent(this).clickHandler(this)'); + } + else { + selectButton.hidden = true; + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +