www

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

commit 0757109c16307076ab53372f506007c3f16b7a08
parent c21d6c9700d4e95aad516171324b7ffd1ddb0e78
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 30 Dec 2016 01:00:15 -0500

Allow direct install from styles page in viewer

When "Get Additional Styles…" is clicked, open a stripped-down version
of the Zotero styles page in a window. When a style is clicked on,
install it and close the window.

I'm going to say that this closes #767, but as Aurimas notes there, if
you know the style you're looking for, being able to just type the name
in a dialog would be faster, so further improvements could be made. But
as it stands, this is much better than clicking through to a browser
(and hoping that it's one with the new connector with style installation
support).

Diffstat:
Mchrome/content/zotero/preferences/preferences_cite.js | 14++++++++++++++
Mchrome/content/zotero/preferences/preferences_cite.xul | 4+++-
Mchrome/content/zotero/xpcom/mimeTypeHandler.js | 16+++++++++++++++-
3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/preferences/preferences_cite.js b/chrome/content/zotero/preferences/preferences_cite.js @@ -90,6 +90,20 @@ Zotero_Preferences.Cite = { }), + openStylesPage: function () { + Zotero.openInViewer("https://www.zotero.org/styles/", function (doc) { + // Hide header, intro paragraph, Link, and Source + // + // (The first two aren't sent to the client normally, but hide anyway in case they are.) + var style = doc.createElement('style'); + style.type = 'text/css'; + style.innerHTML = 'h1, #intro, .style-individual-link, .style-view-source { display: none !important; }'; + Zotero.debug(doc.documentElement.innerHTML); + doc.getElementsByTagName('head')[0].appendChild(style); + }); + }, + + /** * Adds a new style to the style pane **/ diff --git a/chrome/content/zotero/preferences/preferences_cite.xul b/chrome/content/zotero/preferences/preferences_cite.xul @@ -58,7 +58,9 @@ </tree> <separator class="thin"/> <hbox align="center" flex="1" height="40"> - <label class="zotero-text-link" href="http://www.zotero.org/styles/" value="&zotero.preferences.export.getAdditionalStyles;" flex="1"/> + <label class="zotero-text-link" + value="&zotero.preferences.export.getAdditionalStyles;" flex="1" + onclick="Zotero_Preferences.Cite.openStylesPage(); event.preventDefault()"/> <button disabled="true" id="styleManager-delete" label="-" onclick="Zotero_Preferences.Cite.deleteStyle()"/> <button label="+" onclick="Zotero_Preferences.Cite.addStyle()"/> </hbox> diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js @@ -62,7 +62,21 @@ Zotero.MIMETypeHandler = new function () { else this.unregisterMetadataHandlers(); }.bind(this)); - this.addHandler("application/vnd.citationstyles.style+xml", function(a1, a2) { Zotero.Styles.install(a1, a2) }); + this.addHandler("application/vnd.citationstyles.style+xml", Zotero.Promise.coroutine(function* (a1, a2) { + let win = Services.wm.getMostRecentWindow("zotero:basicViewer"); + try { + yield Zotero.Styles.install(a1, a2, true); + } + catch (e) { + Zotero.logError(e); + (new Zotero.Exception.Alert("styles.install.unexpectedError", + a2, "styles.install.title", e)).present(); + } + // Close styles page in basic viewer after installing a style + if (win) { + win.close(); + } + })); this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) }); // deprecated this.addHandler("application/x-zotero-schema", Zotero.Schema.importSchema); this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings);