|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- jQuery.extend({
-
- handleError: function (s, xhr, status, e) {
- // If a local callback was specified, fire it
- if (s.error) {
- s.error.call(s.context || s, xhr, status, e);
- }
- // Fire the global callback
- if (s.global) {
- (s.context ? jQuery(s.context) : jQuery.event).trigger(
- "ajaxError", [xhr, s, e]);
- }
- },
-
-
- createUploadIframe: function (b, d) {
- var a = "jUploadFrame" + b;
- var c = '<iframe id="' + a + '" name="' + a + '" style="position:absolute; top:-9999px; left:-9999px"';
- if (window.ActiveXObject) {
- if (typeof d == "boolean") {
- c += ' src="javascript:false"'
- } else {
- if (typeof d == "string") {
- c += ' src="' + d + '"'
- }
- }
- }
- c += " />";
- jQuery(c).appendTo(document.body);
- return jQuery("#" + a).get(0)
- },
- createUploadForm: function (g, b, a) {
- var e = "jUploadForm" + g;
- var c = "jUploadFile" + g;
- var d = jQuery('<form action="" method="POST" name="' + e + '" id="' + e + '" enctype="multipart/form-data"></form>');
- if (a) {
- for (var f in a) {
- jQuery('<input type="hidden" name="' + f + '" value="' + a[f] + '" />').appendTo(d)
- }
- }
- var j = jQuery("#" + b);
- var h = jQuery(j).clone();
- jQuery(j).attr("id", c);
- jQuery(j).before(h);
- jQuery(j).appendTo(d);
- jQuery(d).css("position", "absolute");
- jQuery(d).css("top", "-1200px");
- jQuery(d).css("left", "-1200px");
- jQuery(d).appendTo("body");
- return d
- },
- ajaxFileUpload: function (i) {
- i = jQuery.extend({},
- jQuery.ajaxSettings, i);
- var f = new Date().getTime();
- var b = jQuery.createUploadForm(f, i.fileElementId, (typeof (i.data) == "undefined" ? false : i.data));
- var g = jQuery.createUploadIframe(f, i.secureuri);
- var d = "jUploadFrame" + f;
- var c = "jUploadForm" + f;
- if (i.global && !jQuery.active++) {
- jQuery.event.trigger("ajaxStart")
- }
- var h = false;
- var k = {};
- if (i.global) {
- jQuery.event.trigger("ajaxSend", [k, i])
- }
- var j = function (o) {
- var n = document.getElementById(d);
- try {
- if (n.contentWindow) {
- k.responseText = n.contentWindow.document.body ? n.contentWindow.document.body.innerHTML : null;
- k.responseXML = n.contentWindow.document.XMLDocument ? n.contentWindow.document.XMLDocument : n.contentWindow.document
- } else {
- if (n.contentDocument) {
- k.responseText = n.contentDocument.document.body ? n.contentDocument.document.body.innerHTML : null;
- k.responseXML = n.contentDocument.document.XMLDocument ? n.contentDocument.document.XMLDocument : n.contentDocument.document
- }
- }
- } catch (m) {
- jQuery.handleError(i, k, null, m)
- }
- if (k || o == "timeout") {
- h = true;
- var p;
- try {
- p = o != "timeout" ? "success" : "error";
- if (p != "error") {
- var l = jQuery.uploadHttpData(k, i.dataType);
- if (i.success) {
- i.success(l, p)
- }
- if (i.global) {
- jQuery.event.trigger("ajaxSuccess", [k, i])
- }
- } else {
- jQuery.handleError(i, k, p)
- }
- } catch (m) {
- p = "error";
- jQuery.handleError(i, k, p, m)
- }
- if (i.global) {
- jQuery.event.trigger("ajaxComplete", [k, i])
- }
- if (i.global && !--jQuery.active) {
- jQuery.event.trigger("ajaxStop")
- }
- if (i.complete) {
- i.complete(k, p)
- }
- jQuery(n).unbind();
- setTimeout(function () {
- try {
- jQuery(n).remove();
- jQuery(b).remove()
- } catch (q) {
- jQuery.handleError(i, k, null, q)
- }
- },
- 100);
- k = null
- }
- };
- if (i.timeout > 0) {
- setTimeout(function () {
- if (!h) {
- j("timeout")
- }
- },
- i.timeout)
- }
- try {
- var b = jQuery("#" + c);
- jQuery(b).attr("action", i.url);
- jQuery(b).attr("method", "POST");
- jQuery(b).attr("target", d);
- if (b.encoding) {
- jQuery(b).attr("encoding", "multipart/form-data")
- } else {
- jQuery(b).attr("enctype", "multipart/form-data")
- }
- jQuery(b).submit()
- } catch (a) {
- jQuery.handleError(i, k, null, a)
- }
- jQuery("#" + d).load(j);
- return {
- abort: function () { }
- }
- },
- uploadHttpData: function (r, type) {
- var data = !type;
- data = type == "xml" || data ? r.responseXML : r.responseText;
- if (type == "script") {
- jQuery.globalEval(data)
- }
- if (type == "json") {
- eval("data = " + data)
- }
- if (type == "html") {
- jQuery("<div>").html(data).evalScripts()
- }
- return data
- }
- });
- var loaddfimg;
- var baseinfo;
- var bootstrap = function (a, b) {
- var c = {
- init: function () {
- c.initData();
- c.bind()
- },
- bind: function () {
- function d() {
- var e = document.getElementById("uploadFile").files[0];
- var g = window.URL.createObjectURL(e);
- document.getElementById("uploadPreview").src = g
- }
- a("#uploadFile").on("change", d);
- a("#lr_save_btn").on("click",
- function () {
- var e = document.getElementById("uploadFile").files[0];
- if (!!e) {
- b.loading(true, "正在保存...");
- a.ajaxFileUpload({
- url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=applogo",
- secureuri: false,
- fileElementId: "uploadFile",
- dataType: "json",
- success: function (f) {
- b.loading(false);
- a("#uploadFile").on("change", d);
- if (f.code == 200) {
- b.alert.success("保存成功")
- }
- }
- })
- }
- })
- },
- initData: function () {
- a(".file").prepend('<img id="uploadPreview" src="' + top.$.rootUrl + '/LR_SystemModule/LogoImg/GetImg?code=applogo" >')
- }
- };
- c.init()
- };
|