trumbowyg_rails 1.1.3 → 2.1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -7
  3. data/VERSION +1 -1
  4. data/lib/{trumbowyg_rails.rb → trumbowyg2-rails.rb} +0 -0
  5. data/trumbowyg_rails.gemspec +5 -5
  6. data/vendor/assets/images/trumbowyg/images/icons.svg +1 -0
  7. data/vendor/assets/javascripts/trumbowyg/langs/ar.js +56 -0
  8. data/vendor/assets/javascripts/trumbowyg/langs/ca.js +33 -34
  9. data/vendor/assets/javascripts/trumbowyg/langs/cs.js +54 -0
  10. data/vendor/assets/javascripts/trumbowyg/langs/da.js +55 -0
  11. data/vendor/assets/javascripts/trumbowyg/langs/de.js +33 -34
  12. data/vendor/assets/javascripts/trumbowyg/langs/el.js +58 -0
  13. data/vendor/assets/javascripts/trumbowyg/langs/es.js +33 -34
  14. data/vendor/assets/javascripts/trumbowyg/langs/es_ar.js +34 -34
  15. data/vendor/assets/javascripts/trumbowyg/langs/fa.js +33 -34
  16. data/vendor/assets/javascripts/trumbowyg/langs/fi.js +33 -34
  17. data/vendor/assets/javascripts/trumbowyg/langs/fr.js +40 -34
  18. data/vendor/assets/javascripts/trumbowyg/langs/he.js +57 -0
  19. data/vendor/assets/javascripts/trumbowyg/langs/hu.js +58 -0
  20. data/vendor/assets/javascripts/trumbowyg/langs/id.js +33 -34
  21. data/vendor/assets/javascripts/trumbowyg/langs/it.js +33 -34
  22. data/vendor/assets/javascripts/trumbowyg/langs/ja.js +56 -0
  23. data/vendor/assets/javascripts/trumbowyg/langs/ko.js +33 -34
  24. data/vendor/assets/javascripts/trumbowyg/langs/my.js +54 -0
  25. data/vendor/assets/javascripts/trumbowyg/langs/nl.js +56 -0
  26. data/vendor/assets/javascripts/trumbowyg/langs/pl.js +33 -34
  27. data/vendor/assets/javascripts/trumbowyg/langs/pt.js +33 -34
  28. data/vendor/assets/javascripts/trumbowyg/langs/ro.js +33 -35
  29. data/vendor/assets/javascripts/trumbowyg/langs/rs.js +53 -0
  30. data/vendor/assets/javascripts/trumbowyg/langs/rs_latin.js +54 -0
  31. data/vendor/assets/javascripts/trumbowyg/langs/ru.js +33 -34
  32. data/vendor/assets/javascripts/trumbowyg/langs/sk.js +54 -0
  33. data/vendor/assets/javascripts/trumbowyg/langs/sv.js +55 -0
  34. data/vendor/assets/javascripts/trumbowyg/langs/tr.js +34 -36
  35. data/vendor/assets/javascripts/trumbowyg/langs/ua.js +54 -0
  36. data/vendor/assets/javascripts/trumbowyg/langs/vi.js +55 -0
  37. data/vendor/assets/javascripts/trumbowyg/langs/zh_cn.js +34 -34
  38. data/vendor/assets/javascripts/trumbowyg/langs/zh_tw.js +57 -0
  39. data/vendor/assets/javascripts/trumbowyg/plugins/base64/trumbowyg.base64.js +90 -0
  40. data/vendor/assets/javascripts/trumbowyg/plugins/colors/trumbowyg.colors.js +164 -0
  41. data/vendor/assets/javascripts/trumbowyg/plugins/noembed/trumbowyg.noembed.js +96 -0
  42. data/vendor/assets/javascripts/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +39 -0
  43. data/vendor/assets/javascripts/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +117 -0
  44. data/vendor/assets/javascripts/trumbowyg/plugins/upload/trumbowyg.upload.js +204 -0
  45. data/vendor/assets/javascripts/trumbowyg/trumbowyg.js +1126 -700
  46. data/vendor/assets/stylesheets/trumbowyg/plugins/colors/trumbowyg.colors.scss +49 -0
  47. data/vendor/assets/stylesheets/trumbowyg/trumbowyg.scss +351 -159
  48. metadata +33 -11
  49. data/vendor/assets/images/trumbowyg/images/icons-2x.png +0 -0
  50. data/vendor/assets/images/trumbowyg/images/icons.png +0 -0
  51. data/vendor/assets/stylesheets/trumbowyg/_sprite-2x.scss +0 -28
  52. data/vendor/assets/stylesheets/trumbowyg/_sprite.scss +0 -28
