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).
This commit is contained in:
parent
c21d6c9700
commit
0757109c16
|
@ -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
|
* Adds a new style to the style pane
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -58,7 +58,9 @@
|
||||||
</tree>
|
</tree>
|
||||||
<separator class="thin"/>
|
<separator class="thin"/>
|
||||||
<hbox align="center" flex="1" height="40">
|
<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 disabled="true" id="styleManager-delete" label="-" onclick="Zotero_Preferences.Cite.deleteStyle()"/>
|
||||||
<button label="+" onclick="Zotero_Preferences.Cite.addStyle()"/>
|
<button label="+" onclick="Zotero_Preferences.Cite.addStyle()"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
|
@ -62,7 +62,21 @@ Zotero.MIMETypeHandler = new function () {
|
||||||
else this.unregisterMetadataHandlers();
|
else this.unregisterMetadataHandlers();
|
||||||
}.bind(this));
|
}.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("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-schema", Zotero.Schema.importSchema);
|
||||||
this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings);
|
this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user