rails_marketplace 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/rails_marketplace/application.js +46 -0
  6. data/app/assets/javascripts/rails_marketplace/catalog.coffee +3 -0
  7. data/app/assets/javascripts/rails_marketplace/flash.js +6 -0
  8. data/app/assets/javascripts/rails_marketplace/footermanifest.js +1 -0
  9. data/app/assets/javascripts/rails_marketplace/js/autocomplete/countries.js +267 -0
  10. data/app/assets/javascripts/rails_marketplace/js/autocomplete/jquery.autocomplete.js +986 -0
  11. data/app/assets/javascripts/rails_marketplace/js/bootstrap.min.js +7 -0
  12. data/app/assets/javascripts/rails_marketplace/js/calendar/fullcalendar.min.js +9 -0
  13. data/app/assets/javascripts/rails_marketplace/js/chartjs/chart.min.js +14 -0
  14. data/app/assets/javascripts/rails_marketplace/js/colorpicker/bootstrap-colorpicker.min.js +1087 -0
  15. data/app/assets/javascripts/rails_marketplace/js/colorpicker/docs.js +17 -0
  16. data/app/assets/javascripts/rails_marketplace/js/cropping/cropper.min.js +10 -0
  17. data/app/assets/javascripts/rails_marketplace/js/cropping/main.js +321 -0
  18. data/app/assets/javascripts/rails_marketplace/js/cropping/main2.js +160 -0
  19. data/app/assets/javascripts/rails_marketplace/js/custom.js +380 -0
  20. data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.bootstrap.min.css +1 -0
  21. data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.bootstrap.min.js +6 -0
  22. data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.html5.min.js +22 -0
  23. data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.print.min.js +4 -0
  24. data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.bootstrap.js +8 -0
  25. data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.buttons.min.js +36 -0
  26. data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.fixedHeader.min.js +17 -0
  27. data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.keyTable.min.js +18 -0
  28. data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.responsive.min.js +25 -0
  29. data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.scroller.min.js +26 -0
  30. data/app/assets/javascripts/rails_marketplace/js/datatables/fixedHeader.bootstrap.min.css +1 -0
  31. data/app/assets/javascripts/rails_marketplace/js/datatables/jquery.dataTables.min.css +333 -0
  32. data/app/assets/javascripts/rails_marketplace/js/datatables/jquery.dataTables.min.js +166 -0
  33. data/app/assets/javascripts/rails_marketplace/js/datatables/json/scroller-demo.json +2502 -0
  34. data/app/assets/javascripts/rails_marketplace/js/datatables/jszip.min.js +14 -0
  35. data/app/assets/javascripts/rails_marketplace/js/datatables/pdfmake.min.js +22 -0
  36. data/app/assets/javascripts/rails_marketplace/js/datatables/responsive.bootstrap.min.css +1 -0
  37. data/app/assets/javascripts/rails_marketplace/js/datatables/responsive.bootstrap.min.js +7 -0
  38. data/app/assets/javascripts/rails_marketplace/js/datatables/scroller.bootstrap.min.css +1 -0
  39. data/app/assets/javascripts/rails_marketplace/js/datatables/vfs_fonts.js +1 -0
  40. data/app/assets/javascripts/rails_marketplace/js/datepicker/daterangepicker.js +1 -0
  41. data/app/assets/javascripts/rails_marketplace/js/dropzone/dropzone.js +2 -0
  42. data/app/assets/javascripts/rails_marketplace/js/easypie/jquery.easypiechart.min.js +9 -0
  43. data/app/assets/javascripts/rails_marketplace/js/echart/echarts-all.js +35 -0
  44. data/app/assets/javascripts/rails_marketplace/js/echart/green.js +212 -0
  45. data/app/assets/javascripts/rails_marketplace/js/editor/bootstrap-wysiwyg.js +200 -0
  46. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-apollo.js +2 -0
  47. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-basic.js +3 -0
  48. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-clj.js +18 -0
  49. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-css.js +2 -0
  50. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-dart.js +3 -0
  51. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-erlang.js +2 -0
  52. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-go.js +1 -0
  53. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-hs.js +2 -0
  54. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-lisp.js +3 -0
  55. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-llvm.js +1 -0
  56. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-lua.js +2 -0
  57. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-matlab.js +6 -0
  58. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-ml.js +2 -0
  59. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-mumps.js +2 -0
  60. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-n.js +4 -0
  61. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-pascal.js +3 -0
  62. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-proto.js +1 -0
  63. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-r.js +2 -0
  64. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-rd.js +1 -0
  65. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-scala.js +2 -0
  66. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-sql.js +2 -0
  67. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-tcl.js +3 -0
  68. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-tex.js +1 -0
  69. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-vb.js +2 -0
  70. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-vhdl.js +3 -0
  71. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-wiki.js +2 -0
  72. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-xq.js +3 -0
  73. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-yaml.js +2 -0
  74. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/prettify.js +30 -0
  75. data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/run_prettify.js +34 -0
  76. data/app/assets/javascripts/rails_marketplace/js/editor/external/jquery.hotkeys.js +100 -0
  77. data/app/assets/javascripts/rails_marketplace/js/flot/curvedLines.js +483 -0
  78. data/app/assets/javascripts/rails_marketplace/js/flot/date.js +104 -0
  79. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.js +2 -0
  80. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.orderBars.js +201 -0
  81. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.pie.js +820 -0
  82. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.resize.js +57 -0
  83. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.spline.js +212 -0
  84. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.stack.js +188 -0
  85. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.time.min.js +1 -0
  86. data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.tooltip.min.js +12 -0
  87. data/app/assets/javascripts/rails_marketplace/js/gauge/gauge.min.js +1 -0
  88. data/app/assets/javascripts/rails_marketplace/js/gauge/gauge_demo.js +21 -0
  89. data/app/assets/javascripts/rails_marketplace/js/icheck/icheck.min.js +11 -0
  90. data/app/assets/javascripts/rails_marketplace/js/input_mask/jquery.inputmask.js +2 -0
  91. data/app/assets/javascripts/rails_marketplace/js/ion_range/ion.rangeSlider.min.js +66 -0
  92. data/app/assets/javascripts/rails_marketplace/js/jquery.min.js +5 -0
  93. data/app/assets/javascripts/rails_marketplace/js/knob/jquery.knob.min.js +1 -0
  94. data/app/assets/javascripts/rails_marketplace/js/maps/gdp-data.js +185 -0
  95. data/app/assets/javascripts/rails_marketplace/js/maps/jquery-jvectormap-2.0.3.min.js +2 -0
  96. data/app/assets/javascripts/rails_marketplace/js/maps/jquery-jvectormap-us-aea-en.js +1 -0
  97. data/app/assets/javascripts/rails_marketplace/js/maps/jquery-jvectormap-world-mill-en.js +1 -0
  98. data/app/assets/javascripts/rails_marketplace/js/maps/us-unemployment.json +1 -0
  99. data/app/assets/javascripts/rails_marketplace/js/moment/moment.min.js +7 -0
  100. data/app/assets/javascripts/rails_marketplace/js/moris/example.js +127 -0
  101. data/app/assets/javascripts/rails_marketplace/js/moris/morris.min.js +7 -0
  102. data/app/assets/javascripts/rails_marketplace/js/moris/raphael-min.js +11 -0
  103. data/app/assets/javascripts/rails_marketplace/js/notify/pnotify.buttons.js +132 -0
  104. data/app/assets/javascripts/rails_marketplace/js/notify/pnotify.core.js +1 -0
  105. data/app/assets/javascripts/rails_marketplace/js/notify/pnotify.nonblock.js +151 -0
  106. data/app/assets/javascripts/rails_marketplace/js/nprogress.js +476 -0
  107. data/app/assets/javascripts/rails_marketplace/js/pace/pace.min.js +2 -0
  108. data/app/assets/javascripts/rails_marketplace/js/parsley/parsley.min.js +9 -0
  109. data/app/assets/javascripts/rails_marketplace/js/progressbar/bootstrap-progressbar.min.js +2 -0
  110. data/app/assets/javascripts/rails_marketplace/js/select/select2.full.js +2 -0
  111. data/app/assets/javascripts/rails_marketplace/js/sidebar/classie.js +80 -0
  112. data/app/assets/javascripts/rails_marketplace/js/sidebar/component.css +569 -0
  113. data/app/assets/javascripts/rails_marketplace/js/sidebar/modernizr.custom.js +4 -0
  114. data/app/assets/javascripts/rails_marketplace/js/sidebar/sidebarEffects.js +63 -0
  115. data/app/assets/javascripts/rails_marketplace/js/skycons/skycons.min.js +1 -0
  116. data/app/assets/javascripts/rails_marketplace/js/sparkline/jquery.sparkline.min.js +5 -0
  117. data/app/assets/javascripts/rails_marketplace/js/switchery/switchery.min.js +1 -0
  118. data/app/assets/javascripts/rails_marketplace/js/tags/jquery.tagsinput.min.js +1 -0
  119. data/app/assets/javascripts/rails_marketplace/js/textarea/autosize.min.js +6 -0
  120. data/app/assets/javascripts/rails_marketplace/js/validator/validator.js +411 -0
  121. data/app/assets/javascripts/rails_marketplace/js/wizard/jquery.smartWizard.js +489 -0
  122. data/app/assets/javascripts/rails_marketplace/less/custom.css +6355 -0
  123. data/app/assets/javascripts/rails_marketplace/marketplace.js +17 -0
  124. data/app/assets/javascripts/rails_marketplace/welcome.coffee +3 -0
  125. data/app/assets/stylesheets/rails_marketplace/application.scss +31 -0
  126. data/app/assets/stylesheets/rails_marketplace/catalog.scss +132 -0
  127. data/app/assets/stylesheets/rails_marketplace/css/animate.min.css +11 -0
  128. data/app/assets/stylesheets/rails_marketplace/css/bootstrap.min.css +6 -0
  129. data/app/assets/stylesheets/rails_marketplace/css/calendar/fullcalendar.css +1116 -0
  130. data/app/assets/stylesheets/rails_marketplace/css/calendar/fullcalendar.min.css +5 -0
  131. data/app/assets/stylesheets/rails_marketplace/css/calendar/fullcalendar.print.css +208 -0
  132. data/app/assets/stylesheets/rails_marketplace/css/colorpicker/bootstrap-colorpicker.min.css +9 -0
  133. data/app/assets/stylesheets/rails_marketplace/css/colorpicker/img/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  134. data/app/assets/stylesheets/rails_marketplace/css/colorpicker/img/bootstrap-colorpicker/alpha.png +0 -0
  135. data/app/assets/stylesheets/rails_marketplace/css/colorpicker/img/bootstrap-colorpicker/hue-horizontal.png +0 -0
  136. data/app/assets/stylesheets/rails_marketplace/css/colorpicker/img/bootstrap-colorpicker/hue.png +0 -0
  137. data/app/assets/stylesheets/rails_marketplace/css/colorpicker/img/bootstrap-colorpicker/saturation.png +0 -0
  138. data/app/assets/stylesheets/rails_marketplace/css/custom.css +5347 -0
  139. data/app/assets/stylesheets/rails_marketplace/css/datatables/css/demo_page.css +103 -0
  140. data/app/assets/stylesheets/rails_marketplace/css/datatables/css/demo_table.css +258 -0
  141. data/app/assets/stylesheets/rails_marketplace/css/datatables/css/demo_table_jui.css +501 -0
  142. data/app/assets/stylesheets/rails_marketplace/css/datatables/css/jquery.dataTables.css +221 -0
  143. data/app/assets/stylesheets/rails_marketplace/css/datatables/css/jquery.dataTables_themeroller.css +244 -0
  144. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/Sorting icons.psd +0 -0
  145. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/back_disabled.png +0 -0
  146. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/back_enabled.png +0 -0
  147. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/back_enabled_hover.png +0 -0
  148. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/favicon.ico +0 -0
  149. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/forward_disabled.png +0 -0
  150. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/forward_enabled.png +0 -0
  151. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/forward_enabled_hover.png +0 -0
  152. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/sort_asc.png +0 -0
  153. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/sort_asc_disabled.png +0 -0
  154. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/sort_both.png +0 -0
  155. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/sort_desc.png +0 -0
  156. data/app/assets/stylesheets/rails_marketplace/css/datatables/images/sort_desc_disabled.png +0 -0
  157. data/app/assets/stylesheets/rails_marketplace/css/datatables/tools/css/dataTables.tableTools.css +336 -0
  158. data/app/assets/stylesheets/rails_marketplace/css/editor/external/google-code-prettify/prettify.css +1 -0
  159. data/app/assets/stylesheets/rails_marketplace/css/editor/index.css +42 -0
  160. data/app/assets/stylesheets/rails_marketplace/css/floatexamples.css +22 -0
  161. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/_all.css +530 -0
  162. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/aero.css +53 -0
  163. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/aero.png +0 -0
  164. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/aero@2x.png +0 -0
  165. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/blue.css +53 -0
  166. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/blue.png +0 -0
  167. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/blue@2x.png +0 -0
  168. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/flat.css +53 -0
  169. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/flat.png +0 -0
  170. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/flat@2x.png +0 -0
  171. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/green.css +53 -0
  172. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/green.png +0 -0
  173. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/green@2x.png +0 -0
  174. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/grey.css +53 -0
  175. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/grey.png +0 -0
  176. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/grey@2x.png +0 -0
  177. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/orange.css +53 -0
  178. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/orange.png +0 -0
  179. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/orange@2x.png +0 -0
  180. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/pink.css +53 -0
  181. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/pink.png +0 -0
  182. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/pink@2x.png +0 -0
  183. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/purple.css +53 -0
  184. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/purple.png +0 -0
  185. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/purple@2x.png +0 -0
  186. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/red.css +53 -0
  187. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/red.png +0 -0
  188. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/red@2x.png +0 -0
  189. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/yellow.css +53 -0
  190. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/yellow.png +0 -0
  191. data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/yellow@2x.png +0 -0
  192. data/app/assets/stylesheets/rails_marketplace/css/ion.rangeSlider.css +146 -0
  193. data/app/assets/stylesheets/rails_marketplace/css/ion.rangeSlider.skinFlat.css +106 -0
  194. data/app/assets/stylesheets/rails_marketplace/css/maps/jquery-jvectormap-2.0.3.css +135 -0
  195. data/app/assets/stylesheets/rails_marketplace/css/normalize.css +421 -0
  196. data/app/assets/stylesheets/rails_marketplace/css/nprogress.css +74 -0
  197. data/app/assets/stylesheets/rails_marketplace/css/progressbar/bootstrap-progressbar-3.3.0.css +161 -0
  198. data/app/assets/stylesheets/rails_marketplace/css/select/select2.min.css +404 -0
  199. data/app/assets/stylesheets/rails_marketplace/css/switchery/switchery.min.css +1 -0
  200. data/app/assets/stylesheets/rails_marketplace/fonts/css/font-awesome.css +2086 -0
  201. data/app/assets/stylesheets/rails_marketplace/fonts/css/font-awesome.min.css +4 -0
  202. data/app/assets/stylesheets/rails_marketplace/fonts/fonts/FontAwesome.otf +0 -0
  203. data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.eot +0 -0
  204. data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.svg +655 -0
  205. data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.ttf +0 -0
  206. data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.woff +0 -0
  207. data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.woff2 +0 -0
  208. data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.eot +0 -0
  209. data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.svg +288 -0
  210. data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.ttf +0 -0
  211. data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.woff +0 -0
  212. data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.woff2 +0 -0
  213. data/app/assets/stylesheets/rails_marketplace/fonts/less/animated.less +34 -0
  214. data/app/assets/stylesheets/rails_marketplace/fonts/less/bordered-pulled.less +25 -0
  215. data/app/assets/stylesheets/rails_marketplace/fonts/less/core.less +12 -0
  216. data/app/assets/stylesheets/rails_marketplace/fonts/less/fixed-width.less +6 -0
  217. data/app/assets/stylesheets/rails_marketplace/fonts/less/font-awesome.less +17 -0
  218. data/app/assets/stylesheets/rails_marketplace/fonts/less/icons.less +697 -0
  219. data/app/assets/stylesheets/rails_marketplace/fonts/less/larger.less +13 -0
  220. data/app/assets/stylesheets/rails_marketplace/fonts/less/list.less +19 -0
  221. data/app/assets/stylesheets/rails_marketplace/fonts/less/mixins.less +26 -0
  222. data/app/assets/stylesheets/rails_marketplace/fonts/less/path.less +15 -0
  223. data/app/assets/stylesheets/rails_marketplace/fonts/less/rotated-flipped.less +20 -0
  224. data/app/assets/stylesheets/rails_marketplace/fonts/less/spinning.less +29 -0
  225. data/app/assets/stylesheets/rails_marketplace/fonts/less/stacked.less +20 -0
  226. data/app/assets/stylesheets/rails_marketplace/fonts/less/variables.less +708 -0
  227. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_animated.scss +34 -0
  228. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_bordered-pulled.scss +25 -0
  229. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_core.scss +12 -0
  230. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_fixed-width.scss +6 -0
  231. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_icons.scss +697 -0
  232. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_larger.scss +13 -0
  233. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_list.scss +19 -0
  234. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_mixins.scss +26 -0
  235. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_path.scss +15 -0
  236. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_rotated-flipped.scss +20 -0
  237. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_spinning.scss +29 -0
  238. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_stacked.scss +20 -0
  239. data/app/assets/stylesheets/rails_marketplace/fonts/scss/_variables.scss +708 -0
  240. data/app/assets/stylesheets/rails_marketplace/fonts/scss/font-awesome.scss +17 -0
  241. data/app/assets/stylesheets/rails_marketplace/images/1.png +0 -0
  242. data/app/assets/stylesheets/rails_marketplace/images/4.jpg +0 -0
  243. data/app/assets/stylesheets/rails_marketplace/images/american-express.png +0 -0
  244. data/app/assets/stylesheets/rails_marketplace/images/back_disabled.png +0 -0
  245. data/app/assets/stylesheets/rails_marketplace/images/back_enabled.png +0 -0
  246. data/app/assets/stylesheets/rails_marketplace/images/back_enabled_hover.png +0 -0
  247. data/app/assets/stylesheets/rails_marketplace/images/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  248. data/app/assets/stylesheets/rails_marketplace/images/bootstrap-colorpicker/alpha.png +0 -0
  249. data/app/assets/stylesheets/rails_marketplace/images/bootstrap-colorpicker/hue-horizontal.png +0 -0
  250. data/app/assets/stylesheets/rails_marketplace/images/bootstrap-colorpicker/hue.png +0 -0
  251. data/app/assets/stylesheets/rails_marketplace/images/bootstrap-colorpicker/saturation.png +0 -0
  252. data/app/assets/stylesheets/rails_marketplace/images/data.png +0 -0
  253. data/app/assets/stylesheets/rails_marketplace/images/favicon.ico +0 -0
  254. data/app/assets/stylesheets/rails_marketplace/images/forward_disabled.png +0 -0
  255. data/app/assets/stylesheets/rails_marketplace/images/forward_enabled.png +0 -0
  256. data/app/assets/stylesheets/rails_marketplace/images/forward_enabled_hover.png +0 -0
  257. data/app/assets/stylesheets/rails_marketplace/images/icons.png +0 -0
  258. data/app/assets/stylesheets/rails_marketplace/images/img.jpg +0 -0
  259. data/app/assets/stylesheets/rails_marketplace/images/loading.gif +0 -0
  260. data/app/assets/stylesheets/rails_marketplace/images/mastercard.png +0 -0
  261. data/app/assets/stylesheets/rails_marketplace/images/paypal2.png +0 -0
  262. data/app/assets/stylesheets/rails_marketplace/images/picture-2.jpg +0 -0
  263. data/app/assets/stylesheets/rails_marketplace/images/picture.jpg +0 -0
  264. data/app/assets/stylesheets/rails_marketplace/images/picture2.jpg +0 -0
  265. data/app/assets/stylesheets/rails_marketplace/images/prod1.jpg +0 -0
  266. data/app/assets/stylesheets/rails_marketplace/images/prod2.jpg +0 -0
  267. data/app/assets/stylesheets/rails_marketplace/images/prod3.jpg +0 -0
  268. data/app/assets/stylesheets/rails_marketplace/images/prod4.jpg +0 -0
  269. data/app/assets/stylesheets/rails_marketplace/images/prod5.jpg +0 -0
  270. data/app/assets/stylesheets/rails_marketplace/images/sprite-skin-flat.png +0 -0
  271. data/app/assets/stylesheets/rails_marketplace/images/sprite-skin-modern.png +0 -0
  272. data/app/assets/stylesheets/rails_marketplace/images/sprite-skin-nice.png +0 -0
  273. data/app/assets/stylesheets/rails_marketplace/images/sprite-skin-simple.png +0 -0
  274. data/app/assets/stylesheets/rails_marketplace/images/user.png +0 -0
  275. data/app/assets/stylesheets/rails_marketplace/images/visa.png +0 -0
  276. data/app/assets/stylesheets/rails_marketplace/marketplace.scss +20 -0
  277. data/app/assets/stylesheets/rails_marketplace/pace.css +76 -0
  278. data/app/assets/stylesheets/rails_marketplace/welcome.scss +3 -0
  279. data/app/assets/stylesheets/scaffold.css +56 -0
  280. data/app/controllers/rails_marketplace/admin_controller.rb +151 -0
  281. data/app/controllers/rails_marketplace/application_controller.rb +4 -0
  282. data/app/controllers/rails_marketplace/catalog_controller.rb +172 -0
  283. data/app/controllers/rails_marketplace/seller_controller.rb +181 -0
  284. data/app/helpers/rails_marketplace/admin_helper.rb +16 -0
  285. data/app/helpers/rails_marketplace/application_helper.rb +4 -0
  286. data/app/helpers/rails_marketplace/catalog_helper.rb +4 -0
  287. data/app/helpers/rails_marketplace/plainpage_helper.rb +4 -0
  288. data/app/helpers/rails_marketplace/seller_helper.rb +16 -0
  289. data/app/models/rails_marketplace/admin.rb +10 -0
  290. data/app/models/rails_marketplace/admin_setting.rb +13 -0
  291. data/app/models/rails_marketplace/cart.rb +49 -0
  292. data/app/models/rails_marketplace/cart_product.rb +7 -0
  293. data/app/models/rails_marketplace/category.rb +22 -0
  294. data/app/models/rails_marketplace/category_product.rb +6 -0
  295. data/app/models/rails_marketplace/customer.rb +6 -0
  296. data/app/models/rails_marketplace/order.rb +22 -0
  297. data/app/models/rails_marketplace/order_product.rb +7 -0
  298. data/app/models/rails_marketplace/product.rb +34 -0
  299. data/app/models/rails_marketplace/seller.rb +13 -0
  300. data/app/models/rails_marketplace/seller_setting.rb +5 -0
  301. data/app/views/layouts/rails_marketplace/application.html.erb +37 -0
  302. data/app/views/layouts/rails_marketplace/seller_central.html.erb +58 -0
  303. data/app/views/layouts/rails_marketplace/super_admin.html.erb +58 -0
  304. data/app/views/rails_marketplace/admin/add_category.html.erb +63 -0
  305. data/app/views/rails_marketplace/admin/categories.html.erb +50 -0
  306. data/app/views/rails_marketplace/admin/category_products.html.erb +54 -0
  307. data/app/views/rails_marketplace/admin/dashboard.html.erb +50 -0
  308. data/app/views/rails_marketplace/admin/edit_category.html.erb +63 -0
  309. data/app/views/rails_marketplace/admin/login_form.html.erb +20 -0
  310. data/app/views/rails_marketplace/admin/products.html.erb +54 -0
  311. data/app/views/rails_marketplace/admin/seller_products.html.erb +54 -0
  312. data/app/views/rails_marketplace/admin/sellers.html.erb +48 -0
  313. data/app/views/rails_marketplace/admin/settings_form.html.erb +39 -0
  314. data/app/views/rails_marketplace/admin/signup_form.html.erb +25 -0
  315. data/app/views/rails_marketplace/catalog/cart.html.erb +80 -0
  316. data/app/views/rails_marketplace/catalog/category_products.html.erb +52 -0
  317. data/app/views/rails_marketplace/catalog/checkout.html.erb +207 -0
  318. data/app/views/rails_marketplace/catalog/checkout_success.html.erb +15 -0
  319. data/app/views/rails_marketplace/catalog/index.html.erb +1 -0
  320. data/app/views/rails_marketplace/catalog/product_detail.html.erb +88 -0
  321. data/app/views/rails_marketplace/partials/_admin_sidenav.html.erb +80 -0
  322. data/app/views/rails_marketplace/partials/_admin_topnav.html.erb +111 -0
  323. data/app/views/rails_marketplace/partials/_footer.html.erb +19 -0
  324. data/app/views/rails_marketplace/partials/_menu.html.erb +42 -0
  325. data/app/views/rails_marketplace/partials/_sidenav.html.erb +77 -0
  326. data/app/views/rails_marketplace/partials/_topnav.html.erb +105 -0
  327. data/app/views/rails_marketplace/seller/add_bulk_products.html.erb +0 -0
  328. data/app/views/rails_marketplace/seller/add_product.html.erb +67 -0
  329. data/app/views/rails_marketplace/seller/dashboard.html.erb +50 -0
  330. data/app/views/rails_marketplace/seller/edit_product.html.erb +69 -0
  331. data/app/views/rails_marketplace/seller/login_form.html.erb +36 -0
  332. data/app/views/rails_marketplace/seller/order_details.html.erb +69 -0
  333. data/app/views/rails_marketplace/seller/orders.html.erb +68 -0
  334. data/app/views/rails_marketplace/seller/products.html.erb +55 -0
  335. data/app/views/rails_marketplace/seller/settings_general.html.erb +64 -0
  336. data/app/views/rails_marketplace/seller/settings_payment.html.erb +34 -0
  337. data/app/views/rails_marketplace/seller/settings_shipping.html.erb +34 -0
  338. data/app/views/rails_marketplace/seller/settings_tax.html.erb +34 -0
  339. data/app/views/rails_marketplace/seller/signup_form.html.erb +28 -0
  340. data/app/views/rails_marketplace/seller/step_two.html.erb +17 -0
  341. data/app/views/rails_marketplace/shared/_admin_error_messages.html.erb +12 -0
  342. data/app/views/rails_marketplace/shared/_product_error_messages.html.erb +12 -0
  343. data/app/views/rails_marketplace/shared/_seller_error_messages.html.erb +12 -0
  344. data/config/routes.rb +58 -0
  345. data/db/migrate/20161013194852_create_sellers.rb +13 -0
  346. data/db/migrate/20161013195006_create_customers.rb +13 -0
  347. data/db/migrate/20161013195758_create_orders.rb +8 -0
  348. data/db/migrate/20161014013032_create_category_products.rb +10 -0
  349. data/db/migrate/20161014013058_create_order_products.rb +13 -0
  350. data/db/migrate/20161017185755_create_admins.rb +12 -0
  351. data/db/migrate/20161017232347_create_products.rb +14 -0
  352. data/db/migrate/20161019012043_add_reference_product_seller.rb +5 -0
  353. data/db/migrate/20161019013502_change_data_type_images_files.rb +6 -0
  354. data/db/migrate/20161019022020_add_reference_order_customers.rb +5 -0
  355. data/db/migrate/20161109191644_create_categories.rb +15 -0
  356. data/db/migrate/20161110021043_create_friendly_id_slugs.rb +15 -0
  357. data/db/migrate/20161110021131_add_slug_to_category.rb +6 -0
  358. data/db/migrate/20161110024118_add_slug_to_product.rb +6 -0
  359. data/db/migrate/20161111001446_create_carts.rb +8 -0
  360. data/db/migrate/20161111004451_create_cart_products.rb +12 -0
  361. data/db/migrate/20161115013956_add_currency_format_to_price.rb +6 -0
  362. data/db/migrate/20161115015227_monetize_product.rb +5 -0
  363. data/db/migrate/20161115032905_add_stripe_key_to_admin.rb +6 -0
  364. data/db/migrate/20161124015608_add_order_fields.rb +16 -0
  365. data/db/migrate/20161207193917_add_seller_to_orders.rb +6 -0
  366. data/db/migrate/20161208012601_add_price_to_cart_products.rb +6 -0
  367. data/db/migrate/20161208013402_add_money_to_cart_products.rb +6 -0
  368. data/db/migrate/20170217183953_create_seller_settings.rb +29 -0
  369. data/db/migrate/20170218003202_create_admin_settings.rb +24 -0
  370. data/db/migrate/20170224230449_create_stripe_managed_accounts.rb +9 -0
  371. data/db/migrate/20170224233736_add_stripe_to_admin_settings.rb +9 -0
  372. data/db/migrate/20170224235259_add_id_to_settings.rb +6 -0
  373. data/db/migrate/20170225002939_delete_stripe_accounts.rb +8 -0
  374. data/db/migrate/20170225003252_add_stripe_account_id_to_seller_settings.rb +5 -0
  375. data/lib/rails_marketplace.rb +4 -0
  376. data/lib/rails_marketplace/engine.rb +9 -0
  377. data/lib/rails_marketplace/version.rb +3 -0
  378. data/lib/tasks/rails_marketplace_tasks.rake +4 -0
  379. data/spec/controllers/rails_marketplace/catalog_controller_spec.rb +75 -0
  380. data/spec/dummy/README.rdoc +28 -0
  381. data/spec/dummy/Rakefile +6 -0
  382. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  383. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  384. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  385. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  386. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  387. data/spec/dummy/bin/bundle +3 -0
  388. data/spec/dummy/bin/rails +4 -0
  389. data/spec/dummy/bin/rake +4 -0
  390. data/spec/dummy/bin/setup +29 -0
  391. data/spec/dummy/config.ru +4 -0
  392. data/spec/dummy/config/application.rb +32 -0
  393. data/spec/dummy/config/boot.rb +5 -0
  394. data/spec/dummy/config/database.yml +25 -0
  395. data/spec/dummy/config/environment.rb +5 -0
  396. data/spec/dummy/config/environments/development.rb +41 -0
  397. data/spec/dummy/config/environments/production.rb +79 -0
  398. data/spec/dummy/config/environments/test.rb +42 -0
  399. data/spec/dummy/config/initializers/assets.rb +11 -0
  400. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  401. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  402. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  403. data/spec/dummy/config/initializers/inflections.rb +16 -0
  404. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  405. data/spec/dummy/config/initializers/session_store.rb +3 -0
  406. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  407. data/spec/dummy/config/locales/en.yml +23 -0
  408. data/spec/dummy/config/routes.rb +4 -0
  409. data/spec/dummy/config/secrets.yml +22 -0
  410. data/spec/dummy/db/schema.rb +194 -0
  411. data/spec/dummy/log/development.log +889 -0
  412. data/spec/dummy/log/test.log +1229 -0
  413. data/spec/dummy/public/404.html +67 -0
  414. data/spec/dummy/public/422.html +67 -0
  415. data/spec/dummy/public/500.html +66 -0
  416. data/spec/dummy/public/favicon.ico +0 -0
  417. data/spec/helpers/rails_marketplace/catalog_helper_spec.rb +17 -0
  418. data/spec/routing/rails_marketplace/catalog_routing_spec.rb +44 -0
  419. data/spec/spec_helper.rb +44 -0
  420. data/spec/views/rails_marketplace/catalog/edit.html.erb_spec.rb +15 -0
  421. data/spec/views/rails_marketplace/catalog/index.html.erb_spec.rb +15 -0
  422. data/spec/views/rails_marketplace/catalog/new.html.erb_spec.rb +15 -0
  423. data/spec/views/rails_marketplace/catalog/show.html.erb_spec.rb +12 -0
  424. metadata +595 -0
