activeadmin_trumbowyg 0.1.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +1 -1
  3. data/README.md +9 -3
  4. data/Rakefile +2 -2
  5. data/app/assets/fonts/trumbowyg/icons.svg +1 -0
  6. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ar.js +67 -0
  7. data/app/assets/javascripts/activeadmin/trumbowyg/langs/bg.js +54 -0
  8. data/app/assets/javascripts/activeadmin/trumbowyg/langs/by.js +61 -0
  9. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ca.js +57 -0
  10. data/app/assets/javascripts/activeadmin/trumbowyg/langs/cs.js +54 -0
  11. data/app/assets/javascripts/activeadmin/trumbowyg/langs/da.js +64 -0
  12. data/app/assets/javascripts/activeadmin/trumbowyg/langs/da.min.js +1 -1
  13. data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.js +57 -0
  14. data/app/assets/javascripts/activeadmin/trumbowyg/langs/de.min.js +1 -1
  15. data/app/assets/javascripts/activeadmin/trumbowyg/langs/el.js +59 -0
  16. data/app/assets/javascripts/activeadmin/trumbowyg/langs/es.js +63 -0
  17. data/app/assets/javascripts/activeadmin/trumbowyg/langs/es_ar.js +56 -0
  18. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fa.js +58 -0
  19. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fa.min.js +1 -1
  20. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fi.js +58 -0
  21. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fr.js +66 -0
  22. data/app/assets/javascripts/activeadmin/trumbowyg/langs/fr.min.js +3 -1
  23. data/app/assets/javascripts/activeadmin/trumbowyg/langs/he.js +57 -0
  24. data/app/assets/javascripts/activeadmin/trumbowyg/langs/hr.js +54 -0
  25. data/app/assets/javascripts/activeadmin/trumbowyg/langs/hu.js +58 -0
  26. data/app/assets/javascripts/activeadmin/trumbowyg/langs/id.js +57 -0
  27. data/app/assets/javascripts/activeadmin/trumbowyg/langs/it.js +59 -0
  28. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ja.js +63 -0
  29. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ko.js +63 -0
  30. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ko.min.js +3 -4
  31. data/app/assets/javascripts/activeadmin/trumbowyg/langs/lt.js +59 -0
  32. data/app/assets/javascripts/activeadmin/trumbowyg/langs/lt.min.js +8 -0
  33. data/app/assets/javascripts/activeadmin/trumbowyg/langs/mn.js +49 -0
  34. data/app/assets/javascripts/activeadmin/trumbowyg/langs/my.js +54 -0
  35. data/app/assets/javascripts/activeadmin/trumbowyg/langs/nl.js +61 -0
  36. data/app/assets/javascripts/activeadmin/trumbowyg/langs/nl.min.js +1 -1
  37. data/app/assets/javascripts/activeadmin/trumbowyg/langs/no_nb.js +56 -0
  38. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ph.js +54 -0
  39. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pl.js +55 -0
  40. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt.js +65 -0
  41. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt_br.js +65 -0
  42. data/app/assets/javascripts/activeadmin/trumbowyg/langs/pt_br.min.js +1 -1
  43. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ro.js +58 -0
  44. data/app/assets/javascripts/activeadmin/trumbowyg/langs/rs.js +53 -0
  45. data/app/assets/javascripts/activeadmin/trumbowyg/langs/rs_latin.js +54 -0
  46. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ru.js +61 -0
  47. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ru.min.js +1 -1
  48. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sk.js +54 -0
  49. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sl.js +48 -0
  50. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sl.min.js +1 -0
  51. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sq.js +65 -0
  52. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sq.min.js +8 -0
  53. data/app/assets/javascripts/activeadmin/trumbowyg/langs/sv.js +58 -0
  54. data/app/assets/javascripts/activeadmin/trumbowyg/langs/th.js +55 -0
  55. data/app/assets/javascripts/activeadmin/trumbowyg/langs/th.min.js +9 -0
  56. data/app/assets/javascripts/activeadmin/trumbowyg/langs/tr.js +55 -0
  57. data/app/assets/javascripts/activeadmin/trumbowyg/langs/ua.js +54 -0
  58. data/app/assets/javascripts/activeadmin/trumbowyg/langs/vi.js +56 -0
  59. data/app/assets/javascripts/activeadmin/trumbowyg/langs/vi.min.js +1 -1
  60. data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_cn.js +57 -0
  61. data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_tw.js +66 -0
  62. data/app/assets/javascripts/activeadmin/trumbowyg/langs/zh_tw.min.js +1 -1
  63. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js +162 -0
  64. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.min.js +1 -0
  65. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +34 -2
  66. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +1 -1
  67. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +29 -97
  68. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +1 -1
  69. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +109 -35
  70. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +1 -1
  71. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +30 -11
  72. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +27 -15
  73. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +2 -2
  74. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +1265 -877
  75. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +1 -1
  76. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss +1 -4
  77. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css +2 -5
  78. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +2 -2
  79. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.js +95 -0
  80. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.min.js +1 -0
  81. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js +257 -0
  82. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/fontsize/trumbowyg.fontsize.min.js +1 -0
  83. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/trumbowyg.giphy.js +182 -0
  84. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/trumbowyg.giphy.min.js +1 -0
  85. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/ui/sass/trumbowyg.giphy.scss +111 -0
  86. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/ui/trumbowyg.giphy.css +90 -0
  87. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/giphy/ui/trumbowyg.giphy.min.css +2 -0
  88. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.js +90 -0
  89. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js +1 -0
  90. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss +25 -0
  91. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css +20 -0
  92. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css +2 -0
  93. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.js +216 -0
  94. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/history/trumbowyg.history.min.js +1 -0
  95. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +19 -2
  96. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +1 -1
  97. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js +162 -0
  98. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js +1 -0
  99. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.js +117 -0
  100. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js +1 -0
  101. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss +36 -0
  102. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css +29 -0
  103. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css +2 -0
  104. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.js +116 -0
  105. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/trumbowyg.mention.min.js +1 -0
  106. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss +29 -0
  107. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.css +24 -0
  108. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css +2 -0
  109. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +21 -1
  110. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +1 -1
  111. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js +96 -0
  112. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js +1 -0
  113. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +10 -2
  114. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +1 -1
  115. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +22 -3
  116. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +1 -1
  117. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/resizable-resolveconflict.js +20 -0
  118. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/resizable-resolveconflict.min.js +1 -0
  119. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js +303 -0
  120. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js +1 -0
  121. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.js +94 -0
  122. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js +1 -0
  123. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/trumbowyg.specialchars.js +79 -0
  124. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/trumbowyg.specialchars.min.js +1 -0
  125. data/app/assets/{stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss → javascripts/activeadmin/trumbowyg/plugins/specialchars/ui/sass/trumbowyg.specialchars.scss} +11 -11
  126. data/app/assets/{stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css → javascripts/activeadmin/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.css} +12 -12
  127. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.min.css +2 -0
  128. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +346 -81
  129. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +1 -1
  130. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss +46 -0
  131. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.css +36 -0
  132. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/table/ui/trumbowyg.table.min.css +2 -0
  133. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +32 -9
  134. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +1 -1
  135. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +58 -23
  136. data/app/assets/javascripts/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +1 -1
  137. data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.js +427 -188
  138. data/app/assets/javascripts/activeadmin/trumbowyg/trumbowyg.min.js +2 -2
  139. data/app/assets/javascripts/activeadmin/trumbowyg_input.js +17 -6
  140. data/app/assets/stylesheets/activeadmin/_trumbowyg_input.scss +67 -0
  141. data/app/assets/stylesheets/activeadmin/trumbowyg/{ui/sass/trumbowyg.scss → trumbowyg.scss} +44 -16
  142. data/lib/activeadmin/trumbowyg.rb +2 -0
  143. data/lib/activeadmin/trumbowyg/engine.rb +2 -0
  144. data/lib/activeadmin/trumbowyg/version.rb +3 -1
  145. data/lib/activeadmin_trumbowyg.rb +2 -1
  146. data/lib/formtastic/inputs/trumbowyg_input.rb +3 -2
  147. data/lib/tasks/trumbowyg.rake +4 -2
  148. metadata +230 -92
  149. data/.gitignore +0 -3
  150. data/Gemfile +0 -4
  151. data/activeadmin_trumbowyg.gemspec +0 -19
  152. data/app/assets/fonts/active_admin-trumbowyg.svg +0 -1
  153. data/app/assets/javascripts/activeadmin/trumbowyg/ui/icons.svg +0 -1
  154. data/app/assets/javascripts/activeadmin/trumbowyg/ui/sass/trumbowyg.scss +0 -796
  155. data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.css +0 -584
  156. data/app/assets/javascripts/activeadmin/trumbowyg/ui/trumbowyg.min.css +0 -2
  157. data/app/assets/stylesheets/activeadmin/_trumbowyg_input.sass +0 -54
  158. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ar.min.js +0 -11
  159. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/bg.min.js +0 -8
  160. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/by.min.js +0 -8
  161. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ca.min.js +0 -11
  162. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/cs.min.js +0 -8
  163. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/da.min.js +0 -9
  164. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/de.min.js +0 -9
  165. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/el.min.js +0 -12
  166. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es.min.js +0 -9
  167. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/es_ar.min.js +0 -10
  168. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fa.min.js +0 -10
  169. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fi.min.js +0 -9
  170. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/fr.min.js +0 -10
  171. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/he.min.js +0 -9
  172. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hr.min.js +0 -9
  173. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/hu.min.js +0 -10
  174. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/id.min.js +0 -11
  175. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/it.min.js +0 -8
  176. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ja.min.js +0 -10
  177. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ko.min.js +0 -10
  178. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/mn.min.js +0 -8
  179. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/my.min.js +0 -8
  180. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/nl.min.js +0 -9
  181. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/no_nb.min.js +0 -10
  182. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ph.min.js +0 -8
  183. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pl.min.js +0 -9
  184. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt.min.js +0 -11
  185. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/pt_br.min.js +0 -11
  186. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ro.min.js +0 -12
  187. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs.min.js +0 -8
  188. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/rs_latin.min.js +0 -9
  189. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ru.min.js +0 -8
  190. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sk.min.js +0 -8
  191. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/sv.min.js +0 -12
  192. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/tr.min.js +0 -9
  193. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/ua.min.js +0 -8
  194. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/vi.min.js +0 -9
  195. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_cn.min.js +0 -11
  196. data/app/assets/stylesheets/activeadmin/trumbowyg/langs/zh_tw.min.js +0 -11
  197. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.js +0 -121
  198. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/base64/trumbowyg.base64.min.js +0 -1
  199. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js +0 -179
  200. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js +0 -1
  201. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.js +0 -176
  202. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/trumbowyg.colors.min.js +0 -1
  203. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss +0 -49
  204. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.css +0 -43
  205. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css +0 -2
  206. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.js +0 -965
  207. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js +0 -1
  208. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css +0 -2
  209. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js +0 -83
  210. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js +0 -1
  211. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.js +0 -101
  212. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js +0 -1
  213. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js +0 -41
  214. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js +0 -1
  215. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js +0 -123
  216. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js +0 -1
  217. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.js +0 -154
  218. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/table/trumbowyg.table.min.js +0 -1
  219. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.js +0 -58
  220. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/template/trumbowyg.template.min.js +0 -1
  221. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.js +0 -242
  222. data/app/assets/stylesheets/activeadmin/trumbowyg/plugins/upload/trumbowyg.upload.min.js +0 -1
  223. data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.js +0 -1688
  224. data/app/assets/stylesheets/activeadmin/trumbowyg/trumbowyg.min.js +0 -2
  225. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/icons.svg +0 -1
  226. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.css +0 -584
  227. data/app/assets/stylesheets/activeadmin/trumbowyg/ui/trumbowyg.min.css +0 -2
  228. data/screenshot.jpg +0 -0
