camaleon_cms_rails6 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (719) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +202 -0
  3. data/Rakefile +32 -0
  4. data/app/apps/plugins/attack/admin_controller.rb +17 -0
  5. data/app/apps/plugins/attack/attack_helper.rb +94 -0
  6. data/app/apps/plugins/attack/config/config.json +31 -0
  7. data/app/apps/plugins/attack/config/custom_models.rb +8 -0
  8. data/app/apps/plugins/attack/config/locales/readme.txt +1 -0
  9. data/app/apps/plugins/attack/config/locales/translation.yml +129 -0
  10. data/app/apps/plugins/attack/config/routes_admin.txt +2 -0
  11. data/app/apps/plugins/attack/models/attack.rb +3 -0
  12. data/app/apps/plugins/attack/views/admin/settings.html.erb +49 -0
  13. data/app/apps/plugins/authoring_post/authoring_post_helper.rb +51 -0
  14. data/app/apps/plugins/authoring_post/config/config.json +24 -0
  15. data/app/apps/plugins/front_cache/admin_controller.rb +29 -0
  16. data/app/apps/plugins/front_cache/config/config.json +21 -0
  17. data/app/apps/plugins/front_cache/config/initializer.rb +7 -0
  18. data/app/apps/plugins/front_cache/config/locales/readme.txt +1 -0
  19. data/app/apps/plugins/front_cache/config/locales/translation.yml +149 -0
  20. data/app/apps/plugins/front_cache/config/routes_admin.txt +3 -0
  21. data/app/apps/plugins/front_cache/front_cache_helper.rb +137 -0
  22. data/app/apps/plugins/front_cache/views/admin/settings.html.erb +81 -0
  23. data/app/apps/plugins/visibility_post/assets/js/form.js +30 -0
  24. data/app/apps/plugins/visibility_post/config/config.json +24 -0
  25. data/app/apps/plugins/visibility_post/visibility_post_helper.rb +124 -0
  26. data/app/apps/themes/camaleon_first/assets/css/magnific-ver.css +394 -0
  27. data/app/apps/themes/camaleon_first/assets/css/main.css +16 -0
  28. data/app/apps/themes/camaleon_first/assets/css/style-ver.css.scss +251 -0
  29. data/app/apps/themes/camaleon_first/assets/css/wpbase.css +1 -0
  30. data/app/apps/themes/camaleon_first/assets/images/empe.jpg +0 -0
  31. data/app/apps/themes/camaleon_first/assets/images/image.png +0 -0
  32. data/app/apps/themes/camaleon_first/assets/images/loader.gif +0 -0
  33. data/app/apps/themes/camaleon_first/assets/images/zoom.png +0 -0
  34. data/app/apps/themes/camaleon_first/assets/js/hover.zoom.js +67 -0
  35. data/app/apps/themes/camaleon_first/assets/js/magnific.min.js +3 -0
  36. data/app/apps/themes/camaleon_first/assets/js/main-ver.js +46 -0
  37. data/app/apps/themes/camaleon_first/assets/js/main.js +18 -0
  38. data/app/apps/themes/camaleon_first/assets/js/modernizr.custom.js +4 -0
  39. data/app/apps/themes/camaleon_first/config/config.json +14 -0
  40. data/app/apps/themes/camaleon_first/main_helper.rb +33 -0
  41. data/app/apps/themes/camaleon_first/views/index.html.erb +28 -0
  42. data/app/apps/themes/camaleon_first/views/layouts/camaleon_cms/mailer.html.erb +22 -0
  43. data/app/apps/themes/camaleon_first/views/layouts/index.html.erb +84 -0
  44. data/app/apps/themes/camaleon_first/views/mailer.html.erb +4 -0
  45. data/app/apps/themes/camaleon_first/views/partials/readme.txt +1 -0
  46. data/app/apps/themes/camaleon_first/views/template_sample_page.html.erb +6 -0
  47. data/app/apps/themes/default/assets/css/main.css +13 -0
  48. data/app/apps/themes/default/assets/css/style.css.scss +3398 -0
  49. data/app/apps/themes/default/assets/css/styles.css.scss +175 -0
  50. data/app/apps/themes/default/assets/genericons/COPYING.txt +9 -0
  51. data/app/apps/themes/default/assets/genericons/Genericons-Regular.otf +0 -0
  52. data/app/apps/themes/default/assets/genericons/LICENSE.txt +339 -0
  53. data/app/apps/themes/default/assets/genericons/README.txt +123 -0
  54. data/app/apps/themes/default/assets/genericons/font/genericons-regular-webfont.eot +0 -0
  55. data/app/apps/themes/default/assets/genericons/font/genericons-regular-webfont.svg +135 -0
  56. data/app/apps/themes/default/assets/genericons/font/genericons-regular-webfont.ttf +0 -0
  57. data/app/apps/themes/default/assets/genericons/font/genericons-regular-webfont.woff +0 -0
  58. data/app/apps/themes/default/assets/genericons/genericons.css +197 -0
  59. data/app/apps/themes/default/assets/images/circle.png +0 -0
  60. data/app/apps/themes/default/assets/images/dotted-line-2x.png +0 -0
  61. data/app/apps/themes/default/assets/images/dotted-line-light-2x.png +0 -0
  62. data/app/apps/themes/default/assets/images/dotted-line-light.png +0 -0
  63. data/app/apps/themes/default/assets/images/dotted-line.png +0 -0
  64. data/app/apps/themes/default/assets/images/headers/circle-thumbnail.png +0 -0
  65. data/app/apps/themes/default/assets/images/headers/circle.png +0 -0
  66. data/app/apps/themes/default/assets/images/headers/diamond-thumbnail.png +0 -0
  67. data/app/apps/themes/default/assets/images/headers/diamond.png +0 -0
  68. data/app/apps/themes/default/assets/images/headers/star-thumbnail.png +0 -0
  69. data/app/apps/themes/default/assets/images/headers/star.png +0 -0
  70. data/app/apps/themes/default/assets/images/image.png +0 -0
  71. data/app/apps/themes/default/assets/images/search-icon-2x.png +0 -0
  72. data/app/apps/themes/default/assets/images/search-icon.png +0 -0
  73. data/app/apps/themes/default/assets/js/main.js +13 -0
  74. data/app/apps/themes/default/config/config.json +19 -0
  75. data/app/apps/themes/default/default_helper.rb +28 -0
  76. data/app/apps/themes/default/views/admin/settings.html.erb +0 -0
  77. data/app/apps/themes/default/views/category.html.erb +16 -0
  78. data/app/apps/themes/default/views/index.html.erb +35 -0
  79. data/app/apps/themes/default/views/layouts/index.html.erb +84 -0
  80. data/app/apps/themes/default/views/page.html.erb +14 -0
  81. data/app/apps/themes/default/views/partials/_breadcrumb.html.erb +10 -0
  82. data/app/apps/themes/default/views/partials/_categories_list.html.erb +23 -0
  83. data/app/apps/themes/default/views/partials/_comments.html.erb +40 -0
  84. data/app/apps/themes/default/views/partials/_comments_list.html.erb +20 -0
  85. data/app/apps/themes/default/views/partials/_flash_messages.html.erb +26 -0
  86. data/app/apps/themes/default/views/partials/_forms.html.erb +19 -0
  87. data/app/apps/themes/default/views/partials/_post_list_item.html.erb +34 -0
  88. data/app/apps/themes/default/views/partials/_search_form.html.erb +8 -0
  89. data/app/apps/themes/default/views/partials/_sidebar.html.erb +50 -0
  90. data/app/apps/themes/default/views/post.html.erb +14 -0
  91. data/app/apps/themes/default/views/post_tag.html.erb +14 -0
  92. data/app/apps/themes/default/views/post_type.html.erb +33 -0
  93. data/app/apps/themes/default/views/search.html.erb +17 -0
  94. data/app/apps/themes/new/assets/css/main.css +14 -0
  95. data/app/apps/themes/new/assets/css/styles.css.scss +175 -0
  96. data/app/apps/themes/new/assets/images/image.png +0 -0
  97. data/app/apps/themes/new/assets/js/main.js +14 -0
  98. data/app/apps/themes/new/config/config.json +26 -0
  99. data/app/apps/themes/new/custom_helper.rb +31 -0
  100. data/app/apps/themes/new/image.png +0 -0
  101. data/app/apps/themes/new/views/admin/settings.html.erb +1 -0
  102. data/app/apps/themes/new/views/category.html.erb +33 -0
  103. data/app/apps/themes/new/views/index.html.erb +71 -0
  104. data/app/apps/themes/new/views/layouts/_footer.html.erb +17 -0
  105. data/app/apps/themes/new/views/layouts/_header.html.erb +38 -0
  106. data/app/apps/themes/new/views/layouts/index.html.erb +32 -0
  107. data/app/apps/themes/new/views/page.html.erb +16 -0
  108. data/app/apps/themes/new/views/post.html.erb +20 -0
  109. data/app/apps/themes/new/views/post_tag.html.erb +22 -0
  110. data/app/apps/themes/new/views/post_type.html.erb +33 -0
  111. data/app/apps/themes/new/views/search.html.erb +18 -0
  112. data/app/assets/config/camaleon-cms.js +7 -0
  113. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.eot +0 -0
  114. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.svg +288 -0
  115. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.ttf +0 -0
  116. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.woff +0 -0
  117. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.woff2 +0 -0
  118. data/app/assets/images/camaleon.png +0 -0
  119. data/app/assets/images/camaleon_cms/admin/admin_spinner.gif +0 -0
  120. data/app/assets/images/camaleon_cms/admin/glyphicons-halflings.png +0 -0
  121. data/app/assets/images/camaleon_cms/admin/intro/menus.png +0 -0
  122. data/app/assets/images/camaleon_cms/admin/no_image.jpg +0 -0
  123. data/app/assets/images/camaleon_cms/bg-tree.jpeg +0 -0
  124. data/app/assets/images/camaleon_cms/camaleon-dark.png +0 -0
  125. data/app/assets/images/camaleon_cms/camaleon.png +0 -0
  126. data/app/assets/images/camaleon_cms/category-icon.png +0 -0
  127. data/app/assets/images/camaleon_cms/favicon.ico +0 -0
  128. data/app/assets/images/camaleon_cms/image-not-found.png +0 -0
  129. data/app/assets/images/camaleon_cms/language/de.png +0 -0
  130. data/app/assets/images/camaleon_cms/language/en.png +0 -0
  131. data/app/assets/images/camaleon_cms/language/es.png +0 -0
  132. data/app/assets/images/camaleon_cms/language/fr.png +0 -0
  133. data/app/assets/images/camaleon_cms/language/it.png +0 -0
  134. data/app/assets/images/camaleon_cms/language/nl.png +0 -0
  135. data/app/assets/images/camaleon_cms/language/pl.png +0 -0
  136. data/app/assets/images/camaleon_cms/language/pt-BR.png +0 -0
  137. data/app/assets/images/camaleon_cms/language/pt.png +0 -0
  138. data/app/assets/images/camaleon_cms/language/ru.png +0 -0
  139. data/app/assets/images/camaleon_cms/language/uk.png +0 -0
  140. data/app/assets/images/camaleon_cms/language/zh-CN.png +0 -0
  141. data/app/assets/images/camaleon_cms/loader.gif +0 -0
  142. data/app/assets/images/camaleon_cms/users/no-image.jpg +0 -0
  143. data/app/assets/javascripts/camaleon_cms/admin/_actions.js +91 -0
  144. data/app/assets/javascripts/camaleon_cms/admin/_bootstrap-datepicker.js +2558 -0
  145. data/app/assets/javascripts/camaleon_cms/admin/_bootstrap-select.js +7 -0
  146. data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +273 -0
  147. data/app/assets/javascripts/camaleon_cms/admin/_data.js +69 -0
  148. data/app/assets/javascripts/camaleon_cms/admin/_i18n.js +32 -0
  149. data/app/assets/javascripts/camaleon_cms/admin/_jquery-ui.min.js +10 -0
  150. data/app/assets/javascripts/camaleon_cms/admin/_jquery.slugify.js +67 -0
  151. data/app/assets/javascripts/camaleon_cms/admin/_jquery.tagsinput.min.js +1 -0
  152. data/app/assets/javascripts/camaleon_cms/admin/_libraries.js +136 -0
  153. data/app/assets/javascripts/camaleon_cms/admin/_modal.js +156 -0
  154. data/app/assets/javascripts/camaleon_cms/admin/_post.js +317 -0
  155. data/app/assets/javascripts/camaleon_cms/admin/_posttype.js.coffee +27 -0
  156. data/app/assets/javascripts/camaleon_cms/admin/_translator.js +123 -0
  157. data/app/assets/javascripts/camaleon_cms/admin/_underscore.js +1536 -0
  158. data/app/assets/javascripts/camaleon_cms/admin/_user_profile.js +28 -0
  159. data/app/assets/javascripts/camaleon_cms/admin/admin-basic-manifest.js +3 -0
  160. data/app/assets/javascripts/camaleon_cms/admin/admin-manifest.js +55 -0
  161. data/app/assets/javascripts/camaleon_cms/admin/bootstrap-colorpicker.js +540 -0
  162. data/app/assets/javascripts/camaleon_cms/admin/custom_fields_form.js +94 -0
  163. data/app/assets/javascripts/camaleon_cms/admin/introjs/_intro.min.js +1317 -0
  164. data/app/assets/javascripts/camaleon_cms/admin/jquery-sieve.js +6 -0
  165. data/app/assets/javascripts/camaleon_cms/admin/jquery.nestable.js +485 -0
  166. data/app/assets/javascripts/camaleon_cms/admin/jquery.validate.js +123 -0
  167. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/de.js +20 -0
  168. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/es.js +27 -0
  169. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/fr.js +49 -0
  170. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/it.js +23 -0
  171. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/nl.js +33 -0
  172. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/pt-BR.js +74 -0
  173. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/ru.js +19 -0
  174. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/uk.js +23 -0
  175. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/zh-CN.js +23 -0
  176. data/app/assets/javascripts/camaleon_cms/admin/lte/app.js +758 -0
  177. data/app/assets/javascripts/camaleon_cms/admin/momentjs/_moment.js +3606 -0
  178. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ar.js +136 -0
  179. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ca.js +79 -0
  180. data/app/assets/javascripts/camaleon_cms/admin/momentjs/de.js +76 -0
  181. data/app/assets/javascripts/camaleon_cms/admin/momentjs/es.js +79 -0
  182. data/app/assets/javascripts/camaleon_cms/admin/momentjs/fr.js +62 -0
  183. data/app/assets/javascripts/camaleon_cms/admin/momentjs/it.js +70 -0
  184. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ja.js +65 -0
  185. data/app/assets/javascripts/camaleon_cms/admin/momentjs/nl.js +71 -0
  186. data/app/assets/javascripts/camaleon_cms/admin/momentjs/pl.js +105 -0
  187. data/app/assets/javascripts/camaleon_cms/admin/momentjs/pt-BR.js +60 -0
  188. data/app/assets/javascripts/camaleon_cms/admin/momentjs/pt.js +64 -0
  189. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ru.js +166 -0
  190. data/app/assets/javascripts/camaleon_cms/admin/momentjs/uk.js +151 -0
  191. data/app/assets/javascripts/camaleon_cms/admin/momentjs/zh-CN.js +127 -0
  192. data/app/assets/javascripts/camaleon_cms/admin/nav_menu.js.coffee +139 -0
  193. data/app/assets/javascripts/camaleon_cms/admin/tageditor/_jquery.caret.min.js +2 -0
  194. data/app/assets/javascripts/camaleon_cms/admin/tageditor/_jquery.tag-editor.js +352 -0
  195. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/de.js +219 -0
  196. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/en.js +179 -0
  197. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/es.js +177 -0
  198. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/fr.js +219 -0
  199. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/it.js +219 -0
  200. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/nl.js +219 -0
  201. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/pt-BR.js +219 -0
  202. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/readme.md +3 -0
  203. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/ru.js +219 -0
  204. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/uk.js +219 -0
  205. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/zh-CN.js +228 -0
  206. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/filemanager/plugin.min.js +30 -0
  207. data/app/assets/javascripts/camaleon_cms/admin/uploader/_cropper.min.js +3003 -0
  208. data/app/assets/javascripts/camaleon_cms/admin/uploader/_jquery.form.js +1277 -0
  209. data/app/assets/javascripts/camaleon_cms/admin/uploader/_jquery.uploadfile.min.js +8 -0
  210. data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +455 -0
  211. data/app/assets/javascripts/camaleon_cms/admin/uploader/uploader_manifest.js +5 -0
  212. data/app/assets/javascripts/camaleon_cms/bootstrap.min.js +7 -0
  213. data/app/assets/stylesheets/camaleon_cms/admin/_bootstrap-datepicker.css.scss +373 -0
  214. data/app/assets/stylesheets/camaleon_cms/admin/_bootstrap-select.css +7 -0
  215. data/app/assets/stylesheets/camaleon_cms/admin/_custom_admin.css.scss +359 -0
  216. data/app/assets/stylesheets/camaleon_cms/admin/_jquery.tagsinput.css +72 -0
  217. data/app/assets/stylesheets/camaleon_cms/admin/admin-basic-manifest.css +16 -0
  218. data/app/assets/stylesheets/camaleon_cms/admin/admin-manifest.css +28 -0
  219. data/app/assets/stylesheets/camaleon_cms/admin/colorpicker.css.scss +96 -0
  220. data/app/assets/stylesheets/camaleon_cms/admin/img/bg.png +0 -0
  221. data/app/assets/stylesheets/camaleon_cms/admin/img/colorpicker/alpha.png +0 -0
  222. data/app/assets/stylesheets/camaleon_cms/admin/img/colorpicker/hue.png +0 -0
  223. data/app/assets/stylesheets/camaleon_cms/admin/img/colorpicker/saturation.png +0 -0
  224. data/app/assets/stylesheets/camaleon_cms/admin/img/girls-1.jpg +0 -0
  225. data/app/assets/stylesheets/camaleon_cms/admin/img/jquery/resize-icon.png +0 -0
  226. data/app/assets/stylesheets/camaleon_cms/admin/img/loading.gif +1 -0
  227. data/app/assets/stylesheets/camaleon_cms/admin/img/logo-small.png +0 -0
  228. data/app/assets/stylesheets/camaleon_cms/admin/img/logo.png +0 -0
  229. data/app/assets/stylesheets/camaleon_cms/admin/img/no_image.jpg +0 -0
  230. data/app/assets/stylesheets/camaleon_cms/admin/img/rormeleon-white.png +0 -0
  231. data/app/assets/stylesheets/camaleon_cms/admin/img/thumb_no_found.jpg +0 -0
  232. data/app/assets/stylesheets/camaleon_cms/admin/introjs/_introjs.min.css +1 -0
  233. data/app/assets/stylesheets/camaleon_cms/admin/jquery/_jquery-ui.scss +1226 -0
  234. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  235. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  236. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  237. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  238. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  239. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  240. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  241. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  242. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-icons_222222_256x240.png +0 -0
  243. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  244. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-icons_454545_256x240.png +0 -0
  245. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-icons_888888_256x240.png +0 -0
  246. data/app/assets/stylesheets/camaleon_cms/admin/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  247. data/app/assets/stylesheets/camaleon_cms/admin/lte/_admin.css.scss +4561 -0
  248. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-black-light.css +176 -0
  249. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-black.css +154 -0
  250. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-blue-light.css +167 -0
  251. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-blue.css +142 -0
  252. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-green-light.css +156 -0
  253. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-green.css +134 -0
  254. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-purple-light.css +156 -0
  255. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-purple.css +135 -0
  256. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-red-light.css +156 -0
  257. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-red.css +134 -0
  258. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-yellow-light.css +156 -0
  259. data/app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-yellow.css +134 -0
  260. data/app/assets/stylesheets/camaleon_cms/admin/nestable/jquery.nestable.css +103 -0
  261. data/app/assets/stylesheets/camaleon_cms/admin/tageditor/_jquery.tag-editor.css.scss +49 -0
  262. data/app/assets/stylesheets/camaleon_cms/admin/uploader/_cropper.min.css +9 -0
  263. data/app/assets/stylesheets/camaleon_cms/admin/uploader/_uploadfile.css.scss +256 -0
  264. data/app/assets/stylesheets/camaleon_cms/admin/uploader/uploader_manifest.css +4 -0
  265. data/app/assets/stylesheets/camaleon_cms/admin/widgets.css.scss +26 -0
  266. data/app/assets/stylesheets/camaleon_cms/bootstrap.min.css.scss +6799 -0
  267. data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +129 -0
  268. data/app/controllers/camaleon_cms/admin/appearances/themes_controller.rb +29 -0
  269. data/app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb +41 -0
  270. data/app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb +55 -0
  271. data/app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb +56 -0
  272. data/app/controllers/camaleon_cms/admin/categories_controller.rb +80 -0
  273. data/app/controllers/camaleon_cms/admin/comments_controller.rb +90 -0
  274. data/app/controllers/camaleon_cms/admin/installers_controller.rb +32 -0
  275. data/app/controllers/camaleon_cms/admin/media_controller.rb +109 -0
  276. data/app/controllers/camaleon_cms/admin/plugins_controller.rb +46 -0
  277. data/app/controllers/camaleon_cms/admin/post_tags_controller.rb +81 -0
  278. data/app/controllers/camaleon_cms/admin/posts/drafts_controller.rb +58 -0
  279. data/app/controllers/camaleon_cms/admin/posts_controller.rb +212 -0
  280. data/app/controllers/camaleon_cms/admin/sessions_controller.rb +172 -0
  281. data/app/controllers/camaleon_cms/admin/settings/custom_fields_controller.rb +108 -0
  282. data/app/controllers/camaleon_cms/admin/settings/post_types_controller.rb +63 -0
  283. data/app/controllers/camaleon_cms/admin/settings/sites_controller.rb +87 -0
  284. data/app/controllers/camaleon_cms/admin/settings_controller.rb +86 -0
  285. data/app/controllers/camaleon_cms/admin/user_roles_controller.rb +74 -0
  286. data/app/controllers/camaleon_cms/admin/users_controller.rb +124 -0
  287. data/app/controllers/camaleon_cms/admin_controller.rb +82 -0
  288. data/app/controllers/camaleon_cms/apps/plugins_admin_controller.rb +19 -0
  289. data/app/controllers/camaleon_cms/apps/plugins_front_controller.rb +19 -0
  290. data/app/controllers/camaleon_cms/apps/themes_admin_controller.rb +12 -0
  291. data/app/controllers/camaleon_cms/apps/themes_front_controller.rb +12 -0
  292. data/app/controllers/camaleon_cms/camaleon_controller.rb +139 -0
  293. data/app/controllers/camaleon_cms/frontend_controller.rb +277 -0
  294. data/app/controllers/concerns/camaleon_cms/frontend_concern.rb +66 -0
  295. data/app/decorators/camaleon_cms/application_decorator.rb +54 -0
  296. data/app/decorators/camaleon_cms/category_decorator.rb +58 -0
  297. data/app/decorators/camaleon_cms/custom_field_decorator.rb +11 -0
  298. data/app/decorators/camaleon_cms/custom_fields_concern.rb +81 -0
  299. data/app/decorators/camaleon_cms/metas_decorator_methods.rb +11 -0
  300. data/app/decorators/camaleon_cms/nav_menu_item_decorator.rb +4 -0
  301. data/app/decorators/camaleon_cms/plugin_decorator.rb +3 -0
  302. data/app/decorators/camaleon_cms/post_comment_decorator.rb +39 -0
  303. data/app/decorators/camaleon_cms/post_decorator.rb +251 -0
  304. data/app/decorators/camaleon_cms/post_tag_decorator.rb +45 -0
  305. data/app/decorators/camaleon_cms/post_type_decorator.rb +87 -0
  306. data/app/decorators/camaleon_cms/site_decorator.rb +200 -0
  307. data/app/decorators/camaleon_cms/term_taxonomy_decorator.rb +93 -0
  308. data/app/decorators/camaleon_cms/theme_decorator.rb +18 -0
  309. data/app/decorators/camaleon_cms/user_decorator.rb +73 -0
  310. data/app/decorators/camaleon_cms/user_role_decorator.rb +12 -0
  311. data/app/decorators/camaleon_cms/widget_decorator.rb +4 -0
  312. data/app/helpers/camaleon_cms/admin/application_helper.rb +36 -0
  313. data/app/helpers/camaleon_cms/admin/breadcrumb_helper.rb +15 -0
  314. data/app/helpers/camaleon_cms/admin/category_helper.rb +24 -0
  315. data/app/helpers/camaleon_cms/admin/custom_fields_helper.rb +354 -0
  316. data/app/helpers/camaleon_cms/admin/menus_helper.rb +182 -0
  317. data/app/helpers/camaleon_cms/admin/post_type_helper.rb +67 -0
  318. data/app/helpers/camaleon_cms/camaleon_helper.rb +88 -0
  319. data/app/helpers/camaleon_cms/captcha_helper.rb +93 -0
  320. data/app/helpers/camaleon_cms/comment_helper.rb +48 -0
  321. data/app/helpers/camaleon_cms/content_helper.rb +29 -0
  322. data/app/helpers/camaleon_cms/email_helper.rb +56 -0
  323. data/app/helpers/camaleon_cms/frontend/application_helper.rb +36 -0
  324. data/app/helpers/camaleon_cms/frontend/content_select_helper.rb +161 -0
  325. data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +237 -0
  326. data/app/helpers/camaleon_cms/frontend/seo_helper.rb +86 -0
  327. data/app/helpers/camaleon_cms/frontend/site_helper.rb +70 -0
  328. data/app/helpers/camaleon_cms/hooks_helper.rb +57 -0
  329. data/app/helpers/camaleon_cms/html_helper.rb +134 -0
  330. data/app/helpers/camaleon_cms/plugins_helper.rb +173 -0
  331. data/app/helpers/camaleon_cms/session_helper.rb +161 -0
  332. data/app/helpers/camaleon_cms/short_code_helper.rb +283 -0
  333. data/app/helpers/camaleon_cms/site_helper.rb +103 -0
  334. data/app/helpers/camaleon_cms/theme_helper.rb +95 -0
  335. data/app/helpers/camaleon_cms/uploader_helper.rb +329 -0
  336. data/app/helpers/camaleon_cms/user_roles_helper.rb +13 -0
  337. data/app/mailers/camaleon_cms/html_mailer.rb +87 -0
  338. data/app/models/camaleon_cms/ability.rb +109 -0
  339. data/app/models/camaleon_cms/category.rb +52 -0
  340. data/app/models/camaleon_cms/custom_field.rb +35 -0
  341. data/app/models/camaleon_cms/custom_field_group.rb +136 -0
  342. data/app/models/camaleon_cms/custom_fields_relationship.rb +27 -0
  343. data/app/models/camaleon_cms/media.rb +54 -0
  344. data/app/models/camaleon_cms/meta.rb +4 -0
  345. data/app/models/camaleon_cms/nav_menu.rb +29 -0
  346. data/app/models/camaleon_cms/nav_menu_item.rb +64 -0
  347. data/app/models/camaleon_cms/plugin.rb +76 -0
  348. data/app/models/camaleon_cms/post.rb +265 -0
  349. data/app/models/camaleon_cms/post_comment.rb +44 -0
  350. data/app/models/camaleon_cms/post_default.rb +78 -0
  351. data/app/models/camaleon_cms/post_relationship.rb +20 -0
  352. data/app/models/camaleon_cms/post_tag.rb +7 -0
  353. data/app/models/camaleon_cms/post_type.rb +189 -0
  354. data/app/models/camaleon_cms/site.rb +242 -0
  355. data/app/models/camaleon_cms/term_relationship.rb +18 -0
  356. data/app/models/camaleon_cms/term_taxonomy.rb +61 -0
  357. data/app/models/camaleon_cms/theme.rb +31 -0
  358. data/app/models/camaleon_cms/user.rb +18 -0
  359. data/app/models/camaleon_cms/user_role.rb +138 -0
  360. data/app/models/camaleon_cms/widget.rb +5 -0
  361. data/app/models/camaleon_cms/widget/assigned.rb +27 -0
  362. data/app/models/camaleon_cms/widget/main.rb +44 -0
  363. data/app/models/camaleon_cms/widget/sidebar.rb +20 -0
  364. data/app/models/concerns/camaleon_cms/categories_tags_for_posts.rb +132 -0
  365. data/app/models/concerns/camaleon_cms/custom_fields_read.rb +310 -0
  366. data/app/models/concerns/camaleon_cms/metas.rb +138 -0
  367. data/app/models/concerns/camaleon_cms/site_default_settings.rb +87 -0
  368. data/app/models/concerns/camaleon_cms/user_methods.rb +133 -0
  369. data/app/models/plugins.rb +5 -0
  370. data/app/models/themes.rb +5 -0
  371. data/app/uploaders/camaleon_cms_aws_uploader.rb +132 -0
  372. data/app/uploaders/camaleon_cms_local_uploader.rb +108 -0
  373. data/app/uploaders/camaleon_cms_uploader.rb +164 -0
  374. data/app/views/camaleon_cms/404.html.erb +4 -0
  375. data/app/views/camaleon_cms/500.html.erb +4 -0
  376. data/app/views/camaleon_cms/_flash_messages.html.erb +39 -0
  377. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_fields.html.erb +6 -0
  378. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_menus.html.erb +42 -0
  379. data/app/views/camaleon_cms/admin/appearances/nav_menus/_external_menu.html.erb +23 -0
  380. data/app/views/camaleon_cms/admin/appearances/nav_menus/_form.html.erb +13 -0
  381. data/app/views/camaleon_cms/admin/appearances/nav_menus/_left_menu_items.html.erb +77 -0
  382. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items.html.erb +19 -0
  383. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items_list.html.erb +12 -0
  384. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_options.html.erb +21 -0
  385. data/app/views/camaleon_cms/admin/appearances/nav_menus/index.html.erb +14 -0
  386. data/app/views/camaleon_cms/admin/appearances/themes/index.html.erb +70 -0
  387. data/app/views/camaleon_cms/admin/appearances/themes/preview.html.erb +1 -0
  388. data/app/views/camaleon_cms/admin/appearances/themes/theme_load_data.html.erb +40 -0
  389. data/app/views/camaleon_cms/admin/appearances/widgets/assign/_form.html.erb +35 -0
  390. data/app/views/camaleon_cms/admin/appearances/widgets/main/_sidebar.html.erb +29 -0
  391. data/app/views/camaleon_cms/admin/appearances/widgets/main/form.html.erb +27 -0
  392. data/app/views/camaleon_cms/admin/appearances/widgets/main/index.html.erb +41 -0
  393. data/app/views/camaleon_cms/admin/appearances/widgets/sidebar/form.html.erb +23 -0
  394. data/app/views/camaleon_cms/admin/categories/_form.html.erb +34 -0
  395. data/app/views/camaleon_cms/admin/categories/edit.html.erb +14 -0
  396. data/app/views/camaleon_cms/admin/categories/index.html.erb +68 -0
  397. data/app/views/camaleon_cms/admin/comments/form.html.erb +12 -0
  398. data/app/views/camaleon_cms/admin/comments/form_answer.html.erb +12 -0
  399. data/app/views/camaleon_cms/admin/comments/index.html.erb +21 -0
  400. data/app/views/camaleon_cms/admin/comments/list.html.erb +36 -0
  401. data/app/views/camaleon_cms/admin/dashboard.html.erb +25 -0
  402. data/app/views/camaleon_cms/admin/installers/form.html.erb +19 -0
  403. data/app/views/camaleon_cms/admin/installers/welcome.html.erb +8 -0
  404. data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +57 -0
  405. data/app/views/camaleon_cms/admin/media/index.html.erb +70 -0
  406. data/app/views/camaleon_cms/admin/plugins/_plugins_list.html.erb +43 -0
  407. data/app/views/camaleon_cms/admin/plugins/index.html.erb +43 -0
  408. data/app/views/camaleon_cms/admin/post_tags/_form.html.erb +26 -0
  409. data/app/views/camaleon_cms/admin/post_tags/edit.html.erb +14 -0
  410. data/app/views/camaleon_cms/admin/post_tags/index.html.erb +59 -0
  411. data/app/views/camaleon_cms/admin/posts/_filter_posts.html.erb +5 -0
  412. data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +156 -0
  413. data/app/views/camaleon_cms/admin/posts/form.html.erb +96 -0
  414. data/app/views/camaleon_cms/admin/posts/index.html.erb +112 -0
  415. data/app/views/camaleon_cms/admin/posts/show.html.erb +20 -0
  416. data/app/views/camaleon_cms/admin/search.html.erb +73 -0
  417. data/app/views/camaleon_cms/admin/sessions/forgot.html.erb +44 -0
  418. data/app/views/camaleon_cms/admin/sessions/login.html.erb +47 -0
  419. data/app/views/camaleon_cms/admin/sessions/register.html.erb +63 -0
  420. data/app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb +75 -0
  421. data/app/views/camaleon_cms/admin/settings/_email_settings.html.erb +58 -0
  422. data/app/views/camaleon_cms/admin/settings/_file_system_settings.html.erb +32 -0
  423. data/app/views/camaleon_cms/admin/settings/_media_settings.html.erb +14 -0
  424. data/app/views/camaleon_cms/admin/settings/_seo_settings.html.erb +22 -0
  425. data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +185 -0
  426. data/app/views/camaleon_cms/admin/settings/custom_fields/_meta_data.html.erb +93 -0
  427. data/app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb +50 -0
  428. data/app/views/camaleon_cms/admin/settings/custom_fields/_render_category_simple.html.erb +25 -0
  429. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_audio.html.erb +4 -0
  430. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_categories.html.erb +11 -0
  431. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkbox.html.erb +8 -0
  432. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkboxes.html.erb +5 -0
  433. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_colorpicker.html.erb +7 -0
  434. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_date.html.erb +6 -0
  435. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_editor.html.erb +3 -0
  436. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_email.html.erb +3 -0
  437. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_field_attrs.html.erb +8 -0
  438. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_file.html.erb +4 -0
  439. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_image.html.erb +16 -0
  440. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_numeric.html.erb +4 -0
  441. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_phone.html.erb +3 -0
  442. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_post_types.html.erb +8 -0
  443. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_posts.html.erb +14 -0
  444. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_private_file.html.erb +4 -0
  445. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_radio.html.erb +5 -0
  446. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_select.html.erb +7 -0
  447. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_select_eval.html.erb +3 -0
  448. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_text_area.html.erb +3 -0
  449. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_text_box.html.erb +3 -0
  450. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_url.html.erb +3 -0
  451. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_users.html.erb +8 -0
  452. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_video.html.erb +4 -0
  453. data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +167 -0
  454. data/app/views/camaleon_cms/admin/settings/custom_fields/index.html.erb +111 -0
  455. data/app/views/camaleon_cms/admin/settings/languages.html.erb +60 -0
  456. data/app/views/camaleon_cms/admin/settings/post_types/_form.html.erb +171 -0
  457. data/app/views/camaleon_cms/admin/settings/post_types/edit.html.erb +14 -0
  458. data/app/views/camaleon_cms/admin/settings/post_types/index.html.erb +55 -0
  459. data/app/views/camaleon_cms/admin/settings/shortcodes.html.erb +37 -0
  460. data/app/views/camaleon_cms/admin/settings/site.html.erb +98 -0
  461. data/app/views/camaleon_cms/admin/settings/sites/form.html.erb +35 -0
  462. data/app/views/camaleon_cms/admin/settings/sites/index.html.erb +60 -0
  463. data/app/views/camaleon_cms/admin/settings/theme.html.erb +20 -0
  464. data/app/views/camaleon_cms/admin/user_roles/form.html.erb +156 -0
  465. data/app/views/camaleon_cms/admin/user_roles/index.html.erb +57 -0
  466. data/app/views/camaleon_cms/admin/users/form.html.erb +161 -0
  467. data/app/views/camaleon_cms/admin/users/index.html.erb +63 -0
  468. data/app/views/camaleon_cms/admin/users/profile.html.erb +1 -0
  469. data/app/views/camaleon_cms/admin/users/profile/_activity.html.erb +180 -0
  470. data/app/views/camaleon_cms/admin/users/profile/_settings.html.erb +15 -0
  471. data/app/views/camaleon_cms/default_theme/category.html.erb +26 -0
  472. data/app/views/camaleon_cms/default_theme/category.json.jbuilder +15 -0
  473. data/app/views/camaleon_cms/default_theme/category.rss.builder +23 -0
  474. data/app/views/camaleon_cms/default_theme/custom_fields/audio.html.erb +3 -0
  475. data/app/views/camaleon_cms/default_theme/custom_fields/checkbox.html.erb +3 -0
  476. data/app/views/camaleon_cms/default_theme/custom_fields/checkboxes.html.erb +3 -0
  477. data/app/views/camaleon_cms/default_theme/custom_fields/colorpicker.html.erb +3 -0
  478. data/app/views/camaleon_cms/default_theme/custom_fields/date.html.erb +3 -0
  479. data/app/views/camaleon_cms/default_theme/custom_fields/editor.html.erb +3 -0
  480. data/app/views/camaleon_cms/default_theme/custom_fields/email.html.erb +3 -0
  481. data/app/views/camaleon_cms/default_theme/custom_fields/field_attrs.html.erb +3 -0
  482. data/app/views/camaleon_cms/default_theme/custom_fields/file.html.erb +3 -0
  483. data/app/views/camaleon_cms/default_theme/custom_fields/image.html.erb +3 -0
  484. data/app/views/camaleon_cms/default_theme/custom_fields/numeric.html.erb +3 -0
  485. data/app/views/camaleon_cms/default_theme/custom_fields/phone.html.erb +3 -0
  486. data/app/views/camaleon_cms/default_theme/custom_fields/posts.html.erb +3 -0
  487. data/app/views/camaleon_cms/default_theme/custom_fields/radio.html.erb +3 -0
  488. data/app/views/camaleon_cms/default_theme/custom_fields/select.html.erb +3 -0
  489. data/app/views/camaleon_cms/default_theme/custom_fields/select_eval.html.erb +3 -0
  490. data/app/views/camaleon_cms/default_theme/custom_fields/text_area.html.erb +3 -0
  491. data/app/views/camaleon_cms/default_theme/custom_fields/text_box.html.erb +3 -0
  492. data/app/views/camaleon_cms/default_theme/custom_fields/url.html.erb +3 -0
  493. data/app/views/camaleon_cms/default_theme/custom_fields/users.html.erb +3 -0
  494. data/app/views/camaleon_cms/default_theme/custom_fields/video.html.erb +3 -0
  495. data/app/views/camaleon_cms/default_theme/index.html.erb +70 -0
  496. data/app/views/camaleon_cms/default_theme/index.json.jbuilder +14 -0
  497. data/app/views/camaleon_cms/default_theme/partials/_breadcrumb.html.erb +10 -0
  498. data/app/views/camaleon_cms/default_theme/partials/_cama_category_entry.json.jbuilder +6 -0
  499. data/app/views/camaleon_cms/default_theme/partials/_cama_comments_entry.json.jbuilder +6 -0
  500. data/app/views/camaleon_cms/default_theme/partials/_cama_post_entry.json.jbuilder +6 -0
  501. data/app/views/camaleon_cms/default_theme/partials/_cama_post_type_entry.json.jbuilder +6 -0
  502. data/app/views/camaleon_cms/default_theme/partials/_cama_posts_entries.json.jbuilder +8 -0
  503. data/app/views/camaleon_cms/default_theme/partials/_cama_tag_entry.json.jbuilder +5 -0
  504. data/app/views/camaleon_cms/default_theme/partials/_cama_user_entry.json.jbuilder +5 -0
  505. data/app/views/camaleon_cms/default_theme/partials/_categories_list.html.erb +23 -0
  506. data/app/views/camaleon_cms/default_theme/partials/_comments.html.erb +48 -0
  507. data/app/views/camaleon_cms/default_theme/partials/_comments_list.html.erb +21 -0
  508. data/app/views/camaleon_cms/default_theme/partials/_comments_list2.html.erb +24 -0
  509. data/app/views/camaleon_cms/default_theme/partials/_flash_messages.html.erb +26 -0
  510. data/app/views/camaleon_cms/default_theme/partials/_forms.html.erb +19 -0
  511. data/app/views/camaleon_cms/default_theme/partials/_post_list_item.html.erb +13 -0
  512. data/app/views/camaleon_cms/default_theme/partials/_render_custom_field.html.erb +55 -0
  513. data/app/views/camaleon_cms/default_theme/partials/_search_form.html.erb +8 -0
  514. data/app/views/camaleon_cms/default_theme/partials/_sidebar.html.erb +66 -0
  515. data/app/views/camaleon_cms/default_theme/post_tag.html.erb +18 -0
  516. data/app/views/camaleon_cms/default_theme/post_tag.json.jbuilder +10 -0
  517. data/app/views/camaleon_cms/default_theme/post_tag.rss.builder +22 -0
  518. data/app/views/camaleon_cms/default_theme/post_type.html.erb +25 -0
  519. data/app/views/camaleon_cms/default_theme/post_type.json.jbuilder +13 -0
  520. data/app/views/camaleon_cms/default_theme/post_type.rss.builder +22 -0
  521. data/app/views/camaleon_cms/default_theme/profile.html.erb +18 -0
  522. data/app/views/camaleon_cms/default_theme/profile.json.jbuilder +4 -0
  523. data/app/views/camaleon_cms/default_theme/robots.text.erb +1 -0
  524. data/app/views/camaleon_cms/default_theme/rss.rss.builder +21 -0
  525. data/app/views/camaleon_cms/default_theme/search.html.erb +13 -0
  526. data/app/views/camaleon_cms/default_theme/search.json.jbuilder +1 -0
  527. data/app/views/camaleon_cms/default_theme/single.html.erb +32 -0
  528. data/app/views/camaleon_cms/default_theme/single.json.jbuilder +21 -0
  529. data/app/views/camaleon_cms/default_theme/single.rss.builder +12 -0
  530. data/app/views/camaleon_cms/default_theme/sitemap.html.erb +23 -0
  531. data/app/views/camaleon_cms/default_theme/sitemap.xml.builder +60 -0
  532. data/app/views/camaleon_cms/html_mailer/confirm_email.html.erb +3 -0
  533. data/app/views/camaleon_cms/html_mailer/mailer.html.erb +4 -0
  534. data/app/views/camaleon_cms/html_mailer/password_reset.html.erb +3 -0
  535. data/app/views/camaleon_cms/shortcode_templates/widget.html.erb +11 -0
  536. data/app/views/layouts/camaleon_cms/admin.html.erb +54 -0
  537. data/app/views/layouts/camaleon_cms/admin/_ajax.html.erb +8 -0
  538. data/app/views/layouts/camaleon_cms/admin/_flash_messages.html.erb +43 -0
  539. data/app/views/layouts/camaleon_cms/admin/_footer.html.erb +13 -0
  540. data/app/views/layouts/camaleon_cms/admin/_form_error.html.erb +10 -0
  541. data/app/views/layouts/camaleon_cms/admin/_header.html.erb +51 -0
  542. data/app/views/layouts/camaleon_cms/admin/_sidebar.html.erb +19 -0
  543. data/app/views/layouts/camaleon_cms/admin/installer.html.erb +35 -0
  544. data/app/views/layouts/camaleon_cms/application.html.erb +15 -0
  545. data/app/views/layouts/camaleon_cms/login.html.erb +22 -0
  546. data/app/views/layouts/camaleon_cms/mailer.html.erb +22 -0
  547. data/config/initializers/action_view.rb +56 -0
  548. data/config/initializers/active_record_extension.rb +104 -0
  549. data/config/initializers/assets.rb +27 -0
  550. data/config/initializers/custom_initializers.rb +10 -0
  551. data/config/initializers/mobu.rb +24 -0
  552. data/config/initializers/model_alias.rb +18 -0
  553. data/config/initializers/sass.rb +52 -0
  554. data/config/locales/ar.yml +275 -0
  555. data/config/locales/camaleon_cms/admin/ar.yml +683 -0
  556. data/config/locales/camaleon_cms/admin/de.yml +682 -0
  557. data/config/locales/camaleon_cms/admin/en.yml +682 -0
  558. data/config/locales/camaleon_cms/admin/es.yml +654 -0
  559. data/config/locales/camaleon_cms/admin/fr.yml +663 -0
  560. data/config/locales/camaleon_cms/admin/it.yml +633 -0
  561. data/config/locales/camaleon_cms/admin/js.yml +435 -0
  562. data/config/locales/camaleon_cms/admin/nl.yml +659 -0
  563. data/config/locales/camaleon_cms/admin/pt-BR.yml +643 -0
  564. data/config/locales/camaleon_cms/admin/pt.yml +641 -0
  565. data/config/locales/camaleon_cms/admin/ru.yml +670 -0
  566. data/config/locales/camaleon_cms/admin/uk.yml +670 -0
  567. data/config/locales/camaleon_cms/admin/zh-CH.yml +703 -0
  568. data/config/locales/camaleon_cms/common.yml +784 -0
  569. data/config/locales/camaleon_cms/languages.yml +167 -0
  570. data/config/locales/camaleon_cms/routes.yml +71 -0
  571. data/config/locales/de.yml +210 -0
  572. data/config/locales/en.yml +207 -0
  573. data/config/locales/es.yml +198 -0
  574. data/config/locales/fr.yml +207 -0
  575. data/config/locales/it.yml +205 -0
  576. data/config/locales/nl.yml +209 -0
  577. data/config/locales/pl.yml +237 -0
  578. data/config/locales/pt-BR.yml +203 -0
  579. data/config/locales/pt.yml +201 -0
  580. data/config/locales/ru.yml +207 -0
  581. data/config/locales/uk.yml +257 -0
  582. data/config/locales/zh-CH.yml +194 -0
  583. data/config/routes.rb +11 -0
  584. data/config/routes/admin.rb +148 -0
  585. data/config/routes/frontend.rb +96 -0
  586. data/config/system.json +19 -0
  587. data/db/migrate/20150611161134_post_table_into_utf8.rb +124 -0
  588. data/db/migrate/20150926095310_rename_column_posts.rb +18 -0
  589. data/db/migrate/20151212095328_add_confirm_token_to_users.rb +7 -0
  590. data/db/migrate/20160504155652_add_feature_to_posts.rb +5 -0
  591. data/db/migrate/20160504155653_move_first_name_of_users.rb +9 -0
  592. data/db/migrate/20160606135421_improve_menus_structure.rb +7 -0
  593. data/db/migrate/20160609121449_add_group_to_custom_field_values.rb +5 -0
  594. data/db/migrate/20161206211917_install_migrated_seo_plugin.rb +8 -0
  595. data/db/migrate/20161215202255_drop_user_relationship_table.rb +5 -0
  596. data/db/migrate/20180124132318_create_media.rb +17 -0
  597. data/db/migrate/20180704211100_adjust_field_length.rb +10 -0
  598. data/lib/camaleon_cms.rb +5 -0
  599. data/lib/camaleon_cms/engine.rb +84 -0
  600. data/lib/camaleon_cms/version.rb +3 -0
  601. data/lib/captcha/bumpyroad.ttf +0 -0
  602. data/lib/captcha/captcha_0.jpg +0 -0
  603. data/lib/captcha/captcha_1.jpg +0 -0
  604. data/lib/captcha/captcha_10.jpg +0 -0
  605. data/lib/captcha/captcha_11.jpg +0 -0
  606. data/lib/captcha/captcha_2.jpg +0 -0
  607. data/lib/captcha/captcha_3.jpg +0 -0
  608. data/lib/captcha/captcha_4.jpg +0 -0
  609. data/lib/captcha/captcha_5.jpg +0 -0
  610. data/lib/captcha/captcha_6.jpg +0 -0
  611. data/lib/captcha/captcha_7.jpg +0 -0
  612. data/lib/captcha/captcha_8.jpg +0 -0
  613. data/lib/captcha/captcha_9.jpg +0 -0
  614. data/lib/ext/array.rb +59 -0
  615. data/lib/ext/hash.rb +41 -0
  616. data/lib/ext/string.rb +162 -0
  617. data/lib/ext/translator.rb +84 -0
  618. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +140 -0
  619. data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/admin_controller.rb +18 -0
  620. data/lib/generators/camaleon_cms/gem_plugin_template/app/controllers/plugins/my_plugin/front_controller.rb +8 -0
  621. data/lib/generators/camaleon_cms/gem_plugin_template/app/helpers/plugins/my_plugin/main_helper.rb +29 -0
  622. data/lib/generators/camaleon_cms/gem_plugin_template/app/models/plugins/my_plugin/my_plugin.rb +6 -0
  623. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/admin/index.html.erb +9 -0
  624. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/admin/settings.html.erb +21 -0
  625. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/front/index.html.erb +2 -0
  626. data/lib/generators/camaleon_cms/gem_plugin_template/app/views/plugins/my_plugin/layouts/readme.txt +2 -0
  627. data/lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json +14 -0
  628. data/lib/generators/camaleon_cms/gem_plugin_template/config/initializers/custom_models.rb +5 -0
  629. data/lib/generators/camaleon_cms/install_generator.rb +43 -0
  630. data/lib/generators/camaleon_cms/install_template/apps/themes/readme.txt +0 -0
  631. data/lib/generators/camaleon_cms/install_template/plugin_routes.rb +22 -0
  632. data/lib/generators/camaleon_cms/install_template/system.json +11 -0
  633. data/lib/generators/camaleon_cms/theme_generator.rb +66 -0
  634. data/lib/generators/camaleon_cms/theme_template/assets/css/main.css +13 -0
  635. data/lib/generators/camaleon_cms/theme_template/assets/images/image.png +0 -0
  636. data/lib/generators/camaleon_cms/theme_template/assets/js/main.js +14 -0
  637. data/lib/generators/camaleon_cms/theme_template/config/config.json +14 -0
  638. data/lib/generators/camaleon_cms/theme_template/main_helper.rb +27 -0
  639. data/lib/generators/camaleon_cms/theme_template/views/admin/settings.html.erb +2 -0
  640. data/lib/generators/camaleon_cms/theme_template/views/index.html.erb +1 -0
  641. data/lib/generators/camaleon_cms/theme_template/views/layouts/index.html.erb +69 -0
  642. data/lib/generators/camaleon_cms/theme_template/views/partials/readme.txt +1 -0
  643. data/lib/plugin_routes.rb +439 -0
  644. data/lib/tasks/camaleon_cms/camaleon_tasks.rake +30 -0
  645. data/lib/tasks/camaleon_cms/rspec_test.rake +20 -0
  646. data/spec/dummy/README.rdoc +28 -0
  647. data/spec/dummy/Rakefile +6 -0
  648. data/spec/dummy/app/assets/config/manifest.js +8 -0
  649. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  650. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  651. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  652. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  653. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  654. data/spec/dummy/bin/bundle +3 -0
  655. data/spec/dummy/bin/rails +4 -0
  656. data/spec/dummy/bin/rake +4 -0
  657. data/spec/dummy/bin/setup +36 -0
  658. data/spec/dummy/bin/update +31 -0
  659. data/spec/dummy/bin/yarn +11 -0
  660. data/spec/dummy/config.ru +4 -0
  661. data/spec/dummy/config/application.rb +27 -0
  662. data/spec/dummy/config/boot.rb +5 -0
  663. data/spec/dummy/config/database.yml +25 -0
  664. data/spec/dummy/config/environment.rb +5 -0
  665. data/spec/dummy/config/environments/development.rb +41 -0
  666. data/spec/dummy/config/environments/production.rb +79 -0
  667. data/spec/dummy/config/environments/test.rb +44 -0
  668. data/spec/dummy/config/initializers/assets.rb +11 -0
  669. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  670. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  671. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  672. data/spec/dummy/config/initializers/inflections.rb +16 -0
  673. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  674. data/spec/dummy/config/initializers/session_store.rb +3 -0
  675. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  676. data/spec/dummy/config/locales/en.yml +23 -0
  677. data/spec/dummy/config/routes.rb +4 -0
  678. data/spec/dummy/config/secrets.yml +22 -0
  679. data/spec/dummy/db/schema.rb +186 -0
  680. data/spec/factories/post.rb +44 -0
  681. data/spec/factories/post_type.rb +9 -0
  682. data/spec/factories/site.rb +18 -0
  683. data/spec/factories/user.rb +19 -0
  684. data/spec/features/admin/categories_spec.rb +25 -0
  685. data/spec/features/admin/comments_spec.rb +52 -0
  686. data/spec/features/admin/contact_form_spec.rb +60 -0
  687. data/spec/features/admin/content_groups_spec.rb +53 -0
  688. data/spec/features/admin/custom_fields_spec.rb +49 -0
  689. data/spec/features/admin/languages_spec.rb +37 -0
  690. data/spec/features/admin/media_spec.rb +50 -0
  691. data/spec/features/admin/menus_spec.rb +50 -0
  692. data/spec/features/admin/pages_spec.rb +35 -0
  693. data/spec/features/admin/plugins_spec.rb +29 -0
  694. data/spec/features/admin/posts_spec.rb +37 -0
  695. data/spec/features/admin/session_spec.rb +102 -0
  696. data/spec/features/admin/settings_spec.rb +17 -0
  697. data/spec/features/admin/shortcodes_spec.rb +11 -0
  698. data/spec/features/admin/sites_spec.rb +53 -0
  699. data/spec/features/admin/tags_spec.rb +34 -0
  700. data/spec/features/admin/themes_spec.rb +18 -0
  701. data/spec/features/admin/user_roles_spec.rb +66 -0
  702. data/spec/features/admin/users_spec.rb +81 -0
  703. data/spec/features/admin/widgets_spec.rb +59 -0
  704. data/spec/features/frontend/pages_spec.rb +136 -0
  705. data/spec/features/frontend/post_type_spec.rb +16 -0
  706. data/spec/helpers/email_helper_spec.rb +16 -0
  707. data/spec/helpers/short_code_helper_spec.rb +64 -0
  708. data/spec/helpers/uploader_helper_spec.rb +56 -0
  709. data/spec/mailers/send_mail_spec.rb +37 -0
  710. data/spec/models/post_spec.rb +50 -0
  711. data/spec/models/user_spec.rb +12 -0
  712. data/spec/rails_helper.rb +50 -0
  713. data/spec/routing/post_type_routes_spec.rb +12 -0
  714. data/spec/spec_helper.rb +167 -0
  715. data/spec/support/capybara_normalize_whitespace_patch.rb +17 -0
  716. data/spec/support/common.rb +119 -0
  717. data/spec/support/fixtures/rails.png +0 -0
  718. data/spec/support/wait_for_ajax.rb +30 -0
  719. metadata +1213 -0
