spree_frontend 4.1.0 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +120 -0
  3. data/.codeclimate.yml +36 -0
  4. data/.deepsource.toml +19 -0
  5. data/.editorconfig +22 -0
  6. data/.eslintignore +7 -0
  7. data/.eslintrc +36 -0
  8. data/.gem_release.yml +7 -0
  9. data/.github/CONTRIBUTING.md +1 -0
  10. data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
  11. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  12. data/.github/ISSUE_TEMPLATE.md +39 -0
  13. data/.github/dependabot.yml +32 -0
  14. data/.gitignore +58 -0
  15. data/.rubocop.yml +197 -0
  16. data/.solargraph.yml +20 -0
  17. data/.stylelintignore +4 -0
  18. data/.stylelintrc +6 -0
  19. data/CODE_OF_CONDUCT.md +22 -0
  20. data/Gemfile +57 -3
  21. data/LICENSE +1 -1
  22. data/README.md +89 -0
  23. data/Rakefile +1 -1
  24. data/SECURITY.md +1 -0
  25. data/app/assets/config/spree_frontend_manifest.js +5 -0
  26. data/app/assets/images/arrow-down.svg +12 -0
  27. data/app/assets/images/arrow-right-circle-fill.svg +3 -0
  28. data/app/assets/images/card-image.svg +4 -0
  29. data/app/assets/images/edit.svg +1 -1
  30. data/app/assets/images/favicon.ico +0 -0
  31. data/app/assets/images/file-image.svg +4 -0
  32. data/app/assets/images/global.svg +1 -0
  33. data/app/assets/images/image.svg +4 -0
  34. data/app/assets/images/info.svg +7 -0
  35. data/app/assets/images/logo/spree_50.png +0 -0
  36. data/app/assets/images/logo-spree.png +0 -0
  37. data/app/assets/images/logo.png +0 -0
  38. data/app/assets/images/logo.svg +10 -1
  39. data/app/assets/images/logo@2x.png +0 -0
  40. data/app/assets/images/logo@3x.png +0 -0
  41. data/app/assets/images/noimage/large.png +0 -0
  42. data/app/assets/images/noimage/mini.png +0 -0
  43. data/app/assets/images/noimage/plp.png +0 -0
  44. data/app/assets/images/noimage/plp.svg +16 -0
  45. data/app/assets/images/noimage/product.png +0 -0
  46. data/app/assets/images/noimage/small.png +0 -0
  47. data/app/assets/images/pagination-arrow-right.svg +3 -10
  48. data/app/assets/images/pagination-double-arrow-right.svg +6 -13
  49. data/app/assets/images/plus.svg +1 -1
  50. data/app/assets/images/search.svg +1 -1
  51. data/app/assets/javascripts/spree/frontend/account.js +1 -1
  52. data/app/assets/javascripts/spree/frontend/api/main.js +36 -0
  53. data/app/assets/javascripts/spree/frontend/api/storefront/cart.js +49 -0
  54. data/app/assets/javascripts/spree/frontend/cart.js +24 -2
  55. data/app/assets/javascripts/spree/frontend/checkout/address.js +78 -52
  56. data/app/assets/javascripts/spree/frontend/checkout/address_book.js +38 -40
  57. data/app/assets/javascripts/spree/frontend/checkout/payment.js +63 -23
  58. data/app/assets/javascripts/spree/frontend/checkout/shipment.js +15 -2
  59. data/app/assets/javascripts/spree/frontend/checkout.js +17 -1
  60. data/app/assets/javascripts/spree/frontend/coupon_manager.js +1 -1
  61. data/app/assets/javascripts/spree/frontend/currency.js +44 -0
  62. data/app/assets/javascripts/spree/frontend/locale.es6 +12 -0
  63. data/app/assets/javascripts/spree/frontend/login.js +5 -0
  64. data/app/assets/javascripts/spree/frontend/main.js +78 -0
  65. data/app/assets/javascripts/spree/frontend/main_nav_bar.js +86 -0
  66. data/app/assets/javascripts/spree/frontend/{turbolinks_scroll_fix.js → turbo_scroll_fix.js} +3 -3
  67. data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +4 -4
  68. data/app/assets/javascripts/spree/frontend/views/spree/product/related.js +3 -3
  69. data/app/assets/javascripts/spree/frontend/views/spree/products/cart_form.js +67 -18
  70. data/app/assets/javascripts/spree/frontend/views/spree/products/description.js +1 -1
  71. data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +76 -15
  72. data/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6 +46 -0
  73. data/app/assets/javascripts/spree/frontend/views/spree/shared/mobile_navigation.js +9 -10
  74. data/app/assets/javascripts/spree/frontend/views/spree/shared/product_added_modal.js +7 -0
  75. data/app/assets/javascripts/spree/frontend/views/spree/shared/variant_select.js +93 -0
  76. data/app/assets/javascripts/spree/frontend.js +68 -11
  77. data/app/assets/stylesheets/spree/frontend/application.scss +5 -2
  78. data/app/assets/stylesheets/spree/frontend/components-bootstrap/button.scss +8 -0
  79. data/app/assets/stylesheets/spree/frontend/components-bootstrap/carousel.scss +4 -0
  80. data/app/assets/stylesheets/spree/frontend/components-custom/inputs.scss +80 -1
  81. data/app/assets/stylesheets/spree/frontend/flags/_flag-icon-base.scss +23 -0
  82. data/app/assets/stylesheets/spree/frontend/flags/_flag-icon-list.scss +265 -0
  83. data/app/assets/stylesheets/spree/frontend/flags/_variables.scss +2 -0
  84. data/app/assets/stylesheets/spree/frontend/flags/flag-icon.scss +3 -0
  85. data/app/assets/stylesheets/spree/frontend/functions.scss +1 -0
  86. data/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss +48 -0
  87. data/app/assets/stylesheets/spree/frontend/variables/bootstrap-overrides.scss +2 -2
  88. data/app/assets/stylesheets/spree/frontend/variables/helper-variables.scss +1 -0
  89. data/app/assets/stylesheets/spree/frontend/variables/variables.scss +54 -0
  90. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/confirm.scss +27 -26
  91. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/delivery.scss +6 -0
  92. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/edit.scss +24 -10
  93. data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss +1 -0
  94. data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss +20 -0
  95. data/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss +54 -67
  96. data/app/assets/stylesheets/spree/frontend/views/spree/orders/edit.scss +4 -3
  97. data/app/assets/stylesheets/spree/frontend/views/spree/orders/show.scss +3 -0
  98. data/app/assets/stylesheets/spree/frontend/views/spree/products/cart_form.scss +8 -0
  99. data/app/assets/stylesheets/spree/frontend/views/spree/products/gallery_modal.scss +7 -0
  100. data/app/assets/stylesheets/spree/frontend/views/spree/products/index.scss +55 -26
  101. data/app/assets/stylesheets/spree/frontend/views/spree/products/show.scss +7 -0
  102. data/app/assets/stylesheets/spree/frontend/views/spree/shared/_color_select.scss +10 -9
  103. data/app/assets/stylesheets/spree/frontend/views/spree/shared/carousel/single.scss +1 -1
  104. data/app/assets/stylesheets/spree/frontend/views/spree/shared/carousel/thumbnails.scss +1 -0
  105. data/app/assets/stylesheets/spree/frontend/views/spree/shared/cart.scss +9 -4
  106. data/app/assets/stylesheets/spree/frontend/views/spree/shared/category_nav_bar.scss +3 -3
  107. data/app/assets/stylesheets/spree/frontend/views/spree/shared/change_store.scss +7 -0
  108. data/app/assets/stylesheets/spree/frontend/views/spree/shared/footer.scss +4 -0
  109. data/app/assets/stylesheets/spree/frontend/views/spree/shared/main_nav_bar.scss +42 -26
  110. data/app/assets/stylesheets/spree/frontend/views/spree/shared/mobile_navigation.scss +34 -3
  111. data/app/assets/stylesheets/spree/frontend/views/spree/shared/nav_bar.scss +24 -7
  112. data/app/assets/stylesheets/spree/frontend/views/spree/shared/quantity_select.scss +9 -12
  113. data/app/assets/stylesheets/spree/frontend/views/spree/shared/search_form.scss +12 -0
  114. data/app/assets/stylesheets/spree/frontend/views/spree/users/show.scss +7 -13
  115. data/app/assets/stylesheets/spree/frontend.css +0 -1
  116. data/app/controllers/concerns/spree/checkout/address_book.rb +9 -7
  117. data/app/controllers/concerns/spree/locale_urls.rb +21 -0
  118. data/app/controllers/spree/addresses_controller.rb +16 -33
  119. data/app/controllers/spree/checkout_controller.rb +15 -13
  120. data/app/controllers/spree/cms_pages_controller.rb +29 -0
  121. data/app/controllers/spree/content_controller.rb +0 -2
  122. data/app/controllers/spree/currency_controller.rb +17 -0
  123. data/app/controllers/spree/errors_controller.rb +11 -0
  124. data/app/controllers/spree/home_controller.rb +38 -1
  125. data/app/controllers/spree/locale_controller.rb +35 -6
  126. data/app/controllers/spree/orders_controller.rb +12 -10
  127. data/app/controllers/spree/products_controller.rb +46 -28
  128. data/app/controllers/spree/store_controller.rb +77 -12
  129. data/app/controllers/spree/taxons_controller.rb +16 -8
  130. data/app/helpers/spree/addresses_helper.rb +64 -12
  131. data/app/helpers/spree/cache_helper.rb +7 -0
  132. data/app/helpers/spree/cms_pages_helper.rb +23 -0
  133. data/app/helpers/spree/frontend_helper.rb +170 -18
  134. data/app/helpers/spree/navigation_helper.rb +81 -4
  135. data/app/helpers/spree/products_filters_helper.rb +168 -0
  136. data/app/helpers/spree/store_helper.rb +41 -0
  137. data/app/helpers/spree/structured_data_helper.rb +6 -2
  138. data/app/helpers/spree/taxons_helper.rb +2 -2
  139. data/app/services/spree/build_localized_redirect_url.rb +141 -0
  140. data/app/views/kaminari/twitter-bootstrap-4/_first_page.html.erb +3 -3
  141. data/app/views/kaminari/twitter-bootstrap-4/_gap.html.erb +2 -2
  142. data/app/views/kaminari/twitter-bootstrap-4/_last_page.html.erb +3 -3
  143. data/app/views/kaminari/twitter-bootstrap-4/_next_page.html.erb +3 -3
  144. data/app/views/kaminari/twitter-bootstrap-4/_page.html.erb +2 -2
  145. data/app/views/kaminari/twitter-bootstrap-4/_paginator.html.erb +2 -2
  146. data/app/views/kaminari/twitter-bootstrap-4/_prev_page.html.erb +3 -3
  147. data/app/views/spree/address/_form.html.erb +26 -27
  148. data/app/views/spree/addresses/_form.html.erb +15 -6
  149. data/app/views/spree/addresses/edit.html.erb +13 -8
  150. data/app/views/spree/addresses/new.html.erb +8 -4
  151. data/app/views/spree/checkout/_address.html.erb +19 -23
  152. data/app/views/spree/checkout/_confirm.html.erb +1 -75
  153. data/app/views/spree/checkout/_credit_card.html.erb +3 -2
  154. data/app/views/spree/checkout/_delivery.html.erb +11 -4
  155. data/app/views/spree/checkout/_delivery_informations.html.erb +51 -0
  156. data/app/views/spree/checkout/_payment.html.erb +5 -24
  157. data/app/views/spree/checkout/_payment_sources.html.erb +17 -0
  158. data/app/views/spree/checkout/_summary.html.erb +22 -19
  159. data/app/views/spree/checkout/edit.html.erb +22 -2
  160. data/app/views/spree/checkout/payment/_gateway.html.erb +2 -2
  161. data/app/views/spree/checkout/registration.html.erb +3 -3
  162. data/app/views/spree/cms_pages/show.html.erb +16 -0
  163. data/app/views/spree/errors/not_found.html.erb +2 -2
  164. data/app/views/spree/home/index.html.erb +17 -123
  165. data/app/views/spree/layouts/checkout.html.erb +3 -1
  166. data/app/views/spree/layouts/spree_application.html.erb +3 -2
  167. data/app/views/spree/locale/index.html.erb +1 -0
  168. data/app/views/spree/orders/_coupon_code.html.erb +3 -4
  169. data/app/views/spree/orders/_line_item.html.erb +4 -4
  170. data/app/views/spree/orders/_line_item_data.html.erb +3 -3
  171. data/app/views/spree/orders/edit.html.erb +2 -3
  172. data/app/views/spree/orders/show.html.erb +2 -72
  173. data/app/views/spree/products/_cart_form.html.erb +5 -2
  174. data/app/views/spree/products/_color_option_type.html.erb +14 -14
  175. data/app/views/spree/products/_description.html.erb +19 -14
  176. data/app/views/spree/products/_filters_desktop.html.erb +80 -40
  177. data/app/views/spree/products/_filters_mobile.html.erb +47 -15
  178. data/app/views/spree/products/_gallery.html.erb +4 -6
  179. data/app/views/spree/products/_gallery_modal.html.erb +4 -6
  180. data/app/views/spree/products/_option_type.html.erb +1 -3
  181. data/app/views/spree/products/_product.html.erb +1 -1
  182. data/app/views/spree/products/_properties.html.erb +6 -4
  183. data/app/views/spree/products/_sort_desktop.html.erb +20 -14
  184. data/app/views/spree/products/_sort_mobile.html.erb +24 -8
  185. data/app/views/spree/products/_thumbnails.html.erb +2 -2
  186. data/app/views/spree/products/index.html.erb +7 -4
  187. data/app/views/spree/products/related.html.erb +11 -5
  188. data/app/views/spree/products/show.html.erb +2 -3
  189. data/app/views/spree/shared/_breadcrumbs.html.erb +2 -2
  190. data/app/views/spree/shared/_carousel_4_products.html.erb +14 -20
  191. data/app/views/spree/shared/_cart.html.erb +1 -1
  192. data/app/views/spree/shared/_checkout_header.html.erb +22 -21
  193. data/app/views/spree/shared/_color_select.html.erb +3 -3
  194. data/app/views/spree/shared/_copyright.html.erb +1 -10
  195. data/app/views/spree/shared/_currency_dropdown.html.erb +13 -0
  196. data/app/views/spree/shared/_delete_address_popup.html.erb +1 -2
  197. data/app/views/spree/shared/_error_messages.html.erb +2 -2
  198. data/app/views/spree/shared/_footer.html.erb +31 -21
  199. data/app/views/spree/shared/_get_started.html.erb +32 -0
  200. data/app/views/spree/shared/_head.html.erb +8 -5
  201. data/app/views/spree/shared/_header.html.erb +4 -4
  202. data/app/views/spree/shared/_internationalization_options.html.erb +31 -0
  203. data/app/views/spree/shared/_line_item.html.erb +3 -3
  204. data/app/views/spree/shared/_link_to_account.html.erb +7 -4
  205. data/app/views/spree/shared/_link_to_cart.html.erb +1 -2
  206. data/app/views/spree/shared/_locale_and_currency.html.erb +6 -0
  207. data/app/views/spree/shared/_locale_dropdown.html.erb +13 -0
  208. data/app/views/spree/shared/_login.html.erb +5 -5
  209. data/app/views/spree/shared/_main_nav_bar.html.erb +69 -45
  210. data/app/views/spree/shared/_mobile_internationalization_options.html.erb +37 -0
  211. data/app/views/spree/shared/_mobile_navigation.html.erb +48 -63
  212. data/app/views/spree/shared/_nav_bar.html.erb +9 -19
  213. data/app/views/spree/shared/_no_product_available.html.erb +1 -1
  214. data/app/views/spree/shared/_option_values.html.erb +2 -21
  215. data/app/views/spree/shared/_order_details.html.erb +117 -174
  216. data/app/views/spree/shared/_paths.html.erb +8 -0
  217. data/app/views/spree/shared/_payment.html.erb +2 -2
  218. data/app/views/spree/shared/_payment_sources.html.erb +2 -2
  219. data/app/views/spree/shared/_product_added_modal.html.erb +3 -3
  220. data/app/views/spree/shared/_properties.html.erb +4 -0
  221. data/app/views/spree/shared/_quantity_select.html.erb +2 -2
  222. data/app/views/spree/shared/_search.html.erb +9 -13
  223. data/app/views/spree/shared/_translations.html.erb +8 -7
  224. data/app/views/spree/shared/carousel/_single.html.erb +9 -14
  225. data/app/views/spree/shared/carousel/_thumbnails.html.erb +35 -39
  226. data/app/views/spree/shared/cms/pages/_edit_mode.html.erb +13 -0
  227. data/app/views/spree/shared/cms/sections/_featured_article.html.erb +27 -0
  228. data/app/views/spree/shared/cms/sections/_hero_image.html.erb +60 -0
  229. data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +171 -0
  230. data/app/views/spree/shared/cms/sections/_product_carousel.html.erb +5 -0
  231. data/app/views/spree/shared/cms/sections/_rich_text_content.html.erb +3 -0
  232. data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +118 -0
  233. data/app/views/spree/taxons/_header.html.erb +7 -2
  234. data/app/views/spree/users/_address.html.erb +16 -24
  235. data/app/views/spree/users/_address_controls.html.erb +10 -0
  236. data/app/views/spree/users/show.html.erb +21 -16
  237. data/config/initializers/admin_actions.rb +18 -0
  238. data/config/initializers/assets.rb +4 -13
  239. data/config/initializers/canonical_rails.rb +1 -1
  240. data/config/routes.rb +30 -26
  241. data/lib/generators/spree/frontend/copy_storefront/copy_storefront_generator.rb +1 -7
  242. data/lib/generators/spree/frontend/install/install_generator.rb +34 -0
  243. data/lib/generators/spree/frontend/install/templates/app/assets/config/manifest.js +2 -0
  244. data/lib/generators/spree/frontend/install/templates/vendor/assets/javascripts/spree/frontend/all.js +8 -0
  245. data/lib/generators/spree/frontend/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +9 -0
  246. data/lib/spree/frontend/configuration.rb +18 -0
  247. data/lib/spree/frontend/engine.rb +3 -1
  248. data/lib/spree/frontend/version.rb +9 -0
  249. data/lib/spree/frontend.rb +8 -4
  250. data/license.md +13 -0
  251. data/spec/fixtures/files/store_favicon.ico +0 -0
  252. data/spree_frontend.gemspec +26 -14
  253. data/vendor/assets/javascripts/cleave.js +8 -0
  254. data/vendor/assets/javascripts/fetch.umd.js +531 -0
  255. data/vendor/assets/javascripts/jquery.payment.js +652 -0
  256. data/vendor/assets/javascripts/jsuri.js +458 -0
  257. data/vendor/assets/javascripts/polyfill.min.js +1 -0
  258. metadata +224 -86
  259. data/app/assets/images/homepage/big_category_banner.jpg +0 -0
  260. data/app/assets/images/homepage/big_category_banner_mobile.jpg +0 -0
  261. data/app/assets/images/homepage/big_category_banner_tablet_landscape.jpg +0 -0
  262. data/app/assets/images/homepage/big_category_banner_tablet_portrait.jpg +0 -0
  263. data/app/assets/images/homepage/category_banner_lower.jpg +0 -0
  264. data/app/assets/images/homepage/category_banner_lower_mobile.jpg +0 -0
  265. data/app/assets/images/homepage/category_banner_lower_tablet_landscape.jpg +0 -0
  266. data/app/assets/images/homepage/category_banner_lower_tablet_portrait.jpg +0 -0
  267. data/app/assets/images/homepage/category_banner_upper.jpg +0 -0
  268. data/app/assets/images/homepage/category_banner_upper_mobile.jpg +0 -0
  269. data/app/assets/images/homepage/category_banner_upper_tablet_landscape.jpg +0 -0
  270. data/app/assets/images/homepage/category_banner_upper_tablet_portrait.jpg +0 -0
  271. data/app/assets/images/homepage/main_banner.jpg +0 -0
  272. data/app/assets/images/homepage/main_banner_mobile.jpg +0 -0
  273. data/app/assets/images/homepage/main_banner_tablet_landscape.jpg +0 -0
  274. data/app/assets/images/homepage/main_banner_tablet_portrait.jpg +0 -0
  275. data/app/assets/images/homepage/promo_banner_left.jpg +0 -0
  276. data/app/assets/images/homepage/promo_banner_left_mobile.jpg +0 -0
  277. data/app/assets/images/homepage/promo_banner_left_tablet_landscape.jpg +0 -0
  278. data/app/assets/images/homepage/promo_banner_left_tablet_portrait.jpg +0 -0
  279. data/app/assets/images/homepage/promo_banner_right.jpg +0 -0
  280. data/app/assets/images/homepage/promo_banner_right_mobile.jpg +0 -0
  281. data/app/assets/images/homepage/promo_banner_right_tablet_landscape.jpg +0 -0
  282. data/app/assets/images/homepage/promo_banner_right_tablet_portrait.jpg +0 -0
  283. data/app/assets/images/meganav/promo_banner_left-first-category.jpg +0 -0
  284. data/app/assets/images/meganav/promo_banner_left-second-category.jpg +0 -0
  285. data/app/assets/images/meganav/promo_banner_left-third-category.jpg +0 -0
  286. data/app/assets/images/meganav/promo_banner_right-first-category.jpg +0 -0
  287. data/app/assets/images/meganav/promo_banner_right-second-category.jpg +0 -0
  288. data/app/assets/images/meganav/promo_banner_right-third-category.jpg +0 -0
  289. data/app/assets/images/noimage/big_category_banner.jpg +0 -0
  290. data/app/assets/images/noimage/big_category_banner_mobile.jpg +0 -0
  291. data/app/assets/images/noimage/big_category_banner_tablet_landscape.jpg +0 -0
  292. data/app/assets/images/noimage/big_category_banner_tablet_portrait.jpg +0 -0
  293. data/app/assets/images/noimage/category_banner.jpg +0 -0
  294. data/app/assets/images/noimage/category_banner_mobile.jpg +0 -0
  295. data/app/assets/images/noimage/category_banner_plp.jpg +0 -0
  296. data/app/assets/images/noimage/category_banner_tablet_landscape.jpg +0 -0
  297. data/app/assets/images/noimage/category_banner_tablet_portrait.jpg +0 -0
  298. data/app/assets/images/noimage/main_banner.jpg +0 -0
  299. data/app/assets/images/noimage/main_banner_mobile.jpg +0 -0
  300. data/app/assets/images/noimage/main_banner_tablet_landscape.jpg +0 -0
  301. data/app/assets/images/noimage/main_banner_tablet_portrait.jpg +0 -0
  302. data/app/assets/images/noimage/product_photo.jpg +0 -0
  303. data/app/assets/images/noimage/promo_banner.jpg +0 -0
  304. data/app/assets/images/noimage/promo_banner_megamenu.jpg +0 -0
  305. data/app/assets/images/noimage/promo_banner_mobile.jpg +0 -0
  306. data/app/assets/images/noimage/promo_banner_tablet_landscape.jpg +0 -0
  307. data/app/assets/images/noimage/promo_banner_tablet_portrait.jpg +0 -0
  308. data/app/assets/images/spark-logo@3x.png +0 -0
  309. data/app/assets/stylesheets/spree/frontend/_glyphicons_urls_fix.scss +0 -10
  310. data/app/assets/stylesheets/spree/frontend/address_book.scss +0 -8
  311. data/app/models/spree/frontend_configuration.rb +0 -7
  312. data/app/views/spree/shared/_taxonomies.html.erb +0 -16
  313. /data/app/views/spree/{shared → errors}/forbidden.html.erb +0 -0
  314. /data/app/views/spree/{shared → errors}/unauthorized.html.erb +0 -0
