www

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

commit fc6c113f25e06c40a9c004c1e08a008927183ba5
parent db33163a990774baf8d97b8159ac80d96027e2c0
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 24 Mar 2016 08:55:32 -0400

Show intro text for My Publications in middle pane when no items

ZoteroPane.setItemsPaneMessage() and setItemPaneMessage() can now
optionally take a DOM node instead of a string.

Closes #705

Diffstat:
Mchrome/content/zotero-platform/mac/overlay.css | 2+-
Mchrome/content/zotero/itemPane.xul | 2+-
Mchrome/content/zotero/xpcom/itemTreeView.js | 32++++++++++++++++++++++++++++++--
Mchrome/content/zotero/zoteroPane.js | 36+++++++++++++++++++++++++-----------
Mchrome/locale/en-US/zotero/zotero.properties | 4++++
Mchrome/skin/default/zotero/itemPane.css | 2+-
Mchrome/skin/default/zotero/overlay.css | 17+++++++++++++++++
Mtest/tests/zoteroPaneTest.js | 8++++----
8 files changed, 83 insertions(+), 20 deletions(-)

diff --git a/chrome/content/zotero-platform/mac/overlay.css b/chrome/content/zotero-platform/mac/overlay.css @@ -246,7 +246,7 @@ background-color: #ffffff; } -#zotero-item-pane-message { +#zotero-item-pane-message-box description { color: #7f7f7f; } diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul @@ -47,7 +47,7 @@ <deck id="zotero-item-pane-content" selectedIndex="0" flex="1"> <!-- Center label (for zero or multiple item selection) --> <groupbox id="zotero-item-pane-groupbox" pack="center" align="center"> - <label id="zotero-item-pane-message"/> + <vbox id="zotero-item-pane-message-box"/> </groupbox> <!-- Regular item --> diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -234,10 +234,38 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree this.expandMatchParents(); if (this._ownerDocument.defaultView.ZoteroPane_Local) { - this._ownerDocument.defaultView.ZoteroPane_Local.clearItemsPaneMessage(); + // For My Publications, show intro text in middle pane if no items + if (this.collectionTreeRow && this.collectionTreeRow.isPublications() && !this.rowCount) { + let doc = this._ownerDocument; + let ns = 'http://www.w3.org/1999/xhtml' + let div = doc.createElementNS(ns, 'div'); + let p = doc.createElementNS(ns, 'p'); + p.textContent = Zotero.getString('publications.intro.text1', ZOTERO_CONFIG.DOMAIN_NAME); + div.appendChild(p); + + p = doc.createElementNS(ns, 'p'); + p.textContent = Zotero.getString('publications.intro.text2'); + div.appendChild(p); + + p = doc.createElementNS(ns, 'p'); + let html = Zotero.getString('publications.intro.text3'); + // Convert <b> tags to placeholders + html = html.replace('<b>', ':b:').replace('</b>', ':/b:'); + // Encode any other special chars, which shouldn't exist + html = Zotero.Utilities.htmlSpecialChars(html); + // Restore bold text + html = html.replace(':b:', '<strong>').replace(':/b:', '</strong>'); + p.innerHTML = html; // AMO note: markup from hard-coded strings and filtered above + div.appendChild(p); + + content = div; + doc.defaultView.ZoteroPane_Local.setItemsPaneMessage(content); + } + else { + this._ownerDocument.defaultView.ZoteroPane_Local.clearItemsPaneMessage(); + } } - // Select a queued item from selectItem() if (this.collectionTreeRow && this.collectionTreeRow.itemToSelect) { var item = this.collectionTreeRow.itemToSelect; yield this.selectItem(item['id'], item['expand']); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -3047,21 +3047,24 @@ var ZoteroPane = new function() } - function setItemsPaneMessage(msg, lock) { + function setItemsPaneMessage(content, lock) { var elem = document.getElementById('zotero-items-pane-message-box'); if (elem.getAttribute('locked') == 'true') { return; } - while (elem.hasChildNodes()) { - elem.removeChild(elem.firstChild); + elem.textContent = ''; + if (typeof content == 'string') { + let contentParts = content.split("\n\n"); + for (let part of contentParts) { + var desc = document.createElement('description'); + desc.appendChild(document.createTextNode(part)); + elem.appendChild(desc); + } } - var msgParts = msg.split("\n\n"); - for (var i=0; i<msgParts.length; i++) { - var desc = document.createElement('description'); - desc.appendChild(document.createTextNode(msgParts[i])); - elem.appendChild(desc); + else { + elem.appendChild(content); } // Make message permanent @@ -3084,11 +3087,22 @@ var ZoteroPane = new function() } - this.setItemPaneMessage = function (msg) { + this.setItemPaneMessage = function (content) { document.getElementById('zotero-item-pane-content').selectedIndex = 0; - var label = document.getElementById('zotero-item-pane-message'); - label.value = msg; + var elem = document.getElementById('zotero-item-pane-message-box'); + elem.textContent = ''; + if (typeof content == 'string') { + let contentParts = content.split("\n\n"); + for (let part of contentParts) { + let desc = document.createElement('description'); + desc.appendChild(document.createTextNode(part)); + elem.appendChild(desc); + } + } + else { + elem.appendChild(content); + } } diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -1052,6 +1052,10 @@ styles.editor.output.individualCitations = Individual Citations styles.editor.output.singleCitation = Single Citation (with position "first") styles.preview.instructions = Select one or more items in Zotero and click the "Refresh" button to see how these items are rendered by the installed CSL citation styles. +publications.intro.text1 = My Publications allows you to create a list of your own work and share it on your profile page on %S. You can add notes about each item and even share PDFs or other files under a license you specify. +publications.intro.text2 = To add items, drag them from another library. You’ll be able to choose whether to include attached notes and files. +publications.intro.text3 = <b>Only add work you yourself have created</b>, and only include files if you have the rights to distribute them publicly and wish to do so. + publications.sharing.keepRightsField = Keep the existing Rights field publications.sharing.keepRightsFieldWhereAvailable = Keep the existing Rights field where available publications.cc.moreInfo.text = Be sure you have read the Creative Commons %S before placing your work under a CC license. Note that the license you apply cannot be revoked, even if you later choose different terms or cease publishing the work. diff --git a/chrome/skin/default/zotero/itemPane.css b/chrome/skin/default/zotero/itemPane.css @@ -1,4 +1,4 @@ -#zotero-item-pane-message { +.zotero-item-pane-message-box description { padding: 0 2em; } diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css @@ -226,6 +226,23 @@ min-width: 290px; } +/* Used for intro text for My Publications */ +#zotero-items-pane-message-box { + overflow-y: auto; + cursor: default; +} + +#zotero-items-pane-message-box div { + padding: 0 35px; +} + +#zotero-items-pane-message-box p { + max-width: 800px; + font-size: 1.2em; + line-height: 1.7em; + text-align: left; +} + #zotero-item-pane { width: 338px; diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js @@ -76,7 +76,7 @@ describe("ZoteroPane", function() { // Unselected, with no items in view assert.equal( - doc.getElementById('zotero-item-pane-message').value, + doc.getElementById('zotero-item-pane-message-box').textContent, Zotero.getString('pane.item.unselected.zero', 0) ); @@ -87,7 +87,7 @@ describe("ZoteroPane", function() { skipSelect: true }); assert.equal( - doc.getElementById('zotero-item-pane-message').value, + doc.getElementById('zotero-item-pane-message-box').textContent, Zotero.getString('pane.item.unselected.singular', 1) ); @@ -98,7 +98,7 @@ describe("ZoteroPane", function() { skipSelect: true }); assert.equal( - doc.getElementById('zotero-item-pane-message').value, + doc.getElementById('zotero-item-pane-message-box').textContent, Zotero.getString('pane.item.unselected.plural', 2) ); @@ -107,7 +107,7 @@ describe("ZoteroPane", function() { zp.itemsView.rememberSelection([itemID1, itemID2]); yield promise; assert.equal( - doc.getElementById('zotero-item-pane-message').value, + doc.getElementById('zotero-item-pane-message-box').textContent, Zotero.getString('pane.item.selected.multiple', 2) ); })