activeadmin_trumbowyg 0.1.6 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +42 -39
- data/Rakefile +2 -2
- data/app/assets/fonts/trumbowyg/icons.svg +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ar.js +67 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/bg.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/by.js +61 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ca.js +57 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/cs.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/da.js +64 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.js +57 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/el.js +59 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/es.js +63 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/es_ar.js +56 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/fa.js +58 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/fi.js +58 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/fr.js +66 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/he.js +57 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/hr.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/hu.js +58 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/id.js +57 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/it.js +59 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ja.js +63 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ko.js +63 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ko.min.js +3 -4
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/lt.js +59 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/mn.js +49 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/my.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/nl.js +61 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/nl.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/no_nb.js +56 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ph.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/pl.js +55 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt.js +65 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt_br.js +65 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt_br.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ro.js +58 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/rs.js +53 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/rs_latin.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ru.js +61 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ru.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/sk.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/sl.js +48 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/sl.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/sq.js +65 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/sv.js +58 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/th.js +55 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/th.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/tr.js +55 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/ua.js +54 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/vi.js +56 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/vi.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_cn.js +57 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_tw.js +66 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js +22 -3
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +14 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +9 -10
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +88 -36
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +30 -11
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +27 -15
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +914 -840
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +1 -4
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +2 -5
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.js +24 -11
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js +121 -24
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/trumbowyg.giphy.js +182 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/trumbowyg.giphy.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/ui/sass/trumbowyg.giphy.scss +111 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/ui/trumbowyg.giphy.css +90 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/ui/trumbowyg.giphy.min.css +2 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.js +11 -3
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.js +17 -3
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +9 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js +59 -19
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.js +25 -6
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss +10 -10
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css +9 -9
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.js +26 -21
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss +1 -11
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.css +14 -22
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +11 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +9 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +6 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/resizable-resolveconflict.js +20 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/resizable-resolveconflict.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js +252 -18
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.js +12 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/trumbowyg.specialchars.js +79 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/trumbowyg.specialchars.min.js +1 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/ui/sass/trumbowyg.specialchars.scss +56 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.css +47 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.min.css +2 -0
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +272 -157
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss +5 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.css +4 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.min.css +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +14 -3
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +15 -4
- data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +1 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.js +234 -132
- data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.min.js +2 -2
- data/app/assets/javascripts/activeadmin/trumbowyg_input.js +22 -9
- data/app/assets/stylesheets/activeadmin/_trumbowyg_input.scss +67 -0
- data/app/assets/stylesheets/activeadmin/trumbowyg/{ui/sass/trumbowyg.scss → trumbowyg.scss} +22 -7
- data/lib/activeadmin/trumbowyg.rb +2 -0
- data/lib/activeadmin/trumbowyg/engine.rb +2 -0
- data/lib/activeadmin/trumbowyg/version.rb +3 -1
- data/lib/activeadmin_trumbowyg.rb +2 -1
- data/lib/formtastic/inputs/trumbowyg_input.rb +3 -2
- data/lib/tasks/trumbowyg.rake +4 -2
- metadata +193 -23
- data/.gitignore +0 -3
- data/Gemfile +0 -4
- data/activeadmin_trumbowyg.gemspec +0 -19
- data/app/assets/fonts/active_admin-trumbowyg.svg +0 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/icons.svg +0 -1
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +0 -809
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.css +0 -587
- data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.min.css +0 -2
- data/app/assets/stylesheets/activeadmin/_trumbowyg_input.sass +0 -56
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/icons.svg +0 -1
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.css +0 -587
- data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.min.css +0 -2
- data/screenshot.jpg +0 -0
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e){"use strict";function n(n){var i=[]
|
1
|
+
!function(e){"use strict";function n(n){var i=[];return e.each(n.o.plugins.lineheight.sizeList,function(l,a){n.addBtnDef("lineheight_"+a,{text:n.lang.lineheights[a]||a,hasIcon:!1,fn:function(){n.saveRange();var i=n.getRangeText();if(""!==i.replace(/\s/g,""))try{var l=t();e(l).css("lineHeight",a)}catch(h){}}}),i.push("lineheight_"+a)}),i}function t(){var e,n=null;return window.getSelection?(e=window.getSelection(),e.rangeCount&&(n=e.getRangeAt(0).commonAncestorContainer,1!==n.nodeType&&(n=n.parentNode))):(e=document.selection)&&"Control"!==e.type&&(n=e.createRange().parentElement()),n}e.extend(!0,e.trumbowyg,{langs:{en:{lineheight:"Line height",lineheights:{.9:"Small",normal:"Regular",1.5:"Large","2.0":"Extra large"}},da:{lineheight:"Linjehøjde",lineheights:{.9:"Lille",normal:"Normal",1.5:"Stor","2.0":"Ekstra stor"}},fr:{lineheight:"Hauteur de ligne",lineheights:{.9:"Petite",normal:"Normale",1.5:"Grande","2.0":"Très grande"}},nl:{lineheight:"Regelhoogte",lineheights:{.9:"Klein",normal:"Normaal",1.5:"Groot","2.0":"Extra groot"}},tr:{lineheight:"Satır yüksekliği",lineheights:{.9:"Küçük",normal:"Normal",1.5:"Büyük","2.0":"Çok Büyük"}},zh_tw:{lineheight:"文字間距",lineheights:{.9:"小",normal:"正常",1.5:"大","2.0":"特大"}},pt_br:{lineheight:"Altura de linha",lineheights:{.9:"Pequena",normal:"Regular",1.5:"Grande","2.0":"Extra grande"}},it:{lineheight:"Altezza linea",lineheights:{.9:"Bassa",normal:"Normale",1.5:"Alta","2.0":"Molto alta"}},ko:{lineheight:"줄 간격",lineheights:{.9:"좁게",normal:"보통",1.5:"넓게","2.0":"아주 넓게"}}}});var i={sizeList:["0.9","normal","1.5","2.0"]};e.extend(!0,e.trumbowyg,{plugins:{lineheight:{init:function(t){t.o.plugins.lineheight=e.extend({},i,t.o.plugins.lineheight||{}),t.addBtnDef("lineheight",{dropdown:n(t)})}}}})}(jQuery);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/* ===========================================================
|
2
2
|
* trumbowyg.mathMl.js v1.0
|
3
3
|
* MathML plugin for Trumbowyg
|
4
|
-
*
|
4
|
+
* http://alex-d.github.com/Trumbowyg
|
5
5
|
* ===========================================================
|
6
6
|
* Author : loclamor
|
7
7
|
*/
|
@@ -11,6 +11,7 @@
|
|
11
11
|
'use strict';
|
12
12
|
$.extend(true, $.trumbowyg, {
|
13
13
|
langs: {
|
14
|
+
// jshint camelcase:false
|
14
15
|
en: {
|
15
16
|
mathml: 'Insert Formulas',
|
16
17
|
formulas: 'Formulas',
|
@@ -36,7 +37,19 @@
|
|
36
37
|
formulas: '方程式',
|
37
38
|
inline: '內嵌'
|
38
39
|
},
|
40
|
+
pt_br: {
|
41
|
+
mathml: 'Inserir fórmulas',
|
42
|
+
formulas: 'Fórmulas',
|
43
|
+
inline: 'Em linha'
|
44
|
+
},
|
45
|
+
ko: {
|
46
|
+
mathml: '수식 넣기',
|
47
|
+
formulas: '수식',
|
48
|
+
inline: '글 안에 넣기'
|
49
|
+
},
|
39
50
|
},
|
51
|
+
// jshint camelcase:true
|
52
|
+
|
40
53
|
plugins: {
|
41
54
|
mathml: {
|
42
55
|
init: function(trumbowyg) {
|
@@ -60,22 +73,28 @@
|
|
60
73
|
};
|
61
74
|
|
62
75
|
var mathmlCallback = function(v) {
|
63
|
-
var
|
76
|
+
var delimiter = v.inline ? '$' : '$$';
|
64
77
|
if (trumbowyg.currentMathNode) {
|
65
|
-
$(trumbowyg.currentMathNode)
|
78
|
+
$(trumbowyg.currentMathNode)
|
79
|
+
.html(delimiter + ' ' + v.formulas + ' ' + delimiter)
|
80
|
+
.attr('formulas', v.formulas)
|
81
|
+
.attr('inline', (v.inline ? 'true' : 'false'));
|
66
82
|
} else {
|
67
|
-
var html = '<span class="mathMlContainer" contenteditable="false" formulas="' + v.formulas + '" inline="' + (v.inline ? 'true' : 'false') + '" >' +
|
83
|
+
var html = '<span class="mathMlContainer" contenteditable="false" formulas="' + v.formulas + '" inline="' + (v.inline ? 'true' : 'false') + '" >' + delimiter + ' ' + v.formulas + ' ' + delimiter + '</span>';
|
68
84
|
var node = $(html)[0];
|
69
|
-
node.onclick = function(
|
85
|
+
node.onclick = function() {
|
70
86
|
trumbowyg.currentMathNode = this;
|
71
87
|
mathMLoptions.formulas.value = $(this).attr('formulas');
|
72
|
-
|
88
|
+
|
89
|
+
if ($(this).attr('inline') === 'true') {
|
73
90
|
mathMLoptions.inline.attributes.checked = true;
|
74
91
|
} else {
|
75
92
|
delete mathMLoptions.inline.attributes.checked;
|
76
93
|
}
|
94
|
+
|
77
95
|
trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMLoptions, mathmlCallback);
|
78
96
|
};
|
97
|
+
|
79
98
|
trumbowyg.range.deleteContents();
|
80
99
|
trumbowyg.range.insertNode(node);
|
81
100
|
}
|
@@ -1 +1 @@
|
|
1
|
-
!function(e){"use strict";e.extend(!0,e.trumbowyg,{langs:{en:{mathml:"Insert Formulas",formulas:"Formulas",inline:"Inline"},da:{mathml:"Indsæt formler",formulas:"Formler",inline:"Inline"},fr:{mathml:"Inserer une formule",formulas:"Formule",inline:"En ligne"},tr:{mathml:"Formül Ekle",formulas:"Formüller",inline:"Satır içi"},zh_tw:{mathml:"插入方程式",formulas:"方程式",inline:"內嵌"}},plugins:{mathml:{init:function(n){var l={fn:function(){n.saveRange();var l={formulas:{label:n.lang.formulas,required:!0,value:""},inline:{label:n.lang.inline,attributes:{checked:!0},type:"checkbox",required:!1}},
|
1
|
+
!function(e){"use strict";e.extend(!0,e.trumbowyg,{langs:{en:{mathml:"Insert Formulas",formulas:"Formulas",inline:"Inline"},da:{mathml:"Indsæt formler",formulas:"Formler",inline:"Inline"},fr:{mathml:"Inserer une formule",formulas:"Formule",inline:"En ligne"},tr:{mathml:"Formül Ekle",formulas:"Formüller",inline:"Satır içi"},zh_tw:{mathml:"插入方程式",formulas:"方程式",inline:"內嵌"},pt_br:{mathml:"Inserir fórmulas",formulas:"Fórmulas",inline:"Em linha"},ko:{mathml:"수식 넣기",formulas:"수식",inline:"글 안에 넣기"}},plugins:{mathml:{init:function(n){var l={fn:function(){n.saveRange();var l={formulas:{label:n.lang.formulas,required:!0,value:""},inline:{label:n.lang.inline,attributes:{checked:!0},type:"checkbox",required:!1}},a=function(t){var r=t.inline?"$":"$$";if(n.currentMathNode)e(n.currentMathNode).html(r+" "+t.formulas+" "+r).attr("formulas",t.formulas).attr("inline",t.inline?"true":"false");else{var i='<span class="mathMlContainer" contenteditable="false" formulas="'+t.formulas+'" inline="'+(t.inline?"true":"false")+'" >'+r+" "+t.formulas+" "+r+"</span>",u=e(i)[0];u.onclick=function(){n.currentMathNode=this,l.formulas.value=e(this).attr("formulas"),"true"===e(this).attr("inline")?l.inline.attributes.checked=!0:delete l.inline.attributes.checked,n.openModalInsert(n.lang.mathml,l,a)},n.range.deleteContents(),n.range.insertNode(u)}return n.currentMathNode=!1,MathJax.Hub.Queue(["Typeset",MathJax.Hub]),!0};l.formulas.value=n.getRangeText(),l.inline.attributes.checked=!0,n.openModalInsert(n.lang.mathml,l,a)}};n.addBtnDef("mathml",l)}}}})}(jQuery);
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Trumbowyg v2.
|
2
|
+
* Trumbowyg v2.21.0 - A lightweight WYSIWYG editor
|
3
3
|
* Default stylesheet for Trumbowyg editor plugin
|
4
4
|
* ------------------------
|
5
5
|
* @link http://alex-d.github.io/Trumbowyg
|
@@ -10,7 +10,6 @@
|
|
10
10
|
*/
|
11
11
|
|
12
12
|
.mathMlContainer {
|
13
|
-
|
14
13
|
position: relative;
|
15
14
|
|
16
15
|
&[inline="false"] {
|
@@ -20,17 +19,18 @@
|
|
20
19
|
|
21
20
|
&:hover {
|
22
21
|
pointer-events: none;
|
23
|
-
|
22
|
+
|
23
|
+
&::after {
|
24
24
|
content: '\270E';
|
25
|
-
pointer-events: auto;
|
26
25
|
position: absolute;
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
top: 0;
|
27
|
+
right: 0;
|
28
|
+
bottom: 0;
|
29
|
+
left: 0;
|
30
|
+
background-color: rgba(255, 255, 255, 0.83);
|
31
|
+
box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83);
|
30
32
|
cursor: pointer;
|
31
|
-
|
32
|
-
right: 0px;
|
33
|
-
box-shadow: 0 0 5px 5px #ffffffd4;
|
33
|
+
pointer-events: auto;
|
34
34
|
}
|
35
35
|
}
|
36
36
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Trumbowyg v2.
|
2
|
+
* Trumbowyg v2.21.0 - A lightweight WYSIWYG editor
|
3
3
|
* Trumbowyg plugin stylesheet
|
4
4
|
* ------------------------
|
5
5
|
* @link http://alex-d.github.io/Trumbowyg
|
@@ -16,14 +16,14 @@
|
|
16
16
|
width: 100%; }
|
17
17
|
.mathMlContainer:hover {
|
18
18
|
pointer-events: none; }
|
19
|
-
.mathMlContainer:hover
|
19
|
+
.mathMlContainer:hover::after {
|
20
20
|
content: '\270E';
|
21
|
-
pointer-events: auto;
|
22
21
|
position: absolute;
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
top: 0;
|
23
|
+
right: 0;
|
24
|
+
bottom: 0;
|
25
|
+
left: 0;
|
26
|
+
background-color: rgba(255, 255, 255, 0.83);
|
27
|
+
box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83);
|
26
28
|
cursor: pointer;
|
27
|
-
|
28
|
-
right: 0px;
|
29
|
-
box-shadow: 0 0 5px 5px #ffffffd4; }
|
29
|
+
pointer-events: auto; }
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
/** Trumbowyg v2.
|
2
|
-
.mathMlContainer{position:relative}.mathMlContainer[inline=false]{display:block;width:100%}.mathMlContainer:hover{pointer-events:none}.mathMlContainer:hover
|
1
|
+
/** Trumbowyg v2.21.0 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */
|
2
|
+
.mathMlContainer{position:relative}.mathMlContainer[inline=false]{display:block;width:100%}.mathMlContainer:hover{pointer-events:none}.mathMlContainer:hover::after{content:'\270E';position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(255,255,255,.83);box-shadow:0 0 5px 5px rgba(255,255,255,.83);cursor:pointer;pointer-events:auto}
|
@@ -12,13 +12,14 @@
|
|
12
12
|
'use strict';
|
13
13
|
|
14
14
|
var defaultOptions = {
|
15
|
-
source:
|
15
|
+
source: [],
|
16
16
|
formatDropdownItem: formatDropdownItem,
|
17
17
|
formatResult: formatResult
|
18
18
|
};
|
19
19
|
|
20
20
|
$.extend(true, $.trumbowyg, {
|
21
21
|
langs: {
|
22
|
+
// jshint camelcase:false
|
22
23
|
en: {
|
23
24
|
mention: 'Mention'
|
24
25
|
},
|
@@ -26,7 +27,7 @@
|
|
26
27
|
mention: 'Nævn'
|
27
28
|
},
|
28
29
|
fr: {
|
29
|
-
mention: '
|
30
|
+
mention: 'Mentionner'
|
30
31
|
},
|
31
32
|
ru: {
|
32
33
|
mention: 'Упомянуть'
|
@@ -37,6 +38,13 @@
|
|
37
38
|
zh_tw: {
|
38
39
|
mention: '標記'
|
39
40
|
},
|
41
|
+
pt_br: {
|
42
|
+
mention: 'Menção'
|
43
|
+
},
|
44
|
+
ko: {
|
45
|
+
mention: '언급'
|
46
|
+
},
|
47
|
+
// jshint camelcase:true
|
40
48
|
},
|
41
49
|
|
42
50
|
plugins: {
|
@@ -57,32 +65,29 @@
|
|
57
65
|
/**
|
58
66
|
* Build dropdown list
|
59
67
|
*
|
60
|
-
* @param
|
61
|
-
* @param
|
68
|
+
* @param {Array} items Items
|
69
|
+
* @param {object} trumbowyg Editor
|
62
70
|
*
|
63
|
-
* @return
|
71
|
+
* @return {Array}
|
64
72
|
*/
|
65
73
|
function buildDropdown(items, trumbowyg) {
|
66
74
|
var dropdown = [];
|
67
75
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
fn: function () {
|
76
|
-
trumbowyg.execCmd('insertHTML', trumbowyg.o.plugins.mention.formatResult(item));
|
76
|
+
$.each(items, function (i, item) {
|
77
|
+
var btn = 'mention-' + i,
|
78
|
+
btnDef = {
|
79
|
+
hasIcon: false,
|
80
|
+
text: trumbowyg.o.plugins.mention.formatDropdownItem(item),
|
81
|
+
fn: function () {
|
82
|
+
trumbowyg.execCmd('insertHTML', trumbowyg.o.plugins.mention.formatResult(item));
|
77
83
|
|
78
|
-
|
79
|
-
|
80
|
-
|
84
|
+
return true;
|
85
|
+
}
|
86
|
+
};
|
81
87
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}
|
88
|
+
trumbowyg.addBtnDef(btn, btnDef);
|
89
|
+
dropdown.push(btn);
|
90
|
+
});
|
86
91
|
|
87
92
|
return dropdown;
|
88
93
|
}
|
@@ -1 +1 @@
|
|
1
|
-
!function(n){"use strict";function t(t,o){var e=[];return
|
1
|
+
!function(n){"use strict";function t(t,o){var e=[];return n.each(t,function(n,t){var i="mention-"+n,r={hasIcon:!1,text:o.o.plugins.mention.formatDropdownItem(t),fn:function(){return o.execCmd("insertHTML",o.o.plugins.mention.formatResult(t)),!0}};o.addBtnDef(i,r),e.push(i)}),e}function o(n){return n.login}function e(n){return"@"+n.login+" "}var i={source:[],formatDropdownItem:o,formatResult:e};n.extend(!0,n.trumbowyg,{langs:{en:{mention:"Mention"},da:{mention:"Nævn"},fr:{mention:"Mentionner"},ru:{mention:"Упомянуть"},tr:{mention:"Bahset"},zh_tw:{mention:"標記"},pt_br:{mention:"Menção"},ko:{mention:"언급"}},plugins:{mention:{init:function(o){o.o.plugins.mention=n.extend(!0,{},i,o.o.plugins.mention||{});var e={dropdown:t(o.o.plugins.mention.source,o)};o.addBtnDef("mention",e)}}}})}(jQuery);
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Trumbowyg v2.
|
2
|
+
* Trumbowyg v2.21.0 - A lightweight WYSIWYG editor
|
3
3
|
* Default stylesheet for Trumbowyg editor plugin
|
4
4
|
* ------------------------
|
5
5
|
* @link http://alex-d.github.io/Trumbowyg
|
@@ -10,16 +10,6 @@
|
|
10
10
|
*/
|
11
11
|
|
12
12
|
.trumbowyg-dropdown-mention {
|
13
|
-
height: calc(75%);
|
14
|
-
width: 300px;
|
15
|
-
max-width: 300px;
|
16
|
-
overflow-y: scroll;
|
17
|
-
overflow-x: hidden;
|
18
|
-
|
19
|
-
svg {
|
20
|
-
display: none !important;
|
21
|
-
}
|
22
|
-
|
23
13
|
button {
|
24
14
|
position: relative;
|
25
15
|
white-space: nowrap;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Trumbowyg v2.
|
2
|
+
* Trumbowyg v2.21.0 - A lightweight WYSIWYG editor
|
3
3
|
* Trumbowyg plugin stylesheet
|
4
4
|
* ------------------------
|
5
5
|
* @link http://alex-d.github.io/Trumbowyg
|
@@ -9,24 +9,16 @@
|
|
9
9
|
* Website : alex-d.fr
|
10
10
|
*/
|
11
11
|
|
12
|
-
.trumbowyg-dropdown-mention {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
position: absolute;
|
26
|
-
top: 0;
|
27
|
-
right: 0;
|
28
|
-
width: 15%;
|
29
|
-
height: 100%;
|
30
|
-
background-size: 100%;
|
31
|
-
background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%);
|
32
|
-
pointer-events: none; }
|
12
|
+
.trumbowyg-dropdown-mention button {
|
13
|
+
position: relative;
|
14
|
+
white-space: nowrap; }
|
15
|
+
.trumbowyg-dropdown-mention button:after {
|
16
|
+
content: "";
|
17
|
+
position: absolute;
|
18
|
+
top: 0;
|
19
|
+
right: 0;
|
20
|
+
width: 15%;
|
21
|
+
height: 100%;
|
22
|
+
background-size: 100%;
|
23
|
+
background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%);
|
24
|
+
pointer-events: none; }
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
/** Trumbowyg v2.
|
2
|
-
.trumbowyg-dropdown-mention
|
1
|
+
/** Trumbowyg v2.21.0 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */
|
2
|
+
.trumbowyg-dropdown-mention button{position:relative;white-space:nowrap}.trumbowyg-dropdown-mention button:after{content:"";position:absolute;top:0;right:0;width:15%;height:100%;background-size:100%;background-image:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 80%,#fff 100%);pointer-events:none}
|
@@ -19,6 +19,7 @@
|
|
19
19
|
|
20
20
|
$.extend(true, $.trumbowyg, {
|
21
21
|
langs: {
|
22
|
+
// jshint camelcase:false
|
22
23
|
en: {
|
23
24
|
noembed: 'Noembed',
|
24
25
|
noembedError: 'Error'
|
@@ -48,6 +49,15 @@
|
|
48
49
|
noembed: '插入影片',
|
49
50
|
noembedError: '錯誤'
|
50
51
|
},
|
52
|
+
pt_br: {
|
53
|
+
noembed: 'Incorporar',
|
54
|
+
noembedError: 'Erro'
|
55
|
+
},
|
56
|
+
ko: {
|
57
|
+
noembed: 'oEmbed 넣기',
|
58
|
+
noembedError: '에러'
|
59
|
+
},
|
60
|
+
// jshint camelcase:true
|
51
61
|
},
|
52
62
|
|
53
63
|
plugins: {
|
@@ -108,4 +118,4 @@
|
|
108
118
|
}
|
109
119
|
}
|
110
120
|
});
|
111
|
-
})(jQuery);
|
121
|
+
})(jQuery);
|
@@ -1 +1 @@
|
|
1
|
-
!function(e){"use strict";var r={proxy:"https://noembed.com/embed?nowrap=on",urlFiled:"url",data:[],success:void 0,error:void 0};e.extend(!0,e.trumbowyg,{langs:{en:{noembed:"Noembed",noembedError:"Error"},da:{noembedError:"Fejl"},sk:{noembedError:"Chyba"},fr:{noembedError:"Erreur"},cs:{noembedError:"Chyba"},ru:{noembedError:"Ошибка"},ja:{noembedError:"エラー"},tr:{noembedError:"Hata"},zh_tw:{noembed:"插入影片",noembedError:"錯誤"}},plugins:{noembed:{init:function(o){o.o.plugins.noembed=e.extend(!0,{},r,o.o.plugins.noembed||{});var n={fn:function(){var r=o.openModalInsert(o.lang.noembed,{url:{label:"URL",required:!0}},function(n){e.ajax({url:o.o.plugins.noembed.proxy,type:"GET",data:n,cache:!1,dataType:"json",success:o.o.plugins.noembed.success||function(n){n.html?(o.execCmd("insertHTML",n.html),setTimeout(function(){o.closeModal()},250)):o.addErrorOnModalField(e("input[type=text]",r),n.error)},error:o.o.plugins.noembed.error||function(){o.addErrorOnModalField(e("input[type=text]",r),o.lang.noembedError)}})})}};o.addBtnDef("noembed",n)}}}})}(jQuery);
|
1
|
+
!function(e){"use strict";var r={proxy:"https://noembed.com/embed?nowrap=on",urlFiled:"url",data:[],success:void 0,error:void 0};e.extend(!0,e.trumbowyg,{langs:{en:{noembed:"Noembed",noembedError:"Error"},da:{noembedError:"Fejl"},sk:{noembedError:"Chyba"},fr:{noembedError:"Erreur"},cs:{noembedError:"Chyba"},ru:{noembedError:"Ошибка"},ja:{noembedError:"エラー"},tr:{noembedError:"Hata"},zh_tw:{noembed:"插入影片",noembedError:"錯誤"},pt_br:{noembed:"Incorporar",noembedError:"Erro"},ko:{noembed:"oEmbed 넣기",noembedError:"에러"}},plugins:{noembed:{init:function(o){o.o.plugins.noembed=e.extend(!0,{},r,o.o.plugins.noembed||{});var n={fn:function(){var r=o.openModalInsert(o.lang.noembed,{url:{label:"URL",required:!0}},function(n){e.ajax({url:o.o.plugins.noembed.proxy,type:"GET",data:n,cache:!1,dataType:"json",success:o.o.plugins.noembed.success||function(n){n.html?(o.execCmd("insertHTML",n.html),setTimeout(function(){o.closeModal()},250)):o.addErrorOnModalField(e("input[type=text]",r),n.error)},error:o.o.plugins.noembed.error||function(){o.addErrorOnModalField(e("input[type=text]",r),o.lang.noembedError)}})})}};o.addBtnDef("noembed",n)}}}})}(jQuery);
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
trumbowyg.pasteHandlers.push(function (pasteEvent) {
|
19
19
|
try {
|
20
20
|
var items = (pasteEvent.originalEvent || pasteEvent).clipboardData.items,
|
21
|
+
mustPreventDefault = false,
|
21
22
|
reader;
|
22
23
|
|
23
24
|
for (var i = items.length - 1; i >= 0; i -= 1) {
|
@@ -25,12 +26,19 @@
|
|
25
26
|
reader = new FileReader();
|
26
27
|
/* jshint -W083 */
|
27
28
|
reader.onloadend = function (event) {
|
28
|
-
trumbowyg.execCmd('insertImage', event.target.result,
|
29
|
+
trumbowyg.execCmd('insertImage', event.target.result, false, true);
|
29
30
|
};
|
30
31
|
/* jshint +W083 */
|
31
32
|
reader.readAsDataURL(items[i].getAsFile());
|
33
|
+
|
34
|
+
mustPreventDefault = true;
|
32
35
|
}
|
33
36
|
}
|
37
|
+
|
38
|
+
if (mustPreventDefault) {
|
39
|
+
pasteEvent.stopPropagation();
|
40
|
+
pasteEvent.preventDefault();
|
41
|
+
}
|
34
42
|
} catch (c) {
|
35
43
|
}
|
36
44
|
});
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e){"use strict";e.extend(!0,e.trumbowyg,{plugins:{pasteImage:{init:function(e){e.pasteHandlers.push(function(t){try{for(var a,n=(t.originalEvent||t).clipboardData.items,i=n.length-1;
|
1
|
+
!function(e){"use strict";e.extend(!0,e.trumbowyg,{plugins:{pasteImage:{init:function(e){e.pasteHandlers.push(function(t){try{for(var a,n=(t.originalEvent||t).clipboardData.items,i=!1,r=n.length-1;r>=0;r-=1)n[r].type.match(/^image\//)&&(a=new FileReader,a.onloadend=function(t){e.execCmd("insertImage",t.target.result,!1,!0)},a.readAsDataURL(n[r].getAsFile()),i=!0);i&&(t.stopPropagation(),t.preventDefault())}catch(o){}})}}}})}(jQuery);
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e){"use strict";function t(){var e,t=null;return window.getSelection?(e=window.getSelection(),e.rangeCount&&(t=e.getRangeAt(0).commonAncestorContainer,1!==t.nodeType&&(t=t.parentNode))):(e=document.selection)&&"Control"!==e.type&&(t=e.createRange().parentElement()),t}function
|
1
|
+
!function(e){"use strict";function t(){var e,t=null;return window.getSelection?(e=window.getSelection(),e.rangeCount&&(t=e.getRangeAt(0).commonAncestorContainer,1!==t.nodeType&&(t=t.parentNode))):(e=document.selection)&&"Control"!==e.type&&(t=e.createRange().parentElement()),t}function r(e){var t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText||""}function n(){var t=null;if(document.selection)t=document.selection.createRange().parentElement();else{var r=window.getSelection();r.rangeCount>0&&(t=r.getRangeAt(0).startContainer.parentNode)}var n=e(t).contents().closest("pre").length,o=e(t).contents().closest("code").length;n&&o?e(t).contents().unwrap("code").unwrap("pre"):n?e(t).contents().unwrap("pre"):o&&e(t).contents().unwrap("code")}e.extend(!0,e.trumbowyg,{langs:{en:{preformatted:"Code sample <pre>"},da:{preformatted:"Præformateret <pre>"},fr:{preformatted:"Exemple de code <pre>"},it:{preformatted:"Codice <pre>"},zh_cn:{preformatted:"代码示例 <pre>"},ru:{preformatted:"Пример кода <pre>"},ja:{preformatted:"コードサンプル <pre>"},tr:{preformatted:"Kod örneği <pre>"},zh_tw:{preformatted:"代碼範例 <pre>"},pt_br:{preformatted:"Exemple de código <pre>"},ko:{preformatted:"코드 예제 <pre>"}},plugins:{preformatted:{init:function(e){var o={fn:function(){e.saveRange();var o=e.getRangeText();if(""!==o.replace(/\s/g,""))try{var a=t().tagName.toLowerCase();if("code"===a||"pre"===a)return n();e.execCmd("insertHTML","<pre><code>"+r(o)+"</code></pre>")}catch(p){}},tag:"pre"};e.addBtnDef("preformatted",o)}}}})}(jQuery);
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/resizable-resolveconflict.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
(function (factory, define, require, module) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
if (typeof define === 'function' && define.amd) {
|
5
|
+
// AMD
|
6
|
+
define(['jquery'], factory);
|
7
|
+
} else if (typeof module === 'object' && typeof module.exports === 'object') {
|
8
|
+
// CommonJS
|
9
|
+
module.exports = factory(require('jquery'));
|
10
|
+
} else {
|
11
|
+
// Global jQuery
|
12
|
+
factory(jQuery);
|
13
|
+
}
|
14
|
+
}(function ($) {
|
15
|
+
'use strict';
|
16
|
+
|
17
|
+
// rename to avoid conflict with jquery-resizable
|
18
|
+
$.fn.uiresizable = $.fn.resizable;
|
19
|
+
delete $.fn.resizable;
|
20
|
+
}));
|
data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/resizable-resolveconflict.min.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
!function(e,t,o,r){"use strict";"function"==typeof t&&t.amd?t(["jquery"],e):"object"==typeof r&&"object"==typeof r.exports?r.exports=e(o("jquery")):e(jQuery)}(function(e){"use strict";e.fn.uiresizable=e.fn.resizable,delete e.fn.resizable});
|
@@ -1,4 +1,4 @@
|
|
1
|
-
(function ($) {
|
1
|
+
;(function ($) {
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
var defaultOptions = {
|
@@ -6,10 +6,206 @@
|
|
6
6
|
step: 4
|
7
7
|
};
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
function preventDefault(e) {
|
10
|
+
e.stopPropagation();
|
11
|
+
e.preventDefault();
|
12
|
+
}
|
13
|
+
|
14
|
+
var ResizeWithCanvas = function () {
|
15
|
+
// variable to create canvas and save img in resize mode
|
16
|
+
this.resizeCanvas = document.createElement('canvas');
|
17
|
+
// to allow canvas to get focus
|
18
|
+
this.resizeCanvas.setAttribute('tabindex', '0');
|
19
|
+
this.resizeCanvas.id = 'trumbowyg-resizimg-' + (+new Date());
|
20
|
+
this.ctx = null;
|
21
|
+
this.resizeImg = null;
|
22
|
+
|
23
|
+
this.pressEscape = function (obj) {
|
24
|
+
obj.reset();
|
25
|
+
};
|
26
|
+
this.pressBackspaceOrDelete = function (obj) {
|
27
|
+
$(obj.resizeCanvas).replaceWith('');
|
28
|
+
obj.resizeImg = null;
|
29
|
+
};
|
30
|
+
|
31
|
+
// PRIVATE FUNCTION
|
32
|
+
var focusedNow = false;
|
33
|
+
var isCursorSeResize = false;
|
34
|
+
|
35
|
+
// calculate offset to change mouse over square in the canvas
|
36
|
+
var offsetX, offsetY;
|
37
|
+
var reOffset = function (canvas) {
|
38
|
+
var BB = canvas.getBoundingClientRect();
|
39
|
+
offsetX = BB.left;
|
40
|
+
offsetY = BB.top;
|
41
|
+
};
|
42
|
+
|
43
|
+
var drawRect = function (shapeData, ctx) {
|
44
|
+
// Inner
|
45
|
+
ctx.beginPath();
|
46
|
+
ctx.fillStyle = 'rgb(255, 255, 255)';
|
47
|
+
ctx.rect(shapeData.points.x, shapeData.points.y, shapeData.points.width, shapeData.points.height);
|
48
|
+
ctx.fill();
|
49
|
+
ctx.stroke();
|
50
|
+
};
|
51
|
+
|
52
|
+
var updateCanvas = function (canvas, ctx, img, canvasWidth, canvasHeight) {
|
53
|
+
ctx.translate(0.5, 0.5);
|
54
|
+
ctx.lineWidth = 1;
|
55
|
+
|
56
|
+
// image
|
57
|
+
ctx.drawImage(img, 5, 5, canvasWidth - 10, canvasHeight - 10);
|
58
|
+
|
59
|
+
// border
|
60
|
+
ctx.beginPath();
|
61
|
+
ctx.rect(5, 5, canvasWidth - 10, canvasHeight - 10);
|
62
|
+
ctx.stroke();
|
63
|
+
|
64
|
+
// square in the angle
|
65
|
+
ctx.beginPath();
|
66
|
+
ctx.fillStyle = 'rgb(255, 255, 255)';
|
67
|
+
ctx.rect(canvasWidth - 10, canvasHeight - 10, 9, 9);
|
68
|
+
ctx.fill();
|
69
|
+
ctx.stroke();
|
70
|
+
|
71
|
+
// get the offset to change the mouse cursor
|
72
|
+
reOffset(canvas);
|
73
|
+
|
74
|
+
return ctx;
|
75
|
+
};
|
76
|
+
|
77
|
+
// PUBLIC FUNCTION
|
78
|
+
// necessary to correctly print cursor over square. Called once for instance. Useless with trumbowyg.
|
79
|
+
this.init = function () {
|
80
|
+
var _this = this;
|
81
|
+
$(window).on('scroll resize', function () {
|
82
|
+
_this.reCalcOffset();
|
83
|
+
});
|
84
|
+
};
|
85
|
+
|
86
|
+
this.reCalcOffset = function () {
|
87
|
+
reOffset(this.resizeCanvas);
|
88
|
+
};
|
89
|
+
|
90
|
+
this.canvasId = function () {
|
91
|
+
return this.resizeCanvas.id;
|
92
|
+
};
|
93
|
+
|
94
|
+
this.isActive = function () {
|
95
|
+
return this.resizeImg !== null;
|
96
|
+
};
|
97
|
+
|
98
|
+
this.isFocusedNow = function () {
|
99
|
+
return focusedNow;
|
100
|
+
};
|
101
|
+
|
102
|
+
this.blurNow = function () {
|
103
|
+
focusedNow = false;
|
104
|
+
};
|
105
|
+
|
106
|
+
// restore image in the HTML of the editor
|
107
|
+
this.reset = function () {
|
108
|
+
if (this.resizeImg === null) {
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
|
112
|
+
this.resizeImg.width = this.resizeCanvas.clientWidth - 10;
|
113
|
+
this.resizeImg.height = this.resizeCanvas.clientHeight - 10;
|
114
|
+
// clear style of image to avoid issue on resize because this attribute have priority over width and height attribute
|
115
|
+
this.resizeImg.removeAttribute('style');
|
116
|
+
|
117
|
+
$(this.resizeCanvas).replaceWith($(this.resizeImg));
|
118
|
+
|
119
|
+
// reset canvas style
|
120
|
+
this.resizeCanvas.removeAttribute('style');
|
121
|
+
this.resizeImg = null;
|
122
|
+
};
|
123
|
+
|
124
|
+
// setup canvas with points and border to allow the resizing operation
|
125
|
+
this.setup = function (img, resizableOptions) {
|
126
|
+
this.resizeImg = img;
|
127
|
+
|
128
|
+
if (!this.resizeCanvas.getContext) {
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
|
132
|
+
focusedNow = true;
|
133
|
+
|
134
|
+
// draw canvas
|
135
|
+
this.resizeCanvas.width = $(this.resizeImg).width() + 10;
|
136
|
+
this.resizeCanvas.height = $(this.resizeImg).height() + 10;
|
137
|
+
this.resizeCanvas.style.margin = '-5px';
|
138
|
+
this.ctx = this.resizeCanvas.getContext('2d');
|
139
|
+
|
140
|
+
// replace image with canvas
|
141
|
+
$(this.resizeImg).replaceWith($(this.resizeCanvas));
|
142
|
+
|
143
|
+
updateCanvas(this.resizeCanvas, this.ctx, this.resizeImg, this.resizeCanvas.width, this.resizeCanvas.height);
|
144
|
+
|
145
|
+
// enable resize
|
146
|
+
$(this.resizeCanvas).resizable(resizableOptions)
|
147
|
+
.on('mousedown', preventDefault);
|
148
|
+
|
149
|
+
var _this = this;
|
150
|
+
$(this.resizeCanvas)
|
151
|
+
.on('mousemove', function (e) {
|
152
|
+
var mouseX = Math.round(e.clientX - offsetX);
|
153
|
+
var mouseY = Math.round(e.clientY - offsetY);
|
154
|
+
|
155
|
+
var wasCursorSeResize = isCursorSeResize;
|
156
|
+
|
157
|
+
_this.ctx.rect(_this.resizeCanvas.width - 10, _this.resizeCanvas.height - 10, 9, 9);
|
158
|
+
isCursorSeResize = _this.ctx.isPointInPath(mouseX, mouseY);
|
159
|
+
if (wasCursorSeResize !== isCursorSeResize) {
|
160
|
+
this.style.cursor = isCursorSeResize ? 'se-resize' : 'default';
|
161
|
+
}
|
162
|
+
})
|
163
|
+
.on('keydown', function (e) {
|
164
|
+
if (!_this.isActive()) {
|
165
|
+
return;
|
166
|
+
}
|
167
|
+
|
168
|
+
var x = e.keyCode;
|
169
|
+
if (x === 27) { // ESC
|
170
|
+
_this.pressEscape(_this);
|
171
|
+
} else if (x === 8 || x === 46) { // BACKSPACE or DELETE
|
172
|
+
_this.pressBackspaceOrDelete(_this);
|
173
|
+
}
|
174
|
+
})
|
175
|
+
.on('focus', preventDefault);
|
176
|
+
|
177
|
+
this.resizeCanvas.focus();
|
178
|
+
|
179
|
+
return true;
|
180
|
+
};
|
181
|
+
|
182
|
+
// update the canvas after the resizing
|
183
|
+
this.refresh = function () {
|
184
|
+
if (!this.resizeCanvas.getContext) {
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
|
188
|
+
this.resizeCanvas.width = this.resizeCanvas.clientWidth;
|
189
|
+
this.resizeCanvas.height = this.resizeCanvas.clientHeight;
|
190
|
+
updateCanvas(this.resizeCanvas, this.ctx, this.resizeImg, this.resizeCanvas.width, this.resizeCanvas.height);
|
191
|
+
};
|
11
192
|
};
|
12
193
|
|
194
|
+
// object to interact with canvas
|
195
|
+
var resizeWithCanvas = new ResizeWithCanvas();
|
196
|
+
|
197
|
+
function destroyResizable(trumbowyg) {
|
198
|
+
// clean html code
|
199
|
+
trumbowyg.$ed.find('canvas.resizable')
|
200
|
+
.resizable('destroy')
|
201
|
+
.off('mousedown', preventDefault)
|
202
|
+
.removeClass('resizable');
|
203
|
+
|
204
|
+
resizeWithCanvas.reset();
|
205
|
+
|
206
|
+
trumbowyg.syncCode();
|
207
|
+
}
|
208
|
+
|
13
209
|
$.extend(true, $.trumbowyg, {
|
14
210
|
plugins: {
|
15
211
|
resizimg: {
|
@@ -38,30 +234,68 @@
|
|
38
234
|
return false;
|
39
235
|
},
|
40
236
|
onDragEnd: function () {
|
41
|
-
|
237
|
+
// resize update canvas information
|
238
|
+
resizeWithCanvas.refresh();
|
239
|
+
trumbowyg.syncCode();
|
42
240
|
}
|
43
241
|
}
|
44
242
|
}
|
45
243
|
);
|
46
244
|
|
47
245
|
function initResizable() {
|
48
|
-
trumbowyg.$ed.find('img
|
49
|
-
.
|
50
|
-
.on('
|
51
|
-
|
246
|
+
trumbowyg.$ed.find('img')
|
247
|
+
.off('click')
|
248
|
+
.on('click', function (e) {
|
249
|
+
// if I'm already do a resize, reset it
|
250
|
+
if (resizeWithCanvas.isActive()) {
|
251
|
+
resizeWithCanvas.reset();
|
252
|
+
}
|
253
|
+
// initialize resize of image
|
254
|
+
resizeWithCanvas.setup(this, trumbowyg.o.plugins.resizimg.resizable);
|
52
255
|
|
53
|
-
|
54
|
-
|
55
|
-
.resizable('destroy')
|
56
|
-
.off('mousedown', preventDefault);
|
57
|
-
trumbowyg.syncTextarea();
|
256
|
+
preventDefault(e);
|
257
|
+
});
|
58
258
|
}
|
59
259
|
|
60
|
-
trumbowyg.$c.on('tbwinit',
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
260
|
+
trumbowyg.$c.on('tbwinit', function () {
|
261
|
+
initResizable();
|
262
|
+
|
263
|
+
// disable resize when click on other items
|
264
|
+
trumbowyg.$ed.on('click', function (e) {
|
265
|
+
// check if I've clicked out of canvas or image to reset it
|
266
|
+
if ($(e.target).is('img') || e.target.id === resizeWithCanvas.canvasId()) {
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
|
270
|
+
preventDefault(e);
|
271
|
+
resizeWithCanvas.reset();
|
272
|
+
|
273
|
+
// save changes
|
274
|
+
trumbowyg.$c.trigger('tbwchange');
|
275
|
+
});
|
276
|
+
|
277
|
+
trumbowyg.$ed.on('scroll', function () {
|
278
|
+
resizeWithCanvas.reCalcOffset();
|
279
|
+
});
|
280
|
+
});
|
281
|
+
|
282
|
+
trumbowyg.$c.on('tbwfocus tbwchange', initResizable);
|
283
|
+
trumbowyg.$c.on('tbwresize', function () {
|
284
|
+
resizeWithCanvas.reCalcOffset();
|
285
|
+
});
|
286
|
+
|
287
|
+
// Destroy
|
288
|
+
trumbowyg.$c.on('tbwblur', function () {
|
289
|
+
// if I have already focused the canvas avoid destroy
|
290
|
+
if (resizeWithCanvas.isFocusedNow()) {
|
291
|
+
resizeWithCanvas.blurNow();
|
292
|
+
} else {
|
293
|
+
destroyResizable(trumbowyg);
|
294
|
+
}
|
295
|
+
});
|
296
|
+
},
|
297
|
+
destroy: function (trumbowyg) {
|
298
|
+
destroyResizable(trumbowyg);
|
65
299
|
}
|
66
300
|
}
|
67
301
|
}
|