@@ -0,0 +1 @@
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);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Trumbowyg v2.21.0 - 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-mention {
13
+ button {
14
+ position: relative;
15
+ white-space: nowrap;
16
+
17
+ &:after {
18
+ content: "";
19
+ position: absolute;
20
+ top: 0;
21
+ right: 0;
22
+ width: 15%;
23
+ height: 100%;
24
+ background-size: 100%;
25
+ background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%);
26
+ pointer-events: none;
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Trumbowyg v2.21.0 - 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-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; }
@@ -0,0 +1,2 @@
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,10 +19,14 @@
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'
25
26
  },
27
+ da: {
28
+ noembedError: 'Fejl'
29
+ },
26
30
  sk: {
27
31
  noembedError: 'Chyba'
28
32
  },
@@ -37,7 +41,23 @@
37
41
  },
38
42
  ja: {
39
43
  noembedError: 'エラー'
40
- }
44
+ },
45
+ tr: {
46
+ noembedError: 'Hata'
47
+ },
48
+ zh_tw: {
49
+ noembed: '插入影片',
50
+ noembedError: '錯誤'
51
+ },
52
+ pt_br: {
53
+ noembed: 'Incorporar',
54
+ noembedError: 'Erro'
55
+ },
56
+ ko: {
57
+ noembed: 'oEmbed 넣기',
58
+ noembedError: '에러'
59
+ },
60
+ // jshint camelcase:true
41
61
  },
