Only in zotero-trunk/chrome/content/zotero: addCitationDialog.js.orig
Only in zotero-trunk/chrome/content/zotero: addCitationDialog.js.rej
diff -r -u zotero-trunk.orig/chrome/content/zotero/xpcom/csl.js zotero-trunk/chrome/content/zotero/xpcom/csl.js
|
old
|
new
|
|
| 48 | 48 | Zotero.debug("CSL: style class is "+this.class); |
| 49 | 49 | |
| 50 | 50 | this.hasBibliography = (this._csl.bibliography.length() ? 1 : 0); |
| | 51 | this.daySuffixes = Zotero.getString("date.daySuffixes").replace(/, ?/g, "|").split("|"); |
| | 52 | for each (i in [0,1,2,3]) { |
| | 53 | if (suffix = this._getTerm("ordinal-0"+(i+1), false, false, false, true)) { |
| | 54 | this.daySuffixes[i] = suffix; |
| | 55 | } |
| | 56 | } |
| | 57 | |
| 51 | 58 | } |
| 52 | 59 | |
| 53 | 60 | /* |
| … |
… |
|
| 491 | 498 | /* |
| 492 | 499 | * gets a term, in singular or plural form |
| 493 | 500 | */ |
| 494 | | Zotero.CSL.prototype._getTerm = function(term, plural, form, includePeriod) { |
| | 501 | Zotero.CSL.prototype._getTerm = function(term, plural, form, includePeriod, quiet) { |
| 495 | 502 | if(!form) { |
| 496 | 503 | form = "long"; |
| 497 | 504 | } |
| … |
… |
|
| 504 | 511 | } else if(form != "long") { |
| 505 | 512 | return this._getTerm(term, plural, "long"); |
| 506 | 513 | } else { |
| | 514 | if (!quiet) { |
| 507 | 515 | Zotero.debug("CSL: WARNING: could not find term \""+term+'"'); |
| | 516 | } |
| 508 | 517 | return ""; |
| 509 | 518 | } |
| 510 | 519 | } |
| … |
… |
|
| 809 | 818 | for(var j=0; j<variables.length; j++) { |
| 810 | 819 | if(ignore[0][variables[j]]) continue; |
| 811 | 820 | |
| 812 | | var text = item.getNumericVariable(variables[j], form); |
| | 821 | var text = item.getNumericVariable(variables[j], citationItem, form, this.daySuffixes); |
| 813 | 822 | if(text) { |
| 814 | 823 | newString.append(text); |
| 815 | 824 | success = true; |
| … |
… |
|
| 925 | 934 | for(var j=0; j<variables.length; j++) { |
| 926 | 935 | if(ignore[0][variables[j]]) continue; |
| 927 | 936 | |
| 928 | | var date = item.getDate(variables[j]); |
| | 937 | var date = item.getDate(variables[j], citationItem); |
| 929 | 938 | if(!date) continue; |
| 930 | 939 | |
| 931 | 940 | var variableString = formattedString.clone(); |
| … |
… |
|
| 1057 | 1066 | } |
| 1058 | 1067 | else if(Zotero.CSL._dateVariables[variables[j]]) { |
| 1059 | 1068 | // getDate not false/undefined |
| 1060 | | exists = !!item.getDate(variables[j]); |
| | 1069 | exists = !!item.getDate(variables[j], citationItem); |
| 1061 | 1070 | } else if(Zotero.CSL._namesVariables[variables[j]]) { |
| 1062 | 1071 | // getNames not false/undefined, not empty |
| 1063 | 1072 | exists = item.getNames(variables[j]); |
| … |
… |
|
| 1067 | 1076 | if (exists) exists = !!exists.length; |
| 1068 | 1077 | } |
| 1069 | 1078 | } else if (attribute == "is-numeric") { |
| 1070 | | exists = item.getNumericVariable(variables[j]); |
| | 1079 | exists = item.getNumericVariable(variables[j], citationItem); |
| 1071 | 1080 | } else if (attribute == "is-date") { // XXX - this needs improving |
| 1072 | 1081 | if (Zotero.CSL._dateVariables[variables[j]]) { |
| 1073 | | exists = !!item.getDate(variables[j]); |
| | 1082 | exists = !!item.getDate(variables[j], citationItem); |
| 1074 | 1083 | } |
| 1075 | 1084 | } else if(attribute == "is-plural") { |
| 1076 | 1085 | if(Zotero.CSL._namesVariables[variables[j]]) { |
| … |
… |
|
| 1757 | 1766 | /* |
| 1758 | 1767 | * Gets an Item.Date object for a specific type. |
| 1759 | 1768 | */ |
| 1760 | | Zotero.CSL.Item.prototype.getDate = function(variable) { |
| | 1769 | Zotero.CSL.Item.prototype.getDate = function(variable, citationItem) { |
| 1761 | 1770 | // ignore accessed date |
| 1762 | 1771 | if(this._ignoreURL && variable == "accessed") return false; |
| 1763 | 1772 | |
| 1764 | 1773 | // load date variable if possible |
| 1765 | 1774 | this._refreshItem(); |
| 1766 | | if(this._dates[variable] == undefined) { |
| 1767 | | this._createDate(variable); |
| | 1775 | if(this._dates[variable] == undefined || citationItem) { |
| | 1776 | this._createDate(variable, citationItem); |
| 1768 | 1777 | } |
| 1769 | 1778 | |
| 1770 | 1779 | if(this._dates[variable]) return this._dates[variable]; |
| … |
… |
|
| 1855 | 1864 | /* |
| 1856 | 1865 | * convert a number into a ordinal number 1st, 2nd, 3rd etc. |
| 1857 | 1866 | */ |
| 1858 | | Zotero.CSL.Item.prototype.makeOrdinal = function(value) { |
| | 1867 | Zotero.CSL.Item.prototype.makeOrdinal = function(value, daySuffixes) { |
| 1859 | 1868 | var ind = parseInt(value); |
| 1860 | | var daySuffixes = Zotero.getString("date.daySuffixes").replace(/, ?/g, "|").split("|"); |
| 1861 | 1869 | value += (parseInt(ind/10)%10) == 1 ? daySuffixes[3] : (ind % 10 == 1) ? daySuffixes[0] : (ind % 10 == 2) ? daySuffixes[1] : (ind % 10 == 3) ? daySuffixes[2] : daySuffixes[3]; |
| 1862 | 1870 | return value; |
| 1863 | 1871 | } |
| … |
… |
|
| 1917 | 1925 | * Gets a numeric object for a specific type. <number variable="edition" form="roman"/> |
| 1918 | 1926 | */ |
| 1919 | 1927 | // citationItem argument to function gets access to locator field |
| 1920 | | Zotero.CSL.Item.prototype.getNumericVariable = function(variable, citationItem, form) { |
| | 1928 | // daySuffixes argument provides array for building localized ordinals |
| | 1929 | Zotero.CSL.Item.prototype.getNumericVariable = function(variable, citationItem, form, daySuffixes) { |
| 1921 | 1930 | |
| 1922 | 1931 | if(!Zotero.CSL.Item._zoteroNumberFieldMap[variable]) return ""; |
| 1923 | 1932 | |
| … |
… |
|
| 1944 | 1953 | if(value != "" && (matches = value.match(Zotero.CSL._numberRegexp)) ) { |
| 1945 | 1954 | value = matches[0]; |
| 1946 | 1955 | if (form == "ordinal") { |
| 1947 | | return this.makeOrdinal(value); |
| | 1956 | return this.makeOrdinal(value, daySuffixes); |
| 1948 | 1957 | } |
| 1949 | 1958 | else if (form == "roman") { |
| 1950 | 1959 | return this.makeRoman(value); |
| … |
… |
|
| 2080 | 2089 | * Generates an date object for a given variable (currently supported: issued |
| 2081 | 2090 | * and accessed) |
| 2082 | 2091 | */ |
| 2083 | | Zotero.CSL.Item.prototype._createDate = function(variable) { |
| | 2092 | Zotero.CSL.Item.prototype._createDate = function(variable, citationItem) { |
| 2084 | 2093 | // first, figure out what date variable to use. |
| 2085 | 2094 | if(variable == "issued") { |
| | 2095 | if (citationItem && citationItem.issued) { |
| | 2096 | var date = citationItem.issued |
| | 2097 | } else { |
| 2086 | 2098 | var date = this.zoteroItem.getField("date", false, true); |
| 2087 | | var sort = this.zoteroItem.getField("date", true, true); |
| | 2099 | } |
| | 2100 | var sort = this.zoteroItem.getField("date", true, true); |
| 2088 | 2101 | } else if(variable == "accessed") { |
| 2089 | 2102 | var date = this.zoteroItem.getField("accessDate", false, true); |
| 2090 | 2103 | var sort = this.zoteroItem.getField("accessDate", true, true); |