Browse Source

fix image dialog bugs

master
Pandao 10 years ago
parent
commit
91351a05ce
  1. 76
      plugins/image-dialog/image-dialog.js

76
plugins/image-dialog/image-dialog.js

@ -126,57 +126,57 @@
});
dialog.attr("id", classPrefix + "image-dialog-" + guid);
}
if (!settings.imageUpload) return ;
if (!settings.imageUpload) return ;
var fileInput = dialog.find("[name=\"" + classPrefix + "image-file\"]");
var fileInput = dialog.find("[name=\"" + classPrefix + "image-file\"]");
fileInput.bind("change", function() {
var fileName = fileInput.val();
var isImage = new RegExp("(\\.(" + settings.imageFormats.join("|") + "))$"); // /(\.(webp|jpg|jpeg|gif|bmp|png))$/
fileInput.bind("change", function() {
var fileName = fileInput.val();
var isImage = new RegExp("(\\.(" + settings.imageFormats.join("|") + "))$"); // /(\.(webp|jpg|jpeg|gif|bmp|png))$/
if (fileName === "")
{
alert(imageLang.uploadFileEmpty);
}
else if (!isImage.test(fileName))
{
alert(imageLang.formatNotAllowed + settings.imageFormats.join(", "));
}
else
{
if (typeof (dialog.loading) == "function") dialog.loading(true);
if (fileName === "")
{
alert(imageLang.uploadFileEmpty);
}
else if (!isImage.test(fileName))
{
alert(imageLang.formatNotAllowed + settings.imageFormats.join(", "));
}
else
{
if (typeof (dialog.loading) == "function") dialog.loading(true);
var submitHandler = function() {
var submitHandler = function() {
var uploadIframe = document.getElementById(iframeName);
var uploadIframe = document.getElementById(iframeName);
uploadIframe.onload = function() {
if (typeof (dialog.loading) == "function") dialog.loading(false);
uploadIframe.onload = function() {
if (typeof (dialog.loading) == "function") dialog.loading(false);
var json = uploadIframe.contentWindow.document.body.innerHTML;
json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
var json = uploadIframe.contentWindow.document.body.innerHTML;
json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
if (json.success === 1)
{
dialog.find("[data-url]").val(json.url);
}
else
{
alert(json.message);
}
if (json.success === 1)
{
dialog.find("[data-url]").val(json.url);
}
else
{
alert(json.message);
}
return false;
};
};
return false;
};
};
dialog.find("[type=\"submit\"]").bind(exports.mouseOrTouch("click", "touchend"), submitHandler).trigger("click");
dialog.find("[type=\"submit\"]").bind(exports.mouseOrTouch("click", "touchend"), submitHandler).trigger("click");
}
}
return false;
});
return false;
});
}
};

Loading…
Cancel
Save