@@ -0,0 +1,652 @@
1
+ // Generated by CoffeeScript 1.7.1
2
+ (function() {
3
+ var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCVC, reFormatCardNumber, reFormatExpiry, reFormatNumeric, replaceFullWidthChars, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, safeVal, setCardType,
4
+ __slice = [].slice,
5
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
6
+
7
+ $ = window.jQuery || window.Zepto || window.$;
8
+
9
+ $.payment = {};
10
+
11
+ $.payment.fn = {};
12
+
13
+ $.fn.payment = function() {
14
+ var args, method;
15
+ method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
16
+ return $.payment.fn[method].apply(this, args);
17
+ };
18
+
19
+ defaultFormat = /(\d{1,4})/g;
20
+
21
+ $.payment.cards = cards = [
22
+ {
23
+ type: 'maestro',
24
+ patterns: [5018, 502, 503, 506, 56, 58, 639, 6220, 67],
25
+ format: defaultFormat,
26
+ length: [12, 13, 14, 15, 16, 17, 18, 19],
27
+ cvcLength: [3],
28
+ luhn: true
29
+ }, {
30
+ type: 'forbrugsforeningen',
31
+ patterns: [600],
32
+ format: defaultFormat,
33
+ length: [16],
34
+ cvcLength: [3],
35
+ luhn: true
36
+ }, {
37
+ type: 'dankort',
38
+ patterns: [5019],
39
+ format: defaultFormat,
40
+ length: [16],
41
+ cvcLength: [3],
42
+ luhn: true
43
+ }, {
44
+ type: 'visa',
45
+ patterns: [4],
46
+ format: defaultFormat,
47
+ length: [13, 16],
48
+ cvcLength: [3],
49
+ luhn: true
50
+ }, {
51
+ type: 'mastercard',
52
+ patterns: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],
53
+ format: defaultFormat,
54
+ length: [16],
55
+ cvcLength: [3],
56
+ luhn: true
57
+ }, {
58
+ type: 'amex',
59
+ patterns: [34, 37],
60
+ format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
61
+ length: [15],
62
+ cvcLength: [3, 4],
63
+ luhn: true
64
+ }, {
65
+ type: 'dinersclub',
66
+ patterns: [30, 36, 38, 39],
67
+ format: /(\d{1,4})(\d{1,6})?(\d{1,4})?/,
68
+ length: [14],
69
+ cvcLength: [3],
70
+ luhn: true
71
+ }, {
72
+ type: 'discover',
73
+ patterns: [60, 64, 65, 622],
74
+ format: defaultFormat,
75
+ length: [16],
76
+ cvcLength: [3],
77
+ luhn: true
78
+ }, {
79
+ type: 'unionpay',
80
+ patterns: [62, 88],
81
+ format: defaultFormat,
82
+ length: [16, 17, 18, 19],
83
+ cvcLength: [3],
84
+ luhn: false
85
+ }, {
86
+ type: 'jcb',
87
+ patterns: [35],
88
+ format: defaultFormat,
89
+ length: [16],
90
+ cvcLength: [3],
91
+ luhn: true
92
+ }
93
+ ];
94
+
95
+ cardFromNumber = function(num) {
96
+ var card, p, pattern, _i, _j, _len, _len1, _ref;
97
+ num = (num + '').replace(/\D/g, '');
98
+ for (_i = 0, _len = cards.length; _i < _len; _i++) {
99
+ card = cards[_i];
100
+ _ref = card.patterns;
101
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
102
+ pattern = _ref[_j];
103
+ p = pattern + '';
104
+ if (num.substr(0, p.length) === p) {
105
+ return card;
106
+ }
107
+ }
108
+ }
109
+ };
110
+
111
+ cardFromType = function(type) {
112
+ var card, _i, _len;
113
+ for (_i = 0, _len = cards.length; _i < _len; _i++) {
114
+ card = cards[_i];
115
+ if (card.type === type) {
116
+ return card;
117
+ }
118
+ }
119
+ };
120
+
121
+ luhnCheck = function(num) {
122
+ var digit, digits, odd, sum, _i, _len;
123
+ odd = true;
124
+ sum = 0;
125
+ digits = (num + '').split('').reverse();
126
+ for (_i = 0, _len = digits.length; _i < _len; _i++) {
127
+ digit = digits[_i];
128
+ digit = parseInt(digit, 10);
129
+ if ((odd = !odd)) {
130
+ digit *= 2;
131
+ }
132
+ if (digit > 9) {
133
+ digit -= 9;
134
+ }
135
+ sum += digit;
136
+ }
137
+ return sum % 10 === 0;
138
+ };
139
+
140
+ hasTextSelected = function($target) {
141
+ var _ref;
142
+ if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== $target.prop('selectionEnd')) {
143
+ return true;
144
+ }
145
+ if ((typeof document !== "undefined" && document !== null ? (_ref = document.selection) != null ? _ref.createRange : void 0 : void 0) != null) {
146
+ if (document.selection.createRange().text) {
147
+ return true;
148
+ }
149
+ }
150
+ return false;
151
+ };
152
+
153
+ safeVal = function(value, $target) {
154
+ var currPair, cursor, digit, error, last, prevPair;
155
+ try {
156
+ cursor = $target.prop('selectionStart');
157
+ } catch (_error) {
158
+ error = _error;
159
+ cursor = null;
160
+ }
161
+ last = $target.val();
162
+ $target.val(value);
163
+ if (cursor !== null && $target.is(":focus")) {
164
+ if (cursor === last.length) {
165
+ cursor = value.length;
166
+ }
167
+ if (last !== value) {
168
+ prevPair = last.slice(cursor - 1, +cursor + 1 || 9e9);
169
+ currPair = value.slice(cursor - 1, +cursor + 1 || 9e9);
170
+ digit = value[cursor];
171
+ if (/\d/.test(digit) && prevPair === ("" + digit + " ") && currPair === (" " + digit)) {
172
+ cursor = cursor + 1;
173
+ }
174
+ }
175
+ $target.prop('selectionStart', cursor);
176
+ return $target.prop('selectionEnd', cursor);
177
+ }
178
+ };
179
+
180
+ replaceFullWidthChars = function(str) {
181
+ var chars, chr, fullWidth, halfWidth, idx, value, _i, _len;
182
+ if (str == null) {
183
+ str = '';
184
+ }
185
+ fullWidth = '\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19';
186
+ halfWidth = '0123456789';
187
+ value = '';
188
+ chars = str.split('');
189
+ for (_i = 0, _len = chars.length; _i < _len; _i++) {
190
+ chr = chars[_i];
191
+ idx = fullWidth.indexOf(chr);
192
+ if (idx > -1) {
193
+ chr = halfWidth[idx];
194
+ }
195
+ value += chr;
196
+ }
197
+ return value;
198
+ };
199
+
200
+ reFormatNumeric = function(e) {
201
+ var $target;
202
+ $target = $(e.currentTarget);
203
+ return setTimeout(function() {
204
+ var value;
205
+ value = $target.val();
206
+ value = replaceFullWidthChars(value);
207
+ value = value.replace(/\D/g, '');
208
+ return safeVal(value, $target);
209
+ });
210
+ };
211
+
212
+ reFormatCardNumber = function(e) {
213
+ var $target;
214
+ $target = $(e.currentTarget);
215
+ return setTimeout(function() {
216
+ var value;
217
+ value = $target.val();
218
+ value = replaceFullWidthChars(value);
219
+ value = $.payment.formatCardNumber(value);
220
+ return safeVal(value, $target);
221
+ });
222
+ };
223
+
224
+ formatCardNumber = function(e) {
225
+ var $target, card, digit, length, re, upperLength, value;
226
+ digit = String.fromCharCode(e.which);
227
+ if (!/^\d+$/.test(digit)) {
228
+ return;
229
+ }
230
+ $target = $(e.currentTarget);
231
+ value = $target.val();
232
+ card = cardFromNumber(value + digit);
233
+ length = (value.replace(/\D/g, '') + digit).length;
234
+ upperLength = 16;
235
+ if (card) {
236
+ upperLength = card.length[card.length.length - 1];
237
+ }
238
+ if (length >= upperLength) {
239
+ return;
240
+ }
241
+ if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
242
+ return;
243
+ }
244
+ if (card && card.type === 'amex') {
245
+ re = /^(\d{4}|\d{4}\s\d{6})$/;
246
+ } else {
247
+ re = /(?:^|\s)(\d{4})$/;
248
+ }
249
+ if (re.test(value)) {
250
+ e.preventDefault();
251
+ return setTimeout(function() {
252
+ return $target.val(value + ' ' + digit);
253
+ });
254
+ } else if (re.test(value + digit)) {
255
+ e.preventDefault();
256
+ return setTimeout(function() {
257
+ return $target.val(value + digit + ' ');
258
+ });
259
+ }
260
+ };
261
+
262
+ formatBackCardNumber = function(e) {
263
+ var $target, value;
264
+ $target = $(e.currentTarget);
265
+ value = $target.val();
266
+ if (e.which !== 8) {
267
+ return;
268
+ }
269
+ if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
270
+ return;
271
+ }
272
+ if (/\d\s$/.test(value)) {
273
+ e.preventDefault();
274
+ return setTimeout(function() {
275
+ return $target.val(value.replace(/\d\s$/, ''));
276
+ });
277
+ } else if (/\s\d?$/.test(value)) {
278
+ e.preventDefault();
279
+ return setTimeout(function() {
280
+ return $target.val(value.replace(/\d$/, ''));
281
+ });
282
+ }
283
+ };
284
+
285
+ reFormatExpiry = function(e) {
286
+ var $target;
287
+ $target = $(e.currentTarget);
288
+ return setTimeout(function() {
289
+ var value;
290
+ value = $target.val();
291
+ value = replaceFullWidthChars(value);
292
+ value = $.payment.formatExpiry(value);
293
+ return safeVal(value, $target);
294
+ });
295
+ };
296
+
297
+ formatExpiry = function(e) {
298
+ var $target, digit, val;
299
+ digit = String.fromCharCode(e.which);
300
+ if (!/^\d+$/.test(digit)) {
301
+ return;
302
+ }
303
+ $target = $(e.currentTarget);
304
+ val = $target.val() + digit;
305
+ if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
306
+ e.preventDefault();
307
+ return setTimeout(function() {
308
+ return $target.val("0" + val + " / ");
309
+ });
310
+ } else if (/^\d\d$/.test(val)) {
311
+ e.preventDefault();
312
+ return setTimeout(function() {
313
+ var m1, m2;
314
+ m1 = parseInt(val[0], 10);
315
+ m2 = parseInt(val[1], 10);
316
+ if (m2 > 2 && m1 !== 0) {
317
+ return $target.val("0" + m1 + " / " + m2);
318
+ } else {
319
+ return $target.val("" + val + " / ");
320
+ }
321
+ });
322
+ }
323
+ };
324
+
325
+ formatForwardExpiry = function(e) {
326
+ var $target, digit, val;
327
+ digit = String.fromCharCode(e.which);
328
+ if (!/^\d+$/.test(digit)) {
329
+ return;
330
+ }
331
+ $target = $(e.currentTarget);
332
+ val = $target.val();
333
+ if (/^\d\d$/.test(val)) {
334
+ return $target.val("" + val + " / ");
335
+ }
336
+ };
337
+
338
+ formatForwardSlashAndSpace = function(e) {
339
+ var $target, val, which;
340
+ which = String.fromCharCode(e.which);
341
+ if (!(which === '/' || which === ' ')) {
342
+ return;
343
+ }
344
+ $target = $(e.currentTarget);
345
+ val = $target.val();
346
+ if (/^\d$/.test(val) && val !== '0') {
347
+ return $target.val("0" + val + " / ");
348
+ }
349
+ };
350
+
351
+ formatBackExpiry = function(e) {
352
+ var $target, value;
353
+ $target = $(e.currentTarget);
354
+ value = $target.val();
355
+ if (e.which !== 8) {
356
+ return;
357
+ }
358
+ if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
359
+ return;
360
+ }
361
+ if (/\d\s\/\s$/.test(value)) {
362
+ e.preventDefault();
363
+ return setTimeout(function() {
364
+ return $target.val(value.replace(/\d\s\/\s$/, ''));
365
+ });
366
+ }
367
+ };
368
+
369
+ reFormatCVC = function(e) {
370
+ var $target;
371
+ $target = $(e.currentTarget);
372
+ return setTimeout(function() {
373
+ var value;
374
+ value = $target.val();
375
+ value = replaceFullWidthChars(value);
376
+ value = value.replace(/\D/g, '').slice(0, 4);
377
+ return safeVal(value, $target);
378
+ });
379
+ };
380
+
381
+ restrictNumeric = function(e) {
382
+ var input;
383
+ if (e.metaKey || e.ctrlKey) {
384
+ return true;
385
+ }
386
+ if (e.which === 32) {
387
+ return false;
388
+ }
389
+ if (e.which === 0) {
390
+ return true;
391
+ }
392
+ if (e.which < 33) {
393
+ return true;
394
+ }
395
+ input = String.fromCharCode(e.which);
396
+ return !!/[\d\s]/.test(input);
397
+ };
398
+
399
+ restrictCardNumber = function(e) {
400
+ var $target, card, digit, value;
401
+ $target = $(e.currentTarget);
402
+ digit = String.fromCharCode(e.which);
403
+ if (!/^\d+$/.test(digit)) {
404
+ return;
405
+ }
406
+ if (hasTextSelected($target)) {
407
+ return;
408
+ }
409
+ value = ($target.val() + digit).replace(/\D/g, '');
410
+ card = cardFromNumber(value);
411
+ if (card) {
412
+ return value.length <= card.length[card.length.length - 1];
413
+ } else {
414
+ return value.length <= 16;
415
+ }
416
+ };
417
+
418
+ restrictExpiry = function(e) {
419
+ var $target, digit, value;
420
+ $target = $(e.currentTarget);
421
+ digit = String.fromCharCode(e.which);
422
+ if (!/^\d+$/.test(digit)) {
423
+ return;
424
+ }
425
+ if (hasTextSelected($target)) {
426
+ return;
427
+ }
428
+ value = $target.val() + digit;
429
+ value = value.replace(/\D/g, '');
430
+ if (value.length > 6) {
431
+ return false;
432
+ }
433
+ };
434
+
435
+ restrictCVC = function(e) {
436
+ var $target, digit, val;
437
+ $target = $(e.currentTarget);
438
+ digit = String.fromCharCode(e.which);
439
+ if (!/^\d+$/.test(digit)) {
440
+ return;
441
+ }
442
+ if (hasTextSelected($target)) {
443
+ return;
444
+ }
445
+ val = $target.val() + digit;
446
+ return val.length <= 4;
447
+ };
448
+
449
+ setCardType = function(e) {
450
+ var $target, allTypes, card, cardType, val;
451
+ $target = $(e.currentTarget);
452
+ val = $target.val();
453
+ cardType = $.payment.cardType(val) || 'unknown';
454
+ if (!$target.hasClass(cardType)) {
455
+ allTypes = (function() {
456
+ var _i, _len, _results;
457
+ _results = [];
458
+ for (_i = 0, _len = cards.length; _i < _len; _i++) {
459
+ card = cards[_i];
460
+ _results.push(card.type);
461
+ }
462
+ return _results;
463
+ })();
464
+ $target.removeClass('unknown');
465
+ $target.removeClass(allTypes.join(' '));
466
+ $target.addClass(cardType);
467
+ $target.toggleClass('identified', cardType !== 'unknown');
468
+ return $target.trigger('payment.cardType', cardType);
469
+ }
470
+ };
471
+
472
+ $.payment.fn.formatCardCVC = function() {
473
+ this.on('keypress', restrictNumeric);
474
+ this.on('keypress', restrictCVC);
475
+ this.on('paste', reFormatCVC);
476
+ this.on('change', reFormatCVC);
477
+ this.on('input', reFormatCVC);
478
+ return this;
479
+ };
480
+
481
+ $.payment.fn.formatCardExpiry = function() {
482
+ this.on('keypress', restrictNumeric);
483
+ this.on('keypress', restrictExpiry);
484
+ this.on('keypress', formatExpiry);
485
+ this.on('keypress', formatForwardSlashAndSpace);
486
+ this.on('keypress', formatForwardExpiry);
487
+ this.on('keydown', formatBackExpiry);
488
+ this.on('change', reFormatExpiry);
489
+ this.on('input', reFormatExpiry);
490
+ return this;
491
+ };
492
+
493
+ $.payment.fn.formatCardNumber = function() {
494
+ this.on('keypress', restrictNumeric);
495
+ this.on('keypress', restrictCardNumber);
496
+ this.on('keypress', formatCardNumber);
497
+ this.on('keydown', formatBackCardNumber);
498
+ this.on('keyup', setCardType);
499
+ this.on('paste', reFormatCardNumber);
500
+ this.on('change', reFormatCardNumber);
501
+ this.on('input', reFormatCardNumber);
502
+ this.on('input', setCardType);
503
+ return this;
504
+ };
505
+
506
+ $.payment.fn.restrictNumeric = function() {
507
+ this.on('keypress', restrictNumeric);
508
+ this.on('paste', reFormatNumeric);
509
+ this.on('change', reFormatNumeric);
510
+ this.on('input', reFormatNumeric);
511
+ return this;
512
+ };
513
+
514
+ $.payment.fn.cardExpiryVal = function() {
515
+ return $.payment.cardExpiryVal($(this).val());
516
+ };
517
+
518
+ $.payment.cardExpiryVal = function(value) {
519
+ var month, prefix, year, _ref;
520
+ _ref = value.split(/[\s\/]+/, 2), month = _ref[0], year = _ref[1];
521
+ if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
522
+ prefix = (new Date).getFullYear();
523
+ prefix = prefix.toString().slice(0, 2);
524
+ year = prefix + year;
525
+ }
526
+ month = parseInt(month, 10);
527
+ year = parseInt(year, 10);
528
+ return {
529
+ month: month,
530
+ year: year
531
+ };
532
+ };
533
+
534
+ $.payment.validateCardNumber = function(num) {
535
+ var card, _ref;
536
+ num = (num + '').replace(/\s+|-/g, '');
537
+ if (!/^\d+$/.test(num)) {
538
+ return false;
539
+ }
540
+ card = cardFromNumber(num);
541
+ if (!card) {
542
+ return false;
543
+ }
544
+ return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
545
+ };
546
+
547
+ $.payment.validateCardExpiry = function(month, year) {
548
+ var currentTime, expiry, _ref;
549
+ if (typeof month === 'object' && 'month' in month) {
550
+ _ref = month, month = _ref.month, year = _ref.year;
551
+ }
552
+ if (!(month && year)) {
553
+ return false;
554
+ }
555
+ month = $.trim(month);
556
+ year = $.trim(year);
557
+ if (!/^\d+$/.test(month)) {
558
+ return false;
559
+ }
560
+ if (!/^\d+$/.test(year)) {
561
+ return false;
562
+ }
563
+ if (!((1 <= month && month <= 12))) {
564
+ return false;
565
+ }
566
+ if (year.length === 2) {
567
+ if (year < 70) {
568
+ year = "20" + year;
569
+ } else {
570
+ year = "19" + year;
571
+ }
572
+ }
573
+ if (year.length !== 4) {
574
+ return false;
575
+ }
576
+ expiry = new Date(year, month);
577
+ currentTime = new Date;
578
+ expiry.setMonth(expiry.getMonth() - 1);
579
+ expiry.setMonth(expiry.getMonth() + 1, 1);
580
+ return expiry > currentTime;
581
+ };
582
+
583
+ $.payment.validateCardCVC = function(cvc, type) {
584
+ var card, _ref;
585
+ cvc = $.trim(cvc);
586
+ if (!/^\d+$/.test(cvc)) {
587
+ return false;
588
+ }
589
+ card = cardFromType(type);
590
+ if (card != null) {
591
+ return _ref = cvc.length, __indexOf.call(card.cvcLength, _ref) >= 0;
592
+ } else {
593
+ return cvc.length >= 3 && cvc.length <= 4;
594
+ }
595
+ };
596
+
597
+ $.payment.cardType = function(num) {
598
+ var _ref;
599
+ if (!num) {
600
+ return null;
601
+ }
602
+ return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
603
+ };
604
+
605
+ $.payment.formatCardNumber = function(num) {
606
+ var card, groups, upperLength, _ref;
607
+ num = num.replace(/\D/g, '');
608
+ card = cardFromNumber(num);
609
+ if (!card) {
610
+ return num;
611
+ }
612
+ upperLength = card.length[card.length.length - 1];
613
+ num = num.slice(0, upperLength);
614
+ if (card.format.global) {
615
+ return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
616
+ } else {
617
+ groups = card.format.exec(num);
618
+ if (groups == null) {
619
+ return;
620
+ }
621
+ groups.shift();
622
+ groups = $.grep(groups, function(n) {
623
+ return n;
624
+ });
625
+ return groups.join(' ');
626
+ }
627
+ };
628
+
629
+ $.payment.formatExpiry = function(expiry) {
630
+ var mon, parts, sep, year;
631
+ parts = expiry.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/);
632
+ if (!parts) {
633
+ return '';
634
+ }
635
+ mon = parts[1] || '';
636
+ sep = parts[2] || '';
637
+ year = parts[3] || '';
638
+ if (year.length > 0) {
639
+ sep = ' / ';
640
+ } else if (sep === ' /') {
641
+ mon = mon.substring(0, 1);
642
+ sep = '';
643
+ } else if (mon.length === 2 || sep.length > 0) {
644
+ sep = ' / ';
645
+ } else if (mon.length === 1 && (mon !== '0' && mon !== '1')) {
646
+ mon = "0" + mon;
647
+ sep = ' / ';
648
+ }
649
+ return mon + sep + year;
650
+ };
651
+
652
+ }).call(this);