Add intro text to middle pane when My Library is empty

This replaces the Quick Start Guide item in earlier versions.

Also increases size of My Publications intro text when the window is
wider.
This commit is contained in:
Dan Stillman 2017-07-07 03:20:06 -04:00
parent 1ddb38036e
commit b07fdc6335
6 changed files with 166 additions and 80 deletions

View file

@ -46,6 +46,7 @@ Zotero.ItemTreeView = function (collectionTreeRow) {
this._ownerDocument = null;
this._needsSort = false;
this._introText = null;
this._cellTextCache = {};
this._itemImages = {};
@ -245,38 +246,7 @@ Zotero.ItemTreeView.prototype.setTree = async function (treebox) {
// handleKeyPress() in zoteroPane.js.
tree._handleEnter = function () {};
if (this._ownerDocument.defaultView.ZoteroPane_Local) {
// 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();
}
}
this._updateIntroText();
if (this.collectionTreeRow && this.collectionTreeRow.itemToSelect) {
var item = this.collectionTreeRow.itemToSelect;
@ -1010,6 +980,8 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
yield this.selectItem(selectItem);
}*/
this._updateIntroText();
//this._treebox.endUpdateBatch();
let selectPromise;
if (madeChanges) {
@ -1725,6 +1697,113 @@ Zotero.ItemTreeView.prototype.sort = function (itemIDs) {
};
/**
* Show intro text in middle pane for some views when no items
*/
Zotero.ItemTreeView.prototype._updateIntroText = function() {
if (!this._ownerDocument.defaultView.ZoteroPane) {
return;
}
if (this.collectionTreeRow && !this.rowCount) {
let doc = this._ownerDocument;
let ns = 'http://www.w3.org/1999/xhtml'
let div;
// My Library and no groups
if (this.collectionTreeRow.isLibrary() && !Zotero.Groups.getAll().length) {
div = doc.createElementNS(ns, 'div');
let p = doc.createElementNS(ns, 'p');
let html = Zotero.getString(
'pane.items.intro.text1',
[
Zotero.clientName
]
);
// Encode special chars, which shouldn't exist
html = Zotero.Utilities.htmlSpecialChars(html);
html = `<b>${html}</b>`;
p.innerHTML = html;
div.appendChild(p);
p = doc.createElementNS(ns, 'p');
html = Zotero.getString(
'pane.items.intro.text2',
[
Zotero.getString('connector.name', Zotero.clientName),
Zotero.clientName
]
);
// Encode special chars, which shouldn't exist
html = Zotero.Utilities.htmlSpecialChars(html);
html = html.replace(
/\[([^\]]+)](.+)\[([^\]]+)]/,
`<span class="text-link" data-href="${ZOTERO_CONFIG.QUICK_START_URL}">$1</span>`
+ '$2'
+ `<span class="text-link" data-href="${ZOTERO_CONFIG.CONNECTORS_URL}">$3</span>`
);
p.innerHTML = html;
div.appendChild(p);
p = doc.createElementNS(ns, 'p');
html = Zotero.getString('pane.items.intro.text3', [Zotero.clientName]);
// Encode special chars, which shouldn't exist
html = Zotero.Utilities.htmlSpecialChars(html);
html = html.replace(
/\[([^\]]+)]/,
'<span class="text-link" '
+ `onclick="Zotero.Utilities.Internal.openPreferences('zotero-prefpane-sync')">$1</span>`
);
p.innerHTML = html;
div.appendChild(p);
// Activate text links
for (let span of div.getElementsByTagName('span')) {
if (span.classList.contains('text-link') && !span.hasAttribute('onclick')) {
span.onclick = function () {
doc.defaultView.ZoteroPane.loadURI(this.getAttribute('data-href'));
};
}
}
}
// My Publications
else if (this.collectionTreeRow.isPublications()) {
div = doc.createElementNS(ns, 'div');
div.className = 'publications';
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);
}
if (div) {
this._introText = true;
doc.defaultView.ZoteroPane_Local.setItemsPaneMessage(div);
return;
}
this._introText = null;
}
if (this._introText || this._introText === null) {
this._ownerDocument.defaultView.ZoteroPane_Local.clearItemsPaneMessage();
this._introText = false;
}
};
////////////////////////////////////////////////////////////////////////////////
///
/// Additional functions for managing data in the tree