@@ -0,0 +1,90 @@
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
+ $.extend(true, $.trumbowyg, {
17
+ langs: {
18
+ // jshint camelcase:false
19
+ en: {
20
+ base64: 'Image as base64',
21
+ file: 'File',
22
+ errFileReaderNotSupported: 'FileReader is not supported by your browser.'
23
+ },
24
+ fr: {
25
+ base64: 'Image en base64',
26
+ file: 'Fichier'
27
+ },
28
+ cs: {
29
+ base64: 'Vložit obrázek',
30
+ file: 'Soubor'
31
+ },
32
+ zh_cn: {
33
+ base64: '图片(Base64编码)',
34
+ file: '文件'
35
+ }
36
+ },
37
+ // jshint camelcase:true
38
+
39
+ plugins: {
40
+ base64: {
41
+ shouldInit: isSupported,
42
+ init: function (trumbowyg) {
43
+ var btnDef = {
44
+ isSupported: isSupported,
45
+ fn: function () {
46
+ trumbowyg.saveRange();
47
+
48
+ var file;
49
+ trumbowyg.openModalInsert(
50
+ // Title
51
+ trumbowyg.lang.base64,
52
+
53
+ // Fields
54
+ {
55
+ file: {
56
+ type: 'file',
57
+ required: true
58
+ },
59
+ alt: {
60
+ label: 'description',
61
+ value: trumbowyg.getRangeText()
62
+ }
63
+ },
64
+
65
+ // Callback
66
+ function (values) {
67
+ var fReader = new FileReader();
68
+
69
+ fReader.onloadend = function () {
70
+ trumbowyg.execCmd('insertImage', fReader.result);
71
+ $(['img[src="', fReader.result, '"]:not([alt])'].join(''), trumbowyg.$box).attr('alt', values.alt);
72
+ trumbowyg.closeModal();
73
+ };
74
+
75
+ fReader.readAsDataURL(file);
76
+ }
77
+ );
78
+
79
+ $('input[type=file]').on('change', function (e) {
80
+ file = e.target.files[0];
81
+ });
82
+ }
83
+ };
84
+
85
+ trumbowyg.addBtnDef('base64', btnDef);
86
+ }
87
+ }
88
+ }
89
+ });
90
+ })(jQuery);
@@ -0,0 +1,164 @@
1
+ /* ===========================================================
2
+ * trumbowyg.colors.js v1.1
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
+ }
38
+ });
39
+ // jshint camelcase:true
40
+
41
+
42
+ function hex(x) {
43
+ return ('0' + parseInt(x).toString(16)).slice(-2);
44
+ }
45
+
46
+ function colorToHex(rgb) {
47
+ if (rgb.search('rgb') === -1) {
48
+ return rgb.replace('#', '');
49
+ } else if (rgb === 'rgba(0, 0, 0, 0)') {
50
+ return 'transparent';
51
+ } else {
52
+ rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
53
+ return hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
54
+ }
55
+ }
56
+
57
+ function colorTagHandler(element, trumbowyg) {
58
+ var tags = [];
59
+
60
+ // background color
61
+ if (element.style.backgroundColor !== '') {
62
+ var backColor = colorToHex(element.style.backgroundColor);
63
+ if (trumbowyg.o.plugins.colors.colorList.indexOf(backColor) >= 0) {
64
+ tags.push('backColor' + backColor);
65
+ } else {
66
+ tags.push('backColorFree');
67
+ }
68
+ }
69
+
70
+ // text color
71
+ var foreColor;
72
+ if (element.style.color !== '') {
73
+ foreColor = colorToHex(element.style.color);
74
+ } else if (element.hasAttribute('color')) {
75
+ foreColor = colorToHex(element.getAttribute('color'));
76
+ }
77
+ if (foreColor) {
78
+ if (trumbowyg.o.plugins.colors.colorList.indexOf(foreColor) >= 0) {
79
+ tags.push('foreColor' + foreColor);
80
+ } else {
81
+ tags.push('foreColorFree');
82
+ }
83
+ }
84
+
85
+ return tags;
86
+ }
87
+
88
+ var defaultOptions = {
89
+ 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']
90
+ };
91
+
92
+ // Add all colors in two dropdowns
93
+ $.extend(true, $.trumbowyg, {
94
+ plugins: {
95
+ color: {
96
+ init: function (trumbowyg) {
97
+ trumbowyg.o.plugins.colors = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.colors || {});
98
+ var foreColorBtnDef = {
99
+ dropdown: buildDropdown('foreColor', trumbowyg)
100
+ },
101
+ backColorBtnDef = {
102
+ dropdown: buildDropdown('backColor', trumbowyg)
103
+ };
104
+
105
+ trumbowyg.addBtnDef('foreColor', foreColorBtnDef);
106
+ trumbowyg.addBtnDef('backColor', backColorBtnDef);
107
+ },
108
+ tagHandler: colorTagHandler
109
+ }
110
+ }
111
+ });
112
+
113
+ function buildDropdown(fn, trumbowyg) {
114
+ var dropdown = [];
115
+
116
+ $.each(trumbowyg.o.plugins.colors.colorList, function (i, color) {
117
+ var btn = fn + color,
118
+ btnDef = {
119
+ fn: fn,
120
+ forceCss: true,
121
+ param: '#' + color,
122
+ style: 'background-color: #' + color + ';'
123
+ };
124
+ trumbowyg.addBtnDef(btn, btnDef);
125
+ dropdown.push(btn);
126
+ });
127
+
128
+ var removeColorButtonName = fn + 'Remove',
129
+ removeColorBtnDef = {
130
+ fn: 'removeFormat',
131
+ param: fn,
132
+ style: 'background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAG0lEQVQIW2NkQAAfEJMRmwBYhoGBYQtMBYoAADziAp0jtJTgAAAAAElFTkSuQmCC);'
133
+ };
134
+ trumbowyg.addBtnDef(removeColorButtonName, removeColorBtnDef);
135
+ dropdown.push(removeColorButtonName);
136
+
137
+ // add free color btn
138
+ var freeColorButtonName = fn + 'Free',
139
+ freeColorBtnDef = {
140
+ fn: function () {
141
+ trumbowyg.openModalInsert(trumbowyg.lang[fn],
142
+ {
143
+ color: {
144
+ label: fn,
145
+ value: '#FFFFFF'
146
+ }
147
+ },
148
+ // callback
149
+ function (values) {
150
+ trumbowyg.execCmd(fn, values.color);
151
+ return true;
152
+ }
153
+ );
154
+ },
155
+ text: '#',
156
+ // style adjust for displaying the text
157
+ style: 'text-indent: 0;line-height: 20px;padding: 0 5px;'
158
+ };
159
+ trumbowyg.addBtnDef(freeColorButtonName, freeColorBtnDef);
160
+ dropdown.push(freeColorButtonName);
161
+
162
+ return dropdown;
163
+ }
164
+ })(jQuery);
@@ -0,0 +1,96 @@
1
+ /* ===========================================================
2
+ * trumbowyg.noembed.js v1.0
3
+ * noEmbed plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Jake Johns (jakejohns)
7
+ */
8
+
9
+ (function ($) {
10
+ 'use strict';
11
+
12
+ var defaultOptions = {
13
+ proxy: 'https://noembed.com/embed?nowrap=on',
14
+ urlFiled: 'url',
15
+ data: [],
16
+ success: undefined,
17
+ error: undefined
18
+ };
19
+
20
+ $.extend(true, $.trumbowyg, {
21
+ langs: {
22
+ en: {
23
+ noembed: 'noEmbed',
24
+ noembedError: 'Error'
25
+ },
26
+ sk: {
27
+ noembedError: 'Chyba'
28
+ },
29
+ fr: {
30
+ noembed: 'noEmbed',
31
+ noembedError: 'Erreur'
32
+ },
33
+ cs: {
34
+ noembedError: 'Chyba'
35
+ }
36
+ },
37
+
38
+ plugins: {
39
+ noembed: {
40
+ init: function (trumbowyg) {
41
+ trumbowyg.o.plugins.noembed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.noembed || {});
42
+
43
+ var btnDef = {
44
+ fn: function () {
45
+ var $modal = trumbowyg.openModalInsert(
46
+ // Title
47
+ trumbowyg.lang.noembed,
48
+
49
+ // Fields
50
+ {
51
+ url: {
52
+ label: 'URL',
53
+ required: true
54
+ }
55
+ },
56
+
57
+ // Callback
58
+ function (data) {
59
+ $.ajax({
60
+ url: trumbowyg.o.plugins.noembed.proxy,
61
+ type: 'GET',
62
+ data: data,
63
+ cache: false,
64
+ dataType: 'json',
65
+
66
+ success: trumbowyg.o.plugins.noembed.success || function (data) {
67
+ if (data.html) {
68
+ trumbowyg.execCmd('insertHTML', $(data.html).unwrap().html());
69
+ setTimeout(function () {
70
+ trumbowyg.closeModal();
71
+ }, 250);
72
+ } else {
73
+ trumbowyg.addErrorOnModalField(
74
+ $('input[type=text]', $modal),
75
+ data.error
76
+ );
77
+ }
78
+ },
79
+ error: trumbowyg.o.plugins.noembed.error || function () {
80
+ trumbowyg.addErrorOnModalField(
81
+ $('input[type=text]', $modal),
82
+ trumbowyg.lang.noembedError
83
+ );
84
+ }
85
+ });
86
+ }
87
+ );
88
+ }
89
+ };
90
+
91
+ trumbowyg.addBtnDef('noembed', btnDef);
92
+ }
93
+ }
94
+ }
95
+ });
96
+ })(jQuery);
@@ -0,0 +1,39 @@
1
+ /* ===========================================================
2
+ * trumbowyg.pasteimage.js v1.0
3
+ * Basic base64 paste 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
+ plugins: {
16
+ pasteImage: {
17
+ init: function (trumbowyg) {
18
+ trumbowyg.pasteHandlers.push(function (pasteEvent) {
19
+ try {
20
+ var items = (pasteEvent.originalEvent || pasteEvent).clipboardData.items,
21
+ reader;
22
+
23
+ if (items[0].type.match(/^image\//)) {
24
+ reader = new FileReader();
25
+ /* jshint -W083 */
26
+ reader.onloadend = function (event) {
27
+ trumbowyg.execCmd('insertImage', event.target.result, undefined, true);
28
+ };
29
+ /* jshint +W083 */
30
+ reader.readAsDataURL(items[0].getAsFile());
31
+ }
32
+ } catch (c) {
33
+ }
34
+ });
35
+ }
36
+ }
37
+ }
38
+ });
39
+ })(jQuery);
@@ -0,0 +1,117 @@
1
+ /* ===========================================================
2
+ * trumbowyg.preformatted.js v1.0
3
+ * Preformatted plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Casella Edoardo (Civile)
7
+ */
8
+
9
+
10
+ (function ($) {
11
+ 'use strict';
12
+
13
+ $.extend(true, $.trumbowyg, {
14
+ langs: {
15
+ // jshint camelcase:false
16
+ en: {
17
+ preformatted: 'Code sample <pre>'
18
+ },
19
+ fr: {
20
+ preformatted: 'Exemple de code'
21
+ },
22
+ it: {
23
+ preformatted: 'Codice <pre>'
24
+ },
25
+ zh_cn: {
26
+ preformatted: '代码示例 <pre>'
27
+ }
28
+ },
29
+ // jshint camelcase:true
30
+
31
+ plugins: {
32
+ preformatted: {
33
+ init: function (trumbowyg) {
34
+ var btnDef = {
35
+ fn: function () {
36
+ trumbowyg.saveRange();
37
+ var text = trumbowyg.getRangeText();
38
+ if (text.replace(/\s/g, '') !== '') {
39
+ try {
40
+ var curtag = getSelectionParentElement().tagName.toLowerCase();
41
+ if (curtag === 'code' || curtag === 'pre') {
42
+ return unwrapCode();
43
+ }
44
+ else {
45
+ trumbowyg.execCmd('insertHTML', '<pre><code>' + strip(text) + '</code></pre>');
46
+ }
47
+ } catch (e) {
48
+ }
49
+ }
50
+ },
51
+ tag: 'pre'
52
+ };
53
+
54
+ trumbowyg.addBtnDef('preformatted', btnDef);
55
+ }
56
+ }
57
+ }
58
+ });
59
+
60
+ /*
61
+ * GetSelectionParentElement
62
+ */
63
+ function getSelectionParentElement() {
64
+ var parentEl = null,
65
+ selection;
66
+ if (window.getSelection) {
67
+ selection = window.getSelection();
68
+ if (selection.rangeCount) {
69
+ parentEl = selection.getRangeAt(0).commonAncestorContainer;
70
+ if (parentEl.nodeType !== 1) {
71
+ parentEl = parentEl.parentNode;
72
+ }
73
+ }
74
+ } else if ((selection = document.selection) && selection.type !== 'Control') {
75
+ parentEl = selection.createRange().parentElement();
76
+ }
77
+ return parentEl;
78
+ }
79
+
80
+ /*
81
+ * Strip
82
+ * returns a text without HTML tags
83
+ */
84
+ function strip(html) {
85
+ var tmp = document.createElement('DIV');
86
+ tmp.innerHTML = html;
87
+ return tmp.textContent || tmp.innerText || '';
88
+ }
89
+
90
+ /*
91
+ * UnwrapCode
92
+ * ADD/FIX: to improve, works but can be better
93
+ * "paranoic" solution
94
+ */
95
+ function unwrapCode() {
96
+ var container = null;
97
+ if (document.selection) { //for IE
98
+ container = document.selection.createRange().parentElement();
99
+ } else {
100
+ var select = window.getSelection();
101
+ if (select.rangeCount > 0) {
102
+ container = select.getRangeAt(0).startContainer.parentNode;
103
+ }
104
+ }
105
+ //'paranoic' unwrap
106
+ var ispre = $(container).contents().closest('pre').length;
107
+ var iscode = $(container).contents().closest('code').length;
108
+ if (ispre && iscode) {
109
+ $(container).contents().unwrap('code').unwrap('pre');
110
+ } else if (ispre) {
111
+ $(container).contents().unwrap('pre');
112
+ } else if (iscode) {
113
+ $(container).contents().unwrap('code');
114
+ }
115
+ }
116
+
117
+ })(jQuery);