activeadmin_trumbowyg 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.md +60 -0
  6. data/Rakefile +3 -0
  7. data/activeadmin_trumbowyg.gemspec +19 -0
  8. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ar.min.js +11 -0
  9. data/app/assets/javascripts/activeadmin/trumbowyg/langs/bg.min.js +8 -0
  10. data/app/assets/javascripts/activeadmin/trumbowyg/langs/by.min.js +8 -0
  11. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ca.min.js +11 -0
  12. data/app/assets/javascripts/activeadmin/trumbowyg/langs/cs.min.js +8 -0
  13. data/app/assets/javascripts/activeadmin/trumbowyg/langs/da.min.js +9 -0
  14. data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.min.js +9 -0
  15. data/app/assets/javascripts/activeadmin/trumbowyg/langs/el.min.js +12 -0
  16. data/app/assets/javascripts/activeadmin/trumbowyg/langs/es.min.js +9 -0
  17. data/app/assets/javascripts/activeadmin/trumbowyg/langs/es_ar.min.js +10 -0
  18. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fa.min.js +10 -0
  19. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fi.min.js +9 -0
  20. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fr.min.js +10 -0
  21. data/app/assets/javascripts/activeadmin/trumbowyg/langs/he.min.js +9 -0
  22. data/app/assets/javascripts/activeadmin/trumbowyg/langs/hr.min.js +9 -0
  23. data/app/assets/javascripts/activeadmin/trumbowyg/langs/hu.min.js +10 -0
  24. data/app/assets/javascripts/activeadmin/trumbowyg/langs/id.min.js +11 -0
  25. data/app/assets/javascripts/activeadmin/trumbowyg/langs/it.min.js +8 -0
  26. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ja.min.js +10 -0
  27. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ko.min.js +10 -0
  28. data/app/assets/javascripts/activeadmin/trumbowyg/langs/mn.min.js +8 -0
  29. data/app/assets/javascripts/activeadmin/trumbowyg/langs/my.min.js +8 -0
  30. data/app/assets/javascripts/activeadmin/trumbowyg/langs/nl.min.js +9 -0
  31. data/app/assets/javascripts/activeadmin/trumbowyg/langs/no_nb.min.js +10 -0
  32. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ph.min.js +8 -0
  33. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pl.min.js +9 -0
  34. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt.min.js +11 -0
  35. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt_br.min.js +11 -0
  36. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ro.min.js +12 -0
  37. data/app/assets/javascripts/activeadmin/trumbowyg/langs/rs.min.js +8 -0
  38. data/app/assets/javascripts/activeadmin/trumbowyg/langs/rs_latin.min.js +9 -0
  39. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ru.min.js +8 -0
  40. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sk.min.js +8 -0
  41. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sv.min.js +12 -0
  42. data/app/assets/javascripts/activeadmin/trumbowyg/langs/tr.min.js +9 -0
  43. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ua.min.js +8 -0
  44. data/app/assets/javascripts/activeadmin/trumbowyg/langs/vi.min.js +9 -0
  45. data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_cn.min.js +11 -0
  46. data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_tw.min.js +11 -0
  47. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +121 -0
  48. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +1 -0
  49. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +179 -0
  50. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +1 -0
  51. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +176 -0
  52. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +1 -0
  53. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +49 -0
  54. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +43 -0
  55. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +2 -0
  56. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +965 -0
  57. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +1 -0
  58. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +56 -0
  59. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +47 -0
  60. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +2 -0
  61. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +83 -0
  62. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +1 -0
  63. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +101 -0
  64. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +1 -0
  65. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +41 -0
  66. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +1 -0
  67. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +123 -0
  68. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +1 -0
  69. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +154 -0
  70. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +1 -0
  71. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +58 -0
  72. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +1 -0
  73. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +242 -0
  74. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +1 -0
  75. data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.js +1688 -0
  76. data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.min.js +2 -0
  77. data/app/assets/javascripts/activeadmin/trumbowyg/ui/icons.svg +1 -0
  78. data/app/assets/javascripts/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +796 -0
  79. data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.css +584 -0
  80. data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.min.css +2 -0
  81. data/app/assets/javascripts/activeadmin/trumbowyg_input.js +7 -0
  82. data/app/assets/stylesheets/activeadmin/_trumbowyg_input.sass +48 -0
  83. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ar.min.js +11 -0
  84. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/bg.min.js +8 -0
  85. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/by.min.js +8 -0
  86. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ca.min.js +11 -0
  87. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/cs.min.js +8 -0
  88. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/da.min.js +9 -0
  89. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/de.min.js +9 -0
  90. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/el.min.js +12 -0
  91. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es.min.js +9 -0
  92. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es_ar.min.js +10 -0
  93. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fa.min.js +10 -0
  94. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fi.min.js +9 -0
  95. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fr.min.js +10 -0
  96. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/he.min.js +9 -0
  97. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hr.min.js +9 -0
  98. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hu.min.js +10 -0
  99. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/id.min.js +11 -0
  100. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/it.min.js +8 -0
  101. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ja.min.js +10 -0
  102. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ko.min.js +10 -0
  103. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/mn.min.js +8 -0
  104. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/my.min.js +8 -0
  105. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/nl.min.js +9 -0
  106. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/no_nb.min.js +10 -0
  107. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ph.min.js +8 -0
  108. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pl.min.js +9 -0
  109. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt.min.js +11 -0
  110. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt_br.min.js +11 -0
  111. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ro.min.js +12 -0
  112. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs.min.js +8 -0
  113. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs_latin.min.js +9 -0
  114. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ru.min.js +8 -0
  115. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sk.min.js +8 -0
  116. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sv.min.js +12 -0
  117. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/tr.min.js +9 -0
  118. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ua.min.js +8 -0
  119. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/vi.min.js +9 -0
  120. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_cn.min.js +11 -0
  121. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_tw.min.js +11 -0
  122. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +121 -0
  123. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +1 -0
  124. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +179 -0
  125. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +1 -0
  126. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +176 -0
  127. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +1 -0
  128. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +49 -0
  129. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +43 -0
  130. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +2 -0
  131. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +965 -0
  132. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +1 -0
  133. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +56 -0
  134. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +47 -0
  135. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +2 -0
  136. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +83 -0
  137. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +1 -0
  138. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +101 -0
  139. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +1 -0
  140. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +41 -0
  141. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +1 -0
  142. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +123 -0
  143. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +1 -0
  144. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +154 -0
  145. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +1 -0
  146. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +58 -0
  147. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +1 -0
  148. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +242 -0
  149. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +1 -0
  150. data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.js +1688 -0
  151. data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.min.js +2 -0
  152. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/icons.svg +1 -0
  153. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +796 -0
  154. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.css +584 -0
  155. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.min.css +2 -0
  156. data/lib/activeadmin/trumbowyg/engine.rb +9 -0
  157. data/lib/activeadmin/trumbowyg/version.rb +5 -0
  158. data/lib/activeadmin/trumbowyg.rb +1 -0
  159. data/lib/activeadmin_trumbowyg.rb +3 -0
  160. data/lib/formtastic/inputs/trumbowyg_input.rb +12 -0
  161. data/screenshot.jpg +0 -0
  162. metadata +217 -0