@@ -0,0 +1,17 @@
1
+ $(function () {
2
+ $('.demo1').colorpicker();
3
+ $('.demo2').colorpicker();
4
+
5
+ // Horizontal mode
6
+ $('#demo_forceformat').colorpicker({
7
+ format: 'rgba', // force this format
8
+ horizontal: true
9
+ });
10
+ // Horizontal mode
11
+ $('#demo_forceformat3').colorpicker({
12
+ format: 'rgba', // force this format
13
+ });
14
+
15
+
16
+ $('.demo-auto').colorpicker();
17
+ });
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * Cropper v0.8.0
3
+ * https://github.com/fengyuanchen/cropper
4
+ *
5
+ * Copyright 2014-2015 Fengyuan Chen
6
+ * Released under the MIT license
7
+ *
8
+ * Date: 2015-02-19T06:49:29.144Z
9
+ */
10
+ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){"use strict";function b(a){return"number"==typeof a}function c(a){return"string"==typeof a}function d(a){return"undefined"==typeof a}function e(a,c){var d=[];return b(c)&&d.push(c),d.slice.apply(a,d)}function f(a,b){var c=e(arguments,2);return function(){return a.apply(b,c.concat(e(arguments)))}}function g(a){var b=a.match(/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i);return!b||b[1]===o.protocol&&b[2]===o.hostname&&b[3]===o.port?!1:!0}function h(a){var b="timestamp="+(new Date).getTime();return a+(-1===a.indexOf("?")?"?":"&")+b}function i(a){return a?"rotate("+a+"deg)":"none"}function j(a){var b=Q(a.degree)%180,c=(b>90?180-b:b)*Math.PI/180;return{width:a.width*S(c)+a.height*R(c),height:a.width*R(c)+a.height*S(c)}}function k(b,c){var d=a("<canvas>")[0],e=d.getContext("2d"),f=c.naturalWidth,g=c.naturalHeight,h=c.rotate,i=j({width:f,height:g,degree:h});return h?(d.width=i.width,d.height=i.height,e.save(),e.translate(i.width/2,i.height/2),e.rotate(h*Math.PI/180),e.drawImage(b,-f/2,-g/2,f,g),e.restore()):(d.width=f,d.height=g,e.drawImage(b,0,0,f,g)),d}function l(b,c){this.$element=a(b),this.options=a.extend({},l.DEFAULTS,a.isPlainObject(c)&&c),this.ready=!1,this.built=!1,this.cropped=!1,this.disabled=!1,this.load()}var m=a(window),n=a(document),o=window.location,p="directive",q=".cropper",r=/^(e|n|w|s|ne|nw|sw|se|all|crop|move|zoom)$/,s="cropper-modal",t="cropper-hide",u="cropper-hidden",v="cropper-invisible",w="cropper-move",x="cropper-crop",y="cropper-disabled",z="cropper-bg",A="mousedown touchstart",B="mousemove touchmove",C="mouseup mouseleave touchend touchleave touchcancel",D="wheel mousewheel DOMMouseScroll",E="dblclick",F="resize"+q,G="build"+q,H="built"+q,I="dragstart"+q,J="dragmove"+q,K="dragend"+q,L={canvas:a.isFunction(a("<canvas>")[0].getContext)},M=Math.round,N=Math.sqrt,O=Math.min,P=Math.max,Q=Math.abs,R=Math.sin,S=Math.cos,T=parseFloat,U={};U.load=function(){var b,c,d,e=this,f=this.options,i=this.$element,j="";i.is("img")?d=i.prop("src"):i.is("canvas")&&L.canvas&&(d=i[0].toDataURL()),d&&(b=a.Event(G),i.one(G,f.build).trigger(b),b.isDefaultPrevented()||(f.checkImageOrigin&&g(d)&&(j=" crossOrigin",d=h(d)),this.$clone=c=a("<img"+j+' src="'+d+'">'),c.one("load",function(){var a=this.naturalWidth||c.width(),b=this.naturalHeight||c.height();e.image={naturalWidth:a,naturalHeight:b,aspectRatio:a/b,rotate:0},e.url=d,e.ready=!0,e.build()}),c.addClass(t).prependTo("body")))},U.build=function(){var b,c,d=this.$element,e=this.options;this.ready&&(this.built&&this.unbuild(),this.$cropper=b=a(l.TEMPLATE),d.addClass(u),this.$clone.removeClass(t).prependTo(b),this.$container=d.parent(),this.$container.append(b),this.$canvas=b.find(".cropper-canvas"),this.$cropBox=c=b.find(".cropper-cropbox"),this.$viewer=b.find(".cropper-viewer"),this.addListeners(),this.initPreview(),e.aspectRatio=Q(T(e.aspectRatio))||0/0,e.autoCrop?(this.cropped=!0,e.modal&&this.$canvas.addClass(s)):c.addClass(u),e.background&&b.addClass(z),!e.highlight&&c.find(".cropper-face").addClass(v),!e.guides&&c.find(".cropper-dashed").addClass(u),!e.movable&&c.find(".cropper-face").data(p,"move"),!e.resizable&&c.find(".cropper-line, .cropper-point").addClass(u),this.setDragMode(e.dragCrop?"crop":"move"),this.built=!0,this.render(),d.one(H,e.built).trigger(H))},U.unbuild=function(){this.built&&(this.built=!1,this.removeListeners(),this.$preview.empty(),this.$preview=null,this.$cropBox=null,this.$canvas=null,this.$container=null,this.$cropper.remove(),this.$cropper=null)},a.extend(U,{render:function(){this.initContainer(),this.initImage(),this.initCropBox()},initContainer:function(){var a=this.$element,b=this.$container,c=this.$cropper,d=this.options;c.addClass(u),a.removeClass(u),c.css(this.container={width:P(b.width(),T(d.minContainerWidth)||350),height:P(b.height(),T(d.minContainerHeight)||150)}),a.addClass(u),c.removeClass(u)},initImage:function(){var b=this.container,c=this.image,d=c.aspectRatio,e=b.width,f=b.height,g=c.naturalWidth,h=c.naturalHeight,i=0,j=0;f*d>e?(g=e,h=g/d,j=(f-h)/2):(h=f,g=h*d,i=(e-g)/2),a.extend(c,{width:g,height:h,left:i,top:j}),this.defaultImage=a.extend({},c),this.renderImage()},renderImage:function(b){var c,d=this.options,e=this.image,f=e.width,g=e.height,h=e.rotate;h&&(c=j({width:f,height:g,degree:h})),a.extend(e,{rotatedWidth:c?c.width:e.width,rotatedHeight:c?c.height:e.height,rotatedLeft:c?e.left-(c.width-f)/2:e.left,rotatedTop:c?e.top-(c.height-g)/2:e.top}),this.$clone.css({width:f,height:g,marginLeft:e.left,marginTop:e.top,transform:i(h)}),b&&(this.preview(),a.isFunction(d.crop)&&d.crop.call(this.$element,this.getData()))},initCropBox:function(){var b=this.options,c=this.container,d=this.image,e=b.aspectRatio,f=c.width,g=c.height,h=Q(T(b.minCropBoxWidth))||0,i=Q(T(b.minCropBoxHeight))||0,j=Q(T(b.autoCropArea))||.8,k={width:d.width,height:d.height,minWidth:h,minHeight:i,maxWidth:f,maxHeight:g};e&&(g*e>f?(k.height=k.width/e,k.maxHeight=f/e):(k.width=d.height*e,k.maxWidth=g*e),h?k.minHeight=k.minWidth/e:i&&(k.minWidth=k.minHeight*e)),k.minWidth=O(k.maxWidth,k.minWidth),k.minHeight=O(k.maxHeight,k.minHeight),k.width=P(k.minWidth,k.width*j),k.height=P(k.minHeight,k.height*j),k.left=(f-k.width)/2,k.top=(g-k.height)/2,k.oldLeft=k.left,k.oldTop=k.top,this.defaultCropBox=a.extend({},k),this.cropBox=k,this.cropped&&this.renderCropBox()},renderCropBox:function(){var b=this.options,c=this.container,d=this.$cropBox,e=this.cropBox;e.width>e.maxWidth?(e.width=e.maxWidth,e.left=e.oldLeft):e.width<e.minWidth&&(e.width=e.minWidth,e.left=e.oldLeft),e.height>e.maxHeight?(e.height=e.maxHeight,e.top=e.oldTop):e.height<e.minHeight&&(e.height=e.minHeight,e.top=e.oldTop),e.left=O(P(e.left,0),c.width-e.width),e.top=O(P(e.top,0),c.height-e.height),e.oldLeft=e.left,e.oldTop=e.top,b.movable&&d.find(".cropper-face").data(p,e.width===c.width&&e.height===c.height?"move":"all"),d.css({width:e.width,height:e.height,left:e.left,top:e.top}),this.disabled||(this.preview(),a.isFunction(b.crop)&&b.crop.call(this.$element,this.getData()))}}),U.initPreview=function(){var b=this.url;this.$preview=a(this.options.preview),this.$viewer.html('<img src="'+b+'">'),this.$preview.each(function(){var c=a(this);c.data({width:c.width(),height:c.height()}).html('<img src="'+b+'" style="display:block;width:100%;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;">')})},U.preview=function(){var b=this.image,c=this.cropBox,d=b.width,e=b.height,f=c.left-b.left,g=c.top-b.top,h=b.rotate;this.cropped&&!this.disabled&&(this.$viewer.find("img").css({width:d,height:e,marginLeft:-f,marginTop:-g,transform:i(h)}),this.$preview.each(function(){var b=a(this),j=b.data(),k=j.width/c.width,l=j.width,m=c.height*k;m>j.height&&(k=j.height/c.height,l=c.width*k,m=j.height),b.width(l).height(m).find("img").css({width:d*k,height:e*k,marginLeft:-f*k,marginTop:-g*k,transform:i(h)})}))},U.addListeners=function(){var b=this.options;this.$element.on(I,b.dragstart).on(J,b.dragmove).on(K,b.dragend),this.$cropper.on(A,a.proxy(this.dragstart,this)).on(E,a.proxy(this.dblclick,this)),b.zoomable&&b.mouseWheelZoom&&this.$cropper.on(D,a.proxy(this.wheel,this)),b.global?n.on(B,this._dragmove=f(this.dragmove,this)).on(C,this._dragend=f(this.dragend,this)):this.$cropper.on(B,a.proxy(this.dragmove,this)).on(C,a.proxy(this.dragend,this)),b.responsive&&m.on(F,this._resize=f(this.resize,this))},U.removeListeners=function(){var a=this.options;this.$element.off(I,a.dragstart).off(J,a.dragmove).off(K,a.dragend),this.$cropper.off(A,this.dragstart).off(E,this.dblclick),a.zoomable&&a.mouseWheelZoom&&this.$cropper.off(D,this.wheel),a.global?n.off(B,this._dragmove).off(C,this._dragend):this.$cropper.off(B,this.dragmove).off(C,this.dragend),a.responsive&&m.off(F,this._resize)},a.extend(U,{resize:function(){var b=this.$container,c=this.container;this.disabled||(b.width()!==c.width||b.height()!==c.height)&&(clearTimeout(this.resizing),this.resizing=setTimeout(a.proxy(function(){var a=this.getImageData(),b=this.getCropBoxData();this.render(),this.setImageData(a),this.setCropBoxData(b)},this),200))},dblclick:function(){this.disabled||this.setDragMode(this.$canvas.hasClass(x)?"move":"crop")},wheel:function(a){var b=a.originalEvent,c=1;this.disabled||(a.preventDefault(),b.deltaY?c=b.deltaY>0?1:-1:b.wheelDelta?c=-b.wheelDelta/120:b.detail&&(c=b.detail>0?1:-1),this.zoom(.1*c))},dragstart:function(b){var c,d,e,f=this.options,g=b.originalEvent,h=g&&g.touches,i=b;if(!this.disabled){if(h){if(e=h.length,e>1){if(!f.zoomable||!f.touchDragZoom||2!==e)return;i=h[1],this.startX2=i.pageX,this.startY2=i.pageY,c="zoom"}i=h[0]}if(c=c||a(i.target).data(p),r.test(c)){if(b.preventDefault(),d=a.Event(I),this.$element.trigger(d),d.isDefaultPrevented())return;this.directive=c,this.cropping=!1,this.startX=i.pageX,this.startY=i.pageY,"crop"===c&&(this.cropping=!0,this.$canvas.addClass(s))}}},dragmove:function(b){var c,d,e=this.options,f=b.originalEvent,g=f&&f.touches,h=b;if(!this.disabled){if(g){if(d=g.length,d>1){if(!e.zoomable||!e.touchDragZoom||2!==d)return;h=g[1],this.endX2=h.pageX,this.endY2=h.pageY}h=g[0]}if(this.directive){if(b.preventDefault(),c=a.Event(J),this.$element.trigger(c),c.isDefaultPrevented())return;this.endX=h.pageX,this.endY=h.pageY,this.change()}}},dragend:function(b){var c;if(!this.disabled&&this.directive){if(b.preventDefault(),c=a.Event(K),this.$element.trigger(c),c.isDefaultPrevented())return;this.cropping&&(this.cropping=!1,this.$canvas.toggleClass(s,this.cropped&&this.options.modal)),this.directive=""}}}),a.extend(U,{reset:function(){this.cropped&&!this.disabled&&(this.image=a.extend({},this.defaultImage),this.renderImage(),this.cropBox=a.extend({},this.defaultCropBox),this.renderCropBox())},clear:function(){var a=this.cropBox;this.cropped&&!this.disabled&&(this.cropped=!1,a.left=0,a.top=0,a.width=0,a.height=0,this.renderCropBox(),this.$canvas.removeClass(s),this.$cropBox.addClass(u))},destroy:function(){var a=this.$element;this.ready||this.$clone.off("load").remove(),this.unbuild(),a.removeClass(u).removeData("cropper")},replace:function(b){var c,d,e=this,f=this.$element;!this.disabled&&b&&b!==this.url&&b!==f.attr("src")&&(f.is("img")?(f.attr("src",b),this.load()):f.is("canvas")&&L.canvas&&(c=f[0],d=c.getContext("2d"),a('<img src="'+b+'"">').one("load",function(){c.width=this.width,c.height=this.height,d.clearRect(0,0,c.width,c.height),d.drawImage(this,0,0),e.load()})))},enable:function(){this.built&&(this.disabled=!1,this.$cropper.removeClass(y))},disable:function(){this.built&&(this.disabled=!0,this.$cropper.addClass(y))},move:function(a,c){var d=this.image;!this.disabled&&b(a)&&b(c)&&(d.left+=a,d.top+=c,this.renderImage(!0))},zoom:function(a){var b,c,d=this.image;a=T(a),a&&this.built&&!this.disabled&&this.options.zoomable&&(a=-1>=a?1/(1-a):1>=a?1+a:a,b=d.width*a,c=d.height*a,d.left-=(b-d.width)/2,d.top-=(c-d.height)/2,d.width=b,d.height=c,this.renderImage(!0),this.setDragMode("move"))},rotate:function(a){var b=this.image;a=T(a)||0,0!==a&&this.built&&!this.disabled&&this.options.rotatable&&(b.rotate=(b.rotate+a)%360,this.renderImage(!0))},getData:function(b){var c,d,e=this.cropBox,f=this.image,g=f.rotate;return this.built&&this.cropped?(d={x:e.left-(g?f.rotatedLeft:f.left),y:e.top-(g?f.rotatedTop:f.top),width:e.width,height:e.height},c=f.width/f.naturalWidth,a.each(d,function(a,e){e/=c,d[a]=b?M(e):e}),d.rotate=g):d={x:0,y:0,width:0,height:0,rotate:g},d},getImageData:function(b){var c=this.image,d={};return this.built&&a.extend(d,b?c:{left:c.left,top:c.top,width:c.width,height:c.height}),d},setImageData:function(c){var d=this.image;this.built&&!this.disabled&&a.isPlainObject(c)&&(b(c.left)&&(d.left=c.left),b(c.top)&&(d.top=c.top),b(c.width)?(d.width=c.width,d.height=d.width/d.aspectRatio):b(c.height)&&(d.height=c.height,d.width=d.height*d.aspectRatio),this.renderImage(!0))},getCropBoxData:function(){var a,b={};return this.cropped&&(a=this.cropBox,b={left:a.left,top:a.top,width:a.width,height:a.height}),b},setCropBoxData:function(c){var d=this.cropBox,e=this.options.aspectRatio;this.cropped&&!this.disabled&&a.isPlainObject(c)&&(b(c.left)&&(d.left=c.left),b(c.top)&&(d.top=c.top),e?b(c.width)?(d.width=c.width,d.height=d.width/e):b(c.height)&&(d.height=c.height,d.width=d.height*e):(b(c.width)&&(d.width=c.width),b(c.height)&&(d.height=c.height)),this.renderCropBox())},getDataURL:function(d,e,f){var g,h,i,j,l,m,n,o,p,q,r;return this.cropped&&L.canvas&&(q=this.getData(),g=q.width,h=q.height,n=a.isPlainObject(d),n?(l=d.width||g,m=d.height||h):(f=e,e=d),i=n?l:g,j=n?m:h,o=a("<canvas>")[0],o.width=i,o.height=j,p=o.getContext("2d"),"image/jpeg"===e&&(p.fillStyle="#fff",p.fillRect(0,0,i,j)),p.drawImage.apply(p,function(){var a,b,c,d,e,f,i,j=k(this.$clone[0],this.image),m=j.width,o=j.height,p=[j],r=q.x,s=q.y;return-g>=r||r>m?r=a=c=e=0:0>=r?(c=-r,r=0,a=e=O(m,g+r)):m>=r&&(c=0,a=e=O(g,m-r)),0>=a||-h>=s||s>o?s=b=d=f=0:0>=s?(d=-s,s=0,b=f=O(o,h+s)):o>=s&&(d=0,b=f=O(h,o-s)),p.push(r,s,a,b),n&&(i=g/l,c/=i,d/=i,e/=i,f/=i),e>0&&f>0&&p.push(c,d,e,f),p}.call(this)),r=o.toDataURL.apply(o,function(){var a=[];return c(e)&&a.push(e),b(f)&&a.push(f),a}.call(this))),r||""},setAspectRatio:function(a){var b=this.options;this.disabled||d(a)||(b.aspectRatio=Q(T(a))||0/0,this.built&&this.initCropBox())},setDragMode:function(a){var b=this.$canvas,c=!1,d=!1;if(this.ready&&!this.disabled){switch(a){case"crop":this.options.dragCrop?(c=!0,b.data(p,a)):d=!0;break;case"move":d=!0,b.data(p,a);break;default:b.removeData(p)}b.toggleClass(x,c).toggleClass(w,d)}}}),U.change=function(){var a,b=this.directive,c=this.image,d=this.container,e=d.width,f=d.height,g=this.cropBox,h=g.width,i=g.height,j=g.left,k=g.top,l=j+h,m=k+i,n=!0,o=this.options.aspectRatio,p={x:this.endX-this.startX,y:this.endY-this.startY};switch(o&&(p.X=p.y*o,p.Y=p.x/o),b){case"all":j+=p.x,k+=p.y;break;case"e":if(p.x>=0&&(l>=e||o&&(0>=k||m>=f))){n=!1;break}h+=p.x,o&&(i=h/o,k-=p.Y/2),0>h&&(b="w",h=0);break;case"n":if(p.y<=0&&(0>=k||o&&(0>=j||l>=e))){n=!1;break}i-=p.y,k+=p.y,o&&(h=i*o,j+=p.X/2),0>i&&(b="s",i=0);break;case"w":if(p.x<=0&&(0>=j||o&&(0>=k||m>=f))){n=!1;break}h-=p.x,j+=p.x,o&&(i=h/o,k+=p.Y/2),0>h&&(b="e",h=0);break;case"s":if(p.y>=0&&(m>=f||o&&(0>=j||l>=e))){n=!1;break}i+=p.y,o&&(h=i*o,j-=p.X/2),0>i&&(b="n",i=0);break;case"ne":if(o){if(p.y<=0&&(0>=k||l>=e)){n=!1;break}i-=p.y,k+=p.y,h=i*o}else p.x>=0?e>l?h+=p.x:p.y<=0&&0>=k&&(n=!1):h+=p.x,p.y<=0?k>0&&(i-=p.y,k+=p.y):(i-=p.y,k+=p.y);0>h&&0>i?(b="sw",i=0,h=0):0>h?(b="nw",h=0):0>i&&(b="se",i=0);break;case"nw":if(o){if(p.y<=0&&(0>=k||0>=j)){n=!1;break}i-=p.y,k+=p.y,h=i*o,j+=p.X}else p.x<=0?j>0?(h-=p.x,j+=p.x):p.y<=0&&0>=k&&(n=!1):(h-=p.x,j+=p.x),p.y<=0?k>0&&(i-=p.y,k+=p.y):(i-=p.y,k+=p.y);0>h&&0>i?(b="se",i=0,h=0):0>h?(b="ne",h=0):0>i&&(b="sw",i=0);break;case"sw":if(o){if(p.x<=0&&(0>=j||m>=f)){n=!1;break}h-=p.x,j+=p.x,i=h/o}else p.x<=0?j>0?(h-=p.x,j+=p.x):p.y>=0&&m>=f&&(n=!1):(h-=p.x,j+=p.x),p.y>=0?f>m&&(i+=p.y):i+=p.y;0>h&&0>i?(b="ne",i=0,h=0):0>h?(b="se",h=0):0>i&&(b="nw",i=0);break;case"se":if(o){if(p.x>=0&&(l>=e||m>=f)){n=!1;break}h+=p.x,i=h/o}else p.x>=0?e>l?h+=p.x:p.y>=0&&m>=f&&(n=!1):h+=p.x,p.y>=0?f>m&&(i+=p.y):i+=p.y;0>h&&0>i?(b="nw",i=0,h=0):0>h?(b="sw",h=0):0>i&&(b="ne",i=0);break;case"move":c.left+=p.x,c.top+=p.y,this.renderImage(!0),n=!1;break;case"zoom":this.zoom(function(a,b,c,d,e,f){return(N(e*e+f*f)-N(c*c+d*d))/N(a*a+b*b)}(c.width,c.height,Q(this.startX-this.startX2),Q(this.startY-this.startY2),Q(this.endX-this.endX2),Q(this.endY-this.endY2))),this.endX2=this.startX2,this.endY2=this.startY2,n=!1;break;case"crop":p.x&&p.y&&(a=this.$cropper.offset(),j=this.startX-a.left,k=this.startY-a.top,h=g.minWidth,i=g.minHeight,p.x>0?p.y>0?b="se":(b="ne",k-=i):p.y>0?(b="sw",j-=h):(b="nw",j-=h,k-=i),this.cropped||(this.cropped=!0,this.$cropBox.removeClass(u)))}n&&(g.width=h,g.height=i,g.left=j,g.top=k,this.directive=b,this.renderCropBox()),this.startX=this.endX,this.startY=this.endY},a.extend(l.prototype,U),l.DEFAULTS={aspectRatio:0/0,autoCropArea:.8,crop:null,preview:"",global:!0,responsive:!0,checkImageOrigin:!0,modal:!0,guides:!0,highlight:!0,background:!0,autoCrop:!0,dragCrop:!0,movable:!0,resizable:!0,rotatable:!0,zoomable:!0,touchDragZoom:!0,mouseWheelZoom:!0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:300,minContainerHeight:150,build:null,built:null,dragstart:null,dragmove:null,dragend:null},l.setDefaults=function(b){a.extend(l.DEFAULTS,b)},l.TEMPLATE=function(a,b){return b=b.split(","),a.replace(/\d+/g,function(a){return b[a]})}('<0 6="5-container"><0 6="5-canvas"></0><0 6="5-cropbox"><1 6="5-viewer"></1><1 6="5-8 8-h"></1><1 6="5-8 8-v"></1><1 6="5-face" 3-2="all"></1><1 6="5-7 7-e" 3-2="e"></1><1 6="5-7 7-n" 3-2="n"></1><1 6="5-7 7-w" 3-2="w"></1><1 6="5-7 7-s" 3-2="s"></1><1 6="5-4 4-e" 3-2="e"></1><1 6="5-4 4-n" 3-2="n"></1><1 6="5-4 4-w" 3-2="w"></1><1 6="5-4 4-s" 3-2="s"></1><1 6="5-4 4-ne" 3-2="ne"></1><1 6="5-4 4-nw" 3-2="nw"></1><1 6="5-4 4-sw" 3-2="sw"></1><1 6="5-4 4-se" 3-2="se"></1></0></0>',"div,span,directive,data,point,cropper,class,line,dashed"),l.other=a.fn.cropper,a.fn.cropper=function(b){var c,f=e(arguments,1);return this.each(function(){var d,e=a(this),g=e.data("cropper");g||e.data("cropper",g=new l(this,b)),"string"==typeof b&&a.isFunction(d=g[b])&&(c=d.apply(g,f))}),d(c)?this:c},a.fn.cropper.Constructor=l,a.fn.cropper.setDefaults=l.setDefaults,a.fn.cropper.noConflict=function(){return a.fn.cropper=l.other,this}});
@@ -0,0 +1,321 @@
1
+ (function (factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ define(['jquery'], factory);
4
+ } else if (typeof exports === 'object') {
5
+ // Node / CommonJS
6
+ factory(require('jquery'));
7
+ } else {
8
+ factory(jQuery);
9
+ }
10
+ })(function ($) {
11
+
12
+ 'use strict';
13
+
14
+ var console = window.console || { log: function () {} };
15
+
16
+ function CropAvatar($element) {
17
+ this.$container = $element;
18
+
19
+ this.$avatarView = this.$container.find('.avatar-view');
20
+ this.$avatar = this.$avatarView.find('img');
21
+ this.$avatarModal = this.$container.find('#avatar-modal');
22
+ this.$loading = this.$container.find('.loading');
23
+
24
+ this.$avatarForm = this.$avatarModal.find('.avatar-form');
25
+ this.$avatarUpload = this.$avatarForm.find('.avatar-upload');
26
+ this.$avatarSrc = this.$avatarForm.find('.avatar-src');
27
+ this.$avatarData = this.$avatarForm.find('.avatar-data');
28
+ this.$avatarInput = this.$avatarForm.find('.avatar-input');
29
+ this.$avatarSave = this.$avatarForm.find('.avatar-save');
30
+ this.$avatarBtns = this.$avatarForm.find('.avatar-btns');
31
+
32
+ this.$avatarWrapper = this.$avatarModal.find('.avatar-wrapper');
33
+ this.$avatarPreview = this.$avatarModal.find('.avatar-preview');
34
+
35
+ this.init();
36
+ console.log(this);
37
+ }
38
+
39
+ CropAvatar.prototype = {
40
+ constructor: CropAvatar,
41
+
42
+ support: {
43
+ fileList: !!$('<input type="file">').prop('files'),
44
+ blobURLs: !!window.URL && URL.createObjectURL,
45
+ formData: !!window.FormData
46
+ },
47
+
48
+ init: function () {
49
+ this.support.datauri = this.support.fileList && this.support.blobURLs;
50
+
51
+ if (!this.support.formData) {
52
+ this.initIframe();
53
+ }
54
+
55
+ this.initTooltip();
56
+ this.initModal();
57
+ this.addListener();
58
+ },
59
+
60
+ addListener: function () {
61
+ this.$avatarView.on('click', $.proxy(this.click, this));
62
+ this.$avatarInput.on('change', $.proxy(this.change, this));
63
+ this.$avatarForm.on('submit', $.proxy(this.submit, this));
64
+ this.$avatarBtns.on('click', $.proxy(this.rotate, this));
65
+ },
66
+
67
+ initTooltip: function () {
68
+ this.$avatarView.tooltip({
69
+ placement: 'bottom'
70
+ });
71
+ },
72
+
73
+ initModal: function () {
74
+ this.$avatarModal.modal({
75
+ show: false
76
+ });
77
+ },
78
+
79
+ initPreview: function () {
80
+ var url = this.$avatar.attr('src');
81
+
82
+ this.$avatarPreview.empty().html('<img src="' + url + '">');
83
+ },
84
+
85
+ initIframe: function () {
86
+ var target = 'upload-iframe-' + (new Date()).getTime(),
87
+ $iframe = $('<iframe>').attr({
88
+ name: target,
89
+ src: ''
90
+ }),
91
+ _this = this;
92
+
93
+ // Ready ifrmae
94
+ $iframe.one('load', function () {
95
+
96
+ // respond response
97
+ $iframe.on('load', function () {
98
+ var data;
99
+
100
+ try {
101
+ data = $(this).contents().find('body').text();
102
+ } catch (e) {
103
+ console.log(e.message);
104
+ }
105
+
106
+ if (data) {
107
+ try {
108
+ data = $.parseJSON(data);
109
+ } catch (e) {
110
+ console.log(e.message);
111
+ }
112
+
113
+ _this.submitDone(data);
114
+ } else {
115
+ _this.submitFail('Image upload failed!');
116
+ }
117
+
118
+ _this.submitEnd();
119
+
120
+ });
121
+ });
122
+
123
+ this.$iframe = $iframe;
124
+ this.$avatarForm.attr('target', target).after($iframe.hide());
125
+ },
126
+
127
+ click: function () {
128
+ this.$avatarModal.modal('show');
129
+ this.initPreview();
130
+ },
131
+
132
+ change: function () {
133
+ var files,
134
+ file;
135
+
136
+ if (this.support.datauri) {
137
+ files = this.$avatarInput.prop('files');
138
+
139
+ if (files.length > 0) {
140
+ file = files[0];
141
+
142
+ if (this.isImageFile(file)) {
143
+ if (this.url) {
144
+ URL.revokeObjectURL(this.url); // Revoke the old one
145
+ }
146
+
147
+ this.url = URL.createObjectURL(file);
148
+ this.startCropper();
149
+ }
150
+ }
151
+ } else {
152
+ file = this.$avatarInput.val();
153
+
154
+ if (this.isImageFile(file)) {
155
+ this.syncUpload();
156
+ }
157
+ }
158
+ },
159
+
160
+ submit: function () {
161
+ if (!this.$avatarSrc.val() && !this.$avatarInput.val()) {
162
+ return false;
163
+ }
164
+
165
+ if (this.support.formData) {
166
+ this.ajaxUpload();
167
+ return false;
168
+ }
169
+ },
170
+
171
+ rotate: function (e) {
172
+ var data;
173
+
174
+ if (this.active) {
175
+ data = $(e.target).data();
176
+
177
+ if (data.method) {
178
+ this.$img.cropper(data.method, data.option);
179
+ }
180
+ }
181
+ },
182
+
183
+ isImageFile: function (file) {
184
+ if (file.type) {
185
+ return /^image\/\w+$/.test(file.type);
186
+ } else {
187
+ return /\.(jpg|jpeg|png|gif)$/.test(file);
188
+ }
189
+ },
190
+
191
+ startCropper: function () {
192
+ var _this = this;
193
+
194
+ if (this.active) {
195
+ this.$img.cropper('replace', this.url);
196
+ } else {
197
+ this.$img = $('<img src="' + this.url + '">');
198
+ this.$avatarWrapper.empty().html(this.$img);
199
+ this.$img.cropper({
200
+ aspectRatio: 1,
201
+ preview: this.$avatarPreview.selector,
202
+ crop: function (data) {
203
+ var json = [
204
+ '{"x":' + data.x,
205
+ '"y":' + data.y,
206
+ '"height":' + data.height,
207
+ '"width":' + data.width,
208
+ '"rotate":' + data.rotate + '}'
209
+ ].join();
210
+
211
+ _this.$avatarData.val(json);
212
+ }
213
+ });
214
+
215
+ this.active = true;
216
+ }
217
+ },
218
+
219
+ stopCropper: function () {
220
+ if (this.active) {
221
+ this.$img.cropper('destroy');
222
+ this.$img.remove();
223
+ this.active = false;
224
+ }
225
+ },
226
+
227
+ ajaxUpload: function () {
228
+ var url = this.$avatarForm.attr('action'),
229
+ data = new FormData(this.$avatarForm[0]),
230
+ _this = this;
231
+
232
+ $.ajax(url, {
233
+ type: 'post',
234
+ data: data,
235
+ dataType: 'json',
236
+ processData: false,
237
+ contentType: false,
238
+
239
+ beforeSend: function () {
240
+ _this.submitStart();
241
+ },
242
+
243
+ success: function (data) {
244
+ _this.submitDone(data);
245
+ },
246
+
247
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
248
+ _this.submitFail(textStatus || errorThrown);
249
+ },
250
+
251
+ complete: function () {
252
+ _this.submitEnd();
253
+ }
254
+ });
255
+ },
256
+
257
+ syncUpload: function () {
258
+ this.$avatarSave.click();
259
+ },
260
+
261
+ submitStart: function () {
262
+ this.$loading.fadeIn();
263
+ },
264
+
265
+ submitDone: function (data) {
266
+ console.log(data);
267
+
268
+ if ($.isPlainObject(data) && data.state === 200) {
269
+ if (data.result) {
270
+ this.url = data.result;
271
+
272
+ if (this.support.datauri || this.uploaded) {
273
+ this.uploaded = false;
274
+ this.cropDone();
275
+ } else {
276
+ this.uploaded = true;
277
+ this.$avatarSrc.val(this.url);
278
+ this.startCropper();
279
+ }
280
+
281
+ this.$avatarInput.val('');
282
+ } else if (data.message) {
283
+ this.alert(data.message);
284
+ }
285
+ } else {
286
+ this.alert('Failed to response');
287
+ }
288
+ },
289
+
290
+ submitFail: function (msg) {
291
+ this.alert(msg);
292
+ },
293
+
294
+ submitEnd: function () {
295
+ this.$loading.fadeOut();
296
+ },
297
+
298
+ cropDone: function () {
299
+ this.$avatarForm.get(0).reset();
300
+ this.$avatar.attr('src', this.url);
301
+ this.stopCropper();
302
+ this.$avatarModal.modal('hide');
303
+ },
304
+
305
+ alert: function (msg) {
306
+ var $alert = [
307
+ '<div class="alert alert-danger avater-alert">',
308
+ '<button type="button" class="close" data-dismiss="alert">&times;</button>',
309
+ msg,
310
+ '</div>'
311
+ ].join('');
312
+
313
+ this.$avatarUpload.after($alert);
314
+ }
315
+ };
316
+
317
+ $(function () {
318
+ return new CropAvatar($('#crop-avatar'));
319
+ });
320
+
321
+ });
@@ -0,0 +1,160 @@
1
+ $(function () {
2
+
3
+ 'use strict';
4
+
5
+ var console = window.console || { log: function () {} },
6
+ $alert = $('.docs-alert'),
7
+ $message = $alert.find('.message'),
8
+ showMessage = function (message, type) {
9
+ $message.text(message);
10
+
11
+ if (type) {
12
+ $message.addClass(type);
13
+ }
14
+
15
+ $alert.fadeIn();
16
+
17
+ setTimeout(function () {
18
+ $alert.fadeOut();
19
+ }, 3000);
20
+ };
21
+
22
+ // Demo
23
+ // -------------------------------------------------------------------------
24
+
25
+ (function () {
26
+ var $image = $('.img-container > img'),
27
+ $dataX = $('#dataX'),
28
+ $dataY = $('#dataY'),
29
+ $dataHeight = $('#dataHeight'),
30
+ $dataWidth = $('#dataWidth'),
31
+ $dataRotate = $('#dataRotate'),
32
+ options = {
33
+ aspectRatio: 16 / 9,
34
+ preview: '.img-preview',
35
+ crop: function (data) {
36
+ $dataX.val(Math.round(data.x));
37
+ $dataY.val(Math.round(data.y));
38
+ $dataHeight.val(Math.round(data.height));
39
+ $dataWidth.val(Math.round(data.width));
40
+ $dataRotate.val(Math.round(data.rotate));
41
+ }
42
+ };
43
+
44
+ $image.on({
45
+ 'build.cropper': function (e) {
46
+ console.log(e.type);
47
+ },
48
+ 'built.cropper': function (e) {
49
+ console.log(e.type);
50
+ }
51
+ }).cropper(options);
52
+
53
+
54
+ // Methods
55
+ $(document.body).on('click', '[data-method]', function () {
56
+ var data = $(this).data(),
57
+ $target,
58
+ result;
59
+
60
+ if (data.method) {
61
+ data = $.extend({}, data); // Clone a new one
62
+
63
+ if (typeof data.target !== 'undefined') {
64
+ $target = $(data.target);
65
+
66
+ if (typeof data.option === 'undefined') {
67
+ try {
68
+ data.option = JSON.parse($target.val());
69
+ } catch (e) {
70
+ console.log(e.message);
71
+ }
72
+ }
73
+ }
74
+
75
+ result = $image.cropper(data.method, data.option);
76
+
77
+ if (data.method === 'getDataURL') {
78
+ $('#getDataURLModal').modal().find('.modal-body').html('<img src="' + result + '">');
79
+ }
80
+
81
+ if ($.isPlainObject(result) && $target) {
82
+ try {
83
+ $target.val(JSON.stringify(result));
84
+ } catch (e) {
85
+ console.log(e.message);
86
+ }
87
+ }
88
+
89
+ }
90
+ }).on('keydown', function (e) {
91
+
92
+ switch (e.which) {
93
+ case 37:
94
+ e.preventDefault();
95
+ $image.cropper('move', -1, 0);
96
+ break;
97
+
98
+ case 38:
99
+ e.preventDefault();
100
+ $image.cropper('move', 0, -1);
101
+ break;
102
+
103
+ case 39:
104
+ e.preventDefault();
105
+ $image.cropper('move', 1, 0);
106
+ break;
107
+
108
+ case 40:
109
+ e.preventDefault();
110
+ $image.cropper('move', 0, 1);
111
+ break;
112
+ }
113
+
114
+ });
115
+
116
+
117
+ // Import image
118
+ var $inputImage = $('#inputImage'),
119
+ URL = window.URL || window.webkitURL,
120
+ blobURL;
121
+
122
+ if (URL) {
123
+ $inputImage.change(function () {
124
+ var files = this.files,
125
+ file;
126
+
127
+ if (files && files.length) {
128
+ file = files[0];
129
+
130
+ if (/^image\/\w+$/.test(file.type)) {
131
+ blobURL = URL.createObjectURL(file);
132
+ $image.one('built.cropper', function () {
133
+ URL.revokeObjectURL(blobURL); // Revoke when load complete
134
+ }).cropper('reset', true).cropper('replace', blobURL);
135
+ $inputImage.val('');
136
+ } else {
137
+ showMessage('Please choose an image file.');
138
+ }
139
+ }
140
+ });
141
+ } else {
142
+ $inputImage.parent().remove();
143
+ }
144
+
145
+
146
+ // Options
147
+ $('.docs-options :checkbox').on('change', function () {
148
+ var $this = $(this);
149
+
150
+ options[$this.val()] = $this.prop('checked');
151
+ $image.cropper('destroy').cropper(options);
152
+ });
153
+
154
+
155
+ // Tooltips
156
+ $('[data-toggle="tooltip"]').tooltip();
157
+
158
+ }());
159
+
160
+ });