You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

356 lines
14 KiB

  1. jQuery.extend({
  2. createUploadIframe: function (b, d) {
  3. var a = "jUploadFrame" + b;
  4. var c = '<iframe id="' + a + '" name="' + a + '" style="position:absolute; top:-9999px; left:-9999px"';
  5. if (window.ActiveXObject) {
  6. if (typeof d == "boolean") {
  7. c += ' src="javascript:false"';
  8. } else {
  9. if (typeof d == "string") {
  10. c += ' src="' + d + '"';
  11. }
  12. }
  13. }
  14. c += " />";
  15. jQuery(c).appendTo(document.body);
  16. return jQuery("#" + a).get(0);
  17. },
  18. createUploadForm: function (g, b, a) {
  19. var e = "jUploadForm" + g;
  20. var c = "jUploadFile" + g;
  21. var d = jQuery('<form action="" method="POST" name="' + e + '" id="' + e + '" enctype="multipart/form-data"></form>');
  22. if (a) {
  23. for (var f in a) {
  24. jQuery('<input type="hidden" name="' + f + '" value="' + a[f] + '" />').appendTo(d);
  25. }
  26. }
  27. var j = jQuery("#" + b);
  28. var h = jQuery(j).clone();
  29. jQuery(j).attr("id", c);
  30. jQuery(j).before(h);
  31. jQuery(j).appendTo(d);
  32. jQuery(d).css("position", "absolute");
  33. jQuery(d).css("top", "-1200px");
  34. jQuery(d).css("left", "-1200px");
  35. jQuery(d).appendTo("body");
  36. return d
  37. },
  38. ajaxFileUpload: function (i) {
  39. i = jQuery.extend({},
  40. jQuery.ajaxSettings, i);
  41. var f = new Date().getTime();
  42. var b = jQuery.createUploadForm(f, i.fileElementId, (typeof (i.data) == "undefined" ? false : i.data));
  43. var g = jQuery.createUploadIframe(f, i.secureuri);
  44. var d = "jUploadFrame" + f;
  45. var c = "jUploadForm" + f;
  46. if (i.global && !jQuery.active++) {
  47. jQuery.event.trigger("ajaxStart");
  48. }
  49. var h = false;
  50. var k = {};
  51. if (i.global) {
  52. jQuery.event.trigger("ajaxSend", [k, i]);
  53. }
  54. var j = function (o) {
  55. var n = document.getElementById(d);
  56. try {
  57. if (n.contentWindow) {
  58. k.responseText = n.contentWindow.document.body ? n.contentWindow.document.body.innerHTML : null;
  59. k.responseXML = n.contentWindow.document.XMLDocument
  60. ? n.contentWindow.document.XMLDocument
  61. : n.contentWindow.document;
  62. } else {
  63. if (n.contentDocument) {
  64. k.responseText = n.contentDocument.document.body ? n.contentDocument.document.body.innerHTML : null;
  65. k.responseXML = n.contentDocument.document.XMLDocument
  66. ? n.contentDocument.document.XMLDocument
  67. : n.contentDocument.document;
  68. }
  69. }
  70. } catch (m) {
  71. jQuery.handleError(i, k, null, m);
  72. }
  73. if (k || o == "timeout") {
  74. h = true;
  75. var p;
  76. try {
  77. p = o != "timeout" ? "success" : "error";
  78. if (p != "error") {
  79. var l = jQuery.uploadHttpData(k, i.dataType);
  80. if (i.success) {
  81. i.success(l, p);
  82. }
  83. if (i.global) {
  84. jQuery.event.trigger("ajaxSuccess", [k, i]);
  85. }
  86. } else {
  87. jQuery.handleError(i, k, p);
  88. }
  89. } catch (m) {
  90. p = "error";
  91. jQuery.handleError(i, k, p, m);
  92. }
  93. if (i.global) {
  94. jQuery.event.trigger("ajaxComplete", [k, i]);
  95. }
  96. if (i.global && !--jQuery.active) {
  97. jQuery.event.trigger("ajaxStop");
  98. }
  99. if (i.complete) {
  100. i.complete(k, p);
  101. }
  102. jQuery(n).unbind();
  103. setTimeout(function () {
  104. try {
  105. jQuery(n).remove();
  106. jQuery(b).remove();
  107. } catch (q) {
  108. jQuery.handleError(i, k, null, q);
  109. }
  110. },
  111. 100);
  112. k = null;
  113. }
  114. };
  115. if (i.timeout > 0) {
  116. setTimeout(function() {
  117. if (!h) {
  118. j("timeout");
  119. }
  120. },
  121. i.timeout);
  122. }
  123. try {
  124. var b = jQuery("#" + c);
  125. jQuery(b).attr("action", i.url);
  126. jQuery(b).attr("method", "POST");
  127. jQuery(b).attr("target", d);
  128. if (b.encoding) {
  129. jQuery(b).attr("encoding", "multipart/form-data");
  130. } else {
  131. jQuery(b).attr("enctype", "multipart/form-data");
  132. }
  133. jQuery(b).submit()
  134. } catch (a) {
  135. jQuery.handleError(i, k, null, a);
  136. }
  137. jQuery("#" + d).load(j);
  138. return {
  139. abort: function () { }
  140. }
  141. },
  142. uploadHttpData: function (r, type) {
  143. var data = !type;
  144. data = type == "xml" || data ? r.responseXML : r.responseText;
  145. if (type == "script") {
  146. jQuery.globalEval(data);
  147. }
  148. if (type == "json") {
  149. eval("data = " + data);
  150. }
  151. if (type == "html") {
  152. jQuery("<div>").html(data).evalScripts();
  153. }
  154. return data;
  155. }
  156. });
  157. var loaddfimg;
  158. var baseinfo;
  159. var bootstrap = function (a, b) {
  160. var c = {
  161. init: function () {
  162. c.initData();
  163. c.bind();
  164. },
  165. bind: function () {
  166. function d(g, h) {
  167. var e = document.getElementById(g).files[0];
  168. var i = window.URL.createObjectURL(e);
  169. document.getElementById(h).src = i;
  170. }
  171. a("#uploadFile").on("change",
  172. function () {
  173. d("uploadFile", "uploadPreview");
  174. });
  175. a("#uploadFile1").on("change",
  176. function () {
  177. d("uploadFile1", "uploadPreview1");
  178. });
  179. a("#uploadFile2").on("change",
  180. function () {
  181. d("uploadFile2", "uploadPreview2");
  182. });
  183. a("#uploadFile3").on("change",
  184. function () {
  185. d("uploadFile3", "uploadPreview3");
  186. });
  187. a("#uploadFile4").on("change",
  188. function () {
  189. d("uploadFile4", "uploadPreview4");
  190. });
  191. a("#uploadFile5").on("change",
  192. function () {
  193. d("uploadFile5", "uploadPreview5");
  194. });
  195. a("#lr_save_btn").on("click",
  196. function () {
  197. var e = document.getElementById("uploadFile").files[0];
  198. if (!!e) {
  199. b.loading(true, "正在保存...");
  200. a.ajaxFileUpload({
  201. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=default",
  202. secureuri: false,
  203. fileElementId: "uploadFile",
  204. dataType: "json",
  205. success: function(f) {
  206. b.loading(false);
  207. a("#uploadFile").on("change",
  208. function() {
  209. d("uploadFile", "uploadPreview");
  210. });
  211. if (f.code == 200) {
  212. b.alert.success("保存成功");
  213. }
  214. }
  215. });
  216. }
  217. });
  218. a("#lr_save_btn1").on("click",
  219. function () {
  220. var e = document.getElementById("uploadFile1").files[0];
  221. if (!!e) {
  222. b.loading(true, "正在保存...");
  223. a.ajaxFileUpload({
  224. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=accordion",
  225. secureuri: false,
  226. fileElementId: "uploadFile1",
  227. dataType: "json",
  228. success: function (f) {
  229. b.loading(false);
  230. a("#uploadFile1").on("change",
  231. function () {
  232. d("uploadFile1", "uploadPreview1");
  233. });
  234. if (f.code == 200) {
  235. b.alert.success("保存成功");
  236. }
  237. }
  238. })
  239. }
  240. });
  241. a("#lr_save_btn2").on("click",
  242. function () {
  243. var e = document.getElementById("uploadFile2").files[0];
  244. if (!!e) {
  245. b.loading(true, "正在保存...");
  246. a.ajaxFileUpload({
  247. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=windows",
  248. secureuri: false,
  249. fileElementId: "uploadFile2",
  250. dataType: "json",
  251. success: function(f) {
  252. b.loading(false);
  253. a("#uploadFile2").on("change",
  254. function() {
  255. d("uploadFile2", "uploadPreview2");
  256. });
  257. if (f.code == 200) {
  258. b.alert.success("保存成功");
  259. }
  260. }
  261. });
  262. }
  263. });
  264. a("#lr_save_btn3").on("click",
  265. function() {
  266. var e = document.getElementById("uploadFile3").files[0];
  267. if (!!e) {
  268. b.loading(true, "正在保存...");
  269. a.ajaxFileUpload({
  270. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=top",
  271. secureuri: false,
  272. fileElementId: "uploadFile3",
  273. dataType: "json",
  274. success: function(f) {
  275. b.loading(false);
  276. a("#uploadFile3").on("change",
  277. function() {
  278. d("uploadFile3", "uploadPreview2");
  279. });
  280. if (f.code == 200) {
  281. b.alert.success("保存成功");
  282. }
  283. }
  284. });
  285. }
  286. });
  287. a("#lr_save_btn4").on("click",
  288. function() {
  289. var e = document.getElementById("uploadFile4").files[0];
  290. if (!!e) {
  291. b.loading(true, "正在保存...");
  292. a.ajaxFileUpload({
  293. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=data",
  294. secureuri: false,
  295. fileElementId: "uploadFile4",
  296. dataType: "json",
  297. success: function(f) {
  298. b.loading(false);
  299. a("#uploadFile4").on("change",
  300. function() {
  301. d("uploadFile4", "uploadPreview4");
  302. });
  303. if (f.code == 200) {
  304. b.alert.success("保存成功");
  305. }
  306. }
  307. });
  308. }
  309. });
  310. a("#lr_save_btn5").on("click",
  311. function() {
  312. var e = document.getElementById("uploadFile5").files[0];
  313. if (!!e) {
  314. b.loading(true, "正在保存...");
  315. a.ajaxFileUpload({
  316. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=headbg",
  317. secureuri: false,
  318. fileElementId: "uploadFile5",
  319. dataType: "json",
  320. success: function(f) {
  321. b.loading(false);
  322. a("#uploadFile5").on("change",
  323. function() {
  324. d("uploadFile5", "uploadPreview5");
  325. });
  326. if (f.code == 200) {
  327. b.alert.success("保存成功");
  328. }
  329. }
  330. });
  331. }
  332. });
  333. },
  334. initData: function () {
  335. a("#file").prepend('<img id="uploadPreview" src="' +
  336. top.$.rootUrl +
  337. '/LR_SystemModule/LogoImg/GetImg?code=default" >');
  338. a("#file1").prepend('<img id="uploadPreview1" src="' +
  339. top.$.rootUrl +
  340. '/LR_SystemModule/LogoImg/GetImg?code=accordion" >');
  341. a("#file2").prepend('<img id="uploadPreview2" src="' +
  342. top.$.rootUrl +
  343. '/LR_SystemModule/LogoImg/GetImg?code=windows" >');
  344. a("#file3").prepend('<img id="uploadPreview3" src="' +
  345. top.$.rootUrl +
  346. '/LR_SystemModule/LogoImg/GetImg?code=top" >');
  347. a("#file4").prepend('<img id="uploadPreview4" src="' +
  348. top.$.rootUrl +
  349. '/LR_SystemModule/LogoImg/GetImg?code=data" >');
  350. a("#file5").prepend('<img id="uploadPreview5" src="' +
  351. top.$.rootUrl +
  352. '/LR_SystemModule/LogoImg/GetImg?code=headbg" >');
  353. }
  354. };
  355. c.init()
  356. };