@@ -0,0 +1,121 @@
1
+ /* ===========================================================
2
+ * trumbowyg.base64.js v1.0
3
+ * Base64 plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Cyril Biencourt (lizardK)
7
+ */
8
+
9
+ (function ($) {
10
+ 'use strict';
11
+
12
+ var isSupported = function () {
13
+ return typeof FileReader !== 'undefined';
14
+ };
15
+
16
+ var isValidImage = function (type) {
17
+ return /^data:image\/[a-z]?/i.test(type);
18
+ };
19
+
20
+ $.extend(true, $.trumbowyg, {
21
+ langs: {
22
+ // jshint camelcase:false
23
+ en: {
24
+ base64: 'Image as base64',
25
+ file: 'File',
26
+ errFileReaderNotSupported: 'FileReader is not supported by your browser.',
27
+ errInvalidImage: 'Invalid image file.'
28
+ },
29
+ fr: {
30
+ base64: 'Image en base64',
31
+ file: 'Fichier'
32
+ },
33
+ cs: {
34
+ base64: 'Vložit obrázek',
35
+ file: 'Soubor'
36
+ },
37
+ zh_cn: {
38
+ base64: '图片(Base64编码)',
39
+ file: '文件'
40
+ },
41
+ nl: {
42
+ errFileReaderNotSupported: 'Uw browser ondersteunt deze functionaliteit niet.',
43
+ errInvalidImage: 'De gekozen afbeelding is ongeldig.'
44
+ },
45
+ ru: {
46
+ base64: 'Изображение как код в base64',
47
+ file: 'Файл',
48
+ errFileReaderNotSupported: 'FileReader не поддерживается вашим браузером.',
49
+ errInvalidImage: 'Недопустимый файл изображения.'
50
+ },
51
+ ja: {
52
+ base64: '画像 (Base64形式)',
53
+ file: 'ファイル',
54
+ errFileReaderNotSupported: 'あなたのブラウザーはFileReaderをサポートしていません',
55
+ errInvalidImage: '画像形式が正しくありません'
56
+ }
57
+ },
58
+ // jshint camelcase:true
59
+
60
+ plugins: {
61
+ base64: {
62
+ shouldInit: isSupported,
63
+ init: function (trumbowyg) {
64
+ var btnDef = {
65
+ isSupported: isSupported,
66
+ fn: function () {
67
+ trumbowyg.saveRange();
68
+
69
+ var file;
70
+ var $modal = trumbowyg.openModalInsert(
71
+ // Title
72
+ trumbowyg.lang.base64,
73
+
74
+ // Fields
75
+ {
76
+ file: {
77
+ type: 'file',
78
+ required: true,
79
+ attributes: {
80
+ accept: 'image/*'
81
+ }
82
+ },
83
+ alt: {
84
+ label: 'description',
85
+ value: trumbowyg.getRangeText()
86
+ }
87
+ },
88
+
89
+ // Callback
90
+ function (values) {
91
+ var fReader = new FileReader();
92
+
93
+ fReader.onloadend = function (e) {
94
+ if (isValidImage(e.target.result)) {
95
+ trumbowyg.execCmd('insertImage', fReader.result);
96
+ $(['img[src="', fReader.result, '"]:not([alt])'].join(''), trumbowyg.$box).attr('alt', values.alt);
97
+ trumbowyg.closeModal();
98
+ } else {
99
+ trumbowyg.addErrorOnModalField(
100
+ $('input[type=file]', $modal),
101
+ trumbowyg.lang.errInvalidImage
102
+ );
103
+ }
104
+ };
105
+
106
+ fReader.readAsDataURL(file);
107
+ }
108
+ );
109
+
110
+ $('input[type=file]').on('change', function (e) {
111
+ file = e.target.files[0];
112
+ });
113
+ }
114
+ };
115
+
116
+ trumbowyg.addBtnDef('base64', btnDef);
117
+ }
118
+ }
119
+ }
120
+ });
121
+ })(jQuery);
@@ -0,0 +1 @@
1
+ !function(e){"use strict";var a=function(){return"undefined"!=typeof FileReader},r=function(e){return/^data:image\/[a-z]?/i.test(e)};e.extend(!0,e.trumbowyg,{langs:{en:{base64:"Image as base64",file:"File",errFileReaderNotSupported:"FileReader is not supported by your browser.",errInvalidImage:"Invalid image file."},fr:{base64:"Image en base64",file:"Fichier"},cs:{base64:"Vložit obrázek",file:"Soubor"},zh_cn:{base64:"图片(Base64编码)",file:"文件"},nl:{errFileReaderNotSupported:"Uw browser ondersteunt deze functionaliteit niet.",errInvalidImage:"De gekozen afbeelding is ongeldig."},ru:{base64:"Изображение как код в base64",file:"Файл",errFileReaderNotSupported:"FileReader не поддерживается вашим браузером.",errInvalidImage:"Недопустимый файл изображения."},ja:{base64:"画像 (Base64形式)",file:"ファイル",errFileReaderNotSupported:"あなたのブラウザーはFileReaderをサポートしていません",errInvalidImage:"画像形式が正しくありません"}},plugins:{base64:{shouldInit:a,init:function(i){var t={isSupported:a,fn:function(){i.saveRange();var a,t=i.openModalInsert(i.lang.base64,{file:{type:"file",required:!0,attributes:{accept:"image/*"}},alt:{label:"description",value:i.getRangeText()}},function(n){var l=new FileReader;l.onloadend=function(a){r(a.target.result)?(i.execCmd("insertImage",l.result),e(['img[src="',l.result,'"]:not([alt])'].join(""),i.$box).attr("alt",n.alt),i.closeModal()):i.addErrorOnModalField(e("input[type=file]",t),i.lang.errInvalidImage)},l.readAsDataURL(a)});e("input[type=file]").on("change",function(e){a=e.target.files[0]})}};i.addBtnDef("base64",t)}}}})}(jQuery);
@@ -0,0 +1,179 @@
1
+ /* ===========================================================
2
+ * trumbowyg.cleanpaste.js v1.0
3
+ * Font Clean paste plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Eric Radin
7
+ */
8
+
9
+ /**
10
+ * This plugin will perform a "cleaning" on any paste, in particular
11
+ * it will clean pasted content of microsoft word document tags and classes.
12
+ */
13
+ (function ($) {
14
+ 'use strict';
15
+
16
+ function reverse(sentString) {
17
+ var theString = '';
18
+ for (var i = sentString.length - 1; i >= 0; i -= 1) {
19
+ theString += sentString.charAt(i);
20
+ }
21
+ return theString;
22
+ }
23
+
24
+ function checkValidTags(snippet) {
25
+ var theString = snippet;
26
+
27
+ // Replace uppercase element names with lowercase
28
+ theString = theString.replace(/<[^> ]*/g, function (match) {
29
+ return match.toLowerCase();
30
+ });
31
+
32
+ // Replace uppercase attribute names with lowercase
33
+ theString = theString.replace(/<[^>]*>/g, function (match) {
34
+ match = match.replace(/ [^=]+=/g, function (match2) {
35
+ return match2.toLowerCase();
36
+ });
37
+ return match;
38
+ });
39
+
40
+ // Put quotes around unquoted attributes
41
+ theString = theString.replace(/<[^>]*>/g, function (match) {
42
+ match = match.replace(/( [^=]+=)([^"][^ >]*)/g, '$1\"$2\"');
43
+ return match;
44
+ });
45
+
46
+ return theString;
47
+ }
48
+
49
+ function cleanIt(htmlBefore, htmlAfter) {
50
+ var matchedHead = '';
51
+ var matchedTail = '';
52
+ var afterStart;
53
+ var afterFinish;
54
+ var newSnippet;
55
+
56
+ // we need to extract the inserted block
57
+ for (afterStart = 0; htmlAfter.charAt(afterStart) === htmlBefore.charAt(afterStart); afterStart += 1) {
58
+ matchedHead += htmlAfter.charAt(afterStart);
59
+ }
60
+
61
+ // If afterStart is inside a HTML tag, move to opening brace of tag
62
+ for (var i = afterStart; i >= 0; i -= 1) {
63
+ if (htmlBefore.charAt(i) === '<') {
64
+ afterStart = i;
65
+ matchedHead = htmlBefore.substring(0, afterStart);
66
+ break;
67
+ } else if (htmlBefore.charAt(i) === '>') {
68
+ break;
69
+ }
70
+ }
71
+
72
+ // now reverse string and work from the end in
73
+ htmlAfter = reverse(htmlAfter);
74
+ htmlBefore = reverse(htmlBefore);
75
+
76
+ // Find end of both strings that matches
77
+ for (afterFinish = 0; htmlAfter.charAt(afterFinish) === htmlBefore.charAt(afterFinish); afterFinish += 1) {
78
+ matchedTail += htmlAfter.charAt(afterFinish);
79
+ }
80
+
81
+ // If afterFinish is inside a HTML tag, move to closing brace of tag
82
+ for (var j = afterFinish; j >= 0; j -= 1) {
83
+ if (htmlBefore.charAt(j) === '>') {
84
+ afterFinish = j;
85
+ matchedTail = htmlBefore.substring(0, afterFinish);
86
+ break;
87
+ } else if (htmlBefore.charAt(j) === '<') {
88
+ break;
89
+ }
90
+ }
91
+
92
+ matchedTail = reverse(matchedTail);
93
+
94
+ // If there's no difference in pasted content
95
+ if (afterStart === (htmlAfter.length - afterFinish)) {
96
+ return false;
97
+ }
98
+
99
+ htmlAfter = reverse(htmlAfter);
100
+ newSnippet = htmlAfter.substring(afterStart, htmlAfter.length - afterFinish);
101
+
102
+ // first make sure all tags and attributes are made valid
103
+ newSnippet = checkValidTags(newSnippet);
104
+
105
+ // Replace opening bold tags with strong
106
+ newSnippet = newSnippet.replace(/<b(\s+|>)/g, '<strong$1');
107
+ // Replace closing bold tags with closing strong
108
+ newSnippet = newSnippet.replace(/<\/b(\s+|>)/g, '</strong$1');
109
+
110
+ // Replace italic tags with em
111
+ newSnippet = newSnippet.replace(/<i(\s+|>)/g, '<em$1');
112
+ // Replace closing italic tags with closing em
113
+ newSnippet = newSnippet.replace(/<\/i(\s+|>)/g, '</em$1');
114
+
115
+ // strip out comments -cgCraft
116
+ newSnippet = newSnippet.replace(/<!(?:--[\s\S]*?--\s*)?>\s*/g, '');
117
+
118
+ // strip out &nbsp; -cgCraft
119
+ newSnippet = newSnippet.replace(/&nbsp;/gi, ' ');
120
+ // strip out extra spaces -cgCraft
121
+ newSnippet = newSnippet.replace(/ <\//gi, '</');
122
+
123
+ while (newSnippet.indexOf(' ') !== -1) {
124
+ var anArray = newSnippet.split(' ');
125
+ newSnippet = anArray.join(' ');
126
+ }
127
+
128
+ // strip &nbsp; -cgCraft
129
+ newSnippet = newSnippet.replace(/^\s*|\s*$/g, '');
130
+
131
+ // Strip out unaccepted attributes
132
+ newSnippet = newSnippet.replace(/<[^>]*>/g, function (match) {
133
+ match = match.replace(/ ([^=]+)="[^"]*"/g, function (match2, attributeName) {
134
+ if (['alt', 'href', 'src', 'title'].indexOf(attributeName) !== -1) {
135
+ return match2;
136
+ }
137
+ return '';
138
+ });
139
+ return match;
140
+ });
141
+
142
+ // Final cleanout for MS Word crud
143
+ newSnippet = newSnippet.replace(/<\?xml[^>]*>/g, '');
144
+ newSnippet = newSnippet.replace(/<[^ >]+:[^>]*>/g, '');
145
+ newSnippet = newSnippet.replace(/<\/[^ >]+:[^>]*>/g, '');
146
+
147
+ // remove unwanted tags
148
+ newSnippet = newSnippet.replace(/<(div|span|style|meta|link){1}.*?>/gi, '');
149
+
150
+ htmlAfter = matchedHead + newSnippet + matchedTail;
151
+ return htmlAfter;
152
+ }
153
+
154
+ // clean editor
155
+ // this will clean the inserted contents
156
+ // it does a compare, before and after paste to determine the
157
+ // pasted contents
158
+ $.extend(true, $.trumbowyg, {
159
+ plugins: {
160
+ cleanPaste: {
161
+ init: function (trumbowyg) {
162
+ trumbowyg.pasteHandlers.push(function () {
163
+ try {
164
+ var contentBefore = trumbowyg.$ed.html();
165
+ setTimeout(function () {
166
+ var contentAfter = trumbowyg.$ed.html();
167
+ contentAfter = cleanIt(contentBefore, contentAfter);
168
+ trumbowyg.$ed.html(contentAfter);
169
+ }, 0);
170
+ } catch (c) {
171
+ }
172
+ });
173
+ }
174
+ }
175
+ }
176
+ });
177
+ })(jQuery);
178
+
179
+
@@ -0,0 +1 @@
1
+ !function(r){"use strict";function e(r){for(var e="",t=r.length-1;t>=0;t-=1)e+=r.charAt(t);return e}function t(r){var e=r;return e=e.replace(/<[^> ]*/g,function(r){return r.toLowerCase()}),e=e.replace(/<[^>]*>/g,function(r){return r=r.replace(/ [^=]+=/g,function(r){return r.toLowerCase()})}),e=e.replace(/<[^>]*>/g,function(r){return r=r.replace(/( [^=]+=)([^"][^ >]*)/g,'$1"$2"')})}function n(r,n){var a,c,i,l="",s="";for(a=0;n.charAt(a)===r.charAt(a);a+=1)l+=n.charAt(a);for(var u=a;u>=0;u-=1){if("<"===r.charAt(u)){a=u,l=r.substring(0,a);break}if(">"===r.charAt(u))break}for(n=e(n),r=e(r),c=0;n.charAt(c)===r.charAt(c);c+=1)s+=n.charAt(c);for(var g=c;g>=0;g-=1){if(">"===r.charAt(g)){c=g,s=r.substring(0,c);break}if("<"===r.charAt(g))break}if(s=e(s),a===n.length-c)return!1;for(n=e(n),i=n.substring(a,n.length-c),i=t(i),i=i.replace(/<b(\s+|>)/g,"<strong$1"),i=i.replace(/<\/b(\s+|>)/g,"</strong$1"),i=i.replace(/<i(\s+|>)/g,"<em$1"),i=i.replace(/<\/i(\s+|>)/g,"</em$1"),i=i.replace(/<!(?:--[\s\S]*?--\s*)?>\s*/g,""),i=i.replace(/&nbsp;/gi," "),i=i.replace(/ <\//gi,"</");-1!==i.indexOf(" ");){var o=i.split(" ");i=o.join(" ")}return i=i.replace(/^\s*|\s*$/g,""),i=i.replace(/<[^>]*>/g,function(r){return r=r.replace(/ ([^=]+)="[^"]*"/g,function(r,e){return-1!==["alt","href","src","title"].indexOf(e)?r:""})}),i=i.replace(/<\?xml[^>]*>/g,""),i=i.replace(/<[^ >]+:[^>]*>/g,""),i=i.replace(/<\/[^ >]+:[^>]*>/g,""),i=i.replace(/<(div|span|style|meta|link){1}.*?>/gi,""),n=l+i+s}r.extend(!0,r.trumbowyg,{plugins:{cleanPaste:{init:function(r){r.pasteHandlers.push(function(){try{var e=r.$ed.html();setTimeout(function(){var t=r.$ed.html();t=n(e,t),r.$ed.html(t)},0)}catch(t){}})}}}})}(jQuery);
@@ -0,0 +1,176 @@
1
+ /* ===========================================================
2
+ * trumbowyg.colors.js v1.2
3
+ * Colors picker plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Alexandre Demode (Alex-D)
7
+ * Twitter : @AlexandreDemode
8
+ * Website : alex-d.fr
9
+ */
10
+
11
+ (function ($) {
12
+ 'use strict';
13
+
14
+ $.extend(true, $.trumbowyg, {
15
+ langs: {
16
+ // jshint camelcase:false
17
+ cs: {
18
+ foreColor: 'Barva textu',
19
+ backColor: 'Barva pozadí'
20
+ },
21
+ en: {
22
+ foreColor: 'Text color',
23
+ backColor: 'Background color'
24
+ },
25
+ fr: {
26
+ foreColor: 'Couleur du texte',
27
+ backColor: 'Couleur de fond'
28
+ },
29
+ sk: {
30
+ foreColor: 'Farba textu',
31
+ backColor: 'Farba pozadia'
32
+ },
33
+ zh_cn: {
34
+ foreColor: '文字颜色',
35
+ backColor: '背景颜色'
36
+ },
37
+ ru: {
38
+ foreColor: 'Цвет текста',
39
+ backColor: 'Цвет выделения текста'
40
+ },
41
+ ja: {
42
+ foreColor: '文字色',
43
+ backColor: '背景色'
44
+ }
45
+ }
46
+ });
47
+ // jshint camelcase:true
48
+
49
+
50
+ function hex(x) {
51
+ return ('0' + parseInt(x).toString(16)).slice(-2);
52
+ }
53
+
54
+ function colorToHex(rgb) {
55
+ if (rgb.search('rgb') === -1) {
56
+ return rgb.replace('#', '');
57
+ } else if (rgb === 'rgba(0, 0, 0, 0)') {
58
+ return 'transparent';
59
+ } else {
60
+ rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
61
+ return hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
62
+ }
63
+ }
64
+
65
+ function colorTagHandler(element, trumbowyg) {
66
+ var tags = [];
67
+
68
+ if(!element.style){
69
+ return tags;
70
+ }
71
+
72
+ // background color
73
+ if (element.style.backgroundColor !== '') {
74
+ var backColor = colorToHex(element.style.backgroundColor);
75
+ if (trumbowyg.o.plugins.colors.colorList.indexOf(backColor) >= 0) {
76
+ tags.push('backColor' + backColor);
77
+ } else {
78
+ tags.push('backColorFree');
79
+ }
80
+ }
81
+
82
+ // text color
83
+ var foreColor;
84
+ if (element.style.color !== '') {
85
+ foreColor = colorToHex(element.style.color);
86
+ } else if (element.hasAttribute('color')) {
87
+ foreColor = colorToHex(element.getAttribute('color'));
88
+ }
89
+ if (foreColor) {
90
+ if (trumbowyg.o.plugins.colors.colorList.indexOf(foreColor) >= 0) {
91
+ tags.push('foreColor' + foreColor);
92
+ } else {
93
+ tags.push('foreColorFree');
94
+ }
95
+ }
96
+
97
+ return tags;
98
+ }
99
+
100
+ var defaultOptions = {
101
+ colorList: ['ffffff', '000000', 'eeece1', '1f497d', '4f81bd', 'c0504d', '9bbb59', '8064a2', '4bacc6', 'f79646', 'ffff00', 'f2f2f2', '7f7f7f', 'ddd9c3', 'c6d9f0', 'dbe5f1', 'f2dcdb', 'ebf1dd', 'e5e0ec', 'dbeef3', 'fdeada', 'fff2ca', 'd8d8d8', '595959', 'c4bd97', '8db3e2', 'b8cce4', 'e5b9b7', 'd7e3bc', 'ccc1d9', 'b7dde8', 'fbd5b5', 'ffe694', 'bfbfbf', '3f3f3f', '938953', '548dd4', '95b3d7', 'd99694', 'c3d69b', 'b2a2c7', 'b7dde8', 'fac08f', 'f2c314', 'a5a5a5', '262626', '494429', '17365d', '366092', '953734', '76923c', '5f497a', '92cddc', 'e36c09', 'c09100', '7f7f7f', '0c0c0c', '1d1b10', '0f243e', '244061', '632423', '4f6128', '3f3151', '31859b', '974806', '7f6000']
102
+ };
103
+
104
+ // Add all colors in two dropdowns
105
+ $.extend(true, $.trumbowyg, {
106
+ plugins: {
107
+ color: {
108
+ init: function (trumbowyg) {
109
+ trumbowyg.o.plugins.colors = trumbowyg.o.plugins.colors || defaultOptions;
110
+ var foreColorBtnDef = {
111
+ dropdown: buildDropdown('foreColor', trumbowyg)
112
+ },
113
+ backColorBtnDef = {
114
+ dropdown: buildDropdown('backColor', trumbowyg)
115
+ };
116
+
117
+ trumbowyg.addBtnDef('foreColor', foreColorBtnDef);
118
+ trumbowyg.addBtnDef('backColor', backColorBtnDef);
119
+ },
120
+ tagHandler: colorTagHandler
121
+ }
122
+ }
123
+ });
124
+
125
+ function buildDropdown(fn, trumbowyg) {
126
+ var dropdown = [];
127
+
128
+ $.each(trumbowyg.o.plugins.colors.colorList, function (i, color) {
129
+ var btn = fn + color,
130
+ btnDef = {
131
+ fn: fn,
132
+ forceCss: true,
133
+ param: '#' + color,
134
+ style: 'background-color: #' + color + ';'
135
+ };
136
+ trumbowyg.addBtnDef(btn, btnDef);
137
+ dropdown.push(btn);
138
+ });
139
+
140
+ var removeColorButtonName = fn + 'Remove',
141
+ removeColorBtnDef = {
142
+ fn: 'removeFormat',
143
+ param: fn,
144
+ style: 'background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAG0lEQVQIW2NkQAAfEJMRmwBYhoGBYQtMBYoAADziAp0jtJTgAAAAAElFTkSuQmCC);'
145
+ };
146
+ trumbowyg.addBtnDef(removeColorButtonName, removeColorBtnDef);
147
+ dropdown.push(removeColorButtonName);
148
+
149
+ // add free color btn
150
+ var freeColorButtonName = fn + 'Free',
151
+ freeColorBtnDef = {
152
+ fn: function () {
153
+ trumbowyg.openModalInsert(trumbowyg.lang[fn],
154
+ {
155
+ color: {
156
+ label: fn,
157
+ value: '#FFFFFF'
158
+ }
159
+ },
160
+ // callback
161
+ function (values) {
162
+ trumbowyg.execCmd(fn, values.color);
163
+ return true;
164
+ }
165
+ );
166
+ },
167
+ text: '#',
168
+ // style adjust for displaying the text
169
+ style: 'text-indent: 0;line-height: 20px;padding: 0 5px;'
170
+ };
171
+ trumbowyg.addBtnDef(freeColorButtonName, freeColorBtnDef);
172
+ dropdown.push(freeColorButtonName);
173
+
174
+ return dropdown;
175
+ }
176
+ })(jQuery);
@@ -0,0 +1 @@
1
+ !function(o){"use strict";function r(o){return("0"+parseInt(o).toString(16)).slice(-2)}function e(o){return-1===o.search("rgb")?o.replace("#",""):"rgba(0, 0, 0, 0)"===o?"transparent":(o=o.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/),r(o[1])+r(o[2])+r(o[3]))}function f(o,r){var f=[];if(!o.style)return f;if(""!==o.style.backgroundColor){var c=e(o.style.backgroundColor);r.o.plugins.colors.colorList.indexOf(c)>=0?f.push("backColor"+c):f.push("backColorFree")}var a;return""!==o.style.color?a=e(o.style.color):o.hasAttribute("color")&&(a=e(o.getAttribute("color"))),a&&(r.o.plugins.colors.colorList.indexOf(a)>=0?f.push("foreColor"+a):f.push("foreColorFree")),f}function c(r,e){var f=[];o.each(e.o.plugins.colors.colorList,function(o,c){var a=r+c,d={fn:r,forceCss:!0,param:"#"+c,style:"background-color: #"+c+";"};e.addBtnDef(a,d),f.push(a)});var c=r+"Remove",a={fn:"removeFormat",param:r,style:"background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAG0lEQVQIW2NkQAAfEJMRmwBYhoGBYQtMBYoAADziAp0jtJTgAAAAAElFTkSuQmCC);"};e.addBtnDef(c,a),f.push(c);var d=r+"Free",l={fn:function(){e.openModalInsert(e.lang[r],{color:{label:r,value:"#FFFFFF"}},function(o){return e.execCmd(r,o.color),!0})},text:"#",style:"text-indent: 0;line-height: 20px;padding: 0 5px;"};return e.addBtnDef(d,l),f.push(d),f}o.extend(!0,o.trumbowyg,{langs:{cs:{foreColor:"Barva textu",backColor:"Barva pozadí"},en:{foreColor:"Text color",backColor:"Background color"},fr:{foreColor:"Couleur du texte",backColor:"Couleur de fond"},sk:{foreColor:"Farba textu",backColor:"Farba pozadia"},zh_cn:{foreColor:"文字颜色",backColor:"背景颜色"},ru:{foreColor:"Цвет текста",backColor:"Цвет выделения текста"},ja:{foreColor:"文字色",backColor:"背景色"}}});var a={colorList:["ffffff","000000","eeece1","1f497d","4f81bd","c0504d","9bbb59","8064a2","4bacc6","f79646","ffff00","f2f2f2","7f7f7f","ddd9c3","c6d9f0","dbe5f1","f2dcdb","ebf1dd","e5e0ec","dbeef3","fdeada","fff2ca","d8d8d8","595959","c4bd97","8db3e2","b8cce4","e5b9b7","d7e3bc","ccc1d9","b7dde8","fbd5b5","ffe694","bfbfbf","3f3f3f","938953","548dd4","95b3d7","d99694","c3d69b","b2a2c7","b7dde8","fac08f","f2c314","a5a5a5","262626","494429","17365d","366092","953734","76923c","5f497a","92cddc","e36c09","c09100","7f7f7f","0c0c0c","1d1b10","0f243e","244061","632423","4f6128","3f3151","31859b","974806","7f6000"]};o.extend(!0,o.trumbowyg,{plugins:{color:{init:function(o){o.o.plugins.colors=o.o.plugins.colors||a;var r={dropdown:c("foreColor",o)},e={dropdown:c("backColor",o)};o.addBtnDef("foreColor",r),o.addBtnDef("backColor",e)},tagHandler:f}}})}(jQuery);
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Trumbowyg v2.8.1 - A lightweight WYSIWYG editor
3
+ * Default stylesheet for Trumbowyg editor plugin
4
+ * ------------------------
5
+ * @link http://alex-d.github.io/Trumbowyg
6
+ * @license MIT
7
+ * @author Alexandre Demode (Alex-D)
8
+ * Twitter : @AlexandreDemode
9
+ * Website : alex-d.fr
10
+ */
11
+
12
+ .trumbowyg-dropdown-foreColor,
13
+ .trumbowyg-dropdown-backColor {
14
+ width: 276px;
15
+ padding: 7px 5px;
16
+
17
+ svg {
18
+ display: none !important;
19
+ }
20
+
21
+ button {
22
+ display: block;
23
+ position: relative;
24
+ float: left;
25
+ text-indent: -9999px;
26
+ height: 20px;
27
+ width: 20px;
28
+ border: 1px solid #333;
29
+ padding: 0;
30
+ margin: 2px;
31
+
32
+ &:hover,
33
+ &:focus {
34
+ &::after {
35
+ content: " ";
36
+ display: block;
37
+ position: absolute;
38
+ top: -5px;
39
+ left: -5px;
40
+ height: 27px;
41
+ width: 27px;
42
+ background: inherit;
43
+ border: 1px solid #FFF;
44
+ box-shadow: #000 0 0 2px;
45
+ z-index: 10;
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Trumbowyg v2.8.1 - A lightweight WYSIWYG editor
3
+ * Trumbowyg plugin stylesheet
4
+ * ------------------------
5
+ * @link http://alex-d.github.io/Trumbowyg
6
+ * @license MIT
7
+ * @author Alexandre Demode (Alex-D)
8
+ * Twitter : @AlexandreDemode
9
+ * Website : alex-d.fr
10
+ */
11
+
12
+ .trumbowyg-dropdown-foreColor,
13
+ .trumbowyg-dropdown-backColor {
14
+ width: 276px;
15
+ padding: 7px 5px; }
16
+ .trumbowyg-dropdown-foreColor svg,
17
+ .trumbowyg-dropdown-backColor svg {
18
+ display: none !important; }
19
+ .trumbowyg-dropdown-foreColor button,
20
+ .trumbowyg-dropdown-backColor button {
21
+ display: block;
22
+ position: relative;
23
+ float: left;
24
+ text-indent: -9999px;
25
+ height: 20px;
26
+ width: 20px;
27
+ border: 1px solid #333;
28
+ padding: 0;
29
+ margin: 2px; }
30
+ .trumbowyg-dropdown-foreColor button:hover::after, .trumbowyg-dropdown-foreColor button:focus::after,
31
+ .trumbowyg-dropdown-backColor button:hover::after,
32
+ .trumbowyg-dropdown-backColor button:focus::after {
33
+ content: " ";
34
+ display: block;
35
+ position: absolute;
36
+ top: -5px;
37
+ left: -5px;
38
+ height: 27px;
39
+ width: 27px;
40
+ background: inherit;
41
+ border: 1px solid #FFF;
42
+ box-shadow: #000 0 0 2px;
43
+ z-index: 10; }
@@ -0,0 +1,2 @@
1
+ /** Trumbowyg v2.8.1 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */
2
+ .trumbowyg-dropdown-backColor,.trumbowyg-dropdown-foreColor{width:276px;padding:7px 5px}.trumbowyg-dropdown-backColor svg,.trumbowyg-dropdown-foreColor svg{display:none!important}.trumbowyg-dropdown-backColor button,.trumbowyg-dropdown-foreColor button{display:block;position:relative;float:left;text-indent:-9999px;height:20px;width:20px;border:1px solid #333;padding:0;margin:2px}.trumbowyg-dropdown-backColor button:focus::after,.trumbowyg-dropdown-backColor button:hover::after,.trumbowyg-dropdown-foreColor button:focus::after,.trumbowyg-dropdown-foreColor button:hover::after{content:" ";display:block;position:absolute;top:-5px;left:-5px;height:27px;width:27px;background:inherit;border:1px solid #FFF;box-shadow:#000 0 0 2px;z-index:10}