core.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. /* ================================================================================
  2. * dever.js v1.0
  3. * http://git.shemic.com/dever/script
  4. * ================================================================================
  5. * Copyright 2017-2018 Dever(dever.cc)
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * ================================================================================
  19. */
  20. //<filter><script src="../script/lib/jquery/jquery.min.js"></script><script src="../script/dever/core.js"></script></filter>
  21. $(function()
  22. {
  23. Dever.Init();
  24. });
  25. //公共类库
  26. var Dever =
  27. {
  28. countdown : -1,
  29. Init : function()
  30. {
  31. this.Import();
  32. this.Page().Init();
  33. this.User().Init();
  34. this.Editor().Init();
  35. this.Upload().Init();
  36. this.Change();
  37. this.LoadPage();
  38. this.Extend();
  39. //this.Target();
  40. //this.Pjax();
  41. }
  42. ,Pjax : function()
  43. {
  44. $(document).pjax('a', '.container');
  45. //$.pjax.reload('.container');
  46. }
  47. ,Page : function()
  48. {
  49. return _Dever_Page;
  50. }
  51. ,Template : function()
  52. {
  53. return _Dever_Template;
  54. }
  55. ,Editor : function()
  56. {
  57. return _Dever_Editor;
  58. }
  59. ,User : function()
  60. {
  61. return _Dever_User;
  62. }
  63. ,Modal : function()
  64. {
  65. return _Dever_Modal;
  66. }
  67. ,Upload : function()
  68. {
  69. return _Dever_Upload;
  70. }
  71. ,Proxy : function(uri)
  72. {
  73. return config.proxy + 'proxy_method=' + encodeURIComponent(uri);
  74. }
  75. ,Jump : function(url)
  76. {
  77. location.href = url;
  78. }
  79. ,BackRun : function(url)
  80. {
  81. $.post(url);
  82. }
  83. ,Reload : function(e)
  84. {
  85. e.attr('src', e.attr('src'));
  86. }
  87. ,Target : function()
  88. {
  89. var link = config.host;
  90. $("a").each(function() {
  91. if (!$(this).attr('onclick')) {
  92. var url = $(this).attr('href');
  93. if (url && url.indexOf(link) == -1) {
  94. //$(this).attr('target', '_blank');
  95. }
  96. }
  97. })
  98. }
  99. ,Time : function(e, time, text)
  100. {
  101. var self = this;
  102. if (this.countdown < 0) {
  103. this.countdown = time;
  104. }
  105. if (this.countdown == 0) {
  106. e.attr("disabled", false);
  107. e.html(text);
  108. self.Init();
  109. this.countdown = time;
  110. } else {
  111. e.attr("disabled", true);
  112. e.html(this.countdown + 's后' + text);
  113. this.countdown--;
  114. e.unbind('click');
  115. setTimeout(function() {
  116. self.Time(e, time, text)
  117. },1000)
  118. }
  119. }
  120. ,Import : function()
  121. {
  122. var self = this;
  123. var include = $("include");
  124. var count = include.length-1;
  125. if (include.length) {
  126. include.each(function(i){
  127. var dom = $(this);
  128. var system = dom.attr('system');
  129. var path = dom.attr('path');
  130. var name = dom.attr('file');
  131. var file = '';
  132. if(path) file = path;
  133. if(system) file = file + '/' + system;
  134. file += name + '.html';
  135. dom.load(file, function(){
  136. $("html").find("include").eq(i).get(0).outerHTML = dom.html();
  137. if (i == count) {
  138. self.Template().Init();
  139. }
  140. });
  141. })
  142. } else {
  143. self.Template().Init();
  144. }
  145. }
  146. ,LoadPage : function()
  147. {
  148. if ($('.dever-loadpage').length) {
  149. $('.dever-loadpage').each(function() {
  150. var url = $(this).attr('dever-url');
  151. var self = $(this);
  152. $.getJSON(Dever.CallUrl(url), function(t) {
  153. self.html(t.msg);
  154. _Dever_Page.Ajax(self);
  155. });
  156. });
  157. }
  158. }
  159. ,CallUrl : function(url)
  160. {
  161. if (url.indexOf('callback') == -1) {
  162. if (url.indexOf('=') != -1) {
  163. url += '&json=1&callback=?';
  164. } else {
  165. url += '?json=1&callback=?';
  166. }
  167. }
  168. return url;
  169. }
  170. ,Change : function()
  171. {
  172. if ($('.dever-change').length) {
  173. $('.dever-change').change(function() {
  174. Dever.Jump($(this).attr('dever-change')+$(this).val());
  175. });
  176. //$('.dever-change').val($('.dever-change').attr('dever-value'));
  177. }
  178. }
  179. ,Host : function(host, uri)
  180. {
  181. var result = '';
  182. uri = uri ? uri : '';
  183. result = config.host.replace('www', host);
  184. result = result.replace('main', host);
  185. if (config.proxy) {
  186. return this.Proxy(host + '/' + uri);
  187. }
  188. return result + uri;
  189. }
  190. // 输出数据,提示框
  191. ,Out : function(content, callback, title)
  192. {
  193. if (content && content.indexOf('登录') != -1 && $("#login_url").length) {
  194. var href = $("#login_url").val();
  195. location.href = href;
  196. return;
  197. } else {
  198. this.Modal().Alert(content, {'yes':callback, 'no':callback}, title);
  199. }
  200. }
  201. // 将数据解析,并进行下一步操作
  202. ,Msg : function(result, error_callback, success_callback)
  203. {
  204. if (result.status == 2) {
  205. if (result.data) {
  206. if (result.data.element) {
  207. if (result.data.attr) {
  208. $(result.data.element).attr(result.data.attr, result.data.value);
  209. } else {
  210. $(result.data.element).val(result.data.value);
  211. }
  212. } else if (result.data.url) {
  213. location.href = result.data.url;
  214. }
  215. }
  216. if (error_callback) {
  217. return error_callback(result.msg);
  218. }
  219. this.Out(result.msg);
  220. } else {
  221. if (typeof(result.data) == 'string') {
  222. result.msg = result.data;
  223. }
  224. if (success_callback) {
  225. return success_callback(result.msg);
  226. }
  227. if (result.msg.indexOf('http://') != -1) {
  228. this.Jump(result.msg);
  229. } else if (parseInt(result.msg) > 0) {
  230. this.Out('操作成功', function() {
  231. location.reload();
  232. });
  233. } else {
  234. this.Out(result.msg);
  235. }
  236. }
  237. }
  238. ,Confirm : function(content, callback, title)
  239. {
  240. this.Modal().Confirm(content, {'yes':callback}, title);
  241. }
  242. ,Extend : function()
  243. {
  244. Array.prototype.indexIn = function(val) {
  245. for (var i = 0; i < this.length; i++) {
  246. if (this[i] == val) return i;
  247. }
  248. return -1;
  249. };
  250. Array.prototype.remove = function(val) {
  251. var index = this.indexIn(val);
  252. if (index > -1) {
  253. this.splice(index, 1);
  254. }
  255. };
  256. $("select option").each(function() {
  257. if ($(this).attr('select') && $(this).attr('select') == 'true') {
  258. $(this).attr('selected', 'true');
  259. } else {
  260. $(this).removeAttr('selected');
  261. }
  262. });
  263. }
  264. ,Ucfirst : function(str)
  265. {
  266. var str = str.toLowerCase();
  267. var strarr = str.split(' ');
  268. var result = '';
  269. for (var i in strarr){
  270. result += strarr[i].substring(0,1).toUpperCase()+strarr[i].substring(1)+' ';
  271. }
  272. return result;
  273. }
  274. };
  275. //瀑布流分页
  276. var _Dever_Page =
  277. {
  278. name : '',
  279. Init : function()
  280. {
  281. if ($(this.name).length) {
  282. var self = this;
  283. $(window).scroll(function() {
  284. if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
  285. self.Start(self.name);
  286. }
  287. });
  288. }
  289. }
  290. ,Start : function(page)
  291. {
  292. page = page ? page : this.name;
  293. if ($(page).length) {
  294. $(page).hide();
  295. var url = $(page).attr('link');
  296. if (url) {
  297. var key = $(page).attr('dever-list');
  298. $.get(url, function(t) {
  299. t = '<div>' + t + '</div>';
  300. var c = $(t).find(key).html();
  301. if (c) {
  302. $(key).append(c);
  303. var l = $(t).find(page).attr('link');
  304. $(page).attr('link', l);
  305. }
  306. });
  307. }
  308. }
  309. }
  310. ,Ajax : function(e)
  311. {
  312. var self = this;
  313. e.find('a').each(function() {
  314. var url = $(this).attr('href');
  315. $(this).attr('href', 'javascript:;');
  316. $(this).unbind('click').bind('click', function() {
  317. $.get(url.replace('callback', ''), function(t) {
  318. e.html(t);
  319. self.Ajax(e);
  320. });
  321. });
  322. });
  323. }
  324. }
  325. //模态框
  326. var _Dever_Modal =
  327. {
  328. state : false,
  329. html : '',
  330. box : '',
  331. title : '',
  332. content : '',
  333. yes : '',
  334. no : '',
  335. setting : '',
  336. confirm : '',
  337. Init : function()
  338. {
  339. this.state = false;
  340. if (this.html && this.box && this.content) {
  341. $('body').append(this.html);
  342. this.box = $(this.box);
  343. this.box.hide();
  344. this.content = $(this.content);
  345. if(this.title) this.title = $(this.title);
  346. if(this.yes) this.yes = $(this.yes);
  347. if(this.no) this.no = $(this.no);
  348. if(this.setting) this.setting = $(this.setting);
  349. if(this.confirm) this.confirm = $(this.confirm);
  350. if(!this.timeout) this.timeout = 3000;
  351. this.state = true;
  352. }
  353. }
  354. ,Alert : function(content, callback, title)
  355. {
  356. if (this.state == false) {
  357. alert(content);
  358. if (callback) {
  359. callback.yes();
  360. }
  361. } else {
  362. if (this.setting.length && this.setting.html()) {
  363. if (this.confirm) this.confirm.hide();
  364. this.setting.show();
  365. } else {
  366. if (this.setting) this.setting.hide();
  367. if (this.confirm) this.confirm.show();
  368. }
  369. this.content.html(content);
  370. if (title) {
  371. this.title.html(title);
  372. }
  373. this.box.show();
  374. if (callback.yes) {
  375. this.Bind(callback);
  376. } else {
  377. this.TimeOut();
  378. }
  379. }
  380. }
  381. ,Confirm : function(content, callback, title)
  382. {
  383. if (this.state == false) {
  384. if (confirm(content)) {
  385. callback.yes();
  386. }
  387. } else {
  388. if (this.confirm) this.confirm.show();
  389. if (this.setting) this.setting.hide();
  390. this.content.html(content);
  391. if (title) {
  392. this.title.html(title);
  393. }
  394. this.box.show();
  395. if (callback.yes) {
  396. this.Bind(callback);
  397. }
  398. }
  399. }
  400. ,Bind : function(callback)
  401. {
  402. if (this.yes.length && callback.yes) {
  403. this.yes.unbind('click').bind('click', callback.yes);
  404. }
  405. if (this.no.length) {
  406. if (callback.no) {
  407. this.no.unbind('click').bind('click', callback.no);
  408. } else {
  409. var self = this;
  410. this.no.unbind('click').bind('click', function()
  411. {
  412. self.Close();
  413. });
  414. }
  415. }
  416. }
  417. ,TimeOut : function()
  418. {
  419. var self = this;
  420. setTimeout(function(){self.Close()}, self.timeout);
  421. }
  422. ,Close : function()
  423. {
  424. this.box.hide();
  425. }
  426. }
  427. //用户相关
  428. var _Dever_User =
  429. {
  430. config : [],
  431. uid : -1,
  432. name : '匿名用户',
  433. Init : function()
  434. {
  435. var self = this;
  436. if (this.config.click) {
  437. for (var i in this.config.click) {
  438. var e = self.config.click[i];
  439. var c = 1;
  440. if (e.indexOf('|') != -1) {
  441. var t = e.split('|');
  442. e = t[0];
  443. c = 2;
  444. }
  445. if ($(e).length) {
  446. $(e).attr('data-i', i);
  447. $(e).attr('data-c', c);
  448. $(e).unbind('click').bind('click', function() {
  449. if ($(this).attr('data-c') == 2) {
  450. var t1 = $(this);
  451. Dever.Confirm(function() {
  452. self.Save($(this).attr('data-i'), t1, config);
  453. });
  454. } else {
  455. self.Save($(this).attr('data-i'), $(this), config);
  456. }
  457. });
  458. }
  459. }
  460. }
  461. }
  462. //通用的保存数据功能
  463. ,Save : function(key, e, setting)
  464. {
  465. var self = this;
  466. var config = self.config[key];
  467. if (config.start) {
  468. config.start.call();
  469. }
  470. var send = {};
  471. var callback = function(msg,state) {
  472. if (config.status && $(config.status).length) {
  473. //$(config.status).html(msg).css('visibility','initial');
  474. state ? $(config.status).html(msg).hide() : $(config.status).html(msg).show();
  475. } else if(!state) {
  476. Dever.Out(msg);
  477. }
  478. }
  479. if (typeof(config.input) != 'undefined') {
  480. if (typeof(config.input) == 'string' && config.input == 'parent') {
  481. if (e.attr('dever-send')) {
  482. send[e.attr('dever-send')] = e.attr('dever-' + e.attr('dever-send'));
  483. }
  484. send.id = e.attr('dever-id');
  485. send.value = e.parent().find('input').val();
  486. if (!send.id || !send.value) {
  487. callback(config.error);
  488. return;
  489. }
  490. } else if (typeof(config.input) == 'string' && config.input == 'click') {
  491. if (e.attr('dever-send')) {
  492. var a = e.attr('dever-send').split('&');
  493. for (var i in a) {
  494. if (typeof(a[i]) == 'string') {
  495. var b = a[i].split('=');
  496. send[b[0]] = b[1];
  497. }
  498. }
  499. }
  500. } else if (typeof(config.input) == 'object') {
  501. for (var i in config.input) {
  502. var option = false;
  503. var input = config.input[i];
  504. if (input.indexOf('|') != -1) {
  505. var t = input.split('|');
  506. input = t[0];
  507. option = true;
  508. }
  509. var m = true;
  510. var el = $(input);
  511. //e.get(0).tagName == 'TEXTAREA'
  512. send[i] = el.val();
  513. if (option == false) {
  514. if (send[i] && el.attr('dever-match')) {
  515. var r = new RegExp(el.attr('dever-match'));
  516. m = r.test(send[i]);
  517. }
  518. if (send[i] && el.attr('dever-value')) {
  519. m = $(el.attr('dever-value')).val() == send[i];
  520. }
  521. if (!send[i] || m != true) {
  522. var error = el.attr('dever-error') ? el.attr('dever-error') : config.error;
  523. callback(error);
  524. return;
  525. }
  526. }
  527. }
  528. }
  529. }
  530. if (!send) {
  531. callback(config.error);
  532. return;
  533. }
  534. if (!config.url) {
  535. config.url = e.attr('dever-send');
  536. }
  537. if (e.attr('dever-refresh')) {
  538. config.url = e.attr('dever-refresh');
  539. }
  540. callback(1,1);
  541. config.url = Dever.CallUrl(config.url);
  542. if (setting.proxy) {
  543. $.post(config.url, send, function(t) {
  544. t = eval('(' + t + ')');
  545. Dever.Msg(t, callback, (config.callback ? function(msg){config.callback(e,msg,t)} : false));
  546. });
  547. } else {
  548. $.getJSON(config.url, send, function(t) {
  549. Dever.Msg(t, callback, (config.callback ? function(msg){config.callback(e,msg,t)} : false));
  550. });
  551. }
  552. }
  553. };
  554. //编辑器相关
  555. var _Dever_Editor =
  556. {
  557. state : false,
  558. editors : [],
  559. Init : function()
  560. {
  561. if (typeof marked == 'function') {
  562. this.state = true;
  563. } else {
  564. this.state = false;
  565. }
  566. this.SetMark();
  567. var self = this;
  568. if ($('.dever-note').length) {
  569. $('.dever-note').each(function() {
  570. self.InitEditor($(this));
  571. })
  572. }
  573. }
  574. ,InitEditor : function(e)
  575. {
  576. var id = e.attr('id');
  577. var key = e.attr('key');
  578. if (config.uid && config.uid > 0) {
  579. var toolbar = [
  580. 'title'
  581. ,'bold'
  582. ,'italic'
  583. ,'underline'
  584. ,'strikethrough'
  585. ,'fontScale'
  586. ,'color'
  587. ,'ol'
  588. ,'ul'
  589. ,'blockquote'
  590. ,'code'
  591. ,'table'
  592. ,'link'
  593. ,'image'
  594. ,'hr'
  595. ,'indent'
  596. ,'outdent'
  597. ,'alignment'
  598. //,'emoji'
  599. ];
  600. } else {
  601. var toolbar = [
  602. 'title'
  603. ,'bold'
  604. ,'fontScale'
  605. ,'color'
  606. ,'ol'
  607. ,'ul'
  608. ,'blockquote'
  609. ,'indent'
  610. ,'outdent'
  611. ,'alignment'
  612. ];
  613. }
  614. if (typeof(this.editors[id]) == "undefined") {
  615. this.editors[id] = new Simditor({
  616. textarea: e,
  617. upload:
  618. {
  619. url: config.upload + '.simditor',
  620. params: {key:key},
  621. fileKey: 'file',
  622. connectionCount: 10,
  623. leaveConfirm: 'Uploading is in progress, are you sure to leave this page?'
  624. },
  625. toolbar : toolbar
  626. /*
  627. ,emoji:
  628. {
  629. imagePath: config.lib + 'simditor/plugins/emoji/images/emoji/'
  630. }
  631. */
  632. });
  633. }
  634. }
  635. ,SetMark : function()
  636. {
  637. return;
  638. }
  639. ,GetMark : function(content)
  640. {
  641. if (this.state == true) {
  642. return marked(content);
  643. }
  644. return content;
  645. }
  646. };
  647. //模板
  648. var _Dever_Template =
  649. {
  650. state : false,
  651. method : '',
  652. element : '',
  653. data : '',
  654. param : '',
  655. attr : '',
  656. Init : function()
  657. {
  658. if (this.Check()) {
  659. var url = config.proxyTemplateUrl;
  660. var send = {};
  661. var parsing = [];
  662. $("dever").each(function(){
  663. parsing.push($(this).html());
  664. $(this).remove();
  665. });
  666. send.url = location.href;
  667. send.parsing = parsing.join('');
  668. send.html = $("html").html();
  669. //$("html").html('dever template loading...');
  670. $.ajax({
  671. type: "POST",
  672. url: url,
  673. data: send,
  674. dataType: "json",
  675. success: function(result){
  676. $("html").html(result.data);
  677. }
  678. });
  679. }
  680. }
  681. ,Check : function()
  682. {
  683. if ($("dever").length) {
  684. this.state = true;
  685. } else {
  686. this.state = false;
  687. }
  688. return this.state;
  689. }
  690. }
  691. //上传 请载入layui
  692. var _Dever_Upload =
  693. {
  694. upload : [],
  695. upload_file : [],
  696. upload_pic : [],
  697. callback : {},
  698. Init : function()
  699. {
  700. var self = this;
  701. if ($(".dever-upload-drag").length) {
  702. $(".dever-upload-drag").each(function() {
  703. var key = $(this).attr('key');
  704. if (config.proxy) {
  705. var url = Dever.Proxy('upload/save.drag') + '&key=' + key;
  706. } else {
  707. var url = config.upload + '.drag?key='+ key;
  708. }
  709. $(this).inlineattachment({
  710. uploadUrl: url,
  711. progressText: '![文件上传中...]()',
  712. urlText: "![文件描述]({filename})\n",
  713. errorText: '上传失败'
  714. });
  715. });
  716. }
  717. if ($(".dever-upload").length) {
  718. $(".dever-upload").each(function(i) {
  719. self.Load(i,$(this));
  720. })
  721. }
  722. }
  723. ,Load : function(i,e)
  724. {
  725. var self = this;
  726. var id = e.attr('id');
  727. var value = e.attr('dever-upload-value');
  728. var key = e.attr('dever-upload-key');
  729. var url = config.upload + '.start';
  730. if (typeof(this.upload[value]) != "undefined") {
  731. return;
  732. }
  733. if (!key) {
  734. key = 1;
  735. }
  736. self.upload[value] = true;
  737. self.upload_pic[value] = [];
  738. self.upload_file[value] = [];
  739. layui.use(['upload','layer'], function() {
  740. var layer = layui.layer;
  741. var layuiUpload = layui.upload;
  742. var uploadInst = layuiUpload.render({
  743. elem: '#' + id
  744. ,data: {'key' : key}
  745. ,field: 'file'
  746. ,url: url
  747. ,multiple: true
  748. ,before: function(obj) {
  749. layer.load();
  750. }
  751. ,done: function(data) {
  752. layer.closeAll('loading');
  753. if (data.status == 1) {
  754. var type = e.attr('dever-upload-type');
  755. var html = '';
  756. var callback = e.attr('dever-upload-callback');
  757. if (type == 'mul') {
  758. if (self.upload_pic[value].length <= 0 && $("#" + value).val()) {
  759. self.upload_pic[value] = $("#" + value).val().split(',');
  760. }
  761. if (self.callback && self.callback[callback]) {
  762. html += self.callback[callback].call(self, e, data.url, 'dever-upload-close');
  763. } else {
  764. html += '<li><img src="'+data.url+'" class="pics"><em class="dever-upload-close"></em></li>';
  765. }
  766. e.before(html);
  767. self.Close(value);
  768. self.upload_pic[value].push(data.url);
  769. $("#" + value).val(self.upload_pic[value].join(','));
  770. } else {
  771. if (self.callback && self.callback[callback]) {
  772. html = self.callback[callback].call(self, e, data.url, 'dever-upload-close');
  773. } else {
  774. html = '<img src="'+data.url+'" class="pics">';
  775. }
  776. e.html(html);
  777. }
  778. } else {
  779. layer.msg(data.msg, {icon: 4});
  780. return false;
  781. }
  782. }
  783. ,error: function() {
  784. layer.msg('上传失败', {icon: 4});
  785. return false;
  786. }
  787. });
  788. });
  789. }
  790. ,Close : function(v)
  791. {
  792. var self = this;
  793. $('.dever-upload-close').each(function()
  794. {
  795. $(this).unbind('click').bind('click', function() {
  796. var e = $(this).parent();
  797. var p = e.find('img').attr('src');
  798. e.remove();
  799. self.upload_pic[v].remove(p);
  800. $("#" + v).val(self.upload_pic[v].join(','));
  801. });
  802. });
  803. }
  804. }