init.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. define(['jquery', 'bootstrap'], function($, bs) {
  2. window.redirect = function(url) {
  3. location.href = url
  4. }, $(document).on('click', '[data-toggle=refresh]', function(e) {
  5. e && e.preventDefault();
  6. var url = $(e.target).data("href");
  7. url ? window.location = url : window.location.reload()
  8. }), $(document).on('click', '[data-toggle=back]', function(e) {
  9. e && e.preventDefault();
  10. var url = $(e.target).data("href");
  11. url ? window.location = url : window.history.back()
  12. });
  13. function _bindCssEvent(events, callback) {
  14. var dom = this;
  15. function fireCallBack(e) {
  16. if (e.target !== this) {
  17. return
  18. }
  19. callback.call(this, e);
  20. for (var i = 0; i < events.length; i++) {
  21. dom.off(events[i], fireCallBack)
  22. }
  23. }
  24. if (callback) {
  25. for (var i = 0; i < events.length; i++) {
  26. dom.on(events[i], fireCallBack)
  27. }
  28. }
  29. }
  30. $.fn.animationEnd = function(callback) {
  31. _bindCssEvent.call(this, ['webkitAnimationEnd', 'animationend'], callback);
  32. return this
  33. };
  34. $.fn.transitionEnd = function(callback) {
  35. _bindCssEvent.call(this, ['webkitTransitionEnd', 'transitionend'], callback);
  36. return this
  37. };
  38. $.fn.transition = function(duration) {
  39. if (typeof duration !== 'string') {
  40. duration = duration + 'ms'
  41. }
  42. for (var i = 0; i < this.length; i++) {
  43. var elStyle = this[i].style;
  44. elStyle.webkitTransitionDuration = elStyle.MozTransitionDuration = elStyle.transitionDuration = duration
  45. }
  46. return this
  47. };
  48. $.fn.transform = function(transform) {
  49. for (var i = 0; i < this.length; i++) {
  50. var elStyle = this[i].style;
  51. elStyle.webkitTransform = elStyle.MozTransform = elStyle.transform = transform
  52. }
  53. return this
  54. };
  55. $.toQueryPair = function(key, value) {
  56. if (typeof value == 'undefined') {
  57. return key
  58. }
  59. return key + '=' + encodeURIComponent(value === null ? '' : String(value))
  60. };
  61. $.toQueryString = function(obj) {
  62. var ret = [];
  63. for (var key in obj) {
  64. key = encodeURIComponent(key);
  65. var values = obj[key];
  66. if (values && values.constructor == Array) {
  67. var queryValues = [];
  68. for (var i = 0, len = values.length, value; i < len; i++) {
  69. value = values[i];
  70. queryValues.push($.toQueryPair(key, value))
  71. }
  72. ret = concat(queryValues)
  73. } else {
  74. ret.push($.toQueryPair(key, values))
  75. }
  76. }
  77. return ret.join('&')
  78. };
  79. myrequire(['web/table']);
  80. myrequire(['jquery.gcjs']);
  81. myrequire(['web/tip']);
  82. myrequire(['tooltipbox']);
  83. if ($('form.form-validate').length > 0 || $('form.form-modal').length > 0) {
  84. myrequire(['web/form'], function(form) {
  85. form.init()
  86. })
  87. }
  88. myrequire(['web/biz']);
  89. if ($('.select2').length > 0) {
  90. myrequire(['select2'], function() {
  91. $('.select2').each(function() {
  92. $(this).select2({})
  93. })
  94. })
  95. }
  96. myrequire(['web/table']);
  97. if ($('.js-switch').length > 0) {
  98. myrequire(['switchery'], function() {
  99. $('.js-switch').switchery()
  100. })
  101. }
  102. if ($('.js-clip').length > 0) {
  103. myrequire(['clipboard'], function(Clipboard) {
  104. var clipboard = new Clipboard('.js-clip', {
  105. text: function(e) {
  106. return $(e).data('url') || $(e).data('href')
  107. }
  108. });
  109. clipboard.on('success', function(e) {
  110. tip.msgbox.suc('复制成功')
  111. })
  112. })
  113. }
  114. $.fn.append2 = function(html, callback) {
  115. var len = $("body").html().length;
  116. this.append(html);
  117. var e = 1,
  118. interval = setInterval(function() {
  119. e++;
  120. var clear = function() {
  121. clearInterval(interval);
  122. callback && callback()
  123. };
  124. if (len != $("body").html().length || e > 1000) {
  125. clear()
  126. }
  127. }, 1)
  128. };
  129. $('[data-toggle="popover"]').popover();
  130. $(document).on("click", '[data-toggle="ajaxModal"]', function(e) {
  131. e.preventDefault();
  132. var obj = $(this),
  133. confirm = obj.data("confirm");
  134. var handler = function() {
  135. $("#ajaxModal").remove(), e.preventDefault();
  136. var url = obj.data("href") || obj.attr("href"),
  137. data = obj.data("set"),
  138. modal;
  139. $.ajax(url, {
  140. type: "get",
  141. dataType: "html",
  142. cache: false,
  143. data: data
  144. }).done(function(html) {
  145. if (html.substr(0, 8) == '{"status') {
  146. json = eval("(" + html + ')');
  147. if (json.status == 0) {
  148. msg = typeof(json.result) == 'object' ? json.result.message : json.result;
  149. tip.msgbox.err(msg || tip.lang.err);
  150. return
  151. }
  152. }
  153. modal = $('<div class="modal fade" id="ajaxModal"><div class="modal-body "></div></div>');
  154. $(document.body).append(modal), modal.modal('show');
  155. myrequire(['jquery.gcjs'], function() {
  156. modal.append2(html, function() {
  157. var form_validate = $('form.form-validate', modal);
  158. if (form_validate.length > 0) {
  159. $("button[type='submit']", modal).length && $("button[type='submit']", modal).attr("disabled", true);
  160. myrequire(['web/form'], function(form) {
  161. form.init();
  162. $("button[type='submit']", modal).length && $("button[type='submit']", modal).removeAttr("disabled")
  163. })
  164. }
  165. })
  166. })
  167. })
  168. },
  169. a;
  170. if (confirm) {
  171. tip.confirm(confirm, handler)
  172. } else {
  173. handler()
  174. }
  175. }), $(document).on("click", '[data-toggle="ajaxPost"]', function(e) {
  176. e.preventDefault();
  177. var obj = $(this),
  178. confirm = obj.data("confirm"),
  179. url = obj.data('href') || obj.attr('href'),
  180. data = obj.data('set') || {},
  181. html = obj.html();
  182. handler = function() {
  183. e.preventDefault();
  184. if (obj.attr('submitting') == '1') {
  185. return
  186. }
  187. obj.html('<i class="fa fa-spinner fa-spin"></i>').attr('submitting', 1);
  188. $.post(url, {
  189. data: data
  190. }, function(ret) {
  191. ret = eval("(" + ret + ")");
  192. if (ret.status == 1) {
  193. tip.msgbox.suc(ret.result.message || tip.lang.success, ret.result.url)
  194. } else {
  195. tip.msgbox.err(ret.result.message || tip.lang.error, ret.result.url), obj.removeAttr('submitting').html(html)
  196. }
  197. }).fail(function() {
  198. obj.removeAttr('submitting').html(html), tip.msgbox.err(tip.lang.exception)
  199. })
  200. };
  201. confirm && tip.confirm(confirm, handler);
  202. !confirm && handler()
  203. }), $(document).on("click", '[data-toggle="ajaxEdit"]', function(e) {
  204. var obj = $(this),
  205. url = obj.data('href') || obj.attr('href'),
  206. data = obj.data('set') || {},
  207. html = $.trim(obj.text()),
  208. required = obj.data('required') || true,
  209. edit = obj.data('edit') || 'input';
  210. var oldval = $.trim($(this).text());
  211. e.preventDefault();
  212. submit = function() {
  213. e.preventDefault();
  214. var val = $.trim(input.val());
  215. if (required) {
  216. if (val == '') {
  217. tip.msgbox.err(tip.lang.empty);
  218. return
  219. }
  220. }
  221. if (val == html) {
  222. input.remove(), obj.html(val).show();
  223. return
  224. }
  225. if (url) {
  226. $.post(url, {
  227. value: val
  228. }, function(ret) {
  229. ret = eval("(" + ret + ")");
  230. if (ret.status == 1) {
  231. obj.html(val).show()
  232. } else {
  233. tip.msgbox.err(ret.result.message, ret.result.url)
  234. }
  235. input.remove()
  236. }).fail(function() {
  237. input.remove(), tip.msgbox.err(tip.lang.exception)
  238. })
  239. } else {
  240. input.remove();
  241. obj.html(val).show()
  242. }
  243. obj.trigger('valueChange', [val, oldval])
  244. }, obj.hide().html('<i class="fa fa-spinner fa-spin"></i>');
  245. var input = $('<input type="text" class="form-control input-sm" style="width: 80%;display: inline;" />');
  246. if (edit == 'textarea') {
  247. input = $('<textarea type="text" class="form-control" style="resize:none" rows=3 ></textarea>')
  248. }
  249. obj.after(input);
  250. input.val(html).select().blur(function() {
  251. submit(input)
  252. }).keypress(function(e) {
  253. if (e.which == 13) {
  254. submit(input)
  255. }
  256. })
  257. }), $(document).on("click", '[data-toggle="ajaxSwitch"]', function(e) {
  258. e.preventDefault();
  259. var obj = $(this),
  260. confirm = obj.data('msg') || obj.data('confirm'),
  261. othercss = obj.data('switch-css'),
  262. other = obj.data('switch-other'),
  263. refresh = obj.data('switch-refresh') || false;
  264. if (obj.attr('submitting') == '1') {
  265. return
  266. }
  267. var value = obj.data('switch-value'),
  268. value0 = obj.data('switch-value0'),
  269. value1 = obj.data('switch-value1');
  270. if (value === undefined || value0 === undefined || value1 === undefined) {
  271. return
  272. }
  273. var url, css, text, newvalue, newurl, newcss, newtext;
  274. value0 = value0.split('|');
  275. value1 = value1.split('|');
  276. if (value == value0[0]) {
  277. url = value0[3], css = value0[2], text = value0[1], newvalue = value1[0], newtext = value1[1], newcss = value1[2]
  278. } else {
  279. url = value1[3], css = value1[2], text = value1[1], newvalue = value0[0], newtext = value0[1], newcss = value0[2]
  280. }
  281. var html = obj.html();
  282. var submit = function() {
  283. $.post(url).done(function(data) {
  284. data = eval("(" + data + ")");
  285. if (data.status == 1) {
  286. if (other && othercss) {
  287. if (newvalue == '1') {
  288. $(othercss).each(function() {
  289. if ($(this).data('switch-value') == newvalue) {
  290. this.className = css;
  291. $(this).data('switch-value', value).html(text || html)
  292. }
  293. })
  294. }
  295. }
  296. obj.data('switch-value', newvalue);
  297. obj.html(newtext || html);
  298. obj[0].className = newcss;
  299. refresh && location.reload()
  300. } else {
  301. obj.html(html), tip.msgbox.err(data.result.message || tip.lang.error, data.result.url)
  302. }
  303. obj.removeAttr('submitting')
  304. }).fail(function() {
  305. obj.removeAttr('submitting');
  306. obj.button('reset');
  307. tip.msgbox.err(tip.lang.exception)
  308. })
  309. },
  310. a;
  311. if (confirm) {
  312. tip.confirm(confirm, function() {
  313. obj.html('<i class="fa fa-spinner fa-spin"></i>').attr('submitting', 1), submit()
  314. })
  315. } else {
  316. obj.html('<i class="fa fa-spinner fa-spin"></i>').attr('submitting', 1), submit()
  317. }
  318. });
  319. $(document).on('click', '[data-toggle="selectUrl"]', function() {
  320. $("#selectUrl").remove();
  321. var _input = $(this).data('input');
  322. var _full = $(this).data('full');
  323. var _platform = $(this).data('platform');
  324. var _callback = $(this).data('callback') || false;
  325. var _cbfunction = !_callback ? false : eval("(" + _callback + ")");
  326. if (!_input && !_callback) {
  327. return
  328. }
  329. var merch = $(".diy-phone").data("merch");
  330. var url = biz.url('util/selecturl', null, merch);
  331. var store = $(".diy-phone").data("store");
  332. if (store) {
  333. url = biz.url('store/diypage/selecturl')
  334. }
  335. if (_full) {
  336. url = url + "&full=1"
  337. }
  338. if (_platform) {
  339. url = url + "&platform=" + _platform
  340. }
  341. $.ajax('seller.php?s=/util/selecturl', {
  342. type: "get",
  343. dataType: "html",
  344. cache: false
  345. }).done(function(html) {
  346. modal = $('<div class="modal fade" id="selectUrl"></div>');
  347. $(document.body).append(modal), modal.modal('show');
  348. modal.append2(html, function() {
  349. $(document).off("click", '#selectUrl nav').on("click", '#selectUrl nav', function() {
  350. var _href = $.trim($(this).data("href"));
  351. if (_input) {
  352. $(_input).val(_href).trigger('change')
  353. } else if (_cbfunction) {
  354. _cbfunction(_href)
  355. }
  356. modal.find(".close").click()
  357. })
  358. })
  359. })
  360. });
  361. $(document).on('click', '[data-toggle="selectImg"]', function() {
  362. var _input = $(this).data('input');
  363. var _img = $(this).data('img');
  364. var _full = $(this).data('full');
  365. require(['jquery', 'util'], function($, util) {
  366. util.image('', function(data) {
  367. var imgurl = data.attachment;
  368. if (_full) {
  369. imgurl = data.url
  370. }
  371. if (_input) {
  372. $(_input).val(imgurl).trigger('change')
  373. }
  374. if (_img) {
  375. $(_img).attr('src', data.url)
  376. }
  377. })
  378. })
  379. });
  380. $(document).on('click', '[data-toggle="selectIcon"]', function() {
  381. var _input = $(this).data('input');
  382. var _element = $(this).data('element');
  383. if (!_input && !_element) {
  384. return
  385. }
  386. var merch = $(".diy-phone").data("merch");
  387. var url = biz.url('util/selecticon', null, merch);
  388. $.ajax(url, {
  389. type: "get",
  390. dataType: "html",
  391. cache: false
  392. }).done(function(html) {
  393. modal = $('<div class="modal fade" id="selectIcon"></div>');
  394. $(document.body).append(modal), modal.modal('show');
  395. modal.append2(html, function() {
  396. $(document).off("click", '#selectIcon nav').on("click", '#selectIcon nav', function() {
  397. var _class = $.trim($(this).data("class"));
  398. if (_input) {
  399. $(_input).val(_class).trigger('change')
  400. }
  401. if (_element) {
  402. $(_element).removeAttr("class").addClass("icon " + _class)
  403. }
  404. modal.find(".close").click()
  405. })
  406. })
  407. })
  408. });
  409. $(document).on('click', '[data-toggle="selectAudio"]', function() {
  410. var _input = $(this).data('input');
  411. var _full = $(this).data('full');
  412. require(['jquery', 'util'], function($, util) {
  413. util.audio('', function(data) {
  414. var audiourl = data.attachment;
  415. if (_full) {
  416. audiourl = data.url
  417. }
  418. if (_input) {
  419. $(_input).val(audiourl).trigger('change')
  420. }
  421. })
  422. })
  423. });
  424. $(document).on('click', '[data-toggle="selectVideo"]', function() {
  425. var _input = $(this).data('input');
  426. var _full = $(this).data('full');
  427. require(['jquery', 'util'], function($, util) {
  428. util.audio('', function(data) {
  429. var audiourl = data.attachment;
  430. if (_full) {
  431. audiourl = data.url
  432. }
  433. if (_input) {
  434. $(_input).val(audiourl).trigger('change')
  435. }
  436. }, {
  437. type: 'video'
  438. })
  439. })
  440. });
  441. $(document).on('click', '[data-toggle="previewVideo"]', function() {
  442. var videoelm = $(this).data('input');
  443. if (!videoelm) {
  444. return
  445. }
  446. var video = $(videoelm).data('url');
  447. if (!video || video == '') {
  448. tip.msgbox.err('未选择视频');
  449. return
  450. }
  451. if ($('#previewVideo').length < 1) {
  452. $('body').append('<div class="modal fade" id="previewVideo"><div class="modal-dialog" style="min-width: 400px !important;"><div class="modal-content"><div class="modal-header"><button data-dismiss="modal" class="close" type="button">×</button><h4 class="modal-title">视频预览</h4></div><div class="modal-body" style="padding: 0; background: #000;"><video src="' + video + '" style="height: 450px; width: 100%; display: block;" controls="controls"></video></div></div></div></div>')
  453. } else {
  454. $("#previewVideo video").attr("src", video)
  455. }
  456. $("#previewVideo").modal();
  457. $("#previewVideo").on("hidden.bs.modal", function() {
  458. $(this).find("video")[0].pause()
  459. })
  460. });
  461. $(window).resize(function() {
  462. var width = $(window).width();
  463. if (width <= 1440) {
  464. $(".wb-panel-fold").removeClass('in').html('<i class="icow icow-info"></i> 消息提醒');
  465. $(".wb-panel").removeClass('in');
  466. $('.wb-container').addClass('right-panel')
  467. } else {
  468. $(".wb-panel-fold").addClass('in').html('<i class="fa fa-angle-double-right"></i> 收起面板');
  469. $(".wb-panel").addClass('in');
  470. $('.wb-container').removeClass('right-panel')
  471. }
  472. });
  473. $(window).scroll(function() {
  474. if ($(window).scrollTop() > 200) {
  475. $('.fixed-header').addClass('active')
  476. } else {
  477. $('.fixed-header').removeClass('active')
  478. }
  479. });
  480. $('.wb-nav-fold').click(function() {
  481. var nav = $(this).closest(".wb-nav");
  482. if (nav.hasClass('fold')) {
  483. nav.removeClass('fold');
  484. $(".wb-header .logo").removeClass('small');
  485. $(".fast-nav").removeClass('indent');
  486. util.cookie.set('foldnav', 0)
  487. } else {
  488. nav.addClass('fold');
  489. $(".wb-header .logo").addClass('small');
  490. $(".fast-nav").addClass('indent');
  491. util.cookie.set('foldnav', 1)
  492. }
  493. });
  494. $('.wb-subnav-fold').click(function() {
  495. var subnav = $(this).closest(".wb-subnav");
  496. if (subnav.hasClass('fold')) {
  497. subnav.removeClass('fold')
  498. } else {
  499. subnav.addClass('fold')
  500. }
  501. });
  502. $('.menu-header').click(function() {
  503. if ($(this).hasClass('active')) {
  504. $(this).next('ul').eq(0).hide();
  505. $(this).find('.menu-icon').removeClass('fa-caret-down').addClass('fa-caret-right');
  506. $(this).removeClass('active')
  507. } else {
  508. $(this).next('ul').eq(0).show();
  509. $(this).find('.menu-icon').removeClass('fa-caret-right').addClass('fa-caret-down');
  510. $(this).addClass('active')
  511. }
  512. });
  513. $('.wb-header-btn').click(function() {
  514. if ($('.wb-topbar-search').hasClass('expand-search')) {
  515. $('.wb-search-box').focus();
  516. var keyword = $.trim($(".wb-search-box").val());
  517. if (keyword != '') {
  518. location.href = './index.php?c=site&a=entry&m=lionfish_comshop&do=admin&r=search&keyword=' + keyword;
  519. return
  520. }
  521. } else {}
  522. });
  523. $(".wb-search-box").bind('input propertychange', function() {
  524. var keyword = $.trim($(this).val());
  525. var merch = $(this).data('merch') || 0;
  526. if (keyword == '') {
  527. $('.wb-search-result ul').empty();
  528. $('.wb-search-result').hide();
  529. $(".wb-search-box").val('');
  530. return
  531. }
  532. $.getJSON(biz.url('searchlist', null, merch), {
  533. keyword: keyword
  534. }, function(ret) {
  535. var result = ret.result;
  536. var html = '';
  537. $('.wb-search-result ul').empty();
  538. if (result.menu.length < 1) {
  539. html = '<li class="empty-data"><a>暂未搜索到与“' + keyword + '”相关功能</a></li>'
  540. } else {
  541. $.each(result.menu, function(index, menu) {
  542. html += '<li><a href="' + menu.url + '">' + menu.title + '</a></li>'
  543. })
  544. }
  545. $('.wb-search-result ul').html(html);
  546. $('.wb-search-result').show()
  547. })
  548. });
  549. $(".wb-header-logout").click(function() {
  550. var href = $(this).closest('li').data('href');
  551. tip.confirm("当前已登录,确认退出?", function() {
  552. location.href = href
  553. })
  554. });
  555. $(".wb-panel-fold").click(function() {
  556. $(this).toggleClass('in');
  557. $(".wb-panel").toggleClass('in');
  558. if (!$(this).hasClass('in')) {
  559. $(this).html('<i class="icow icow-info"></i> 消息提醒');
  560. util.cookie.set('foldpanel', 1);
  561. $('.wb-container').addClass('right-panel')
  562. } else {
  563. $(this).html('<i class="fa fa-angle-double-right"></i> 收起面板');
  564. util.cookie.set('foldpanel', 0);
  565. $('.wb-container').removeClass('right-panel')
  566. }
  567. });
  568. $(".wb-shortcut").click(function() {
  569. if ($(this).hasClass('active')) {
  570. $(this).removeClass('active');
  571. $(".fast-nav").removeClass('in')
  572. } else {
  573. $(this).addClass('active');
  574. $(".fast-nav").addClass('in')
  575. }
  576. });
  577. $(".fast-list.menu a").hover(function() {
  578. $(this).addClass('active').siblings().removeClass('active');
  579. var tab = $(this).data('tab');
  580. $(".fast-list.list [data-tab='" + tab + "']").addClass('in').siblings('.in').removeClass('in');
  581. $(".funbar-panel").hide();
  582. $("#funbar-name").val('');
  583. $("#funbar-color").val('#666666')
  584. });
  585. $(".funbar-add-btn").click(function() {
  586. $(".funbar-panel").show();
  587. $("#funbar-bold-0").prop('checked', 'checked')
  588. });
  589. $(".funbar-cancel-btn").click(function() {
  590. $(".funbar-panel").hide();
  591. $("#funbar-name").val('');
  592. $("#funbar-color").val('#666666')
  593. });
  594. $(".funbar-save-btn").click(function() {
  595. var name = $.trim($("#funbar-name").val());
  596. if (name == '') {
  597. tip.msgbox.err('请输入导航名称');
  598. return
  599. }
  600. var color = $("#funbar-color").val();
  601. var bold = $("#funbar-bold-1").is(':checked') ? 1 : 0;
  602. var link = $("#funbar-link").val();
  603. var fundata = {
  604. href: link,
  605. text: name,
  606. color: color,
  607. bold: bold
  608. };
  609. $.post(biz.url('sysset/funbar/post'), {
  610. funbardata: fundata
  611. }, function(ret) {
  612. if (ret.status == 1) {
  613. var html = '<a href="' + link + '" style=" ';
  614. if (bold == 1) {
  615. html += 'font-weight: bold;'
  616. }
  617. if (color != '#666666') {
  618. html += 'color: ' + color + ';'
  619. }
  620. html += '">' + name + '</a>';
  621. $("#funbar-list").prepend(html);
  622. $(".funbar-panel").hide();
  623. $("#funbar-name").val('');
  624. $("#funbar-color").val('#666666')
  625. } else {
  626. tip.msgbox.err("保存失败请重试!")
  627. }
  628. }, 'json')
  629. });
  630. $("#btn-clear-history").click(function() {
  631. var merch = $(this).data('merch') || 0;
  632. tip.confirm("确认清除最近访问吗?", function() {
  633. $.post(biz.url('clearhistory', null, merch), {
  634. type: 0
  635. }, function(ret) {
  636. $(".fast-list.history").remove()
  637. })
  638. })
  639. });
  640. $(document).click(function(e) {
  641. var btn1 = $(e.target).closest('.wb-shortcut').length;
  642. if (!btn1) {
  643. var fastNav = $(e.target).closest('.fast-nav').length;
  644. if (!fastNav) {
  645. $(".wb-shortcut").removeClass('active');
  646. $(".fast-nav").removeClass('in')
  647. }
  648. }
  649. });
  650. if ($(".form-editor-group").length > 0) {
  651. $(".form-editor-group .form-editor-btn").click(function() {
  652. var editor = $(this).closest(".form-editor-group");
  653. editor.find(".form-editor-show").hide();
  654. editor.find(".form-editor-edit").css('display', 'table')
  655. });
  656. $(".form-editor-group .form-editor-finish").click(function() {
  657. if ($(this).closest(".form-group").hasClass("has-error")) {
  658. return
  659. }
  660. var editor = $(this).closest(".form-editor-group");
  661. editor.find(".form-editor-show").show();
  662. editor.find(".form-editor-edit").hide();
  663. var input = editor.find(".form-editor-input");
  664. var value = $.trim(input.val());
  665. editor.find(".form-editor-text").text(value)
  666. })
  667. }
  668. $("img").error(function() {
  669. $(this).attr('src', '/static/images/nopic.png')
  670. })
  671. });