@@ -0,0 +1,228 @@
1
+ tinymce.addI18n('zh-CN',{
2
+ "Cut": "\u526a\u5207",
3
+ "Heading 5": "\u6807\u98985",
4
+ "Header 2": "\u6807\u98982",
5
+ "Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X\/C\/V keyboard shortcuts instead.": "\u4f60\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u5bf9\u526a\u8d34\u677f\u7684\u8bbf\u95ee\uff0c\u8bf7\u4f7f\u7528Ctrl+X\/C\/V\u952e\u8fdb\u884c\u590d\u5236\u7c98\u8d34\u3002",
6
+ "Heading 4": "\u6807\u98984",
7
+ "Div": "Div\u533a\u5757",
8
+ "Heading 2": "\u6807\u98982",
9
+ "Paste": "\u7c98\u8d34",
10
+ "Close": "\u5173\u95ed",
11
+ "Font Family": "\u5b57\u4f53",
12
+ "Pre": "\u9884\u683c\u5f0f\u6587\u672c",
13
+ "Align right": "\u53f3\u5bf9\u9f50",
14
+ "New document": "\u65b0\u6587\u6863",
15
+ "Blockquote": "\u5f15\u7528",
16
+ "Numbered list": "\u7f16\u53f7\u5217\u8868",
17
+ "Heading 1": "\u6807\u98981",
18
+ "Headings": "\u6807\u9898",
19
+ "Increase indent": "\u589e\u52a0\u7f29\u8fdb",
20
+ "Formats": "\u683c\u5f0f",
21
+ "Headers": "\u6807\u9898",
22
+ "Select all": "\u5168\u9009",
23
+ "Header 3": "\u6807\u98983",
24
+ "Blocks": "\u533a\u5757",
25
+ "Undo": "\u64a4\u6d88",
26
+ "Strikethrough": "\u5220\u9664\u7ebf",
27
+ "Bullet list": "\u9879\u76ee\u7b26\u53f7",
28
+ "Header 1": "\u6807\u98981",
29
+ "Superscript": "\u4e0a\u6807",
30
+ "Clear formatting": "\u6e05\u9664\u683c\u5f0f",
31
+ "Font Sizes": "\u5b57\u53f7",
32
+ "Subscript": "\u4e0b\u6807",
33
+ "Header 6": "\u6807\u98986",
34
+ "Redo": "\u91cd\u590d",
35
+ "Paragraph": "\u6bb5\u843d",
36
+ "Ok": "\u786e\u5b9a",
37
+ "Bold": "\u7c97\u4f53",
38
+ "Code": "\u4ee3\u7801",
39
+ "Italic": "\u659c\u4f53",
40
+ "Align center": "\u5c45\u4e2d",
41
+ "Header 5": "\u6807\u98985",
42
+ "Heading 6": "\u6807\u98986",
43
+ "Heading 3": "\u6807\u98983",
44
+ "Decrease indent": "\u51cf\u5c11\u7f29\u8fdb",
45
+ "Header 4": "\u6807\u98984",
46
+ "Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.": "\u5f53\u524d\u4e3a\u7eaf\u6587\u672c\u7c98\u8d34\u6a21\u5f0f\uff0c\u518d\u6b21\u70b9\u51fb\u53ef\u4ee5\u56de\u5230\u666e\u901a\u7c98\u8d34\u6a21\u5f0f\u3002",
47
+ "Underline": "\u4e0b\u5212\u7ebf",
48
+ "Cancel": "\u53d6\u6d88",
49
+ "Justify": "\u4e24\u7aef\u5bf9\u9f50",
50
+ "Inline": "\u6587\u672c",
51
+ "Copy": "\u590d\u5236",
52
+ "Align left": "\u5de6\u5bf9\u9f50",
53
+ "Visual aids": "\u7f51\u683c\u7ebf",
54
+ "Lower Greek": "\u5c0f\u5199\u5e0c\u814a\u5b57\u6bcd",
55
+ "Square": "\u65b9\u5757",
56
+ "Default": "\u9ed8\u8ba4",
57
+ "Lower Alpha": "\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd",
58
+ "Circle": "\u7a7a\u5fc3\u5706",
59
+ "Disc": "\u5b9e\u5fc3\u5706",
60
+ "Upper Alpha": "\u5927\u5199\u82f1\u6587\u5b57\u6bcd",
61
+ "Upper Roman": "\u5927\u5199\u7f57\u9a6c\u5b57\u6bcd",
62
+ "Lower Roman": "\u5c0f\u5199\u7f57\u9a6c\u5b57\u6bcd",
63
+ "Name": "\u540d\u79f0",
64
+ "Anchor": "\u951a\u70b9",
65
+ "You have unsaved changes are you sure you want to navigate away?": "\u4f60\u8fd8\u6709\u6587\u6863\u5c1a\u672a\u4fdd\u5b58\uff0c\u786e\u5b9a\u8981\u79bb\u5f00\uff1f",
66
+ "Restore last draft": "\u6062\u590d\u4e0a\u6b21\u7684\u8349\u7a3f",
67
+ "Special character": "\u7279\u6b8a\u7b26\u53f7",
68
+ "Source code": "\u6e90\u4ee3\u7801",
69
+ "B": "B",
70
+ "R": "R",
71
+ "G": "G",
72
+ "Color": "\u989c\u8272",
73
+ "Right to left": "\u4ece\u53f3\u5230\u5de6",
74
+ "Left to right": "\u4ece\u5de6\u5230\u53f3",
75
+ "Emoticons": "\u8868\u60c5",
76
+ "Robots": "\u673a\u5668\u4eba",
77
+ "Document properties": "\u6587\u6863\u5c5e\u6027",
78
+ "Title": "\u6807\u9898",
79
+ "Keywords": "\u5173\u952e\u8bcd",
80
+ "Encoding": "\u7f16\u7801",
81
+ "Description": "\u63cf\u8ff0",
82
+ "Author": "\u4f5c\u8005",
83
+ "Fullscreen": "\u5168\u5c4f",
84
+ "Horizontal line": "\u6c34\u5e73\u5206\u5272\u7ebf",
85
+ "Horizontal space": "\u6c34\u5e73\u8fb9\u8ddd",
86
+ "Insert\/edit image": "\u63d2\u5165\/\u7f16\u8f91\u56fe\u7247",
87
+ "General": "\u666e\u901a",
88
+ "Advanced": "\u9ad8\u7ea7",
89
+ "Source": "\u5730\u5740",
90
+ "Border": "\u8fb9\u6846",
91
+ "Constrain proportions": "\u4fdd\u6301\u7eb5\u6a2a\u6bd4",
92
+ "Vertical space": "\u5782\u76f4\u8fb9\u8ddd",
93
+ "Image description": "\u56fe\u7247\u63cf\u8ff0",
94
+ "Style": "\u6837\u5f0f",
95
+ "Dimensions": "\u5927\u5c0f",
96
+ "Insert image": "\u63d2\u5165\u56fe\u7247",
97
+ "Zoom in": "\u653e\u5927",
98
+ "Contrast": "\u5bf9\u6bd4\u5ea6",
99
+ "Back": "\u540e\u9000",
100
+ "Gamma": "\u4f3d\u9a6c\u503c",
101
+ "Flip horizontally": "\u6c34\u5e73\u7ffb\u8f6c",
102
+ "Resize": "\u8c03\u6574\u5927\u5c0f",
103
+ "Sharpen": "\u9510\u5316",
104
+ "Zoom out": "\u7f29\u5c0f",
105
+ "Image options": "\u56fe\u7247\u9009\u9879",
106
+ "Apply": "\u5e94\u7528",
107
+ "Brightness": "\u4eae\u5ea6",
108
+ "Rotate clockwise": "\u987a\u65f6\u9488\u65cb\u8f6c",
109
+ "Rotate counterclockwise": "\u9006\u65f6\u9488\u65cb\u8f6c",
110
+ "Edit image": "\u7f16\u8f91\u56fe\u7247",
111
+ "Color levels": "\u989c\u8272\u5c42\u6b21",
112
+ "Crop": "\u88c1\u526a",
113
+ "Orientation": "\u65b9\u5411",
114
+ "Flip vertically": "\u5782\u76f4\u7ffb\u8f6c",
115
+ "Invert": "\u53cd\u8f6c",
116
+ "Insert date\/time": "\u63d2\u5165\u65e5\u671f\/\u65f6\u95f4",
117
+ "Remove link": "\u5220\u9664\u94fe\u63a5",
118
+ "Url": "\u5730\u5740",
119
+ "Text to display": "\u663e\u793a\u6587\u5b57",
120
+ "Anchors": "\u951a\u70b9",
121
+ "Insert link": "\u63d2\u5165\u94fe\u63a5",
122
+ "New window": "\u5728\u65b0\u7a97\u53e3\u6253\u5f00",
123
+ "None": "\u65e0",
124
+ "The URL you entered seems to be an external link. Do you want to add the required http:\/\/ prefix?": "\u4f60\u6240\u586b\u5199\u7684URL\u5730\u5740\u5c5e\u4e8e\u5916\u90e8\u94fe\u63a5\uff0c\u9700\u8981\u52a0\u4e0ahttp:\/\/:\u524d\u7f00\u5417\uff1f",
125
+ "Target": "\u6253\u5f00\u65b9\u5f0f",
126
+ "The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?": "\u4f60\u6240\u586b\u5199\u7684URL\u5730\u5740\u4e3a\u90ae\u4ef6\u5730\u5740\uff0c\u9700\u8981\u52a0\u4e0amailto:\u524d\u7f00\u5417\uff1f",
127
+ "Insert\/edit link": "\u63d2\u5165\/\u7f16\u8f91\u94fe\u63a5",
128
+ "Insert\/edit video": "\u63d2\u5165\/\u7f16\u8f91\u89c6\u9891",
129
+ "Poster": "\u5c01\u9762",
130
+ "Alternative source": "\u955c\u50cf",
131
+ "Paste your embed code below:": "\u5c06\u5185\u5d4c\u4ee3\u7801\u7c98\u8d34\u5728\u4e0b\u9762:",
132
+ "Insert file": "插入文件",
133
+ "Media": "媒体文件",
134
+ "Image": "图片",
135
+ "Link": "链接",
136
+ "New line at the end": "在末尾插入新行",
137
+ "New line": "新行",
138
+ "Date/time": "日期/时间",
139
+ "Template": "模板",
140
+ "Insert/edit media": "插入/编辑媒体文件",
141
+ "Insert video": "\u63d2\u5165\u89c6\u9891",
142
+ "Embed": "\u5185\u5d4c",
143
+ "Nonbreaking space": "\u4e0d\u95f4\u65ad\u7a7a\u683c",
144
+ "Page break": "\u5206\u9875\u7b26",
145
+ "Paste as text": "\u7c98\u8d34\u4e3a\u6587\u672c",
146
+ "Preview": "\u9884\u89c8",
147
+ "Print": "\u6253\u5370",
148
+ "Save": "\u4fdd\u5b58",
149
+ "Could not find the specified string.": "\u672a\u627e\u5230\u641c\u7d22\u5185\u5bb9.",
150
+ "Replace": "\u66ff\u6362",
151
+ "Next": "\u4e0b\u4e00\u4e2a",
152
+ "Whole words": "\u5168\u5b57\u5339\u914d",
153
+ "Find and replace": "\u67e5\u627e\u548c\u66ff\u6362",
154
+ "Replace with": "\u66ff\u6362\u4e3a",
155
+ "Find": "\u67e5\u627e",
156
+ "Replace all": "\u5168\u90e8\u66ff\u6362",
157
+ "Match case": "\u533a\u5206\u5927\u5c0f\u5199",
158
+ "Prev": "\u4e0a\u4e00\u4e2a",
159
+ "Spellcheck": "\u62fc\u5199\u68c0\u67e5",
160
+ "Finish": "\u5b8c\u6210",
161
+ "Ignore all": "\u5168\u90e8\u5ffd\u7565",
162
+ "Ignore": "\u5ffd\u7565",
163
+ "Add to Dictionary": "\u6dfb\u52a0\u5230\u5b57\u5178",
164
+ "Insert row before": "\u5728\u4e0a\u65b9\u63d2\u5165",
165
+ "Rows": "\u884c",
166
+ "Height": "\u9ad8",
167
+ "Paste row after": "\u7c98\u8d34\u5230\u4e0b\u65b9",
168
+ "Alignment": "\u5bf9\u9f50\u65b9\u5f0f",
169
+ "Border color": "\u8fb9\u6846\u989c\u8272",
170
+ "Column group": "\u5217\u7ec4",
171
+ "Row": "\u884c",
172
+ "Insert column before": "\u5728\u5de6\u4fa7\u63d2\u5165",
173
+ "Split cell": "\u62c6\u5206\u5355\u5143\u683c",
174
+ "Cell padding": "\u5355\u5143\u683c\u5185\u8fb9\u8ddd",
175
+ "Cell spacing": "\u5355\u5143\u683c\u5916\u95f4\u8ddd",
176
+ "Row type": "\u884c\u7c7b\u578b",
177
+ "Insert table": "\u63d2\u5165\u8868\u683c",
178
+ "Body": "\u8868\u4f53",
179
+ "Caption": "\u6807\u9898",
180
+ "Footer": "\u8868\u5c3e",
181
+ "Delete row": "\u5220\u9664\u884c",
182
+ "Paste row before": "\u7c98\u8d34\u5230\u4e0a\u65b9",
183
+ "Scope": "\u8303\u56f4",
184
+ "Delete table": "\u5220\u9664\u8868\u683c",
185
+ "H Align": "\u6c34\u5e73\u5bf9\u9f50",
186
+ "Top": "\u9876\u90e8\u5bf9\u9f50",
187
+ "Header cell": "\u8868\u5934\u5355\u5143\u683c",
188
+ "Column": "\u5217",
189
+ "Row group": "\u884c\u7ec4",
190
+ "Cell": "\u5355\u5143\u683c",
191
+ "Middle": "\u5782\u76f4\u5c45\u4e2d",
192
+ "Cell type": "\u5355\u5143\u683c\u7c7b\u578b",
193
+ "Copy row": "\u590d\u5236\u884c",
194
+ "Row properties": "\u884c\u5c5e\u6027",
195
+ "Table properties": "\u8868\u683c\u5c5e\u6027",
196
+ "Bottom": "\u5e95\u90e8\u5bf9\u9f50",
197
+ "V Align": "\u5782\u76f4\u5bf9\u9f50",
198
+ "Header": "\u8868\u5934",
199
+ "Right": "\u53f3\u5bf9\u9f50",
200
+ "Insert column after": "\u5728\u53f3\u4fa7\u63d2\u5165",
201
+ "Cols": "\u5217",
202
+ "Insert row after": "\u5728\u4e0b\u65b9\u63d2\u5165",
203
+ "Width": "\u5bbd",
204
+ "Cell properties": "\u5355\u5143\u683c\u5c5e\u6027",
205
+ "Left": "\u5de6\u5bf9\u9f50",
206
+ "Cut row": "\u526a\u5207\u884c",
207
+ "Delete column": "\u5220\u9664\u5217",
208
+ "Center": "\u5c45\u4e2d",
209
+ "Merge cells": "\u5408\u5e76\u5355\u5143\u683c",
210
+ "Insert template": "\u63d2\u5165\u6a21\u677f",
211
+ "Templates": "\u6a21\u677f",
212
+ "Background color": "\u80cc\u666f\u8272",
213
+ "Custom...": "\u81ea\u5b9a\u4e49...",
214
+ "Custom color": "\u81ea\u5b9a\u4e49\u989c\u8272",
215
+ "No color": "\u65e0",
216
+ "Text color": "\u6587\u5b57\u989c\u8272",
217
+ "Show blocks": "\u663e\u793a\u533a\u5757\u8fb9\u6846",
218
+ "Show invisible characters": "\u663e\u793a\u4e0d\u53ef\u89c1\u5b57\u7b26",
219
+ "Words: {0}": "\u5b57\u6570\uff1a{0}",
220
+ "Insert": "\u63d2\u5165",
221
+ "File": "\u6587\u4ef6",
222
+ "Edit": "\u7f16\u8f91",
223
+ "Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help": "\u5728\u7f16\u8f91\u533a\u6309ALT-F9\u6253\u5f00\u83dc\u5355\uff0c\u6309ALT-F10\u6253\u5f00\u5de5\u5177\u680f\uff0c\u6309ALT-0\u67e5\u770b\u5e2e\u52a9",
224
+ "Tools": "\u5de5\u5177",
225
+ "View": "\u89c6\u56fe",
226
+ "Table": "\u8868\u683c",
227
+ "Format": "\u683c\u5f0f"
228
+ });
@@ -0,0 +1,30 @@
1
+ tinymce.PluginManager.add('filemanager', function(editor) {
2
+ function openmanager() {
3
+ var dom = editor.dom;
4
+ $.fn.upload_filemanager({
5
+ selected: function(file){
6
+ var linkAttrs = {
7
+ href: file.url,
8
+ target: '_blank',
9
+ rel: null,
10
+ "class": null,
11
+ title: file.name
12
+ }
13
+ editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(file.name)));
14
+ }
15
+ });
16
+ }
17
+ editor.addButton('filemanager', {
18
+ icon: 'browse',
19
+ tooltip: 'Insert file',
20
+ onclick: openmanager,
21
+ stateSelector: 'img:not([data-mce-object])'
22
+ });
23
+ editor.addMenuItem('filemanager', {
24
+ icon: 'browse',
25
+ text: 'Insert file',
26
+ onclick: openmanager,
27
+ context: 'insert',
28
+ prependToContext: true
29
+ })
30
+ });
@@ -0,0 +1,3003 @@
1
+ /*!
2
+ * Cropper v2.3.4
3
+ * https://github.com/fengyuanchen/cropper
4
+ *
5
+ * Copyright (c) 2014-2016 Fengyuan Chen and contributors
6
+ * Released under the MIT license
7
+ *
8
+ * Date: 2016-09-03T05:50:45.412Z
9
+ */
10
+
11
+ (function (factory) {
12
+ if (typeof define === 'function' && define.amd) {
13
+ // AMD. Register as anonymous module.
14
+ define(['jquery'], factory);
15
+ } else if (typeof exports === 'object') {
16
+ // Node / CommonJS
17
+ factory(require('jquery'));
18
+ } else {
19
+ // Browser globals.
20
+ factory(jQuery);
21
+ }
22
+ })(function ($) {
23
+
24
+ 'use strict';
25
+
26
+ // Globals
27
+ var $window = $(window);
28
+ var $document = $(document);
29
+ var location = window.location;
30
+ var navigator = window.navigator;
31
+ var ArrayBuffer = window.ArrayBuffer;
32
+ var Uint8Array = window.Uint8Array;
33
+ var DataView = window.DataView;
34
+ var btoa = window.btoa;
35
+
36
+ // Constants
37
+ var NAMESPACE = 'cropper';
38
+
39
+ // Classes
40
+ var CLASS_MODAL = 'cropper-modal';
41
+ var CLASS_HIDE = 'cropper-hide';
42
+ var CLASS_HIDDEN = 'cropper-hidden';
43
+ var CLASS_INVISIBLE = 'cropper-invisible';
44
+ var CLASS_MOVE = 'cropper-move';
45
+ var CLASS_CROP = 'cropper-crop';
46
+ var CLASS_DISABLED = 'cropper-disabled';
47
+ var CLASS_BG = 'cropper-bg';
48
+
49
+ // Events
50
+ var EVENT_MOUSE_DOWN = 'mousedown touchstart pointerdown MSPointerDown';
51
+ var EVENT_MOUSE_MOVE = 'mousemove touchmove pointermove MSPointerMove';
52
+ var EVENT_MOUSE_UP = 'mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel';
53
+ var EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll';
54
+ var EVENT_DBLCLICK = 'dblclick';
55
+ var EVENT_LOAD = 'load.' + NAMESPACE;
56
+ var EVENT_ERROR = 'error.' + NAMESPACE;
57
+ var EVENT_RESIZE = 'resize.' + NAMESPACE; // Bind to window with namespace
58
+ var EVENT_BUILD = 'build.' + NAMESPACE;
59
+ var EVENT_BUILT = 'built.' + NAMESPACE;
60
+ var EVENT_CROP_START = 'cropstart.' + NAMESPACE;
61
+ var EVENT_CROP_MOVE = 'cropmove.' + NAMESPACE;
62
+ var EVENT_CROP_END = 'cropend.' + NAMESPACE;
63
+ var EVENT_CROP = 'crop.' + NAMESPACE;
64
+ var EVENT_ZOOM = 'zoom.' + NAMESPACE;
65
+
66
+ // RegExps
67
+ var REGEXP_ACTIONS = /^(e|w|s|n|se|sw|ne|nw|all|crop|move|zoom)$/;
68
+ var REGEXP_DATA_URL = /^data:/;
69
+ var REGEXP_DATA_URL_HEAD = /^data:([^;]+);base64,/;
70
+ var REGEXP_DATA_URL_JPEG = /^data:image\/jpeg.*;base64,/;
71
+
72
+ // Data keys
73
+ var DATA_PREVIEW = 'preview';
74
+ var DATA_ACTION = 'action';
75
+
76
+ // Actions
77
+ var ACTION_EAST = 'e';
78
+ var ACTION_WEST = 'w';
79
+ var ACTION_SOUTH = 's';
80
+ var ACTION_NORTH = 'n';
81
+ var ACTION_SOUTH_EAST = 'se';
82
+ var ACTION_SOUTH_WEST = 'sw';
83
+ var ACTION_NORTH_EAST = 'ne';
84
+ var ACTION_NORTH_WEST = 'nw';
85
+ var ACTION_ALL = 'all';
86
+ var ACTION_CROP = 'crop';
87
+ var ACTION_MOVE = 'move';
88
+ var ACTION_ZOOM = 'zoom';
89
+ var ACTION_NONE = 'none';
90
+
91
+ // Supports
92
+ var SUPPORT_CANVAS = $.isFunction($('<canvas>')[0].getContext);
93
+ var IS_SAFARI_OR_UIWEBVIEW = navigator && /(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent);
94
+
95
+ // Maths
96
+ var num = Number;
97
+ var min = Math.min;
98
+ var max = Math.max;
99
+ var abs = Math.abs;
100
+ var sin = Math.sin;
101
+ var cos = Math.cos;
102
+ var sqrt = Math.sqrt;
103
+ var round = Math.round;
104
+ var floor = Math.floor;
105
+
106
+ // Utilities
107
+ var fromCharCode = String.fromCharCode;
108
+
109
+ function isNumber(n) {
110
+ return typeof n === 'number' && !isNaN(n);
111
+ }
112
+
113
+ function isUndefined(n) {
114
+ return typeof n === 'undefined';
115
+ }
116
+
117
+ function toArray(obj, offset) {
118
+ var args = [];
119
+
120
+ // This is necessary for IE8
121
+ if (isNumber(offset)) {
122
+ args.push(offset);
123
+ }
124
+
125
+ return args.slice.apply(obj, args);
126
+ }
127
+
128
+ // Custom proxy to avoid jQuery's guid
129
+ function proxy(fn, context) {
130
+ var args = toArray(arguments, 2);
131
+
132
+ return function () {
133
+ return fn.apply(context, args.concat(toArray(arguments)));
134
+ };
135
+ }
136
+
137
+ function isCrossOriginURL(url) {
138
+ var parts = url.match(/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i);
139
+
140
+ return parts && (
141
+ parts[1] !== location.protocol ||
142
+ parts[2] !== location.hostname ||
143
+ parts[3] !== location.port
144
+ );
145
+ }
146
+
147
+ function addTimestamp(url) {
148
+ var timestamp = 'timestamp=' + (new Date()).getTime();
149
+
150
+ return (url + (url.indexOf('?') === -1 ? '?' : '&') + timestamp);
151
+ }
152
+
153
+ function getCrossOrigin(crossOrigin) {
154
+ return crossOrigin ? ' crossOrigin="' + crossOrigin + '"' : '';
155
+ }
156
+
157
+ function getImageSize(image, callback) {
158
+ var newImage;
159
+
160
+ // Modern browsers (ignore Safari, #120 & #509)
161
+ if (image.naturalWidth && !IS_SAFARI_OR_UIWEBVIEW) {
162
+ return callback(image.naturalWidth, image.naturalHeight);
163
+ }
164
+
165
+ // IE8: Don't use `new Image()` here (#319)
166
+ newImage = document.createElement('img');
167
+
168
+ newImage.onload = function () {
169
+ callback(this.width, this.height);
170
+ };
171
+
172
+ newImage.src = image.src;
173
+ }
174
+
175
+ function getTransform(options) {
176
+ var transforms = [];
177
+ var rotate = options.rotate;
178
+ var scaleX = options.scaleX;
179
+ var scaleY = options.scaleY;
180
+
181
+ // Rotate should come first before scale to match orientation transform
182
+ if (isNumber(rotate) && rotate !== 0) {
183
+ transforms.push('rotate(' + rotate + 'deg)');
184
+ }
185
+
186
+ if (isNumber(scaleX) && scaleX !== 1) {
187
+ transforms.push('scaleX(' + scaleX + ')');
188
+ }
189
+
190
+ if (isNumber(scaleY) && scaleY !== 1) {
191
+ transforms.push('scaleY(' + scaleY + ')');
192
+ }
193
+
194
+ return transforms.length ? transforms.join(' ') : 'none';
195
+ }
196
+
197
+ function getRotatedSizes(data, isReversed) {
198
+ var deg = abs(data.degree) % 180;
199
+ var arc = (deg > 90 ? (180 - deg) : deg) * Math.PI / 180;
200
+ var sinArc = sin(arc);
201
+ var cosArc = cos(arc);
202
+ var width = data.width;
203
+ var height = data.height;
204
+ var aspectRatio = data.aspectRatio;
205
+ var newWidth;
206
+ var newHeight;
207
+
208
+ if (!isReversed) {
209
+ newWidth = width * cosArc + height * sinArc;
210
+ newHeight = width * sinArc + height * cosArc;
211
+ } else {
212
+ newWidth = width / (cosArc + sinArc / aspectRatio);
213
+ newHeight = newWidth / aspectRatio;
214
+ }
215
+
216
+ return {
217
+ width: newWidth,
218
+ height: newHeight
219
+ };
220
+ }
221
+
222
+ function getSourceCanvas(image, data) {
223
+ var canvas = $('<canvas>')[0];
224
+ var context = canvas.getContext('2d');
225
+ var dstX = 0;
226
+ var dstY = 0;
227
+ var dstWidth = data.naturalWidth;
228
+ var dstHeight = data.naturalHeight;
229
+ var rotate = data.rotate;
230
+ var scaleX = data.scaleX;
231
+ var scaleY = data.scaleY;
232
+ var scalable = isNumber(scaleX) && isNumber(scaleY) && (scaleX !== 1 || scaleY !== 1);
233
+ var rotatable = isNumber(rotate) && rotate !== 0;
234
+ var advanced = rotatable || scalable;
235
+ var canvasWidth = dstWidth * abs(scaleX || 1);
236
+ var canvasHeight = dstHeight * abs(scaleY || 1);
237
+ var translateX;
238
+ var translateY;
239
+ var rotated;
240
+
241
+ if (scalable) {
242
+ translateX = canvasWidth / 2;
243
+ translateY = canvasHeight / 2;
244
+ }
245
+
246
+ if (rotatable) {
247
+ rotated = getRotatedSizes({
248
+ width: canvasWidth,
249
+ height: canvasHeight,
250
+ degree: rotate
251
+ });
252
+
253
+ canvasWidth = rotated.width;
254
+ canvasHeight = rotated.height;
255
+ translateX = canvasWidth / 2;
256
+ translateY = canvasHeight / 2;
257
+ }
258
+
259
+ canvas.width = canvasWidth;
260
+ canvas.height = canvasHeight;
261
+
262
+ if (advanced) {
263
+ dstX = -dstWidth / 2;
264
+ dstY = -dstHeight / 2;
265
+
266
+ context.save();
267
+ context.translate(translateX, translateY);
268
+ }
269
+
270
+ // Rotate should come first before scale as in the "getTransform" function
271
+ if (rotatable) {
272
+ context.rotate(rotate * Math.PI / 180);
273
+ }
274
+
275
+ if (scalable) {
276
+ context.scale(scaleX, scaleY);
277
+ }
278
+
279
+ context.drawImage(image, floor(dstX), floor(dstY), floor(dstWidth), floor(dstHeight));
280
+
281
+ if (advanced) {
282
+ context.restore();
283
+ }
284
+
285
+ return canvas;
286
+ }
287
+
288
+ function getTouchesCenter(touches) {
289
+ var length = touches.length;
290
+ var pageX = 0;
291
+ var pageY = 0;
292
+
293
+ if (length) {
294
+ $.each(touches, function (i, touch) {
295
+ pageX += touch.pageX;
296
+ pageY += touch.pageY;
297
+ });
298
+
299
+ pageX /= length;
300
+ pageY /= length;
301
+ }
302
+
303
+ return {
304
+ pageX: pageX,
305
+ pageY: pageY
306
+ };
307
+ }
308
+
309
+ function getStringFromCharCode(dataView, start, length) {
310
+ var str = '';
311
+ var i;
312
+
313
+ for (i = start, length += start; i < length; i++) {
314
+ str += fromCharCode(dataView.getUint8(i));
315
+ }
316
+
317
+ return str;
318
+ }
319
+
320
+ function getOrientation(arrayBuffer) {
321
+ var dataView = new DataView(arrayBuffer);
322
+ var length = dataView.byteLength;
323
+ var orientation;
324
+ var exifIDCode;
325
+ var tiffOffset;
326
+ var firstIFDOffset;
327
+ var littleEndian;
328
+ var endianness;
329
+ var app1Start;
330
+ var ifdStart;
331
+ var offset;
332
+ var i;
333
+
334
+ // Only handle JPEG image (start by 0xFFD8)
335
+ if (dataView.getUint8(0) === 0xFF && dataView.getUint8(1) === 0xD8) {
336
+ offset = 2;
337
+
338
+ while (offset < length) {
339
+ if (dataView.getUint8(offset) === 0xFF && dataView.getUint8(offset + 1) === 0xE1) {
340
+ app1Start = offset;
341
+ break;
342
+ }
343
+
344
+ offset++;
345
+ }
346
+ }
347
+
348
+ if (app1Start) {
349
+ exifIDCode = app1Start + 4;
350
+ tiffOffset = app1Start + 10;
351
+
352
+ if (getStringFromCharCode(dataView, exifIDCode, 4) === 'Exif') {
353
+ endianness = dataView.getUint16(tiffOffset);
354
+ littleEndian = endianness === 0x4949;
355
+
356
+ if (littleEndian || endianness === 0x4D4D /* bigEndian */) {
357
+ if (dataView.getUint16(tiffOffset + 2, littleEndian) === 0x002A) {
358
+ firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
359
+
360
+ if (firstIFDOffset >= 0x00000008) {
361
+ ifdStart = tiffOffset + firstIFDOffset;
362
+ }
363
+ }
364
+ }
365
+ }
366
+ }
367
+
368
+ if (ifdStart) {
369
+ length = dataView.getUint16(ifdStart, littleEndian);
370
+
371
+ for (i = 0; i < length; i++) {
372
+ offset = ifdStart + i * 12 + 2;
373
+
374
+ if (dataView.getUint16(offset, littleEndian) === 0x0112 /* Orientation */) {
375
+
376
+ // 8 is the offset of the current tag's value
377
+ offset += 8;
378
+
379
+ // Get the original orientation value
380
+ orientation = dataView.getUint16(offset, littleEndian);
381
+
382
+ // Override the orientation with its default value for Safari (#120)
383
+ if (IS_SAFARI_OR_UIWEBVIEW) {
384
+ dataView.setUint16(offset, 1, littleEndian);
385
+ }
386
+
387
+ break;
388
+ }
389
+ }
390
+ }
391
+
392
+ return orientation;
393
+ }
394
+
395
+ function dataURLToArrayBuffer(dataURL) {
396
+ var base64 = dataURL.replace(REGEXP_DATA_URL_HEAD, '');
397
+ var binary = atob(base64);
398
+ var length = binary.length;
399
+ var arrayBuffer = new ArrayBuffer(length);
400
+ var dataView = new Uint8Array(arrayBuffer);
401
+ var i;
402
+
403
+ for (i = 0; i < length; i++) {
404
+ dataView[i] = binary.charCodeAt(i);
405
+ }
406
+
407
+ return arrayBuffer;
408
+ }
409
+
410
+ // Only available for JPEG image
411
+ function arrayBufferToDataURL(arrayBuffer) {
412
+ var dataView = new Uint8Array(arrayBuffer);
413
+ var length = dataView.length;
414
+ var base64 = '';
415
+ var i;
416
+
417
+ for (i = 0; i < length; i++) {
418
+ base64 += fromCharCode(dataView[i]);
419
+ }
420
+
421
+ return 'data:image/jpeg;base64,' + btoa(base64);
422
+ }
423
+
424
+ function Cropper(element, options) {
425
+ this.$element = $(element);
426
+ this.options = $.extend({}, Cropper.DEFAULTS, $.isPlainObject(options) && options);
427
+ this.isLoaded = false;
428
+ this.isBuilt = false;
429
+ this.isCompleted = false;
430
+ this.isRotated = false;
431
+ this.isCropped = false;
432
+ this.isDisabled = false;
433
+ this.isReplaced = false;
434
+ this.isLimited = false;
435
+ this.wheeling = false;
436
+ this.isImg = false;
437
+ this.originalUrl = '';
438
+ this.canvas = null;
439
+ this.cropBox = null;
440
+ this.init();
441
+ }
442
+
443
+ Cropper.prototype = {
444
+ constructor: Cropper,
445
+
446
+ init: function () {
447
+ var $this = this.$element;
448
+ var url;
449
+
450
+ if ($this.is('img')) {
451
+ this.isImg = true;
452
+
453
+ // Should use `$.fn.attr` here. e.g.: "img/picture.jpg"
454
+ this.originalUrl = url = $this.attr('src');
455
+
456
+ // Stop when it's a blank image
457
+ if (!url) {
458
+ return;
459
+ }
460
+
461
+ // Should use `$.fn.prop` here. e.g.: "http://example.com/img/picture.jpg"
462
+ url = $this.prop('src');
463
+ } else if ($this.is('canvas') && SUPPORT_CANVAS) {
464
+ url = $this[0].toDataURL();
465
+ }
466
+
467
+ this.load(url);
468
+ },
469
+
470
+ // A shortcut for triggering custom events
471
+ trigger: function (type, data) {
472
+ var e = $.Event(type, data);
473
+
474
+ this.$element.trigger(e);
475
+
476
+ return e;
477
+ },
478
+
479
+ load: function (url) {
480
+ var options = this.options;
481
+ var $this = this.$element;
482
+ var read;
483
+ var xhr;
484
+
485
+ if (!url) {
486
+ return;
487
+ }
488
+
489
+ // Trigger build event first
490
+ $this.one(EVENT_BUILD, options.build);
491
+
492
+ if (this.trigger(EVENT_BUILD).isDefaultPrevented()) {
493
+ return;
494
+ }
495
+
496
+ this.url = url;
497
+ this.image = {};
498
+
499
+ if (!options.checkOrientation || !ArrayBuffer) {
500
+ return this.clone();
501
+ }
502
+
503
+ read = $.proxy(this.read, this);
504
+
505
+ // XMLHttpRequest disallows to open a Data URL in some browsers like IE11 and Safari
506
+ if (REGEXP_DATA_URL.test(url)) {
507
+ return REGEXP_DATA_URL_JPEG.test(url) ?
508
+ read(dataURLToArrayBuffer(url)) :
509
+ this.clone();
510
+ }
511
+
512
+ xhr = new XMLHttpRequest();
513
+
514
+ xhr.onerror = xhr.onabort = $.proxy(function () {
515
+ this.clone();
516
+ }, this);
517
+
518
+ xhr.onload = function () {
519
+ read(this.response);
520
+ };
521
+
522
+ if (options.checkCrossOrigin && isCrossOriginURL(url) && $this.prop('crossOrigin')) {
523
+ url = addTimestamp(url);
524
+ }
525
+
526
+ xhr.open('get', url);
527
+ xhr.responseType = 'arraybuffer';
528
+ xhr.send();
529
+ },
530
+
531
+ read: function (arrayBuffer) {
532
+ var options = this.options;
533
+ var orientation = getOrientation(arrayBuffer);
534
+ var image = this.image;
535
+ var rotate = 0;
536
+ var scaleX = 1;
537
+ var scaleY = 1;
538
+
539
+ if (orientation > 1) {
540
+ this.url = arrayBufferToDataURL(arrayBuffer);
541
+
542
+ switch (orientation) {
543
+
544
+ // flip horizontal
545
+ case 2:
546
+ scaleX = -1;
547
+ break;
548
+
549
+ // rotate left 180°
550
+ case 3:
551
+ rotate = -180;
552
+ break;
553
+
554
+ // flip vertical
555
+ case 4:
556
+ scaleY = -1;
557
+ break;
558
+
559
+ // flip vertical + rotate right 90°
560
+ case 5:
561
+ rotate = 90;
562
+ scaleY = -1;
563
+ break;
564
+
565
+ // rotate right 90°
566
+ case 6:
567
+ rotate = 90;
568
+ break;
569
+
570
+ // flip horizontal + rotate right 90°
571
+ case 7:
572
+ rotate = 90;
573
+ scaleX = -1;
574
+ break;
575
+
576
+ // rotate left 90°
577
+ case 8:
578
+ rotate = -90;
579
+ break;
580
+ }
581
+ }
582
+
583
+ if (options.rotatable) {
584
+ image.rotate = rotate;
585
+ }
586
+
587
+ if (options.scalable) {
588
+ image.scaleX = scaleX;
589
+ image.scaleY = scaleY;
590
+ }
591
+
592
+ this.clone();
593
+ },
594
+
595
+ clone: function () {
596
+ var options = this.options;
597
+ var $this = this.$element;
598
+ var url = this.url;
599
+ var crossOrigin = '';
600
+ var crossOriginUrl;
601
+ var $clone;
602
+
603
+ if (options.checkCrossOrigin && isCrossOriginURL(url)) {
604
+ crossOrigin = $this.prop('crossOrigin');
605
+
606
+ if (crossOrigin) {
607
+ crossOriginUrl = url;
608
+ } else {
609
+ crossOrigin = 'anonymous';
610
+
611
+ // Bust cache (#148) when there is not a "crossOrigin" property
612
+ crossOriginUrl = addTimestamp(url);
613
+ }
614
+ }
615
+
616
+ this.crossOrigin = crossOrigin;
617
+ this.crossOriginUrl = crossOriginUrl;
618
+ this.$clone = $clone = $('<img' + getCrossOrigin(crossOrigin) + ' src="' + (crossOriginUrl || url) + '">');
619
+
620
+ if (this.isImg) {
621
+ if ($this[0].complete) {
622
+ this.start();
623
+ } else {
624
+ $this.one(EVENT_LOAD, $.proxy(this.start, this));
625
+ }
626
+ } else {
627
+ $clone.
628
+ one(EVENT_LOAD, $.proxy(this.start, this)).
629
+ one(EVENT_ERROR, $.proxy(this.stop, this)).
630
+ addClass(CLASS_HIDE).
631
+ insertAfter($this);
632
+ }
633
+ },
634
+
635
+ start: function () {
636
+ var $image = this.$element;
637
+ var $clone = this.$clone;
638
+
639
+ if (!this.isImg) {
640
+ $clone.off(EVENT_ERROR, this.stop);
641
+ $image = $clone;
642
+ }
643
+
644
+ getImageSize($image[0], $.proxy(function (naturalWidth, naturalHeight) {
645
+ $.extend(this.image, {
646
+ naturalWidth: naturalWidth,
647
+ naturalHeight: naturalHeight,
648
+ aspectRatio: naturalWidth / naturalHeight
649
+ });
650
+
651
+ this.isLoaded = true;
652
+ this.build();
653
+ }, this));
654
+ },
655
+
656
+ stop: function () {
657
+ this.$clone.remove();
658
+ this.$clone = null;
659
+ },
660
+
661
+ build: function () {
662
+ var options = this.options;
663
+ var $this = this.$element;
664
+ var $clone = this.$clone;
665
+ var $cropper;
666
+ var $cropBox;
667
+ var $face;
668
+
669
+ if (!this.isLoaded) {
670
+ return;
671
+ }
672
+
673
+ // Unbuild first when replace
674
+ if (this.isBuilt) {
675
+ this.unbuild();
676
+ }
677
+
678
+ // Create cropper elements
679
+ this.$container = $this.parent();
680
+ this.$cropper = $cropper = $(Cropper.TEMPLATE);
681
+ this.$canvas = $cropper.find('.cropper-canvas').append($clone);
682
+ this.$dragBox = $cropper.find('.cropper-drag-box');
683
+ this.$cropBox = $cropBox = $cropper.find('.cropper-crop-box');
684
+ this.$viewBox = $cropper.find('.cropper-view-box');
685
+ this.$face = $face = $cropBox.find('.cropper-face');
686
+
687
+ // Hide the original image
688
+ $this.addClass(CLASS_HIDDEN).after($cropper);
689
+
690
+ // Show the clone image if is hidden
691
+ if (!this.isImg) {
692
+ $clone.removeClass(CLASS_HIDE);
693
+ }
694
+
695
+ this.initPreview();
696
+ this.bind();
697
+
698
+ options.aspectRatio = max(0, options.aspectRatio) || NaN;
699
+ options.viewMode = max(0, min(3, round(options.viewMode))) || 0;
700
+
701
+ if (options.autoCrop) {
702
+ this.isCropped = true;
703
+
704
+ if (options.modal) {
705
+ this.$dragBox.addClass(CLASS_MODAL);
706
+ }
707
+ } else {
708
+ $cropBox.addClass(CLASS_HIDDEN);
709
+ }
710
+
711
+ if (!options.guides) {
712
+ $cropBox.find('.cropper-dashed').addClass(CLASS_HIDDEN);
713
+ }
714
+
715
+ if (!options.center) {
716
+ $cropBox.find('.cropper-center').addClass(CLASS_HIDDEN);
717
+ }
718
+
719
+ if (options.cropBoxMovable) {
720
+ $face.addClass(CLASS_MOVE).data(DATA_ACTION, ACTION_ALL);
721
+ }
722
+
723
+ if (!options.highlight) {
724
+ $face.addClass(CLASS_INVISIBLE);
725
+ }
726
+
727
+ if (options.background) {
728
+ $cropper.addClass(CLASS_BG);
729
+ }
730
+
731
+ if (!options.cropBoxResizable) {
732
+ $cropBox.find('.cropper-line, .cropper-point').addClass(CLASS_HIDDEN);
733
+ }
734
+
735
+ this.setDragMode(options.dragMode);
736
+ this.render();
737
+ this.isBuilt = true;
738
+ this.setData(options.data);
739
+ $this.one(EVENT_BUILT, options.built);
740
+
741
+ // Trigger the built event asynchronously to keep `data('cropper')` is defined
742
+ this.completing = setTimeout($.proxy(function () {
743
+ this.trigger(EVENT_BUILT);
744
+ this.trigger(EVENT_CROP, this.getData());
745
+ this.isCompleted = true;
746
+ }, this), 0);
747
+ },
748
+
749
+ unbuild: function () {
750
+ if (!this.isBuilt) {
751
+ return;
752
+ }
753
+
754
+ if (!this.isCompleted) {
755
+ clearTimeout(this.completing);
756
+ }
757
+
758
+ this.isBuilt = false;
759
+ this.isCompleted = false;
760
+ this.initialImage = null;
761
+
762
+ // Clear `initialCanvas` is necessary when replace
763
+ this.initialCanvas = null;
764
+ this.initialCropBox = null;
765
+ this.container = null;
766
+ this.canvas = null;
767
+
768
+ // Clear `cropBox` is necessary when replace
769
+ this.cropBox = null;
770
+ this.unbind();
771
+
772
+ this.resetPreview();
773
+ this.$preview = null;
774
+
775
+ this.$viewBox = null;
776
+ this.$cropBox = null;
777
+ this.$dragBox = null;
778
+ this.$canvas = null;
779
+ this.$container = null;
780
+
781
+ this.$cropper.remove();
782
+ this.$cropper = null;
783
+ },
784
+
785
+ render: function () {
786
+ this.initContainer();
787
+ this.initCanvas();
788
+ this.initCropBox();
789
+
790
+ this.renderCanvas();
791
+
792
+ if (this.isCropped) {
793
+ this.renderCropBox();
794
+ }
795
+ },
796
+
797
+ initContainer: function () {
798
+ var options = this.options;
799
+ var $this = this.$element;
800
+ var $container = this.$container;
801
+ var $cropper = this.$cropper;
802
+
803
+ $cropper.addClass(CLASS_HIDDEN);
804
+ $this.removeClass(CLASS_HIDDEN);
805
+
806
+ $cropper.css((this.container = {
807
+ width: max($container.width(), num(options.minContainerWidth) || 200),
808
+ height: max($container.height(), num(options.minContainerHeight) || 100)
809
+ }));
810
+
811
+ $this.addClass(CLASS_HIDDEN);
812
+ $cropper.removeClass(CLASS_HIDDEN);
813
+ },
814
+
815
+ // Canvas (image wrapper)
816
+ initCanvas: function () {
817
+ var viewMode = this.options.viewMode;
818
+ var container = this.container;
819
+ var containerWidth = container.width;
820
+ var containerHeight = container.height;
821
+ var image = this.image;
822
+ var imageNaturalWidth = image.naturalWidth;
823
+ var imageNaturalHeight = image.naturalHeight;
824
+ var is90Degree = abs(image.rotate) === 90;
825
+ var naturalWidth = is90Degree ? imageNaturalHeight : imageNaturalWidth;
826
+ var naturalHeight = is90Degree ? imageNaturalWidth : imageNaturalHeight;
827
+ var aspectRatio = naturalWidth / naturalHeight;
828
+ var canvasWidth = containerWidth;
829
+ var canvasHeight = containerHeight;
830
+ var canvas;
831
+
832
+ if (containerHeight * aspectRatio > containerWidth) {
833
+ if (viewMode === 3) {
834
+ canvasWidth = containerHeight * aspectRatio;
835
+ } else {
836
+ canvasHeight = containerWidth / aspectRatio;
837
+ }
838
+ } else {
839
+ if (viewMode === 3) {
840
+ canvasHeight = containerWidth / aspectRatio;
841
+ } else {
842
+ canvasWidth = containerHeight * aspectRatio;
843
+ }
844
+ }
845
+
846
+ canvas = {
847
+ naturalWidth: naturalWidth,
848
+ naturalHeight: naturalHeight,
849
+ aspectRatio: aspectRatio,
850
+ width: canvasWidth,
851
+ height: canvasHeight
852
+ };
853
+
854
+ canvas.oldLeft = canvas.left = (containerWidth - canvasWidth) / 2;
855
+ canvas.oldTop = canvas.top = (containerHeight - canvasHeight) / 2;
856
+
857
+ this.canvas = canvas;
858
+ this.isLimited = (viewMode === 1 || viewMode === 2);
859
+ this.limitCanvas(true, true);
860
+ this.initialImage = $.extend({}, image);
861
+ this.initialCanvas = $.extend({}, canvas);
862
+ },
863
+
864
+ limitCanvas: function (isSizeLimited, isPositionLimited) {
865
+ var options = this.options;
866
+ var viewMode = options.viewMode;
867
+ var container = this.container;
868
+ var containerWidth = container.width;
869
+ var containerHeight = container.height;
870
+ var canvas = this.canvas;
871
+ var aspectRatio = canvas.aspectRatio;
872
+ var cropBox = this.cropBox;
873
+ var isCropped = this.isCropped && cropBox;
874
+ var minCanvasWidth;
875
+ var minCanvasHeight;
876
+ var newCanvasLeft;
877
+ var newCanvasTop;
878
+
879
+ if (isSizeLimited) {
880
+ minCanvasWidth = num(options.minCanvasWidth) || 0;
881
+ minCanvasHeight = num(options.minCanvasHeight) || 0;
882
+
883
+ if (viewMode) {
884
+ if (viewMode > 1) {
885
+ minCanvasWidth = max(minCanvasWidth, containerWidth);
886
+ minCanvasHeight = max(minCanvasHeight, containerHeight);
887
+
888
+ if (viewMode === 3) {
889
+ if (minCanvasHeight * aspectRatio > minCanvasWidth) {
890
+ minCanvasWidth = minCanvasHeight * aspectRatio;
891
+ } else {
892
+ minCanvasHeight = minCanvasWidth / aspectRatio;
893
+ }
894
+ }
895
+ } else {
896
+ if (minCanvasWidth) {
897
+ minCanvasWidth = max(minCanvasWidth, isCropped ? cropBox.width : 0);
898
+ } else if (minCanvasHeight) {
899
+ minCanvasHeight = max(minCanvasHeight, isCropped ? cropBox.height : 0);
900
+ } else if (isCropped) {
901
+ minCanvasWidth = cropBox.width;
902
+ minCanvasHeight = cropBox.height;
903
+
904
+ if (minCanvasHeight * aspectRatio > minCanvasWidth) {
905
+ minCanvasWidth = minCanvasHeight * aspectRatio;
906
+ } else {
907
+ minCanvasHeight = minCanvasWidth / aspectRatio;
908
+ }
909
+ }
910
+ }
911
+ }
912
+
913
+ if (minCanvasWidth && minCanvasHeight) {
914
+ if (minCanvasHeight * aspectRatio > minCanvasWidth) {
915
+ minCanvasHeight = minCanvasWidth / aspectRatio;
916
+ } else {
917
+ minCanvasWidth = minCanvasHeight * aspectRatio;
918
+ }
919
+ } else if (minCanvasWidth) {
920
+ minCanvasHeight = minCanvasWidth / aspectRatio;
921
+ } else if (minCanvasHeight) {
922
+ minCanvasWidth = minCanvasHeight * aspectRatio;
923
+ }
924
+
925
+ canvas.minWidth = minCanvasWidth;
926
+ canvas.minHeight = minCanvasHeight;
927
+ canvas.maxWidth = Infinity;
928
+ canvas.maxHeight = Infinity;
929
+ }
930
+
931
+ if (isPositionLimited) {
932
+ if (viewMode) {
933
+ newCanvasLeft = containerWidth - canvas.width;
934
+ newCanvasTop = containerHeight - canvas.height;
935
+
936
+ canvas.minLeft = min(0, newCanvasLeft);
937
+ canvas.minTop = min(0, newCanvasTop);
938
+ canvas.maxLeft = max(0, newCanvasLeft);
939
+ canvas.maxTop = max(0, newCanvasTop);
940
+
941
+ if (isCropped && this.isLimited) {
942
+ canvas.minLeft = min(
943
+ cropBox.left,
944
+ cropBox.left + cropBox.width - canvas.width
945
+ );
946
+ canvas.minTop = min(
947
+ cropBox.top,
948
+ cropBox.top + cropBox.height - canvas.height
949
+ );
950
+ canvas.maxLeft = cropBox.left;
951
+ canvas.maxTop = cropBox.top;
952
+
953
+ if (viewMode === 2) {
954
+ if (canvas.width >= containerWidth) {
955
+ canvas.minLeft = min(0, newCanvasLeft);
956
+ canvas.maxLeft = max(0, newCanvasLeft);
957
+ }
958
+
959
+ if (canvas.height >= containerHeight) {
960
+ canvas.minTop = min(0, newCanvasTop);
961
+ canvas.maxTop = max(0, newCanvasTop);
962
+ }
963
+ }
964
+ }
965
+ } else {
966
+ canvas.minLeft = -canvas.width;
967
+ canvas.minTop = -canvas.height;
968
+ canvas.maxLeft = containerWidth;
969
+ canvas.maxTop = containerHeight;
970
+ }
971
+ }
972
+ },
973
+
974
+ renderCanvas: function (isChanged) {
975
+ var canvas = this.canvas;
976
+ var image = this.image;
977
+ var rotate = image.rotate;
978
+ var naturalWidth = image.naturalWidth;
979
+ var naturalHeight = image.naturalHeight;
980
+ var aspectRatio;
981
+ var rotated;
982
+
983
+ if (this.isRotated) {
984
+ this.isRotated = false;
985
+
986
+ // Computes rotated sizes with image sizes
987
+ rotated = getRotatedSizes({
988
+ width: image.width,
989
+ height: image.height,
990
+ degree: rotate
991
+ });
992
+
993
+ aspectRatio = rotated.width / rotated.height;
994
+
995
+ if (aspectRatio !== canvas.aspectRatio) {
996
+ canvas.left -= (rotated.width - canvas.width) / 2;
997
+ canvas.top -= (rotated.height - canvas.height) / 2;
998
+ canvas.width = rotated.width;
999
+ canvas.height = rotated.height;
1000
+ canvas.aspectRatio = aspectRatio;
1001
+ canvas.naturalWidth = naturalWidth;
1002
+ canvas.naturalHeight = naturalHeight;
1003
+
1004
+ // Computes rotated sizes with natural image sizes
1005
+ if (rotate % 180) {
1006
+ rotated = getRotatedSizes({
1007
+ width: naturalWidth,
1008
+ height: naturalHeight,
1009
+ degree: rotate
1010
+ });
1011
+
1012
+ canvas.naturalWidth = rotated.width;
1013
+ canvas.naturalHeight = rotated.height;
1014
+ }
1015
+
1016
+ this.limitCanvas(true, false);
1017
+ }
1018
+ }
1019
+
1020
+ if (canvas.width > canvas.maxWidth || canvas.width < canvas.minWidth) {
1021
+ canvas.left = canvas.oldLeft;
1022
+ }
1023
+
1024
+ if (canvas.height > canvas.maxHeight || canvas.height < canvas.minHeight) {
1025
+ canvas.top = canvas.oldTop;
1026
+ }
1027
+
1028
+ canvas.width = min(max(canvas.width, canvas.minWidth), canvas.maxWidth);
1029
+ canvas.height = min(max(canvas.height, canvas.minHeight), canvas.maxHeight);
1030
+
1031
+ this.limitCanvas(false, true);
1032
+
1033
+ canvas.oldLeft = canvas.left = min(max(canvas.left, canvas.minLeft), canvas.maxLeft);
1034
+ canvas.oldTop = canvas.top = min(max(canvas.top, canvas.minTop), canvas.maxTop);
1035
+
1036
+ this.$canvas.css({
1037
+ width: canvas.width,
1038
+ height: canvas.height,
1039
+ left: canvas.left,
1040
+ top: canvas.top
1041
+ });
1042
+
1043
+ this.renderImage();
1044
+
1045
+ if (this.isCropped && this.isLimited) {
1046
+ this.limitCropBox(true, true);
1047
+ }
1048
+
1049
+ if (isChanged) {
1050
+ this.output();
1051
+ }
1052
+ },
1053
+
1054
+ renderImage: function (isChanged) {
1055
+ var canvas = this.canvas;
1056
+ var image = this.image;
1057
+ var reversed;
1058
+
1059
+ if (image.rotate) {
1060
+ reversed = getRotatedSizes({
1061
+ width: canvas.width,
1062
+ height: canvas.height,
1063
+ degree: image.rotate,
1064
+ aspectRatio: image.aspectRatio
1065
+ }, true);
1066
+ }
1067
+
1068
+ $.extend(image, reversed ? {
1069
+ width: reversed.width,
1070
+ height: reversed.height,
1071
+ left: (canvas.width - reversed.width) / 2,
1072
+ top: (canvas.height - reversed.height) / 2
1073
+ } : {
1074
+ width: canvas.width,
1075
+ height: canvas.height,
1076
+ left: 0,
1077
+ top: 0
1078
+ });
1079
+
1080
+ this.$clone.css({
1081
+ width: image.width,
1082
+ height: image.height,
1083
+ marginLeft: image.left,
1084
+ marginTop: image.top,
1085
+ transform: getTransform(image)
1086
+ });
1087
+
1088
+ if (isChanged) {
1089
+ this.output();
1090
+ }
1091
+ },
1092
+
1093
+ initCropBox: function () {
1094
+ var options = this.options;
1095
+ var canvas = this.canvas;
1096
+ var aspectRatio = options.aspectRatio;
1097
+ var autoCropArea = num(options.autoCropArea) || 0.8;
1098
+ var cropBox = {
1099
+ width: canvas.width,
1100
+ height: canvas.height
1101
+ };
1102
+
1103
+ if (aspectRatio) {
1104
+ if (canvas.height * aspectRatio > canvas.width) {
1105
+ cropBox.height = cropBox.width / aspectRatio;
1106
+ } else {
1107
+ cropBox.width = cropBox.height * aspectRatio;
1108
+ }
1109
+ }
1110
+
1111
+ this.cropBox = cropBox;
1112
+ this.limitCropBox(true, true);
1113
+
1114
+ // Initialize auto crop area
1115
+ cropBox.width = min(max(cropBox.width, cropBox.minWidth), cropBox.maxWidth);
1116
+ cropBox.height = min(max(cropBox.height, cropBox.minHeight), cropBox.maxHeight);
1117
+
1118
+ // The width of auto crop area must large than "minWidth", and the height too. (#164)
1119
+ cropBox.width = max(cropBox.minWidth, cropBox.width * autoCropArea);
1120
+ cropBox.height = max(cropBox.minHeight, cropBox.height * autoCropArea);
1121
+ cropBox.oldLeft = cropBox.left = canvas.left + (canvas.width - cropBox.width) / 2;
1122
+ cropBox.oldTop = cropBox.top = canvas.top + (canvas.height - cropBox.height) / 2;
1123
+
1124
+ this.initialCropBox = $.extend({}, cropBox);
1125
+ },
1126
+
1127
+ limitCropBox: function (isSizeLimited, isPositionLimited) {
1128
+ var options = this.options;
1129
+ var aspectRatio = options.aspectRatio;
1130
+ var container = this.container;
1131
+ var containerWidth = container.width;
1132
+ var containerHeight = container.height;
1133
+ var canvas = this.canvas;
1134
+ var cropBox = this.cropBox;
1135
+ var isLimited = this.isLimited;
1136
+ var minCropBoxWidth;
1137
+ var minCropBoxHeight;
1138
+ var maxCropBoxWidth;
1139
+ var maxCropBoxHeight;
1140
+
1141
+ if (isSizeLimited) {
1142
+ minCropBoxWidth = num(options.minCropBoxWidth) || 0;
1143
+ minCropBoxHeight = num(options.minCropBoxHeight) || 0;
1144
+
1145
+ // The min/maxCropBoxWidth/Height must be less than containerWidth/Height
1146
+ minCropBoxWidth = min(minCropBoxWidth, containerWidth);
1147
+ minCropBoxHeight = min(minCropBoxHeight, containerHeight);
1148
+ maxCropBoxWidth = min(containerWidth, isLimited ? canvas.width : containerWidth);
1149
+ maxCropBoxHeight = min(containerHeight, isLimited ? canvas.height : containerHeight);
1150
+
1151
+ if (aspectRatio) {
1152
+ if (minCropBoxWidth && minCropBoxHeight) {
1153
+ if (minCropBoxHeight * aspectRatio > minCropBoxWidth) {
1154
+ minCropBoxHeight = minCropBoxWidth / aspectRatio;
1155
+ } else {
1156
+ minCropBoxWidth = minCropBoxHeight * aspectRatio;
1157
+ }
1158
+ } else if (minCropBoxWidth) {
1159
+ minCropBoxHeight = minCropBoxWidth / aspectRatio;
1160
+ } else if (minCropBoxHeight) {
1161
+ minCropBoxWidth = minCropBoxHeight * aspectRatio;
1162
+ }
1163
+
1164
+ if (maxCropBoxHeight * aspectRatio > maxCropBoxWidth) {
1165
+ maxCropBoxHeight = maxCropBoxWidth / aspectRatio;
1166
+ } else {
1167
+ maxCropBoxWidth = maxCropBoxHeight * aspectRatio;
1168
+ }
1169
+ }
1170
+
1171
+ // The minWidth/Height must be less than maxWidth/Height
1172
+ cropBox.minWidth = min(minCropBoxWidth, maxCropBoxWidth);
1173
+ cropBox.minHeight = min(minCropBoxHeight, maxCropBoxHeight);
1174
+ cropBox.maxWidth = maxCropBoxWidth;
1175
+ cropBox.maxHeight = maxCropBoxHeight;
1176
+ }
1177
+
1178
+ if (isPositionLimited) {
1179
+ if (isLimited) {
1180
+ cropBox.minLeft = max(0, canvas.left);
1181
+ cropBox.minTop = max(0, canvas.top);
1182
+ cropBox.maxLeft = min(containerWidth, canvas.left + canvas.width) - cropBox.width;
1183
+ cropBox.maxTop = min(containerHeight, canvas.top + canvas.height) - cropBox.height;
1184
+ } else {
1185
+ cropBox.minLeft = 0;
1186
+ cropBox.minTop = 0;
1187
+ cropBox.maxLeft = containerWidth - cropBox.width;
1188
+ cropBox.maxTop = containerHeight - cropBox.height;
1189
+ }
1190
+ }
1191
+ },
1192
+
1193
+ renderCropBox: function () {
1194
+ var options = this.options;
1195
+ var container = this.container;
1196
+ var containerWidth = container.width;
1197
+ var containerHeight = container.height;
1198
+ var cropBox = this.cropBox;
1199
+
1200
+ if (cropBox.width > cropBox.maxWidth || cropBox.width < cropBox.minWidth) {
1201
+ cropBox.left = cropBox.oldLeft;
1202
+ }
1203
+
1204
+ if (cropBox.height > cropBox.maxHeight || cropBox.height < cropBox.minHeight) {
1205
+ cropBox.top = cropBox.oldTop;
1206
+ }
1207
+
1208
+ cropBox.width = min(max(cropBox.width, cropBox.minWidth), cropBox.maxWidth);
1209
+ cropBox.height = min(max(cropBox.height, cropBox.minHeight), cropBox.maxHeight);
1210
+
1211
+ this.limitCropBox(false, true);
1212
+
1213
+ cropBox.oldLeft = cropBox.left = min(max(cropBox.left, cropBox.minLeft), cropBox.maxLeft);
1214
+ cropBox.oldTop = cropBox.top = min(max(cropBox.top, cropBox.minTop), cropBox.maxTop);
1215
+
1216
+ if (options.movable && options.cropBoxMovable) {
1217
+
1218
+ // Turn to move the canvas when the crop box is equal to the container
1219
+ this.$face.data(DATA_ACTION, (cropBox.width === containerWidth && cropBox.height === containerHeight) ? ACTION_MOVE : ACTION_ALL);
1220
+ }
1221
+
1222
+ this.$cropBox.css({
1223
+ width: cropBox.width,
1224
+ height: cropBox.height,
1225
+ left: cropBox.left,
1226
+ top: cropBox.top
1227
+ });
1228
+
1229
+ if (this.isCropped && this.isLimited) {
1230
+ this.limitCanvas(true, true);
1231
+ }
1232
+
1233
+ if (!this.isDisabled) {
1234
+ this.output();
1235
+ }
1236
+ },
1237
+
1238
+ output: function () {
1239
+ this.preview();
1240
+
1241
+ if (this.isCompleted) {
1242
+ this.trigger(EVENT_CROP, this.getData());
1243
+ }
1244
+ },
1245
+
1246
+ initPreview: function () {
1247
+ var crossOrigin = getCrossOrigin(this.crossOrigin);
1248
+ var url = crossOrigin ? this.crossOriginUrl : this.url;
1249
+ var $clone2;
1250
+
1251
+ this.$preview = $(this.options.preview);
1252
+ this.$clone2 = $clone2 = $('<img' + crossOrigin + ' src="' + url + '">');
1253
+ this.$viewBox.html($clone2);
1254
+ this.$preview.each(function () {
1255
+ var $this = $(this);
1256
+
1257
+ // Save the original size for recover
1258
+ $this.data(DATA_PREVIEW, {
1259
+ width: $this.width(),
1260
+ height: $this.height(),
1261
+ html: $this.html()
1262
+ });
1263
+
1264
+ /**
1265
+ * Override img element styles
1266
+ * Add `display:block` to avoid margin top issue
1267
+ * (Occur only when margin-top <= -height)
1268
+ */
1269
+ $this.html(
1270
+ '<img' + crossOrigin + ' src="' + url + '" style="' +
1271
+ 'display:block;width:100%;height:auto;' +
1272
+ 'min-width:0!important;min-height:0!important;' +
1273
+ 'max-width:none!important;max-height:none!important;' +
1274
+ 'image-orientation:0deg!important;">'
1275
+ );
1276
+ });
1277
+ },
1278
+
1279
+ resetPreview: function () {
1280
+ this.$preview.each(function () {
1281
+ var $this = $(this);
1282
+ var data = $this.data(DATA_PREVIEW);
1283
+
1284
+ $this.css({
1285
+ width: data.width,
1286
+ height: data.height
1287
+ }).html(data.html).removeData(DATA_PREVIEW);
1288
+ });
1289
+ },
1290
+
1291
+ preview: function () {
1292
+ var image = this.image;
1293
+ var canvas = this.canvas;
1294
+ var cropBox = this.cropBox;
1295
+ var cropBoxWidth = cropBox.width;
1296
+ var cropBoxHeight = cropBox.height;
1297
+ var width = image.width;
1298
+ var height = image.height;
1299
+ var left = cropBox.left - canvas.left - image.left;
1300
+ var top = cropBox.top - canvas.top - image.top;
1301
+
1302
+ if (!this.isCropped || this.isDisabled) {
1303
+ return;
1304
+ }
1305
+
1306
+ this.$clone2.css({
1307
+ width: width,
1308
+ height: height,
1309
+ marginLeft: -left,
1310
+ marginTop: -top,
1311
+ transform: getTransform(image)
1312
+ });
1313
+
1314
+ this.$preview.each(function () {
1315
+ var $this = $(this);
1316
+ var data = $this.data(DATA_PREVIEW);
1317
+ var originalWidth = data.width;
1318
+ var originalHeight = data.height;
1319
+ var newWidth = originalWidth;
1320
+ var newHeight = originalHeight;
1321
+ var ratio = 1;
1322
+
1323
+ if (cropBoxWidth) {
1324
+ ratio = originalWidth / cropBoxWidth;
1325
+ newHeight = cropBoxHeight * ratio;
1326
+ }
1327
+
1328
+ if (cropBoxHeight && newHeight > originalHeight) {
1329
+ ratio = originalHeight / cropBoxHeight;
1330
+ newWidth = cropBoxWidth * ratio;
1331
+ newHeight = originalHeight;
1332
+ }
1333
+
1334
+ $this.css({
1335
+ width: newWidth,
1336
+ height: newHeight
1337
+ }).find('img').css({
1338
+ width: width * ratio,
1339
+ height: height * ratio,
1340
+ marginLeft: -left * ratio,
1341
+ marginTop: -top * ratio,
1342
+ transform: getTransform(image)
1343
+ });
1344
+ });
1345
+ },
1346
+
1347
+ bind: function () {
1348
+ var options = this.options;
1349
+ var $this = this.$element;
1350
+ var $cropper = this.$cropper;
1351
+
1352
+ if ($.isFunction(options.cropstart)) {
1353
+ $this.on(EVENT_CROP_START, options.cropstart);
1354
+ }
1355
+
1356
+ if ($.isFunction(options.cropmove)) {
1357
+ $this.on(EVENT_CROP_MOVE, options.cropmove);
1358
+ }
1359
+
1360
+ if ($.isFunction(options.cropend)) {
1361
+ $this.on(EVENT_CROP_END, options.cropend);
1362
+ }
1363
+
1364
+ if ($.isFunction(options.crop)) {
1365
+ $this.on(EVENT_CROP, options.crop);
1366
+ }
1367
+
1368
+ if ($.isFunction(options.zoom)) {
1369
+ $this.on(EVENT_ZOOM, options.zoom);
1370
+ }
1371
+
1372
+ $cropper.on(EVENT_MOUSE_DOWN, $.proxy(this.cropStart, this));
1373
+
1374
+ if (options.zoomable && options.zoomOnWheel) {
1375
+ $cropper.on(EVENT_WHEEL, $.proxy(this.wheel, this));
1376
+ }
1377
+
1378
+ if (options.toggleDragModeOnDblclick) {
1379
+ $cropper.on(EVENT_DBLCLICK, $.proxy(this.dblclick, this));
1380
+ }
1381
+
1382
+ $document.
1383
+ on(EVENT_MOUSE_MOVE, (this._cropMove = proxy(this.cropMove, this))).
1384
+ on(EVENT_MOUSE_UP, (this._cropEnd = proxy(this.cropEnd, this)));
1385
+
1386
+ if (options.responsive) {
1387
+ $window.on(EVENT_RESIZE, (this._resize = proxy(this.resize, this)));
1388
+ }
1389
+ },
1390
+
1391
+ unbind: function () {
1392
+ var options = this.options;
1393
+ var $this = this.$element;
1394
+ var $cropper = this.$cropper;
1395
+
1396
+ if ($.isFunction(options.cropstart)) {
1397
+ $this.off(EVENT_CROP_START, options.cropstart);
1398
+ }
1399
+
1400
+ if ($.isFunction(options.cropmove)) {
1401
+ $this.off(EVENT_CROP_MOVE, options.cropmove);
1402
+ }
1403
+
1404
+ if ($.isFunction(options.cropend)) {
1405
+ $this.off(EVENT_CROP_END, options.cropend);
1406
+ }
1407
+
1408
+ if ($.isFunction(options.crop)) {
1409
+ $this.off(EVENT_CROP, options.crop);
1410
+ }
1411
+
1412
+ if ($.isFunction(options.zoom)) {
1413
+ $this.off(EVENT_ZOOM, options.zoom);
1414
+ }
1415
+
1416
+ $cropper.off(EVENT_MOUSE_DOWN, this.cropStart);
1417
+
1418
+ if (options.zoomable && options.zoomOnWheel) {
1419
+ $cropper.off(EVENT_WHEEL, this.wheel);
1420
+ }
1421
+
1422
+ if (options.toggleDragModeOnDblclick) {
1423
+ $cropper.off(EVENT_DBLCLICK, this.dblclick);
1424
+ }
1425
+
1426
+ $document.
1427
+ off(EVENT_MOUSE_MOVE, this._cropMove).
1428
+ off(EVENT_MOUSE_UP, this._cropEnd);
1429
+
1430
+ if (options.responsive) {
1431
+ $window.off(EVENT_RESIZE, this._resize);
1432
+ }
1433
+ },
1434
+
1435
+ resize: function () {
1436
+ var restore = this.options.restore;
1437
+ var $container = this.$container;
1438
+ var container = this.container;
1439
+ var canvasData;
1440
+ var cropBoxData;
1441
+ var ratio;
1442
+
1443
+ // Check `container` is necessary for IE8
1444
+ if (this.isDisabled || !container) {
1445
+ return;
1446
+ }
1447
+
1448
+ ratio = $container.width() / container.width;
1449
+
1450
+ // Resize when width changed or height changed
1451
+ if (ratio !== 1 || $container.height() !== container.height) {
1452
+ if (restore) {
1453
+ canvasData = this.getCanvasData();
1454
+ cropBoxData = this.getCropBoxData();
1455
+ }
1456
+
1457
+ this.render();
1458
+
1459
+ if (restore) {
1460
+ this.setCanvasData($.each(canvasData, function (i, n) {
1461
+ canvasData[i] = n * ratio;
1462
+ }));
1463
+ this.setCropBoxData($.each(cropBoxData, function (i, n) {
1464
+ cropBoxData[i] = n * ratio;
1465
+ }));
1466
+ }
1467
+ }
1468
+ },
1469
+
1470
+ dblclick: function () {
1471
+ if (this.isDisabled) {
1472
+ return;
1473
+ }
1474
+
1475
+ if (this.$dragBox.hasClass(CLASS_CROP)) {
1476
+ this.setDragMode(ACTION_MOVE);
1477
+ } else {
1478
+ this.setDragMode(ACTION_CROP);
1479
+ }
1480
+ },
1481
+
1482
+ wheel: function (event) {
1483
+ var e = event.originalEvent || event;
1484
+ var ratio = num(this.options.wheelZoomRatio) || 0.1;
1485
+ var delta = 1;
1486
+
1487
+ if (this.isDisabled) {
1488
+ return;
1489
+ }
1490
+
1491
+ event.preventDefault();
1492
+
1493
+ // Limit wheel speed to prevent zoom too fast
1494
+ if (this.wheeling) {
1495
+ return;
1496
+ }
1497
+
1498
+ this.wheeling = true;
1499
+
1500
+ setTimeout($.proxy(function () {
1501
+ this.wheeling = false;
1502
+ }, this), 50);
1503
+
1504
+ if (e.deltaY) {
1505
+ delta = e.deltaY > 0 ? 1 : -1;
1506
+ } else if (e.wheelDelta) {
1507
+ delta = -e.wheelDelta / 120;
1508
+ } else if (e.detail) {
1509
+ delta = e.detail > 0 ? 1 : -1;
1510
+ }
1511
+
1512
+ this.zoom(-delta * ratio, event);
1513
+ },
1514
+
1515
+ cropStart: function (event) {
1516
+ var options = this.options;
1517
+ var originalEvent = event.originalEvent;
1518
+ var touches = originalEvent && originalEvent.touches;
1519
+ var e = event;
1520
+ var touchesLength;
1521
+ var action;
1522
+
1523
+ if (this.isDisabled) {
1524
+ return;
1525
+ }
1526
+
1527
+ if (touches) {
1528
+ touchesLength = touches.length;
1529
+
1530
+ if (touchesLength > 1) {
1531
+ if (options.zoomable && options.zoomOnTouch && touchesLength === 2) {
1532
+ e = touches[1];
1533
+ this.startX2 = e.pageX;
1534
+ this.startY2 = e.pageY;
1535
+ action = ACTION_ZOOM;
1536
+ } else {
1537
+ return;
1538
+ }
1539
+ }
1540
+
1541
+ e = touches[0];
1542
+ }
1543
+
1544
+ action = action || $(e.target).data(DATA_ACTION);
1545
+
1546
+ if (REGEXP_ACTIONS.test(action)) {
1547
+ if (this.trigger(EVENT_CROP_START, {
1548
+ originalEvent: originalEvent,
1549
+ action: action
1550
+ }).isDefaultPrevented()) {
1551
+ return;
1552
+ }
1553
+
1554
+ event.preventDefault();
1555
+
1556
+ this.action = action;
1557
+ this.cropping = false;
1558
+
1559
+ // IE8 has `event.pageX/Y`, but not `event.originalEvent.pageX/Y`
1560
+ // IE10 has `event.originalEvent.pageX/Y`, but not `event.pageX/Y`
1561
+ this.startX = e.pageX || originalEvent && originalEvent.pageX;
1562
+ this.startY = e.pageY || originalEvent && originalEvent.pageY;
1563
+
1564
+ if (action === ACTION_CROP) {
1565
+ this.cropping = true;
1566
+ this.$dragBox.addClass(CLASS_MODAL);
1567
+ }
1568
+ }
1569
+ },
1570
+
1571
+ cropMove: function (event) {
1572
+ var options = this.options;
1573
+ var originalEvent = event.originalEvent;
1574
+ var touches = originalEvent && originalEvent.touches;
1575
+ var e = event;
1576
+ var action = this.action;
1577
+ var touchesLength;
1578
+
1579
+ if (this.isDisabled) {
1580
+ return;
1581
+ }
1582
+
1583
+ if (touches) {
1584
+ touchesLength = touches.length;
1585
+
1586
+ if (touchesLength > 1) {
1587
+ if (options.zoomable && options.zoomOnTouch && touchesLength === 2) {
1588
+ e = touches[1];
1589
+ this.endX2 = e.pageX;
1590
+ this.endY2 = e.pageY;
1591
+ } else {
1592
+ return;
1593
+ }
1594
+ }
1595
+
1596
+ e = touches[0];
1597
+ }
1598
+
1599
+ if (action) {
1600
+ if (this.trigger(EVENT_CROP_MOVE, {
1601
+ originalEvent: originalEvent,
1602
+ action: action
1603
+ }).isDefaultPrevented()) {
1604
+ return;
1605
+ }
1606
+
1607
+ event.preventDefault();
1608
+
1609
+ this.endX = e.pageX || originalEvent && originalEvent.pageX;
1610
+ this.endY = e.pageY || originalEvent && originalEvent.pageY;
1611
+
1612
+ this.change(e.shiftKey, action === ACTION_ZOOM ? event : null);
1613
+ }
1614
+ },
1615
+
1616
+ cropEnd: function (event) {
1617
+ var originalEvent = event.originalEvent;
1618
+ var action = this.action;
1619
+
1620
+ if (this.isDisabled) {
1621
+ return;
1622
+ }
1623
+
1624
+ if (action) {
1625
+ event.preventDefault();
1626
+
1627
+ if (this.cropping) {
1628
+ this.cropping = false;
1629
+ this.$dragBox.toggleClass(CLASS_MODAL, this.isCropped && this.options.modal);
1630
+ }
1631
+
1632
+ this.action = '';
1633
+
1634
+ this.trigger(EVENT_CROP_END, {
1635
+ originalEvent: originalEvent,
1636
+ action: action
1637
+ });
1638
+ }
1639
+ },
1640
+
1641
+ change: function (shiftKey, event) {
1642
+ var options = this.options;
1643
+ var aspectRatio = options.aspectRatio;
1644
+ var action = this.action;
1645
+ var container = this.container;
1646
+ var canvas = this.canvas;
1647
+ var cropBox = this.cropBox;
1648
+ var width = cropBox.width;
1649
+ var height = cropBox.height;
1650
+ var left = cropBox.left;
1651
+ var top = cropBox.top;
1652
+ var right = left + width;
1653
+ var bottom = top + height;
1654
+ var minLeft = 0;
1655
+ var minTop = 0;
1656
+ var maxWidth = container.width;
1657
+ var maxHeight = container.height;
1658
+ var renderable = true;
1659
+ var offset;
1660
+ var range;
1661
+
1662
+ // Locking aspect ratio in "free mode" by holding shift key (#259)
1663
+ if (!aspectRatio && shiftKey) {
1664
+ aspectRatio = width && height ? width / height : 1;
1665
+ }
1666
+
1667
+ if (this.isLimited) {
1668
+ minLeft = cropBox.minLeft;
1669
+ minTop = cropBox.minTop;
1670
+ maxWidth = minLeft + min(container.width, canvas.width, canvas.left + canvas.width);
1671
+ maxHeight = minTop + min(container.height, canvas.height, canvas.top + canvas.height);
1672
+ }
1673
+
1674
+ range = {
1675
+ x: this.endX - this.startX,
1676
+ y: this.endY - this.startY
1677
+ };
1678
+
1679
+ if (aspectRatio) {
1680
+ range.X = range.y * aspectRatio;
1681
+ range.Y = range.x / aspectRatio;
1682
+ }
1683
+
1684
+ switch (action) {
1685
+ // Move crop box
1686
+ case ACTION_ALL:
1687
+ left += range.x;
1688
+ top += range.y;
1689
+ break;
1690
+
1691
+ // Resize crop box
1692
+ case ACTION_EAST:
1693
+ if (range.x >= 0 && (right >= maxWidth || aspectRatio &&
1694
+ (top <= minTop || bottom >= maxHeight))) {
1695
+
1696
+ renderable = false;
1697
+ break;
1698
+ }
1699
+
1700
+ width += range.x;
1701
+
1702
+ if (aspectRatio) {
1703
+ height = width / aspectRatio;
1704
+ top -= range.Y / 2;
1705
+ }
1706
+
1707
+ if (width < 0) {
1708
+ action = ACTION_WEST;
1709
+ width = 0;
1710
+ }
1711
+
1712
+ break;
1713
+
1714
+ case ACTION_NORTH:
1715
+ if (range.y <= 0 && (top <= minTop || aspectRatio &&
1716
+ (left <= minLeft || right >= maxWidth))) {
1717
+
1718
+ renderable = false;
1719
+ break;
1720
+ }
1721
+
1722
+ height -= range.y;
1723
+ top += range.y;
1724
+
1725
+ if (aspectRatio) {
1726
+ width = height * aspectRatio;
1727
+ left += range.X / 2;
1728
+ }
1729
+
1730
+ if (height < 0) {
1731
+ action = ACTION_SOUTH;
1732
+ height = 0;
1733
+ }
1734
+
1735
+ break;
1736
+
1737
+ case ACTION_WEST:
1738
+ if (range.x <= 0 && (left <= minLeft || aspectRatio &&
1739
+ (top <= minTop || bottom >= maxHeight))) {
1740
+
1741
+ renderable = false;
1742
+ break;
1743
+ }
1744
+
1745
+ width -= range.x;
1746
+ left += range.x;
1747
+
1748
+ if (aspectRatio) {
1749
+ height = width / aspectRatio;
1750
+ top += range.Y / 2;
1751
+ }
1752
+
1753
+ if (width < 0) {
1754
+ action = ACTION_EAST;
1755
+ width = 0;
1756
+ }
1757
+
1758
+ break;
1759
+
1760
+ case ACTION_SOUTH:
1761
+ if (range.y >= 0 && (bottom >= maxHeight || aspectRatio &&
1762
+ (left <= minLeft || right >= maxWidth))) {
1763
+
1764
+ renderable = false;
1765
+ break;
1766
+ }
1767
+
1768
+ height += range.y;
1769
+
1770
+ if (aspectRatio) {
1771
+ width = height * aspectRatio;
1772
+ left -= range.X / 2;
1773
+ }
1774
+
1775
+ if (height < 0) {
1776
+ action = ACTION_NORTH;
1777
+ height = 0;
1778
+ }
1779
+
1780
+ break;
1781
+
1782
+ case ACTION_NORTH_EAST:
1783
+ if (aspectRatio) {
1784
+ if (range.y <= 0 && (top <= minTop || right >= maxWidth)) {
1785
+ renderable = false;
1786
+ break;
1787
+ }
1788
+
1789
+ height -= range.y;
1790
+ top += range.y;
1791
+ width = height * aspectRatio;
1792
+ } else {
1793
+ if (range.x >= 0) {
1794
+ if (right < maxWidth) {
1795
+ width += range.x;
1796
+ } else if (range.y <= 0 && top <= minTop) {
1797
+ renderable = false;
1798
+ }
1799
+ } else {
1800
+ width += range.x;
1801
+ }
1802
+
1803
+ if (range.y <= 0) {
1804
+ if (top > minTop) {
1805
+ height -= range.y;
1806
+ top += range.y;
1807
+ }
1808
+ } else {
1809
+ height -= range.y;
1810
+ top += range.y;
1811
+ }
1812
+ }
1813
+
1814
+ if (width < 0 && height < 0) {
1815
+ action = ACTION_SOUTH_WEST;
1816
+ height = 0;
1817
+ width = 0;
1818
+ } else if (width < 0) {
1819
+ action = ACTION_NORTH_WEST;
1820
+ width = 0;
1821
+ } else if (height < 0) {
1822
+ action = ACTION_SOUTH_EAST;
1823
+ height = 0;
1824
+ }
1825
+
1826
+ break;
1827
+
1828
+ case ACTION_NORTH_WEST:
1829
+ if (aspectRatio) {
1830
+ if (range.y <= 0 && (top <= minTop || left <= minLeft)) {
1831
+ renderable = false;
1832
+ break;
1833
+ }
1834
+
1835
+ height -= range.y;
1836
+ top += range.y;
1837
+ width = height * aspectRatio;
1838
+ left += range.X;
1839
+ } else {
1840
+ if (range.x <= 0) {
1841
+ if (left > minLeft) {
1842
+ width -= range.x;
1843
+ left += range.x;
1844
+ } else if (range.y <= 0 && top <= minTop) {
1845
+ renderable = false;
1846
+ }
1847
+ } else {
1848
+ width -= range.x;
1849
+ left += range.x;
1850
+ }
1851
+
1852
+ if (range.y <= 0) {
1853
+ if (top > minTop) {
1854
+ height -= range.y;
1855
+ top += range.y;
1856
+ }
1857
+ } else {
1858
+ height -= range.y;
1859
+ top += range.y;
1860
+ }
1861
+ }
1862
+
1863
+ if (width < 0 && height < 0) {
1864
+ action = ACTION_SOUTH_EAST;
1865
+ height = 0;
1866
+ width = 0;
1867
+ } else if (width < 0) {
1868
+ action = ACTION_NORTH_EAST;
1869
+ width = 0;
1870
+ } else if (height < 0) {
1871
+ action = ACTION_SOUTH_WEST;
1872
+ height = 0;
1873
+ }
1874
+
1875
+ break;
1876
+
1877
+ case ACTION_SOUTH_WEST:
1878
+ if (aspectRatio) {
1879
+ if (range.x <= 0 && (left <= minLeft || bottom >= maxHeight)) {
1880
+ renderable = false;
1881
+ break;
1882
+ }
1883
+
1884
+ width -= range.x;
1885
+ left += range.x;
1886
+ height = width / aspectRatio;
1887
+ } else {
1888
+ if (range.x <= 0) {
1889
+ if (left > minLeft) {
1890
+ width -= range.x;
1891
+ left += range.x;
1892
+ } else if (range.y >= 0 && bottom >= maxHeight) {
1893
+ renderable = false;
1894
+ }
1895
+ } else {
1896
+ width -= range.x;
1897
+ left += range.x;
1898
+ }
1899
+
1900
+ if (range.y >= 0) {
1901
+ if (bottom < maxHeight) {
1902
+ height += range.y;
1903
+ }
1904
+ } else {
1905
+ height += range.y;
1906
+ }
1907
+ }
1908
+
1909
+ if (width < 0 && height < 0) {
1910
+ action = ACTION_NORTH_EAST;
1911
+ height = 0;
1912
+ width = 0;
1913
+ } else if (width < 0) {
1914
+ action = ACTION_SOUTH_EAST;
1915
+ width = 0;
1916
+ } else if (height < 0) {
1917
+ action = ACTION_NORTH_WEST;
1918
+ height = 0;
1919
+ }
1920
+
1921
+ break;
1922
+
1923
+ case ACTION_SOUTH_EAST:
1924
+ if (aspectRatio) {
1925
+ if (range.x >= 0 && (right >= maxWidth || bottom >= maxHeight)) {
1926
+ renderable = false;
1927
+ break;
1928
+ }
1929
+
1930
+ width += range.x;
1931
+ height = width / aspectRatio;
1932
+ } else {
1933
+ if (range.x >= 0) {
1934
+ if (right < maxWidth) {
1935
+ width += range.x;
1936
+ } else if (range.y >= 0 && bottom >= maxHeight) {
1937
+ renderable = false;
1938
+ }
1939
+ } else {
1940
+ width += range.x;
1941
+ }
1942
+
1943
+ if (range.y >= 0) {
1944
+ if (bottom < maxHeight) {
1945
+ height += range.y;
1946
+ }
1947
+ } else {
1948
+ height += range.y;
1949
+ }
1950
+ }
1951
+
1952
+ if (width < 0 && height < 0) {
1953
+ action = ACTION_NORTH_WEST;
1954
+ height = 0;
1955
+ width = 0;
1956
+ } else if (width < 0) {
1957
+ action = ACTION_SOUTH_WEST;
1958
+ width = 0;
1959
+ } else if (height < 0) {
1960
+ action = ACTION_NORTH_EAST;
1961
+ height = 0;
1962
+ }
1963
+
1964
+ break;
1965
+
1966
+ // Move canvas
1967
+ case ACTION_MOVE:
1968
+ this.move(range.x, range.y);
1969
+ renderable = false;
1970
+ break;
1971
+
1972
+ // Zoom canvas
1973
+ case ACTION_ZOOM:
1974
+ this.zoom((function (x1, y1, x2, y2) {
1975
+ var z1 = sqrt(x1 * x1 + y1 * y1);
1976
+ var z2 = sqrt(x2 * x2 + y2 * y2);
1977
+
1978
+ return (z2 - z1) / z1;
1979
+ })(
1980
+ abs(this.startX - this.startX2),
1981
+ abs(this.startY - this.startY2),
1982
+ abs(this.endX - this.endX2),
1983
+ abs(this.endY - this.endY2)
1984
+ ), event);
1985
+ this.startX2 = this.endX2;
1986
+ this.startY2 = this.endY2;
1987
+ renderable = false;
1988
+ break;
1989
+
1990
+ // Create crop box
1991
+ case ACTION_CROP:
1992
+ if (!range.x || !range.y) {
1993
+ renderable = false;
1994
+ break;
1995
+ }
1996
+
1997
+ offset = this.$cropper.offset();
1998
+ left = this.startX - offset.left;
1999
+ top = this.startY - offset.top;
2000
+ width = cropBox.minWidth;
2001
+ height = cropBox.minHeight;
2002
+
2003
+ if (range.x > 0) {
2004
+ action = range.y > 0 ? ACTION_SOUTH_EAST : ACTION_NORTH_EAST;
2005
+ } else if (range.x < 0) {
2006
+ left -= width;
2007
+ action = range.y > 0 ? ACTION_SOUTH_WEST : ACTION_NORTH_WEST;
2008
+ }
2009
+
2010
+ if (range.y < 0) {
2011
+ top -= height;
2012
+ }
2013
+
2014
+ // Show the crop box if is hidden
2015
+ if (!this.isCropped) {
2016
+ this.$cropBox.removeClass(CLASS_HIDDEN);
2017
+ this.isCropped = true;
2018
+
2019
+ if (this.isLimited) {
2020
+ this.limitCropBox(true, true);
2021
+ }
2022
+ }
2023
+
2024
+ break;
2025
+
2026
+ // No default
2027
+ }
2028
+
2029
+ if (renderable) {
2030
+ cropBox.width = width;
2031
+ cropBox.height = height;
2032
+ cropBox.left = left;
2033
+ cropBox.top = top;
2034
+ this.action = action;
2035
+
2036
+ this.renderCropBox();
2037
+ }
2038
+
2039
+ // Override
2040
+ this.startX = this.endX;
2041
+ this.startY = this.endY;
2042
+ },
2043
+
2044
+ // Show the crop box manually
2045
+ crop: function () {
2046
+ if (!this.isBuilt || this.isDisabled) {
2047
+ return;
2048
+ }
2049
+
2050
+ if (!this.isCropped) {
2051
+ this.isCropped = true;
2052
+ this.limitCropBox(true, true);
2053
+
2054
+ if (this.options.modal) {
2055
+ this.$dragBox.addClass(CLASS_MODAL);
2056
+ }
2057
+
2058
+ this.$cropBox.removeClass(CLASS_HIDDEN);
2059
+ }
2060
+
2061
+ this.setCropBoxData(this.initialCropBox);
2062
+ },
2063
+
2064
+ // Reset the image and crop box to their initial states
2065
+ reset: function () {
2066
+ if (!this.isBuilt || this.isDisabled) {
2067
+ return;
2068
+ }
2069
+
2070
+ this.image = $.extend({}, this.initialImage);
2071
+ this.canvas = $.extend({}, this.initialCanvas);
2072
+ this.cropBox = $.extend({}, this.initialCropBox);
2073
+
2074
+ this.renderCanvas();
2075
+
2076
+ if (this.isCropped) {
2077
+ this.renderCropBox();
2078
+ }
2079
+ },
2080
+
2081
+ // Clear the crop box
2082
+ clear: function () {
2083
+ if (!this.isCropped || this.isDisabled) {
2084
+ return;
2085
+ }
2086
+
2087
+ $.extend(this.cropBox, {
2088
+ left: 0,
2089
+ top: 0,
2090
+ width: 0,
2091
+ height: 0
2092
+ });
2093
+
2094
+ this.isCropped = false;
2095
+ this.renderCropBox();
2096
+
2097
+ this.limitCanvas(true, true);
2098
+
2099
+ // Render canvas after crop box rendered
2100
+ this.renderCanvas();
2101
+
2102
+ this.$dragBox.removeClass(CLASS_MODAL);
2103
+ this.$cropBox.addClass(CLASS_HIDDEN);
2104
+ },
2105
+
2106
+ /**
2107
+ * Replace the image's src and rebuild the cropper
2108
+ *
2109
+ * @param {String} url
2110
+ * @param {Boolean} onlyColorChanged (optional)
2111
+ */
2112
+ replace: function (url, onlyColorChanged) {
2113
+ if (!this.isDisabled && url) {
2114
+ if (this.isImg) {
2115
+ this.$element.attr('src', url);
2116
+ }
2117
+
2118
+ if (onlyColorChanged) {
2119
+ this.url = url;
2120
+ this.$clone.attr('src', url);
2121
+
2122
+ if (this.isBuilt) {
2123
+ this.$preview.find('img').add(this.$clone2).attr('src', url);
2124
+ }
2125
+ } else {
2126
+ if (this.isImg) {
2127
+ this.isReplaced = true;
2128
+ }
2129
+
2130
+ // Clear previous data
2131
+ this.options.data = null;
2132
+ this.load(url);
2133
+ }
2134
+ }
2135
+ },
2136
+
2137
+ // Enable (unfreeze) the cropper
2138
+ enable: function () {
2139
+ if (this.isBuilt) {
2140
+ this.isDisabled = false;
2141
+ this.$cropper.removeClass(CLASS_DISABLED);
2142
+ }
2143
+ },
2144
+
2145
+ // Disable (freeze) the cropper
2146
+ disable: function () {
2147
+ if (this.isBuilt) {
2148
+ this.isDisabled = true;
2149
+ this.$cropper.addClass(CLASS_DISABLED);
2150
+ }
2151
+ },
2152
+
2153
+ // Destroy the cropper and remove the instance from the image
2154
+ destroy: function () {
2155
+ var $this = this.$element;
2156
+
2157
+ if (this.isLoaded) {
2158
+ if (this.isImg && this.isReplaced) {
2159
+ $this.attr('src', this.originalUrl);
2160
+ }
2161
+
2162
+ this.unbuild();
2163
+ $this.removeClass(CLASS_HIDDEN);
2164
+ } else {
2165
+ if (this.isImg) {
2166
+ $this.off(EVENT_LOAD, this.start);
2167
+ } else if (this.$clone) {
2168
+ this.$clone.remove();
2169
+ }
2170
+ }
2171
+
2172
+ $this.removeData(NAMESPACE);
2173
+ },
2174
+
2175
+ /**
2176
+ * Move the canvas with relative offsets
2177
+ *
2178
+ * @param {Number} offsetX
2179
+ * @param {Number} offsetY (optional)
2180
+ */
2181
+ move: function (offsetX, offsetY) {
2182
+ var canvas = this.canvas;
2183
+
2184
+ this.moveTo(
2185
+ isUndefined(offsetX) ? offsetX : canvas.left + num(offsetX),
2186
+ isUndefined(offsetY) ? offsetY : canvas.top + num(offsetY)
2187
+ );
2188
+ },
2189
+
2190
+ /**
2191
+ * Move the canvas to an absolute point
2192
+ *
2193
+ * @param {Number} x
2194
+ * @param {Number} y (optional)
2195
+ */
2196
+ moveTo: function (x, y) {
2197
+ var canvas = this.canvas;
2198
+ var isChanged = false;
2199
+
2200
+ // If "y" is not present, its default value is "x"
2201
+ if (isUndefined(y)) {
2202
+ y = x;
2203
+ }
2204
+
2205
+ x = num(x);
2206
+ y = num(y);
2207
+
2208
+ if (this.isBuilt && !this.isDisabled && this.options.movable) {
2209
+ if (isNumber(x)) {
2210
+ canvas.left = x;
2211
+ isChanged = true;
2212
+ }
2213
+
2214
+ if (isNumber(y)) {
2215
+ canvas.top = y;
2216
+ isChanged = true;
2217
+ }
2218
+
2219
+ if (isChanged) {
2220
+ this.renderCanvas(true);
2221
+ }
2222
+ }
2223
+ },
2224
+
2225
+ /**
2226
+ * Zoom the canvas with a relative ratio
2227
+ *
2228
+ * @param {Number} ratio
2229
+ * @param {jQuery Event} _event (private)
2230
+ */
2231
+ zoom: function (ratio, _event) {
2232
+ var canvas = this.canvas;
2233
+
2234
+ ratio = num(ratio);
2235
+
2236
+ if (ratio < 0) {
2237
+ ratio = 1 / (1 - ratio);
2238
+ } else {
2239
+ ratio = 1 + ratio;
2240
+ }
2241
+
2242
+ this.zoomTo(canvas.width * ratio / canvas.naturalWidth, _event);
2243
+ },
2244
+
2245
+ /**
2246
+ * Zoom the canvas to an absolute ratio
2247
+ *
2248
+ * @param {Number} ratio
2249
+ * @param {jQuery Event} _event (private)
2250
+ */
2251
+ zoomTo: function (ratio, _event) {
2252
+ var options = this.options;
2253
+ var canvas = this.canvas;
2254
+ var width = canvas.width;
2255
+ var height = canvas.height;
2256
+ var naturalWidth = canvas.naturalWidth;
2257
+ var naturalHeight = canvas.naturalHeight;
2258
+ var originalEvent;
2259
+ var newWidth;
2260
+ var newHeight;
2261
+ var offset;
2262
+ var center;
2263
+
2264
+ ratio = num(ratio);
2265
+
2266
+ if (ratio >= 0 && this.isBuilt && !this.isDisabled && options.zoomable) {
2267
+ newWidth = naturalWidth * ratio;
2268
+ newHeight = naturalHeight * ratio;
2269
+
2270
+ if (_event) {
2271
+ originalEvent = _event.originalEvent;
2272
+ }
2273
+
2274
+ if (this.trigger(EVENT_ZOOM, {
2275
+ originalEvent: originalEvent,
2276
+ oldRatio: width / naturalWidth,
2277
+ ratio: newWidth / naturalWidth
2278
+ }).isDefaultPrevented()) {
2279
+ return;
2280
+ }
2281
+
2282
+ if (originalEvent) {
2283
+ offset = this.$cropper.offset();
2284
+ center = originalEvent.touches ? getTouchesCenter(originalEvent.touches) : {
2285
+ pageX: _event.pageX || originalEvent.pageX || 0,
2286
+ pageY: _event.pageY || originalEvent.pageY || 0
2287
+ };
2288
+
2289
+ // Zoom from the triggering point of the event
2290
+ canvas.left -= (newWidth - width) * (
2291
+ ((center.pageX - offset.left) - canvas.left) / width
2292
+ );
2293
+ canvas.top -= (newHeight - height) * (
2294
+ ((center.pageY - offset.top) - canvas.top) / height
2295
+ );
2296
+ } else {
2297
+
2298
+ // Zoom from the center of the canvas
2299
+ canvas.left -= (newWidth - width) / 2;
2300
+ canvas.top -= (newHeight - height) / 2;
2301
+ }
2302
+
2303
+ canvas.width = newWidth;
2304
+ canvas.height = newHeight;
2305
+ this.renderCanvas(true);
2306
+ }
2307
+ },
2308
+
2309
+ /**
2310
+ * Rotate the canvas with a relative degree
2311
+ *
2312
+ * @param {Number} degree
2313
+ */
2314
+ rotate: function (degree) {
2315
+ this.rotateTo((this.image.rotate || 0) + num(degree));
2316
+ },
2317
+
2318
+ /**
2319
+ * Rotate the canvas to an absolute degree
2320
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function#rotate()
2321
+ *
2322
+ * @param {Number} degree
2323
+ */
2324
+ rotateTo: function (degree) {
2325
+ degree = num(degree);
2326
+
2327
+ if (isNumber(degree) && this.isBuilt && !this.isDisabled && this.options.rotatable) {
2328
+ this.image.rotate = degree % 360;
2329
+ this.isRotated = true;
2330
+ this.renderCanvas(true);
2331
+ }
2332
+ },
2333
+
2334
+ /**
2335
+ * Scale the image
2336
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function#scale()
2337
+ *
2338
+ * @param {Number} scaleX
2339
+ * @param {Number} scaleY (optional)
2340
+ */
2341
+ scale: function (scaleX, scaleY) {
2342
+ var image = this.image;
2343
+ var isChanged = false;
2344
+
2345
+ // If "scaleY" is not present, its default value is "scaleX"
2346
+ if (isUndefined(scaleY)) {
2347
+ scaleY = scaleX;
2348
+ }
2349
+
2350
+ scaleX = num(scaleX);
2351
+ scaleY = num(scaleY);
2352
+
2353
+ if (this.isBuilt && !this.isDisabled && this.options.scalable) {
2354
+ if (isNumber(scaleX)) {
2355
+ image.scaleX = scaleX;
2356
+ isChanged = true;
2357
+ }
2358
+
2359
+ if (isNumber(scaleY)) {
2360
+ image.scaleY = scaleY;
2361
+ isChanged = true;
2362
+ }
2363
+
2364
+ if (isChanged) {
2365
+ this.renderImage(true);
2366
+ }
2367
+ }
2368
+ },
2369
+
2370
+ /**
2371
+ * Scale the abscissa of the image
2372
+ *
2373
+ * @param {Number} scaleX
2374
+ */
2375
+ scaleX: function (scaleX) {
2376
+ var scaleY = this.image.scaleY;
2377
+
2378
+ this.scale(scaleX, isNumber(scaleY) ? scaleY : 1);
2379
+ },
2380
+
2381
+ /**
2382
+ * Scale the ordinate of the image
2383
+ *
2384
+ * @param {Number} scaleY
2385
+ */
2386
+ scaleY: function (scaleY) {
2387
+ var scaleX = this.image.scaleX;
2388
+
2389
+ this.scale(isNumber(scaleX) ? scaleX : 1, scaleY);
2390
+ },
2391
+
2392
+ /**
2393
+ * Get the cropped area position and size data (base on the original image)
2394
+ *
2395
+ * @param {Boolean} isRounded (optional)
2396
+ * @return {Object} data
2397
+ */
2398
+ getData: function (isRounded) {
2399
+ var options = this.options;
2400
+ var image = this.image;
2401
+ var canvas = this.canvas;
2402
+ var cropBox = this.cropBox;
2403
+ var ratio;
2404
+ var data;
2405
+
2406
+ if (this.isBuilt && this.isCropped) {
2407
+ data = {
2408
+ x: cropBox.left - canvas.left,
2409
+ y: cropBox.top - canvas.top,
2410
+ width: cropBox.width,
2411
+ height: cropBox.height
2412
+ };
2413
+
2414
+ ratio = image.width / image.naturalWidth;
2415
+
2416
+ $.each(data, function (i, n) {
2417
+ n = n / ratio;
2418
+ data[i] = isRounded ? round(n) : n;
2419
+ });
2420
+
2421
+ } else {
2422
+ data = {
2423
+ x: 0,
2424
+ y: 0,
2425
+ width: 0,
2426
+ height: 0
2427
+ };
2428
+ }
2429
+
2430
+ if (options.rotatable) {
2431
+ data.rotate = image.rotate || 0;
2432
+ }
2433
+
2434
+ if (options.scalable) {
2435
+ data.scaleX = image.scaleX || 1;
2436
+ data.scaleY = image.scaleY || 1;
2437
+ }
2438
+
2439
+ return data;
2440
+ },
2441
+
2442
+ /**
2443
+ * Set the cropped area position and size with new data
2444
+ *
2445
+ * @param {Object} data
2446
+ */
2447
+ setData: function (data) {
2448
+ var options = this.options;
2449
+ var image = this.image;
2450
+ var canvas = this.canvas;
2451
+ var cropBoxData = {};
2452
+ var isRotated;
2453
+ var isScaled;
2454
+ var ratio;
2455
+
2456
+ if ($.isFunction(data)) {
2457
+ data = data.call(this.element);
2458
+ }
2459
+
2460
+ if (this.isBuilt && !this.isDisabled && $.isPlainObject(data)) {
2461
+ if (options.rotatable) {
2462
+ if (isNumber(data.rotate) && data.rotate !== image.rotate) {
2463
+ image.rotate = data.rotate;
2464
+ this.isRotated = isRotated = true;
2465
+ }
2466
+ }
2467
+
2468
+ if (options.scalable) {
2469
+ if (isNumber(data.scaleX) && data.scaleX !== image.scaleX) {
2470
+ image.scaleX = data.scaleX;
2471
+ isScaled = true;
2472
+ }
2473
+
2474
+ if (isNumber(data.scaleY) && data.scaleY !== image.scaleY) {
2475
+ image.scaleY = data.scaleY;
2476
+ isScaled = true;
2477
+ }
2478
+ }
2479
+
2480
+ if (isRotated) {
2481
+ this.renderCanvas();
2482
+ } else if (isScaled) {
2483
+ this.renderImage();
2484
+ }
2485
+
2486
+ ratio = image.width / image.naturalWidth;
2487
+
2488
+ if (isNumber(data.x)) {
2489
+ cropBoxData.left = data.x * ratio + canvas.left;
2490
+ }
2491
+
2492
+ if (isNumber(data.y)) {
2493
+ cropBoxData.top = data.y * ratio + canvas.top;
2494
+ }
2495
+
2496
+ if (isNumber(data.width)) {
2497
+ cropBoxData.width = data.width * ratio;
2498
+ }
2499
+
2500
+ if (isNumber(data.height)) {
2501
+ cropBoxData.height = data.height * ratio;
2502
+ }
2503
+
2504
+ this.setCropBoxData(cropBoxData);
2505
+ }
2506
+ },
2507
+
2508
+ /**
2509
+ * Get the container size data
2510
+ *
2511
+ * @return {Object} data
2512
+ */
2513
+ getContainerData: function () {
2514
+ return this.isBuilt ? this.container : {};
2515
+ },
2516
+
2517
+ /**
2518
+ * Get the image position and size data
2519
+ *
2520
+ * @return {Object} data
2521
+ */
2522
+ getImageData: function () {
2523
+ return this.isLoaded ? this.image : {};
2524
+ },
2525
+
2526
+ /**
2527
+ * Get the canvas position and size data
2528
+ *
2529
+ * @return {Object} data
2530
+ */
2531
+ getCanvasData: function () {
2532
+ var canvas = this.canvas;
2533
+ var data = {};
2534
+
2535
+ if (this.isBuilt) {
2536
+ $.each([
2537
+ 'left',
2538
+ 'top',
2539
+ 'width',
2540
+ 'height',
2541
+ 'naturalWidth',
2542
+ 'naturalHeight'
2543
+ ], function (i, n) {
2544
+ data[n] = canvas[n];
2545
+ });
2546
+ }
2547
+
2548
+ return data;
2549
+ },
2550
+
2551
+ /**
2552
+ * Set the canvas position and size with new data
2553
+ *
2554
+ * @param {Object} data
2555
+ */
2556
+ setCanvasData: function (data) {
2557
+ var canvas = this.canvas;
2558
+ var aspectRatio = canvas.aspectRatio;
2559
+
2560
+ if ($.isFunction(data)) {
2561
+ data = data.call(this.$element);
2562
+ }
2563
+
2564
+ if (this.isBuilt && !this.isDisabled && $.isPlainObject(data)) {
2565
+ if (isNumber(data.left)) {
2566
+ canvas.left = data.left;
2567
+ }
2568
+
2569
+ if (isNumber(data.top)) {
2570
+ canvas.top = data.top;
2571
+ }
2572
+
2573
+ if (isNumber(data.width)) {
2574
+ canvas.width = data.width;
2575
+ canvas.height = data.width / aspectRatio;
2576
+ } else if (isNumber(data.height)) {
2577
+ canvas.height = data.height;
2578
+ canvas.width = data.height * aspectRatio;
2579
+ }
2580
+
2581
+ this.renderCanvas(true);
2582
+ }
2583
+ },
2584
+
2585
+ /**
2586
+ * Get the crop box position and size data
2587
+ *
2588
+ * @return {Object} data
2589
+ */
2590
+ getCropBoxData: function () {
2591
+ var cropBox = this.cropBox;
2592
+ var data;
2593
+
2594
+ if (this.isBuilt && this.isCropped) {
2595
+ data = {
2596
+ left: cropBox.left,
2597
+ top: cropBox.top,
2598
+ width: cropBox.width,
2599
+ height: cropBox.height
2600
+ };
2601
+ }
2602
+
2603
+ return data || {};
2604
+ },
2605
+
2606
+ /**
2607
+ * Set the crop box position and size with new data
2608
+ *
2609
+ * @param {Object} data
2610
+ */
2611
+ setCropBoxData: function (data) {
2612
+ var cropBox = this.cropBox;
2613
+ var aspectRatio = this.options.aspectRatio;
2614
+ var isWidthChanged;
2615
+ var isHeightChanged;
2616
+
2617
+ if ($.isFunction(data)) {
2618
+ data = data.call(this.$element);
2619
+ }
2620
+
2621
+ if (this.isBuilt && this.isCropped && !this.isDisabled && $.isPlainObject(data)) {
2622
+
2623
+ if (isNumber(data.left)) {
2624
+ cropBox.left = data.left;
2625
+ }
2626
+
2627
+ if (isNumber(data.top)) {
2628
+ cropBox.top = data.top;
2629
+ }
2630
+
2631
+ if (isNumber(data.width)) {
2632
+ isWidthChanged = true;
2633
+ cropBox.width = data.width;
2634
+ }
2635
+
2636
+ if (isNumber(data.height)) {
2637
+ isHeightChanged = true;
2638
+ cropBox.height = data.height;
2639
+ }
2640
+
2641
+ if (aspectRatio) {
2642
+ if (isWidthChanged) {
2643
+ cropBox.height = cropBox.width / aspectRatio;
2644
+ } else if (isHeightChanged) {
2645
+ cropBox.width = cropBox.height * aspectRatio;
2646
+ }
2647
+ }
2648
+
2649
+ this.renderCropBox();
2650
+ }
2651
+ },
2652
+
2653
+ /**
2654
+ * Get a canvas drawn the cropped image
2655
+ *
2656
+ * @param {Object} options (optional)
2657
+ * @return {HTMLCanvasElement} canvas
2658
+ */
2659
+ getCroppedCanvas: function (options) {
2660
+ var originalWidth;
2661
+ var originalHeight;
2662
+ var canvasWidth;
2663
+ var canvasHeight;
2664
+ var scaledWidth;
2665
+ var scaledHeight;
2666
+ var scaledRatio;
2667
+ var aspectRatio;
2668
+ var canvas;
2669
+ var context;
2670
+ var data;
2671
+
2672
+ if (!this.isBuilt || !SUPPORT_CANVAS) {
2673
+ return;
2674
+ }
2675
+
2676
+ if (!this.isCropped) {
2677
+ return getSourceCanvas(this.$clone[0], this.image);
2678
+ }
2679
+
2680
+ if (!$.isPlainObject(options)) {
2681
+ options = {};
2682
+ }
2683
+
2684
+ data = this.getData();
2685
+ originalWidth = data.width;
2686
+ originalHeight = data.height;
2687
+ aspectRatio = originalWidth / originalHeight;
2688
+
2689
+ if ($.isPlainObject(options)) {
2690
+ scaledWidth = options.width;
2691
+ scaledHeight = options.height;
2692
+ if(scaledWidth && scaledHeight){
2693
+ scaledRatio = scaledWidth / originalWidth;
2694
+ }else if (scaledWidth) {
2695
+ scaledHeight = scaledWidth / aspectRatio;
2696
+ scaledRatio = scaledWidth / originalWidth;
2697
+ } else if (scaledHeight) {
2698
+ scaledWidth = scaledHeight * aspectRatio;
2699
+ scaledRatio = scaledHeight / originalHeight;
2700
+ }
2701
+ }
2702
+
2703
+ // The canvas element will use `Math.floor` on a float number, so floor first
2704
+ canvasWidth = floor(scaledWidth || originalWidth);
2705
+ canvasHeight = floor(scaledHeight || originalHeight);
2706
+
2707
+ canvas = $('<canvas>')[0];
2708
+ canvas.width = canvasWidth;
2709
+ canvas.height = canvasHeight;
2710
+ context = canvas.getContext('2d');
2711
+ if (options.fillColor) {
2712
+ context.fillStyle = options.fillColor;
2713
+ context.fillRect(0, 0, canvasWidth, canvasHeight);
2714
+ }
2715
+
2716
+ // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.drawImage
2717
+ context.drawImage.apply(context, (function () {
2718
+ var source = getSourceCanvas(this.$clone[0], this.image);
2719
+ var sourceWidth = source.width;
2720
+ var sourceHeight = source.height;
2721
+ var canvas = this.canvas;
2722
+ var params = [source];
2723
+
2724
+ // Source canvas
2725
+ var srcX = data.x + canvas.naturalWidth * (abs(data.scaleX || 1) - 1) / 2;
2726
+ var srcY = data.y + canvas.naturalHeight * (abs(data.scaleY || 1) - 1) / 2;
2727
+ var srcWidth;
2728
+ var srcHeight;
2729
+
2730
+ // Destination canvas
2731
+ var dstX;
2732
+ var dstY;
2733
+ var dstWidth;
2734
+ var dstHeight;
2735
+
2736
+ if (srcX <= -originalWidth || srcX > sourceWidth) {
2737
+ srcX = srcWidth = dstX = dstWidth = 0;
2738
+ } else if (srcX <= 0) {
2739
+ dstX = -srcX;
2740
+ srcX = 0;
2741
+ srcWidth = dstWidth = min(sourceWidth, originalWidth + srcX);
2742
+ } else if (srcX <= sourceWidth) {
2743
+ dstX = 0;
2744
+ srcWidth = dstWidth = min(originalWidth, sourceWidth - srcX);
2745
+ }
2746
+
2747
+ if (srcWidth <= 0 || srcY <= -originalHeight || srcY > sourceHeight) {
2748
+ srcY = srcHeight = dstY = dstHeight = 0;
2749
+ } else if (srcY <= 0) {
2750
+ dstY = -srcY;
2751
+ srcY = 0;
2752
+ srcHeight = dstHeight = min(sourceHeight, originalHeight + srcY);
2753
+ } else if (srcY <= sourceHeight) {
2754
+ dstY = 0;
2755
+ srcHeight = dstHeight = min(originalHeight, sourceHeight - srcY);
2756
+ }
2757
+
2758
+ // All the numerical parameters should be integer for `drawImage` (#476)
2759
+ params.push(floor(srcX), floor(srcY), floor(srcWidth), floor(srcHeight));
2760
+
2761
+ // Scale destination sizes
2762
+ if (scaledRatio) {
2763
+ dstX *= scaledRatio;
2764
+ dstY *= scaledRatio;
2765
+ dstWidth *= scaledRatio;
2766
+ dstHeight *= scaledRatio;
2767
+ }
2768
+
2769
+ // Avoid "IndexSizeError" in IE and Firefox
2770
+ if (dstWidth > 0 && dstHeight > 0) {
2771
+ params.push(floor(dstX), floor(dstY), floor(dstWidth), floor(dstHeight));
2772
+ }
2773
+ return params;
2774
+ }).call(this));
2775
+ return canvas;
2776
+ },
2777
+
2778
+ /**
2779
+ * Change the aspect ratio of the crop box
2780
+ *
2781
+ * @param {Number} aspectRatio
2782
+ */
2783
+ setAspectRatio: function (aspectRatio) {
2784
+ var options = this.options;
2785
+
2786
+ if (!this.isDisabled && !isUndefined(aspectRatio)) {
2787
+
2788
+ // 0 -> NaN
2789
+ options.aspectRatio = max(0, aspectRatio) || NaN;
2790
+
2791
+ if (this.isBuilt) {
2792
+ this.initCropBox();
2793
+
2794
+ if (this.isCropped) {
2795
+ this.renderCropBox();
2796
+ }
2797
+ }
2798
+ }
2799
+ },
2800
+
2801
+ /**
2802
+ * Change the drag mode
2803
+ *
2804
+ * @param {String} mode (optional)
2805
+ */
2806
+ setDragMode: function (mode) {
2807
+ var options = this.options;
2808
+ var croppable;
2809
+ var movable;
2810
+
2811
+ if (this.isLoaded && !this.isDisabled) {
2812
+ croppable = mode === ACTION_CROP;
2813
+ movable = options.movable && mode === ACTION_MOVE;
2814
+ mode = (croppable || movable) ? mode : ACTION_NONE;
2815
+
2816
+ this.$dragBox.
2817
+ data(DATA_ACTION, mode).
2818
+ toggleClass(CLASS_CROP, croppable).
2819
+ toggleClass(CLASS_MOVE, movable);
2820
+
2821
+ if (!options.cropBoxMovable) {
2822
+
2823
+ // Sync drag mode to crop box when it is not movable(#300)
2824
+ this.$face.
2825
+ data(DATA_ACTION, mode).
2826
+ toggleClass(CLASS_CROP, croppable).
2827
+ toggleClass(CLASS_MOVE, movable);
2828
+ }
2829
+ }
2830
+ }
2831
+ };
2832
+
2833
+ Cropper.DEFAULTS = {
2834
+
2835
+ // Define the view mode of the cropper
2836
+ viewMode: 0, // 0, 1, 2, 3
2837
+
2838
+ // Define the dragging mode of the cropper
2839
+ dragMode: 'crop', // 'crop', 'move' or 'none'
2840
+
2841
+ // Define the aspect ratio of the crop box
2842
+ aspectRatio: NaN,
2843
+
2844
+ // An object with the previous cropping result data
2845
+ data: null,
2846
+
2847
+ // A jQuery selector for adding extra containers to preview
2848
+ preview: '',
2849
+
2850
+ // Re-render the cropper when resize the window
2851
+ responsive: true,
2852
+
2853
+ // Restore the cropped area after resize the window
2854
+ restore: true,
2855
+
2856
+ // Check if the current image is a cross-origin image
2857
+ checkCrossOrigin: true,
2858
+
2859
+ // Check the current image's Exif Orientation information
2860
+ checkOrientation: true,
2861
+
2862
+ // Show the black modal
2863
+ modal: true,
2864
+
2865
+ // Show the dashed lines for guiding
2866
+ guides: true,
2867
+
2868
+ // Show the center indicator for guiding
2869
+ center: true,
2870
+
2871
+ // Show the white modal to highlight the crop box
2872
+ highlight: true,
2873
+
2874
+ // Show the grid background
2875
+ background: true,
2876
+
2877
+ // Enable to crop the image automatically when initialize
2878
+ autoCrop: true,
2879
+
2880
+ // Define the percentage of automatic cropping area when initializes
2881
+ autoCropArea: 0.8,
2882
+
2883
+ // Enable to move the image
2884
+ movable: true,
2885
+
2886
+ // Enable to rotate the image
2887
+ rotatable: true,
2888
+
2889
+ // Enable to scale the image
2890
+ scalable: true,
2891
+
2892
+ // Enable to zoom the image
2893
+ zoomable: true,
2894
+
2895
+ // Enable to zoom the image by dragging touch
2896
+ zoomOnTouch: true,
2897
+
2898
+ // Enable to zoom the image by wheeling mouse
2899
+ zoomOnWheel: true,
2900
+
2901
+ // Define zoom ratio when zoom the image by wheeling mouse
2902
+ wheelZoomRatio: 0.1,
2903
+
2904
+ // Enable to move the crop box
2905
+ cropBoxMovable: true,
2906
+
2907
+ // Enable to resize the crop box
2908
+ cropBoxResizable: true,
2909
+
2910
+ // Toggle drag mode between "crop" and "move" when click twice on the cropper
2911
+ toggleDragModeOnDblclick: true,
2912
+
2913
+ // Size limitation
2914
+ minCanvasWidth: 0,
2915
+ minCanvasHeight: 0,
2916
+ minCropBoxWidth: 0,
2917
+ minCropBoxHeight: 0,
2918
+ minContainerWidth: 200,
2919
+ minContainerHeight: 100,
2920
+
2921
+ // Shortcuts of events
2922
+ build: null,
2923
+ built: null,
2924
+ cropstart: null,
2925
+ cropmove: null,
2926
+ cropend: null,
2927
+ crop: null,
2928
+ zoom: null
2929
+ };
2930
+
2931
+ Cropper.setDefaults = function (options) {
2932
+ $.extend(Cropper.DEFAULTS, options);
2933
+ };
2934
+
2935
+ Cropper.TEMPLATE = (
2936
+ '<div class="cropper-container">' +
2937
+ '<div class="cropper-wrap-box">' +
2938
+ '<div class="cropper-canvas"></div>' +
2939
+ '</div>' +
2940
+ '<div class="cropper-drag-box"></div>' +
2941
+ '<div class="cropper-crop-box">' +
2942
+ '<span class="cropper-view-box"></span>' +
2943
+ '<span class="cropper-dashed dashed-h"></span>' +
2944
+ '<span class="cropper-dashed dashed-v"></span>' +
2945
+ '<span class="cropper-center"></span>' +
2946
+ '<span class="cropper-face"></span>' +
2947
+ '<span class="cropper-line line-e" data-action="e"></span>' +
2948
+ '<span class="cropper-line line-n" data-action="n"></span>' +
2949
+ '<span class="cropper-line line-w" data-action="w"></span>' +
2950
+ '<span class="cropper-line line-s" data-action="s"></span>' +
2951
+ '<span class="cropper-point point-e" data-action="e"></span>' +
2952
+ '<span class="cropper-point point-n" data-action="n"></span>' +
2953
+ '<span class="cropper-point point-w" data-action="w"></span>' +
2954
+ '<span class="cropper-point point-s" data-action="s"></span>' +
2955
+ '<span class="cropper-point point-ne" data-action="ne"></span>' +
2956
+ '<span class="cropper-point point-nw" data-action="nw"></span>' +
2957
+ '<span class="cropper-point point-sw" data-action="sw"></span>' +
2958
+ '<span class="cropper-point point-se" data-action="se"></span>' +
2959
+ '</div>' +
2960
+ '</div>'
2961
+ );
2962
+
2963
+ // Save the other cropper
2964
+ Cropper.other = $.fn.cropper;
2965
+
2966
+ // Register as jQuery plugin
2967
+ $.fn.cropper = function (option) {
2968
+ var args = toArray(arguments, 1);
2969
+ var result;
2970
+
2971
+ this.each(function () {
2972
+ var $this = $(this);
2973
+ var data = $this.data(NAMESPACE);
2974
+ var options;
2975
+ var fn;
2976
+
2977
+ if (!data) {
2978
+ if (/destroy/.test(option)) {
2979
+ return;
2980
+ }
2981
+
2982
+ options = $.extend({}, $this.data(), $.isPlainObject(option) && option);
2983
+ $this.data(NAMESPACE, (data = new Cropper(this, options)));
2984
+ }
2985
+
2986
+ if (typeof option === 'string' && $.isFunction(fn = data[option])) {
2987
+ result = fn.apply(data, args);
2988
+ }
2989
+ });
2990
+
2991
+ return isUndefined(result) ? this : result;
2992
+ };
2993
+
2994
+ $.fn.cropper.Constructor = Cropper;
2995
+ $.fn.cropper.setDefaults = Cropper.setDefaults;
2996
+
2997
+ // No conflict
2998
+ $.fn.cropper.noConflict = function () {
2999
+ $.fn.cropper = Cropper.other;
3000
+ return this;
3001
+ };
3002
+
3003
+ });