2006-10-04 17:16:56 +00:00
|
|
|
/*
|
|
|
|
***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
2009-12-28 09:47:49 +00:00
|
|
|
Copyright © 2009 Center for History and New Media
|
|
|
|
George Mason University, Fairfax, Virginia, USA
|
|
|
|
http://zotero.org
|
2006-10-04 17:16:56 +00:00
|
|
|
|
2009-12-28 09:47:49 +00:00
|
|
|
This file is part of Zotero.
|
2006-10-04 17:16:56 +00:00
|
|
|
|
2009-12-28 09:47:49 +00:00
|
|
|
Zotero is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2006-10-04 17:16:56 +00:00
|
|
|
|
2009-12-28 09:47:49 +00:00
|
|
|
Zotero is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
2006-10-04 17:16:56 +00:00
|
|
|
|
|
|
|
***** END LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2006-07-27 23:01:55 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2006-10-02 23:15:27 +00:00
|
|
|
// Zotero_File_Interface_Bibliography
|
2006-07-27 23:01:55 +00:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Class to provide options for bibliography
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var Zotero_File_Interface_Bibliography = new function() {
|
2007-10-23 07:11:59 +00:00
|
|
|
var _io, _saveStyle;
|
2006-07-27 23:01:55 +00:00
|
|
|
|
|
|
|
this.init = init;
|
2007-10-23 07:11:59 +00:00
|
|
|
this.styleChanged = styleChanged;
|
2006-07-27 23:01:55 +00:00
|
|
|
this.acceptSelection = acceptSelection;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize some variables and prepare event listeners for when chrome is done
|
|
|
|
* loading
|
|
|
|
*/
|
|
|
|
function init() {
|
2007-10-23 07:11:59 +00:00
|
|
|
// Set font size from pref
|
|
|
|
// Affects bibliography.xul and integrationDocPrefs.xul
|
2009-09-25 08:30:07 +00:00
|
|
|
Zotero.setFontSize(document.documentElement);
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2009-05-01 11:46:07 +00:00
|
|
|
if(window.arguments && window.arguments.length) {
|
|
|
|
_io = window.arguments[0];
|
|
|
|
if(_io.wrappedJSObject) _io = _io.wrappedJSObject;
|
|
|
|
} else {
|
|
|
|
_io = {};
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2006-07-27 23:01:55 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
var listbox = document.getElementById("style-listbox");
|
2008-09-11 21:29:05 +00:00
|
|
|
var styles = Zotero.Styles.getVisible();
|
2006-07-27 23:01:55 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
// if no style is set, get the last style used
|
|
|
|
if(!_io.style) {
|
|
|
|
_io.style = Zotero.Prefs.get("export.lastStyle");
|
|
|
|
_saveStyle = true;
|
|
|
|
}
|
|
|
|
|
2006-08-29 23:15:13 +00:00
|
|
|
// add styles to list
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
var index = 0;
|
2008-09-11 21:29:05 +00:00
|
|
|
var nStyles = styles.length;
|
2008-10-24 21:08:44 +00:00
|
|
|
var selectIndex = -1;
|
2008-09-11 21:29:05 +00:00
|
|
|
for(var i=0; i<nStyles; i++) {
|
2007-10-23 07:11:59 +00:00
|
|
|
var itemNode = document.createElement("listitem");
|
2008-09-11 21:29:05 +00:00
|
|
|
itemNode.setAttribute("value", styles[i].styleID);
|
|
|
|
itemNode.setAttribute("label", styles[i].title);
|
2006-07-27 23:01:55 +00:00
|
|
|
listbox.appendChild(itemNode);
|
2006-08-29 23:15:13 +00:00
|
|
|
|
2008-09-11 21:29:05 +00:00
|
|
|
if(styles[i].styleID == _io.style) {
|
2008-10-24 21:08:44 +00:00
|
|
|
selectIndex = index;
|
2006-08-29 23:15:13 +00:00
|
|
|
}
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
index++;
|
2006-07-27 23:01:55 +00:00
|
|
|
}
|
|
|
|
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
if (selectIndex < 1) {
|
|
|
|
selectIndex = 0;
|
2006-07-27 23:01:55 +00:00
|
|
|
}
|
2006-08-30 06:12:26 +00:00
|
|
|
|
2010-07-09 20:25:17 +00:00
|
|
|
listbox.ensureIndexIsVisible(selectIndex);
|
|
|
|
listbox.selectedIndex = selectIndex;
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
// ONLY FOR bibliography.xul: export options
|
|
|
|
if(document.getElementById("save-as-rtf")) {
|
|
|
|
// restore saved bibliographic settings
|
Merged revisions 2890,2895-2896,2898,2900-2901,2905,2909-2911,2913,2916-2917,2919,2922,2936-2937,2953-2954,2957,2959,2962-2965,2969-2970,2973-2975,2979-2980,2983 via svnmerge from 1.0 branch
2008-07-07 15:18:49 +00:00
|
|
|
document.getElementById('output-radio').selectedItem =
|
|
|
|
document.getElementById(Zotero.Prefs.get("export.bibliographySettings"));
|
2006-08-30 06:12:26 +00:00
|
|
|
}
|
2006-09-04 08:06:04 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
// ONLY FOR integrationDocPrefs.xul: update status of displayAs, set
|
|
|
|
// bookmarks text
|
|
|
|
if(document.getElementById("displayAs")) {
|
|
|
|
if(_io.useEndnotes && _io.useEndnotes == 1) document.getElementById("displayAs").selectedIndex = 1;
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
styleChanged(selectIndex);
|
2009-05-01 11:46:07 +00:00
|
|
|
}
|
|
|
|
if(document.getElementById("formatUsing")) {
|
2009-08-24 03:26:17 +00:00
|
|
|
if(_io.fieldType == "Bookmark") document.getElementById("formatUsing").selectedIndex = 1;
|
2009-08-20 05:02:55 +00:00
|
|
|
var formatOption = (_io.primaryFieldType == "ReferenceMark" ? "referenceMarks" : "fields");
|
2007-10-23 07:11:59 +00:00
|
|
|
document.getElementById("fields").label = Zotero.getString("integration."+formatOption+".label");
|
|
|
|
document.getElementById("fields-caption").textContent = Zotero.getString("integration."+formatOption+".caption");
|
2009-08-08 11:32:16 +00:00
|
|
|
document.getElementById("fields-file-format-notice").textContent = Zotero.getString("integration."+formatOption+".fileFormatNotice");
|
|
|
|
document.getElementById("bookmarks-file-format-notice").textContent = Zotero.getString("integration.fields.fileFormatNotice");
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
2009-08-25 07:02:24 +00:00
|
|
|
|
|
|
|
// set style to false, in case this is cancelled
|
|
|
|
_io.style = false;
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ONLY FOR integrationDocPrefs.xul: called when style is changed
|
|
|
|
*/
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
function styleChanged(index) {
|
|
|
|
// When called from init(), selectedItem isn't yet set
|
|
|
|
if (index != undefined) {
|
|
|
|
var selectedItem = document.getElementById("style-listbox").getItemAtIndex(index);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var selectedItem = document.getElementById("style-listbox").selectedItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
var selectedStyle = selectedItem.getAttribute('value');
|
|
|
|
|
2008-11-03 10:11:47 +00:00
|
|
|
// update status of displayAs box based on style class
|
2009-05-01 11:46:07 +00:00
|
|
|
if(document.getElementById("displayAs")) {
|
|
|
|
var isNote = Zotero.Styles.get(selectedStyle).class == "note";
|
|
|
|
document.getElementById("displayAs").disabled = !isNote;
|
|
|
|
}
|
Merged revisions 1986,1988-1990,1996,1998,2000-2004,2006,2008-2010,2013,2020-2028,2032-2034,2037,2039,2044-2049,2052-2056,2059,2065-2066,2068-2072,2075,2077-2079,2081,2083-2084,2086,2088-2094,2096,2099,2101,2103-2104,2107-2110,2115,2118,2120-2122,2126-2128,2131,2140,2142-2145,2149-2153,2155-2159,2165,2167-2168,2170-2171,2173-2176,2179-2183,2185-2186 via svnmerge from
https://www.zotero.org/svn/extension/branches/1.0
2008-01-30 09:53:19 +00:00
|
|
|
|
2008-11-03 10:11:47 +00:00
|
|
|
// update status of formatUsing box based on style class
|
2009-05-01 11:46:07 +00:00
|
|
|
if(document.getElementById("formatUsing")) {
|
|
|
|
if(isNote) document.getElementById("formatUsing").selectedIndex = 0;
|
|
|
|
document.getElementById("bookmarks").disabled = isNote;
|
|
|
|
document.getElementById("bookmarks-caption").disabled = isNote;
|
|
|
|
}
|
2006-07-27 23:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function acceptSelection() {
|
|
|
|
// collect code
|
2007-10-23 07:11:59 +00:00
|
|
|
_io.style = document.getElementById("style-listbox").selectedItem.value;
|
2006-08-29 23:15:13 +00:00
|
|
|
if(document.getElementById("output-radio")) {
|
2007-10-23 07:11:59 +00:00
|
|
|
// collect settings
|
2006-08-29 23:15:13 +00:00
|
|
|
_io.output = document.getElementById("output-radio").selectedItem.id;
|
2007-10-23 07:11:59 +00:00
|
|
|
// save settings
|
|
|
|
Zotero.Prefs.set("export.bibliographySettings", _io.output);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ONLY FOR integrationDocPrefs.xul: collect displayAs
|
|
|
|
if(document.getElementById("displayAs")) {
|
|
|
|
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
|
2009-08-20 05:02:55 +00:00
|
|
|
_io.fieldType = (document.getElementById("formatUsing").selectedIndex == 0 ? _io.primaryFieldType : _io.secondaryFieldType);
|
2007-10-23 07:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// save style (this happens only for "Export Bibliography," or Word
|
|
|
|
// integration when no bibliography style was previously selected)
|
|
|
|
if(_saveStyle) {
|
|
|
|
Zotero.Prefs.set("export.lastStyle", _io.style);
|
2006-08-29 23:15:13 +00:00
|
|
|
}
|
2006-07-27 23:01:55 +00:00
|
|
|
}
|
|
|
|
}
|