The version of vichan running on lainchan.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.5KB

  1. if (active_page === "thread" || active_page === "index" || active_page === "ukko") {
  2. $(document).on("ready", function() {
  3. if (window.Options && Options.get_tab('general')) {
  4. Options.extend_tab("general",
  5. "<fieldset><legend>Editor Dialog </legend>"
  6. + ("<label class='sceditorc' id='sceditor'><input type='checkbox' /> Enable SCEditor WYSIWYG Editor</label>")
  7. + "</fieldset>");
  8. }
  9. $('.sceditorc').on('change', function(){
  10. var setting = $(this).attr('id');
  11. localStorage[setting] = $(this).children('input').is(':checked');
  12. location.reload();
  13. });
  14. if (!localStorage.sceditor) {
  15. localStorage.sceditor = 'false';
  16. }
  17. function getSetting(key) {
  18. return (localStorage[key] == 'true');
  19. }
  20. if (getSetting('sceditor')) $('#sceditor>input').prop('checked', 'checked');
  21. function initsceditor() {
  22. if (!getSetting("sceditor")) {return;}
  23. $('.format-text').toggle();
  24. $.sceditor.plugins.bbcode.bbcode.set('spoiler', {
  25. tags: {
  26. 'span': {
  27. 'class': ['spoiler']
  28. }
  29. },
  30. format: '[spoiler]{0}[/spoiler]',
  31. html: '<span class="spoiler">{0}</span>'
  32. });
  33. $.sceditor.plugins.bbcode.bbcode.set('t', {
  34. tags: {
  35. 'span': {
  36. 'class': ['heading']
  37. }
  38. },
  39. format: '\t=={0}==\t',
  40. html: '<span class="heading">{0}</span>'
  41. });
  42. $.sceditor.command.set("spoiler", {
  43. exec: function() {
  44. this.insert("[spoiler]", "[/spoiler]");
  45. },
  46. txtExec: ["[spoiler]", "[/spoiler]"],
  47. tooltip: "Spoiler (CTRL+S)",
  48. });
  49. $.sceditor.command.set("t", {
  50. exec: function() {
  51. this.insert("\t==", "==\t");
  52. },
  53. txtExec: ["\t==", "==\t"],
  54. tooltip: "Heading (CTRL+T)",
  55. });
  56. $('#body').sceditor({
  57. plugins: 'bbcode',
  58. style: $('#stylesheet').attr("href"),
  59. //style: '/stylesheets/sceditor/jquery.sceditor.default.min.css',
  60. toolbar: "bold,italic,t,spoiler,code|source",
  61. emoticonsEnabled : false,
  62. autoUpdate : true,
  63. });
  64. var backgroundcolor = $('#body').css('background-color');
  65. $('.sceditor-container').css('background-color',backgroundcolor);
  66. $('.sceditor-toolbar').css('background-color',backgroundcolor);
  67. $('#body').sceditor('instance').css('body { background-color: ' + backgroundcolor +'; }');
  68. /*$(document).on('ajax_before_post', function (e, formData) {
  69. formData.set(body, $("#body").sceditor('instance').val());
  70. });
  71. $(document).on('ajax_after_post', function () {
  72. $("#body").sceditor('instance').val("");
  73. });*/
  74. }
  75. initsceditor();
  76. });
  77. }