Просмотр файла public/assets/js/markitup-set.js

Размер файла: 9.52Kb
  1. // ----------------------------------------------------------------------------
  2. // markItUp bb-code setting!
  3. // ----------------------------------------------------------------------------
  4. var currentLang = $('html').attr('lang');
  5. var translate = window['translate_' + currentLang];
  6.  
  7. mySettings = {
  8. previewParserPath: '/ajax/bbcode', // path to your BBCode parser
  9. previewAutoRefresh: false,
  10. onTab: {keepDefault: false, openWith: ' '},
  11. markupSet: [
  12. {title: translate.editor.bold, name: '<i class="fa fa-bold"></i>', className: 'bb-bold', key: 'B', openWith: '[b]', closeWith: '[/b]'},
  13. {title: translate.editor.italic, name: '<i class="fa fa-italic"></i>', className: 'bb-italic', key: 'I', openWith: '[i]', closeWith: '[/i]'},
  14. {title: translate.editor.underline, name: '<i class="fa fa-underline"></i>', className: 'bb-underline', key: 'U', openWith: '[u]', closeWith: '[/u]'},
  15. {title: translate.editor.strike, name: '<i class="fa fa-strikethrough"></i>', className: 'bb-strike', key: 'S', openWith: '[s]', closeWith: '[/s]'},
  16.  
  17. {separator: '---------------'},
  18. {title: translate.editor.link, name: '<i class="fa fa-link"></i>', className: 'bb-link', key: 'L', openWith: '[url=[![' + translate.editor.link + ':!:http://]!]]', closeWith: '[/url]', placeHolder: translate.editor.link_text},
  19.  
  20. {title: translate.editor.image, name: '<i class="fa fa-image"></i>', className: 'bb-image', openWith: '[img][![' + translate.editor.image_text + ':!:http://]!]', closeWith: '[/img]'},
  21.  
  22. {title: translate.editor.video, name: '<i class="fab fa-youtube"></i>', className: 'bb-youtube', openWith: '[youtube][![' + translate.editor.video_link + ']!]', closeWith: '[/youtube]'},
  23. {title: translate.editor.color, name: '<i class="fa fa-th"></i>', className: 'bb-color', openWith: '[color=[![' + translate.editor.color_code + ']!]]', closeWith: '[/color]',
  24. dropMenu: [
  25. {name: 'Yellow', openWith: '[color=#ffd700]', closeWith: '[/color]', className: 'col1-1'},
  26. {name: 'Orange', openWith: '[color=#ffa500]', closeWith: '[/color]', className: 'col1-2'},
  27. {name: 'Red', openWith: '[color=#ff0000]', closeWith: '[/color]', className: 'col1-3'},
  28.  
  29. {name: 'Blue', openWith: '[color=#0000ff]', closeWith: '[/color]', className: 'col2-1'},
  30. {name: 'Purple', openWith: '[color=#800080]', closeWith: '[/color]', className: 'col2-2'},
  31. {name: 'Green', openWith: '[color=#00cc00]', closeWith: '[/color]', className: 'col2-3'},
  32.  
  33. {name: 'Magenta', openWith: '[color=#ff00ff]', closeWith: '[/color]', className: 'col3-1'},
  34. {name: 'Gray', openWith: '[color=#808080]', closeWith: '[/color]', className: 'col3-2'},
  35. {name: 'Cyan', openWith: '[color=#00ffff]', closeWith: '[/color]', className: 'col3-3'}
  36. ]},
  37.  
  38. {separator: '---------------'},
  39. {title: translate.editor.font_size, name: '<i class="fa fa-font"></i>', className: 'bb-size', openWith: '[size=[![' + translate.editor.font_text + ']!]]', closeWith: '[/size]',
  40. dropMenu :[
  41. {name: 'x-small', openWith: '[size=1]', closeWith: '[/size]'},
  42. {name: 'small', openWith: '[size=2]', closeWith: '[/size]'},
  43. {name: 'medium', openWith: '[size=3]', closeWith: '[/size]'},
  44. {name: 'large', openWith: '[size=4]', closeWith: '[/size]'},
  45. {name: 'x-large', openWith: '[size=5]', closeWith: '[/size]'}
  46. ]},
  47.  
  48. {title: translate.editor.center, name: '<i class="fa fa-align-center"></i>', className: 'bb-center', openWith: '[center]', closeWith: '[/center]'},
  49. {title: translate.editor.spoiler, name: '<i class="fa fa-plus-square"></i>', className: 'bb-spoiler', openWith: '[spoiler=[![' + translate.editor.spoiler_title + ']!]]', closeWith: '[/spoiler]', placeHolder: translate.editor.spoiler_text},
  50. {
  51. title: translate.editor.sticker,
  52. name: '<i class="fa fa-smile"></i>',
  53. className: 'bb-sticker',
  54. beforeInsert: function () {
  55. const stikerModal = $('#stickersModal');
  56.  
  57. if (stikerModal.length) {
  58. stikerModal.modal('show');
  59.  
  60. return false;
  61. }
  62.  
  63. $.ajax({
  64. dataType: 'json', type: 'get', url: '/ajax/getstickers',
  65. success: function (data) {
  66. if (data.success) {
  67. $('body').append(data.stickers);
  68. }
  69.  
  70. $('#stickersModal').modal('show')
  71. }
  72. });
  73. }
  74. },
  75.  
  76. {separator: '---------------'},
  77. {title: translate.editor.hide, name: '<i class="fa fa-eye-slash"></i>', className: 'bb-hide', openWith: '[hide]', closeWith: '[/hide]'},
  78. {title: translate.editor.quote, name: '<i class="fa fa-quote-right"></i>', className: 'bb-quote', openWith: '[quote]', closeWith: '[/quote]'},
  79. {title: translate.editor.code, name: '<i class="fa fa-code"></i>', className: 'bb-code', openWith: '[code]', closeWith: '[/code]'},
  80.  
  81. {separator: '---------------'},
  82. {title: translate.editor.unorderedlist, name: '<i class="fa fa-list-ul"></i>', className: 'bb-unorderedlist', multiline:true, openBlockWith: '[list]\n', closeBlockWith: '\n[/list]', placeHolder: translate.editor.list_text},
  83. {title: translate.editor.orderedlist, name: '<i class="fa fa-list-ol"></i>', className: 'bb-orderedlist', multiline:true, openBlockWith: '[list=1]\n', closeBlockWith: '\n[/list]', placeHolder: translate.editor.list_text},
  84.  
  85. {separator: '---------------'},
  86. {title: translate.editor.clean, name: '<i class="fa fa-eraser"></i>', className: 'bb-clean', replaceWith:function(markitup) { return markitup.selection.replace(/\[(.*?)\]/g, "") } },
  87. {title: translate.editor.cutpage, name: '<i class="fa fa-cut"></i>', className: 'bb-cutpage', openWith: '[cut]'},
  88. {title: translate.editor.preview, name: '<i class="fa fa-check-square"></i>', classname: 'bb-preview', call: 'preview'}
  89. ]
  90. };
  91.  
  92. // ----------------------------------------------------------------------------
  93. // markItUp Html setting!
  94. // ----------------------------------------------------------------------------
  95. myHtmlSettings = {
  96. onCtrlEnter: {keepDefault: false, replaceWith: '<br />\r'},
  97. onTab: {keepDefault: false, openWith: ' '},
  98. markupSet: [
  99. {title: 'Div', name: '<i class="fa fa-list-alt"></i>', className: 'bb-div', openWith: '<div(!( class="[![Class]!]")!)>', closeWith: '</div>\n'},
  100. {title: 'Span', name: '<i class="fa fa-columns"></i>', className: 'bb-span', openWith: '<span(!( class="[![Class]!]")!)>', closeWith: '</span>\n'},
  101. {title: 'Paragraph', name: '<i class="fa fa-paragraph"></i>', className: 'bb-paragraph', openWith: '<p(!( class="[![Class]!]")!)>', closeWith: '</p>\n'},
  102. {title: 'Paragraph', name: '<i class="fa fa-table"></i>', className: 'bb-table', openWith: '<table(!( class="[![Class]!]")!)>\n <tr>\n <td>', closeWith: '</td>\n </tr>\n</table>'},
  103. {separator: '---------------'},
  104. {title: 'Heading 1', name: '<i class="fa fa-heading">1</i>', className: 'bb-heading1', key: '1', openWith: '<h1(!( class="[![Class]!]")!)>', closeWith: '</h1>', placeHolder: translate.editor.enter_title},
  105. {title: 'Heading 2', name: '<i class="fa fa-heading">2</i>', className: 'bb-heading2', key: '2', openWith: '<h2(!( class="[![Class]!]")!)>', closeWith: '</h2>', placeHolder: translate.editor.enter_title},
  106. {title: 'Heading 3', name: '<i class="fa fa-heading">3</i>', className: 'bb-heading3', key: '3', openWith: '<h3(!( class="[![Class]!]")!)>', closeWith: '</h3>', placeHolder: translate.editor.enter_title},
  107. {separator: '---------------'},
  108. {title: translate.editor.bold, name: '<i class="fa fa-bold"></i>', className: 'bb-bold', key: 'B', openWith: '(!(<strong>|!|<b>)!)', closeWith: '(!(</strong>|!|</b>)!)'},
  109. {title: translate.editor.italic, name: '<i class="fa fa-italic"></i>', className: 'bb-italic', key: 'I', openWith: '(!(<em>|!|<i>)!)', closeWith: '(!(</em>|!|</i>)!)'},
  110. {title: translate.editor.underline, name: '<i class="fa fa-underline"></i>', className: 'bb-underline', key: 'U', openWith: '<u>', closeWith: '</u>'},
  111. {title: translate.editor.strike, name: '<i class="fa fa-strikethrough"></i>', className: 'bb-strike', key: 'S', openWith: '<del>', closeWith: '</del>'},
  112. {separator: '---------------'},
  113. {title: 'Ul', name: '<i class="fa fa-list-ul"></i>', className: 'bb-ul', openWith: '<ul>\n', closeWith: '</ul>\n'},
  114. {title: 'Ol', name: '<i class="fa fa-list-ol"></i>', className: 'bb-ol', openWith: '<ol>\n', closeWith: '</ol>\n'},
  115. {title: 'Li', name: '<i class="fa fa-minus"></i>', className: 'bb-li', openWith: '<li>', closeWith: '</li>'},
  116. {separator: '---------------'},
  117. {title: translate.editor.image, name: '<i class="fa fa-image"></i>', className: 'bb-picture', key: 'P', replaceWith: '<img src="[![' + translate.editor.image_text + ':!:http://]!]" alt="[![' + translate.editor.alt + ']!]" />'},
  118. {title: translate.editor.link, name: '<i class="fa fa-link"></i>', className: 'bb-link', key: 'L', openWith: '<a href="[![' + translate.editor.link + ':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith: '</a>', placeHolder: translate.editor.link_text},
  119. {separator: '---------------'},
  120. {title: translate.editor.clean, name: '<i class="fa fa-eraser"></i>', classname: 'bb-clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }
  121. ]
  122. };