commit 3a9483070e94aba62780cecee7d5289e2de85223 parent 2fc4ca59bda9b743d2663079da468339e9fc1907 Author: Dan Stillman <dstillman@zotero.org> Date: Thu, 1 Nov 2012 22:14:08 -0400 Merge branch '3.0' Conflicts: chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js chrome/content/zotero/xpcom/translation/translate_firefox.js chrome/content/zotero/zoteroPane.js install.rdf update.rdf Diffstat:
18 files changed, 267 insertions(+), 109 deletions(-)
diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js @@ -95,9 +95,24 @@ var Zotero_File_Interface_Bibliography = new function() { // ONLY FOR bibliography.xul: export options if(document.getElementById("save-as-rtf")) { + var settings = Zotero.Prefs.get("export.bibliographySettings"); + try { + settings = JSON.parse(settings); + var mode = settings.mode; + var method = settings.method; + } + // If not JSON, assume it's the previous format-as-a-string + catch (e) { + method = settings; + } + if (!mode) mode = "bibliography"; + if (!method) method = "save-as-rtf"; + // restore saved bibliographic settings - document.getElementById('output-radio').selectedItem = - document.getElementById(Zotero.Prefs.get("export.bibliographySettings")); + document.getElementById('output-mode-radio').selectedItem = + document.getElementById(mode); + document.getElementById('output-method-radio').selectedItem = + document.getElementById(method); } // ONLY FOR integrationDocPrefs.xul: update status of displayAs, set @@ -126,7 +141,7 @@ var Zotero_File_Interface_Bibliography = new function() { } /* - * ONLY FOR integrationDocPrefs.xul: called when style is changed + * Called when style is changed */ function styleChanged(index) { // When called from init(), selectedItem isn't yet set @@ -139,6 +154,10 @@ var Zotero_File_Interface_Bibliography = new function() { var selectedStyle = selectedItem.getAttribute('value'); + // + // For integrationDocPrefs.xul + // + // update status of displayAs box based on style class if(document.getElementById("displayAs")) { var isNote = Zotero.Styles.get(selectedStyle).class == "note"; @@ -151,16 +170,32 @@ var Zotero_File_Interface_Bibliography = new function() { document.getElementById("bookmarks").disabled = isNote; document.getElementById("bookmarks-caption").disabled = isNote; } + + // + // For bibliography.xul + // + + // Change label to "Citation" or "Note" depending on style class + if(document.getElementById("citation")) { + if(Zotero.Styles.get(selectedStyle).class == "note") { + var label = Zotero.getString('citation.note'); + } else { + var label = Zotero.getString('citation.citation'); + } + document.getElementById("citation").label = label; + } } function acceptSelection() { // collect code _io.style = document.getElementById("style-listbox").selectedItem.value; - if(document.getElementById("output-radio")) { + if(document.getElementById("output-method-radio")) { // collect settings - _io.output = document.getElementById("output-radio").selectedItem.id; + _io.mode = document.getElementById("output-mode-radio").selectedItem.id; + _io.method = document.getElementById("output-method-radio").selectedItem.id; // save settings - Zotero.Prefs.set("export.bibliographySettings", _io.output); + Zotero.Prefs.set("export.bibliographySettings", + JSON.stringify({ mode: _io.mode, method: _io.method })); } // ONLY FOR integrationDocPrefs.xul: collect displayAs diff --git a/chrome/content/zotero/bibliography.xul b/chrome/content/zotero/bibliography.xul @@ -14,11 +14,18 @@ <vbox id="zotero-bibliography-container"> <groupbox> <caption label="&zotero.bibliography.style.label;"/> - <listbox id="style-listbox" oncommand="Zotero_File_Interface_Bibliography.styleChanged()"/> + <listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/> </groupbox> <groupbox> - <caption label="&zotero.bibliography.output.label;"/> - <radiogroup id="output-radio"> + <caption label="&zotero.bibliography.outputMode;"/> + <radiogroup id="output-mode-radio"> + <radio id="citation"/> + <radio id="bibliography" label="&zotero.bibliography.bibliography;"/> + </radiogroup> + </groupbox> + <groupbox> + <caption label="&zotero.bibliography.outputMethod;"/> + <radiogroup id="output-method-radio"> <radio id="save-as-rtf" label="&zotero.bibliography.saveAsRTF.label;"/> <radio id="save-as-html" label="&zotero.bibliography.saveAsHTML.label;"/> <radio id="copy-to-clipboard" label="&zotero.bibliography.copyToClipboard.label;"/> diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml @@ -268,11 +268,28 @@ <body> <![CDATA[ switch (event.keyCode) { - // Insert tab manually case 9: - if (event.shiftKey || event.ctrlKey || event.altKey) { + if (event.ctrlKey || event.altKey) { return; } + + event.stopPropagation(); + event.preventDefault(); + + // On shift-tab, focus the element specified in + // the 'previousfocus' attribute + if (event.shiftKey) { + let id = this.getAttribute('previousfocus'); + if (id) { + setTimeout(function () { + document.getElementById(id).focus(); + }, 0); + } + return; + } + + // Insert tab manually + // // From http://kb.mozillazine.org/Inserting_text_at_cursor try { var command = "cmd_insertText"; @@ -289,9 +306,6 @@ Zotero.debug("Can't do cmd_insertText!\n" + e, 1); } - event.stopPropagation(); - event.preventDefault(); - // DEBUG: is there a better way to prevent blur()? setTimeout(function() { event.target.focus(); }, 1); break; diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js @@ -521,30 +521,43 @@ var Zotero_File_Interface = new function() { var newDialog = window.openDialog("chrome://zotero/content/bibliography.xul", "_blank","chrome,modal,centerscreen", io); - if(!io.output) return; + if(!io.method) return; // determine output format var format = "html"; - if(io.output == "save-as-rtf") { + if(io.method == "save-as-rtf") { format = "rtf"; } // generate bibliography try { - if(io.output == 'copy-to-clipboard') { - copyItemsToClipboard(items, io.style); + if(io.method == 'copy-to-clipboard') { + if (io.mode == 'citation') { + copyCitationToClipboard(items, io.style); + } + else { + copyItemsToClipboard(items, io.style); + } return; } else { - var style = Zotero.Styles.get(io.style); - var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, format); + if (io.mode == 'citation') { + var csl = Zotero.Styles.get(format).csl; + csl.updateItems([item.id for each(item in items)]); + var citation = {citationItems:[{id:item.id} for each(item in items)], properties:{}}; + var bibliography = csl.previewCitationCluster(citation, [], [], "html"); + } + else { + var style = Zotero.Styles.get(io.style); + var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, format); + } } } catch(e) { window.alert(Zotero.getString("fileInterface.bibliographyGenerationError")); throw(e); } - if(io.output == "print") { + if(io.method == "print") { // printable bibliography, using a hidden browser var browser = Zotero.Browser.createHiddenBrowser(window); @@ -581,7 +594,7 @@ var Zotero_File_Interface = new function() { browser.addEventListener("pageshow", listener, false); browser.loadURIWithFlags("data:text/html;charset=utf-8,"+encodeURI(bibliography), Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, "utf-8", null); - } else if(io.output == "save-as-html") { + } else if(io.method == "save-as-html") { var fStream = _saveBibliography(name, "HTML"); if(fStream !== false) { @@ -607,7 +620,7 @@ var Zotero_File_Interface = new function() { os.close(); fStream.close(); } - } else if(io.output == "save-as-rtf") { + } else if(io.method == "save-as-rtf") { var fStream = _saveBibliography(name, "RTF"); if(fStream !== false) { fStream.write(bibliography, bibliography.length); diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul @@ -90,7 +90,7 @@ <!-- Note item --> <groupbox id="zotero-view-note" flex="1"> - <zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"/> + <zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1" previousfocus="zotero-items-tree"/> <button id="zotero-view-note-button" label="&zotero.notes.separate;" oncommand="ZoteroPane_Local.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ZoteroPane_Local.selectItem(this.getAttribute('sourceID'));"/> </groupbox> diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js @@ -118,7 +118,9 @@ const Zotero_Lookup = new function () { /** * Cancels the popup and resets fields */ - this.onHidden = function() { - document.getElementById("zotero-lookup-textbox").value = ""; + this.onHidden = function(event) { + if (event.target.id == 'zotero-lookup-panel') { + document.getElementById("zotero-lookup-textbox").value = ""; + } } } diff --git a/chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js b/chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js @@ -1 +1 @@ -(function(){var c=tinymce.each,a={paste_auto_cleanup_on_paste:true,paste_enable_default_filters:true,paste_block_drop:false,paste_retain_style_properties:"none",paste_strip_class_attributes:"mso",paste_remove_spans:false,paste_remove_styles:false,paste_remove_styles_if_webkit:true,paste_convert_middot_lists:true,paste_convert_headers_to_strong:false,paste_dialog_width:"450",paste_dialog_height:"400",paste_max_consecutive_linebreaks:2,paste_text_use_dialog:false,paste_text_sticky:false,paste_text_sticky_default:false,paste_text_notifyalways:false,paste_text_linebreaktype:"combined",paste_text_replacements:[[/\u2026/g,"..."],[/[\x93\x94\u201c\u201d]/g,'"'],[/[\x60\x91\x92\u2018\u2019]/g,"'"]]};function b(d,e){return d.getParam(e,a[e])}tinymce.create("tinymce.plugins.PastePlugin",{init:function(d,e){var f=this;f.editor=d;f.url=e;f.onPreProcess=new tinymce.util.Dispatcher(f);f.onPostProcess=new tinymce.util.Dispatcher(f);f.onPreProcess.add(f._preProcess);f.onPostProcess.add(f._postProcess);f.onPreProcess.add(function(i,j){d.execCallback("paste_preprocess",i,j)});f.onPostProcess.add(function(i,j){d.execCallback("paste_postprocess",i,j)});d.onKeyDown.addToTop(function(i,j){if(((tinymce.isMac?j.metaKey:j.ctrlKey)&&j.keyCode==86)||(j.shiftKey&&j.keyCode==45)){return false}});d.pasteAsPlainText=b(d,"paste_text_sticky_default");function h(l,j){var k=d.dom,i;f.onPreProcess.dispatch(f,l);l.node=k.create("div",0,l.content);if(tinymce.isGecko){i=d.selection.getRng(true);if(i.startContainer==i.endContainer&&i.startContainer.nodeType==3){if(l.node.childNodes.length===1&&/^(p|h[1-6]|pre)$/i.test(l.node.firstChild.nodeName)&&l.content.indexOf("__MCE_ITEM__")===-1){k.remove(l.node.firstChild,true)}}}f.onPostProcess.dispatch(f,l);l.content=d.serializer.serialize(l.node,{getInner:1,forced_root_block:""});if((!j)&&(d.pasteAsPlainText)){f._insertPlainText(l.content);if(!b(d,"paste_text_sticky")){d.pasteAsPlainText=false;d.controlManager.setActive("pastetext",false)}}else{f._insert(l.content)}}d.addCommand("mceInsertClipboardContent",function(i,j){h(j,true)});if(!b(d,"paste_text_use_dialog")){d.addCommand("mcePasteText",function(j,i){var k=tinymce.util.Cookie;d.pasteAsPlainText=!d.pasteAsPlainText;d.controlManager.setActive("pastetext",d.pasteAsPlainText);if((d.pasteAsPlainText)&&(!k.get("tinymcePasteText"))){if(b(d,"paste_text_sticky")){d.windowManager.alert(d.translate("paste.plaintext_mode_sticky"))}else{d.windowManager.alert(d.translate("paste.plaintext_mode"))}if(!b(d,"paste_text_notifyalways")){k.set("tinymcePasteText","1",new Date(new Date().getFullYear()+1,12,31))}}})}d.addButton("pastetext",{title:"paste.paste_text_desc",cmd:"mcePasteText"});d.addButton("selectall",{title:"paste.selectall_desc",cmd:"selectall"});function g(s){var l,p,j,t,k=d.selection,o=d.dom,q=d.getBody(),i,r;if(s.clipboardData||o.doc.dataTransfer){r=(s.clipboardData||o.doc.dataTransfer).getData("Text");if(d.pasteAsPlainText){s.preventDefault();h({content:o.encode(r).replace(/\r?\n/g,"<br />")});return}}if(o.get("_mcePaste")){return}l=o.add(q,"div",{id:"_mcePaste","class":"mcePaste","data-mce-bogus":"1"},"\uFEFF\uFEFF");if(q!=d.getDoc().body){i=o.getPos(d.selection.getStart(),q).y}else{i=q.scrollTop+o.getViewPort(d.getWin()).y}o.setStyles(l,{position:"absolute",left:tinymce.isGecko?-40:0,top:i-25,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){t=k.getRng();j=o.doc.body.createTextRange();j.moveToElementText(l);j.execCommand("Paste");o.remove(l);if(l.innerHTML==="\uFEFF\uFEFF"){d.execCommand("mcePasteWord");s.preventDefault();return}k.setRng(t);k.setContent("");setTimeout(function(){h({content:l.innerHTML})},0);return tinymce.dom.Event.cancel(s)}else{function m(n){n.preventDefault()}o.bind(d.getDoc(),"mousedown",m);o.bind(d.getDoc(),"keydown",m);p=d.selection.getRng();l=l.firstChild;j=d.getDoc().createRange();j.setStart(l,0);j.setEnd(l,2);k.setRng(j);window.setTimeout(function(){var u="",n;if(!o.select("div.mcePaste > div.mcePaste").length){n=o.select("div.mcePaste");c(n,function(w){var v=w.firstChild;if(v&&v.nodeName=="DIV"&&v.style.marginTop&&v.style.backgroundColor){o.remove(v,1)}c(o.select("span.Apple-style-span",w),function(x){o.remove(x,1)});c(o.select("br[data-mce-bogus]",w),function(x){o.remove(x)});if(w.parentNode.className!="mcePaste"){u+=w.innerHTML}})}else{u="<p>"+o.encode(r).replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br />")+"</p>"}c(o.select("div.mcePaste"),function(v){o.remove(v)});if(p){k.setRng(p)}h({content:u});o.unbind(d.getDoc(),"mousedown",m);o.unbind(d.getDoc(),"keydown",m)},0)}}if(b(d,"paste_auto_cleanup_on_paste")){if(/* Modified by Dan S./Zotero tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)*/false){d.onKeyDown.addToTop(function(i,j){if(((tinymce.isMac?j.metaKey:j.ctrlKey)&&j.keyCode==86)||(j.shiftKey&&j.keyCode==45)){g(j)}})}else{d.onPaste.addToTop(function(i,j){return g(j)})}}d.onInit.add(function(){d.controlManager.setActive("pastetext",d.pasteAsPlainText);if(b(d,"paste_block_drop")){d.dom.bind(d.getBody(),["dragend","dragover","draggesture","dragdrop","drop","drag"],function(i){i.preventDefault();i.stopPropagation();return false})}});f._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(g,e){var k=this.editor,j=e.content,p=tinymce.grep,n=tinymce.explode,f=tinymce.trim,l,i;function d(h){c(h,function(o){if(o.constructor==RegExp){j=j.replace(o,"")}else{j=j.replace(o[0],o[1])}})}if(k.settings.paste_enable_default_filters==false){return}if(tinymce.isIE&&document.documentMode>=9&&/<(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)/.test(e.content)){d([[/(?:<br> [\s\r\n]+|<br>)*(<\/?(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)[^>]*>)(?:<br> [\s\r\n]+|<br>)*/g,"$1"]]);d([[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}if(/class="?Mso|style="[^"]*\bmso-|w:WordDocument/i.test(j)||e.wordContent){e.wordContent=true;d([/^\s*( )+/gi,/( |<br[^>]*>)+\s*$/gi]);if(b(k,"paste_convert_headers_to_strong")){j=j.replace(/<p [^>]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"<p><strong>$1</strong></p>")}if(b(k,"paste_convert_middot_lists")){d([[/<!--\[if !supportLists\]-->/gi,"$&__MCE_ITEM__"],[/(<span[^>]+(?:mso-list:|:\s*symbol)[^>]+>)/gi,"$1__MCE_ITEM__"],[/(<p[^>]+(?:MsoListParagraph)[^>]+>)/gi,"$1__MCE_ITEM__"]])}d([/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\u00a0"]]);do{l=j.length;j=j.replace(/(<[a-z][^>]*\s)(?:id|name|language|type|on\w+|\w+:\w+)=(?:"[^"]*"|\w+)\s?/gi,"$1")}while(l!=j.length);if(b(k,"paste_retain_style_properties").replace(/^none$/i,"").length==0){j=j.replace(/<\/?span[^>]*>/gi,"")}else{d([[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(o,h){return(h.length>0)?h.replace(/./," ").slice(Math.floor(h.length/2)).split("").join("\u00a0"):""}],[/(<[a-z][^>]*)\sstyle="([^"]*)"/gi,function(t,h,r){var u=[],o=0,q=n(f(r).replace(/"/gi,"'"),";");c(q,function(s){var w,y,z=n(s,":");function x(A){return A+((A!=="0")&&(/\d$/.test(A)))?"px":""}if(z.length==2){w=z[0].toLowerCase();y=z[1].toLowerCase();switch(w){case"mso-padding-alt":case"mso-padding-top-alt":case"mso-padding-right-alt":case"mso-padding-bottom-alt":case"mso-padding-left-alt":case"mso-margin-alt":case"mso-margin-top-alt":case"mso-margin-right-alt":case"mso-margin-bottom-alt":case"mso-margin-left-alt":case"mso-table-layout-alt":case"mso-height":case"mso-width":case"mso-vertical-align-alt":u[o++]=w.replace(/^mso-|-alt$/g,"")+":"+x(y);return;case"horiz-align":u[o++]="text-align:"+y;return;case"vert-align":u[o++]="vertical-align:"+y;return;case"font-color":case"mso-foreground":u[o++]="color:"+y;return;case"mso-background":case"mso-highlight":u[o++]="background:"+y;return;case"mso-default-height":u[o++]="min-height:"+x(y);return;case"mso-default-width":u[o++]="min-width:"+x(y);return;case"mso-padding-between-alt":u[o++]="border-collapse:separate;border-spacing:"+x(y);return;case"text-line-through":if((y=="single")||(y=="double")){u[o++]="text-decoration:line-through"}return;case"mso-zero-height":if(y=="yes"){u[o++]="display:none"}return}if(/^(mso|column|font-emph|lang|layout|line-break|list-image|nav|panose|punct|row|ruby|sep|size|src|tab-|table-border|text-(?!align|decor|indent|trans)|top-bar|version|vnd|word-break)/.test(w)){return}u[o++]=w+":"+z[1]}});if(o>0){return h+' style="'+u.join(";")+'"'}else{return h}}]])}}if(b(k,"paste_convert_headers_to_strong")){d([[/<h[1-6][^>]*>/gi,"<p><strong>"],[/<\/h[1-6][^>]*>/gi,"</strong></p>"]])}d([[/Version:[\d.]+\nStartHTML:\d+\nEndHTML:\d+\nStartFragment:\d+\nEndFragment:\d+/gi,""]]);i=b(k,"paste_strip_class_attributes");if(i!=="none"){function m(q,o){if(i==="all"){return""}var h=p(n(o.replace(/^(["'])(.*)\1$/,"$2")," "),function(r){return(/^(?!mso)/i.test(r))});return h.length?' class="'+h.join(" ")+'"':""}j=j.replace(/ class="([^"]+)"/gi,m);j=j.replace(/ class=([\-\w]+)/gi,m)}if(b(k,"paste_remove_spans")){j=j.replace(/<\/?span[^>]*>/gi,"")}e.content=j},_postProcess:function(g,i){var f=this,e=f.editor,h=e.dom,d;if(e.settings.paste_enable_default_filters==false){return}if(i.wordContent){c(h.select("a",i.node),function(j){if(!j.href||j.href.indexOf("#_Toc")!=-1){h.remove(j,1)}});if(b(e,"paste_convert_middot_lists")){f._convertLists(g,i)}d=b(e,"paste_retain_style_properties");if((tinymce.is(d,"string"))&&(d!=="all")&&(d!=="*")){d=tinymce.explode(d.replace(/^none$/i,""));c(h.select("*",i.node),function(m){var n={},k=0,l,o,j;if(d){for(l=0;l<d.length;l++){o=d[l];j=h.getStyle(m,o);if(j){n[o]=j;k++}}}h.setAttrib(m,"style","");if(d&&k>0){h.setStyles(m,n)}else{if(m.nodeName=="SPAN"&&!m.className){h.remove(m,true)}}})}}if(b(e,"paste_remove_styles")||(b(e,"paste_remove_styles_if_webkit")&&tinymce.isWebKit)){c(h.select("*[style]",i.node),function(j){j.removeAttribute("style");j.removeAttribute("data-mce-style")})}else{if(tinymce.isWebKit){c(h.select("*",i.node),function(j){j.removeAttribute("data-mce-style")})}}},_convertLists:function(g,e){var i=g.editor.dom,h,l,d=-1,f,m=[],k,j;c(i.select("p",e.node),function(t){var q,u="",s,r,n,o;for(q=t.firstChild;q&&q.nodeType==3;q=q.nextSibling){u+=q.nodeValue}u=t.innerHTML.replace(/<\/?\w+[^>]*>/gi,"").replace(/ /g,"\u00a0");if(/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o\u25CF]\s*\u00a0*/.test(u)){s="ul"}if(/^__MCE_ITEM__\s*\w+\.\s*\u00a0+/.test(u)){s="ol"}if(s){f=parseFloat(t.style.marginLeft||0);if(f>d){m.push(f)}if(!h||s!=k){h=i.create(s);i.insertAfter(h,t)}else{if(f>d){h=l.appendChild(i.create(s))}else{if(f<d){n=tinymce.inArray(m,f);o=i.getParents(h.parentNode,s);h=o[o.length-1-n]||h}}}c(i.select("span",t),function(v){var p=v.innerHTML.replace(/<\/?\w+[^>]*>/gi,"");if(s=="ul"&&/^__MCE_ITEM__[\u2022\u00b7\u00a7\u00d8o\u25CF]/.test(p)){i.remove(v)}else{if(/^__MCE_ITEM__[\s\S]*\w+\.( |\u00a0)*\s*/.test(p)){i.remove(v)}}});r=t.innerHTML;if(s=="ul"){r=t.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^[\u2022\u00b7\u00a7\u00d8o\u25CF]\s*( |\u00a0)+\s*/,"")}else{r=t.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.( |\u00a0)+\s*/,"")}l=h.appendChild(i.create("li",0,r));i.remove(t);d=f;k=s}else{h=d=0}});j=e.node.innerHTML;if(j.indexOf("__MCE_ITEM__")!=-1){e.node.innerHTML=j.replace(/__MCE_ITEM__/g,"")}},_insert:function(f,d){var e=this.editor,g=e.selection.getRng();if(!e.selection.isCollapsed()&&g.startContainer!=g.endContainer){e.getDoc().execCommand("Delete",false,null)}e.execCommand("mceInsertContent",false,f,{skip_undo:d})},_insertPlainText:function(j){var h=this.editor,f=b(h,"paste_text_linebreaktype"),k=b(h,"paste_text_replacements"),g=tinymce.is;function e(m){c(m,function(n){if(n.constructor==RegExp){j=j.replace(n,"")}else{j=j.replace(n[0],n[1])}})}if((typeof(j)==="string")&&(j.length>0)){if(/<(?:p|br|h[1-6]|ul|ol|dl|table|t[rdh]|div|blockquote|fieldset|pre|address|center)[^>]*>/i.test(j)){e([/[\n\r]+/g])}else{e([/\r+/g])}e([[/<\/(?:p|h[1-6]|ul|ol|dl|table|div|blockquote|fieldset|pre|address|center)>/gi,"\n\n"],[/<br[^>]*>|<\/tr>/gi,"\n"],[/<\/t[dh]>\s*<t[dh][^>]*>/gi,"\t"],/<[a-z!\/?][^>]*>/gi,[/ /gi," "],[/(?:(?!\n)\s)*(\n+)(?:(?!\n)\s)*/gi,"$1"]]);var d=Number(b(h,"paste_max_consecutive_linebreaks"));if(d>-1){var l=new RegExp("\n{"+(d+1)+",}","g");var i="";while(i.length<d){i+="\n"}e([[l,i]])}j=h.dom.decode(tinymce.html.Entities.encodeRaw(j));if(g(k,"array")){e(k)}else{if(g(k,"string")){e(new RegExp(k,"gi"))}}if(f=="none"){e([[/\n+/g," "]])}else{if(f=="br"){e([[/\n/g,"<br />"]])}else{if(f=="p"){e([[/\n+/g,"</p><p>"],[/^(.*<\/p>)(<p>)$/,"<p>$1"]])}else{e([[/\n\n/g,"</p><p>"],[/^(.*<\/p>)(<p>)$/,"<p>$1"],[/\n/g,"<br />"]])}}}h.execCommand("mceInsertContent",false,j)}},_legacySupport:function(){var e=this,d=e.editor;d.addCommand("mcePasteWord",function(){d.windowManager.open({file:e.url+"/pasteword.htm",width:parseInt(b(d,"paste_dialog_width")),height:parseInt(b(d,"paste_dialog_height")),inline:1})});if(b(d,"paste_text_use_dialog")){d.addCommand("mcePasteText",function(){d.windowManager.open({file:e.url+"/pastetext.htm",width:parseInt(b(d,"paste_dialog_width")),height:parseInt(b(d,"paste_dialog_height")),inline:1})})}d.addButton("pasteword",{title:"paste.paste_word_desc",cmd:"mcePasteWord"})}});tinymce.PluginManager.add("paste",tinymce.plugins.PastePlugin)})(); -\ No newline at end of file +(function(){var c=tinymce.each,a={paste_auto_cleanup_on_paste:true,paste_enable_default_filters:true,paste_block_drop:false,paste_retain_style_properties:"none",paste_strip_class_attributes:"mso",paste_remove_spans:false,paste_remove_styles:false,paste_remove_styles_if_webkit:true,paste_convert_middot_lists:true,paste_convert_headers_to_strong:false,paste_dialog_width:"450",paste_dialog_height:"400",paste_max_consecutive_linebreaks:2,paste_text_use_dialog:false,paste_text_sticky:false,paste_text_sticky_default:false,paste_text_notifyalways:false,paste_text_linebreaktype:"combined",paste_text_replacements:[[/\u2026/g,"..."],[/[\x93\x94\u201c\u201d]/g,'"'],[/[\x60\x91\x92\u2018\u2019]/g,"'"]]};function b(d,e){return d.getParam(e,a[e])}tinymce.create("tinymce.plugins.PastePlugin",{init:function(d,e){var f=this;f.editor=d;f.url=e;f.onPreProcess=new tinymce.util.Dispatcher(f);f.onPostProcess=new tinymce.util.Dispatcher(f);f.onPreProcess.add(f._preProcess);f.onPostProcess.add(f._postProcess);f.onPreProcess.add(function(i,j){d.execCallback("paste_preprocess",i,j)});f.onPostProcess.add(function(i,j){d.execCallback("paste_postprocess",i,j)});d.onKeyDown.addToTop(function(i,j){if(((tinymce.isMac?j.metaKey:j.ctrlKey)&&j.keyCode==86)||(j.shiftKey&&j.keyCode==45)){return false}});d.pasteAsPlainText=b(d,"paste_text_sticky_default");function h(l,j){var k=d.dom,i;f.onPreProcess.dispatch(f,l);l.node=k.create("div",0,l.content);if(tinymce.isGecko){i=d.selection.getRng(true);if(i.startContainer==i.endContainer&&i.startContainer.nodeType==3){if(l.node.childNodes.length===1&&/^(p|h[1-6]|pre)$/i.test(l.node.firstChild.nodeName)&&l.content.indexOf("__MCE_ITEM__")===-1){k.remove(l.node.firstChild,true)}}}f.onPostProcess.dispatch(f,l);l.content=d.serializer.serialize(l.node,{getInner:1,forced_root_block:""});if((!j)&&(d.pasteAsPlainText)){f._insertPlainText(l.content);if(!b(d,"paste_text_sticky")){d.pasteAsPlainText=false;d.controlManager.setActive("pastetext",false)}}else{f._insert(l.content)}}d.addCommand("mceInsertClipboardContent",function(i,j){h(j,true)});if(!b(d,"paste_text_use_dialog")){d.addCommand("mcePasteText",function(j,i){var k=tinymce.util.Cookie;d.pasteAsPlainText=!d.pasteAsPlainText;d.controlManager.setActive("pastetext",d.pasteAsPlainText);if((d.pasteAsPlainText)&&(!k.get("tinymcePasteText"))){if(b(d,"paste_text_sticky")){d.windowManager.alert(d.translate("paste.plaintext_mode_sticky"))}else{d.windowManager.alert(d.translate("paste.plaintext_mode"))}if(!b(d,"paste_text_notifyalways")){k.set("tinymcePasteText","1",new Date(new Date().getFullYear()+1,12,31))}}})}d.addButton("pastetext",{title:"paste.paste_text_desc",cmd:"mcePasteText"});d.addButton("selectall",{title:"paste.selectall_desc",cmd:"selectall"});function g(s){var l,p,j,t,k=d.selection,o=d.dom,q=d.getBody(),i,r;if(s.clipboardData||o.doc.dataTransfer){r=(s.clipboardData||o.doc.dataTransfer).getData("Text");if(d.pasteAsPlainText){s.preventDefault();h({content:o.encode(r).replace(/\r?\n/g,"<br />")});return}}if(o.get("_mcePaste")){return}l=o.add(q,"div",{id:"_mcePaste","class":"mcePaste","data-mce-bogus":"1"},"\uFEFF\uFEFF");if(q!=d.getDoc().body){i=o.getPos(d.selection.getStart(),q).y}else{i=q.scrollTop+o.getViewPort(d.getWin()).y}o.setStyles(l,{position:"absolute",left:tinymce.isGecko?-40:0,top:i-25,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){t=k.getRng();j=o.doc.body.createTextRange();j.moveToElementText(l);j.execCommand("Paste");o.remove(l);if(l.innerHTML==="\uFEFF\uFEFF"){d.execCommand("mcePasteWord");s.preventDefault();return}k.setRng(t);k.setContent("");setTimeout(function(){h({content:l.innerHTML})},0);return tinymce.dom.Event.cancel(s)}else{function m(n){n.preventDefault()}o.bind(d.getDoc(),"mousedown",m);o.bind(d.getDoc(),"keydown",m);p=d.selection.getRng();l=l.firstChild;j=d.getDoc().createRange();j.setStart(l,0);j.setEnd(l,2);k.setRng(j);window.setTimeout(function(){var u="",n;if(!o.select("div.mcePaste > div.mcePaste").length){n=o.select("div.mcePaste");c(n,function(w){var v=w.firstChild;if(v&&v.nodeName=="DIV"&&v.style.marginTop&&v.style.backgroundColor){o.remove(v,1)}c(o.select("span.Apple-style-span",w),function(x){o.remove(x,1)});c(o.select("br[data-mce-bogus]",w),function(x){o.remove(x)});if(w.parentNode.className!="mcePaste"){u+=w.innerHTML}})}else{u="<p>"+o.encode(r).replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br />")+"</p>"}c(o.select("div.mcePaste"),function(v){o.remove(v)});if(p){k.setRng(p)}h({content:u});o.unbind(d.getDoc(),"mousedown",m);o.unbind(d.getDoc(),"keydown",m)},0)}}if(b(d,"paste_auto_cleanup_on_paste")){if(/* Modified by Dan S./Zotero tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)*/false){d.onKeyDown.addToTop(function(i,j){if(((tinymce.isMac?j.metaKey:j.ctrlKey)&&j.keyCode==86)||(j.shiftKey&&j.keyCode==45)){g(j)}})}else{d.onPaste.addToTop(function(i,j){return g(j)})}}d.onInit.add(function(){d.controlManager.setActive("pastetext",d.pasteAsPlainText);if(b(d,"paste_block_drop")){d.dom.bind(d.getBody(),["dragend","dragover","draggesture","dragdrop","drop","drag"],function(i){i.preventDefault();i.stopPropagation();return false})}});f._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(g,e){var k=this.editor,j=e.content,p=tinymce.grep,n=tinymce.explode,f=tinymce.trim,l,i;function d(h){c(h,function(o){if(o.constructor==RegExp){j=j.replace(o,"")}else{j=j.replace(o[0],o[1])}})}if(k.settings.paste_enable_default_filters==false){return}if(tinymce.isIE&&document.documentMode>=9&&/<(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)/.test(e.content)){d([[/(?:<br> [\s\r\n]+|<br>)*(<\/?(h[1-6r]|p|div|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|caption|blockquote|center|dl|dt|dd|dir|fieldset)[^>]*>)(?:<br> [\s\r\n]+|<br>)*/g,"$1"]]);d([[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}if(/class="?Mso|style="[^"]*\bmso-|w:WordDocument/i.test(j)||e.wordContent){e.wordContent=true;d([/^\s*( )+/gi,/( |<br[^>]*>)+\s*$/gi]);if(b(k,"paste_convert_headers_to_strong")){j=j.replace(/<p [^>]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"<p><strong>$1</strong></p>")}if(b(k,"paste_convert_middot_lists")){d([[/<!--\[if !supportLists\]-->/gi,"$&__MCE_ITEM__"],[/(<span[^>]+(?:mso-list:|:\s*symbol)[^>]+>)/gi,"$1__MCE_ITEM__"],[/(<p[^>]+(?:MsoListParagraph)[^>]+>)/gi,"$1__MCE_ITEM__"]])}d([/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\u00a0"]]);do{l=j.length;j=j.replace(/(<[a-z][^>]*\s)(?:id|name|language|type|on\w+|\w+:\w+)=(?:"[^"]*"|\w+)\s?/gi,"$1")}while(l!=j.length);if(b(k,"paste_retain_style_properties").replace(/^none$/i,"").length==0){j=j.replace(/<\/?span[^>]*>/gi,"")}else{d([[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(o,h){return(h.length>0)?h.replace(/./," ").slice(Math.floor(h.length/2)).split("").join("\u00a0"):""}],[/(<[a-z][^>]*)\sstyle="([^"]*)"/gi,function(t,h,r){var u=[],o=0,q=n(f(r).replace(/"/gi,"'"),";");c(q,function(s){var w,y,z=n(s,":");function x(A){return A+((A!=="0")&&(/\d$/.test(A)))?"px":""}if(z.length==2){w=z[0].toLowerCase();y=z[1].toLowerCase();switch(w){case"mso-padding-alt":case"mso-padding-top-alt":case"mso-padding-right-alt":case"mso-padding-bottom-alt":case"mso-padding-left-alt":case"mso-margin-alt":case"mso-margin-top-alt":case"mso-margin-right-alt":case"mso-margin-bottom-alt":case"mso-margin-left-alt":case"mso-table-layout-alt":case"mso-height":case"mso-width":case"mso-vertical-align-alt":u[o++]=w.replace(/^mso-|-alt$/g,"")+":"+x(y);return;case"horiz-align":u[o++]="text-align:"+y;return;case"vert-align":u[o++]="vertical-align:"+y;return;case"font-color":case"mso-foreground":u[o++]="color:"+y;return;case"mso-background":case"mso-highlight":u[o++]="background:"+y;return;case"mso-default-height":u[o++]="min-height:"+x(y);return;case"mso-default-width":u[o++]="min-width:"+x(y);return;case"mso-padding-between-alt":u[o++]="border-collapse:separate;border-spacing:"+x(y);return;case"text-line-through":if((y=="single")||(y=="double")){u[o++]="text-decoration:line-through"}return;case"mso-zero-height":if(y=="yes"){u[o++]="display:none"}return}if(/^(mso|column|font-emph|lang|layout|line-break|list-image|nav|panose|punct|row|ruby|sep|size|src|tab-|table-border|text-(?!align|decor|indent|trans)|top-bar|version|vnd|word-break)/.test(w)){return}u[o++]=w+":"+z[1]}});if(o>0){return h+' style="'+u.join(";")+'"'}else{return h}}]])}}if(b(k,"paste_convert_headers_to_strong")){d([[/<h[1-6][^>]*>/gi,"<p><strong>"],[/<\/h[1-6][^>]*>/gi,"</strong></p>"]])}d([[/Version:[\d.]+\nStartHTML:\d+\nEndHTML:\d+\nStartFragment:\d+\nEndFragment:\d+/gi,""]]);i=b(k,"paste_strip_class_attributes");if(i!=="none"){function m(q,o){if(i==="all"){return""}var h=p(n(o.replace(/^(["'])(.*)\1$/,"$2")," "),function(r){return(/^(?!mso)/i.test(r))});return h.length?' class="'+h.join(" ")+'"':""}j=j.replace(/ class="([^"]+)"/gi,m);j=j.replace(/ class=([\-\w]+)/gi,m)}if(b(k,"paste_remove_spans")){j=j.replace(/<\/?span[^>]*>/gi,"")}e.content=j},_postProcess:function(g,i){var f=this,e=f.editor,h=e.dom,d;if(e.settings.paste_enable_default_filters==false){return}if(i.wordContent){c(h.select("a",i.node),function(j){if(!j.href||j.href.indexOf("#_Toc")!=-1){h.remove(j,1)}});if(b(e,"paste_convert_middot_lists")){f._convertLists(g,i)}d=b(e,"paste_retain_style_properties");if((tinymce.is(d,"string"))&&(d!=="all")&&(d!=="*")){d=tinymce.explode(d.replace(/^none$/i,""));c(h.select("*",i.node),function(m){var n={},k=0,l,o,j;if(d){for(l=0;l<d.length;l++){o=d[l];j=h.getStyle(m,o);if(j){n[o]=j;k++}}}h.setAttrib(m,"style","");if(d&&k>0){h.setStyles(m,n)}else{if(m.nodeName=="SPAN"&&!m.className){h.remove(m,true)}}})}}if(b(e,"paste_remove_styles")||(b(e,"paste_remove_styles_if_webkit")&&tinymce.isWebKit)){c(h.select("*[style]",i.node),function(j){j.removeAttribute("style");j.removeAttribute("data-mce-style")})}else{if(tinymce.isWebKit){c(h.select("*",i.node),function(j){j.removeAttribute("data-mce-style")})}}},_convertLists:function(g,e){var i=g.editor.dom,h,l,d=-1,f,m=[],k,j;c(i.select("p",e.node),function(t){var q,u="",s,r,n,o;for(q=t.firstChild;q&&q.nodeType==3;q=q.nextSibling){u+=q.nodeValue}u=t.innerHTML.replace(/<\/?\w+[^>]*>/gi,"").replace(/ /g,"\u00a0");if(/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o\u25CF]\s*\u00a0*/.test(u)){s="ul"}if(/^__MCE_ITEM__\s*\w+\.\s*\u00a0+/.test(u)){s="ol"}if(s){f=parseFloat(t.style.marginLeft||0);if(f>d){m.push(f)}if(!h||s!=k){h=i.create(s);i.insertAfter(h,t)}else{if(f>d){h=l.appendChild(i.create(s))}else{if(f<d){n=tinymce.inArray(m,f);o=i.getParents(h.parentNode,s);h=o[o.length-1-n]||h}}}c(i.select("span",t),function(v){var p=v.innerHTML.replace(/<\/?\w+[^>]*>/gi,"");if(s=="ul"&&/^__MCE_ITEM__[\u2022\u00b7\u00a7\u00d8o\u25CF]/.test(p)){i.remove(v)}else{if(/^__MCE_ITEM__[\s\S]*\w+\.( |\u00a0)*\s*/.test(p)){i.remove(v)}}});r=t.innerHTML;if(s=="ul"){r=t.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^[\u2022\u00b7\u00a7\u00d8o\u25CF]\s*( |\u00a0)+\s*/,"")}else{r=t.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.( |\u00a0)+\s*/,"")}l=h.appendChild(i.create("li",0,r));i.remove(t);d=f;k=s}else{h=d=0}});j=e.node.innerHTML;if(j.indexOf("__MCE_ITEM__")!=-1){e.node.innerHTML=j.replace(/__MCE_ITEM__/g,"")}},_insert:function(f,d){var e=this.editor,g=e.selection.getRng();if(!e.selection.isCollapsed()&&g.startContainer!=g.endContainer){e.getDoc().execCommand("Delete",false,null)}e.execCommand("mceInsertContent",false,f,{skip_undo:d})},_insertPlainText:function(j){var h=this.editor,f=b(h,"paste_text_linebreaktype"),k=b(h,"paste_text_replacements"),g=tinymce.is;function e(m){c(m,function(n){if(n.constructor==RegExp){j=j.replace(n,"")}else{j=j.replace(n[0],n[1])}})}if((typeof(j)==="string")&&(j.length>0)){if(/<(?:p|br|h[1-6]|ul|ol|dl|table|t[rdh]|div|blockquote|fieldset|pre|address|center)[^>]*>/i.test(j)){e([/[\n\r]+/g])}else{e([/\r+/g])}e([[/<\/(?:p|h[1-6]|ul|ol|dl|table|div|blockquote|fieldset|pre|address|center)>/gi,"\n\n"],[/<br[^>]*>|<\/tr>/gi,"\n"],[/<\/t[dh]>\s*<t[dh][^>]*>/gi,"\t"],/<[a-z!\/?][^>]*>/gi,[/ /gi," "],[/(?:(?!\n)\s)*(\n+)(?:(?!\n)\s)*/gi,"$1"]]);var d=Number(b(h,"paste_max_consecutive_linebreaks"));if(d>-1){var l=new RegExp("\n{"+(d+1)+",}","g");var i="";while(i.length<d){i+="\n"}e([[l,i]])}j=h.dom.decode(tinymce.html.Entities.encodeRaw(j));if(g(k,"array")){e(k)}else{if(g(k,"string")){e(new RegExp(k,"gi"))}}if(f=="none"){e([[/\n+/g," "]])}else{if(f=="br"){e([[/\n/g,"<br />"]])}else{if(f=="p"){e([[/\n+/g,"</p><p>"],[/^(.*<\/p>)(<p>)$/,"<p>$1"]])}else{e([[/\n\n/g,"</p><p>"],[/^(.*<\/p>)(<p>)$/,"<p>$1"],[/\n/g,"<br />"]])}}}h.execCommand("mceInsertContent",false,j)}},_legacySupport:function(){var e=this,d=e.editor;d.addCommand("mcePasteWord",function(){d.windowManager.open({file:e.url+"/pasteword.htm",width:parseInt(b(d,"paste_dialog_width")),height:parseInt(b(d,"paste_dialog_height")),inline:1})});if(b(d,"paste_text_use_dialog")){d.addCommand("mcePasteText",function(){d.windowManager.open({file:e.url+"/pastetext.htm",width:parseInt(b(d,"paste_dialog_width")),height:parseInt(b(d,"paste_dialog_height")),inline:1})})}d.addButton("pasteword",{title:"paste.paste_word_desc",cmd:"mcePasteWord"})}});tinymce.PluginManager.add("paste",tinymce.plugins.PastePlugin)})(); diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js @@ -1394,7 +1394,7 @@ Zotero.Attachments = new function(){ var win = doc.defaultView; if(win) { win = win.wrappedJSObject; - if(win && "PDFJS" in win && win.PDFJS.isFirefoxExtension) { + if(win && "PDFJS" in win) { return true; } } diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -174,6 +174,10 @@ Zotero.ItemTreeView.prototype._setTreeGenerator = function(treebox) // in overlay.js::onCollectionSelected() this.listener = listener; tree.addEventListener('keypress', listener, false); + // This seems to be the only way to prevent Enter/Return + // from toggle row open/close. The event is handled by + // handleKeyPress() in zoteroPane.js. + tree._handleEnter = function () {}; this.sort(); diff --git a/chrome/content/zotero/xpcom/report.js b/chrome/content/zotero/xpcom/report.js @@ -70,12 +70,17 @@ Zotero.Report = new function() { // Independent note if (arr['note']) { content += '\n'; - if (arr.note.substr(0, 1024).match(/<p[^>]*>/)) { - content += arr.note + '\n'; + + // If not valid XML, display notes with entities encoded + var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); + var doc = parser.parseFromString(arr.note, "application/xml"); + if (doc.documentElement.tagName == 'parsererror') { + content += '<p class="plaintext">' + escapeXML(arr.note) + '</p>\n'; } - // Wrap plaintext notes in <p> + // Otherwise render markup normally else { - content += '<p class="plaintext">' + arr.note + '</p>\n'; + content += arr.note + '\n'; } } } @@ -92,12 +97,16 @@ Zotero.Report = new function() { for each(var note in arr.reportChildren.notes) { content += '<li id="i' + note.itemID + '">\n'; - if (note.note.substr(0, 1024).match(/<p[^>]*>/)) { - content += note.note + '\n'; + // If not valid XML, display notes with entities encoded + var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); + var doc = parser.parseFromString(note.note, "application/xml"); + if (doc.documentElement.tagName == 'parsererror') { + content += '<p class="plaintext">' + escapeXML(note.note) + '</p>\n'; } - // Wrap plaintext notes in <p> + // Otherwise render markup normally else { - content += '<p class="plaintext">' + escapeXML(note.note) + '</p>\n'; + content += note.note + '\n'; } // Child note tags diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -453,7 +453,8 @@ Zotero.Translate.SandboxManager.prototype = { */ "importObject":function(object, passAsFirstArgument, attachTo) { if(!attachTo) attachTo = this.sandbox.Zotero; - var newExposedProps = false; + var newExposedProps = false, + sandbox = this.sandbox; if(!object.__exposedProps__) newExposedProps = {}; for(var key in (newExposedProps ? object : object.__exposedProps__)) { let localKey = key; @@ -464,11 +465,16 @@ Zotero.Translate.SandboxManager.prototype = { var isObject = typeof object[localKey] === "object"; if(isFunction || isObject) { if(isFunction) { - if(passAsFirstArgument) { - attachTo[localKey] = object[localKey].bind(object, passAsFirstArgument); - } else { - attachTo[localKey] = object[localKey].bind(object); - } + attachTo[localKey] = function() { + var args = Array.prototype.slice.apply(arguments); + if(passAsFirstArgument) args.unshift(passAsFirstArgument); + var out = object[localKey].apply(object, args); + if(out instanceof Array) { + // Copy to sandbox + out = sandbox.Array.prototype.slice.apply(out); + } + return out; + }; } else { attachTo[localKey] = {}; } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -35,7 +35,7 @@ const ZOTERO_CONFIG = { API_URL: 'https://api.zotero.org/', PREF_BRANCH: 'extensions.zotero.', BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/', - VERSION: "3.0.8.SOURCE" + VERSION: "3.0.9.SOURCE" }; // Commonly used imports accessible anywhere diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -502,6 +502,19 @@ var ZoteroPane = new function() return; } + else if (from == 'zotero-items-tree') { + // Focus TinyMCE explicitly on tab key, since the normal focusing + // doesn't work right + if (!event.shiftKey && event.keyCode == event.DOM_VK_TAB) { + var deck = document.getElementById('zotero-item-pane-content'); + if (deck.selectedPanel.id == 'zotero-view-note') { + setTimeout(function () { + document.getElementById('zotero-note-editor').focus(); + }, 0); + } + } + return; + } // Ignore keystrokes if Zotero pane is closed var zoteroPane = document.getElementById('zotero-pane-stack'); @@ -657,6 +670,19 @@ var ZoteroPane = new function() event.preventDefault(); return; } + else if (event.keyCode == event.DOM_VK_RETURN) { + var items = this.itemsView.getSelectedItems(); + // Don't do anything if more than 20 items selected + if (!items.length || items.length > 20) { + return; + } + ZoteroPane_Local.viewItems(items, event); + // These don't seem to do anything. Instead we override + // the tree binding's _handleEnter method in itemTreeView.js. + //event.preventDefault(); + //event.stopPropagation(); + return; + } } } @@ -738,7 +764,7 @@ var ZoteroPane = new function() return false; } - if (!this.canEdit()) { + if (!this.canEditLibrary()) { this.displayCannotEditLibraryMessage(); return; } @@ -1087,7 +1113,24 @@ var ZoteroPane = new function() ]; for(var i=0; i<disableIfNoEdit.length; i++) { var el = document.getElementById(disableIfNoEdit[i]); - if(itemgroup.editable) { + + // If a trash is selected, new collection depends on the + // editability of the library + if (itemgroup.isTrash() && + disableIfNoEdit[i] == 'cmd_zotero_newCollection') { + if (itemgroup.ref.libraryID) { + var overrideEditable = + Zotero.Libraries.isEditable(itemgroup.ref.libraryID); + } + else { + var overrideEditable = true; + } + } + else { + var overrideEditable = false; + } + + if (itemgroup.editable || overrideEditable) { if(el.hasAttribute("disabled")) el.removeAttribute("disabled"); } else { el.setAttribute("disabled", "true"); @@ -2602,66 +2645,23 @@ var ZoteroPane = new function() } } else if (tree.id == 'zotero-items-tree') { - var viewOnDoubleClick = Zotero.Prefs.get('viewOnDoubleClick'); - // Expand/collapse on triple-click - if (viewOnDoubleClick) { - if (event.detail == 3) { - tree.view.toggleOpenState(tree.view.selection.currentIndex); - return; - } - - // Don't expand/collapse on double-click - event.stopPropagation(); + if (!Zotero.Prefs.get('viewOnDoubleClick')) { + return; + } + + if (event.detail == 3) { + tree.view.toggleOpenState(tree.view.selection.currentIndex); + return; } + // Don't expand/collapse on double-click + event.stopPropagation(); + if (tree.view && tree.view.selection.currentIndex > -1) { var item = ZoteroPane_Local.getSelectedItems()[0]; if (item) { - if (item.isRegularItem()) { - if (itemGroup.isBucket()) { - var uri = itemGroup.ref.getItemURI(item); - ZoteroPane_Local.loadURI(uri); - event.stopPropagation(); - return; - } - - if (!viewOnDoubleClick) { - return; - } - - var uri = Components.classes["@mozilla.org/network/standard-url;1"]. - createInstance(Components.interfaces.nsIURI); - var snapID = item.getBestAttachment(); - if (snapID) { - ZoteroPane_Local.viewAttachment(snapID, event); - return; - } - - var uri = item.getField('url'); - if (!uri) { - var doi = item.getField('DOI'); - if (doi) { - // Pull out DOI, in case there's a prefix - doi = Zotero.Utilities.cleanDOI(doi); - if (doi) { - uri = "http://dx.doi.org/" + encodeURIComponent(doi); - } - } - } - if (uri) { - ZoteroPane_Local.loadURI(uri); - } - } - else if (item.isNote()) { - if (!ZoteroPane_Local.collectionsView.editable) { - return; - } - document.getElementById('zotero-view-note-button').doCommand(); - } - else if (item.isAttachment()) { - ZoteroPane_Local.viewSelectedAttachment(event); - } + ZoteroPane_Local.viewItems([item], event); } } } @@ -3368,6 +3368,51 @@ var ZoteroPane = new function() } + this.viewItems = function (items, event) { + if (items.length > 1) { + if (!event || (!event.metaKey && !event.shiftKey)) { + event = { metaKey: true, shiftKey: true }; + } + } + + for each(var item in items) { + if (item.isRegularItem()) { + var uri = Components.classes["@mozilla.org/network/standard-url;1"] + .createInstance(Components.interfaces.nsIURI); + var snapID = item.getBestAttachment(); + if (snapID) { + ZoteroPane_Local.viewAttachment(snapID, event); + continue; + } + + var uri = item.getField('url'); + if (!uri) { + var doi = item.getField('DOI'); + if (doi) { + // Pull out DOI, in case there's a prefix + doi = Zotero.Utilities.cleanDOI(doi); + if (doi) { + uri = "http://dx.doi.org/" + encodeURIComponent(doi); + } + } + } + if (uri) { + ZoteroPane_Local.loadURI(uri, event); + } + } + else if (item.isNote()) { + if (!ZoteroPane_Local.collectionsView.editable) { + continue; + } + document.getElementById('zotero-view-note-button').doCommand(); + } + else if (item.isAttachment()) { + ZoteroPane_Local.viewAttachment(item.id, event); + } + } + } + + function viewAttachment(itemIDs, event, noLocateOnMissing, forceExternalViewer) { // If view isn't editable, don't show Locate button, since the updated // path couldn't be sent back up @@ -3591,8 +3636,7 @@ var ZoteroPane = new function() /** - * Test if the user can edit the currently selected library/collection, - * and display an error if not + * Test if the user can edit the currently selected view * * @param {Integer} [row] * @@ -3610,8 +3654,28 @@ var ZoteroPane = new function() /** - * Test if the user can edit the currently selected library/collection, - * and display an error if not + * Test if the user can edit the parent library of the selected view + * + * @param {Integer} [row] + * @return {Boolean} TRUE if user can edit, FALSE if not + */ + this.canEditLibrary = function (row) { + // Currently selected row + if (row === undefined) { + row = this.collectionsView.selection.currentIndex; + } + + var itemGroup = this.collectionsView._getItemAtRow(row); + // TODO: isEditable for user library should just return true + if (itemGroup.ref.libraryID) { + return Zotero.Libraries.isEditable(itemGroup.ref.libraryID); + } + return true; + } + + + /** + * Test if the user can edit the currently selected library/collection * * @param {Integer} [row] * diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul @@ -142,7 +142,7 @@ <toolbarbutton id="zotero-tb-item-from-page" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newItemFromPage.label;" command="cmd_zotero_newItemFromCurrentPage"/> <toolbarbutton id="zotero-tb-lookup" class="zotero-tb-button" tooltiptext="&zotero.toolbar.lookup.label;" type="panel"> <panel id="zotero-lookup-panel" type="arrow" onpopupshown="Zotero_Lookup.onShowing()" - onpopuphidden="Zotero_Lookup.onHidden()"> + onpopuphidden="Zotero_Lookup.onHidden(event)"> <vbox> <description>&zotero.lookup.description;</description> <stack> @@ -331,6 +331,7 @@ id="zotero-items-tree" context="zotero-itemmenu" enableColumnDrag="true" onfocus="if (ZoteroPane_Local.itemsView.rowCount && !ZoteroPane_Local.itemsView.selection.count) { ZoteroPane_Local.itemsView.selection.select(0); }" + onkeydown="ZoteroPane_Local.handleKeyDown(event, this.id)" onkeypress="ZoteroPane_Local.handleKeyPress(event, this.id)" onselect="ZoteroPane_Local.itemSelected(event)" ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane_Local.itemsView.onDragStart(event); }" diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd @@ -146,9 +146,11 @@ <!ENTITY zotero.selectitems.cancel.label "Cancel"> <!ENTITY zotero.selectitems.select.label "OK"> -<!ENTITY zotero.bibliography.title "Create Bibliography"> +<!ENTITY zotero.bibliography.title "Create Citation/Bibliography"> <!ENTITY zotero.bibliography.style.label "Citation Style:"> -<!ENTITY zotero.bibliography.output.label "Output Format"> +<!ENTITY zotero.bibliography.outputMode "Output Mode:"> +<!ENTITY zotero.bibliography.bibliography "Bibliography"> +<!ENTITY zotero.bibliography.outputMethod "Output Method:"> <!ENTITY zotero.bibliography.saveAsRTF.label "Save as RTF"> <!ENTITY zotero.bibliography.saveAsHTML.label "Save as HTML"> <!ENTITY zotero.bibliography.copyToClipboard.label "Copy to Clipboard"> diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -569,6 +569,8 @@ citation.multipleSources = Multiple Sources… citation.singleSource = Single Source… citation.showEditor = Show Editor… citation.hideEditor = Hide Editor… +citation.citation = Citation +citation.note = Note report.title.default = Zotero Report report.parentItem = Parent Item: diff --git a/install.rdf b/install.rdf @@ -25,7 +25,7 @@ <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>5.0</em:minVersion> - <em:maxVersion>19.0a1</em:maxVersion> + <em:maxVersion>17.*</em:maxVersion> </Description> </em:targetApplication> diff --git a/update.rdf b/update.rdf @@ -12,7 +12,7 @@ <RDF:Description> <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id> <minVersion>5.0</minVersion> - <maxVersion>19.0a1</maxVersion> + <maxVersion>17.*</maxVersion> <updateLink>http://download.zotero.org/extension/zotero.xpi</updateLink> <updateHash>sha1:</updateHash> </RDF:Description>