42
62
 
43
63
  plugins: {
@@ -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"},sk:{noembedError:"Chyba"},fr:{noembedError:"Erreur"},cs:{noembedError:"Chyba"},ru:{noembedError:"Ошибка"},ja:{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);
@@ -0,0 +1,96 @@
1
+ /* ===========================================================
2
+ * trumbowyg.pasteembed.js v1.0
3
+ * Url paste to iframe with noembed. Plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Max Seelig
7
+ * Facebook : https://facebook.com/maxse
8
+ * Website : https://www.maxmade.nl/
9
+ */
10
+
11
+ (function($) {
12
+ 'use strict';
13
+
14
+ var defaultOptions = {
15
+ enabled: true,
16
+ endpoints: [
17
+ 'https://noembed.com/embed?nowrap=on',
18
+ 'https://api.maxmade.nl/url2iframe/embed'
19
+ ]
20
+ };
21
+
22
+ $.extend(true, $.trumbowyg, {
23
+ plugins: {
24
+ pasteEmbed: {
25
+ init: function(trumbowyg) {
26
+ trumbowyg.o.plugins.pasteEmbed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.pasteEmbed || {});
27
+
28
+ if (!trumbowyg.o.plugins.pasteEmbed.enabled) {
29
+ return;
30
+ }
31
+
32
+ trumbowyg.pasteHandlers.push(function(pasteEvent) {
33
+ try {
34
+ var clipboardData = (pasteEvent.originalEvent || pasteEvent).clipboardData,
35
+ pastedData = clipboardData.getData('Text'),
36
+ endpoints = trumbowyg.o.plugins.pasteEmbed.endpoints,
37
+ request = null;
38
+
39
+ if (pastedData.startsWith('http')) {
40
+ pasteEvent.stopPropagation();
41
+ pasteEvent.preventDefault();
42
+
43
+ var query = {
44
+ url: pastedData.trim()
45
+ };
46
+ var content = '';
47
+ var index = 0;
48
+
49
+ if (request && request.transport) {
50
+ request.transport.abort();
51
+ }
52
+
53
+ request = $.ajax({
54
+ crossOrigin: true,
55
+ url: endpoints[index],
56
+ type: 'GET',
57
+ data: query,
58
+ cache: false,
59
+ dataType: 'jsonp',
60
+ success: function(res) {
61
+ if (res.html) {
62
+ index = 0;
63
+ content = res.html;
64
+ } else {
65
+ index += 1;
66
+ }
67
+ },
68
+ error: function() {
69
+ index += 1;
70
+ },
71
+ complete: function() {
72
+ if (content.length === 0 && index < endpoints.length - 1) {
73
+ this.url = endpoints[index];
74
+ this.data = query;
75
+ $.ajax(this);
76
+ }
77
+ if (index === endpoints.length - 1) {
78
+ content = $('<a>', {
79
+ href: pastedData,
80
+ text: pastedData
81
+ }).prop('outerHTML');
82
+ }
83
+ if (content.length > 0) {
84
+ index = 0;
85
+ trumbowyg.execCmd('insertHTML', content);
86
+ }
87
+ }
88
+ });
89
+ }
90
+ } catch (c) {}
91
+ });
92
+ }
93
+ }
94
+ }
95
+ });
96
+ })(jQuery);
@@ -0,0 +1 @@
1
+ !function(t){"use strict";var e={enabled:!0,endpoints:["https://noembed.com/embed?nowrap=on","https://api.maxmade.nl/url2iframe/embed"]};t.extend(!0,t.trumbowyg,{plugins:{pasteEmbed:{init:function(n){n.o.plugins.pasteEmbed=t.extend(!0,{},e,n.o.plugins.pasteEmbed||{}),n.o.plugins.pasteEmbed.enabled&&n.pasteHandlers.push(function(e){try{var a=(e.originalEvent||e).clipboardData,r=a.getData("Text"),s=n.o.plugins.pasteEmbed.endpoints,i=null;if(r.startsWith("http")){e.stopPropagation(),e.preventDefault();var o={url:r.trim()},p="",l=0;i&&i.transport&&i.transport.abort(),i=t.ajax({crossOrigin:!0,url:s[l],type:"GET",data:o,cache:!1,dataType:"jsonp",success:function(t){t.html?(l=0,p=t.html):l+=1},error:function(){l+=1},complete:function(){0===p.length&&l<s.length-1&&(this.url=s[l],this.data=o,t.ajax(this)),l===s.length-1&&(p=t("<a>",{href:r,text:r}).prop("outerHTML")),p.length>0&&(l=0,n.execCmd("insertHTML",p))}})}}catch(u){}})}}}})}(jQuery);
@@ -18,19 +18,27 @@
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
- for (var i = items.length -1; i >= 0; i += 1) {
24
+ for (var i = items.length - 1; i >= 0; i -= 1) {
24
25
  if (items[i].type.match(/^image\//)) {
25
26
  reader = new FileReader();
26
27
  /* jshint -W083 */
27
28
  reader.onloadend = function (event) {
28
- trumbowyg.execCmd('insertImage', event.target.result, undefined, true);
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
  });
@@ -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;i>=0;i+=1)n[i].type.match(/^image\//)&&(a=new FileReader,a.onloadend=function(t){e.execCmd("insertImage",t.target.result,void 0,!0)},a.readAsDataURL(n[i].getAsFile()))}catch(r){}})}}}})}(jQuery);
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);
@@ -16,8 +16,11 @@
16
16
  en: {
17
17
  preformatted: 'Code sample <pre>'
18
18
  },
19
+ da: {
20
+ preformatted: 'Præformateret <pre>'
21
+ },
19
22
  fr: {
20
- preformatted: 'Exemple de code'
23
+ preformatted: 'Exemple de code <pre>'
21
24
  },
22
25
  it: {
23
26
  preformatted: 'Codice <pre>'
@@ -30,7 +33,19 @@
30
33
  },
31
34
  ja: {
32
35
  preformatted: 'コードサンプル <pre>'
33
- }
36
+ },
37
+ tr: {
38
+ preformatted: 'Kod örneği <pre>'
39
+ },
40
+ zh_tw: {
41
+ preformatted: '代碼範例 <pre>'
42
+ },
43
+ pt_br: {
44
+ preformatted: 'Exemple de código <pre>'
45
+ },
46
+ ko: {
47
+ preformatted: '코드 예제 <pre>'
48
+ },
34
49
  },
