GA special symbols

Добавляет к редактору панель с набором спец. символов.

  1. // ==UserScript==
  2. // @name GA special symbols
  3. // @namespace glav.su
  4. // @description Добавляет к редактору панель с набором спец. символов.
  5. // @include https://glav.su/forum/*
  6. // @version 1.2
  7. // @grant none
  8. // ==/UserScript==
  9. $(document).ready(function(){
  10. if(typeof $.sceditor == 'function' && $("div.sceditor-group").length > 0){
  11. function addStyle(styleText) {
  12. var style = document.createElement('style');
  13. if (document.head) {
  14. document.head.appendChild(style);
  15. style.innerHTML = styleText;
  16. }
  17. }
  18. addStyle([
  19. '.spec_symbol {',
  20. 'cursor: pointer;',
  21. 'display: inline-block;',
  22. 'border: 1px solid #eee;',
  23. 'padding: 5px;',
  24. 'background-color: #fff;',
  25. 'color: black;',
  26. 'font-size: 16px;',
  27. 'width: 16px;',
  28. 'height: 16px;',
  29. 'text-align: center;',
  30. 'text-indent: 0px;',
  31. 'vertical-align: middle;',
  32. 'line-height: 1;',
  33. '}',
  34. '.spec_symbol:hover {',
  35. 'background-color: #ddd;',
  36. '}',
  37. '.spec_button {',
  38. 'background-color: #eee;',
  39. 'background-clip: padding-box;',
  40. 'border: 1px solid #ccc;',
  41. 'border-radius: 0px;',
  42. 'cursor: pointer;',
  43. 'display: block;',
  44. 'float: left;',
  45. 'height: 24px;',
  46. 'margin: 0px 1px 0px 0px;',
  47. 'padding: 0;',
  48. 'text-decoration: none;',
  49. 'width: 24px;',
  50. '-moz-background-clip: padding;',
  51. '-moz-border-radius: 0px;',
  52. '-webkit-background-clip: padding-box;',
  53. '-webkit-border-radius: 0px;',
  54. '}',
  55. '.spec_button:hover {',
  56. 'background-color: #ccc;',
  57. 'text-decoration: none;',
  58. '}',
  59. ].join(''));
  60. var symbols = [
  61. {s: '©', d: 'Copyright'},{s: '®', d: 'Reserved'},{s: '™', d: 'Trade Mark'},{s: '€', d: 'Евро'},{s: '£', d: 'Фунт'},{s: '¥', d: 'Йена'},
  62. {s: '§', d: 'Параграф'},{s: '«', d: 'Кавычка «уголки»'},{s: '»', d: 'Кавычка «уголки»'},{s: '́', d: 'Ударение'},{s: '–', d: 'Тире En Dash'},{s: '—', d: 'Тире Em Dash'},
  63. {s: '¹', d: 'Первая степень'},{s: '²', d: 'Квадрат'},{s: '³', d: 'Куб'},{s: '·', d: 'Точка по центру'},{s: '•', d: 'Большая точка (bullet)'},{s: '…', d: 'Троеточие'},
  64. {s: '±', d: 'Плюс-минус'},{s: '≈', d: 'Примерно равно'},{s: '≠', d: 'Не равно'},{s: '≡', d: 'Тождественно равно'},{s: '≤', d: 'Меньше или равно'},{s: '≥', d: 'Больше или равно'},
  65. {s: '°', d: 'Градус'},{s: '√', d: 'Корень'},{s: '∫', d: 'Интеграл'},{s: 'µ', d: 'Мю'},{s: 'π', d: 'Пи'},{s: 'ω', d: 'Омега'},
  66. {s: '∑', d: 'Сумма'},{s: 'λ', d: 'Лямбда'},{s: '∆', d: 'Дельта'},{s: '∂', d: 'Дифференциал'},{s: '∞', d: 'Бесконечность'},{s: 'ε', d: 'Эпсилон'},
  67. {s: '¼', d: 'Четверть'},{s: '½', d: 'Одна вторая'},{s: '¾', d: 'Три четверти'},{s: '⅓', d: 'Одна треть'},{s: '⅔', d: 'Две трети'},{s: '⅛', d: 'Одна восьмая'},
  68. {s: '←', d: 'Стрелка влево'},{s: '↑', d: 'Стрелка вверх'},{s: '→', d: 'Стрелка вправо'},{s: '↓', d: 'Стрелка вниз'},{s: '↔', d: 'Стрелка влево-вправо'},{s: '↕', d: 'Стрелка вверх-вниз'},
  69. ];
  70. var $symbols_box = $('<div id="symbols_box" style="cursor: pointer; display: none; border: 1px solid #aaa; padding: 5px 2px; white-space: nowrap; border-radius: 5px; position: absolute; box-shadow: 3px 3px 10px #444; background-color: #fff; background-image: none; width: auto; height: auto;">')
  71. .mouseenter(function(){ $symbols_box.under_mouse = true; })
  72. .mouseleave(function(){ $symbols_box.under_mouse = false; });
  73. $symbols_box.under_mouse = false;
  74. $(document.body).click(function(){
  75. if(!$symbols_box.under_mouse){
  76. $symbols_box.hide();
  77. }
  78. });
  79. $('#messageBBCodeForm').find('textarea').sceditor('instance').focus(function(){
  80. $symbols_box.hide();
  81. });
  82. var $symbols_button = $('<a class="spec_button" title="Специальные символы">')
  83. .append($('<div>')
  84. .css({'background-image': "url(/files/messages/f2b0cbedeeafbe675883cd6a311c7c67.gif)",
  85. height: "24px", width: "24px", display: "block", })
  86. )
  87. .mouseenter(function(){ $symbols_box.under_mouse = true; })
  88. .mouseleave(function(){ $symbols_box.under_mouse = false; })
  89. .click(function(){
  90. $("#symbols_box").toggle();
  91. })
  92. .appendTo( $($("div.sceditor-group")[0]) );
  93. $symbols_box.appendTo( $($("div.sceditor-toolbar")[0]) );
  94. var i = 0;
  95. $("#symbols_box").append('<br />');
  96. $.each(symbols, function(sidx, sym){
  97. $('<span class="spec_symbol" title="'+sym.d+'">'+sym.s+'</span>')
  98. .click(function(){
  99. $('#messageBBCodeForm').find('textarea').sceditor('instance').insert(sym.s);
  100. $("#symbols_box").hide();
  101. })
  102. .appendTo($("#symbols_box"));
  103. if( ++i % 6 == 0 ) $("#symbols_box").append('<br />');
  104. });
  105. $('<a class="spec_button" title="Ударение">')
  106. .append($('<div>')
  107. .css({'background-image': "url(/files/messages/fcceb9e0d812176b96f1da874b41eb40.gif)",
  108. height: "24px", width: "24px", display: "block", })
  109. )
  110. .click(function(){
  111. $('#messageBBCodeForm').find('textarea').sceditor('instance').insert('́');
  112. })
  113. .appendTo( $($("div.sceditor-group")[0]) );
  114. $('<a class="spec_button" title="Тире">')
  115. .append($('<div>–</div>')
  116. .css({ 'text-indent': "0", color: "#000", 'text-align': "center", 'padding-top': "10px",
  117. height: "24px", width: "24px", display: "block", })
  118. )
  119. .click(function(){
  120. $('#messageBBCodeForm').find('textarea').sceditor('instance').insert('–');
  121. })
  122. .appendTo( $($("div.sceditor-group")[0]) );
  123. }
  124. });