xmt_froala 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +2 -0
  5. data/app/assets/javascripts/xmt_froala.js +31 -0
  6. data/app/assets/stylesheets/xmt_froala.css +17 -0
  7. data/app/controllers/xmt_froala/application_controller.rb +5 -0
  8. data/app/controllers/xmt_froala/assets_controller.rb +94 -0
  9. data/app/models/xmt_froala/asset_uploader.rb +107 -0
  10. data/app/models/xmt_froala/file_uploader.rb +10 -0
  11. data/app/models/xmt_froala/flash_uploader.rb +10 -0
  12. data/app/models/xmt_froala/image_uploader.rb +10 -0
  13. data/app/models/xmt_froala/media_uploader.rb +10 -0
  14. data/config/routes.rb +6 -0
  15. data/lib/generators/xmt_froala/install/USAGE +10 -0
  16. data/lib/generators/xmt_froala/install/install_generator.rb +23 -0
  17. data/lib/generators/xmt_froala/install/templates/application.js +17 -0
  18. data/lib/generators/xmt_froala/install/templates/xmt_froala.rb +29 -0
  19. data/lib/generators/xmt_froala/migration/USAGE +14 -0
  20. data/lib/generators/xmt_froala/migration/migration_generator.rb +36 -0
  21. data/lib/generators/xmt_froala/migration/templates/migration/migration.rb +18 -0
  22. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/asset.rb +14 -0
  23. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/file.rb +3 -0
  24. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/flash.rb +3 -0
  25. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/image.rb +3 -0
  26. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/media.rb +3 -0
  27. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/asset.rb +27 -0
  28. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/file.rb +3 -0
  29. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/flash.rb +3 -0
  30. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/image.rb +3 -0
  31. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/media.rb +3 -0
  32. data/lib/tasks/xmt_froala_tasks.rake +9 -0
  33. data/lib/xmt_froala.rb +65 -0
  34. data/lib/xmt_froala/active_record.rb +14 -0
  35. data/lib/xmt_froala/engine.rb +32 -0
  36. data/lib/xmt_froala/formtastic.rb +12 -0
  37. data/lib/xmt_froala/helper.rb +105 -0
  38. data/lib/xmt_froala/simple_form.rb +11 -0
  39. data/lib/xmt_froala/version.rb +3 -0
  40. data/vendor/assets/javascripts/xmt_froala/froala_editor.js +0 -0
  41. data/vendor/assets/javascripts/xmt_froala/languages/ar.js +318 -0
  42. data/vendor/assets/javascripts/xmt_froala/languages/bs.js +318 -0
  43. data/vendor/assets/javascripts/xmt_froala/languages/cs.js +318 -0
  44. data/vendor/assets/javascripts/xmt_froala/languages/da.js +318 -0
  45. data/vendor/assets/javascripts/xmt_froala/languages/de.js +318 -0
  46. data/vendor/assets/javascripts/xmt_froala/languages/en_ca.js +262 -0
  47. data/vendor/assets/javascripts/xmt_froala/languages/en_gb.js +262 -0
  48. data/vendor/assets/javascripts/xmt_froala/languages/es.js +318 -0
  49. data/vendor/assets/javascripts/xmt_froala/languages/et.js +318 -0
  50. data/vendor/assets/javascripts/xmt_froala/languages/fa.js +318 -0
  51. data/vendor/assets/javascripts/xmt_froala/languages/fi.js +318 -0
  52. data/vendor/assets/javascripts/xmt_froala/languages/fr.js +318 -0
  53. data/vendor/assets/javascripts/xmt_froala/languages/he.js +318 -0
  54. data/vendor/assets/javascripts/xmt_froala/languages/hr.js +318 -0
  55. data/vendor/assets/javascripts/xmt_froala/languages/hu.js +318 -0
  56. data/vendor/assets/javascripts/xmt_froala/languages/id.js +319 -0
  57. data/vendor/assets/javascripts/xmt_froala/languages/it.js +318 -0
  58. data/vendor/assets/javascripts/xmt_froala/languages/ja.js +318 -0
  59. data/vendor/assets/javascripts/xmt_froala/languages/ko.js +318 -0
  60. data/vendor/assets/javascripts/xmt_froala/languages/me.js +318 -0
  61. data/vendor/assets/javascripts/xmt_froala/languages/nb.js +318 -0
  62. data/vendor/assets/javascripts/xmt_froala/languages/nl.js +318 -0
  63. data/vendor/assets/javascripts/xmt_froala/languages/pl.js +318 -0
  64. data/vendor/assets/javascripts/xmt_froala/languages/pt_br.js +318 -0
  65. data/vendor/assets/javascripts/xmt_froala/languages/pt_pt.js +318 -0
  66. data/vendor/assets/javascripts/xmt_froala/languages/ro.js +319 -0
  67. data/vendor/assets/javascripts/xmt_froala/languages/ru.js +318 -0
  68. data/vendor/assets/javascripts/xmt_froala/languages/sk.js +318 -0
  69. data/vendor/assets/javascripts/xmt_froala/languages/sr.js +318 -0
  70. data/vendor/assets/javascripts/xmt_froala/languages/sv.js +318 -0
  71. data/vendor/assets/javascripts/xmt_froala/languages/th.js +318 -0
  72. data/vendor/assets/javascripts/xmt_froala/languages/tr.js +318 -0
  73. data/vendor/assets/javascripts/xmt_froala/languages/uk.js +318 -0
  74. data/vendor/assets/javascripts/xmt_froala/languages/vi.js +258 -0
  75. data/vendor/assets/javascripts/xmt_froala/languages/zh_cn.js +320 -0
  76. data/vendor/assets/javascripts/xmt_froala/languages/zh_tw.js +318 -0
  77. data/vendor/assets/javascripts/xmt_froala/plugins/align.js +139 -0
  78. data/vendor/assets/javascripts/xmt_froala/plugins/align.min.js +7 -0
  79. data/vendor/assets/javascripts/xmt_froala/plugins/char_counter.js +154 -0
  80. data/vendor/assets/javascripts/xmt_froala/plugins/char_counter.min.js +7 -0
  81. data/vendor/assets/javascripts/xmt_froala/plugins/code_beautifier.js +3270 -0
  82. data/vendor/assets/javascripts/xmt_froala/plugins/code_beautifier.min.js +7 -0
  83. data/vendor/assets/javascripts/xmt_froala/plugins/code_view.js +393 -0
  84. data/vendor/assets/javascripts/xmt_froala/plugins/code_view.min.js +7 -0
  85. data/vendor/assets/javascripts/xmt_froala/plugins/colors.js +492 -0
  86. data/vendor/assets/javascripts/xmt_froala/plugins/colors.min.js +7 -0
  87. data/vendor/assets/javascripts/xmt_froala/plugins/draggable.js +459 -0
  88. data/vendor/assets/javascripts/xmt_froala/plugins/draggable.min.js +7 -0
  89. data/vendor/assets/javascripts/xmt_froala/plugins/emoticons.js +509 -0
  90. data/vendor/assets/javascripts/xmt_froala/plugins/emoticons.min.js +7 -0
  91. data/vendor/assets/javascripts/xmt_froala/plugins/entities.js +121 -0
  92. data/vendor/assets/javascripts/xmt_froala/plugins/entities.min.js +7 -0
  93. data/vendor/assets/javascripts/xmt_froala/plugins/file.js +736 -0
  94. data/vendor/assets/javascripts/xmt_froala/plugins/file.min.js +239 -0
  95. data/vendor/assets/javascripts/xmt_froala/plugins/font_family.js +182 -0
  96. data/vendor/assets/javascripts/xmt_froala/plugins/font_family.min.js +7 -0
  97. data/vendor/assets/javascripts/xmt_froala/plugins/font_size.js +118 -0
  98. data/vendor/assets/javascripts/xmt_froala/plugins/font_size.min.js +7 -0
  99. data/vendor/assets/javascripts/xmt_froala/plugins/forms.js +430 -0
  100. data/vendor/assets/javascripts/xmt_froala/plugins/forms.min.js +7 -0
  101. data/vendor/assets/javascripts/xmt_froala/plugins/fullscreen.js +274 -0
  102. data/vendor/assets/javascripts/xmt_froala/plugins/fullscreen.min.js +7 -0
  103. data/vendor/assets/javascripts/xmt_froala/plugins/help.js +216 -0
  104. data/vendor/assets/javascripts/xmt_froala/plugins/help.min.js +7 -0
  105. data/vendor/assets/javascripts/xmt_froala/plugins/image.js +3323 -0
  106. data/vendor/assets/javascripts/xmt_froala/plugins/image.min.js +7 -0
  107. data/vendor/assets/javascripts/xmt_froala/plugins/image_manager.js +1056 -0
  108. data/vendor/assets/javascripts/xmt_froala/plugins/image_manager.min.js +7 -0
  109. data/vendor/assets/javascripts/xmt_froala/plugins/inline_style.js +94 -0
  110. data/vendor/assets/javascripts/xmt_froala/plugins/inline_style.min.js +7 -0
  111. data/vendor/assets/javascripts/xmt_froala/plugins/line_breaker.js +537 -0
  112. data/vendor/assets/javascripts/xmt_froala/plugins/line_breaker.min.js +7 -0
  113. data/vendor/assets/javascripts/xmt_froala/plugins/link.js +1157 -0
  114. data/vendor/assets/javascripts/xmt_froala/plugins/link.min.js +7 -0
  115. data/vendor/assets/javascripts/xmt_froala/plugins/lists.js +462 -0
  116. data/vendor/assets/javascripts/xmt_froala/plugins/lists.min.js +7 -0
  117. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_format.js +290 -0
  118. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_format.min.js +7 -0
  119. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_style.js +144 -0
  120. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_style.min.js +7 -0
  121. data/vendor/assets/javascripts/xmt_froala/plugins/plain_paste.js +96 -0
  122. data/vendor/assets/javascripts/xmt_froala/plugins/print.js +137 -0
  123. data/vendor/assets/javascripts/xmt_froala/plugins/print.min.js +7 -0
  124. data/vendor/assets/javascripts/xmt_froala/plugins/quick_format.js +89 -0
  125. data/vendor/assets/javascripts/xmt_froala/plugins/quick_insert.js +478 -0
  126. data/vendor/assets/javascripts/xmt_froala/plugins/quick_insert.min.js +7 -0
  127. data/vendor/assets/javascripts/xmt_froala/plugins/quote.js +141 -0
  128. data/vendor/assets/javascripts/xmt_froala/plugins/quote.min.js +7 -0
  129. data/vendor/assets/javascripts/xmt_froala/plugins/save.js +189 -0
  130. data/vendor/assets/javascripts/xmt_froala/plugins/save.min.js +7 -0
  131. data/vendor/assets/javascripts/xmt_froala/plugins/special_characters.js +781 -0
  132. data/vendor/assets/javascripts/xmt_froala/plugins/special_characters.min.js +7 -0
  133. data/vendor/assets/javascripts/xmt_froala/plugins/table.js +4194 -0
  134. data/vendor/assets/javascripts/xmt_froala/plugins/table.min.js +7 -0
  135. data/vendor/assets/javascripts/xmt_froala/plugins/url.js +194 -0
  136. data/vendor/assets/javascripts/xmt_froala/plugins/url.min.js +7 -0
  137. data/vendor/assets/javascripts/xmt_froala/plugins/video.js +2342 -0
  138. data/vendor/assets/javascripts/xmt_froala/plugins/video.min.js +7 -0
  139. data/vendor/assets/javascripts/xmt_froala/plugins/word_paste.js +1403 -0
  140. data/vendor/assets/javascripts/xmt_froala/plugins/word_paste.min.js +7 -0
  141. data/vendor/assets/javascripts/xmt_froala/third_party/embedly.js +543 -0
  142. data/vendor/assets/javascripts/xmt_froala/third_party/embedly.min.js +7 -0
  143. data/vendor/assets/javascripts/xmt_froala/third_party/image_aviary.js +163 -0
  144. data/vendor/assets/javascripts/xmt_froala/third_party/image_aviary.min.js +7 -0
  145. data/vendor/assets/javascripts/xmt_froala/third_party/spell_checker.js +222 -0
  146. data/vendor/assets/javascripts/xmt_froala/third_party/spell_checker.min.js +7 -0
  147. data/vendor/assets/javascripts/xmt_froala/xmt_froala.js +15172 -0
  148. data/vendor/assets/stylesheets/xmt_froala/css/font-awesome.css +2546 -0
  149. data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.min.css +7 -0
  150. data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.pkgd.css +2902 -0
  151. data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.pkgd.min.css +7 -0
  152. data/vendor/assets/stylesheets/xmt_froala/css/froala_style.css +413 -0
  153. data/vendor/assets/stylesheets/xmt_froala/css/froala_style.min.css +7 -0
  154. data/vendor/assets/stylesheets/xmt_froala/css/plugins/char_counter.css +57 -0
  155. data/vendor/assets/stylesheets/xmt_froala/css/plugins/char_counter.min.css +7 -0
  156. data/vendor/assets/stylesheets/xmt_froala/css/plugins/code_view.css +112 -0
  157. data/vendor/assets/stylesheets/xmt_froala/css/plugins/code_view.min.css +7 -0
  158. data/vendor/assets/stylesheets/xmt_froala/css/plugins/colors.css +155 -0
  159. data/vendor/assets/stylesheets/xmt_froala/css/plugins/colors.min.css +7 -0
  160. data/vendor/assets/stylesheets/xmt_froala/css/plugins/draggable.css +43 -0
  161. data/vendor/assets/stylesheets/xmt_froala/css/plugins/draggable.min.css +7 -0
  162. data/vendor/assets/stylesheets/xmt_froala/css/plugins/emoticons.css +42 -0
  163. data/vendor/assets/stylesheets/xmt_froala/css/plugins/emoticons.min.css +7 -0
  164. data/vendor/assets/stylesheets/xmt_froala/css/plugins/file.css +146 -0
  165. data/vendor/assets/stylesheets/xmt_froala/css/plugins/file.min.css +7 -0
  166. data/vendor/assets/stylesheets/xmt_froala/css/plugins/fullscreen.css +28 -0
  167. data/vendor/assets/stylesheets/xmt_froala/css/plugins/fullscreen.min.css +7 -0
  168. data/vendor/assets/stylesheets/xmt_froala/css/plugins/help.css +52 -0
  169. data/vendor/assets/stylesheets/xmt_froala/css/plugins/help.min.css +7 -0
  170. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image.css +244 -0
  171. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image.min.css +7 -0
  172. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image_manager.css +266 -0
  173. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image_manager.min.css +7 -0
  174. data/vendor/assets/stylesheets/xmt_froala/css/plugins/line_breaker.css +37 -0
  175. data/vendor/assets/stylesheets/xmt_froala/css/plugins/line_breaker.min.css +7 -0
  176. data/vendor/assets/stylesheets/xmt_froala/css/plugins/quick_insert.css +70 -0
  177. data/vendor/assets/stylesheets/xmt_froala/css/plugins/quick_insert.min.css +7 -0
  178. data/vendor/assets/stylesheets/xmt_froala/css/plugins/special_characters.css +51 -0
  179. data/vendor/assets/stylesheets/xmt_froala/css/plugins/special_characters.min.css +7 -0
  180. data/vendor/assets/stylesheets/xmt_froala/css/plugins/table.css +181 -0
  181. data/vendor/assets/stylesheets/xmt_froala/css/plugins/table.min.css +7 -0
  182. data/vendor/assets/stylesheets/xmt_froala/css/plugins/video.css +231 -0
  183. data/vendor/assets/stylesheets/xmt_froala/css/plugins/video.min.css +7 -0
  184. data/vendor/assets/stylesheets/xmt_froala/css/themes/dark.css +1281 -0
  185. data/vendor/assets/stylesheets/xmt_froala/css/themes/dark.min.css +7 -0
  186. data/vendor/assets/stylesheets/xmt_froala/css/themes/gray.css +1281 -0
  187. data/vendor/assets/stylesheets/xmt_froala/css/themes/gray.min.css +7 -0
  188. data/vendor/assets/stylesheets/xmt_froala/css/themes/red.css +1281 -0
  189. data/vendor/assets/stylesheets/xmt_froala/css/themes/red.min.css +7 -0
  190. data/vendor/assets/stylesheets/xmt_froala/css/themes/royal.css +1281 -0
  191. data/vendor/assets/stylesheets/xmt_froala/css/themes/royal.min.css +7 -0
  192. data/vendor/assets/stylesheets/xmt_froala/css/third_party/embedly.css +64 -0
  193. data/vendor/assets/stylesheets/xmt_froala/css/third_party/embedly.min.css +7 -0
  194. data/vendor/assets/stylesheets/xmt_froala/css/third_party/spell_checker.css +72 -0
  195. data/vendor/assets/stylesheets/xmt_froala/css/third_party/spell_checker.min.css +7 -0
  196. data/vendor/assets/stylesheets/xmt_froala/css/xmt_froala.css +1423 -0
  197. data/vendor/assets/stylesheets/xmt_froala/fonts/FontAwesome.otf +0 -0
  198. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.eot +0 -0
  199. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.svg +2671 -0
  200. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.ttf +0 -0
  201. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.woff +0 -0
  202. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.woff2 +0 -0
  203. metadata +273 -0
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ !function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=function(e,o){return o===undefined&&(o="undefined"!=typeof window?require("jquery"):require("jquery")(e)),t(o)}:t(window.jQuery)}(function(g){g.extend(g.FE.POPUP_TEMPLATES,{emoticons:"[_BUTTONS_][_EMOTICONS_]"}),g.extend(g.FE.DEFAULTS,{emoticonsStep:8,emoticonsSet:[{code:"1f600",desc:"Grinning face"},{code:"1f601",desc:"Grinning face with smiling eyes"},{code:"1f602",desc:"Face with tears of joy"},{code:"1f603",desc:"Smiling face with open mouth"},{code:"1f604",desc:"Smiling face with open mouth and smiling eyes"},{code:"1f605",desc:"Smiling face with open mouth and cold sweat"},{code:"1f606",desc:"Smiling face with open mouth and tightly-closed eyes"},{code:"1f607",desc:"Smiling face with halo"},{code:"1f608",desc:"Smiling face with horns"},{code:"1f609",desc:"Winking face"},{code:"1f60a",desc:"Smiling face with smiling eyes"},{code:"1f60b",desc:"Face savoring delicious food"},{code:"1f60c",desc:"Relieved face"},{code:"1f60d",desc:"Smiling face with heart-shaped eyes"},{code:"1f60e",desc:"Smiling face with sunglasses"},{code:"1f60f",desc:"Smirking face"},{code:"1f610",desc:"Neutral face"},{code:"1f611",desc:"Expressionless face"},{code:"1f612",desc:"Unamused face"},{code:"1f613",desc:"Face with cold sweat"},{code:"1f614",desc:"Pensive face"},{code:"1f615",desc:"Confused face"},{code:"1f616",desc:"Confounded face"},{code:"1f617",desc:"Kissing face"},{code:"1f618",desc:"Face throwing a kiss"},{code:"1f619",desc:"Kissing face with smiling eyes"},{code:"1f61a",desc:"Kissing face with closed eyes"},{code:"1f61b",desc:"Face with stuck out tongue"},{code:"1f61c",desc:"Face with stuck out tongue and winking eye"},{code:"1f61d",desc:"Face with stuck out tongue and tightly-closed eyes"},{code:"1f61e",desc:"Disappointed face"},{code:"1f61f",desc:"Worried face"},{code:"1f620",desc:"Angry face"},{code:"1f621",desc:"Pouting face"},{code:"1f622",desc:"Crying face"},{code:"1f623",desc:"Persevering face"},{code:"1f624",desc:"Face with look of triumph"},{code:"1f625",desc:"Disappointed but relieved face"},{code:"1f626",desc:"Frowning face with open mouth"},{code:"1f627",desc:"Anguished face"},{code:"1f628",desc:"Fearful face"},{code:"1f629",desc:"Weary face"},{code:"1f62a",desc:"Sleepy face"},{code:"1f62b",desc:"Tired face"},{code:"1f62c",desc:"Grimacing face"},{code:"1f62d",desc:"Loudly crying face"},{code:"1f62e",desc:"Face with open mouth"},{code:"1f62f",desc:"Hushed face"},{code:"1f630",desc:"Face with open mouth and cold sweat"},{code:"1f631",desc:"Face screaming in fear"},{code:"1f632",desc:"Astonished face"},{code:"1f633",desc:"Flushed face"},{code:"1f634",desc:"Sleeping face"},{code:"1f635",desc:"Dizzy face"},{code:"1f636",desc:"Face without mouth"},{code:"1f637",desc:"Face with medical mask"}],emoticonsButtons:["emoticonsBack","|"],emoticonsUseImage:!0}),g.FE.PLUGINS.emoticons=function(E){function n(){if(!E.selection.isCollapsed())return!1;var e=E.selection.element(),o=E.selection.endElement();if(e&&E.node.hasClass(e,"fr-emoticon"))return e;if(o&&E.node.hasClass(o,"fr-emoticon"))return o;var t=E.selection.ranges(0),s=t.startContainer;if(s.nodeType==Node.ELEMENT_NODE&&0<s.childNodes.length&&0<t.startOffset){var n=s.childNodes[t.startOffset-1];if(E.node.hasClass(n,"fr-emoticon"))return n}return!1}return{_init:function(){var e=function(){for(var e=E.el.querySelectorAll(".fr-emoticon:not(.fr-deletable)"),o=0;o<e.length;o++)e[o].className+=" fr-deletable"};e(),E.events.on("html.set",e),E.events.on("keydown",function(e){if(E.keys.isCharacter(e.which)&&E.selection.inEditor()){var o=E.selection.ranges(0),t=n();E.node.hasClass(t,"fr-emoticon-img")&&t&&(0===o.startOffset&&E.selection.element()===t?g(t).before(g.FE.MARKERS+g.FE.INVISIBLE_SPACE):g(t).after(g.FE.INVISIBLE_SPACE+g.FE.MARKERS),E.selection.restore())}}),E.events.on("keyup",function(e){for(var o=E.el.querySelectorAll(".fr-emoticon"),t=0;t<o.length;t++)"undefined"!=typeof o[t].textContent&&0===o[t].textContent.replace(/\u200B/gi,"").length&&g(o[t]).remove();if(!(e.which>=g.FE.KEYCODE.ARROW_LEFT&&e.which<=g.FE.KEYCODE.ARROW_DOWN)){var s=n();E.node.hasClass(s,"fr-emoticon-img")&&(g(s).append(g.FE.MARKERS),E.selection.restore())}})},insert:function(e,o){var t=n(),s=E.selection.ranges(0);t?(0===s.startOffset&&E.selection.element()===t?g(t).before(g.FE.MARKERS+g.FE.INVISIBLE_SPACE):0<s.startOffset&&E.selection.element()===t&&s.commonAncestorContainer.parentNode.classList.contains("fr-emoticon")&&g(t).after(g.FE.INVISIBLE_SPACE+g.FE.MARKERS),E.selection.restore(),E.html.insert('<span class="fr-emoticon fr-deletable'+(o?" fr-emoticon-img":"")+'"'+(o?' style="background: url('+o+');"':"")+">"+(o?"&nbsp;":e)+"</span>&nbsp;"+g.FE.MARKERS,!0)):E.html.insert('<span class="fr-emoticon fr-deletable'+(o?" fr-emoticon-img":"")+'"'+(o?' style="background: url('+o+');"':"")+">"+(o?"&nbsp;":e)+"</span>&nbsp;",!0)},showEmoticonsPopup:function(){var e=E.$tb.find('.fr-command[data-cmd="emoticons"]'),o=E.popups.get("emoticons");if(o||(o=function(){var e="";E.opts.toolbarInline&&0<E.opts.emoticonsButtons.length&&(e='<div class="fr-buttons fr-emoticons-buttons">'+E.button.buildList(E.opts.emoticonsButtons)+"</div>");var h,o={buttons:e,emoticons:function(){for(var e='<div style="text-align: center">',o=0;o<E.opts.emoticonsSet.length;o++)0!==o&&o%E.opts.emoticonsStep==0&&(e+="<br>"),e+='<span class="fr-command fr-emoticon" tabIndex="-1" data-cmd="insertEmoticon" title="'+E.language.translate(E.opts.emoticonsSet[o].desc)+'" role="button" data-param1="'+E.opts.emoticonsSet[o].code+'">'+(E.opts.emoticonsUseImage?'<img src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.0.1/assets/svg/'+E.opts.emoticonsSet[o].code+'.svg"/>':"&#x"+E.opts.emoticonsSet[o].code+";")+'<span class="fr-sr-only">'+E.language.translate(E.opts.emoticonsSet[o].desc)+"&nbsp;&nbsp;&nbsp;</span></span>";return E.opts.emoticonsUseImage&&(e+='<p style="font-size: 12px; text-align: center; padding: 0 5px;">Emoji free by <a class="fr-link" tabIndex="-1" href="http://emojione.com/" target="_blank" rel="nofollow" role="link" aria-label="Open Emoji One website.">Emoji One</a></p>'),e+="</div>"}()},t=E.popups.create("emoticons",o);return E.tooltip.bind(t,".fr-emoticon"),h=t,E.events.on("popup.tab",function(e){var o=g(e.currentTarget);if(!E.popups.isVisible("emoticons")||!o.is("span, a"))return!0;var t,s,n,c=e.which;if(g.FE.KEYCODE.TAB==c){if(o.is("span.fr-emoticon")&&e.shiftKey||o.is("a")&&!e.shiftKey){var i=h.find(".fr-buttons");t=!E.accessibility.focusToolbar(i,!!e.shiftKey)}if(!1!==t){var a=h.find("span.fr-emoticon:focus:first, span.fr-emoticon:visible:first, a");o.is("span.fr-emoticon")&&(a=a.not("span.fr-emoticon:not(:focus)")),s=a.index(o),s=e.shiftKey?((s-1)%a.length+a.length)%a.length:(s+1)%a.length,n=a.get(s),E.events.disableBlur(),n.focus(),t=!1}}else if(g.FE.KEYCODE.ARROW_UP==c||g.FE.KEYCODE.ARROW_DOWN==c||g.FE.KEYCODE.ARROW_LEFT==c||g.FE.KEYCODE.ARROW_RIGHT==c){if(o.is("span.fr-emoticon")){var f=o.parent().find("span.fr-emoticon");s=f.index(o);var d=E.opts.emoticonsStep,r=Math.floor(f.length/d),l=s%d,m=Math.floor(s/d),u=m*d+l,p=r*d;g.FE.KEYCODE.ARROW_UP==c?u=((u-d)%p+p)%p:g.FE.KEYCODE.ARROW_DOWN==c?u=(u+d)%p:g.FE.KEYCODE.ARROW_LEFT==c?u=((u-1)%p+p)%p:g.FE.KEYCODE.ARROW_RIGHT==c&&(u=(u+1)%p),n=g(f.get(u)),E.events.disableBlur(),n.focus(),t=!1}}else g.FE.KEYCODE.ENTER==c&&(o.is("a")?o[0].click():E.button.exec(o),t=!1);return!1===t&&(e.preventDefault(),e.stopPropagation()),t},!0),t}()),!o.hasClass("fr-active")){E.popups.refresh("emoticons"),E.popups.setContainer("emoticons",E.$tb);var t=e.offset().left+e.outerWidth()/2,s=e.offset().top+(E.opts.toolbarBottom?10:e.outerHeight()-10);E.popups.show("emoticons",t,s,e.outerHeight())}},hideEmoticonsPopup:function(){E.popups.hide("emoticons")},back:function(){E.popups.hide("emoticons"),E.toolbar.showInline()}}},g.FE.DefineIcon("emoticons",{NAME:"smile-o",FA5NAME:"smile"}),g.FE.RegisterCommand("emoticons",{title:"Emoticons",undo:!1,focus:!0,refreshOnCallback:!1,popup:!0,callback:function(){this.popups.isVisible("emoticons")?(this.$el.find(".fr-marker").length&&(this.events.disableBlur(),this.selection.restore()),this.popups.hide("emoticons")):this.emoticons.showEmoticonsPopup()},plugin:"emoticons"}),g.FE.RegisterCommand("insertEmoticon",{callback:function(e,o){this.emoticons.insert("&#x"+o+";",this.opts.emoticonsUseImage?"https://cdnjs.cloudflare.com/ajax/libs/emojione/2.0.1/assets/svg/"+o+".svg":null),this.emoticons.hideEmoticonsPopup()}}),g.FE.DefineIcon("emoticonsBack",{NAME:"arrow-left"}),g.FE.RegisterCommand("emoticonsBack",{title:"Back",undo:!1,focus:!1,back:!0,refreshAfterCallback:!1,callback:function(){this.emoticons.back()}})});
@@ -0,0 +1,121 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ (function (factory) {
8
+ if (typeof define === 'function' && define.amd) {
9
+ // AMD. Register as an anonymous module.
10
+ define(['jquery'], factory);
11
+ } else if (typeof module === 'object' && module.exports) {
12
+ // Node/CommonJS
13
+ module.exports = function( root, jQuery ) {
14
+ if ( jQuery === undefined ) {
15
+ // require('jQuery') returns a factory that requires window to
16
+ // build a jQuery instance, we normalize how we use modules
17
+ // that require this pattern but the window provided is a noop
18
+ // if it's defined (how jquery works)
19
+ if ( typeof window !== 'undefined' ) {
20
+ jQuery = require('jquery');
21
+ }
22
+ else {
23
+ jQuery = require('jquery')(root);
24
+ }
25
+ }
26
+ return factory(jQuery);
27
+ };
28
+ } else {
29
+ // Browser globals
30
+ factory(window.jQuery);
31
+ }
32
+ }(function ($) {
33
+
34
+
35
+
36
+ // Extend defaults.
37
+ $.extend($.FE.DEFAULTS, {
38
+ entities: '&quot;&#39;&iexcl;&cent;&pound;&curren;&yen;&brvbar;&sect;&uml;&copy;&ordf;&laquo;&not;&shy;&reg;&macr;&deg;&plusmn;&sup2;&sup3;&acute;&micro;&para;&middot;&cedil;&sup1;&ordm;&raquo;&frac14;&frac12;&frac34;&iquest;&Agrave;&Aacute;&Acirc;&Atilde;&Auml;&Aring;&AElig;&Ccedil;&Egrave;&Eacute;&Ecirc;&Euml;&Igrave;&Iacute;&Icirc;&Iuml;&ETH;&Ntilde;&Ograve;&Oacute;&Ocirc;&Otilde;&Ouml;&times;&Oslash;&Ugrave;&Uacute;&Ucirc;&Uuml;&Yacute;&THORN;&szlig;&agrave;&aacute;&acirc;&atilde;&auml;&aring;&aelig;&ccedil;&egrave;&eacute;&ecirc;&euml;&igrave;&iacute;&icirc;&iuml;&eth;&ntilde;&ograve;&oacute;&ocirc;&otilde;&ouml;&divide;&oslash;&ugrave;&uacute;&ucirc;&uuml;&yacute;&thorn;&yuml;&OElig;&oelig;&Scaron;&scaron;&Yuml;&fnof;&circ;&tilde;&Alpha;&Beta;&Gamma;&Delta;&Epsilon;&Zeta;&Eta;&Theta;&Iota;&Kappa;&Lambda;&Mu;&Nu;&Xi;&Omicron;&Pi;&Rho;&Sigma;&Tau;&Upsilon;&Phi;&Chi;&Psi;&Omega;&alpha;&beta;&gamma;&delta;&epsilon;&zeta;&eta;&theta;&iota;&kappa;&lambda;&mu;&nu;&xi;&omicron;&pi;&rho;&sigmaf;&sigma;&tau;&upsilon;&phi;&chi;&psi;&omega;&thetasym;&upsih;&piv;&ensp;&emsp;&thinsp;&zwnj;&zwj;&lrm;&rlm;&ndash;&mdash;&lsquo;&rsquo;&sbquo;&ldquo;&rdquo;&bdquo;&dagger;&Dagger;&bull;&hellip;&permil;&prime;&Prime;&lsaquo;&rsaquo;&oline;&frasl;&euro;&image;&weierp;&real;&trade;&alefsym;&larr;&uarr;&rarr;&darr;&harr;&crarr;&lArr;&uArr;&rArr;&dArr;&hArr;&forall;&part;&exist;&empty;&nabla;&isin;&notin;&ni;&prod;&sum;&minus;&lowast;&radic;&prop;&infin;&ang;&and;&or;&cap;&cup;&int;&there4;&sim;&cong;&asymp;&ne;&equiv;&le;&ge;&sub;&sup;&nsub;&sube;&supe;&oplus;&otimes;&perp;&sdot;&lceil;&rceil;&lfloor;&rfloor;&lang;&rang;&loz;&spades;&clubs;&hearts;&diams;'
39
+ });
40
+
41
+
42
+ $.FE.PLUGINS.entities = function (editor) {
43
+ var _reg_exp;
44
+ var _map;
45
+
46
+ // if &, then index should be 0
47
+ function _process (el) {
48
+ var text = el.textContent;
49
+
50
+ if (text.match(_reg_exp)) {
51
+ var new_text = '';
52
+
53
+ for (var j = 0; j < text.length; j++) {
54
+ if (_map[text[j]]) new_text += _map[text[j]];
55
+ else new_text += text[j];
56
+ }
57
+
58
+ el.textContent = new_text;
59
+ }
60
+ }
61
+
62
+ function _encode (el) {
63
+ if (el && ['STYLE', 'SCRIPT', 'svg', 'IFRAME'].indexOf(el.tagName) >= 0) return true;
64
+
65
+ var contents = editor.node.contents(el);
66
+
67
+ // Process contents.
68
+ for (var i = 0; i < contents.length; i++) {
69
+ if (contents[i].nodeType == Node.TEXT_NODE) {
70
+ _process(contents[i]);
71
+ }
72
+ else {
73
+ _encode(contents[i]);
74
+ }
75
+ }
76
+
77
+ // Process node itself.
78
+ if (el.nodeType == Node.TEXT_NODE) _process(el);
79
+ }
80
+
81
+ /**
82
+ * Encode entities.
83
+ */
84
+ function _encodeEntities (html) {
85
+ if (html.length === 0) return '';
86
+
87
+ var x = editor.clean.exec(html, _encode).replace(/\&amp;/g, '&');
88
+
89
+ return x;
90
+ }
91
+
92
+ /*
93
+ * Initialize.
94
+ */
95
+ function _init () {
96
+ if (!editor.opts.htmlSimpleAmpersand) {
97
+ editor.opts.entities = editor.opts.entities + '&amp;';
98
+ }
99
+
100
+ // Do escape.
101
+ var entities_text = $('<div>').html(editor.opts.entities).text();
102
+ var entities_array = editor.opts.entities.split(';');
103
+ _map = {};
104
+ _reg_exp = '';
105
+
106
+ for (var i = 0; i < entities_text.length; i++) {
107
+ var chr = entities_text.charAt(i);
108
+ _map[chr] = entities_array[i] + ';';
109
+ _reg_exp += '\\' + chr + (i < entities_text.length - 1 ? '|' : '');
110
+ }
111
+ _reg_exp = new RegExp('(' + _reg_exp + ')', 'g');
112
+
113
+ editor.events.on('html.get', _encodeEntities, true);
114
+ }
115
+
116
+ return {
117
+ _init: _init
118
+ }
119
+ }
120
+
121
+ }));
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(e,r){return r===undefined&&(r="undefined"!=typeof window?require("jquery"):require("jquery")(e)),a(r)}:a(window.jQuery)}(function(c){c.extend(c.FE.DEFAULTS,{entities:"&quot;&#39;&iexcl;&cent;&pound;&curren;&yen;&brvbar;&sect;&uml;&copy;&ordf;&laquo;&not;&shy;&reg;&macr;&deg;&plusmn;&sup2;&sup3;&acute;&micro;&para;&middot;&cedil;&sup1;&ordm;&raquo;&frac14;&frac12;&frac34;&iquest;&Agrave;&Aacute;&Acirc;&Atilde;&Auml;&Aring;&AElig;&Ccedil;&Egrave;&Eacute;&Ecirc;&Euml;&Igrave;&Iacute;&Icirc;&Iuml;&ETH;&Ntilde;&Ograve;&Oacute;&Ocirc;&Otilde;&Ouml;&times;&Oslash;&Ugrave;&Uacute;&Ucirc;&Uuml;&Yacute;&THORN;&szlig;&agrave;&aacute;&acirc;&atilde;&auml;&aring;&aelig;&ccedil;&egrave;&eacute;&ecirc;&euml;&igrave;&iacute;&icirc;&iuml;&eth;&ntilde;&ograve;&oacute;&ocirc;&otilde;&ouml;&divide;&oslash;&ugrave;&uacute;&ucirc;&uuml;&yacute;&thorn;&yuml;&OElig;&oelig;&Scaron;&scaron;&Yuml;&fnof;&circ;&tilde;&Alpha;&Beta;&Gamma;&Delta;&Epsilon;&Zeta;&Eta;&Theta;&Iota;&Kappa;&Lambda;&Mu;&Nu;&Xi;&Omicron;&Pi;&Rho;&Sigma;&Tau;&Upsilon;&Phi;&Chi;&Psi;&Omega;&alpha;&beta;&gamma;&delta;&epsilon;&zeta;&eta;&theta;&iota;&kappa;&lambda;&mu;&nu;&xi;&omicron;&pi;&rho;&sigmaf;&sigma;&tau;&upsilon;&phi;&chi;&psi;&omega;&thetasym;&upsih;&piv;&ensp;&emsp;&thinsp;&zwnj;&zwj;&lrm;&rlm;&ndash;&mdash;&lsquo;&rsquo;&sbquo;&ldquo;&rdquo;&bdquo;&dagger;&Dagger;&bull;&hellip;&permil;&prime;&Prime;&lsaquo;&rsaquo;&oline;&frasl;&euro;&image;&weierp;&real;&trade;&alefsym;&larr;&uarr;&rarr;&darr;&harr;&crarr;&lArr;&uArr;&rArr;&dArr;&hArr;&forall;&part;&exist;&empty;&nabla;&isin;&notin;&ni;&prod;&sum;&minus;&lowast;&radic;&prop;&infin;&ang;&and;&or;&cap;&cup;&int;&there4;&sim;&cong;&asymp;&ne;&equiv;&le;&ge;&sub;&sup;&nsub;&sube;&supe;&oplus;&otimes;&perp;&sdot;&lceil;&rceil;&lfloor;&rfloor;&lang;&rang;&loz;&spades;&clubs;&hearts;&diams;"}),c.FE.PLUGINS.entities=function(t){var n,u;function i(e){var r=e.textContent;if(r.match(n)){for(var a="",i=0;i<r.length;i++)u[r[i]]?a+=u[r[i]]:a+=r[i];e.textContent=a}}function o(e){if(e&&0<=["STYLE","SCRIPT","svg","IFRAME"].indexOf(e.tagName))return!0;for(var r=t.node.contents(e),a=0;a<r.length;a++)r[a].nodeType==Node.TEXT_NODE?i(r[a]):o(r[a]);e.nodeType==Node.TEXT_NODE&&i(e)}function l(e){return 0===e.length?"":t.clean.exec(e,o).replace(/\&amp;/g,"&")}return{_init:function(){t.opts.htmlSimpleAmpersand||(t.opts.entities=t.opts.entities+"&amp;");var e=c("<div>").html(t.opts.entities).text(),r=t.opts.entities.split(";");u={},n="";for(var a=0;a<e.length;a++){var i=e.charAt(a);u[i]=r[a]+";",n+="\\"+i+(a<e.length-1?"|":"")}n=new RegExp("("+n+")","g"),t.events.on("html.get",l,!0)}}}});
@@ -0,0 +1,736 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ (function (factory) {
8
+ if (typeof define === 'function' && define.amd) {
9
+ // AMD. Register as an anonymous module.
10
+ define(['jquery'], factory);
11
+ } else if (typeof module === 'object' && module.exports) {
12
+ // Node/CommonJS
13
+ module.exports = function( root, jQuery ) {
14
+ if ( jQuery === undefined ) {
15
+ // require('jQuery') returns a factory that requires window to
16
+ // build a jQuery instance, we normalize how we use modules
17
+ // that require this pattern but the window provided is a noop
18
+ // if it's defined (how jquery works)
19
+ if ( typeof window !== 'undefined' ) {
20
+ jQuery = require('jquery');
21
+ }
22
+ else {
23
+ jQuery = require('jquery')(root);
24
+ }
25
+ }
26
+ return factory(jQuery);
27
+ };
28
+ } else {
29
+ // Browser globals
30
+ factory(window.jQuery);
31
+ }
32
+ }(function ($) {
33
+
34
+
35
+
36
+ $.extend($.FE.POPUP_TEMPLATES, {
37
+ 'file.insert': '[_BUTTONS_][_UPLOAD_LAYER_][_PROGRESS_BAR_]'
38
+ })
39
+
40
+ // Extend defaults.
41
+ $.extend($.FE.DEFAULTS, {
42
+ fileUpload: true,
43
+ fileUploadURL: 'https://i.froala.com/upload',
44
+ fileUploadParam: 'file',
45
+ fileUploadParams: {},
46
+ fileUploadToS3: false,
47
+ fileUploadMethod: 'POST',
48
+ fileMaxSize: 10 * 1024 * 1024,
49
+ fileAllowedTypes: ['*'],
50
+ fileInsertButtons: ['fileBack', '|'],
51
+ fileUseSelectedText: false
52
+ });
53
+
54
+
55
+ $.FE.PLUGINS.file = function (editor) {
56
+ var BAD_LINK = 1;
57
+ var MISSING_LINK = 2;
58
+ var ERROR_DURING_UPLOAD = 3;
59
+ var BAD_RESPONSE = 4;
60
+ var MAX_SIZE_EXCEEDED = 5;
61
+ var BAD_FILE_TYPE = 6;
62
+ var NO_CORS_IE = 7;
63
+
64
+ var error_messages = {};
65
+ error_messages[BAD_LINK] = 'File cannot be loaded from the passed link.';
66
+ error_messages[MISSING_LINK] = 'No link in upload response.';
67
+ error_messages[ERROR_DURING_UPLOAD] = 'Error during file upload.';
68
+ error_messages[BAD_RESPONSE] = 'Parsing response failed.';
69
+ error_messages[MAX_SIZE_EXCEEDED] = 'File is too large.';
70
+ error_messages[BAD_FILE_TYPE] = 'File file type is invalid.';
71
+ error_messages[NO_CORS_IE] = 'Files can be uploaded only to same domain in IE 8 and IE 9.';
72
+
73
+ function showInsertPopup () {
74
+ var $btn = editor.$tb.find('.fr-command[data-cmd="insertFile"]');
75
+
76
+ var $popup = editor.popups.get('file.insert');
77
+
78
+ if (!$popup) $popup = _initInsertPopup();
79
+
80
+ hideProgressBar();
81
+
82
+ if (!$popup.hasClass('fr-active')) {
83
+ editor.popups.refresh('file.insert');
84
+ editor.popups.setContainer('file.insert', editor.$tb);
85
+
86
+ if ($btn.is(':visible')) {
87
+ var left = $btn.offset().left + $btn.outerWidth() / 2;
88
+ var top = $btn.offset().top + (editor.opts.toolbarBottom ? 10 : $btn.outerHeight() - 10);
89
+ editor.popups.show('file.insert', left, top, $btn.outerHeight());
90
+ }
91
+ else {
92
+ editor.position.forSelection($popup);
93
+ editor.popups.show('file.insert');
94
+ }
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Show progress bar.
100
+ */
101
+ function showProgressBar () {
102
+ var $popup = editor.popups.get('file.insert');
103
+
104
+ if (!$popup) $popup = _initInsertPopup();
105
+
106
+ $popup.find('.fr-layer.fr-active').removeClass('fr-active').addClass('fr-pactive');
107
+ $popup.find('.fr-file-progress-bar-layer').addClass('fr-active');
108
+ $popup.find('.fr-buttons').hide();
109
+
110
+ _setProgressMessage(editor.language.translate('Uploading'), 0);
111
+ }
112
+
113
+ /**
114
+ * Hide progress bar.
115
+ */
116
+ function hideProgressBar (dismiss) {
117
+ var $popup = editor.popups.get('file.insert');
118
+
119
+ if ($popup) {
120
+ $popup.find('.fr-layer.fr-pactive').addClass('fr-active').removeClass('fr-pactive');
121
+ $popup.find('.fr-file-progress-bar-layer').removeClass('fr-active');
122
+ $popup.find('.fr-buttons').show();
123
+
124
+ if (dismiss) {
125
+ editor.events.focus();
126
+ editor.popups.hide('file.insert');
127
+ }
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Set a progress message.
133
+ */
134
+ function _setProgressMessage (message, progress) {
135
+ var $popup = editor.popups.get('file.insert');
136
+
137
+ if ($popup) {
138
+ var $layer = $popup.find('.fr-file-progress-bar-layer');
139
+ $layer.find('h3').text(message + (progress ? ' ' + progress + '%' : ''));
140
+
141
+ $layer.removeClass('fr-error');
142
+
143
+ if (progress) {
144
+ $layer.find('div').removeClass('fr-indeterminate');
145
+ $layer.find('div > span').css('width', progress + '%');
146
+ }
147
+ else {
148
+ $layer.find('div').addClass('fr-indeterminate');
149
+ }
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Show error message to the user.
155
+ */
156
+ function _showErrorMessage (message) {
157
+ showProgressBar();
158
+ var $popup = editor.popups.get('file.insert');
159
+ var $layer = $popup.find('.fr-file-progress-bar-layer');
160
+ $layer.addClass('fr-error');
161
+ var $message_header = $layer.find('h3');
162
+ $message_header.text(message);
163
+ editor.events.disableBlur();
164
+ $message_header.focus();
165
+ }
166
+
167
+ /**
168
+ * Insert the uploaded file.
169
+ */
170
+ function insert (link, text, response) {
171
+ editor.edit.on();
172
+
173
+ // Focus in the editor.
174
+ editor.events.focus(true);
175
+ editor.selection.restore();
176
+
177
+ if (editor.opts.fileUseSelectedText && editor.selection.text().length) {
178
+ text = editor.selection.text();
179
+ }
180
+
181
+ // Insert the link.
182
+ editor.html.insert('<a href="' + link + '" target="_blank" id="fr-inserted-file" class="fr-file">' + text + '</a>');
183
+
184
+ // Get the file.
185
+ var $file = editor.$el.find('#fr-inserted-file');
186
+
187
+ $file.removeAttr('id');
188
+
189
+ editor.popups.hide('file.insert');
190
+
191
+ editor.undo.saveStep();
192
+
193
+ _syncFiles();
194
+
195
+ editor.events.trigger('file.inserted', [$file, response]);
196
+ }
197
+
198
+ /**
199
+ * Parse file response.
200
+ */
201
+ function _parseResponse (response) {
202
+ try {
203
+ if (editor.events.trigger('file.uploaded', [response], true) === false) {
204
+ editor.edit.on();
205
+
206
+ return false;
207
+ }
208
+
209
+ var resp = JSON.parse(response);
210
+
211
+ if (resp.link) {
212
+
213
+ return resp;
214
+ }
215
+ else {
216
+
217
+ // No link in upload request.
218
+ _throwError(MISSING_LINK, response);
219
+
220
+ return false;
221
+ }
222
+ }
223
+ catch (ex) {
224
+
225
+ // Bad response.
226
+ _throwError(BAD_RESPONSE, response);
227
+
228
+ return false;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Parse file response.
234
+ */
235
+ function _parseXMLResponse (response) {
236
+ try {
237
+ var link = $(response).find('Location').text();
238
+ var key = $(response).find('Key').text();
239
+
240
+ if (editor.events.trigger('file.uploadedToS3', [link, key, response], true) === false) {
241
+ editor.edit.on();
242
+
243
+ return false;
244
+ }
245
+
246
+ return link;
247
+ }
248
+ catch (ex) {
249
+
250
+ // Bad response.
251
+ _throwError(BAD_RESPONSE, response);
252
+
253
+ return false;
254
+ }
255
+ }
256
+
257
+ /**
258
+ * File was uploaded to the server and we have a response.
259
+ */
260
+ function _fileUploaded (text) {
261
+ var status = this.status;
262
+ var response = this.response;
263
+ var responseXML = this.responseXML;
264
+ var responseText = this.responseText;
265
+
266
+ try {
267
+ if (editor.opts.fileUploadToS3) {
268
+ if (status == 201) {
269
+ var link = _parseXMLResponse(responseXML);
270
+
271
+ if (link) {
272
+ insert(link, text, response || responseXML);
273
+ }
274
+ }
275
+ else {
276
+ _throwError(BAD_RESPONSE, response || responseXML);
277
+ }
278
+ }
279
+ else {
280
+ if (status >= 200 && status < 300) {
281
+ var resp = _parseResponse(responseText);
282
+
283
+ if (resp) {
284
+ insert(resp.link, text, response || responseText);
285
+ }
286
+ }
287
+ else {
288
+ _throwError(ERROR_DURING_UPLOAD, response || responseText);
289
+ }
290
+ }
291
+ }
292
+ catch (ex) {
293
+
294
+ // Bad response.
295
+ _throwError(BAD_RESPONSE, response || responseText);
296
+ }
297
+ }
298
+
299
+ /**
300
+ * File upload error.
301
+ */
302
+ function _fileUploadError () {
303
+ _throwError(BAD_RESPONSE, this.response || this.responseText || this.responseXML);
304
+ }
305
+
306
+ /**
307
+ * File upload progress.
308
+ */
309
+ function _fileUploadProgress (e) {
310
+ if (e.lengthComputable) {
311
+ var complete = (e.loaded / e.total * 100 | 0);
312
+ _setProgressMessage(editor.language.translate('Uploading'), complete);
313
+ }
314
+ }
315
+
316
+ /**
317
+ * Throw an file error.
318
+ */
319
+ function _throwError (code, response) {
320
+ editor.edit.on();
321
+ _showErrorMessage(editor.language.translate('Something went wrong. Please try again.'));
322
+
323
+ editor.events.trigger('file.error', [{
324
+ code: code,
325
+ message: error_messages[code]
326
+ }, response]);
327
+ }
328
+
329
+ /**
330
+ * File upload aborted.
331
+ */
332
+ function _fileUploadAborted () {
333
+ editor.edit.on();
334
+ hideProgressBar(true);
335
+ }
336
+
337
+ function upload (files) {
338
+
339
+ // Make sure we have what to upload.
340
+ if (typeof files != 'undefined' && files.length > 0) {
341
+
342
+ // Check if we should cancel the file upload.
343
+ if (editor.events.trigger('file.beforeUpload', [files]) === false) {
344
+
345
+ return false;
346
+ }
347
+
348
+
349
+ var file = files[0];
350
+
351
+ // Check file max size.
352
+ if (file.size > editor.opts.fileMaxSize) {
353
+ _throwError(MAX_SIZE_EXCEEDED);
354
+
355
+ return false;
356
+ }
357
+
358
+ // Check file types.
359
+ if (editor.opts.fileAllowedTypes.indexOf('*') < 0 && editor.opts.fileAllowedTypes.indexOf(file.type.replace(/file\//g,'')) < 0) {
360
+ _throwError(BAD_FILE_TYPE);
361
+
362
+ return false;
363
+ }
364
+
365
+ // Create form Data.
366
+ var form_data;
367
+
368
+ if (editor.drag_support.formdata) {
369
+ form_data = editor.drag_support.formdata ? new FormData() : null;
370
+ }
371
+
372
+ // Prepare form data for request.
373
+ if (form_data) {
374
+ var key;
375
+
376
+ // Upload to S3.
377
+ if (editor.opts.fileUploadToS3 !== false) {
378
+ form_data.append('key', editor.opts.fileUploadToS3.keyStart + (new Date()).getTime() + '-' + (file.name || 'untitled'));
379
+ form_data.append('success_action_status', '201');
380
+ form_data.append('X-Requested-With', 'xhr');
381
+ form_data.append('Content-Type', file.type);
382
+
383
+ for (key in editor.opts.fileUploadToS3.params) {
384
+ if (editor.opts.fileUploadToS3.params.hasOwnProperty(key)) {
385
+ form_data.append(key, editor.opts.fileUploadToS3.params[key]);
386
+ }
387
+ }
388
+ }
389
+
390
+ // Add upload params.
391
+ for (key in editor.opts.fileUploadParams) {
392
+ if (editor.opts.fileUploadParams.hasOwnProperty(key)) {
393
+ form_data.append(key, editor.opts.fileUploadParams[key]);
394
+ }
395
+ }
396
+
397
+ // Set the file in the request.
398
+ form_data.append(editor.opts.fileUploadParam, file);
399
+
400
+ // Create XHR request.
401
+ var url = editor.opts.fileUploadURL;
402
+
403
+ if (editor.opts.fileUploadToS3) {
404
+ if (editor.opts.fileUploadToS3.uploadURL) {
405
+ url = editor.opts.fileUploadToS3.uploadURL;
406
+ }
407
+ else {
408
+ url = 'https://' + editor.opts.fileUploadToS3.region + '.amazonaws.com/' + editor.opts.fileUploadToS3.bucket;
409
+ }
410
+ }
411
+ var xhr = editor.core.getXHR(url, editor.opts.fileUploadMethod);
412
+
413
+ // Set upload events.
414
+ xhr.onload = function () {
415
+ _fileUploaded.call(xhr, file.name);
416
+ };
417
+ xhr.onerror = _fileUploadError;
418
+ xhr.upload.onprogress = _fileUploadProgress;
419
+ xhr.onabort = _fileUploadAborted;
420
+
421
+ showProgressBar();
422
+
423
+ // editor.edit.off();
424
+
425
+ var $popup = editor.popups.get('file.insert');
426
+
427
+ if ($popup) {
428
+ $popup.off('abortUpload').on('abortUpload', function () {
429
+ if (xhr.readyState != 4) {
430
+ xhr.abort();
431
+ }
432
+ })
433
+ }
434
+
435
+ // Send data.
436
+ xhr.send(form_data);
437
+ }
438
+ }
439
+ }
440
+
441
+ function _bindInsertEvents ($popup) {
442
+
443
+ // Drag over the dropable area.
444
+ editor.events.$on($popup, 'dragover dragenter', '.fr-file-upload-layer', function () {
445
+ $(this).addClass('fr-drop');
446
+
447
+ return false;
448
+ }, true);
449
+
450
+ // Drag end.
451
+ editor.events.$on($popup, 'dragleave dragend', '.fr-file-upload-layer', function () {
452
+ $(this).removeClass('fr-drop');
453
+
454
+ return false;
455
+ }, true);
456
+
457
+ // Drop.
458
+ editor.events.$on($popup, 'drop', '.fr-file-upload-layer', function (e) {
459
+ e.preventDefault();
460
+ e.stopPropagation();
461
+
462
+ $(this).removeClass('fr-drop');
463
+
464
+ var dt = e.originalEvent.dataTransfer;
465
+
466
+ if (dt && dt.files) {
467
+ var inst = $popup.data('instance') || editor;
468
+ inst.file.upload(dt.files);
469
+ }
470
+ }, true);
471
+
472
+ if (editor.helpers.isIOS()) {
473
+ editor.events.$on($popup, 'touchstart', '.fr-file-upload-layer input[type="file"]', function () {
474
+ $(this).trigger('click');
475
+ });
476
+ }
477
+
478
+ editor.events.$on($popup, 'change', '.fr-file-upload-layer input[type="file"]', function () {
479
+ if (this.files) {
480
+ var inst = $popup.data('instance') || editor;
481
+ inst.file.upload(this.files);
482
+ }
483
+
484
+ // Else IE 9 case.
485
+
486
+ // Chrome fix.
487
+ $(this).val('');
488
+ }, true);
489
+ }
490
+
491
+ function _hideInsertPopup () {
492
+ hideProgressBar();
493
+ }
494
+
495
+ function _initInsertPopup (delayed) {
496
+ if (delayed) {
497
+ editor.popups.onHide('file.insert', _hideInsertPopup);
498
+
499
+ return true;
500
+ }
501
+
502
+ // Image buttons.
503
+ var file_buttons = '';
504
+
505
+ if (!editor.opts.fileUpload) {
506
+ editor.opts.fileInsertButtons.splice(editor.opts.fileInsertButtons.indexOf('fileUpload'), 1);
507
+ }
508
+
509
+ file_buttons = '<div class="fr-buttons">' + editor.button.buildList(editor.opts.fileInsertButtons) + '</div>';
510
+
511
+ // File upload layer.
512
+ var upload_layer = '';
513
+
514
+ if (editor.opts.fileUpload) {
515
+ upload_layer = '<div class="fr-file-upload-layer fr-layer fr-active" id="fr-file-upload-layer-' + editor.id + '"><strong>' + editor.language.translate('Drop file') + '</strong><br>(' + editor.language.translate('or click') + ')<div class="fr-form"><input type="file" name="' + editor.opts.fileUploadParam + '" accept="/*" tabIndex="-1" aria-labelledby="fr-file-upload-layer-' + editor.id + '" role="button"></div></div>'
516
+ }
517
+
518
+
519
+ // Progress bar.
520
+ var progress_bar_layer = '<div class="fr-file-progress-bar-layer fr-layer"><h3 tabIndex="-1" class="fr-message">Uploading</h3><div class="fr-loader"><span class="fr-progress"></span></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-dismiss" data-cmd="fileDismissError" tabIndex="2" role="button">OK</button></div></div>';
521
+
522
+ var template = {
523
+ buttons: file_buttons,
524
+ upload_layer: upload_layer,
525
+ progress_bar: progress_bar_layer
526
+ };
527
+
528
+ // Set the template in the popup.
529
+ var $popup = editor.popups.create('file.insert', template);
530
+
531
+ _bindInsertEvents($popup);
532
+
533
+ return $popup;
534
+ }
535
+
536
+ function _onRemove (link) {
537
+ if (editor.node.hasClass(link, 'fr-file')) {
538
+
539
+ return;
540
+ }
541
+ }
542
+
543
+ function _drop (e) {
544
+
545
+ // Check if we are dropping files.
546
+ var dt = e.originalEvent.dataTransfer;
547
+
548
+ if (dt && dt.files && dt.files.length) {
549
+ var file = dt.files[0];
550
+
551
+ if (file && typeof file.type != 'undefined') {
552
+
553
+ // Dropped file is an file that we allow.
554
+ if (file.type.indexOf('image') < 0) {
555
+ if (!editor.opts.fileUpload) {
556
+ e.preventDefault();
557
+ e.stopPropagation();
558
+
559
+ return false;
560
+ }
561
+
562
+
563
+ editor.markers.remove();
564
+ editor.markers.insertAtPoint(e.originalEvent);
565
+ editor.$el.find('.fr-marker').replaceWith($.FE.MARKERS);
566
+
567
+ // Hide popups.
568
+ editor.popups.hideAll();
569
+
570
+ // Show the file insert popup.
571
+ var $popup = editor.popups.get('file.insert');
572
+
573
+ if (!$popup) $popup = _initInsertPopup();
574
+ editor.popups.setContainer('file.insert', editor.$sc);
575
+ editor.popups.show('file.insert', e.originalEvent.pageX, e.originalEvent.pageY);
576
+ showProgressBar();
577
+
578
+ // Upload files.
579
+ upload(dt.files);
580
+
581
+ // Cancel anything else.
582
+ e.preventDefault();
583
+ e.stopPropagation();
584
+
585
+ return false;
586
+ }
587
+ }
588
+ else if (file.type.indexOf('image') < 0) {
589
+ e.preventDefault();
590
+ e.stopPropagation();
591
+ }
592
+ }
593
+ }
594
+
595
+ function _initEvents() {
596
+
597
+ // Drop inside the editor.
598
+ editor.events.on('drop', _drop);
599
+
600
+ editor.events.$on(editor.$win, 'keydown', function (e) {
601
+ var key_code = e.which;
602
+ var $popup = editor.popups.get('file.insert');
603
+
604
+ if ($popup && key_code == $.FE.KEYCODE.ESC) {
605
+ $popup.trigger('abortUpload');
606
+ }
607
+ });
608
+
609
+ editor.events.on('destroy', function () {
610
+ var $popup = editor.popups.get('file.insert');
611
+
612
+ if ($popup) {
613
+ $popup.trigger('abortUpload');
614
+ }
615
+ });
616
+ }
617
+
618
+ function back () {
619
+ editor.events.disableBlur();
620
+ editor.selection.restore();
621
+ editor.events.enableBlur();
622
+
623
+ editor.popups.hide('file.insert');
624
+ editor.toolbar.showInline();
625
+ }
626
+
627
+ var files;
628
+
629
+ function _syncFiles () {
630
+
631
+ // Get current files.
632
+ var c_files = Array.prototype.slice.call(editor.el.querySelectorAll('a.fr-file'));
633
+
634
+ // Current files src.
635
+ var file_srcs = [];
636
+ var i;
637
+
638
+ for (i = 0; i < c_files.length; i++) {
639
+ file_srcs.push(c_files[i].getAttribute('href'));
640
+ }
641
+
642
+ // Loop previous files and check their src.
643
+ if (files) {
644
+ for (i = 0; i < files.length; i++) {
645
+ if (file_srcs.indexOf(files[i].getAttribute('href')) < 0) {
646
+ editor.events.trigger('file.unlink', [files[i]]);
647
+ }
648
+ }
649
+ }
650
+
651
+ // Current files are the old ones.
652
+ files = c_files;
653
+ }
654
+
655
+ /*
656
+ * Initialize.
657
+ */
658
+ function _init () {
659
+ _initEvents();
660
+
661
+ editor.events.on('link.beforeRemove', _onRemove);
662
+
663
+ if (editor.$wp) {
664
+ _syncFiles();
665
+ editor.events.on('contentChanged', _syncFiles);
666
+ }
667
+
668
+ _initInsertPopup(true);
669
+ }
670
+
671
+ return {
672
+ _init: _init,
673
+ showInsertPopup: showInsertPopup,
674
+ upload: upload,
675
+ insert: insert,
676
+ back: back,
677
+ hideProgressBar: hideProgressBar
678
+ }
679
+ }
680
+
681
+ // Insert file button.
682
+ $.FE.DefineIcon('insertFile', {
683
+ NAME: 'file-o',
684
+ FA5NAME: 'file'
685
+ });
686
+ $.FE.RegisterCommand('insertFile', {
687
+ title: 'Upload File',
688
+ undo: false,
689
+ focus: true,
690
+ refreshAfterCallback: false,
691
+ popup: true,
692
+ callback: function () {
693
+ if (!this.popups.isVisible('file.insert')) {
694
+ this.file.showInsertPopup();
695
+ }
696
+ else {
697
+ if (this.$el.find('.fr-marker').length) {
698
+ this.events.disableBlur();
699
+ this.selection.restore();
700
+ }
701
+ this.popups.hide('file.insert');
702
+ }
703
+ },
704
+ plugin: 'file'
705
+ });
706
+
707
+ $.FE.DefineIcon('fileBack', { NAME: 'arrow-left' });
708
+ $.FE.RegisterCommand('fileBack', {
709
+ title: 'Back',
710
+ undo: false,
711
+ focus: false,
712
+ back: true,
713
+ refreshAfterCallback: false,
714
+ callback: function () {
715
+ this.file.back();
716
+ },
717
+ refresh: function ($btn) {
718
+ if (!this.opts.toolbarInline) {
719
+ $btn.addClass('fr-hidden');
720
+ $btn.next('.fr-separator').addClass('fr-hidden');
721
+ }
722
+ else {
723
+ $btn.removeClass('fr-hidden');
724
+ $btn.next('.fr-separator').removeClass('fr-hidden');
725
+ }
726
+ }
727
+ });
728
+
729
+ $.FE.RegisterCommand('fileDismissError', {
730
+ title: 'OK',
731
+ callback: function () {
732
+ this.file.hideProgressBar(true);
733
+ }
734
+ })
735
+
736
+ }));