35
50
  // jshint camelcase:true
36
51
 
@@ -69,6 +84,7 @@
69
84
  function getSelectionParentElement() {
70
85
  var parentEl = null,
71
86
  selection;
87
+
72
88
  if (window.getSelection) {
73
89
  selection = window.getSelection();
74
90
  if (selection.rangeCount) {
@@ -80,6 +96,7 @@
80
96
  } else if ((selection = document.selection) && selection.type !== 'Control') {
81
97
  parentEl = selection.createRange().parentElement();
82
98
  }
99
+
83
100
  return parentEl;
84
101
  }
85
102
 
@@ -100,6 +117,7 @@
100
117
  */
101
118
  function unwrapCode() {
102
119
  var container = null;
120
+
103
121
  if (document.selection) { //for IE
104
122
  container = document.selection.createRange().parentElement();
105
123
  } else {
@@ -108,9 +126,11 @@
108
126
  container = select.getRangeAt(0).startContainer.parentNode;
109
127
  }
110
128
  }
129
+
111
130
  //'paranoic' unwrap
112
131
  var ispre = $(container).contents().closest('pre').length;
113
132
  var iscode = $(container).contents().closest('code').length;
133
+
114
134
  if (ispre && iscode) {
115
135
  $(container).contents().unwrap('code').unwrap('pre');
116
136
  } else if (ispre) {
@@ -119,5 +139,4 @@
119
139
  $(container).contents().unwrap('code');
120
140
  }
121
141
  }
