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
@@ -1,16 +1,24 @@
1
- Spree.ready(function ($) {
2
- Spree.onAddress = function () {
1
+ Spree.ready(function($) {
2
+ Spree.onAddress = function() {
3
3
  if ($('#checkout_form_address').length) {
4
- Spree.updateState = function (region) {
4
+ Spree.updateState = function(region) {
5
5
  var countryId = getCountryId(region)
6
6
  if (countryId != null) {
7
7
  if (Spree.Checkout[countryId] == null) {
8
8
  $.ajax({
9
- async: false, method: 'GET', url: Spree.pathFor('/api/v2/storefront/countries/' + countryId + '?include=states'), dataType: 'json'
10
- }).done(function (data) {
11
- var json = data.included; var xStates = []
9
+ async: false,
10
+ method: 'GET',
11
+ url: Spree.localizedPathFor('/api/v2/storefront/countries/' + countryId + '?include=checkout_zone_applicable_states'),
12
+ dataType: 'json'
13
+ }).done(function(data) {
14
+ var json = data.included;
15
+ var xStates = [];
12
16
  for (var i = 0; i < json.length; i++) {
13
- var obj = json[i]; xStates.push({ 'id': obj.id, 'name': obj.attributes.name })
17
+ var obj = json[i];
18
+ xStates.push({
19
+ id: obj.id,
20
+ name: obj.attributes.name
21
+ })
14
22
  }
15
23
  Spree.Checkout[countryId] = {
16
24
  states: xStates,
@@ -27,91 +35,108 @@ Spree.ready(function ($) {
27
35
  }
28
36
  }
29
37
 
30
- Spree.toggleZipcode = function (data, region) {
38
+ Spree.toggleZipcode = function(data, region) {
39
+ var requiredIndicator = $('span#required_marker').first().text()
31
40
  var zipcodeRequired = data.zipcode_required
32
41
  var zipcodePara = $('#' + region + 'zipcode')
33
42
  var zipcodeInput = zipcodePara.find('input')
34
- var zipcodeSpanRequired = zipcodePara.find('abbr')
43
+ var zipcodeLabel = zipcodePara.find('label')
44
+ var zipcodeLabelText = zipcodeInput.attr('aria-label')
35
45
 
36
46
  if (zipcodeRequired) {
37
- zipcodeInput.prop('required', true)
38
- zipcodeSpanRequired.show()
39
- // zipcodeInput.prop('disabled', false)
40
- // zipcodePara.show()
47
+ var zipText = zipcodeLabelText + ' ' + requiredIndicator
48
+ zipcodeInput.prop('required', true).attr('placeholder', zipText)
49
+ zipcodeLabel.text('')
50
+ zipcodeLabel.text(zipText)
51
+ zipcodeInput.addClass('required')
41
52
  } else {
42
- zipcodeInput.val('')
43
- zipcodeInput.prop('required', false)
44
- zipcodeSpanRequired.hide()
45
- // zipcodeInput.prop('disabled', true)
46
- // zipcodePara.hide()
53
+ zipcodeInput.prop('required', false).attr('placeholder', zipcodeLabelText)
54
+ zipcodeLabel.text('')
55
+ zipcodeLabel.text(zipcodeLabelText)
56
+ zipcodeInput.removeClass('required')
47
57
  }
48
58
  }
49
59
 
50
- Spree.fillStates = function (data, region) {
60
+ Spree.fillStates = function(data, region) {
51
61
  var selected
52
62
  var statesRequired = data.states_required
53
63
  var states = data.states
54
64
  var statePara = $('#' + region + 'state')
55
65
  var stateSelect = statePara.find('select')
56
66
  var stateInput = statePara.find('input')
67
+ var stateLabel = statePara.find('label')
68
+ var stateSelectImg = statePara.find('img')
57
69
  var stateSpanRequired = statePara.find('abbr')
58
70
 
59
71
  if (states.length > 0) {
60
- selected = parseInt(stateSelect.val())
72
+ selected = stateSelect.val()
61
73
  stateSelect.html('')
62
- $.each(states, function (idx, state) {
63
- var opt = $(document.createElement('option')).attr('value', state.id).html(state.name)
64
- if (selected.toString(10) === state.id.toString(10)) {
74
+ $.each(states, function(idx, state) {
75
+ var opt = $(document.createElement('option')).attr('value', state.id.toString()).html(state.name)
76
+ if (selected && selected.toString() === state.id.toString()) {
65
77
  opt.prop('selected', true)
66
78
  }
67
79
  stateSelect.append(opt)
68
80
  })
69
- stateSelect.prop('required', false)
70
- stateSelect.prop('disabled', false).show()
71
- stateInput.hide().prop('disabled', true)
72
- statePara.show()
73
- stateSpanRequired.hide()
74
- stateSelect.removeClass('required')
81
+ // If States are listed for the Country selected kill the input field
82
+ stateInput.hide()
83
+ .prop('disabled', true)
84
+ .prop('required', false)
85
+ .val('')
75
86
 
76
- if (statesRequired) {
77
- stateSelect.addClass('required')
78
- stateSpanRequired.show()
79
- stateSelect.prop('required', true)
80
- }
81
- stateSelect.removeClass('hidden')
82
- stateInput.removeClass('required')
87
+ // Activate the State select dropdown.
88
+ statePara.show()
89
+ stateSelect.prop('required', statesRequired)
90
+ .prop('disabled', false)
91
+ .show()
92
+ stateSelectImg.show()
93
+ stateLabel.addClass('state-select-label')
94
+ stateSpanRequired.toggle(statesRequired)
83
95
  } else {
84
- stateSelect.hide().prop('disabled', true)
85
- stateInput.show()
96
+ // If no States are listed in the database for the country selected
97
+ // and a State is not required => (United Kingdom).
98
+ // Kill the State selector and input field.
99
+ stateSelectImg.hide()
100
+ stateSelect.hide()
101
+ .prop('disabled', true)
102
+ .prop('required', false)
103
+ .find('option').remove()
104
+
105
+ stateInput.prop('disabled', true)
106
+ .prop('required', false)
107
+ .hide()
108
+
109
+ // Toggle visibility of States parent element based on State required.
110
+ statePara.toggle(statesRequired)
111
+
86
112
  if (statesRequired) {
113
+ // If a State is required, but none are listed in the database
114
+ // for the country selected => (Hong Kong)
115
+ // Enable the State input field, set it to required.
116
+ stateInput.show()
117
+ .prop('disabled', false)
118
+ .prop('required', true)
87
119
  stateSpanRequired.show()
88
- stateInput.addClass('required form-control')
89
- } else {
90
- stateInput.val('')
91
- stateSpanRequired.hide()
92
- stateInput.removeClass('required')
120
+ stateLabel.removeClass('state-select-label') // required for floating label
93
121
  }
94
- statePara.toggle(!!statesRequired)
95
- stateInput.prop('disabled', !statesRequired)
96
- stateInput.removeClass('hidden')
97
- stateSelect.removeClass('required')
98
122
  }
99
123
  }
100
- $('#bcountry select').change(function () {
124
+ $('#bcountry select').change(function() {
101
125
  Spree.updateState('b')
102
126
  })
103
- $('#scountry select').change(function () {
127
+ $('#scountry select').change(function() {
104
128
  Spree.updateState('s')
105
129
  })
106
130
  Spree.updateState('b')
107
131
 
108
132
  var orderUseBilling = $('input#order_use_billing')
109
- orderUseBilling.change(function () {
133
+ orderUseBilling.change(function() {
110
134
  updateShippingFormState(orderUseBilling)
111
135
  })
112
136
  updateShippingFormState(orderUseBilling)
113
137
  }
114
- function updateShippingFormState (orderUseBilling) {
138
+
139
+ function updateShippingFormState(orderUseBilling) {
115
140
  if (orderUseBilling.is(':checked')) {
116
141
  $('#shipping .inner').hide()
117
142
  $('#shipping .inner input, #shipping .inner select').prop('disabled', true)
@@ -121,7 +146,8 @@ Spree.ready(function ($) {
121
146
  Spree.updateState('s')
122
147
  }
123
148
  }
124
- function getCountryId (region) {
149
+
150
+ function getCountryId(region) {
125
151
  return $('#' + region + 'country select').val()
126
152
  }
127
153
  }
@@ -1,56 +1,54 @@
1
- (function ($) {
2
- $(document).ready(function () {
3
- if ($('.select_address').length > 0) {
4
- $('input#order_use_billing').unbind('change')
1
+ Spree.ready(function ($) {
2
+ if ($('.select_address').length > 0) {
3
+ $('input#order_use_billing').unbind('change');
5
4
 
6
- hide_address_form('billing')
7
- hide_address_form('shipping')
5
+ hide_address_form('billing');
6
+ hide_address_form('shipping');
8
7
 
9
- if ($('input#order_use_billing').is(':checked')) {
10
- $('#shipping .select_address').hide()
11
- }
12
-
13
- $('input#order_use_billing').click(function () {
14
- if ($(this).is(':checked')) {
15
- $('#shipping .select_address').hide()
16
- hide_address_form('shipping')
17
- } else {
18
- $('#shipping .select_address').show()
19
- if ($("input[name='order[ship_address_id]']:checked").val() == '0') {
20
- show_address_form('shipping')
21
- } else {
22
- hide_address_form('shipping')
23
- }
24
- }
25
- })
26
-
27
- $("input[name='order[bill_address_id]']:radio").change(function () {
28
- if ($("input[name='order[bill_address_id]']:checked").val() == '0') {
29
- show_address_form('billing')
30
- } else {
31
- hide_address_form('billing')
32
- }
33
- })
8
+ if ($('input#order_use_billing').is(':checked')) {
9
+ $('#shipping .select_address').hide()
10
+ }
34
11
 
35
- $("input[name='order[ship_address_id]']:radio").change(function () {
12
+ $('input#order_use_billing').click(function () {
13
+ if ($(this).is(':checked')) {
14
+ $('#shipping .select_address').hide()
15
+ hide_address_form('shipping')
16
+ } else {
17
+ $('#shipping .select_address').show()
36
18
  if ($("input[name='order[ship_address_id]']:checked").val() == '0') {
37
19
  show_address_form('shipping')
38
20
  } else {
39
21
  hide_address_form('shipping')
40
22
  }
41
- })
42
- }
43
- })
23
+ }
24
+ });
25
+
26
+ $("input[name='order[bill_address_id]']:radio").change(function () {
27
+ if ($("input[name='order[bill_address_id]']:checked").val() == '0') {
28
+ show_address_form('billing')
29
+ } else {
30
+ hide_address_form('billing')
31
+ }
32
+ });
33
+
34
+ $("input[name='order[ship_address_id]']:radio").change(function () {
35
+ if ($("input[name='order[ship_address_id]']:checked").val() == '0') {
36
+ show_address_form('shipping')
37
+ } else {
38
+ hide_address_form('shipping')
39
+ }
40
+ })
41
+ }
44
42
 
45
- function hide_address_form (address_type) {
46
- $('#' + address_type + ' .inner').hide()
43
+ function hide_address_form(address_type) {
44
+ $('#' + address_type + ' .inner').hide();
47
45
  $('#' + address_type + ' .inner input').prop('disabled', true)
48
46
  $('#' + address_type + ' .inner select').prop('disabled', true)
49
47
  }
50
48
 
51
- function show_address_form (address_type) {
52
- $('#' + address_type + ' .inner').show()
49
+ function show_address_form(address_type) {
50
+ $('#' + address_type + ' .inner').show();
53
51
  $('#' + address_type + ' .inner input').prop('disabled', false)
54
52
  $('#' + address_type + ' .inner select').prop('disabled', false)
55
53
  }
56
- })(jQuery)
54
+ });
@@ -1,45 +1,85 @@
1
+ /* global Cleave */
2
+ var CARD_NUMBER_SELECTOR = '.cardNumber'
3
+ var CARD_EXPIRATION_SELECTOR = '.cardExpiry'
4
+ var CARD_CODE_SELECTOR = '.cardCode'
5
+
1
6
  //= require spree/frontend/coupon_manager
2
7
  Spree.ready(function ($) {
3
8
  Spree.onPayment = function () {
4
9
  if ($('#checkout_form_payment').length) {
5
10
  if ($('#existing_cards').length) {
6
- $('#existing_cards').hide()
7
11
  $('#payment-methods').hide()
8
- $("#payment-method-fields label[data-type='card']").click(function() {
9
- $('#existing_cards').show()
10
- $('.payment-sources').show()
11
- $('.existing-cc-radio').first().prop('checked', true)
12
- })
13
- $("#payment-method-fields label:not([data-type='card'])").click(function() {
14
- $('#existing_cards').hide()
15
- $('#payment-methods').hide()
16
- $('.payment-sources').hide()
17
- $('.existing-cc-radio').prop('checked', false)
18
- $('#use_existing_card_no').prop('checked', false)
19
- })
20
12
  $('.existing-cc-radio').click(function () {
21
13
  $(this).prop('checked', true)
22
14
  $('#use_existing_card_no').prop('checked', false)
23
15
  $('#use_existing_card_yes').prop('checked', true)
24
16
  $('#payment-methods').hide()
17
+ Spree.enableSave()
25
18
  })
26
19
  $('#use_existing_card_no').click(function () {
27
20
  $('#payment-methods').show()
28
21
  $('.existing-cc-radio').prop('checked', false)
29
22
  $('#use_existing_card_yes').prop('checked', false)
23
+ Spree.enableSave()
30
24
  })
31
25
  }
32
- $('.cardNumber').payment('formatCardNumber')
33
- $('.cardExpiry').payment('formatCardExpiry')
34
- $('.cardCode').payment('formatCardCVC')
35
- $('.cardNumber').change(function () {
36
- $(this).parent().siblings('.ccType').val($.payment.cardType(this.value))
37
- })
26
+
27
+ if ($(CARD_NUMBER_SELECTOR).length > 0 &&
28
+ $(CARD_EXPIRATION_SELECTOR).length > 0 &&
29
+ $(CARD_CODE_SELECTOR).length > 0) {
30
+ var cardCodeCleave;
31
+ var updateCardCodeCleave = function (length) {
32
+ if (cardCodeCleave) cardCodeCleave.destroy()
33
+
34
+ cardCodeCleave = new Cleave(CARD_CODE_SELECTOR, {
35
+ numericOnly: true,
36
+ blocks: [length]
37
+ })
38
+ }
39
+
40
+ updateCardCodeCleave(3)
41
+
42
+ /* eslint-disable no-new */
43
+ new Cleave(CARD_NUMBER_SELECTOR, {
44
+ creditCard: true,
45
+ onCreditCardTypeChanged: function (type) {
46
+ $('.ccType').val(type)
47
+
48
+ if (type === 'amex') {
49
+ updateCardCodeCleave(4)
50
+ } else {
51
+ updateCardCodeCleave(3)
52
+ }
53
+ }
54
+ })
55
+ /* eslint-disable no-new */
56
+ new Cleave(CARD_EXPIRATION_SELECTOR, {
57
+ date: true,
58
+ datePattern: ['m', 'Y']
59
+ })
60
+ }
61
+
38
62
  $('input[type="radio"][name="order[payments_attributes][][payment_method_id]"]').click(function () {
39
- if ($('#payment_method_' + this.value).find('fieldset').children().length == 0) {
40
- $('.payment-sources').hide()
41
- } else {
42
- $('.payment-sources').show()
63
+ $('#payment-methods').hide()
64
+ $('.payment-sources').hide()
65
+ Spree.enableSave()
66
+ if ($('#payment_method_' + this.value).find('fieldset').children().length !== 0) {
67
+ if (this.closest('label').dataset.type === 'card') {
68
+ if ($('#existing_cards').length) {
69
+ $('.existing-cc-radio').first().prop('checked', true);
70
+ $('#use_existing_card_no').prop('checked', false)
71
+ $('#use_existing_card_yes').prop('checked', true)
72
+ $('#existing_cards').show();
73
+ $('#payment-methods').hide();
74
+ $('.payment-sources').show()
75
+ }
76
+ } else {
77
+ $('.existing-cc-radio').prop('checked', false);
78
+ $('#use_existing_card_no').prop('checked', false);
79
+ $('#existing_cards').hide();
80
+ $('#payment-methods').show();
81
+ $('.payment-sources').show()
82
+ }
43
83
  }
44
84
  $('#payment-methods li').hide()
45
85
  if (this.checked) {
@@ -3,6 +3,7 @@ function ShippingTotalManager (input1) {
3
3
  this.input = input1
4
4
  this.shippingMethods = this.input.shippingMethods
5
5
  this.shipmentTotal = this.input.shipmentTotal
6
+ this.isFreeShipping = this.input.isFreeShipping
6
7
  this.taxTotal = this.input.taxTotal
7
8
  this.nonShipmentTax = $(this.taxTotal).data('non-shipment-tax')
8
9
  this.orderTotal = this.input.orderTotal
@@ -35,8 +36,19 @@ ShippingTotalManager.prototype.parseCurrencyToFloat = function (input) {
35
36
  return accounting.unformat(input, this.formatOptions.decimal)
36
37
  }
37
38
 
39
+ ShippingTotalManager.prototype.totalShipmentAmount = function (newShipmentTotal, oldShipmentTotal) {
40
+ var totalShipmentAmount = 0;
41
+ if (!this.isFreeShipping.html()) {
42
+ totalShipmentAmount = newShipmentTotal - oldShipmentTotal
43
+
44
+ return totalShipmentAmount
45
+ } else {
46
+ return totalShipmentAmount
47
+ }
48
+ }
49
+
38
50
  ShippingTotalManager.prototype.readjustSummarySection = function (orderTotal, newShipmentTotal, oldShipmentTotal, newTaxTotal, oldTaxTotal) {
39
- var newOrderTotal = orderTotal + (newShipmentTotal - oldShipmentTotal) + (newTaxTotal - oldTaxTotal)
51
+ var newOrderTotal = orderTotal + this.totalShipmentAmount(newShipmentTotal, oldShipmentTotal) + (newTaxTotal - oldTaxTotal)
40
52
  this.taxTotal.html(accounting.formatMoney(newTaxTotal, this.formatOptions))
41
53
  this.shipmentTotal.html(accounting.formatMoney(newShipmentTotal, this.formatOptions))
42
54
  return this.orderTotal.html(accounting.formatMoney(accounting.toFixed(newOrderTotal, 10), this.formatOptions))
@@ -53,7 +65,8 @@ Spree.ready(function ($) {
53
65
  orderTotal: $('#summary-order-total'),
54
66
  taxTotal: $('[data-hook="tax-total"]'),
55
67
  shipmentTotal: $('[data-hook="shipping-total"]'),
56
- shippingMethods: $('input[data-behavior="shipping-method-selector"]')
68
+ shippingMethods: $('input[data-behavior="shipping-method-selector"]'),
69
+ isFreeShipping: $('[data-hook="is-free-shipping"]')
57
70
  }
58
71
  return new ShippingTotalManager(input).bindEvent()
59
72
  })
@@ -12,7 +12,7 @@ Spree.disableSaveOnClick = function () {
12
12
  }
13
13
 
14
14
  Spree.enableSave = function () {
15
- $('form.edit_order').data('submitted', false).find(':submit, :image').attr('disabled', false).addClass('primary').removeClass('disabled')
15
+ $('#checkout form').data('submitted', false).find(':submit, :image').attr('disabled', false).addClass('primary').removeClass('disabled')
16
16
  }
17
17
 
18
18
  Spree.ready(function () {
@@ -59,3 +59,19 @@ Spree.ready(function () {
59
59
 
60
60
  return Spree.Checkout
61
61
  })
62
+
63
+ $('.js-remove-credit-card').click(function() {
64
+ if (confirm(Spree.translations.credit_card_remove_confirmation)) {
65
+ return $.ajax({
66
+ async: false,
67
+ method: 'DELETE',
68
+ url: Spree.routes.api_v2_storefront_destroy_credit_card(this.dataset.id),
69
+ dataType: 'json',
70
+ headers: {
71
+ 'Authorization': 'Bearer ' + SpreeAPI.oauthToken
72
+ }
73
+ }).done(function() {
74
+ location.reload();
75
+ })
76
+ }
77
+ })
@@ -74,7 +74,7 @@ CouponManager.prototype.sendRemoveRequest = function () {
74
74
  return $.ajax({
75
75
  async: false,
76
76
  method: 'DELETE',
77
- url: Spree.routes.api_v2_storefront_cart_remove_coupon_code + '/' + this.couponCode,
77
+ url: Spree.routes.api_v2_storefront_cart_remove_coupon_code(this.couponCode),
78
78
  dataType: 'json',
79
79
  headers: {
80
80
  'X-Spree-Order-Token': SpreeAPI.orderToken
@@ -0,0 +1,44 @@
1
+ document.addEventListener('turbo:load', function(event) {
2
+ // this condition checks if this is the first initial load of turbo application
3
+ if (!event.detail.timing.visitStart) {
4
+ var currencySelect = document.querySelectorAll('select[name=switch_to_currency]')
5
+
6
+ if (currencySelect.length) {
7
+ currencySelect.forEach(function (element) {
8
+ element.addEventListener('change', function () {
9
+ var newCurrency = this.value
10
+
11
+ // we need to make AJAX call here to the backend to set currency in session
12
+ fetch(Spree.routes.set_currency(newCurrency), {
13
+ method: 'GET'
14
+ }).then(function (response) {
15
+ switch (response.status) {
16
+ case 200:
17
+ Spree.setCurrency(newCurrency)
18
+ document.getElementById('internationalization-options-desktop').classList.remove('show')
19
+ break
20
+ }
21
+ })
22
+ })
23
+ })
24
+ }
25
+ }
26
+ })
27
+
28
+ // fix back button issue with different currency set
29
+ // invalidate page if cached page has different currency then the current one
30
+ document.addEventListener('turbo:load', function(event) {
31
+ if (typeof (SPREE_DEFAULT_CURRENCY) !== 'undefined' && typeof (SPREE_CURRENCY) !== 'undefined') {
32
+ if (SPREE_CURRENCY === SPREE_DEFAULT_CURRENCY) {
33
+ var regexAnyCurrency = new RegExp('currency=')
34
+ if (event.detail.url.match(regexAnyCurrency) && !event.detail.url.match(SPREE_CURRENCY)) {
35
+ Spree.setCurrency(SPREE_CURRENCY)
36
+ }
37
+ } else {
38
+ var regex = new RegExp('currency=' + SPREE_CURRENCY)
39
+ if (!event.detail.url.match(regex)) {
40
+ Spree.setCurrency(SPREE_CURRENCY)
41
+ }
42
+ }
43
+ }
44
+ })
@@ -0,0 +1,12 @@
1
+ document.addEventListener('turbo:load', () => {
2
+ const localeSelect = document.querySelectorAll('select[name=switch_to_locale]')
3
+
4
+ if (localeSelect.length) {
5
+ localeSelect.forEach((element) => {
6
+ element.addEventListener('change', () => {
7
+ Spree.clearCache()
8
+ element.form.submit()
9
+ })
10
+ })
11
+ }
12
+ })
@@ -0,0 +1,5 @@
1
+ Spree.ready(function ($) {
2
+ $('#new_spree_user').on('submit', function() {
3
+ sessionStorage.setItem('page-invalidated', 'true')
4
+ })
5
+ })
@@ -0,0 +1,78 @@
1
+ //= require jsuri
2
+ function Spree () {}
3
+
4
+ Spree.ready = function (callback) {
5
+ return jQuery(document).on('page:load turbo:load', function () {
6
+ return callback(jQuery)
7
+ })
8
+ }
9
+
10
+ Spree.mountedAt = function () {
11
+ return window.SpreePaths.mounted_at
12
+ }
13
+
14
+ Spree.adminPath = function () {
15
+ return window.SpreePaths.admin
16
+ }
17
+
18
+ Spree.pathFor = function (path) {
19
+ var locationOrigin = (window.location.protocol + '//' + window.location.hostname) + (window.location.port ? ':' + window.location.port : '')
20
+
21
+ return this.url('' + locationOrigin + (this.mountedAt()) + path, this.url_params).toString()
22
+ }
23
+
24
+ Spree.localizedPathFor = function(path) {
25
+ if (typeof (SPREE_LOCALE) !== 'undefined' && typeof (SPREE_CURRENCY) !== 'undefined') {
26
+ var fullUrl = new URL(Spree.pathFor(path))
27
+ var params = fullUrl.searchParams
28
+ var pathName = fullUrl.pathname
29
+
30
+ params.set('currency', SPREE_CURRENCY)
31
+
32
+ if (pathName.match(/api\/v/)) {
33
+ params.set('locale', SPREE_LOCALE)
34
+ } else {
35
+ pathName = (this.mountedAt()) + SPREE_LOCALE + '/' + pathName
36
+ }
37
+ return fullUrl.origin + pathName + '?' + params.toString()
38
+ }
39
+ return Spree.pathFor(path)
40
+ }
41
+
42
+ Spree.adminPathFor = function (path) {
43
+ return this.pathFor('' + (this.adminPath()) + path)
44
+ }
45
+
46
+ Spree.url = function (uri, query) {
47
+ if (uri.path === void 0) {
48
+ // eslint-disable-next-line no-undef
49
+ uri = new Uri(uri)
50
+ }
51
+ if (query) {
52
+ $.each(query, function (key, value) {
53
+ return uri.addQueryParam(key, value)
54
+ })
55
+ }
56
+ return uri
57
+ }
58
+
59
+ Spree.ajax = function (urlOrSettings, settings) {
60
+ var url
61
+ if (typeof urlOrSettings === 'string') {
62
+ return $.ajax(Spree.url(urlOrSettings).toString(), settings)
63
+ } else {
64
+ url = urlOrSettings['url']
65
+ delete urlOrSettings['url']
66
+ return $.ajax(Spree.url(url).toString(), urlOrSettings)
67
+ }
68
+ }
69
+
70
+ Spree.routes = {
71
+ states_search: Spree.localizedPathFor('api/v1/states'),
72
+ apply_coupon_code: function (orderId) {
73
+ return Spree.localizedPathFor('api/v1/orders/' + orderId + '/apply_coupon_code')
74
+ },
75
+ cart: Spree.localizedPathFor('cart')
76
+ }
77
+
78
+ Spree.url_params = {}