rails_marketplace 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -20
- data/README.rdoc +2 -2
- data/Rakefile +37 -37
- data/app/assets/javascripts/rails_marketplace/application.js +46 -46
- data/app/assets/javascripts/rails_marketplace/catalog.coffee +3 -3
- data/app/assets/javascripts/rails_marketplace/flash.js +6 -6
- data/app/assets/javascripts/rails_marketplace/footermanifest.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/autocomplete/countries.js +266 -266
- data/app/assets/javascripts/rails_marketplace/js/autocomplete/jquery.autocomplete.js +986 -986
- data/app/assets/javascripts/rails_marketplace/js/bootstrap.min.js +6 -6
- data/app/assets/javascripts/rails_marketplace/js/calendar/fullcalendar.min.js +8 -8
- data/app/assets/javascripts/rails_marketplace/js/chartjs/chart.min.js +13 -13
- data/app/assets/javascripts/rails_marketplace/js/colorpicker/bootstrap-colorpicker.min.js +1087 -1087
- data/app/assets/javascripts/rails_marketplace/js/colorpicker/docs.js +17 -17
- data/app/assets/javascripts/rails_marketplace/js/cropping/cropper.min.js +9 -9
- data/app/assets/javascripts/rails_marketplace/js/cropping/main.js +321 -321
- data/app/assets/javascripts/rails_marketplace/js/cropping/main2.js +160 -160
- data/app/assets/javascripts/rails_marketplace/js/custom.js +379 -379
- data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.bootstrap.min.css +1 -1
- data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.bootstrap.min.js +6 -6
- data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.html5.min.js +22 -22
- data/app/assets/javascripts/rails_marketplace/js/datatables/buttons.print.min.js +4 -4
- data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.bootstrap.js +8 -8
- data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.buttons.min.js +36 -36
- data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.fixedHeader.min.js +17 -17
- data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.keyTable.min.js +18 -18
- data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.responsive.min.js +25 -25
- data/app/assets/javascripts/rails_marketplace/js/datatables/dataTables.scroller.min.js +26 -26
- data/app/assets/javascripts/rails_marketplace/js/datatables/fixedHeader.bootstrap.min.css +1 -1
- data/app/assets/javascripts/rails_marketplace/js/datatables/jquery.dataTables.min.css +333 -333
- data/app/assets/javascripts/rails_marketplace/js/datatables/jquery.dataTables.min.js +166 -166
- data/app/assets/javascripts/rails_marketplace/js/datatables/json/scroller-demo.json +2501 -2501
- data/app/assets/javascripts/rails_marketplace/js/datatables/jszip.min.js +14 -14
- data/app/assets/javascripts/rails_marketplace/js/datatables/pdfmake.min.js +21 -21
- data/app/assets/javascripts/rails_marketplace/js/datatables/responsive.bootstrap.min.css +1 -1
- data/app/assets/javascripts/rails_marketplace/js/datatables/responsive.bootstrap.min.js +7 -7
- data/app/assets/javascripts/rails_marketplace/js/datatables/scroller.bootstrap.min.css +1 -1
- data/app/assets/javascripts/rails_marketplace/js/dropzone/dropzone.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/easypie/jquery.easypiechart.min.js +9 -9
- data/app/assets/javascripts/rails_marketplace/js/echart/echarts-all.js +35 -35
- data/app/assets/javascripts/rails_marketplace/js/echart/green.js +212 -212
- data/app/assets/javascripts/rails_marketplace/js/editor/bootstrap-wysiwyg.js +200 -200
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-apollo.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-basic.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-clj.js +18 -18
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-css.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-dart.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-erlang.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-go.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-hs.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-lisp.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-llvm.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-lua.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-matlab.js +6 -6
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-ml.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-mumps.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-n.js +4 -4
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-pascal.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-proto.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-r.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-rd.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-scala.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-sql.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-tcl.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-tex.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-vb.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-vhdl.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-wiki.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-xq.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/lang-yaml.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/prettify.js +30 -30
- data/app/assets/javascripts/rails_marketplace/js/editor/external/google-code-prettify/run_prettify.js +34 -34
- data/app/assets/javascripts/rails_marketplace/js/editor/external/jquery.hotkeys.js +99 -99
- data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.orderBars.js +200 -200
- data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.pie.js +820 -820
- data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.resize.js +57 -57
- data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.stack.js +188 -188
- data/app/assets/javascripts/rails_marketplace/js/flot/jquery.flot.tooltip.min.js +11 -11
- data/app/assets/javascripts/rails_marketplace/js/gauge/gauge.min.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/gauge/gauge_demo.js +21 -21
- data/app/assets/javascripts/rails_marketplace/js/icheck/icheck.min.js +11 -11
- data/app/assets/javascripts/rails_marketplace/js/input_mask/jquery.inputmask.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/jquery.min.js +5 -5
- data/app/assets/javascripts/rails_marketplace/js/maps/gdp-data.js +184 -184
- data/app/assets/javascripts/rails_marketplace/js/maps/jquery-jvectormap-2.0.3.min.js +2 -2
- data/app/assets/javascripts/rails_marketplace/js/moment/moment.min.js +6 -6
- data/app/assets/javascripts/rails_marketplace/js/moris/example.js +127 -127
- data/app/assets/javascripts/rails_marketplace/js/moris/morris.min.js +7 -7
- data/app/assets/javascripts/rails_marketplace/js/moris/raphael-min.js +11 -11
- data/app/assets/javascripts/rails_marketplace/js/notify/pnotify.buttons.js +132 -132
- data/app/assets/javascripts/rails_marketplace/js/notify/pnotify.nonblock.js +151 -151
- data/app/assets/javascripts/rails_marketplace/js/nprogress.js +476 -476
- data/app/assets/javascripts/rails_marketplace/js/pace/pace.min.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/parsley/parsley.min.js +8 -8
- data/app/assets/javascripts/rails_marketplace/js/progressbar/bootstrap-progressbar.min.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/select/select2.full.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/sidebar/classie.js +80 -80
- data/app/assets/javascripts/rails_marketplace/js/sidebar/component.css +569 -569
- data/app/assets/javascripts/rails_marketplace/js/sidebar/modernizr.custom.js +3 -3
- data/app/assets/javascripts/rails_marketplace/js/sidebar/sidebarEffects.js +62 -62
- data/app/assets/javascripts/rails_marketplace/js/skycons/skycons.min.js +1 -1
- data/app/assets/javascripts/rails_marketplace/js/sparkline/jquery.sparkline.min.js +4 -4
- data/app/assets/javascripts/rails_marketplace/js/textarea/autosize.min.js +5 -5
- data/app/assets/javascripts/rails_marketplace/less/custom.css +6355 -6355
- data/app/assets/javascripts/rails_marketplace/marketplace.js +17 -17
- data/app/assets/javascripts/rails_marketplace/welcome.coffee +3 -3
- data/app/assets/stylesheets/rails_marketplace/application.scss +30 -30
- data/app/assets/stylesheets/rails_marketplace/catalog.scss +131 -131
- data/app/assets/stylesheets/rails_marketplace/css/animate.min.css +11 -11
- data/app/assets/stylesheets/rails_marketplace/css/bootstrap.min.css +5 -5
- data/app/assets/stylesheets/rails_marketplace/css/calendar/fullcalendar.css +1116 -1116
- data/app/assets/stylesheets/rails_marketplace/css/calendar/fullcalendar.min.css +4 -4
- data/app/assets/stylesheets/rails_marketplace/css/calendar/fullcalendar.print.css +208 -208
- data/app/assets/stylesheets/rails_marketplace/css/colorpicker/bootstrap-colorpicker.min.css +8 -8
- data/app/assets/stylesheets/rails_marketplace/css/custom.css +5347 -5347
- data/app/assets/stylesheets/rails_marketplace/css/datatables/css/demo_page.css +103 -103
- data/app/assets/stylesheets/rails_marketplace/css/datatables/css/demo_table.css +258 -258
- data/app/assets/stylesheets/rails_marketplace/css/datatables/css/demo_table_jui.css +500 -500
- data/app/assets/stylesheets/rails_marketplace/css/datatables/css/jquery.dataTables.css +221 -221
- data/app/assets/stylesheets/rails_marketplace/css/datatables/css/jquery.dataTables_themeroller.css +244 -244
- data/app/assets/stylesheets/rails_marketplace/css/datatables/tools/css/dataTables.tableTools.css +336 -336
- data/app/assets/stylesheets/rails_marketplace/css/editor/index.css +42 -42
- data/app/assets/stylesheets/rails_marketplace/css/floatexamples.css +21 -21
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/_all.css +529 -529
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/aero.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/blue.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/flat.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/green.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/grey.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/orange.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/pink.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/purple.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/red.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/icheck/flat/yellow.css +52 -52
- data/app/assets/stylesheets/rails_marketplace/css/ion.rangeSlider.css +146 -146
- data/app/assets/stylesheets/rails_marketplace/css/ion.rangeSlider.skinFlat.css +106 -106
- data/app/assets/stylesheets/rails_marketplace/css/maps/jquery-jvectormap-2.0.3.css +135 -135
- data/app/assets/stylesheets/rails_marketplace/css/normalize.css +421 -421
- data/app/assets/stylesheets/rails_marketplace/css/nprogress.css +74 -74
- data/app/assets/stylesheets/rails_marketplace/css/progressbar/bootstrap-progressbar-3.3.0.css +161 -161
- data/app/assets/stylesheets/rails_marketplace/css/select/select2.min.css +403 -403
- data/app/assets/stylesheets/rails_marketplace/fonts/css/font-awesome.css +2086 -2086
- data/app/assets/stylesheets/rails_marketplace/fonts/css/font-awesome.min.css +4 -4
- data/app/assets/stylesheets/rails_marketplace/fonts/fonts/FontAwesome.otf +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.svg +654 -654
- data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/fonts/fontawesome-webfont.woff2 +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.svg +287 -287
- data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/assets/stylesheets/rails_marketplace/fonts/less/animated.less +34 -34
- data/app/assets/stylesheets/rails_marketplace/fonts/less/bordered-pulled.less +25 -25
- data/app/assets/stylesheets/rails_marketplace/fonts/less/core.less +12 -12
- data/app/assets/stylesheets/rails_marketplace/fonts/less/fixed-width.less +6 -6
- data/app/assets/stylesheets/rails_marketplace/fonts/less/font-awesome.less +17 -17
- data/app/assets/stylesheets/rails_marketplace/fonts/less/icons.less +697 -697
- data/app/assets/stylesheets/rails_marketplace/fonts/less/larger.less +13 -13
- data/app/assets/stylesheets/rails_marketplace/fonts/less/list.less +19 -19
- data/app/assets/stylesheets/rails_marketplace/fonts/less/mixins.less +26 -26
- data/app/assets/stylesheets/rails_marketplace/fonts/less/path.less +15 -15
- data/app/assets/stylesheets/rails_marketplace/fonts/less/rotated-flipped.less +20 -20
- data/app/assets/stylesheets/rails_marketplace/fonts/less/spinning.less +29 -29
- data/app/assets/stylesheets/rails_marketplace/fonts/less/stacked.less +20 -20
- data/app/assets/stylesheets/rails_marketplace/fonts/less/variables.less +708 -708
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_animated.scss +34 -34
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_bordered-pulled.scss +25 -25
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_core.scss +12 -12
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_fixed-width.scss +6 -6
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_icons.scss +697 -697
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_larger.scss +13 -13
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_list.scss +19 -19
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_mixins.scss +26 -26
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_path.scss +15 -15
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_rotated-flipped.scss +20 -20
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_spinning.scss +29 -29
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_stacked.scss +20 -20
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/_variables.scss +708 -708
- data/app/assets/stylesheets/rails_marketplace/fonts/scss/font-awesome.scss +17 -17
- data/app/assets/stylesheets/rails_marketplace/images/loading.gif +0 -0
- data/app/assets/stylesheets/rails_marketplace/marketplace.scss +19 -19
- data/app/assets/stylesheets/rails_marketplace/pace.css +76 -76
- data/app/assets/stylesheets/rails_marketplace/welcome.scss +3 -3
- data/app/assets/stylesheets/scaffold.css +56 -56
- data/app/controllers/rails_marketplace/admin_controller.rb +150 -150
- data/app/controllers/rails_marketplace/application_controller.rb +4 -4
- data/app/controllers/rails_marketplace/catalog_controller.rb +171 -171
- data/app/controllers/rails_marketplace/seller_controller.rb +180 -180
- data/app/helpers/rails_marketplace/admin_helper.rb +16 -16
- data/app/helpers/rails_marketplace/application_helper.rb +4 -4
- data/app/helpers/rails_marketplace/catalog_helper.rb +4 -4
- data/app/helpers/rails_marketplace/plainpage_helper.rb +4 -4
- data/app/helpers/rails_marketplace/seller_helper.rb +15 -15
- data/app/models/rails_marketplace/admin.rb +9 -9
- data/app/models/rails_marketplace/admin_setting.rb +13 -13
- data/app/models/rails_marketplace/cart.rb +48 -48
- data/app/models/rails_marketplace/cart_product.rb +6 -6
- data/app/models/rails_marketplace/category.rb +21 -21
- data/app/models/rails_marketplace/category_product.rb +5 -5
- data/app/models/rails_marketplace/customer.rb +5 -5
- data/app/models/rails_marketplace/order.rb +21 -21
- data/app/models/rails_marketplace/order_product.rb +6 -6
- data/app/models/rails_marketplace/product.rb +33 -33
- data/app/models/rails_marketplace/seller.rb +12 -12
- data/app/models/rails_marketplace/seller_setting.rb +5 -5
- data/app/views/layouts/rails_marketplace/application.html.erb +37 -37
- data/app/views/layouts/rails_marketplace/seller_central.html.erb +58 -58
- data/app/views/layouts/rails_marketplace/super_admin.html.erb +58 -58
- data/app/views/rails_marketplace/admin/add_category.html.erb +63 -63
- data/app/views/rails_marketplace/admin/categories.html.erb +50 -50
- data/app/views/rails_marketplace/admin/category_products.html.erb +54 -54
- data/app/views/rails_marketplace/admin/dashboard.html.erb +49 -49
- data/app/views/rails_marketplace/admin/edit_category.html.erb +63 -63
- data/app/views/rails_marketplace/admin/login_form.html.erb +19 -19
- data/app/views/rails_marketplace/admin/products.html.erb +54 -54
- data/app/views/rails_marketplace/admin/seller_products.html.erb +54 -54
- data/app/views/rails_marketplace/admin/sellers.html.erb +48 -48
- data/app/views/rails_marketplace/admin/settings_form.html.erb +38 -38
- data/app/views/rails_marketplace/admin/signup_form.html.erb +24 -24
- data/app/views/rails_marketplace/catalog/cart.html.erb +80 -80
- data/app/views/rails_marketplace/catalog/category_products.html.erb +52 -52
- data/app/views/rails_marketplace/catalog/checkout.html.erb +207 -207
- data/app/views/rails_marketplace/catalog/checkout_success.html.erb +14 -14
- data/app/views/rails_marketplace/catalog/index.html.erb +0 -0
- data/app/views/rails_marketplace/catalog/product_detail.html.erb +87 -87
- data/app/views/rails_marketplace/partials/_admin_sidenav.html.erb +80 -80
- data/app/views/rails_marketplace/partials/_admin_topnav.html.erb +111 -111
- data/app/views/rails_marketplace/partials/_footer.html.erb +19 -19
- data/app/views/rails_marketplace/partials/_menu.html.erb +41 -41
- data/app/views/rails_marketplace/partials/_sidenav.html.erb +77 -77
- data/app/views/rails_marketplace/partials/_topnav.html.erb +105 -105
- data/app/views/rails_marketplace/seller/add_bulk_products.html.erb +0 -0
- data/app/views/rails_marketplace/seller/add_product.html.erb +66 -66
- data/app/views/rails_marketplace/seller/dashboard.html.erb +50 -50
- data/app/views/rails_marketplace/seller/edit_product.html.erb +68 -68
- data/app/views/rails_marketplace/seller/login_form.html.erb +36 -36
- data/app/views/rails_marketplace/seller/order_details.html.erb +69 -69
- data/app/views/rails_marketplace/seller/orders.html.erb +68 -68
- data/app/views/rails_marketplace/seller/products.html.erb +55 -55
- data/app/views/rails_marketplace/seller/settings_general.html.erb +64 -64
- data/app/views/rails_marketplace/seller/settings_payment.html.erb +34 -34
- data/app/views/rails_marketplace/seller/settings_shipping.html.erb +34 -34
- data/app/views/rails_marketplace/seller/settings_tax.html.erb +34 -34
- data/app/views/rails_marketplace/seller/signup_form.html.erb +27 -27
- data/app/views/rails_marketplace/seller/step_two.html.erb +16 -16
- data/app/views/rails_marketplace/shared/_admin_error_messages.html.erb +11 -11
- data/app/views/rails_marketplace/shared/_product_error_messages.html.erb +11 -11
- data/app/views/rails_marketplace/shared/_seller_error_messages.html.erb +11 -11
- data/config/routes.rb +58 -58
- data/db/migrate/20161013194852_create_sellers.rb +13 -13
- data/db/migrate/20161013195006_create_customers.rb +13 -13
- data/db/migrate/20161013195758_create_orders.rb +8 -8
- data/db/migrate/20161014013032_create_category_products.rb +10 -10
- data/db/migrate/20161014013058_create_order_products.rb +13 -13
- data/db/migrate/20161017185755_create_admins.rb +12 -12
- data/db/migrate/20161017232347_create_products.rb +14 -14
- data/db/migrate/20161019012043_add_reference_product_seller.rb +5 -5
- data/db/migrate/20161019013502_change_data_type_images_files.rb +6 -6
- data/db/migrate/20161019022020_add_reference_order_customers.rb +5 -5
- data/db/migrate/20161109191644_create_categories.rb +15 -15
- data/db/migrate/20161110021043_create_friendly_id_slugs.rb +15 -15
- data/db/migrate/20161110021131_add_slug_to_category.rb +6 -6
- data/db/migrate/20161110024118_add_slug_to_product.rb +6 -6
- data/db/migrate/20161111001446_create_carts.rb +8 -8
- data/db/migrate/20161111004451_create_cart_products.rb +12 -12
- data/db/migrate/20161115013956_add_currency_format_to_price.rb +6 -6
- data/db/migrate/20161115015227_monetize_product.rb +5 -5
- data/db/migrate/20161115032905_add_stripe_key_to_admin.rb +6 -6
- data/db/migrate/20161124015608_add_order_fields.rb +16 -16
- data/db/migrate/20161207193917_add_seller_to_orders.rb +6 -6
- data/db/migrate/20161208012601_add_price_to_cart_products.rb +6 -6
- data/db/migrate/20161208013402_add_money_to_cart_products.rb +6 -6
- data/db/migrate/20170217183953_create_seller_settings.rb +29 -29
- data/db/migrate/20170218003202_create_admin_settings.rb +24 -24
- data/db/migrate/20170224230449_create_stripe_managed_accounts.rb +9 -9
- data/db/migrate/20170224233736_add_stripe_to_admin_settings.rb +9 -9
- data/db/migrate/20170224235259_add_id_to_settings.rb +6 -6
- data/db/migrate/20170225002939_delete_stripe_accounts.rb +8 -8
- data/db/migrate/20170225003252_add_stripe_account_id_to_seller_settings.rb +5 -5
- data/lib/rails_marketplace.rb +4 -4
- data/lib/rails_marketplace/engine.rb +9 -9
- data/lib/rails_marketplace/version.rb +3 -3
- data/lib/tasks/rails_marketplace_tasks.rake +4 -4
- data/spec/controllers/rails_marketplace/catalog_controller_spec.rb +75 -75
- data/spec/dummy/README.rdoc +28 -28
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/javascripts/application.js +13 -13
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/controllers/application_controller.rb +5 -5
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/views/layouts/application.html.erb +14 -14
- data/spec/dummy/bin/bundle +3 -3
- data/spec/dummy/bin/rails +4 -4
- data/spec/dummy/bin/rake +4 -4
- data/spec/dummy/bin/setup +29 -29
- data/spec/dummy/config.ru +4 -4
- data/spec/dummy/config/application.rb +32 -32
- data/spec/dummy/config/boot.rb +5 -5
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +41 -41
- data/spec/dummy/config/environments/production.rb +79 -79
- data/spec/dummy/config/environments/test.rb +42 -42
- data/spec/dummy/config/initializers/assets.rb +11 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
- data/spec/dummy/config/initializers/inflections.rb +16 -16
- data/spec/dummy/config/initializers/mime_types.rb +4 -4
- data/spec/dummy/config/initializers/session_store.rb +3 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +23 -23
- data/spec/dummy/config/routes.rb +4 -4
- data/spec/dummy/config/secrets.yml +22 -22
- data/spec/dummy/db/schema.rb +194 -194
- data/spec/dummy/log/development.log +889 -889
- data/spec/dummy/log/test.log +1229 -1229
- data/spec/dummy/public/404.html +67 -67
- data/spec/dummy/public/422.html +67 -67
- data/spec/dummy/public/500.html +66 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/rails_marketplace/catalog_helper_spec.rb +17 -17
- data/spec/routing/rails_marketplace/catalog_routing_spec.rb +44 -44
- data/spec/spec_helper.rb +44 -44
- data/spec/views/rails_marketplace/catalog/edit.html.erb_spec.rb +15 -15
- data/spec/views/rails_marketplace/catalog/index.html.erb_spec.rb +15 -15
- data/spec/views/rails_marketplace/catalog/new.html.erb_spec.rb +15 -15
- data/spec/views/rails_marketplace/catalog/show.html.erb_spec.rb +12 -12
- metadata +37 -38
@@ -1,17 +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
|
-
});
|
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
|
+
});
|
@@ -1,10 +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
|
-
*/
|
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
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}});
|
@@ -1,321 +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">×</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
|
-
});
|
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">×</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
|
+
});
|