122
-
123
142
  })(jQuery);
@@ -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 n(e){var t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText||""}function r(){var t=null;if(document.selection)t=document.selection.createRange().parentElement();else{var n=window.getSelection();n.rangeCount>0&&(t=n.getRangeAt(0).startContainer.parentNode)}var r=e(t).contents().closest("pre").length,o=e(t).contents().closest("code").length;r&&o?e(t).contents().unwrap("code").unwrap("pre"):r?e(t).contents().unwrap("pre"):o&&e(t).contents().unwrap("code")}e.extend(!0,e.trumbowyg,{langs:{en:{preformatted:"Code sample <pre>"},fr:{preformatted:"Exemple de code"},it:{preformatted:"Codice <pre>"},zh_cn:{preformatted:"代码示例 <pre>"},ru:{preformatted:"Пример кода <pre>"},ja:{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 r();e.execCmd("insertHTML","<pre><code>"+n(o)+"</code></pre>")}catch(c){}},tag:"pre"};e.addBtnDef("preformatted",o)}}}})}(jQuery);
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);
@@ -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
+ }));
@@ -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});
@@ -0,0 +1,303 @@
1
+ ;(function ($) {
2
+ 'use strict';
3
+
4
+ var defaultOptions = {
5
+ minSize: 32,
6
+ step: 4
7
+ };
8
+
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
+ };
192
+ };
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
+
209
+ $.extend(true, $.trumbowyg, {
210
+ plugins: {
211
+ resizimg: {
212
+ init: function (trumbowyg) {
213
+ trumbowyg.o.plugins.resizimg = $.extend(true, {},
214
+ defaultOptions,
215
+ trumbowyg.o.plugins.resizimg || {},
216
+ {
217
+ resizable: {
218
+ resizeWidth: false,
219
+ onDragStart: function (ev, $el) {
220
+ var opt = trumbowyg.o.plugins.resizimg;
221
+ var x = ev.pageX - $el.offset().left;
222
+ var y = ev.pageY - $el.offset().top;
223
+ if (x < $el.width() - opt.minSize || y < $el.height() - opt.minSize) {
224
+ return false;
225
+ }
226
+ },
227
+ onDrag: function (ev, $el, newWidth, newHeight) {
228
+ var opt = trumbowyg.o.plugins.resizimg;
229
+ if (newHeight < opt.minSize) {
230
+ newHeight = opt.minSize;
231
+ }
232
+ newHeight -= newHeight % opt.step;
233
+ $el.height(newHeight);
234
+ return false;
235
+ },
236
+ onDragEnd: function () {
237
+ // resize update canvas information
238
+ resizeWithCanvas.refresh();
239
+ trumbowyg.syncCode();
240
+ }
241
+ }
242
+ }
243
+ );
244
+
245
+ function initResizable() {
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);
255
+
256
+ preventDefault(e);
257
+ });
258
+ }
259
+
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);
299
+ }
300
+ }
301
+ }
302
+ });
303
+ })(jQuery);