active_admin_jcrop 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_admin_jcrop/version.rb +1 -1
  3. data/{test → spec}/dummy/README.rdoc +0 -0
  4. data/{test → spec}/dummy/Rakefile +0 -0
  5. data/{test → spec}/dummy/app/admin/dashboard.rb +0 -0
  6. data/{test → spec}/dummy/app/admin/post.rb +0 -0
  7. data/{test → spec}/dummy/app/assets/javascripts/active_admin.js.coffee +0 -0
  8. data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
  9. data/{test → spec}/dummy/app/assets/stylesheets/active_admin.css.scss +0 -0
  10. data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
  11. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  12. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  13. data/{test → spec}/dummy/app/models/post.rb +0 -0
  14. data/{test → spec}/dummy/app/uploaders/image_uploader.rb +0 -0
  15. data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
  16. data/{test → spec}/dummy/bin/bundle +0 -0
  17. data/{test → spec}/dummy/bin/rails +0 -0
  18. data/{test → spec}/dummy/bin/rake +0 -0
  19. data/{test → spec}/dummy/config.ru +0 -0
  20. data/{test → spec}/dummy/config/application.rb +2 -2
  21. data/{test → spec}/dummy/config/boot.rb +1 -1
  22. data/{test → spec}/dummy/config/database.yml +0 -0
  23. data/{test → spec}/dummy/config/environment.rb +0 -0
  24. data/{test → spec}/dummy/config/environments/development.rb +0 -0
  25. data/{test → spec}/dummy/config/environments/production.rb +0 -0
  26. data/{test → spec}/dummy/config/environments/test.rb +10 -3
  27. data/{test → spec}/dummy/config/initializers/active_admin.rb +2 -2
  28. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  29. data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
  30. data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  31. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  32. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  33. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  34. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  35. data/{test → spec}/dummy/config/locales/devise.en.yml +0 -0
  36. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  37. data/{test → spec}/dummy/config/routes.rb +4 -2
  38. data/{test → spec}/dummy/config/secrets.yml +0 -0
  39. data/{test → spec}/dummy/db/migrate/20140609195344_create_posts.rb +0 -0
  40. data/{test → spec}/dummy/db/migrate/20140609200814_create_active_admin_comments.rb +0 -0
  41. data/{test → spec}/dummy/db/migrate/20140609202215_devise_create_admin_users.rb +1 -1
  42. data/spec/dummy/db/migrate/20140619201236_drop_admin_user_table.rb +5 -0
  43. data/{test → spec}/dummy/db/schema.rb +1 -19
  44. data/{test → spec}/dummy/log/development.log +3403 -0
  45. data/spec/dummy/log/test.log +3948 -0
  46. data/{test → spec}/dummy/public/404.html +0 -0
  47. data/{test → spec}/dummy/public/422.html +0 -0
  48. data/{test → spec}/dummy/public/500.html +0 -0
  49. data/{test → spec}/dummy/public/favicon.ico +0 -0
  50. data/{test → spec}/dummy/public/uploads/post/image/1/caminhao.jpeg +0 -0
  51. data/spec/dummy/public/uploads/post/image/1/thumb_caminhao.jpeg +0 -0
  52. data/{test → spec}/dummy/public/uploads/tmp/1402854070-53359-7950/caminhao.jpeg +0 -0
  53. data/{test → spec}/dummy/public/uploads/tmp/1402854070-53359-7950/thumb_caminhao.jpeg +0 -0
  54. data/{test → spec}/dummy/public/uploads/tmp/1402854510-53557-6949/caminhao.jpeg +0 -0
  55. data/{test → spec}/dummy/public/uploads/tmp/1402854510-53557-6949/thumb_caminhao.jpeg +0 -0
  56. data/{test → spec}/dummy/public/uploads/tmp/1402854728-53655-1717/caminhao.jpeg +0 -0
  57. data/{test → spec}/dummy/public/uploads/tmp/1402854728-53655-1717/thumb_caminhao.jpeg +0 -0
  58. data/{test → spec}/dummy/public/uploads/tmp/1402855138-53797-0268/caminhao.jpeg +0 -0
  59. data/{test → spec}/dummy/public/uploads/tmp/1402855138-53797-0268/thumb_caminhao.jpeg +0 -0
  60. data/{test → spec}/dummy/public/uploads/tmp/1402856174-54150-2897/caminhao.jpeg +0 -0
  61. data/{test → spec}/dummy/public/uploads/tmp/1402856174-54150-2897/thumb_caminhao.jpeg +0 -0
  62. data/{test → spec}/dummy/public/uploads/tmp/1402856561-54391-5701/caminhao.jpeg +0 -0
  63. data/{test → spec}/dummy/public/uploads/tmp/1402856561-54391-5701/thumb_caminhao.jpeg +0 -0
  64. data/{test → spec}/dummy/public/uploads/tmp/1402884860-59723-5663/caminhao.jpeg +0 -0
  65. data/{test → spec}/dummy/public/uploads/tmp/1402884860-59723-5663/thumb_caminhao.jpeg +0 -0
  66. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/01cc28ef6cf61e838f8df3854de4e76b +0 -0
  67. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/04815176b18d23ced953077cdab6c799 +0 -0
  68. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/05329eaf5e8ad8c55f7356cd6f1a208d +0 -0
  69. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/09b3ba6de4c7b276240b56d755d22193 +0 -0
  70. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/0c410be62a5a11fa5bd31553203370c9 +0 -0
  71. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/11666820d5c80bd008d64048ad423cf2 +0 -0
  72. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/153271d97599450d4419ff64c0096e7a +0 -0
  73. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/198ca7c8448aa0272e8b33c7c8f7f85b +0 -0
  74. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/1c328d420a3818d37452e98c6001b467 +0 -0
  75. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/1ce4a7570f4520b8014c358d0e417201 +0 -0
  76. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/1d7d77c0ef36a03c1a532428dc56fb43 +0 -0
  77. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/1e7ffade48952c7cdfc8672bad4eb410 +0 -0
  78. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/2469f5828ec5a821a8e3a1fa52f62ecc +0 -0
  79. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/280b1fab7672e0fd9bb4f1578ca14a9c +0 -0
  80. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/2894eb75de440448b3c40d69d7c3daf1 +0 -0
  81. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/2de35a92daa792d65be049f319e98640 +0 -0
  82. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/2e6efe9c42b17ddcbc206cb7029a6435 +0 -0
  83. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/37ac2b1140ba52b9c49281dfaaeb0a5c +0 -0
  84. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/39d5b668acdaf4ac39dfbec7998c6088 +0 -0
  85. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/3dbddfc04cc1ce845cea75a5d053eb78 +0 -0
  86. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/3f8d2b3750a2c4a35e2fc80119be599b +0 -0
  87. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/4168e815a6e3b7f527bae1357a3b4a88 +0 -0
  88. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/42599e7e19d0844f558bf6755147af8a +0 -0
  89. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/43f5bd66cd4b99ca8a25a3a3585dc10f +0 -0
  90. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/4806b0909dd0f9ef46c0f8529c16d0cb +0 -0
  91. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/49366e6a8a305846f3b6e35412b622be +0 -0
  92. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/4abf4453141fa8280d3e92b9d6f95893 +0 -0
  93. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/4e10e25ed23161425328c0e86fd2d964 +0 -0
  94. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/4f3ac0b41fcb58bba41dd8990f521960 +0 -0
  95. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/50868216b236752b04eac5d3ee00f04c +0 -0
  96. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/517db557c9ab037fe61fcc4135e67a97 +0 -0
  97. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/51a626ab0064c74348ca0076f2464081 +0 -0
  98. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/5248fc2c7af1008d55cc8c390c5aadfd +0 -0
  99. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/52ec38bf0b8162c3a0b60334179fd9d8 +0 -0
  100. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/542ba2c861120c117755b256e75fc931 +0 -0
  101. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/58242bae329210944c12eef4b21e74fc +0 -0
  102. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/586f47ea7b97a5a0c2864cafc7fa681a +0 -0
  103. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/59f28a7fdd955b2eb441b3ede79d6634 +0 -0
  104. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/5e5c38446431a684f7d95b931dd29845 +0 -0
  105. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/5e978a23006b9bf0e8cb8e01af6b830e +0 -0
  106. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/63f0e112cc9f52fcc19a660011424d4d +0 -0
  107. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/63f701be894a406a83f338a15dbbff5b +0 -0
  108. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/66ecbfb3aaaec21a5dd4da1c53b09474 +0 -0
  109. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/6e600d6b6e57393c380d4f34b7e462c1 +0 -0
  110. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/7058e63d0f91885601240f901d028889 +0 -0
  111. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/7863b5114d0b7761ee50ab47927118ee +0 -0
  112. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/79a9f34b9b567a41a3c023f6c31b6251 +0 -0
  113. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/7aa6ca65af176c54e4e7c93c8eee5a7f +0 -0
  114. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/7f8b2599f8306c1dc7d1e3e5b9deded8 +0 -0
  115. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/81dd6767e418fdc1ab0263c94cd79d8b +0 -0
  116. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8247e64103aa55a761ab0f354ff45c16 +0 -0
  117. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/82a4b11f94b10449d88fc04cf6df3a18 +0 -0
  118. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/82a8bc708c97f88caaf13018bf6b279d +0 -0
  119. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/83054e22209abf270f4394486dd2629b +0 -0
  120. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/833571bbb8aac2c2d7ead0bb6c360747 +0 -0
  121. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8546b8d3c7ef5ea3e50ac4a872f661cb +0 -0
  122. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/857ecd2092cee11f740b3cf2e373ad2a +0 -0
  123. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8636ac646366920af1a3b008b51ceed1 +0 -0
  124. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/86a0e6da188e8b595d42390ae7c686d9 +0 -0
  125. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/870b072c21a14943e77df52a2cda1b73 +0 -0
  126. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8811d2e446647a23d3edf4b867ad0c02 +0 -0
  127. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/88197c7050fe981f868afc887b2ce0ba +0 -0
  128. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/887d9abab3188ec82c44b8c157617ca7 +0 -0
  129. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/88887cda2e4b689f7b1af350c003d0d2 +0 -0
  130. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/88b9d244297285b4704261b08355377c +0 -0
  131. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8a7d09231ebe79adabff0fbb009fea25 +0 -0
  132. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8a88e7d4780f75cec7a24872a705b76b +0 -0
  133. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8bd0b3620014ec125304f9605c337077 +0 -0
  134. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8d39cc657ceec60e0d5ea1fa37e5e1a0 +0 -0
  135. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/8f2e727a35967938c7f3368ad0e1fd17 +0 -0
  136. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/9181c05dfda585ad6bf9ddb219eb15a1 +0 -0
  137. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/921e258c04378d5f0ecf0f3ee547195e +0 -0
  138. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/95682c5bcf707ffdac00772b90de8e9d +0 -0
  139. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/963d3f2d23c24941fe0b9c0231b8849d +0 -0
  140. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/99f0365331f36952dca860bcc6e8fd4a +0 -0
  141. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/9b9cde87d5e9f732acdc4fb18077c71d +0 -0
  142. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/9ba436ceb3644f8f052f05eeff94a880 +0 -0
  143. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/9f495611485125fd9772059d732fd3ec +0 -0
  144. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/a60a6f908e1d257971c558b8c6db7ae5 +0 -0
  145. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/a6b936ad9b28fb786d3135a007e5d5b8 +0 -0
  146. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/a6eedf5e824ca04685c9da227f406b8f +0 -0
  147. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/a759d4068225951d142110473dd6c8b3 +0 -0
  148. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/aae43c2efd29f832dccb299bfa566e44 +0 -0
  149. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/abafd28d094dec608d1a73ec02e75c34 +0 -0
  150. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/ae3ffb8f5a8c49bb8253a13ef5d1d2a4 +0 -0
  151. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/af888b78046ad78708407984ecb3c8a6 +0 -0
  152. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/b09cd2d5bea8a15151b6022c038dda5c +0 -0
  153. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/b461b3c64042d0c6dbaf73e92275300e +0 -0
  154. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/b4948b52a9f8e7cdd8a77902409545c0 +0 -0
  155. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/c1de6e9cb5f12e4481b52b1cf8d38d31 +0 -0
  156. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/c6698cd7d2263b8d2095648c2ac0fe79 +0 -0
  157. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/c72957ff133a3fd942c3ab9960d1d423 +0 -0
  158. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/c8c8162f2a41f8578ba98c9a1f37e46b +0 -0
  159. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/c962852af3d1e3dc670690c90a7b070e +0 -0
  160. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/ca13fe06919030ff6b989ec199d70a44 +0 -0
  161. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/cb1fc3f2ce1b7f41695e590c097b311b +0 -0
  162. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/cc6dcaa815625d7d4b57e3972e144bda +0 -0
  163. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/ccbc9b9b1eb80fbb7865bc756ce55b87 +0 -0
  164. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/ce5e8cfd00d9fb6c6fde000c5e03662d +0 -0
  165. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/cfc55116cc6269b60cf1be77557f0fa0 +0 -0
  166. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/d295569fa361346a1980638387ef138b +0 -0
  167. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/d46eab415cde36a1cf5eace3991cf63a +0 -0
  168. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/d7e88e6d648deff48df25b735ddc1826 +0 -0
  169. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/db631d9298c9a2f7e02011d47fd3ccca +0 -0
  170. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/e1f04589fe51a214b3d97f4b9d693db2 +0 -0
  171. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/e41a3d9a4ba0bd341c8da19fb9e53cca +0 -0
  172. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/e574af4ac554c85b5795e56916e5264e +0 -0
  173. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/e641d229c53e2926a5ed4ab6ce79eada +0 -0
  174. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/e73b7841ac8e835c29aeb4fc4bf27e40 +0 -0
  175. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/e88a13629d2c3498c801d061a01f6bf1 +0 -0
  176. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/ed9f0de1b65ae8d7ef89087c83728461 +0 -0
  177. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f0f4cedded536278ec7f580408e6e60f +0 -0
  178. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f156de297b7d2034db1844f92f4f92ba +0 -0
  179. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f2f4ef8251bfbaced240dfbd93538a90 +0 -0
  180. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f655e2d083e4e5fc8b2c6a8064178998 +0 -0
  181. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f6667183705babbc5a9efea96e26953b +0 -0
  182. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f669eeb6c0059dbcab647979cad28c4b +0 -0
  183. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/f985e5d99fd0dcf330b2a243b63c71f8 +0 -0
  184. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/fa4cfa52c2f50e31e33e69d54e6694dc +0 -0
  185. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/fb8b186d5bf0307f86f65fc787d2adeb +0 -0
  186. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/fd2f0ae1c70d86cc45823b51d707e220 +0 -0
  187. data/{test → spec}/dummy/tmp/cache/assets/development/sprockets/ff328cfd9b51b215b0db24b8bb3c63f4 +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/01cc28ef6cf61e838f8df3854de4e76b +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/04815176b18d23ced953077cdab6c799 +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/05329eaf5e8ad8c55f7356cd6f1a208d +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/09b3ba6de4c7b276240b56d755d22193 +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/0c410be62a5a11fa5bd31553203370c9 +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/11666820d5c80bd008d64048ad423cf2 +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/153271d97599450d4419ff64c0096e7a +0 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/198ca7c8448aa0272e8b33c7c8f7f85b +0 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/1c328d420a3818d37452e98c6001b467 +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/1ce4a7570f4520b8014c358d0e417201 +0 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/1d7d77c0ef36a03c1a532428dc56fb43 +0 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/2469f5828ec5a821a8e3a1fa52f62ecc +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/280b1fab7672e0fd9bb4f1578ca14a9c +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/2894eb75de440448b3c40d69d7c3daf1 +0 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/2de35a92daa792d65be049f319e98640 +0 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/2e6efe9c42b17ddcbc206cb7029a6435 +0 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/37ac2b1140ba52b9c49281dfaaeb0a5c +0 -0
  205. data/spec/dummy/tmp/cache/assets/test/sprockets/39d5b668acdaf4ac39dfbec7998c6088 +0 -0
  206. data/spec/dummy/tmp/cache/assets/test/sprockets/3dbddfc04cc1ce845cea75a5d053eb78 +0 -0
  207. data/spec/dummy/tmp/cache/assets/test/sprockets/3f8d2b3750a2c4a35e2fc80119be599b +0 -0
  208. data/spec/dummy/tmp/cache/assets/test/sprockets/42599e7e19d0844f558bf6755147af8a +0 -0
  209. data/spec/dummy/tmp/cache/assets/test/sprockets/43f5bd66cd4b99ca8a25a3a3585dc10f +0 -0
  210. data/spec/dummy/tmp/cache/assets/test/sprockets/4806b0909dd0f9ef46c0f8529c16d0cb +0 -0
  211. data/spec/dummy/tmp/cache/assets/test/sprockets/49366e6a8a305846f3b6e35412b622be +0 -0
  212. data/spec/dummy/tmp/cache/assets/test/sprockets/4abf4453141fa8280d3e92b9d6f95893 +0 -0
  213. data/spec/dummy/tmp/cache/assets/test/sprockets/4e10e25ed23161425328c0e86fd2d964 +0 -0
  214. data/spec/dummy/tmp/cache/assets/test/sprockets/4f3ac0b41fcb58bba41dd8990f521960 +0 -0
  215. data/spec/dummy/tmp/cache/assets/test/sprockets/50868216b236752b04eac5d3ee00f04c +0 -0
  216. data/spec/dummy/tmp/cache/assets/test/sprockets/517db557c9ab037fe61fcc4135e67a97 +0 -0
  217. data/spec/dummy/tmp/cache/assets/test/sprockets/51a626ab0064c74348ca0076f2464081 +0 -0
  218. data/spec/dummy/tmp/cache/assets/test/sprockets/5248fc2c7af1008d55cc8c390c5aadfd +0 -0
  219. data/spec/dummy/tmp/cache/assets/test/sprockets/52ec38bf0b8162c3a0b60334179fd9d8 +0 -0
  220. data/spec/dummy/tmp/cache/assets/test/sprockets/542ba2c861120c117755b256e75fc931 +0 -0
  221. data/spec/dummy/tmp/cache/assets/test/sprockets/58242bae329210944c12eef4b21e74fc +0 -0
  222. data/spec/dummy/tmp/cache/assets/test/sprockets/586f47ea7b97a5a0c2864cafc7fa681a +0 -0
  223. data/spec/dummy/tmp/cache/assets/test/sprockets/59f28a7fdd955b2eb441b3ede79d6634 +0 -0
  224. data/spec/dummy/tmp/cache/assets/test/sprockets/5e5c38446431a684f7d95b931dd29845 +0 -0
  225. data/spec/dummy/tmp/cache/assets/test/sprockets/5e978a23006b9bf0e8cb8e01af6b830e +0 -0
  226. data/spec/dummy/tmp/cache/assets/test/sprockets/63f0e112cc9f52fcc19a660011424d4d +0 -0
  227. data/spec/dummy/tmp/cache/assets/test/sprockets/63f701be894a406a83f338a15dbbff5b +0 -0
  228. data/spec/dummy/tmp/cache/assets/test/sprockets/66ecbfb3aaaec21a5dd4da1c53b09474 +0 -0
  229. data/spec/dummy/tmp/cache/assets/test/sprockets/6e600d6b6e57393c380d4f34b7e462c1 +0 -0
  230. data/spec/dummy/tmp/cache/assets/test/sprockets/7058e63d0f91885601240f901d028889 +0 -0
  231. data/spec/dummy/tmp/cache/assets/test/sprockets/7863b5114d0b7761ee50ab47927118ee +0 -0
  232. data/spec/dummy/tmp/cache/assets/test/sprockets/79a9f34b9b567a41a3c023f6c31b6251 +0 -0
  233. data/spec/dummy/tmp/cache/assets/test/sprockets/7aa6ca65af176c54e4e7c93c8eee5a7f +0 -0
  234. data/spec/dummy/tmp/cache/assets/test/sprockets/7f8b2599f8306c1dc7d1e3e5b9deded8 +0 -0
  235. data/spec/dummy/tmp/cache/assets/test/sprockets/81dd6767e418fdc1ab0263c94cd79d8b +0 -0
  236. data/spec/dummy/tmp/cache/assets/test/sprockets/8247e64103aa55a761ab0f354ff45c16 +0 -0
  237. data/spec/dummy/tmp/cache/assets/test/sprockets/82a8bc708c97f88caaf13018bf6b279d +0 -0
  238. data/spec/dummy/tmp/cache/assets/test/sprockets/83054e22209abf270f4394486dd2629b +0 -0
  239. data/spec/dummy/tmp/cache/assets/test/sprockets/833571bbb8aac2c2d7ead0bb6c360747 +0 -0
  240. data/spec/dummy/tmp/cache/assets/test/sprockets/8546b8d3c7ef5ea3e50ac4a872f661cb +0 -0
  241. data/spec/dummy/tmp/cache/assets/test/sprockets/857ecd2092cee11f740b3cf2e373ad2a +0 -0
  242. data/spec/dummy/tmp/cache/assets/test/sprockets/8636ac646366920af1a3b008b51ceed1 +0 -0
  243. data/spec/dummy/tmp/cache/assets/test/sprockets/870b072c21a14943e77df52a2cda1b73 +0 -0
  244. data/spec/dummy/tmp/cache/assets/test/sprockets/8811d2e446647a23d3edf4b867ad0c02 +0 -0
  245. data/spec/dummy/tmp/cache/assets/test/sprockets/88197c7050fe981f868afc887b2ce0ba +0 -0
  246. data/spec/dummy/tmp/cache/assets/test/sprockets/887d9abab3188ec82c44b8c157617ca7 +0 -0
  247. data/spec/dummy/tmp/cache/assets/test/sprockets/88887cda2e4b689f7b1af350c003d0d2 +0 -0
  248. data/spec/dummy/tmp/cache/assets/test/sprockets/88b9d244297285b4704261b08355377c +0 -0
  249. data/spec/dummy/tmp/cache/assets/test/sprockets/8a7d09231ebe79adabff0fbb009fea25 +0 -0
  250. data/spec/dummy/tmp/cache/assets/test/sprockets/8a88e7d4780f75cec7a24872a705b76b +0 -0
  251. data/spec/dummy/tmp/cache/assets/test/sprockets/8bd0b3620014ec125304f9605c337077 +0 -0
  252. data/spec/dummy/tmp/cache/assets/test/sprockets/8d39cc657ceec60e0d5ea1fa37e5e1a0 +0 -0
  253. data/spec/dummy/tmp/cache/assets/test/sprockets/8f2e727a35967938c7f3368ad0e1fd17 +0 -0
  254. data/spec/dummy/tmp/cache/assets/test/sprockets/9181c05dfda585ad6bf9ddb219eb15a1 +0 -0
  255. data/spec/dummy/tmp/cache/assets/test/sprockets/921e258c04378d5f0ecf0f3ee547195e +0 -0
  256. data/spec/dummy/tmp/cache/assets/test/sprockets/95682c5bcf707ffdac00772b90de8e9d +0 -0
  257. data/spec/dummy/tmp/cache/assets/test/sprockets/963d3f2d23c24941fe0b9c0231b8849d +0 -0
  258. data/spec/dummy/tmp/cache/assets/test/sprockets/99f0365331f36952dca860bcc6e8fd4a +0 -0
  259. data/spec/dummy/tmp/cache/assets/test/sprockets/9b9cde87d5e9f732acdc4fb18077c71d +0 -0
  260. data/spec/dummy/tmp/cache/assets/test/sprockets/9ba436ceb3644f8f052f05eeff94a880 +0 -0
  261. data/spec/dummy/tmp/cache/assets/test/sprockets/9f495611485125fd9772059d732fd3ec +0 -0
  262. data/spec/dummy/tmp/cache/assets/test/sprockets/a6b936ad9b28fb786d3135a007e5d5b8 +0 -0
  263. data/spec/dummy/tmp/cache/assets/test/sprockets/a6eedf5e824ca04685c9da227f406b8f +0 -0
  264. data/spec/dummy/tmp/cache/assets/test/sprockets/a759d4068225951d142110473dd6c8b3 +0 -0
  265. data/spec/dummy/tmp/cache/assets/test/sprockets/aae43c2efd29f832dccb299bfa566e44 +0 -0
  266. data/spec/dummy/tmp/cache/assets/test/sprockets/abafd28d094dec608d1a73ec02e75c34 +0 -0
  267. data/spec/dummy/tmp/cache/assets/test/sprockets/ae3ffb8f5a8c49bb8253a13ef5d1d2a4 +0 -0
  268. data/spec/dummy/tmp/cache/assets/test/sprockets/af888b78046ad78708407984ecb3c8a6 +0 -0
  269. data/spec/dummy/tmp/cache/assets/test/sprockets/b09cd2d5bea8a15151b6022c038dda5c +0 -0
  270. data/spec/dummy/tmp/cache/assets/test/sprockets/b461b3c64042d0c6dbaf73e92275300e +0 -0
  271. data/spec/dummy/tmp/cache/assets/test/sprockets/b4948b52a9f8e7cdd8a77902409545c0 +0 -0
  272. data/spec/dummy/tmp/cache/assets/test/sprockets/c1de6e9cb5f12e4481b52b1cf8d38d31 +0 -0
  273. data/spec/dummy/tmp/cache/assets/test/sprockets/c6698cd7d2263b8d2095648c2ac0fe79 +0 -0
  274. data/spec/dummy/tmp/cache/assets/test/sprockets/c72957ff133a3fd942c3ab9960d1d423 +0 -0
  275. data/spec/dummy/tmp/cache/assets/test/sprockets/c8c8162f2a41f8578ba98c9a1f37e46b +0 -0
  276. data/spec/dummy/tmp/cache/assets/test/sprockets/c962852af3d1e3dc670690c90a7b070e +0 -0
  277. data/spec/dummy/tmp/cache/assets/test/sprockets/ca13fe06919030ff6b989ec199d70a44 +0 -0
  278. data/spec/dummy/tmp/cache/assets/test/sprockets/cb1fc3f2ce1b7f41695e590c097b311b +0 -0
  279. data/spec/dummy/tmp/cache/assets/test/sprockets/cc6dcaa815625d7d4b57e3972e144bda +0 -0
  280. data/spec/dummy/tmp/cache/assets/test/sprockets/ccbc9b9b1eb80fbb7865bc756ce55b87 +0 -0
  281. data/spec/dummy/tmp/cache/assets/test/sprockets/ce5e8cfd00d9fb6c6fde000c5e03662d +0 -0
  282. data/spec/dummy/tmp/cache/assets/test/sprockets/cfc55116cc6269b60cf1be77557f0fa0 +0 -0
  283. data/spec/dummy/tmp/cache/assets/test/sprockets/d295569fa361346a1980638387ef138b +0 -0
  284. data/spec/dummy/tmp/cache/assets/test/sprockets/d46eab415cde36a1cf5eace3991cf63a +0 -0
  285. data/spec/dummy/tmp/cache/assets/test/sprockets/d7e88e6d648deff48df25b735ddc1826 +0 -0
  286. data/spec/dummy/tmp/cache/assets/test/sprockets/db631d9298c9a2f7e02011d47fd3ccca +0 -0
  287. data/spec/dummy/tmp/cache/assets/test/sprockets/e1f04589fe51a214b3d97f4b9d693db2 +0 -0
  288. data/spec/dummy/tmp/cache/assets/test/sprockets/e41a3d9a4ba0bd341c8da19fb9e53cca +0 -0
  289. data/spec/dummy/tmp/cache/assets/test/sprockets/e574af4ac554c85b5795e56916e5264e +0 -0
  290. data/spec/dummy/tmp/cache/assets/test/sprockets/e641d229c53e2926a5ed4ab6ce79eada +0 -0
  291. data/spec/dummy/tmp/cache/assets/test/sprockets/e73b7841ac8e835c29aeb4fc4bf27e40 +0 -0
  292. data/spec/dummy/tmp/cache/assets/test/sprockets/e88a13629d2c3498c801d061a01f6bf1 +0 -0
  293. data/spec/dummy/tmp/cache/assets/test/sprockets/ed9f0de1b65ae8d7ef89087c83728461 +0 -0
  294. data/spec/dummy/tmp/cache/assets/test/sprockets/f0f4cedded536278ec7f580408e6e60f +0 -0
  295. data/spec/dummy/tmp/cache/assets/test/sprockets/f156de297b7d2034db1844f92f4f92ba +0 -0
  296. data/spec/dummy/tmp/cache/assets/test/sprockets/f2f4ef8251bfbaced240dfbd93538a90 +0 -0
  297. data/spec/dummy/tmp/cache/assets/test/sprockets/f655e2d083e4e5fc8b2c6a8064178998 +0 -0
  298. data/spec/dummy/tmp/cache/assets/test/sprockets/f6667183705babbc5a9efea96e26953b +0 -0
  299. data/spec/dummy/tmp/cache/assets/test/sprockets/f669eeb6c0059dbcab647979cad28c4b +0 -0
  300. data/spec/dummy/tmp/cache/assets/test/sprockets/f985e5d99fd0dcf330b2a243b63c71f8 +0 -0
  301. data/spec/dummy/tmp/cache/assets/test/sprockets/fa4cfa52c2f50e31e33e69d54e6694dc +0 -0
  302. data/spec/dummy/tmp/cache/assets/test/sprockets/fb8b186d5bf0307f86f65fc787d2adeb +0 -0
  303. data/spec/dummy/tmp/cache/assets/test/sprockets/fd2f0ae1c70d86cc45823b51d707e220 +0 -0
  304. data/spec/dummy/tmp/cache/assets/test/sprockets/ff328cfd9b51b215b0db24b8bb3c63f4 +0 -0
  305. data/spec/dummy/tmp/capybara/capybara-201406201333154448559003.html +40 -0
  306. data/spec/dummy/tmp/capybara/capybara-201406201334471332489322.html +40 -0
  307. data/spec/dummy/tmp/capybara/capybara-20140620133457504347654.html +40 -0
  308. data/spec/dummy/tmp/capybara/capybara-201406201339146009119774.html +40 -0
  309. data/spec/dummy/tmp/capybara/capybara-201406201435033322913505.html +46 -0
  310. data/spec/dummy/tmp/capybara/capybara-201406201436161732509467.html +13 -0
  311. data/spec/dummy/tmp/capybara/capybara-201406201437066148983056.html +75 -0
  312. data/spec/factories.rb +7 -0
  313. data/spec/features/post_jcrop_feature_spec.rb +15 -0
  314. data/spec/images/example.jpeg +0 -0
  315. data/spec/spec_helper.rb +112 -0
  316. data/spec/support/active_record.rb +12 -0
  317. data/spec/support/carrierwave.rb +23 -0
  318. data/spec/support/uploads/post/image/7/example.jpeg +0 -0
  319. data/spec/support/uploads/post/image/7/thumb_example.jpeg +0 -0
  320. data/vendor/assets/images/active_admin_jcrop/Jcrop.gif +0 -0
  321. data/vendor/assets/javascripts/active_admin_jcrop/jquery.Jcrop.js +1699 -0
  322. data/vendor/assets/javascripts/active_admin_jcrop/jquery.Jcrop.min.js +22 -0
  323. data/vendor/assets/javascripts/active_admin_jcrop/jquery.color.js +661 -0
  324. data/vendor/assets/stylesheets/active_admin_jcrop/Jcrop.gif +0 -0
  325. data/vendor/assets/stylesheets/active_admin_jcrop/jquery.Jcrop.css +165 -0
  326. data/vendor/assets/stylesheets/active_admin_jcrop/jquery.Jcrop.min.css +29 -0
  327. metadata +718 -391
  328. data/test/active_admin_jcrop_test.rb +0 -7
  329. data/test/dummy/app/admin/admin_user.rb +0 -28
  330. data/test/dummy/app/models/admin_user.rb +0 -6
  331. data/test/dummy/config/initializers/devise.rb +0 -256
  332. data/test/dummy/public/uploads/post/image/1/thumb_caminhao.jpeg +0 -0
  333. data/test/dummy/test/fixtures/admin_users.yml +0 -11
  334. data/test/dummy/test/fixtures/posts.yml +0 -9
  335. data/test/dummy/test/models/admin_user_test.rb +0 -7
  336. data/test/dummy/test/models/post_test.rb +0 -7
  337. data/test/test_helper.rb +0 -15
