diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml index 041f5a65ca..7a63f59de2 100644 --- a/chrome/content/zotero/bindings/styled-textbox.xml +++ b/chrome/content/zotero/bindings/styled-textbox.xml @@ -362,7 +362,7 @@ var matchTo = null; var listener = function(e) { var win = self._iframe.contentWindow; - var SJOW = self._iframe.contentWindow.wrappedJSObject; + var SJOW = win.wrappedJSObject; // only fire if the target matches, or _zoteroMatchTo, which we set last // time the target matched, matches @@ -386,6 +386,49 @@ return; } + if (!SJOW.zoteroInit) { + SJOW.zoteroInit = function(editor) { + self._editor = editor; + if (self._value) { + self.value = self._value; + } + if (self._focus) { + self._iframe.focus(); + self._editor.focus(); + self._focus = false; + } + + // Add CSS rules to notes + if (self.mode == 'note') { + var css = "body#zotero-tinymce-note.mceContentBody, " + + "body#zotero-tinymce-note.mceContentBody p, " + + "body#zotero-tinymce-note.mceContentBody th, " + + "body#zotero-tinymce-note.mceContentBody td, " + + "body#zotero-tinymce-note.mceContentBody pre { " + + "font-size: " + + Zotero.Prefs.get('note.fontSize') + "px; " + + "} " + + "body#zotero-tinymce-note.mceContentBody, " + + "body#zotero-tinymce-note.mceContentBody p { " + + "font-family: " + + Zotero.Prefs.get('note.fontFamily') + "; " + + "}" + + Zotero.Prefs.get('note.css'); + + var doc = editor.contentDocument; + var head = doc.getElementsByTagName("head")[0]; + var style = doc.createElement("style"); + style.innerHTML = css; + head.appendChild(style); + } + + // Dispatch a tinymceInitialized event + var ev = document.createEvent('HTMLEvents'); + ev.initEvent('tinymceInitialized', true, true); + self.dispatchEvent(ev); + }; + } + var editor = SJOW.tinyMCE.get("tinymce"); if (!editor) { Zotero.debug("editor not ready"); @@ -405,59 +448,16 @@ self._iframe.removeEventListener("DOMContentLoaded", listener, false); } - var onInitFunction = function() { - self._editor = editor; - if (self._value) { - self.value = self._value; - } - if (self._focus) { - self._iframe.focus(); - self._editor.focus(); - self._focus = false; - } - - // Add CSS rules to notes - if (self.mode == 'note') { - var css = "body#zotero-tinymce-note.mceContentBody, " - + "body#zotero-tinymce-note.mceContentBody p, " - + "body#zotero-tinymce-note.mceContentBody th, " - + "body#zotero-tinymce-note.mceContentBody td, " - + "body#zotero-tinymce-note.mceContentBody pre { " - + "font-size: " - + Zotero.Prefs.get('note.fontSize') + "px; " - + "} " - + "body#zotero-tinymce-note.mceContentBody, " - + "body#zotero-tinymce-note.mceContentBody p { " - + "font-family: " - + Zotero.Prefs.get('note.fontFamily') + "; " - + "}" - + Zotero.Prefs.get('note.css'); - - var doc = editor.contentDocument; - var head = doc.getElementsByTagName("head")[0]; - var style = doc.createElement("style"); - style.innerHTML = css; - head.appendChild(style); - } - - // Dispatch a tinymceInitialized event - var ev = document.createEvent('HTMLEvents'); - ev.initEvent('tinymceInitialized', true, true); - self.dispatchEvent(ev); - }; - onInitFunction.__exposedProps__ = {"apply":"r"}; - editor.onInit.add(onInitFunction); - if (self._eventHandler) { - self._iframe.contentWindow.wrappedJSObject.zoteroHandleEvent = self._eventHandler; + win.wrappedJSObject.zoteroHandleEvent = self._eventHandler; } // Run Cut/Copy/Paste with chrome privileges - self._iframe.contentWindow.wrappedJSObject.zoteroExecCommand = function (doc, command, ui, value) { + win.wrappedJSObject.zoteroExecCommand = function (doc, command, ui, value) { return doc.execCommand(command, ui, value); } - self._iframe.contentWindow.wrappedJSObject.zoteroFixWindow = function (win) { + win.wrappedJSObject.zoteroFixWindow = function (win) { win.locationbar.visible = false; win.statusbar.visible = false; } diff --git a/chrome/content/zotero/tinymce/note.html b/chrome/content/zotero/tinymce/note.html old mode 100755 new mode 100644 index b93b7744d7..7a97f1c89d --- a/chrome/content/zotero/tinymce/note.html +++ b/chrome/content/zotero/tinymce/note.html @@ -1,6 +1,7 @@ + diff --git a/chrome/content/zotero/tinymce/themes/advanced/link.htm b/chrome/content/zotero/tinymce/themes/advanced/link.htm index 5d9dea9b8c..ec928adcec 100644 --- a/chrome/content/zotero/tinymce/themes/advanced/link.htm +++ b/chrome/content/zotero/tinymce/themes/advanced/link.htm @@ -1,6 +1,7 @@ + {#advanced_dlg.link_title} diff --git a/chrome/content/zotero/tinymce/themes/advanced/source_editor.htm b/chrome/content/zotero/tinymce/themes/advanced/source_editor.htm index dd973fcc05..673c09f312 100644 --- a/chrome/content/zotero/tinymce/themes/advanced/source_editor.htm +++ b/chrome/content/zotero/tinymce/themes/advanced/source_editor.htm @@ -1,5 +1,6 @@ + {#advanced_dlg.code_title} diff --git a/chrome/content/zotero/tinymce/tiny_mce.js b/chrome/content/zotero/tinymce/tiny_mce.js index fab0d3014d..b1596e3044 100644 --- a/chrome/content/zotero/tinymce/tiny_mce.js +++ b/chrome/content/zotero/tinymce/tiny_mce.js @@ -1,4 +1,5 @@ -// FILE IS GENERATED BY COMBINING THE SOURCES IN THE "classes" DIRECTORY SO DON'T MODIFY THIS FILE DIRECTLY +// Contains modifications by Dan S./Zotero + (function(win) { var whiteSpaceRe = /^\s*|\s*$/g, undef, isRegExpBroken = 'B'.replace(/A(.)|B/, '$1') === '$1'; @@ -591,7 +592,11 @@ tinymce.create('tinymce.util.Dispatcher', { t.source = u; return; } - + + // Added by Dan S./Zotero + u = u.replace("jar:file", "jarfile"); + u = u.replace("zotero@chnm.gmu.edu", "zotero.chnm.gmu.edu"); + // Absolute path with no host, fake host and protocol if (u.indexOf('/') === 0 && u.indexOf('//') !== 0) u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u; @@ -599,9 +604,15 @@ tinymce.create('tinymce.util.Dispatcher', { // Relative path http:// or protocol relative //path if (!/^[\w\-]*:?\/\//.test(u)) { base_url = s.base_uri ? s.base_uri.path : new tinymce.util.URI(location.href).directory; - u = ((s.base_uri && s.base_uri.protocol) || 'http') + '://mce_host' + t.toAbsPath(base_url, u); + // Modified by Dan S./Zotero + //u = ((s.base_uri && s.base_uri.protocol) || 'http') + '://mce_host' + t.toAbsPath(base_url, u); + u = s.base_uri.protocol + '://' + s.base_uri.path + '/' + u; } - + + // Added by Dan S./Zotero + u = u.replace("jar:file", "jarfile"); + u = u.replace("zotero@chnm.gmu.edu", "zotero.chnm.gmu.edu"); + // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri) u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u); @@ -609,8 +620,13 @@ tinymce.create('tinymce.util.Dispatcher', { var s = u[i]; // Zope 3 workaround, they use @@something - if (s) + if (s) { s = s.replace(/\(mce_at\)/g, '@@'); + + // Modified by Dan S./Zotero + s = s.replace("jarfile", "jar:file"); + s = s.replace("zotero.chnm.gmu.edu", "zotero@chnm.gmu.edu"); + } t[v] = s; }); @@ -966,7 +982,9 @@ tinymce.create('static tinymce.util.XHR', { function ready() { if (!o.async || x.readyState == 4 || c++ > 10000) { - if (o.success && c < 10000 && x.status == 200) + // Modified by Dan S./Zotero + //if (o.success && c < 10000 && x.status == 200) + if (o.success && c < 10000 && (x.status == 200 || x.status == 0)) o.success.call(o.success_scope, '' + x.responseText, x, o); else if (o.error) o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o); @@ -16309,7 +16327,10 @@ tinymce.ForceBlocks = function(editor) { } catch (ex) { // Ignore } - + + // Added by Dan S./Zotero + zoteroFixWindow(w); + if (!w) alert(t.editor.getLang('popup_blocked')); },