main.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  1. //这里的代码是最早写的,很乱,以后整合优化
  2. var editors = [];
  3. var tables = [];
  4. var select = '';
  5. $(document).ready(function()
  6. {
  7. //init();
  8. });
  9. function init()
  10. {
  11. select = '';
  12. edit();
  13. del();
  14. checkbox();
  15. image();
  16. change();
  17. autocomplete();
  18. template();
  19. submit();
  20. loadShow();
  21. initEditor();
  22. initPic();
  23. initDate();
  24. //更新页面一些功能,上边的一些功能等找时间再优化吧
  25. dever_update.init();
  26. hljs.initHighlightingOnLoad();
  27. table();
  28. }
  29. function initMenu()
  30. {
  31. if(typeof(config.layout) != "undefined")
  32. {
  33. $('.list-unstyled li').each(function(j)
  34. {
  35. $(this).unbind('click').bind('click', function()
  36. {
  37. if ($(this).index() == i) {
  38. return;
  39. }
  40. $('.list-unstyled .active').each(function()
  41. {
  42. $(this).attr('class', '');
  43. $(this).find('a').attr('class', '');
  44. })
  45. $(this).attr('class', 'active');
  46. var a = $(this).find('a');
  47. a.attr('class', 'subdrop');
  48. //alert($(this).attr('class'));
  49. })
  50. });
  51. /*
  52. $('.project-list').each(function(i)
  53. {
  54. $(this).unbind('click').bind('click', function()
  55. {
  56. if ($(this).index() == i) {
  57. return;
  58. }
  59. $('.project-list').each(function()
  60. {
  61. $(this).find('i').parent().attr('class', '');
  62. $(this).find('ul').attr('class', 'list-unstyled upload-menu');
  63. })
  64. $(this).find('i').parent().attr('class', 'active');
  65. $(this).find('ul').attr('class', 'list-unstyled upload-menu in');
  66. })
  67. });
  68. */
  69. }
  70. }
  71. function setOption(e, id)
  72. {
  73. var s = $("select[name="+id+"]");
  74. var v = s.val();
  75. if (!select) {
  76. select = s.clone();
  77. }
  78. s.find('option[parent]').remove();
  79. //查找出需要显示的option并复制
  80. var options = select.find("option[parent="+e.val()+"]").clone();
  81. //将需要显示的option添加到select中
  82. s.append(options);
  83. //因为option.remove()不会刷新控件,需要将新的option切换上去
  84. //这里排除了options.size() == 0的情况
  85. var state = 2;
  86. s.find('option').each(function()
  87. {
  88. var val = $(this).val();
  89. if (v == val) {
  90. state = 1;
  91. }
  92. });
  93. if (state == 1) {
  94. s.val(v);
  95. } else {
  96. s.val(0);
  97. }
  98. }
  99. function table()
  100. {
  101. $('.table-responsive[data-pattern]').each(function()
  102. {
  103. //$(this).responsiveTable('update');
  104. });
  105. }
  106. function pjax(param)
  107. {
  108. param.timeout = 8000;
  109. $.pjax(param);
  110. }
  111. function initDate()
  112. {
  113. $.datetimepicker.setLocale('ch');
  114. if($(".manage_time").length)
  115. {
  116. $(".manage_time").each(function()
  117. {
  118. $(this).datetimepicker(
  119. {
  120. //inline:true,
  121. timepicker:false,
  122. format:'Y-m-d',
  123. lang:'ch'
  124. });
  125. });
  126. }
  127. if($(".manage_date").length)
  128. {
  129. $(".manage_date").each(function()
  130. {
  131. $(this).datetimepicker(
  132. {
  133. //datepicker:false,
  134. format:'Y-m-d H:i:s',
  135. lang:'ch'
  136. });
  137. });
  138. }
  139. }
  140. function initPic()
  141. {
  142. $('a[rel]').fancybox();
  143. }
  144. function initEditor()
  145. {
  146. if($('.editor').length)
  147. {
  148. $('.editor').each(function()
  149. {
  150. var parent = $(this).parent().parent();
  151. //alert(parent.attr('id'));
  152. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  153. {
  154. return;
  155. }
  156. loadEditor($(this));
  157. //loadKEditor($(this));
  158. })
  159. }
  160. }
  161. function loadKEditor(e)
  162. {
  163. if(!e.length)
  164. {
  165. return;
  166. }
  167. var id = e.attr('id');
  168. var key = e.attr('key');
  169. if(typeof(editors[id]) == "object")
  170. {
  171. editors[id] = undefined;
  172. }
  173. if(typeof(editors[id]) == "undefined")
  174. {
  175. var key = e.attr('key');
  176. var param = {
  177. allowImageUpload: true, //上传图片框本地上传的功能,false为隐藏,默认为true
  178. allowImageRemote : false, //上传图片框网络图片的功能,false为隐藏,默认为true
  179. allowFileManager : false, //浏览图片空间
  180. filterMode : false, //HTML特殊代码过滤
  181. themeType : 'simple',
  182. filePostName : 'file',
  183. uploadJson : config.upload + '.kindeditor?key=' + key,
  184. fileManagerJson : config.upload + '.kindeditorFile?key=' + key
  185. /*,
  186. items : [
  187. 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
  188. 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
  189. 'insertunorderedlist', '|', 'emoticons', 'image', 'link', 'lineheight']
  190. */
  191. }
  192. KindEditor.ready(function(K) {
  193. editors[id] = K.create('#' + id, param);
  194. });
  195. }
  196. }
  197. function loadEditor(e)
  198. {
  199. //return loadKEditor(e);
  200. if(!e.length)
  201. {
  202. return;
  203. }
  204. var id = e.attr('id');
  205. var key = e.attr('key');
  206. var toolbar = [
  207. 'title'
  208. ,'bold'
  209. ,'italic'
  210. ,'underline'
  211. ,'strikethrough'
  212. ,'fontScale'
  213. ,'color'
  214. ,'ol'
  215. ,'ul'
  216. ,'blockquote'
  217. ,'code'
  218. ,'table'
  219. ,'link'
  220. ,'image'
  221. ,'hr'
  222. ,'indent'
  223. ,'outdent'
  224. ,'alignment'
  225. //,'emoji'
  226. , '|'
  227. ,'html'
  228. ];
  229. if(typeof(editors[id]) == "object")
  230. {
  231. editors[id].destroy();
  232. editors[id] = undefined;
  233. }
  234. if(typeof(editors[id]) == "undefined")
  235. {
  236. editors[id] = new Simditor(
  237. {
  238. textarea: e,
  239. upload:
  240. {
  241. url: config.upload + '.simditor',
  242. params: {key:key},
  243. fileKey: 'file',
  244. connectionCount: 10,
  245. leaveConfirm: 'Uploading is in progress, are you sure to leave this page?'
  246. },
  247. toolbar : toolbar,
  248. emoji:
  249. {
  250. imagePath: config.lib + 'simditor/plugins/emoji/images/emoji/'
  251. }
  252. });
  253. }
  254. }
  255. //更新页面的提交按钮
  256. function submit()
  257. {
  258. if($(".save-data").length)
  259. {
  260. $(".save-data").unbind('click').bind('click', function()
  261. {
  262. submit_action();
  263. //$(this).unbind('click');
  264. })
  265. }
  266. }
  267. //设置某一个input的值
  268. function set_update(id, value)
  269. {
  270. if($(id).length)
  271. {
  272. $(id).val(value);
  273. }
  274. }
  275. /**
  276. * 批量复制数据
  277. */
  278. function copy_data(e)
  279. {
  280. var html = '<div>';
  281. html += '<div><span>请输入要复制的数量:</span><input type="text" class="form-control form_margin" id="temp_copy_num" /></div>';
  282. html += '</div>';
  283. $('#dever_modal_body').html(html);
  284. $('#dever_modal_title').html('复制数据');
  285. $("#dever_modal_yes").unbind('click').bind('click', function()
  286. {
  287. set_update('#copy_num', $("#temp_copy_num").val());
  288. set_update('#update_where_id', 0);
  289. submit_action();
  290. });
  291. }
  292. //直接提交更新页的数据
  293. function submit_action()
  294. {
  295. $(".form1").submit();
  296. }
  297. //头部菜单
  298. function topMenu(e)
  299. {
  300. var p = e.parent().parent().parent().find('span');
  301. p.html(e.html());
  302. //更新当前的精细权限
  303. var url = config.host + 'top.update_action?json=1';
  304. var id = e.attr('data-id');
  305. $.post(url, {id:id}, function(t)
  306. {
  307. var href = location.href;
  308. if(location.href.indexOf('where_id') != -1)
  309. {
  310. var temp = location.href.split('where_id');
  311. href = temp[0] + 'where_id=' + t;
  312. }
  313. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  314. {
  315. pjax({url: href, container: config.layout})
  316. }
  317. else
  318. {
  319. location.href = href;
  320. }
  321. })
  322. }
  323. //更新页面的批量载入选择
  324. function loadShow()
  325. {
  326. if($(".show_input").length)
  327. {
  328. $(".show_input input").each(function()
  329. {
  330. if($(this).attr('checked'))
  331. {
  332. inputShow($(this), $(this).attr('show_id'));
  333. }
  334. })
  335. $(".show_input select").each(function()
  336. {
  337. if($(this).attr('selected'))
  338. {
  339. inputShow($(this), $(this).attr('show_id'));
  340. }
  341. })
  342. }
  343. }
  344. function inputShow(e,n)
  345. {
  346. var item = e.parent().find('input');
  347. $(".show_" + n).hide();
  348. var array = ['input', 'textarea'];
  349. for(var a in array)
  350. {
  351. if ($(".show_" + n).find(array[a]).length) {
  352. var c = $(".show_" + n).find(array[a]).attr('class');
  353. if (c.indexOf('validate[required]') > -1) {
  354. $(".show_" + n).find(array[a]).removeClass('validate[required]').addClass('validates');
  355. }
  356. }
  357. }
  358. item.each(function()
  359. {
  360. if($(this).get(0).checked == true)
  361. {
  362. inputShowOne($(this),n);
  363. }
  364. });
  365. }
  366. function inputShowOne(e,n)
  367. {
  368. var value = e.val();
  369. //$(".show_" + n).hide();
  370. //$(".show_" + n + '_' + value).attr('style','color:red').show();
  371. $(".show_" + n + '_' + value).show();
  372. var array = ['input', 'textarea'];
  373. for(var a in array)
  374. {
  375. if($(".show_" + n + '_' + value).length && $(".show_" + n + '_' + value).attr('class').indexOf('show_no') == -1)
  376. {
  377. $(".show_" + n + '_' + value).find(array[a]).each(function()
  378. {
  379. var parent = $(this).parent();
  380. if($(this).attr('class') != 'editor' && $(this).attr('class').indexOf('validates') > -1 && parent.find('label').length && parent.find('label').html().indexOf('选填') == -1)
  381. {
  382. $(this).addClass('validate[required]');
  383. }
  384. })
  385. }
  386. }
  387. }
  388. //批量更新
  389. function list_mul(e)
  390. {
  391. var type = parseInt($("#mul_type").val());
  392. if(type != 1 && type != 2)
  393. {
  394. alert('您还没有选择数据更新方式');
  395. return;
  396. }
  397. if(confirm('确定进行此项操作吗?'))
  398. {
  399. //e.html('更新中').unbind('click');
  400. $('#method').val('mul');
  401. $('#function').val('msg');
  402. $('#form1').attr('target', 'f1').submit();
  403. }
  404. }
  405. //搜索
  406. function list_search(e)
  407. {
  408. $('#method').val('search');
  409. $('#function').val('');
  410. $('#form1').attr('target', '').submit();
  411. }
  412. //更新数据
  413. function update(e, id, project, table, notice)
  414. {
  415. var call = function()
  416. {
  417. var col = e.attr('name').replace('up_col_', '');
  418. var value = e.val();
  419. var url = config.host + 'database.update_action?json=1';
  420. $.post(url, {where_id:id,col:col,value:value,project:project,table:table}, function(t)
  421. {
  422. notify('操作已成功!您的操作已修改当前选项!');
  423. preview();
  424. })
  425. }
  426. if(notice && confirm(notice))
  427. {
  428. call();
  429. }
  430. else
  431. {
  432. call();
  433. }
  434. }
  435. function notify(msg)
  436. {
  437. var notice = new PNotify({
  438. title: '提示信息',
  439. text: msg,
  440. buttons: {
  441. closer: false,
  442. sticker: false
  443. }
  444. });
  445. notice.get().click(function() {
  446. notice.remove();
  447. });
  448. }
  449. //模板选择
  450. function template()
  451. {
  452. if(config.template)
  453. {
  454. $('body').attr('class', 'theme-' + config.template);
  455. }
  456. if($(".selector").length)
  457. {
  458. $(".selector").each(function()
  459. {
  460. if($(this).data('check') == 'checked')
  461. {
  462. selector($(this));
  463. }
  464. })
  465. }
  466. }
  467. //选择器
  468. function selector(e)
  469. {
  470. var value = e.data('value');
  471. var name = e.data('name');
  472. $('#'+name+'_value').val(value);
  473. $('.'+name+'_selector').children().css({'border':'1px solid #ccc'});
  474. e.children().css({'border':'1px solid black'});
  475. if(name == 'update_template')
  476. {
  477. $('body').attr('class', 'theme-' + value);
  478. }
  479. }
  480. //根据e的值,来载入其他数据
  481. function loading(e, data)
  482. {
  483. var value = e.val();
  484. if(e.attr('id') && e.attr('id').indexOf('_temp') != -1)
  485. {
  486. var id = e.attr('id').replace('_temp', '');
  487. if($('#' + id).length)
  488. {
  489. var value = $('#' + id).val();
  490. }
  491. }
  492. if(data.element)
  493. {
  494. if(data.url)
  495. {
  496. data.value = value;
  497. $.getJSON(data.url, data, function(t)
  498. {
  499. $('#update_'+data.element+'_value').val(t.data);
  500. });
  501. }
  502. else
  503. {
  504. $('#update_'+data.element+'_value').val(value);
  505. }
  506. }
  507. else if(data.url)
  508. {
  509. data.value = value;
  510. data.where_id = $('#update_where_id').val();
  511. data.table = $('#table').val();
  512. data.project = $('#project').val();
  513. $.getJSON(data.url, data, function(s)
  514. {
  515. t = s.data;
  516. if(t.indexOf('onblur') != -1)
  517. {
  518. eval(t);
  519. }
  520. else
  521. {
  522. var parent = e.parent().parent();
  523. if(t.indexOf('status') == -1)
  524. {
  525. if(data.type == 1)
  526. {
  527. $('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
  528. {
  529. $(this).remove();
  530. });
  531. }
  532. else
  533. {
  534. $('.checking_-1,.checking_3,.checking_4').each(function()
  535. {
  536. $(this).remove();
  537. });
  538. }
  539. parent.after(t);
  540. checkbox();
  541. }
  542. }
  543. });
  544. }
  545. }
  546. //根据e的值,来载入其他数据,先检测是否选中
  547. function checking(name, e, data)
  548. {
  549. var value = [];
  550. $('.' + name).each(function()
  551. {
  552. if($(this).get(0).checked == true)
  553. {
  554. value.push($(this).val());
  555. }
  556. });
  557. if(data.url)
  558. {
  559. data.value = value.join(',');
  560. data.where_id = $('#update_where_id').val();
  561. data.table = $('#table').val();
  562. data.project = $('#project').val();
  563. if(data.check)
  564. {
  565. data.check_value = false;
  566. $(data.check).each(function()
  567. {
  568. if($(this).get(0).checked == true)
  569. {
  570. data.check_value = $(this).val();
  571. }
  572. });
  573. }
  574. $.getJSON(data.url, data, function(s)
  575. {
  576. t = s.data;
  577. var parent = e.parent().parent().parent();
  578. if(t.indexOf('status') == -1)
  579. {
  580. if(data.type == 1)
  581. {
  582. $('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
  583. {
  584. $(this).remove();
  585. });
  586. }
  587. else
  588. {
  589. $('.checking_-1,.checking_3,.checking_4').each(function()
  590. {
  591. $(this).remove();
  592. });
  593. }
  594. parent.after(t);
  595. checkbox();
  596. }
  597. });
  598. }
  599. }
  600. function autocomplete()
  601. {
  602. if($("input[complete]").length)
  603. {
  604. $("input[complete]").each(function()
  605. {
  606. var cache = {};
  607. var self = $(this);
  608. self.autocomplete(
  609. {
  610. minLength: 2,
  611. source: function( request, response )
  612. {
  613. var term = request.term;
  614. if ( term in cache ) {
  615. response( cache[ term ] );
  616. return;
  617. }
  618. $.getJSON(self.attr('complete') + '&callback=?', request, function( data, status, xhr ) {
  619. console.info(data);
  620. cache[ term ] = data;
  621. var state = true;
  622. for(var i in data)
  623. {
  624. if(data[i].id <=0)
  625. {
  626. state = false;
  627. }
  628. }
  629. if(state)
  630. {
  631. response( data );
  632. }
  633. });
  634. },
  635. select: function( event, ui )
  636. {
  637. //log( "Selected: " + ui.item.value + " aka " + ui.item.id );
  638. var value = self.attr('complete_callback');
  639. var id = self.attr('id').replace('_temp', '');
  640. $("#" + id).val(ui.item[value]);
  641. }
  642. });
  643. })
  644. }
  645. }
  646. //后台通用的提示
  647. function msg(value)
  648. {
  649. if(!value.data)
  650. {
  651. value.data = value.msg;
  652. }
  653. if(value == 1)
  654. {
  655. location.reload();
  656. return;
  657. }
  658. submit();
  659. var url = '';
  660. if(value.data != 'reload' && value.status == 2)
  661. {
  662. //showAlert(value.msg);
  663. alert(value.data);
  664. //location.reload();
  665. return;
  666. }
  667. else if(value.data == 'reload')
  668. {
  669. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  670. {
  671. pjax({url: location.href, container: config.layout})
  672. }
  673. else
  674. {
  675. location.reload();
  676. }
  677. return;
  678. }
  679. else
  680. {
  681. if(value.data.indexOf('http://') != -1)
  682. {
  683. url = value.data;
  684. }
  685. else if($("#url").length)
  686. {
  687. url = $("#url").val();
  688. }
  689. else
  690. {
  691. notify(value.data)
  692. return;
  693. }
  694. if(url)
  695. {
  696. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  697. {
  698. pjax({url: url, container: config.layout});
  699. }
  700. else
  701. {
  702. location.href = url;
  703. }
  704. }
  705. else
  706. {
  707. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  708. {
  709. pjax({url: location.href, container: config.layout});
  710. }
  711. else
  712. {
  713. location.reload();
  714. }
  715. }
  716. }
  717. return;
  718. }
  719. /**
  720. * 处理多选问题,处理全选按钮
  721. */
  722. function checkbox()
  723. {
  724. if($(".autoload").length)
  725. {
  726. $(".autoload").each(function()
  727. {
  728. if($(this).get(0).checked == true)
  729. {
  730. $(this).removeClass('autoload');
  731. $(this).load();
  732. }
  733. });
  734. }
  735. if($(".autoload_text").length)
  736. {
  737. $(".autoload_text").each(function()
  738. {
  739. if($(this).val())
  740. {
  741. $(this).removeClass('autoload_text');
  742. $(this).load();
  743. }
  744. });
  745. }
  746. var name = 'checkbox-checkall';
  747. var checkbox = $("." + name);
  748. if(checkbox.length)
  749. {
  750. checkbox.click(function()
  751. {
  752. var self = $(this);
  753. $("." + name + "-" + self.val()).each(function()
  754. {
  755. $(this).get(0).checked = self.get(0).checked;
  756. var next = $(this).next();
  757. if($(this).get(0).checked == true)
  758. {
  759. if(next.length)
  760. {
  761. //next.attr('disabled', false);
  762. }
  763. if($("#mul_type").length)
  764. {
  765. $("#mul_type").val(1);
  766. }
  767. }
  768. else
  769. {
  770. if(next.length)
  771. {
  772. //next.attr('disabled', true);
  773. }
  774. if($("#mul_type").length)
  775. {
  776. $("#mul_type").val(0);
  777. }
  778. }
  779. if ($(this).attr('onclick') && $(this).attr('onclick').indexOf('show') > 0) {
  780. inputShow($(this), 'col');
  781. }
  782. })
  783. });
  784. checkbox.each(function()
  785. {
  786. var self = $(this);
  787. $("." + name + "-" + self.val()).each(function()
  788. {
  789. $(this).click(function()
  790. {
  791. var next = $(this).next();
  792. if($(this).get(0).checked == true)
  793. {
  794. self.get(0).checked = true;
  795. if(self.attr('type') == 'radio')
  796. {
  797. //如果父选项是radio类型,做下限制
  798. //alert(1);
  799. }
  800. if($("#mul_type").length)
  801. {
  802. $("#mul_type").val(1);
  803. }
  804. if(next.length)
  805. {
  806. //next.attr('disabled', false);
  807. }
  808. }
  809. else
  810. {
  811. //子选项取消时,处理一下父级选项
  812. var num = 0;
  813. $("." + name + "-" + self.val()).each(function()
  814. {
  815. if($(this).get(0).checked == true)
  816. {
  817. num = 1;
  818. }
  819. });
  820. if(num == 0)
  821. {
  822. self.get(0).checked = false;
  823. if($("#mul_type").length)
  824. {
  825. $("#mul_type").val(0);
  826. }
  827. }
  828. if(next.length)
  829. {
  830. //next.attr('disabled', true);
  831. }
  832. }
  833. })
  834. if($(this).get(0).checked == true)
  835. {
  836. self.get(0).checked = true;
  837. if ($(this).attr('onclick') && $(this).attr('onclick').indexOf('show') > 0) {
  838. inputShow($(this), 'col');
  839. }
  840. }
  841. });
  842. })
  843. }
  844. }
  845. /**
  846. * 处理双击编辑
  847. */
  848. function edit()
  849. {
  850. if($(".edit").length)
  851. {
  852. $(".edit").each(function()
  853. {
  854. $(this).bind('dblclick', function()
  855. {
  856. var col = $(this).attr('data-col');
  857. var project = $(this).attr('data-project');
  858. var table = $(this).attr('data-table');
  859. var url = $(this).attr('data-url');
  860. var id = $(this).attr('data-id');
  861. var html = $(this).attr('data-content');
  862. var type = $(this).attr('data-type');
  863. if($(this).find(".edit-content").length)
  864. {
  865. html = $(this).find(".edit-content").html();
  866. html = html.replace('<!--', '<');
  867. html = html.replace('-->', '>');
  868. }
  869. if(html.indexOf('input') == -1)
  870. {
  871. if(type && type == 'textarea')
  872. {
  873. $(this).html('<textarea type="text" name="edit" id="edit" rows="10" cols="60">'+html+'</textarea>');
  874. }
  875. else
  876. {
  877. $(this).html('<input type="text" name="edit" id="edit" value="'+html+'">');
  878. }
  879. var self = $(this);
  880. self.find("#edit").blur(function()
  881. {
  882. var value = self.find("#edit").val();
  883. if(!value)
  884. {
  885. alert('不能为空');
  886. return;
  887. }
  888. if($(this).find(".edit-content").length)
  889. {
  890. $(this).find(".edit-content").html(value);
  891. }
  892. else
  893. {
  894. self.attr('data-content', value);
  895. }
  896. self.html(value);
  897. $.post(url, {project:project,table:table,value:value,where_id:id,col:col}, function(t)
  898. {
  899. notify('修改成功');
  900. preview();
  901. /*
  902. if(type && type == 'textarea')
  903. {
  904. self.html(t);
  905. }
  906. */
  907. })
  908. })
  909. }
  910. });
  911. })
  912. }
  913. }
  914. function preview()
  915. {
  916. if($("#preview").length)
  917. {
  918. var time = Date.parse(new Date());
  919. var src = $('#preview').attr('src').split('#');
  920. $('#preview').attr('src', src[0] + '&' + time + '#' + src[1]);
  921. }
  922. }
  923. function del()
  924. {
  925. if($(".oper_delete").length)
  926. {
  927. $(".oper_delete").each(function()
  928. {
  929. var href = $(this).attr('href');
  930. $(this).attr('href', '#');
  931. $(this).unbind('click');
  932. $(this).bind('click', function()
  933. {
  934. del_act(href);
  935. });
  936. })
  937. }
  938. }
  939. /**
  940. * 处理删除
  941. */
  942. function del_act(href)
  943. {
  944. if(confirm('确定进行此项操作吗?'))
  945. {
  946. $.getJSON(href + '&json=1&callback=?', {}, function(t)
  947. {
  948. msg(t);
  949. })
  950. }
  951. }
  952. /**
  953. * 处理特殊加载的按钮
  954. */
  955. function load(href)
  956. {
  957. if(confirm('确定进行此项操作吗?'))
  958. {
  959. if(href.indexOf('&') == -1)
  960. {
  961. href += '?json=1&callback=?';
  962. }
  963. else
  964. {
  965. href += '&json=1&callback=?';
  966. }
  967. $.getJSON(href, {}, function(t)
  968. {
  969. msg(t);
  970. //location.reload();
  971. })
  972. }
  973. /*
  974. showAlert('确定进行此项操作吗?', function()
  975. {
  976. $("#dever_modal_no").click();
  977. $.getJSON(href + '&json=1', {}, function(t)
  978. {
  979. msg(t);
  980. })
  981. });
  982. */
  983. }
  984. /**
  985. * 处理特殊加载的按钮
  986. */
  987. function jump(href)
  988. {
  989. location.href = href;
  990. }
  991. /**
  992. * 处理change
  993. */
  994. function change()
  995. {
  996. if($(".change").length)
  997. {
  998. $(".change").each(function()
  999. {
  1000. var key = $(this).attr('data-child');
  1001. /*
  1002. $('.' + key).each(function()
  1003. {
  1004. if($(this).find('select option:selected').val())
  1005. {
  1006. $(this).show();
  1007. $('#set_cate_id_child').get(0).value = $(this).attr('parent');
  1008. }
  1009. });
  1010. */
  1011. $(this).change(function()
  1012. {
  1013. $('.' + key).hide();
  1014. var v = $('.' + key + '_' + $(this).val());
  1015. var s = v.find('select');
  1016. s.change(function()
  1017. {
  1018. $('.' + key + '_value').val($(this).val());
  1019. })
  1020. if(v.length)
  1021. {
  1022. $('.' + key + '_value').val(s.val());
  1023. v.show();
  1024. }
  1025. else
  1026. {
  1027. $('.' + key + '_value').val(-1);
  1028. }
  1029. });
  1030. if($(this).val() > 0)
  1031. {
  1032. $(this).change();
  1033. }
  1034. });
  1035. }
  1036. }
  1037. /**
  1038. * 处理图库系统
  1039. */
  1040. function image()
  1041. {
  1042. if($(".dever-note").length)
  1043. {
  1044. $(".dever-note").each(function()
  1045. {
  1046. var key = $(this).attr('key');
  1047. $(this).inlineattachment(
  1048. {
  1049. uploadUrl: config.upload + '.drag?key='+ key
  1050. });
  1051. });
  1052. }
  1053. if($(".image_upload").length)
  1054. {
  1055. $(".image_upload").each(function(i)
  1056. {
  1057. var parent = $(this).parent().parent();
  1058. //alert(parent.attr('id'));
  1059. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1060. {
  1061. return;
  1062. }
  1063. loadUpload(i,$(this),$(this).attr('key'),config.upload + '.start', config.lib + 'upload/');//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1064. })
  1065. }
  1066. }
  1067. /**
  1068. * 修改密码
  1069. */
  1070. function pass(e)
  1071. {
  1072. var html = '<style>.password_edit div{margin:10px;}.password_edit input{width:200px;}</style><div class="password_edit">';
  1073. html += '<div><span>旧密码:</span><input type="password" class="form-control form_margin" id="edit_old_password" /></div>';
  1074. html += '<div><span>新密码:</span><input type="password" class="form-control form_margin" id="edit_new_password" /></div>';
  1075. html += '</div>';
  1076. $('#dever_modal_body').html(html);
  1077. $('#dever_modal_title').html('修改密码');
  1078. $("#dever_modal_yes").unbind('click').bind('click', function()
  1079. {
  1080. var old_password = $("#edit_old_password").val();
  1081. var new_password = $("#edit_new_password").val();
  1082. if(!old_password || !new_password)
  1083. {
  1084. alert('请输入密码');
  1085. return;
  1086. }
  1087. if(old_password == new_password)
  1088. {
  1089. alert('旧密码和新密码相同');
  1090. return;
  1091. }
  1092. $.post(config.host + 'auth.password', {old:old_password,new:new_password}, function(t)
  1093. {
  1094. alert(t);
  1095. $("#dever_modal_no").click();
  1096. })
  1097. })
  1098. }
  1099. var MSG = [];
  1100. /**
  1101. * 打开弹窗
  1102. */
  1103. //function showMsg(title, e, id, func)
  1104. function showMsg(title, e, id, func)
  1105. {
  1106. if(id.indexOf('http://') == -1)
  1107. {
  1108. if($(id).length)
  1109. {
  1110. var html = $(id).html();
  1111. if($(id).html())
  1112. {
  1113. var html = $(id).html();
  1114. MSG[id] = html;
  1115. $(id).html('');
  1116. }
  1117. else
  1118. {
  1119. var html = MSG[id];
  1120. }
  1121. }
  1122. else
  1123. {
  1124. var html = id;
  1125. }
  1126. $('#dever_modal_body').html(html);
  1127. $('#dever_modal_title').html(title);
  1128. if(func)
  1129. {
  1130. $("#dever_modal_yes").unbind('click').bind('click', func);
  1131. }
  1132. }
  1133. else
  1134. {
  1135. if(e)
  1136. {
  1137. data = e.attr('msg-send');
  1138. }
  1139. $.getJSON(id+'?json=1',{data:data},function(t)
  1140. {
  1141. t = t.data;
  1142. $('#dever_modal_body').html(t);
  1143. $('#dever_modal_title').html(title);
  1144. if(func)
  1145. {
  1146. $("#dever_modal_yes").unbind('click').bind('click', func);
  1147. }
  1148. });
  1149. }
  1150. }
  1151. function updateMsg(id)
  1152. {
  1153. $("#"+id).submit();
  1154. }
  1155. function showAlert(msg, func)
  1156. {
  1157. //$("#dever_modal_no").click();
  1158. $("#dever_modal").modal();
  1159. $('#dever_modal_body').html(msg);
  1160. $('#dever_modal_title').html('提醒您');
  1161. if(func)
  1162. {
  1163. $("#dever_modal_yes").unbind('click').bind('click', func);
  1164. }
  1165. else
  1166. {
  1167. $("#dever_modal_yes").unbind('click').bind('click', function(){$("#dever_modal_no").click()});
  1168. }
  1169. }
  1170. /*
  1171. var test =
  1172. {
  1173. refreshPage: false,
  1174. addAjaxFlag: true,
  1175. //添加收藏
  1176. add: function(cfg)
  1177. {
  1178. }
  1179. }
  1180. */
  1181. function showToggle(e)
  1182. {
  1183. var id = e.attr('toggle');
  1184. var child = e.attr('toggle_child');
  1185. var parent = e.parent();
  1186. parent.parent().find('li').removeClass('active');
  1187. parent.addClass('active');
  1188. $(child).fadeOut(100);
  1189. $(id).fadeIn(500);
  1190. loadEditor($(id).find('.editor'));
  1191. }
  1192. function select_mul(level, id, url, name, value, valid, w, num)
  1193. {
  1194. if(level == 0)
  1195. {
  1196. $(id).find('select').remove();
  1197. $(id).find('span').remove();
  1198. return;
  1199. }
  1200. var parent = value.split(',');
  1201. var cur = parent[0];
  1202. parent.remove(cur);
  1203. value = parent.join(',');
  1204. var html = '';
  1205. var old = level;
  1206. if(level != -1)
  1207. {
  1208. if($(id + '_' + level).length)
  1209. {
  1210. level = $(id + '_' + level).val();
  1211. }
  1212. if(level == 0)
  1213. {
  1214. $(id + '_' + old).nextAll('select').remove();
  1215. $(id + '_' + old).next('span').nextAll('span').remove();
  1216. if($('#' + name + '_level_value').length)
  1217. {
  1218. var total = $(id).find('select').length;
  1219. $('#' + name + '_level_value').val(total);
  1220. }
  1221. if(old == -2 && $('#' + name + '_value_value').length)
  1222. {
  1223. $('#' + name + '_value_value').val(level);
  1224. }
  1225. return;
  1226. }
  1227. if(old == -2)
  1228. {
  1229. $(id + '_' + old).nextAll('select').remove();
  1230. $(id + '_' + old).next('span').nextAll('span').remove();
  1231. }
  1232. if($('#' + name + '_value_value').length)
  1233. {
  1234. $('#' + name + '_value_value').val(level);
  1235. }
  1236. }
  1237. var total = $(id).find('select').length;
  1238. if(num > 0 && total >= num)
  1239. {
  1240. return;
  1241. }
  1242. var get = url.replace('{level}', level);
  1243. if(level == -1)
  1244. {
  1245. level = -2;
  1246. }
  1247. if(!$(id + '_' + level).length)
  1248. {
  1249. $.getJSON(get + '&json=1', function(t)
  1250. {
  1251. var check = '';
  1252. if(!t.status)
  1253. {
  1254. html = '<select style="'+w+'display:inline;margin-top:10px;" class="update_value form-control '+valid+' dever-mul-'+name+'_'+level+'" name="'+name+'[]" onchange="select_mul('+level+', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+num+');">';
  1255. for(a in t.data)
  1256. {
  1257. if(t.data[a].value)
  1258. {
  1259. check = '';
  1260. if(cur == t.data[a].value)
  1261. {
  1262. check = ' selected';
  1263. }
  1264. html += '<option value="'+t.data[a].value+'" '+check+'>'+t.data[a].name+'</option>';
  1265. }
  1266. }
  1267. html += '</select><span>&nbsp;&nbsp;</span>';
  1268. $(id).append(html);
  1269. $(id + '_' + level).change();
  1270. }
  1271. else
  1272. {
  1273. $(id + '_' + old).nextAll('select').remove();
  1274. $(id + '_' + old).next('span').nextAll('span').remove();
  1275. }
  1276. if($('#' + name + '_level_value').length)
  1277. {
  1278. var total = $(id).find('select').length;
  1279. $('#' + name + '_level_value').val(total);
  1280. }
  1281. if($('#' + name + '_up_value').length)
  1282. {
  1283. $('#' + name + '_up_value').val($(id + '_-2').val());
  1284. }
  1285. });
  1286. }
  1287. }
  1288. //处理更新页面的一些功能,写到一起吧
  1289. var dever_update =
  1290. {
  1291. addIndex : 2,
  1292. index : [],
  1293. auto : false,
  1294. save_key : '',
  1295. init : function()
  1296. {
  1297. var self = this;
  1298. // 增加整个更新的表单
  1299. if($(".dever_update_add").length)
  1300. {
  1301. $('.dever_update_add').unbind('click').bind('click', function()
  1302. {
  1303. self.add($(this));
  1304. })
  1305. }
  1306. /* 以后再增加 同时更新另外一个表
  1307. if($(".form-add-content").length)
  1308. {
  1309. var url = config.host + 'auth.password';
  1310. var url = 'http://localhost/dever/manage/?database.update?project=weixin&table=message&menu=weixin&menu_id=39&ajax=1';
  1311. $.get(url, function(t)
  1312. {
  1313. $(".form-add-content").html(t);
  1314. init();
  1315. })
  1316. }
  1317. */
  1318. //增加某一部分表单
  1319. if($(".dever_form_add").length)
  1320. {
  1321. $('.dever_form_add').each(function()
  1322. {
  1323. var key = $.attr('toggle_key');
  1324. if(typeof(self.index[key]) == "undefined")
  1325. {
  1326. self.index[key] = 0;
  1327. }
  1328. $(this).unbind('click').bind('click', function()
  1329. {
  1330. self.append($(this));
  1331. })
  1332. })
  1333. self.del();
  1334. }
  1335. // 开启自动保存
  1336. if($("#struct").length)
  1337. {
  1338. var save = $("#struct").attr('save');
  1339. if(save == 'yes')
  1340. {
  1341. //检测
  1342. self.save_key = location.href + 'test';
  1343. self.check();
  1344. }
  1345. }
  1346. if($('.dever-note').length)
  1347. {
  1348. $('.dever-note').each(function()
  1349. {
  1350. var mditor = new Mditor($(this),{
  1351. fixedHeight:true
  1352. });
  1353. mditor.openPreview();
  1354. })
  1355. }
  1356. },
  1357. save : function()
  1358. {
  1359. //var data = $("#data-1").html();
  1360. var data = [];
  1361. $(".update_value").each(function(i)
  1362. {
  1363. if($(this).attr("update_type") == 'checked')
  1364. {
  1365. data[i] = $(this).get(0).checked;
  1366. }
  1367. else if($(this).attr("update_type") == 'html')
  1368. {
  1369. data[i] = $(this).html();
  1370. }
  1371. else if($(this).attr("update_type") == 'src')
  1372. {
  1373. data[i] = $(this).attr('src');
  1374. }
  1375. else
  1376. {
  1377. data[i] = $(this).val();
  1378. }
  1379. });
  1380. store.set(this.save_key, data.join('|||'));
  1381. //console.info(data);
  1382. },
  1383. recover : function()
  1384. {
  1385. if(confirm('确定恢复上次保存的数据吗?'))
  1386. {
  1387. var data = store.get(this.save_key).split('|||');
  1388. if(data)
  1389. {
  1390. var value = $(".update_value");
  1391. for(var k in data)
  1392. {
  1393. var e = value.eq(k);
  1394. if(e.attr('update_type') == 'checked')
  1395. {
  1396. if(data[k] == 'true')
  1397. {
  1398. e.get(0).checked = true;
  1399. }
  1400. else
  1401. {
  1402. e.get(0).checked = false;
  1403. }
  1404. }
  1405. else if(e.attr('update_type') == 'html')
  1406. {
  1407. e.html(data[k]);
  1408. }
  1409. else if(e.attr('update_type') == 'src')
  1410. {
  1411. e.attr('src', data[k]);
  1412. }
  1413. else
  1414. {
  1415. if(e.attr('id'))
  1416. {
  1417. var id = e.attr('id');
  1418. if(typeof(editors[id]) != "undefined")
  1419. {
  1420. editors[id].setContent(data[k]);
  1421. }
  1422. }
  1423. e.val(data[k]);
  1424. }
  1425. }
  1426. store.set(this.save_key, '');
  1427. this.check();
  1428. }
  1429. }
  1430. },
  1431. check : function()
  1432. {
  1433. var data = store.get(this.save_key);
  1434. var self = this;
  1435. if(data)
  1436. {
  1437. $(".dever_save").unbind('click').bind('click', function()
  1438. {
  1439. self.recover();
  1440. }).show();
  1441. }
  1442. else
  1443. {
  1444. $(".dever_save").hide();
  1445. self.auto = setInterval(function(){self.save()}, 3000);
  1446. }
  1447. },
  1448. del : function()
  1449. {
  1450. var self = this;
  1451. if($(".dever_form_delete").length)
  1452. {
  1453. $('.dever_form_delete').each(function()
  1454. {
  1455. $(this).unbind('click').bind('click', function()
  1456. {
  1457. var parent = $(this).parent();
  1458. var id = parent.attr('id');
  1459. var index = parseInt($('#tab-' + id).attr('toggle_id'));
  1460. var key = $('#tab-' + id).attr('toggle_key');
  1461. if(index <= 1 && self.index[key] <= index)
  1462. {
  1463. }
  1464. else if(index <= 1 && self.index[key] > index)
  1465. {
  1466. index = index+1;
  1467. $("#tab-"+key+"-child-" + index).click();
  1468. }
  1469. else
  1470. {
  1471. index = index-1;
  1472. $("#tab-"+key+"-child-" + index).click();
  1473. };
  1474. $('#tab-' + id).parent().remove();
  1475. parent.remove();
  1476. self.index[key]--;
  1477. })
  1478. })
  1479. }
  1480. },
  1481. append : function(e)
  1482. {
  1483. var self = this;
  1484. var key = e.attr('toggle_key');
  1485. var child = '.dever_'+key+'_child';
  1486. if(typeof(self.index[key]) == "undefined")
  1487. {
  1488. self.index[key] = 0;
  1489. }
  1490. if(self.index[key] <= 0)
  1491. {
  1492. self.index[key] = $(child).length;
  1493. }
  1494. if(self.index[key] > 30)
  1495. {
  1496. alert('最多只能增加30条');
  1497. return;
  1498. }
  1499. var p = e.parent();
  1500. var id = key + '-child-' + self.index[key];
  1501. var name = '第' + (self.index[key]) + '条';
  1502. p.before('<li><a href="javascript:;" id="tab-'+id+'" toggle_key="'+key+'" toggle_id="'+self.index[key]+'" toggle_child="'+child+'" toggle="#'+id+'" onclick="showToggle($(this))">'+name+'</a></li>');
  1503. var e = e.parent().parent();
  1504. var n = e.next();
  1505. var p = e.parent();
  1506. var content = n.html();
  1507. content = content.replaceAll('_c_', '_c_' + (self.index[key]-1) + '_i_');
  1508. content = '<div id="'+id+'" style="display:none;" class="'+n.attr('class')+' dever_form_add_child">' + content + '</div>';
  1509. p.append(content);
  1510. $('#update_' + key +'_c_' + (self.index[key]-1) + '_i_' + 'order_value').val(parseInt($('#update_' + key +'_c_' + (self.index[key]-2) + '_i_' + 'order_value').val())+1);
  1511. self.del();
  1512. //$("html,body").animate({scrollTop:$('.dever_form_add_child').eq(this.appendIndex).offset().top},500);
  1513. self.index[key]++;
  1514. image();
  1515. loadShow();
  1516. autocomplete();
  1517. change();
  1518. },
  1519. add : function(e)
  1520. {
  1521. var self = this;
  1522. var p = e.parent();
  1523. var id = 'data-' + this.addIndex;
  1524. var name = '新增数据-' + (this.addIndex-1);
  1525. p.before('<li><a href="#'+id+'" data-toggle="tab">'+name+'</a></li>');
  1526. var content = $("#myTabContent").find('.tab-pane').eq(0).html();
  1527. content = content.replaceAll('update_', 'update_' + this.addIndex + '__');
  1528. content = '<div class="tab-pane fade" id="'+id+'">' + content + '</div>';
  1529. $("#myTabContent").append(content);
  1530. $('#update_' + this.addIndex + '__where_id').val('-1');
  1531. this.addIndex++;
  1532. }
  1533. }
  1534. String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
  1535. if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
  1536. return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
  1537. } else {
  1538. return this.replace(reallyDo, replaceWith);
  1539. }
  1540. }
  1541. Array.prototype.remove = function(val) {
  1542. var index = -1;
  1543. for(var i = 0; i < this.length; i++)
  1544. {
  1545. if(this[i] == val)
  1546. {
  1547. index = i;
  1548. }
  1549. }
  1550. if (index > -1) {
  1551. this.splice(index, 1);
  1552. }
  1553. };
  1554. $.fn.pasteEvents = function( delay ) {
  1555. if (delay == undefined) delay = 20;
  1556. return $(this).each(function() {
  1557. var $el = $(this);
  1558. $el.on("paste", function() {
  1559. $el.trigger("prepaste");
  1560. setTimeout(function() { $el.trigger("postpaste"); }, delay);
  1561. });
  1562. });
  1563. };
  1564. $("textarea").on("postpaste", function()
  1565. {
  1566. if($(this).val().indexOf('<') != -1)
  1567. {
  1568. $(this).val(toMarkdown($(this).val()));
  1569. }
  1570. }).pasteEvents();