data/spec/factories.rb ADDED
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :post do
3
+ name "Name of Post"
4
+ image Rack::Test::UploadedFile.new(File.open(Rails.root.join('spec', 'images', 'example.jpeg')))
5
+ #image { fixture_file_upload(Rails.root.join('spec', 'images', 'example.jpeg'), 'image/jpeg') }
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Post admin' do
4
+
5
+ describe 'Croping modal', js: true do
6
+
7
+ subject { page }
8
+
9
+ background do
10
+ @post = FactoryGirl.create(:post)
11
+ visit "/admin/posts/#{@post.id}/edit"
12
+ end
13
+
14
+ end
15
+ end
Binary file
@@ -0,0 +1,112 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'carrierwave'
5
+ require 'carrierwave/orm/activerecord'
6
+
7
+ require_relative 'dummy/app/models/post'
8
+
9
+ require 'rspec/rails'
10
+ require 'database_cleaner'
11
+ require 'factory_girl'
12
+ require 'factories'
13
+ require 'formtastic/inputs/jcrop_input'
14
+
15
+ require 'activeadmin'
16
+ require 'pry'
17
+
18
+ include ActionDispatch::TestProcess
19
+
20
+ #Workaround for Capybara/RSPEC issues
21
+ require_relative 'dummy/app/admin/post'
22
+ require_relative 'dummy/app/admin/dashboard'
23
+ require_relative 'dummy/config/routes'
24
+
25
+
26
+ # Requires supporting ruby files with custom matchers and macros, etc, in
27
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
28
+ # run as spec files by default. This means that files in spec/support that end
29
+ # in _spec.rb will both be required and run as specs, causing the specs to be
30
+ # run twice. It is recommended that you do not name files matching this glob to
31
+ # end with _spec.rb. You can configure this pattern with with the --pattern
32
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
33
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
34
+
35
+ # Checks for pending migrations before tests are run.
36
+ # If you are not using ActiveRecord, you can remove this line.
37
+ ActiveRecord::Migration.maintain_test_schema!
38
+
39
+ RSpec.configure do |config|
40
+ config.include FactoryGirl::Syntax::Methods
41
+ # ## Mock Framework
42
+ #
43
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
44
+ #
45
+ # config.mock_with :mocha
46
+ # config.mock_with :flexmock
47
+ # config.mock_with :rr
48
+
49
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
50
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
51
+
52
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
53
+ # examples within a transaction, remove the following line or assign false
54
+ # instead of true.
55
+ #config.use_transactional_fixtures = false
56
+
57
+ # If true, the base class of anonymous controllers will be inferred
58
+ # automatically. This will be the default behavior in future versions of
59
+ # rspec-rails.
60
+ config.infer_base_class_for_anonymous_controllers = false
61
+
62
+ # Run specs in random order to surface order dependencies. If you find an
63
+ # order dependency and want to debug it, you can fix the order by providing
64
+ # the seed, which is printed after each run.
65
+ # --seed 1234
66
+ config.after(:each) do
67
+ if Rails.env.test? || Rails.env.cucumber?
68
+ FileUtils.rm_rf(Dir["#{Rails.root}/spec/support/uploads"])
69
+ end
70
+ end
71
+
72
+ config.order = "random"
73
+
74
+ # RSpec Rails can automatically mix in different behaviours to your tests
75
+ # based on their file location, for example enabling you to call `get` and
76
+ # `post` in specs under `spec/controllers`.
77
+ #
78
+ # You can disable this behaviour by removing the line below, and instead
79
+ # explictly tag your specs with their type, e.g.:
80
+ #
81
+ # describe UsersController, :type => :controller do
82
+ # # ...
83
+ # end
84
+ #
85
+
86
+
87
+ config.use_transactional_fixtures = false
88
+ config.before :each do
89
+ DatabaseCleaner.start
90
+ end
91
+ config.after :each do
92
+ DatabaseCleaner.clean
93
+ end
94
+
95
+
96
+ # config.before(:suite) do
97
+ # DatabaseCleaner.strategy = :transaction
98
+ # DatabaseCleaner.clean_with(:truncation)
99
+ # end
100
+
101
+ config.around(:each) do |example|
102
+ DatabaseCleaner.cleaning do
103
+ example.run
104
+ end
105
+ end
106
+
107
+ # The different available types are documented in the features, such as in
108
+ # https://relishapp.com/rspec/rspec-rails/v/3-0/docs
109
+ config.infer_spec_type_from_file_location!
110
+ end
111
+
112
+
@@ -0,0 +1,12 @@
1
+ class ActiveRecord::Base
2
+ mattr_accessor :shared_connection
3
+ @@shared_connection = nil
4
+
5
+ def self.connection
6
+ @@shared_connection || retrieve_connection
7
+ end
8
+ end
9
+
10
+ # Forces all threads to share the same connection. This works on
11
+ # Capybara because it starts the web server in a thread.
12
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@@ -0,0 +1,23 @@
1
+ if Rails.env.test? || Rails.env.cucumber?
2
+ CarrierWave.configure do |config|
3
+ config.storage = :file
4
+ config.enable_processing = false
5
+ end
6
+
7
+ # use different dirs when testing
8
+ CarrierWave::Uploader::Base.descendants.each do |klass|
9
+ next if klass.anonymous?
10
+ klass.class_eval do
11
+ def cache_dir
12
+ "#{Rails.root}/spec/support/uploads/tmp"
13
+ end
14
+
15
+ def store_dir
16
+ "#{Rails.root}/spec/support/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
+ end
18
+ end
19
+ end
20
+ CarrierWave.configure do |config|
21
+ config.root = "#{Rails.root}/spec/support/uploads/"
22
+ end
23
+ end
@@ -0,0 +1,1699 @@
1
+ /**
2
+ * jquery.Jcrop.js v0.9.12
3
+ * jQuery Image Cropping Plugin - released under MIT License
4
+ * Author: Kelly Hallman <khallman@gmail.com>
5
+ * http://github.com/tapmodo/Jcrop
6
+ * Copyright (c) 2008-2013 Tapmodo Interactive LLC {{{
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person
9
+ * obtaining a copy of this software and associated documentation
10
+ * files (the "Software"), to deal in the Software without
11
+ * restriction, including without limitation the rights to use,
12
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the
14
+ * Software is furnished to do so, subject to the following
15
+ * conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ * OTHER DEALINGS IN THE SOFTWARE.
28
+ *
29
+ * }}}
30
+ */
31
+
32
+ (function ($) {
33
+
34
+ $.Jcrop = function (obj, opt) {
35
+ var options = $.extend({}, $.Jcrop.defaults),
36
+ docOffset,
37
+ _ua = navigator.userAgent.toLowerCase(),
38
+ is_msie = /msie/.test(_ua),
39
+ ie6mode = /msie [1-6]\./.test(_ua);
40
+
41
+ // Internal Methods {{{
42
+ function px(n) {
43
+ return Math.round(n) + 'px';
44
+ }
45
+ function cssClass(cl) {
46
+ return options.baseClass + '-' + cl;
47
+ }
48
+ function supportsColorFade() {
49
+ return $.fx.step.hasOwnProperty('backgroundColor');
50
+ }
51
+ function getPos(obj) //{{{
52
+ {
53
+ var pos = $(obj).offset();
54
+ return [pos.left, pos.top];
55
+ }
56
+ //}}}
57
+ function mouseAbs(e) //{{{
58
+ {
59
+ return [(e.pageX - docOffset[0]), (e.pageY - docOffset[1])];
60
+ }
61
+ //}}}
62
+ function setOptions(opt) //{{{
63
+ {
64
+ if (typeof(opt) !== 'object') opt = {};
65
+ options = $.extend(options, opt);
66
+
67
+ $.each(['onChange','onSelect','onRelease','onDblClick'],function(i,e) {
68
+ if (typeof(options[e]) !== 'function') options[e] = function () {};
69
+ });
70
+ }
71
+ //}}}
72
+ function startDragMode(mode, pos, touch) //{{{
73
+ {
74
+ docOffset = getPos($img);
75
+ Tracker.setCursor(mode === 'move' ? mode : mode + '-resize');
76
+
77
+ if (mode === 'move') {
78
+ return Tracker.activateHandlers(createMover(pos), doneSelect, touch);
79
+ }
80
+
81
+ var fc = Coords.getFixed();
82
+ var opp = oppLockCorner(mode);
83
+ var opc = Coords.getCorner(oppLockCorner(opp));
84
+
85
+ Coords.setPressed(Coords.getCorner(opp));
86
+ Coords.setCurrent(opc);
87
+
88
+ Tracker.activateHandlers(dragmodeHandler(mode, fc), doneSelect, touch);
89
+ }
90
+ //}}}
91
+ function dragmodeHandler(mode, f) //{{{
92
+ {
93
+ return function (pos) {
94
+ if (!options.aspectRatio) {
95
+ switch (mode) {
96
+ case 'e':
97
+ pos[1] = f.y2;
98
+ break;
99
+ case 'w':
100
+ pos[1] = f.y2;
101
+ break;
102
+ case 'n':
103
+ pos[0] = f.x2;
104
+ break;
105
+ case 's':
106
+ pos[0] = f.x2;
107
+ break;
108
+ }
109
+ } else {
110
+ switch (mode) {
111
+ case 'e':
112
+ pos[1] = f.y + 1;
113
+ break;
114
+ case 'w':
115
+ pos[1] = f.y + 1;
116
+ break;
117
+ case 'n':
118
+ pos[0] = f.x + 1;
119
+ break;
120
+ case 's':
121
+ pos[0] = f.x + 1;
122
+ break;
123
+ }
124
+ }
125
+ Coords.setCurrent(pos);
126
+ Selection.update();
127
+ };
128
+ }
129
+ //}}}
130
+ function createMover(pos) //{{{
131
+ {
132
+ var lloc = pos;
133
+ KeyManager.watchKeys();
134
+
135
+ return function (pos) {
136
+ Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]);
137
+ lloc = pos;
138
+
139
+ Selection.update();
140
+ };
141
+ }
142
+ //}}}
143
+ function oppLockCorner(ord) //{{{
144
+ {
145
+ switch (ord) {
146
+ case 'n':
147
+ return 'sw';
148
+ case 's':
149
+ return 'nw';
150
+ case 'e':
151
+ return 'nw';
152
+ case 'w':
153
+ return 'ne';
154
+ case 'ne':
155
+ return 'sw';
156
+ case 'nw':
157
+ return 'se';
158
+ case 'se':
159
+ return 'nw';
160
+ case 'sw':
161
+ return 'ne';
162
+ }
163
+ }
164
+ //}}}
165
+ function createDragger(ord) //{{{
166
+ {
167
+ return function (e) {
168
+ if (options.disabled) {
169
+ return false;
170
+ }
171
+ if ((ord === 'move') && !options.allowMove) {
172
+ return false;
173
+ }
174
+
175
+ // Fix position of crop area when dragged the very first time.
176
+ // Necessary when crop image is in a hidden element when page is loaded.
177
+ docOffset = getPos($img);
178
+
179
+ btndown = true;
180
+ startDragMode(ord, mouseAbs(e));
181
+ e.stopPropagation();
182
+ e.preventDefault();
183
+ return false;
184
+ };
185
+ }
186
+ //}}}
187
+ function presize($obj, w, h) //{{{
188
+ {
189
+ var nw = $obj.width(),
190
+ nh = $obj.height();
191
+ if ((nw > w) && w > 0) {
192
+ nw = w;
193
+ nh = (w / $obj.width()) * $obj.height();
194
+ }
195
+ if ((nh > h) && h > 0) {
196
+ nh = h;
197
+ nw = (h / $obj.height()) * $obj.width();
198
+ }
199
+ xscale = $obj.width() / nw;
200
+ yscale = $obj.height() / nh;
201
+ $obj.width(nw).height(nh);
202
+ }
203
+ //}}}
204
+ function unscale(c) //{{{
205
+ {
206
+ return {
207
+ x: c.x * xscale,
208
+ y: c.y * yscale,
209
+ x2: c.x2 * xscale,
210
+ y2: c.y2 * yscale,
211
+ w: c.w * xscale,
212
+ h: c.h * yscale
213
+ };
214
+ }
215
+ //}}}
216
+ function doneSelect(pos) //{{{
217
+ {
218
+ var c = Coords.getFixed();
219
+ if ((c.w > options.minSelect[0]) && (c.h > options.minSelect[1])) {
220
+ Selection.enableHandles();
221
+ Selection.done();
222
+ } else {
223
+ Selection.release();
224
+ }
225
+ Tracker.setCursor(options.allowSelect ? 'crosshair' : 'default');
226
+ }
227
+ //}}}
228
+ function newSelection(e) //{{{
229
+ {
230
+ if (options.disabled) {
231
+ return false;
232
+ }
233
+ if (!options.allowSelect) {
234
+ return false;
235
+ }
236
+ btndown = true;
237
+ docOffset = getPos($img);
238
+ Selection.disableHandles();
239
+ Tracker.setCursor('crosshair');
240
+ var pos = mouseAbs(e);
241
+ Coords.setPressed(pos);
242
+ Selection.update();
243
+ Tracker.activateHandlers(selectDrag, doneSelect, e.type.substring(0,5)==='touch');
244
+ KeyManager.watchKeys();
245
+
246
+ e.stopPropagation();
247
+ e.preventDefault();
248
+ return false;
249
+ }
250
+ //}}}
251
+ function selectDrag(pos) //{{{
252
+ {
253
+ Coords.setCurrent(pos);
254
+ Selection.update();
255
+ }
256
+ //}}}
257
+ function newTracker() //{{{
258
+ {
259
+ var trk = $('<div></div>').addClass(cssClass('tracker'));
260
+ if (is_msie) {
261
+ trk.css({
262
+ opacity: 0,
263
+ backgroundColor: 'white'
264
+ });
265
+ }
266
+ return trk;
267
+ }
268
+ //}}}
269
+
270
+ // }}}
271
+ // Initialization {{{
272
+ // Sanitize some options {{{
273
+ if (typeof(obj) !== 'object') {
274
+ obj = $(obj)[0];
275
+ }
276
+ if (typeof(opt) !== 'object') {
277
+ opt = {};
278
+ }
279
+ // }}}
280
+ setOptions(opt);
281
+ // Initialize some jQuery objects {{{
282
+ // The values are SET on the image(s) for the interface
283
+ // If the original image has any of these set, they will be reset
284
+ // However, if you destroy() the Jcrop instance the original image's
285
+ // character in the DOM will be as you left it.
286
+ var img_css = {
287
+ border: 'none',
288
+ visibility: 'visible',
289
+ margin: 0,
290
+ padding: 0,
291
+ position: 'absolute',
292
+ top: 0,
293
+ left: 0
294
+ };
295
+
296
+ var $origimg = $(obj),
297
+ img_mode = true;
298
+
299
+ if (obj.tagName == 'IMG') {
300
+ // Fix size of crop image.
301
+ // Necessary when crop image is within a hidden element when page is loaded.
302
+ if ($origimg[0].width != 0 && $origimg[0].height != 0) {
303
+ // Obtain dimensions from contained img element.
304
+ $origimg.width($origimg[0].width);
305
+ $origimg.height($origimg[0].height);
306
+ } else {
307
+ // Obtain dimensions from temporary image in case the original is not loaded yet (e.g. IE 7.0).
308
+ var tempImage = new Image();
309
+ tempImage.src = $origimg[0].src;
310
+ $origimg.width(tempImage.width);
311
+ $origimg.height(tempImage.height);
312
+ }
313
+
314
+ var $img = $origimg.clone().removeAttr('id').css(img_css).show();
315
+
316
+ $img.width($origimg.width());
317
+ $img.height($origimg.height());
318
+ $origimg.after($img).hide();
319
+
320
+ } else {
321
+ $img = $origimg.css(img_css).show();
322
+ img_mode = false;
323
+ if (options.shade === null) { options.shade = true; }
324
+ }
325
+
326
+ presize($img, options.boxWidth, options.boxHeight);
327
+
328
+ var boundx = $img.width(),
329
+ boundy = $img.height(),
330
+
331
+
332
+ $div = $('<div />').width(boundx).height(boundy).addClass(cssClass('holder')).css({
333
+ position: 'relative',
334
+ backgroundColor: options.bgColor
335
+ }).insertAfter($origimg).append($img);
336
+
337
+ if (options.addClass) {
338
+ $div.addClass(options.addClass);
339
+ }
340
+
341
+ var $img2 = $('<div />'),
342
+
343
+ $img_holder = $('<div />')
344
+ .width('100%').height('100%').css({
345
+ zIndex: 310,
346
+ position: 'absolute',
347
+ overflow: 'hidden'
348
+ }),
349
+
350
+ $hdl_holder = $('<div />')
351
+ .width('100%').height('100%').css('zIndex', 320),
352
+
353
+ $sel = $('<div />')
354
+ .css({
355
+ position: 'absolute',
356
+ zIndex: 600
357
+ }).dblclick(function(){
358
+ var c = Coords.getFixed();
359
+ options.onDblClick.call(api,c);
360
+ }).insertBefore($img).append($img_holder, $hdl_holder);
361
+
362
+ if (img_mode) {
363
+
364
+ $img2 = $('<img />')
365
+ .attr('src', $img.attr('src')).css(img_css).width(boundx).height(boundy),
366
+
367
+ $img_holder.append($img2);
368
+
369
+ }
370
+
371
+ if (ie6mode) {
372
+ $sel.css({
373
+ overflowY: 'hidden'
374
+ });
375
+ }
376
+
377
+ var bound = options.boundary;
378
+ var $trk = newTracker().width(boundx + (bound * 2)).height(boundy + (bound * 2)).css({
379
+ position: 'absolute',
380
+ top: px(-bound),
381
+ left: px(-bound),
382
+ zIndex: 290
383
+ }).mousedown(newSelection);
384
+
385
+ /* }}} */
386
+ // Set more variables {{{
387
+ var bgcolor = options.bgColor,
388
+ bgopacity = options.bgOpacity,
389
+ xlimit, ylimit, xmin, ymin, xscale, yscale, enabled = true,
390
+ btndown, animating, shift_down;
391
+
392
+ docOffset = getPos($img);
393
+ // }}}
394
+ // }}}
395
+ // Internal Modules {{{
396
+ // Touch Module {{{
397
+ var Touch = (function () {
398
+ // Touch support detection function adapted (under MIT License)
399
+ // from code by Jeffrey Sambells - http://github.com/iamamused/
400
+ function hasTouchSupport() {
401
+ var support = {}, events = ['touchstart', 'touchmove', 'touchend'],
402
+ el = document.createElement('div'), i;
403
+
404
+ try {
405
+ for(i=0; i<events.length; i++) {
406
+ var eventName = events[i];
407
+ eventName = 'on' + eventName;
408
+ var isSupported = (eventName in el);
409
+ if (!isSupported) {
410
+ el.setAttribute(eventName, 'return;');
411
+ isSupported = typeof el[eventName] == 'function';
412
+ }
413
+ support[events[i]] = isSupported;
414
+ }
415
+ return support.touchstart && support.touchend && support.touchmove;
416
+ }
417
+ catch(err) {
418
+ return false;
419
+ }
420
+ }
421
+
422
+ function detectSupport() {
423
+ if ((options.touchSupport === true) || (options.touchSupport === false)) return options.touchSupport;
424
+ else return hasTouchSupport();
425
+ }
426
+ return {
427
+ createDragger: function (ord) {
428
+ return function (e) {
429
+ if (options.disabled) {
430
+ return false;
431
+ }
432
+ if ((ord === 'move') && !options.allowMove) {
433
+ return false;
434
+ }
435
+ docOffset = getPos($img);
436
+ btndown = true;
437
+ startDragMode(ord, mouseAbs(Touch.cfilter(e)), true);
438
+ e.stopPropagation();
439
+ e.preventDefault();
440
+ return false;
441
+ };
442
+ },
443
+ newSelection: function (e) {
444
+ return newSelection(Touch.cfilter(e));
445
+ },
446
+ cfilter: function (e){
447
+ e.pageX = e.originalEvent.changedTouches[0].pageX;
448
+ e.pageY = e.originalEvent.changedTouches[0].pageY;
449
+ return e;
450
+ },
451
+ isSupported: hasTouchSupport,
452
+ support: detectSupport()
453
+ };
454
+ }());
455
+ // }}}
456
+ // Coords Module {{{
457
+ var Coords = (function () {
458
+ var x1 = 0,
459
+ y1 = 0,
460
+ x2 = 0,
461
+ y2 = 0,
462
+ ox, oy;
463
+
464
+ function setPressed(pos) //{{{
465
+ {
466
+ pos = rebound(pos);
467
+ x2 = x1 = pos[0];
468
+ y2 = y1 = pos[1];
469
+ }
470
+ //}}}
471
+ function setCurrent(pos) //{{{
472
+ {
473
+ pos = rebound(pos);
474
+ ox = pos[0] - x2;
475
+ oy = pos[1] - y2;
476
+ x2 = pos[0];
477
+ y2 = pos[1];
478
+ }
479
+ //}}}
480
+ function getOffset() //{{{
481
+ {
482
+ return [ox, oy];
483
+ }
484
+ //}}}
485
+ function moveOffset(offset) //{{{
486
+ {
487
+ var ox = offset[0],
488
+ oy = offset[1];
489
+
490
+ if (0 > x1 + ox) {
491
+ ox -= ox + x1;
492
+ }
493
+ if (0 > y1 + oy) {
494
+ oy -= oy + y1;
495
+ }
496
+
497
+ if (boundy < y2 + oy) {
498
+ oy += boundy - (y2 + oy);
499
+ }
500
+ if (boundx < x2 + ox) {
501
+ ox += boundx - (x2 + ox);
502
+ }
503
+
504
+ x1 += ox;
505
+ x2 += ox;
506
+ y1 += oy;
507
+ y2 += oy;
508
+ }
509
+ //}}}
510
+ function getCorner(ord) //{{{
511
+ {
512
+ var c = getFixed();
513
+ switch (ord) {
514
+ case 'ne':
515
+ return [c.x2, c.y];
516
+ case 'nw':
517
+ return [c.x, c.y];
518
+ case 'se':
519
+ return [c.x2, c.y2];
520
+ case 'sw':
521
+ return [c.x, c.y2];
522
+ }
523
+ }
524
+ //}}}
525
+ function getFixed() //{{{
526
+ {
527
+ if (!options.aspectRatio) {
528
+ return getRect();
529
+ }
530
+ // This function could use some optimization I think...
531
+ var aspect = options.aspectRatio,
532
+ min_x = options.minSize[0] / xscale,
533
+
534
+
535
+ //min_y = options.minSize[1]/yscale,
536
+ max_x = options.maxSize[0] / xscale,
537
+ max_y = options.maxSize[1] / yscale,
538
+ rw = x2 - x1,
539
+ rh = y2 - y1,
540
+ rwa = Math.abs(rw),
541
+ rha = Math.abs(rh),
542
+ real_ratio = rwa / rha,
543
+ xx, yy, w, h;
544
+
545
+ if (max_x === 0) {
546
+ max_x = boundx * 10;
547
+ }
548
+ if (max_y === 0) {
549
+ max_y = boundy * 10;
550
+ }
551
+ if (real_ratio < aspect) {
552
+ yy = y2;
553
+ w = rha * aspect;
554
+ xx = rw < 0 ? x1 - w : w + x1;
555
+
556
+ if (xx < 0) {
557
+ xx = 0;
558
+ h = Math.abs((xx - x1) / aspect);
559
+ yy = rh < 0 ? y1 - h : h + y1;
560
+ } else if (xx > boundx) {
561
+ xx = boundx;
562
+ h = Math.abs((xx - x1) / aspect);
563
+ yy = rh < 0 ? y1 - h : h + y1;
564
+ }
565
+ } else {
566
+ xx = x2;
567
+ h = rwa / aspect;
568
+ yy = rh < 0 ? y1 - h : y1 + h;
569
+ if (yy < 0) {
570
+ yy = 0;
571
+ w = Math.abs((yy - y1) * aspect);
572
+ xx = rw < 0 ? x1 - w : w + x1;
573
+ } else if (yy > boundy) {
574
+ yy = boundy;
575
+ w = Math.abs(yy - y1) * aspect;
576
+ xx = rw < 0 ? x1 - w : w + x1;
577
+ }
578
+ }
579
+
580
+ // Magic %-)
581
+ if (xx > x1) { // right side
582
+ if (xx - x1 < min_x) {
583
+ xx = x1 + min_x;
584
+ } else if (xx - x1 > max_x) {
585
+ xx = x1 + max_x;
586
+ }
587
+ if (yy > y1) {
588
+ yy = y1 + (xx - x1) / aspect;
589
+ } else {
590
+ yy = y1 - (xx - x1) / aspect;
591
+ }
592
+ } else if (xx < x1) { // left side
593
+ if (x1 - xx < min_x) {
594
+ xx = x1 - min_x;
595
+ } else if (x1 - xx > max_x) {
596
+ xx = x1 - max_x;
597
+ }
598
+ if (yy > y1) {
599
+ yy = y1 + (x1 - xx) / aspect;
600
+ } else {
601
+ yy = y1 - (x1 - xx) / aspect;
602
+ }
603
+ }
604
+
605
+ if (xx < 0) {
606
+ x1 -= xx;
607
+ xx = 0;
608
+ } else if (xx > boundx) {
609
+ x1 -= xx - boundx;
610
+ xx = boundx;
611
+ }
612
+
613
+ if (yy < 0) {
614
+ y1 -= yy;
615
+ yy = 0;
616
+ } else if (yy > boundy) {
617
+ y1 -= yy - boundy;
618
+ yy = boundy;
619
+ }
620
+
621
+ return makeObj(flipCoords(x1, y1, xx, yy));
622
+ }
623
+ //}}}
624
+ function rebound(p) //{{{
625
+ {
626
+ if (p[0] < 0) p[0] = 0;
627
+ if (p[1] < 0) p[1] = 0;
628
+
629
+ if (p[0] > boundx) p[0] = boundx;
630
+ if (p[1] > boundy) p[1] = boundy;
631
+
632
+ return [Math.round(p[0]), Math.round(p[1])];
633
+ }
634
+ //}}}
635
+ function flipCoords(x1, y1, x2, y2) //{{{
636
+ {
637
+ var xa = x1,
638
+ xb = x2,
639
+ ya = y1,
640
+ yb = y2;
641
+ if (x2 < x1) {
642
+ xa = x2;
643
+ xb = x1;
644
+ }
645
+ if (y2 < y1) {
646
+ ya = y2;
647
+ yb = y1;
648
+ }
649
+ return [xa, ya, xb, yb];
650
+ }
651
+ //}}}
652
+ function getRect() //{{{
653
+ {
654
+ var xsize = x2 - x1,
655
+ ysize = y2 - y1,
656
+ delta;
657
+
658
+ if (xlimit && (Math.abs(xsize) > xlimit)) {
659
+ x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit);
660
+ }
661
+ if (ylimit && (Math.abs(ysize) > ylimit)) {
662
+ y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit);
663
+ }
664
+
665
+ if (ymin / yscale && (Math.abs(ysize) < ymin / yscale)) {
666
+ y2 = (ysize > 0) ? (y1 + ymin / yscale) : (y1 - ymin / yscale);
667
+ }
668
+ if (xmin / xscale && (Math.abs(xsize) < xmin / xscale)) {
669
+ x2 = (xsize > 0) ? (x1 + xmin / xscale) : (x1 - xmin / xscale);
670
+ }
671
+
672
+ if (x1 < 0) {
673
+ x2 -= x1;
674
+ x1 -= x1;
675
+ }
676
+ if (y1 < 0) {
677
+ y2 -= y1;
678
+ y1 -= y1;
679
+ }
680
+ if (x2 < 0) {
681
+ x1 -= x2;
682
+ x2 -= x2;
683
+ }
684
+ if (y2 < 0) {
685
+ y1 -= y2;
686
+ y2 -= y2;
687
+ }
688
+ if (x2 > boundx) {
689
+ delta = x2 - boundx;
690
+ x1 -= delta;
691
+ x2 -= delta;
692
+ }
693
+ if (y2 > boundy) {
694
+ delta = y2 - boundy;
695
+ y1 -= delta;
696
+ y2 -= delta;
697
+ }
698
+ if (x1 > boundx) {
699
+ delta = x1 - boundy;
700
+ y2 -= delta;
701
+ y1 -= delta;
702
+ }
703
+ if (y1 > boundy) {
704
+ delta = y1 - boundy;
705
+ y2 -= delta;
706
+ y1 -= delta;
707
+ }
708
+
709
+ return makeObj(flipCoords(x1, y1, x2, y2));
710
+ }
711
+ //}}}
712
+ function makeObj(a) //{{{
713
+ {
714
+ return {
715
+ x: a[0],
716
+ y: a[1],
717
+ x2: a[2],
718
+ y2: a[3],
719
+ w: a[2] - a[0],
720
+ h: a[3] - a[1]
721
+ };
722
+ }
723
+ //}}}
724
+
725
+ return {
726
+ flipCoords: flipCoords,
727
+ setPressed: setPressed,
728
+ setCurrent: setCurrent,
729
+ getOffset: getOffset,
730
+ moveOffset: moveOffset,
731
+ getCorner: getCorner,
732
+ getFixed: getFixed
733
+ };
734
+ }());
735
+
736
+ //}}}
737
+ // Shade Module {{{
738
+ var Shade = (function() {
739
+ var enabled = false,
740
+ holder = $('<div />').css({
741
+ position: 'absolute',
742
+ zIndex: 240,
743
+ opacity: 0
744
+ }),
745
+ shades = {
746
+ top: createShade(),
747
+ left: createShade().height(boundy),
748
+ right: createShade().height(boundy),
749
+ bottom: createShade()
750
+ };
751
+
752
+ function resizeShades(w,h) {
753
+ shades.left.css({ height: px(h) });
754
+ shades.right.css({ height: px(h) });
755
+ }
756
+ function updateAuto()
757
+ {
758
+ return updateShade(Coords.getFixed());
759
+ }
760
+ function updateShade(c)
761
+ {
762
+ shades.top.css({
763
+ left: px(c.x),
764
+ width: px(c.w),
765
+ height: px(c.y)
766
+ });
767
+ shades.bottom.css({
768
+ top: px(c.y2),
769
+ left: px(c.x),
770
+ width: px(c.w),
771
+ height: px(boundy-c.y2)
772
+ });
773
+ shades.right.css({
774
+ left: px(c.x2),
775
+ width: px(boundx-c.x2)
776
+ });
777
+ shades.left.css({
778
+ width: px(c.x)
779
+ });
780
+ }
781
+ function createShade() {
782
+ return $('<div />').css({
783
+ position: 'absolute',
784
+ backgroundColor: options.shadeColor||options.bgColor
785
+ }).appendTo(holder);
786
+ }
787
+ function enableShade() {
788
+ if (!enabled) {
789
+ enabled = true;
790
+ holder.insertBefore($img);
791
+ updateAuto();
792
+ Selection.setBgOpacity(1,0,1);
793
+ $img2.hide();
794
+
795
+ setBgColor(options.shadeColor||options.bgColor,1);
796
+ if (Selection.isAwake())
797
+ {
798
+ setOpacity(options.bgOpacity,1);
799
+ }
800
+ else setOpacity(1,1);
801
+ }
802
+ }
803
+ function setBgColor(color,now) {
804
+ colorChangeMacro(getShades(),color,now);
805
+ }
806
+ function disableShade() {
807
+ if (enabled) {
808
+ holder.remove();
809
+ $img2.show();
810
+ enabled = false;
811
+ if (Selection.isAwake()) {
812
+ Selection.setBgOpacity(options.bgOpacity,1,1);
813
+ } else {
814
+ Selection.setBgOpacity(1,1,1);
815
+ Selection.disableHandles();
816
+ }
817
+ colorChangeMacro($div,0,1);
818
+ }
819
+ }
820
+ function setOpacity(opacity,now) {
821
+ if (enabled) {
822
+ if (options.bgFade && !now) {
823
+ holder.animate({
824
+ opacity: 1-opacity
825
+ },{
826
+ queue: false,
827
+ duration: options.fadeTime
828
+ });
829
+ }
830
+ else holder.css({opacity:1-opacity});
831
+ }
832
+ }
833
+ function refreshAll() {
834
+ options.shade ? enableShade() : disableShade();
835
+ if (Selection.isAwake()) setOpacity(options.bgOpacity);
836
+ }
837
+ function getShades() {
838
+ return holder.children();
839
+ }
840
+
841
+ return {
842
+ update: updateAuto,
843
+ updateRaw: updateShade,
844
+ getShades: getShades,
845
+ setBgColor: setBgColor,
846
+ enable: enableShade,
847
+ disable: disableShade,
848
+ resize: resizeShades,
849
+ refresh: refreshAll,
850
+ opacity: setOpacity
851
+ };
852
+ }());
853
+ // }}}
854
+ // Selection Module {{{
855
+ var Selection = (function () {
856
+ var awake,
857
+ hdep = 370,
858
+ borders = {},
859
+ handle = {},
860
+ dragbar = {},
861
+ seehandles = false;
862
+
863
+ // Private Methods
864
+ function insertBorder(type) //{{{
865
+ {
866
+ var jq = $('<div />').css({
867
+ position: 'absolute',
868
+ opacity: options.borderOpacity
869
+ }).addClass(cssClass(type));
870
+ $img_holder.append(jq);
871
+ return jq;
872
+ }
873
+ //}}}
874
+ function dragDiv(ord, zi) //{{{
875
+ {
876
+ var jq = $('<div />').mousedown(createDragger(ord)).css({
877
+ cursor: ord + '-resize',
878
+ position: 'absolute',
879
+ zIndex: zi
880
+ }).addClass('ord-'+ord);
881
+
882
+ if (Touch.support) {
883
+ jq.bind('touchstart.jcrop', Touch.createDragger(ord));
884
+ }
885
+
886
+ $hdl_holder.append(jq);
887
+ return jq;
888
+ }
889
+ //}}}
890
+ function insertHandle(ord) //{{{
891
+ {
892
+ var hs = options.handleSize,
893
+
894
+ div = dragDiv(ord, hdep++).css({
895
+ opacity: options.handleOpacity
896
+ }).addClass(cssClass('handle'));
897
+
898
+ if (hs) { div.width(hs).height(hs); }
899
+
900
+ return div;
901
+ }
902
+ //}}}
903
+ function insertDragbar(ord) //{{{
904
+ {
905
+ return dragDiv(ord, hdep++).addClass('jcrop-dragbar');
906
+ }
907
+ //}}}
908
+ function createDragbars(li) //{{{
909
+ {
910
+ var i;
911
+ for (i = 0; i < li.length; i++) {
912
+ dragbar[li[i]] = insertDragbar(li[i]);
913
+ }
914
+ }
915
+ //}}}
916
+ function createBorders(li) //{{{
917
+ {
918
+ var cl,i;
919
+ for (i = 0; i < li.length; i++) {
920
+ switch(li[i]){
921
+ case'n': cl='hline'; break;
922
+ case's': cl='hline bottom'; break;
923
+ case'e': cl='vline right'; break;
924
+ case'w': cl='vline'; break;
925
+ }
926
+ borders[li[i]] = insertBorder(cl);
927
+ }
928
+ }
929
+ //}}}
930
+ function createHandles(li) //{{{
931
+ {
932
+ var i;
933
+ for (i = 0; i < li.length; i++) {
934
+ handle[li[i]] = insertHandle(li[i]);
935
+ }
936
+ }
937
+ //}}}
938
+ function moveto(x, y) //{{{
939
+ {
940
+ if (!options.shade) {
941
+ $img2.css({
942
+ top: px(-y),
943
+ left: px(-x)
944
+ });
945
+ }
946
+ $sel.css({
947
+ top: px(y),
948
+ left: px(x)
949
+ });
950
+ }
951
+ //}}}
952
+ function resize(w, h) //{{{
953
+ {
954
+ $sel.width(Math.round(w)).height(Math.round(h));
955
+ }
956
+ //}}}
957
+ function refresh() //{{{
958
+ {
959
+ var c = Coords.getFixed();
960
+
961
+ Coords.setPressed([c.x, c.y]);
962
+ Coords.setCurrent([c.x2, c.y2]);
963
+
964
+ updateVisible();
965
+ }
966
+ //}}}
967
+
968
+ // Internal Methods
969
+ function updateVisible(select) //{{{
970
+ {
971
+ if (awake) {
972
+ return update(select);
973
+ }
974
+ }
975
+ //}}}
976
+ function update(select) //{{{
977
+ {
978
+ var c = Coords.getFixed();
979
+
980
+ resize(c.w, c.h);
981
+ moveto(c.x, c.y);
982
+ if (options.shade) Shade.updateRaw(c);
983
+
984
+ awake || show();
985
+
986
+ if (select) {
987
+ options.onSelect.call(api, unscale(c));
988
+ } else {
989
+ options.onChange.call(api, unscale(c));
990
+ }
991
+ }
992
+ //}}}
993
+ function setBgOpacity(opacity,force,now) //{{{
994
+ {
995
+ if (!awake && !force) return;
996
+ if (options.bgFade && !now) {
997
+ $img.animate({
998
+ opacity: opacity
999
+ },{
1000
+ queue: false,
1001
+ duration: options.fadeTime
1002
+ });
1003
+ } else {
1004
+ $img.css('opacity', opacity);
1005
+ }
1006
+ }
1007
+ //}}}
1008
+ function show() //{{{
1009
+ {
1010
+ $sel.show();
1011
+
1012
+ if (options.shade) Shade.opacity(bgopacity);
1013
+ else setBgOpacity(bgopacity,true);
1014
+
1015
+ awake = true;
1016
+ }
1017
+ //}}}
1018
+ function release() //{{{
1019
+ {
1020
+ disableHandles();
1021
+ $sel.hide();
1022
+
1023
+ if (options.shade) Shade.opacity(1);
1024
+ else setBgOpacity(1);
1025
+
1026
+ awake = false;
1027
+ options.onRelease.call(api);
1028
+ }
1029
+ //}}}
1030
+ function showHandles() //{{{
1031
+ {
1032
+ if (seehandles) {
1033
+ $hdl_holder.show();
1034
+ }
1035
+ }
1036
+ //}}}
1037
+ function enableHandles() //{{{
1038
+ {
1039
+ seehandles = true;
1040
+ if (options.allowResize) {
1041
+ $hdl_holder.show();
1042
+ return true;
1043
+ }
1044
+ }
1045
+ //}}}
1046
+ function disableHandles() //{{{
1047
+ {
1048
+ seehandles = false;
1049
+ $hdl_holder.hide();
1050
+ }
1051
+ //}}}
1052
+ function animMode(v) //{{{
1053
+ {
1054
+ if (v) {
1055
+ animating = true;
1056
+ disableHandles();
1057
+ } else {
1058
+ animating = false;
1059
+ enableHandles();
1060
+ }
1061
+ }
1062
+ //}}}
1063
+ function done() //{{{
1064
+ {
1065
+ animMode(false);
1066
+ refresh();
1067
+ }
1068
+ //}}}
1069
+ // Insert draggable elements {{{
1070
+ // Insert border divs for outline
1071
+
1072
+ if (options.dragEdges && $.isArray(options.createDragbars))
1073
+ createDragbars(options.createDragbars);
1074
+
1075
+ if ($.isArray(options.createHandles))
1076
+ createHandles(options.createHandles);
1077
+
1078
+ if (options.drawBorders && $.isArray(options.createBorders))
1079
+ createBorders(options.createBorders);
1080
+
1081
+ //}}}
1082
+
1083
+ // This is a hack for iOS5 to support drag/move touch functionality
1084
+ $(document).bind('touchstart.jcrop-ios',function(e) {
1085
+ if ($(e.currentTarget).hasClass('jcrop-tracker')) e.stopPropagation();
1086
+ });
1087
+
1088
+ var $track = newTracker().mousedown(createDragger('move')).css({
1089
+ cursor: 'move',
1090
+ position: 'absolute',
1091
+ zIndex: 360
1092
+ });
1093
+
1094
+ if (Touch.support) {
1095
+ $track.bind('touchstart.jcrop', Touch.createDragger('move'));
1096
+ }
1097
+
1098
+ $img_holder.append($track);
1099
+ disableHandles();
1100
+
1101
+ return {
1102
+ updateVisible: updateVisible,
1103
+ update: update,
1104
+ release: release,
1105
+ refresh: refresh,
1106
+ isAwake: function () {
1107
+ return awake;
1108
+ },
1109
+ setCursor: function (cursor) {
1110
+ $track.css('cursor', cursor);
1111
+ },
1112
+ enableHandles: enableHandles,
1113
+ enableOnly: function () {
1114
+ seehandles = true;
1115
+ },
1116
+ showHandles: showHandles,
1117
+ disableHandles: disableHandles,
1118
+ animMode: animMode,
1119
+ setBgOpacity: setBgOpacity,
1120
+ done: done
1121
+ };
1122
+ }());
1123
+
1124
+ //}}}
1125
+ // Tracker Module {{{
1126
+ var Tracker = (function () {
1127
+ var onMove = function () {},
1128
+ onDone = function () {},
1129
+ trackDoc = options.trackDocument;
1130
+
1131
+ function toFront(touch) //{{{
1132
+ {
1133
+ $trk.css({
1134
+ zIndex: 450
1135
+ });
1136
+
1137
+ if (touch)
1138
+ $(document)
1139
+ .bind('touchmove.jcrop', trackTouchMove)
1140
+ .bind('touchend.jcrop', trackTouchEnd);
1141
+
1142
+ else if (trackDoc)
1143
+ $(document)
1144
+ .bind('mousemove.jcrop',trackMove)
1145
+ .bind('mouseup.jcrop',trackUp);
1146
+ }
1147
+ //}}}
1148
+ function toBack() //{{{
1149
+ {
1150
+ $trk.css({
1151
+ zIndex: 290
1152
+ });
1153
+ // Monkey patch, see https://github.com/tapmodo/Jcrop/issues/79
1154
+ //$(document).unbind('.jcrop');
1155
+ $(document).unbind('touchmove.jcrop');
1156
+ $(document).unbind('touchend.jcrop');
1157
+ $(document).unbind('mousemove.jcrop');
1158
+ $(document).unbind('mouseup.jcrop');
1159
+ }
1160
+ //}}}
1161
+ function trackMove(e) //{{{
1162
+ {
1163
+ onMove(mouseAbs(e));
1164
+ return false;
1165
+ }
1166
+ //}}}
1167
+ function trackUp(e) //{{{
1168
+ {
1169
+ e.preventDefault();
1170
+ e.stopPropagation();
1171
+
1172
+ if (btndown) {
1173
+ btndown = false;
1174
+
1175
+ onDone(mouseAbs(e));
1176
+
1177
+ if (Selection.isAwake()) {
1178
+ options.onSelect.call(api, unscale(Coords.getFixed()));
1179
+ }
1180
+
1181
+ toBack();
1182
+ onMove = function () {};
1183
+ onDone = function () {};
1184
+ }
1185
+
1186
+ return false;
1187
+ }
1188
+ //}}}
1189
+ function activateHandlers(move, done, touch) //{{{
1190
+ {
1191
+ btndown = true;
1192
+ onMove = move;
1193
+ onDone = done;
1194
+ toFront(touch);
1195
+ return false;
1196
+ }
1197
+ //}}}
1198
+ function trackTouchMove(e) //{{{
1199
+ {
1200
+ onMove(mouseAbs(Touch.cfilter(e)));
1201
+ return false;
1202
+ }
1203
+ //}}}
1204
+ function trackTouchEnd(e) //{{{
1205
+ {
1206
+ return trackUp(Touch.cfilter(e));
1207
+ }
1208
+ //}}}
1209
+ function setCursor(t) //{{{
1210
+ {
1211
+ $trk.css('cursor', t);
1212
+ }
1213
+ //}}}
1214
+
1215
+ if (!trackDoc) {
1216
+ $trk.mousemove(trackMove).mouseup(trackUp).mouseout(trackUp);
1217
+ }
1218
+
1219
+ $img.before($trk);
1220
+ return {
1221
+ activateHandlers: activateHandlers,
1222
+ setCursor: setCursor
1223
+ };
1224
+ }());
1225
+ //}}}
1226
+ // KeyManager Module {{{
1227
+ var KeyManager = (function () {
1228
+ var $keymgr = $('<input type="radio" />').css({
1229
+ position: 'fixed',
1230
+ left: '-120px',
1231
+ width: '12px'
1232
+ }).addClass('jcrop-keymgr'),
1233
+
1234
+ $keywrap = $('<div />').css({
1235
+ position: 'absolute',
1236
+ overflow: 'hidden'
1237
+ }).append($keymgr);
1238
+
1239
+ function watchKeys() //{{{
1240
+ {
1241
+ if (options.keySupport) {
1242
+ $keymgr.show();
1243
+ $keymgr.focus();
1244
+ }
1245
+ }
1246
+ //}}}
1247
+ function onBlur(e) //{{{
1248
+ {
1249
+ $keymgr.hide();
1250
+ }
1251
+ //}}}
1252
+ function doNudge(e, x, y) //{{{
1253
+ {
1254
+ if (options.allowMove) {
1255
+ Coords.moveOffset([x, y]);
1256
+ Selection.updateVisible(true);
1257
+ }
1258
+ e.preventDefault();
1259
+ e.stopPropagation();
1260
+ }
1261
+ //}}}
1262
+ function parseKey(e) //{{{
1263
+ {
1264
+ if (e.ctrlKey || e.metaKey) {
1265
+ return true;
1266
+ }
1267
+ shift_down = e.shiftKey ? true : false;
1268
+ var nudge = shift_down ? 10 : 1;
1269
+
1270
+ switch (e.keyCode) {
1271
+ case 37:
1272
+ doNudge(e, -nudge, 0);
1273
+ break;
1274
+ case 39:
1275
+ doNudge(e, nudge, 0);
1276
+ break;
1277
+ case 38:
1278
+ doNudge(e, 0, -nudge);
1279
+ break;
1280
+ case 40:
1281
+ doNudge(e, 0, nudge);
1282
+ break;
1283
+ case 27:
1284
+ if (options.allowSelect) Selection.release();
1285
+ break;
1286
+ case 9:
1287
+ return true;
1288
+ }
1289
+
1290
+ return false;
1291
+ }
1292
+ //}}}
1293
+
1294
+ if (options.keySupport) {
1295
+ $keymgr.keydown(parseKey).blur(onBlur);
1296
+ if (ie6mode || !options.fixedSupport) {
1297
+ $keymgr.css({
1298
+ position: 'absolute',
1299
+ left: '-20px'
1300
+ });
1301
+ $keywrap.append($keymgr).insertBefore($img);
1302
+ } else {
1303
+ $keymgr.insertBefore($img);
1304
+ }
1305
+ }
1306
+
1307
+
1308
+ return {
1309
+ watchKeys: watchKeys
1310
+ };
1311
+ }());
1312
+ //}}}
1313
+ // }}}
1314
+ // API methods {{{
1315
+ function setClass(cname) //{{{
1316
+ {
1317
+ $div.removeClass().addClass(cssClass('holder')).addClass(cname);
1318
+ }
1319
+ //}}}
1320
+ function animateTo(a, callback) //{{{
1321
+ {
1322
+ var x1 = a[0] / xscale,
1323
+ y1 = a[1] / yscale,
1324
+ x2 = a[2] / xscale,
1325
+ y2 = a[3] / yscale;
1326
+
1327
+ if (animating) {
1328
+ return;
1329
+ }
1330
+
1331
+ var animto = Coords.flipCoords(x1, y1, x2, y2),
1332
+ c = Coords.getFixed(),
1333
+ initcr = [c.x, c.y, c.x2, c.y2],
1334
+ animat = initcr,
1335
+ interv = options.animationDelay,
1336
+ ix1 = animto[0] - initcr[0],
1337
+ iy1 = animto[1] - initcr[1],
1338
+ ix2 = animto[2] - initcr[2],
1339
+ iy2 = animto[3] - initcr[3],
1340
+ pcent = 0,
1341
+ velocity = options.swingSpeed;
1342
+
1343
+ x1 = animat[0];
1344
+ y1 = animat[1];
1345
+ x2 = animat[2];
1346
+ y2 = animat[3];
1347
+
1348
+ Selection.animMode(true);
1349
+ var anim_timer;
1350
+
1351
+ function queueAnimator() {
1352
+ window.setTimeout(animator, interv);
1353
+ }
1354
+ var animator = (function () {
1355
+ return function () {
1356
+ pcent += (100 - pcent) / velocity;
1357
+
1358
+ animat[0] = Math.round(x1 + ((pcent / 100) * ix1));
1359
+ animat[1] = Math.round(y1 + ((pcent / 100) * iy1));
1360
+ animat[2] = Math.round(x2 + ((pcent / 100) * ix2));
1361
+ animat[3] = Math.round(y2 + ((pcent / 100) * iy2));
1362
+
1363
+ if (pcent >= 99.8) {
1364
+ pcent = 100;
1365
+ }
1366
+ if (pcent < 100) {
1367
+ setSelectRaw(animat);
1368
+ queueAnimator();
1369
+ } else {
1370
+ Selection.done();
1371
+ Selection.animMode(false);
1372
+ if (typeof(callback) === 'function') {
1373
+ callback.call(api);
1374
+ }
1375
+ }
1376
+ };
1377
+ }());
1378
+ queueAnimator();
1379
+ }
1380
+ //}}}
1381
+ function setSelect(rect) //{{{
1382
+ {
1383
+ setSelectRaw([rect[0] / xscale, rect[1] / yscale, rect[2] / xscale, rect[3] / yscale]);
1384
+ options.onSelect.call(api, unscale(Coords.getFixed()));
1385
+ Selection.enableHandles();
1386
+ }
1387
+ //}}}
1388
+ function setSelectRaw(l) //{{{
1389
+ {
1390
+ Coords.setPressed([l[0], l[1]]);
1391
+ Coords.setCurrent([l[2], l[3]]);
1392
+ Selection.update();
1393
+ }
1394
+ //}}}
1395
+ function tellSelect() //{{{
1396
+ {
1397
+ return unscale(Coords.getFixed());
1398
+ }
1399
+ //}}}
1400
+ function tellScaled() //{{{
1401
+ {
1402
+ return Coords.getFixed();
1403
+ }
1404
+ //}}}
1405
+ function setOptionsNew(opt) //{{{
1406
+ {
1407
+ setOptions(opt);
1408
+ interfaceUpdate();
1409
+ }
1410
+ //}}}
1411
+ function disableCrop() //{{{
1412
+ {
1413
+ options.disabled = true;
1414
+ Selection.disableHandles();
1415
+ Selection.setCursor('default');
1416
+ Tracker.setCursor('default');
1417
+ }
1418
+ //}}}
1419
+ function enableCrop() //{{{
1420
+ {
1421
+ options.disabled = false;
1422
+ interfaceUpdate();
1423
+ }
1424
+ //}}}
1425
+ function cancelCrop() //{{{
1426
+ {
1427
+ Selection.done();
1428
+ Tracker.activateHandlers(null, null);
1429
+ }
1430
+ //}}}
1431
+ function destroy() //{{{
1432
+ {
1433
+ $div.remove();
1434
+ $origimg.show();
1435
+ $origimg.css('visibility','visible');
1436
+ $(obj).removeData('Jcrop');
1437
+ }
1438
+ //}}}
1439
+ function setImage(src, callback) //{{{
1440
+ {
1441
+ Selection.release();
1442
+ disableCrop();
1443
+ var img = new Image();
1444
+ img.onload = function () {
1445
+ var iw = img.width;
1446
+ var ih = img.height;
1447
+ var bw = options.boxWidth;
1448
+ var bh = options.boxHeight;
1449
+ $img.width(iw).height(ih);
1450
+ $img.attr('src', src);
1451
+ $img2.attr('src', src);
1452
+ presize($img, bw, bh);
1453
+ boundx = $img.width();
1454
+ boundy = $img.height();
1455
+ $img2.width(boundx).height(boundy);
1456
+ $trk.width(boundx + (bound * 2)).height(boundy + (bound * 2));
1457
+ $div.width(boundx).height(boundy);
1458
+ Shade.resize(boundx,boundy);
1459
+ enableCrop();
1460
+
1461
+ if (typeof(callback) === 'function') {
1462
+ callback.call(api);
1463
+ }
1464
+ };
1465
+ img.src = src;
1466
+ }
1467
+ //}}}
1468
+ function colorChangeMacro($obj,color,now) {
1469
+ var mycolor = color || options.bgColor;
1470
+ if (options.bgFade && supportsColorFade() && options.fadeTime && !now) {
1471
+ $obj.animate({
1472
+ backgroundColor: mycolor
1473
+ }, {
1474
+ queue: false,
1475
+ duration: options.fadeTime
1476
+ });
1477
+ } else {
1478
+ $obj.css('backgroundColor', mycolor);
1479
+ }
1480
+ }
1481
+ function interfaceUpdate(alt) //{{{
1482
+ // This method tweaks the interface based on options object.
1483
+ // Called when options are changed and at end of initialization.
1484
+ {
1485
+ if (options.allowResize) {
1486
+ if (alt) {
1487
+ Selection.enableOnly();
1488
+ } else {
1489
+ Selection.enableHandles();
1490
+ }
1491
+ } else {
1492
+ Selection.disableHandles();
1493
+ }
1494
+
1495
+ Tracker.setCursor(options.allowSelect ? 'crosshair' : 'default');
1496
+ Selection.setCursor(options.allowMove ? 'move' : 'default');
1497
+
1498
+ if (options.hasOwnProperty('trueSize')) {
1499
+ xscale = options.trueSize[0] / boundx;
1500
+ yscale = options.trueSize[1] / boundy;
1501
+ }
1502
+
1503
+ if (options.hasOwnProperty('setSelect')) {
1504
+ setSelect(options.setSelect);
1505
+ Selection.done();
1506
+ delete(options.setSelect);
1507
+ }
1508
+
1509
+ Shade.refresh();
1510
+
1511
+ if (options.bgColor != bgcolor) {
1512
+ colorChangeMacro(
1513
+ options.shade? Shade.getShades(): $div,
1514
+ options.shade?
1515
+ (options.shadeColor || options.bgColor):
1516
+ options.bgColor
1517
+ );
1518
+ bgcolor = options.bgColor;
1519
+ }
1520
+
1521
+ if (bgopacity != options.bgOpacity) {
1522
+ bgopacity = options.bgOpacity;
1523
+ if (options.shade) Shade.refresh();
1524
+ else Selection.setBgOpacity(bgopacity);
1525
+ }
1526
+
1527
+ xlimit = options.maxSize[0] || 0;
1528
+ ylimit = options.maxSize[1] || 0;
1529
+ xmin = options.minSize[0] || 0;
1530
+ ymin = options.minSize[1] || 0;
1531
+
1532
+ if (options.hasOwnProperty('outerImage')) {
1533
+ $img.attr('src', options.outerImage);
1534
+ delete(options.outerImage);
1535
+ }
1536
+
1537
+ Selection.refresh();
1538
+ }
1539
+ //}}}
1540
+ //}}}
1541
+
1542
+ if (Touch.support) $trk.bind('touchstart.jcrop', Touch.newSelection);
1543
+
1544
+ $hdl_holder.hide();
1545
+ interfaceUpdate(true);
1546
+
1547
+ var api = {
1548
+ setImage: setImage,
1549
+ animateTo: animateTo,
1550
+ setSelect: setSelect,
1551
+ setOptions: setOptionsNew,
1552
+ tellSelect: tellSelect,
1553
+ tellScaled: tellScaled,
1554
+ setClass: setClass,
1555
+
1556
+ disable: disableCrop,
1557
+ enable: enableCrop,
1558
+ cancel: cancelCrop,
1559
+ release: Selection.release,
1560
+ destroy: destroy,
1561
+
1562
+ focus: KeyManager.watchKeys,
1563
+
1564
+ getBounds: function () {
1565
+ return [boundx * xscale, boundy * yscale];
1566
+ },
1567
+ getWidgetSize: function () {
1568
+ return [boundx, boundy];
1569
+ },
1570
+ getScaleFactor: function () {
1571
+ return [xscale, yscale];
1572
+ },
1573
+ getOptions: function() {
1574
+ // careful: internal values are returned
1575
+ return options;
1576
+ },
1577
+
1578
+ ui: {
1579
+ holder: $div,
1580
+ selection: $sel
1581
+ }
1582
+ };
1583
+
1584
+ if (is_msie) $div.bind('selectstart', function () { return false; });
1585
+
1586
+ $origimg.data('Jcrop', api);
1587
+ return api;
1588
+ };
1589
+ $.fn.Jcrop = function (options, callback) //{{{
1590
+ {
1591
+ var api;
1592
+ // Iterate over each object, attach Jcrop
1593
+ this.each(function () {
1594
+ // If we've already attached to this object
1595
+ if ($(this).data('Jcrop')) {
1596
+ // The API can be requested this way (undocumented)
1597
+ if (options === 'api') return $(this).data('Jcrop');
1598
+ // Otherwise, we just reset the options...
1599
+ else $(this).data('Jcrop').setOptions(options);
1600
+ }
1601
+ // If we haven't been attached, preload and attach
1602
+ else {
1603
+ if (this.tagName == 'IMG')
1604
+ $.Jcrop.Loader(this,function(){
1605
+ $(this).css({display:'block',visibility:'hidden'});
1606
+ api = $.Jcrop(this, options);
1607
+ if ($.isFunction(callback)) callback.call(api);
1608
+ });
1609
+ else {
1610
+ $(this).css({display:'block',visibility:'hidden'});
1611
+ api = $.Jcrop(this, options);
1612
+ if ($.isFunction(callback)) callback.call(api);
1613
+ }
1614
+ }
1615
+ });
1616
+
1617
+ // Return "this" so the object is chainable (jQuery-style)
1618
+ return this;
1619
+ };
1620
+ //}}}
1621
+ // $.Jcrop.Loader - basic image loader {{{
1622
+
1623
+ $.Jcrop.Loader = function(imgobj,success,error){
1624
+ var $img = $(imgobj), img = $img[0];
1625
+
1626
+ function completeCheck(){
1627
+ if (img.complete) {
1628
+ $img.unbind('.jcloader');
1629
+ if ($.isFunction(success)) success.call(img);
1630
+ }
1631
+ else window.setTimeout(completeCheck,50);
1632
+ }
1633
+
1634
+ $img
1635
+ .bind('load.jcloader',completeCheck)
1636
+ .bind('error.jcloader',function(e){
1637
+ $img.unbind('.jcloader');
1638
+ if ($.isFunction(error)) error.call(img);
1639
+ });
1640
+
1641
+ if (img.complete && $.isFunction(success)){
1642
+ $img.unbind('.jcloader');
1643
+ success.call(img);
1644
+ }
1645
+ };
1646
+
1647
+ //}}}
1648
+ // Global Defaults {{{
1649
+ $.Jcrop.defaults = {
1650
+
1651
+ // Basic Settings
1652
+ allowSelect: true,
1653
+ allowMove: true,
1654
+ allowResize: true,
1655
+
1656
+ trackDocument: true,
1657
+
1658
+ // Styling Options
1659
+ baseClass: 'jcrop',
1660
+ addClass: null,
1661
+ bgColor: 'black',
1662
+ bgOpacity: 0.6,
1663
+ bgFade: false,
1664
+ borderOpacity: 0.4,
1665
+ handleOpacity: 0.5,
1666
+ handleSize: null,
1667
+
1668
+ aspectRatio: 0,
1669
+ keySupport: true,
1670
+ createHandles: ['n','s','e','w','nw','ne','se','sw'],
1671
+ createDragbars: ['n','s','e','w'],
1672
+ createBorders: ['n','s','e','w'],
1673
+ drawBorders: true,
1674
+ dragEdges: true,
1675
+ fixedSupport: true,
1676
+ touchSupport: null,
1677
+
1678
+ shade: null,
1679
+
1680
+ boxWidth: 0,
1681
+ boxHeight: 0,
1682
+ boundary: 2,
1683
+ fadeTime: 400,
1684
+ animationDelay: 20,
1685
+ swingSpeed: 3,
1686
+
1687
+ minSelect: [0, 0],
1688
+ maxSize: [0, 0],
1689
+ minSize: [0, 0],
1690
+
1691
+ // Callbacks / Event Handlers
1692
+ onChange: function () {},
1693
+ onSelect: function () {},
1694
+ onDblClick: function () {},
1695
+ onRelease: function () {}
1696
+ };
1697
+
1698
+ // }}}
1699
+ }(jQuery));