From 4294250fea787949dc72b4c070564c0d2e256142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=95=86=E8=AE=AF=E5=9C=A8=E7=BA=BF?= Date: Mon, 18 May 2015 23:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DFirefox=E4=B8=8B=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=9B=BE=E7=89=87=E8=BF=94=E5=9B=9Ejson=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=BAundefined=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/image-dialog/image-dialog.js | 33 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/plugins/image-dialog/image-dialog.js b/plugins/image-dialog/image-dialog.js index 5cb042e..ac67731 100644 --- a/plugins/image-dialog/image-dialog.js +++ b/plugins/image-dialog/image-dialog.js @@ -31,13 +31,13 @@ cm.focus(); - var loading = function(show) { + var loading = function(show) { var _loading = dialog.find("." + classPrefix + "dialog-mask"); _loading[(show) ? "show" : "hide"](); }; if (editor.find("." + dialogName).length < 1) - { + { var guid = (new Date).getTime(); var action = settings.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid; @@ -57,14 +57,14 @@ })() + "
" + "" + - "" + + "" + "
" + "" + "" + "
" + ( (settings.imageUpload) ? "" : ""); - //var imageFooterHTML = ""; + //var imageFooterHTML = ""; dialog = this.createDialog({ title : imageLang.title, @@ -94,11 +94,11 @@ var altAttr = (alt !== "") ? " \"" + alt + "\"" : ""; if (link === "" || link === "http://") - { + { cm.replaceSelection("![" + alt + "](" + url + altAttr + ")"); } - else - { + else + { cm.replaceSelection("[![" + alt + "](" + url + altAttr + ")](" + link + altAttr + ")"); } @@ -111,7 +111,7 @@ return false; }], - cancel : [lang.buttons.cancel, function() { + cancel : [lang.buttons.cancel, function() { this.hide().lockScreen(false).hideMask(); return false; @@ -136,9 +136,9 @@ alert(imageLang.uploadFileEmpty); } else if (!isImage.test(fileName)) - { + { alert(imageLang.formatNotAllowed + settings.imageFormats.join(", ")); - } + } else { loading(true); @@ -150,7 +150,12 @@ uploadIframe.onload = function() { loading(false); - var json = uploadIframe.contentWindow.document.body.innerText; + var json = ""; + if (uploadIframe.contentWindow) { + json = uploadIframe.contentWindow.document.body ? uploadIframe.contentWindow.document.body.innerHTML : null; + } else if (uploadIframe.contentDocument) { + json = uploadIframe.contentDocument.document.body ? uploadIframe.contentDocument.document.body.innerHTML : null; + } json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")"); if (json.success === 1) @@ -186,10 +191,10 @@ }; }; - + // CommonJS/Node.js if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { + { module.exports = factory; } else if (typeof define === "function") // AMD/CMD/Sea.js @@ -206,7 +211,7 @@ factory(editormd); }); } - } + } else { factory(window.editormd);