View file

@ -1460,36 +1460,6 @@ Zotero.Schema = new function(){
+ "(?, 'user', 1, 1)";
yield Zotero.DB.queryAsync(sql, userLibraryID);
/*if (!Zotero.Schema.skipDefaultData) {
// Quick Start Guide web page item
var sql = "INSERT INTO items VALUES(1, 13, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?, 'ABCD2345', 0, 0)";
yield Zotero.DB.queryAsync(sql, userLibraryID);
var sql = "INSERT INTO itemDataValues VALUES (1, ?)";
yield Zotero.DB.queryAsync(sql, Zotero.getString('install.quickStartGuide'));
var sql = "INSERT INTO itemData VALUES (1, 110, 1)";
yield Zotero.DB.queryAsync(sql);
var sql = "INSERT INTO itemDataValues VALUES (2, 'https://www.zotero.org/support/quick_start_guide')";
yield Zotero.DB.queryAsync(sql);
var sql = "INSERT INTO itemData VALUES (1, 1, 2)";
yield Zotero.DB.queryAsync(sql);
// CHNM as creator
var sql = "INSERT INTO creators VALUES (1, '', 'Center for History and New Media', 1)";
yield Zotero.DB.queryAsync(sql);
var sql = "INSERT INTO itemCreators VALUES (1, 1, 1, 0)";
yield Zotero.DB.queryAsync(sql);
// Welcome note
var sql = "INSERT INTO items VALUES(2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?, 'ABCD3456', 0, 0)";
yield Zotero.DB.queryAsync(sql, userLibraryID);
var welcomeTitle = Zotero.getString('install.quickStartGuide.message.welcome');
var welcomeMsg = '<div class="zotero-note znv1"><p><strong>' + welcomeTitle + '</strong></p>'
+ '<p>' + Zotero.getString('install.quickStartGuide.message.view') + '</p>'
+ '<p>' + Zotero.getString('install.quickStartGuide.message.thanks') + '</p></div>';
var sql = "INSERT INTO itemNotes VALUES (2, 1, ?, ?)";
yield Zotero.DB.queryAsync(sql, [welcomeMsg, welcomeTitle]);
}*/
yield _updateLastClientVersion();
self.dbInitialized = true;

View file

@ -37,7 +37,6 @@ var ZoteroPane = new function()
var _lastSelectedItems = [];
//Privileged methods
this.init = init;
this.destroy = destroy;
this.isShowing = isShowing;
this.isFullScreen = isFullScreen;
@ -71,7 +70,7 @@ var ZoteroPane = new function()
/**
* Called when the window containing Zotero pane is open
*/
function init() {
this.init = function () {
Zotero.debug("Initializing Zotero pane");
// Fix window without menubar/titlebar when Standalone is closed in full-screen mode
@ -100,7 +99,11 @@ var ZoteroPane = new function()
Zotero.setFontSize(zp);
ZoteroPane_Local.updateLayout();
ZoteroPane_Local.updateToolbarPosition();
window.addEventListener("resize", ZoteroPane_Local.updateToolbarPosition, false);
this.updateWindow();
window.addEventListener("resize", () => {
this.updateWindow();
this.updateToolbarPosition();
});
window.setTimeout(ZoteroPane_Local.updateToolbarPosition, 0);
Zotero.updateQuickSearchBox(document);
@ -138,7 +141,7 @@ var ZoteroPane = new function()
// continue loading pane
_loadPane();
}
};
/**
* Called on window load or when pane has been reloaded after switching into or out of connector
@ -4812,6 +4815,21 @@ var ZoteroPane = new function()
Zotero.Prefs.set("pane.persist", JSON.stringify(serializedValues));
}
this.updateWindow = function () {
var zoteroPane = document.getElementById('zotero-pane');
// Must match value in overlay.css
var breakpoint = 1000;
var className = `width-${breakpoint}`;
if (window.innerWidth >= breakpoint) {
zoteroPane.classList.add(className);
}
else {
zoteroPane.classList.remove(className);
}
};
/**
* Moves around the toolbar when the user moves around the pane
*/

View file

@ -242,6 +242,10 @@ pane.tagSelector.maxColoredTags = Only %S tags in each library c
tagColorChooser.numberKeyInstructions = You can add this tag to selected items by pressing the $NUMBER key on the keyboard.
tagColorChooser.maxTags = Up to %S tags in each library can have colors assigned.
pane.items.intro.text1 = Welcome to %S!
pane.items.intro.text2 = View the [Quick Start Guide] to learn how to begin building your library, and be sure to [install a %S] so you can add items to %S as you browse the web.
pane.items.intro.text3 = Already using %S on another computer? [Set up syncing] to pick up right where you left off.
pane.items.loading = Loading items…
pane.items.columnChooser.moreColumns = More Columns
pane.items.columnChooser.secondarySort = Secondary Sort (%S)
@ -1084,6 +1088,7 @@ standalone.rootWarning.exit = Exit
standalone.rootWarning.continue = Continue
standalone.updateMessage = A recommended update is available, but you do not have permission to install it. To update automatically, modify the Zotero program directory to be writeable by your user account.
connector.name = %S Connector
connector.error.title = Zotero Connector Error
connector.standaloneOpen = Your database cannot be accessed because Zotero Standalone is currently open. Please view your items in Zotero Standalone.
connector.loadInProgress = Zotero Standalone was launched but is not accessible. If you experienced an error opening Zotero Standalone, restart Firefox.

View file

@ -227,7 +227,7 @@
min-height: 150px;
}
/* Used for intro text for My Publications */
/* Used for intro text */
#zotero-items-pane-message-box {
overflow-y: auto;
cursor: default;
@ -239,11 +239,36 @@
#zotero-items-pane-message-box p {
max-width: 800px;
font-size: 1.2em;
font-size: 1.45em;
line-height: 1.7em;
text-align: left;
}
#zotero-items-pane-message-box div.publications p {
font-size: 1.2em;
}
/* Increase size when window is wider */
#zotero-pane.width-1000 #zotero-items-pane-message-box div.publications p {
font-size: 1.35em;
}
#zotero-items-pane-message-box span.text-link {
color: rgb(0, 149, 221);
cursor: pointer;
text-decoration: underline;
}
#zotero-items-pane-message-box {
-moz-appearance: listbox;
text-align: center;
padding: 20px;
}
#zotero-items-pane-message-box description:not(:first-child) {
margin-top: .75em;
}
#zotero-item-pane
{
width: 338px;
@ -636,18 +661,6 @@
background-image: none;
}
#zotero-items-pane-message-box
{
-moz-appearance: listbox;
text-align: center;
padding: 20px;
}
#zotero-items-pane-message-box description:not(:first-child) {
margin-top: .75em;
}
#zotero-annotate-tb-add
{
list-style-image: url('chrome://zotero/skin/annotate-add.png');

View file

@ -17,6 +17,7 @@ var ZOTERO_CONFIG = {
HTTP_BOOKMARKLET_ORIGIN: 'http://www.zotero.org',
BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/',
START_URL: "https://www.zotero.org/start_standalone",
QUICK_START_URL: "https://www.zotero.org/support/quick_start_guide",
PDF_TOOLS_URL: "https://www.zotero.org/download/xpdf/",
SUPPORT_URL: "https://www.zotero.org/support/",
TROUBLESHOOTING_URL: "https://www.zotero.org/support/getting_help",