Browse Source

Merge pull request #90 from admpub/master

优化对 textarea 中 name 属性值的设置 和 修复 Firefox 下上传图片返回 JSON 数据为 undefined 的问题
master
pandao 10 years ago
parent
commit
fdf1c5abff
  1. 1796
      editormd.js
  2. 2
      editormd.min.js
  3. 33
      plugins/image-dialog/image-dialog.js

1796
editormd.js

File diff suppressed because it is too large

2
editormd.min.js

File diff suppressed because one or more lines are too long

33
plugins/image-dialog/image-dialog.js

@ -31,13 +31,13 @@
cm.focus(); cm.focus();
var loading = function(show) {
var loading = function(show) {
var _loading = dialog.find("." + classPrefix + "dialog-mask"); var _loading = dialog.find("." + classPrefix + "dialog-mask");
_loading[(show) ? "show" : "hide"](); _loading[(show) ? "show" : "hide"]();
}; };
if (editor.find("." + dialogName).length < 1) if (editor.find("." + dialogName).length < 1)
{
{
var guid = (new Date).getTime(); var guid = (new Date).getTime();
var action = settings.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid; var action = settings.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid;
@ -57,14 +57,14 @@
})() + })() +
"<br/>" + "<br/>" +
"<label>" + imageLang.alt + "</label>" + "<label>" + imageLang.alt + "</label>" +
"<input type=\"text\" value=\"" + selection + "\" data-alt />" +
"<input type=\"text\" value=\"" + selection + "\" data-alt />" +
"<br/>" + "<br/>" +
"<label>" + imageLang.link + "</label>" + "<label>" + imageLang.link + "</label>" +
"<input type=\"text\" value=\"http://\" data-link />" + "<input type=\"text\" value=\"http://\" data-link />" +
"<br/>" + "<br/>" +
( (settings.imageUpload) ? "</form>" : "</div>"); ( (settings.imageUpload) ? "</form>" : "</div>");
//var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + imageLang.managerButton + "</button>";
//var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + imageLang.managerButton + "</button>";
dialog = this.createDialog({ dialog = this.createDialog({
title : imageLang.title, title : imageLang.title,
@ -94,11 +94,11 @@
var altAttr = (alt !== "") ? " \"" + alt + "\"" : ""; var altAttr = (alt !== "") ? " \"" + alt + "\"" : "";
if (link === "" || link === "http://") if (link === "" || link === "http://")
{
{
cm.replaceSelection("![" + alt + "](" + url + altAttr + ")"); cm.replaceSelection("![" + alt + "](" + url + altAttr + ")");
} }
else
{
else
{
cm.replaceSelection("[![" + alt + "](" + url + altAttr + ")](" + link + altAttr + ")"); cm.replaceSelection("[![" + alt + "](" + url + altAttr + ")](" + link + altAttr + ")");
} }
@ -111,7 +111,7 @@
return false; return false;
}], }],
cancel : [lang.buttons.cancel, function() {
cancel : [lang.buttons.cancel, function() {
this.hide().lockScreen(false).hideMask(); this.hide().lockScreen(false).hideMask();
return false; return false;
@ -136,9 +136,9 @@
alert(imageLang.uploadFileEmpty); alert(imageLang.uploadFileEmpty);
} }
else if (!isImage.test(fileName)) else if (!isImage.test(fileName))
{
{
alert(imageLang.formatNotAllowed + settings.imageFormats.join(", ")); alert(imageLang.formatNotAllowed + settings.imageFormats.join(", "));
}
}
else else
{ {
loading(true); loading(true);
@ -150,7 +150,12 @@
uploadIframe.onload = function() { uploadIframe.onload = function() {
loading(false); 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 + ")"); json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
if (json.success === 1) if (json.success === 1)
@ -186,10 +191,10 @@
}; };
}; };
// CommonJS/Node.js // CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
{
{
module.exports = factory; module.exports = factory;
} }
else if (typeof define === "function") // AMD/CMD/Sea.js else if (typeof define === "function") // AMD/CMD/Sea.js
@ -206,7 +211,7 @@
factory(editormd); factory(editormd);
}); });
} }
}
}
else else
{ {
factory(window.editormd); factory(window.editormd);

Loading…
Cancel
Save