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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +120 -0
- data/.codeclimate.yml +36 -0
- data/.deepsource.toml +19 -0
- data/.editorconfig +22 -0
- data/.eslintignore +7 -0
- data/.eslintrc +36 -0
- data/.gem_release.yml +7 -0
- data/.github/CONTRIBUTING.md +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/ISSUE_TEMPLATE.md +39 -0
- data/.github/dependabot.yml +32 -0
- data/.gitignore +58 -0
- data/.rubocop.yml +197 -0
- data/.solargraph.yml +20 -0
- data/.stylelintignore +4 -0
- data/.stylelintrc +6 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +57 -3
- data/LICENSE +1 -1
- data/README.md +89 -0
- data/Rakefile +1 -1
- data/SECURITY.md +1 -0
- data/app/assets/config/spree_frontend_manifest.js +5 -0
- data/app/assets/images/arrow-down.svg +12 -0
- data/app/assets/images/arrow-right-circle-fill.svg +3 -0
- data/app/assets/images/card-image.svg +4 -0
- data/app/assets/images/edit.svg +1 -1
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/file-image.svg +4 -0
- data/app/assets/images/global.svg +1 -0
- data/app/assets/images/image.svg +4 -0
- data/app/assets/images/info.svg +7 -0
- data/app/assets/images/logo/spree_50.png +0 -0
- data/app/assets/images/logo-spree.png +0 -0
- data/app/assets/images/logo.png +0 -0
- data/app/assets/images/logo.svg +10 -1
- data/app/assets/images/logo@2x.png +0 -0
- data/app/assets/images/logo@3x.png +0 -0
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/images/noimage/mini.png +0 -0
- data/app/assets/images/noimage/plp.png +0 -0
- data/app/assets/images/noimage/plp.svg +16 -0
- data/app/assets/images/noimage/product.png +0 -0
- data/app/assets/images/noimage/small.png +0 -0
- data/app/assets/images/pagination-arrow-right.svg +3 -10
- data/app/assets/images/pagination-double-arrow-right.svg +6 -13
- data/app/assets/images/plus.svg +1 -1
- data/app/assets/images/search.svg +1 -1
- data/app/assets/javascripts/spree/frontend/account.js +1 -1
- data/app/assets/javascripts/spree/frontend/api/main.js +36 -0
- data/app/assets/javascripts/spree/frontend/api/storefront/cart.js +49 -0
- data/app/assets/javascripts/spree/frontend/cart.js +24 -2
- data/app/assets/javascripts/spree/frontend/checkout/address.js +78 -52
- data/app/assets/javascripts/spree/frontend/checkout/address_book.js +38 -40
- data/app/assets/javascripts/spree/frontend/checkout/payment.js +63 -23
- data/app/assets/javascripts/spree/frontend/checkout/shipment.js +15 -2
- data/app/assets/javascripts/spree/frontend/checkout.js +17 -1
- data/app/assets/javascripts/spree/frontend/coupon_manager.js +1 -1
- data/app/assets/javascripts/spree/frontend/currency.js +44 -0
- data/app/assets/javascripts/spree/frontend/locale.es6 +12 -0
- data/app/assets/javascripts/spree/frontend/login.js +5 -0
- data/app/assets/javascripts/spree/frontend/main.js +78 -0
- data/app/assets/javascripts/spree/frontend/main_nav_bar.js +86 -0
- data/app/assets/javascripts/spree/frontend/{turbolinks_scroll_fix.js → turbo_scroll_fix.js} +3 -3
- data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +4 -4
- data/app/assets/javascripts/spree/frontend/views/spree/product/related.js +3 -3
- data/app/assets/javascripts/spree/frontend/views/spree/products/cart_form.js +67 -18
- data/app/assets/javascripts/spree/frontend/views/spree/products/description.js +1 -1
- data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +76 -15
- data/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6 +46 -0
- data/app/assets/javascripts/spree/frontend/views/spree/shared/mobile_navigation.js +9 -10
- data/app/assets/javascripts/spree/frontend/views/spree/shared/product_added_modal.js +7 -0
- data/app/assets/javascripts/spree/frontend/views/spree/shared/variant_select.js +93 -0
- data/app/assets/javascripts/spree/frontend.js +68 -11
- data/app/assets/stylesheets/spree/frontend/application.scss +5 -2
- data/app/assets/stylesheets/spree/frontend/components-bootstrap/button.scss +8 -0
- data/app/assets/stylesheets/spree/frontend/components-bootstrap/carousel.scss +4 -0
- data/app/assets/stylesheets/spree/frontend/components-custom/inputs.scss +80 -1
- data/app/assets/stylesheets/spree/frontend/flags/_flag-icon-base.scss +23 -0
- data/app/assets/stylesheets/spree/frontend/flags/_flag-icon-list.scss +265 -0
- data/app/assets/stylesheets/spree/frontend/flags/_variables.scss +2 -0
- data/app/assets/stylesheets/spree/frontend/flags/flag-icon.scss +3 -0
- data/app/assets/stylesheets/spree/frontend/functions.scss +1 -0
- data/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss +48 -0
- data/app/assets/stylesheets/spree/frontend/variables/bootstrap-overrides.scss +2 -2
- data/app/assets/stylesheets/spree/frontend/variables/helper-variables.scss +1 -0
- data/app/assets/stylesheets/spree/frontend/variables/variables.scss +54 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/checkout/confirm.scss +27 -26
- data/app/assets/stylesheets/spree/frontend/views/spree/checkout/delivery.scss +6 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/checkout/edit.scss +24 -10
- data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss +1 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss +54 -67
- data/app/assets/stylesheets/spree/frontend/views/spree/orders/edit.scss +4 -3
- data/app/assets/stylesheets/spree/frontend/views/spree/orders/show.scss +3 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/products/cart_form.scss +8 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/products/gallery_modal.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/products/index.scss +55 -26
- data/app/assets/stylesheets/spree/frontend/views/spree/products/show.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/_color_select.scss +10 -9
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/carousel/single.scss +1 -1
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/carousel/thumbnails.scss +1 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/cart.scss +9 -4
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/category_nav_bar.scss +3 -3
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/change_store.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/footer.scss +4 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/main_nav_bar.scss +42 -26
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/mobile_navigation.scss +34 -3
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/nav_bar.scss +24 -7
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/quantity_select.scss +9 -12
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/search_form.scss +12 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/users/show.scss +7 -13
- data/app/assets/stylesheets/spree/frontend.css +0 -1
- data/app/controllers/concerns/spree/checkout/address_book.rb +9 -7
- data/app/controllers/concerns/spree/locale_urls.rb +21 -0
- data/app/controllers/spree/addresses_controller.rb +16 -33
- data/app/controllers/spree/checkout_controller.rb +15 -13
- data/app/controllers/spree/cms_pages_controller.rb +29 -0
- data/app/controllers/spree/content_controller.rb +0 -2
- data/app/controllers/spree/currency_controller.rb +17 -0
- data/app/controllers/spree/errors_controller.rb +11 -0
- data/app/controllers/spree/home_controller.rb +38 -1
- data/app/controllers/spree/locale_controller.rb +35 -6
- data/app/controllers/spree/orders_controller.rb +12 -10
- data/app/controllers/spree/products_controller.rb +46 -28
- data/app/controllers/spree/store_controller.rb +77 -12
- data/app/controllers/spree/taxons_controller.rb +16 -8
- data/app/helpers/spree/addresses_helper.rb +64 -12
- data/app/helpers/spree/cache_helper.rb +7 -0
- data/app/helpers/spree/cms_pages_helper.rb +23 -0
- data/app/helpers/spree/frontend_helper.rb +170 -18
- data/app/helpers/spree/navigation_helper.rb +81 -4
- data/app/helpers/spree/products_filters_helper.rb +168 -0
- data/app/helpers/spree/store_helper.rb +41 -0
- data/app/helpers/spree/structured_data_helper.rb +6 -2
- data/app/helpers/spree/taxons_helper.rb +2 -2
- data/app/services/spree/build_localized_redirect_url.rb +141 -0
- data/app/views/kaminari/twitter-bootstrap-4/_first_page.html.erb +3 -3
- data/app/views/kaminari/twitter-bootstrap-4/_gap.html.erb +2 -2
- data/app/views/kaminari/twitter-bootstrap-4/_last_page.html.erb +3 -3
- data/app/views/kaminari/twitter-bootstrap-4/_next_page.html.erb +3 -3
- data/app/views/kaminari/twitter-bootstrap-4/_page.html.erb +2 -2
- data/app/views/kaminari/twitter-bootstrap-4/_paginator.html.erb +2 -2
- data/app/views/kaminari/twitter-bootstrap-4/_prev_page.html.erb +3 -3
- data/app/views/spree/address/_form.html.erb +26 -27
- data/app/views/spree/addresses/_form.html.erb +15 -6
- data/app/views/spree/addresses/edit.html.erb +13 -8
- data/app/views/spree/addresses/new.html.erb +8 -4
- data/app/views/spree/checkout/_address.html.erb +19 -23
- data/app/views/spree/checkout/_confirm.html.erb +1 -75
- data/app/views/spree/checkout/_credit_card.html.erb +3 -2
- data/app/views/spree/checkout/_delivery.html.erb +11 -4
- data/app/views/spree/checkout/_delivery_informations.html.erb +51 -0
- data/app/views/spree/checkout/_payment.html.erb +5 -24
- data/app/views/spree/checkout/_payment_sources.html.erb +17 -0
- data/app/views/spree/checkout/_summary.html.erb +22 -19
- data/app/views/spree/checkout/edit.html.erb +22 -2
- data/app/views/spree/checkout/payment/_gateway.html.erb +2 -2
- data/app/views/spree/checkout/registration.html.erb +3 -3
- data/app/views/spree/cms_pages/show.html.erb +16 -0
- data/app/views/spree/errors/not_found.html.erb +2 -2
- data/app/views/spree/home/index.html.erb +17 -123
- data/app/views/spree/layouts/checkout.html.erb +3 -1
- data/app/views/spree/layouts/spree_application.html.erb +3 -2
- data/app/views/spree/locale/index.html.erb +1 -0
- data/app/views/spree/orders/_coupon_code.html.erb +3 -4
- data/app/views/spree/orders/_line_item.html.erb +4 -4
- data/app/views/spree/orders/_line_item_data.html.erb +3 -3
- data/app/views/spree/orders/edit.html.erb +2 -3
- data/app/views/spree/orders/show.html.erb +2 -72
- data/app/views/spree/products/_cart_form.html.erb +5 -2
- data/app/views/spree/products/_color_option_type.html.erb +14 -14
- data/app/views/spree/products/_description.html.erb +19 -14
- data/app/views/spree/products/_filters_desktop.html.erb +80 -40
- data/app/views/spree/products/_filters_mobile.html.erb +47 -15
- data/app/views/spree/products/_gallery.html.erb +4 -6
- data/app/views/spree/products/_gallery_modal.html.erb +4 -6
- data/app/views/spree/products/_option_type.html.erb +1 -3
- data/app/views/spree/products/_product.html.erb +1 -1
- data/app/views/spree/products/_properties.html.erb +6 -4
- data/app/views/spree/products/_sort_desktop.html.erb +20 -14
- data/app/views/spree/products/_sort_mobile.html.erb +24 -8
- data/app/views/spree/products/_thumbnails.html.erb +2 -2
- data/app/views/spree/products/index.html.erb +7 -4
- data/app/views/spree/products/related.html.erb +11 -5
- data/app/views/spree/products/show.html.erb +2 -3
- data/app/views/spree/shared/_breadcrumbs.html.erb +2 -2
- data/app/views/spree/shared/_carousel_4_products.html.erb +14 -20
- data/app/views/spree/shared/_cart.html.erb +1 -1
- data/app/views/spree/shared/_checkout_header.html.erb +22 -21
- data/app/views/spree/shared/_color_select.html.erb +3 -3
- data/app/views/spree/shared/_copyright.html.erb +1 -10
- data/app/views/spree/shared/_currency_dropdown.html.erb +13 -0
- data/app/views/spree/shared/_delete_address_popup.html.erb +1 -2
- data/app/views/spree/shared/_error_messages.html.erb +2 -2
- data/app/views/spree/shared/_footer.html.erb +31 -21
- data/app/views/spree/shared/_get_started.html.erb +32 -0
- data/app/views/spree/shared/_head.html.erb +8 -5
- data/app/views/spree/shared/_header.html.erb +4 -4
- data/app/views/spree/shared/_internationalization_options.html.erb +31 -0
- data/app/views/spree/shared/_line_item.html.erb +3 -3
- data/app/views/spree/shared/_link_to_account.html.erb +7 -4
- data/app/views/spree/shared/_link_to_cart.html.erb +1 -2
- data/app/views/spree/shared/_locale_and_currency.html.erb +6 -0
- data/app/views/spree/shared/_locale_dropdown.html.erb +13 -0
- data/app/views/spree/shared/_login.html.erb +5 -5
- data/app/views/spree/shared/_main_nav_bar.html.erb +69 -45
- data/app/views/spree/shared/_mobile_internationalization_options.html.erb +37 -0
- data/app/views/spree/shared/_mobile_navigation.html.erb +48 -63
- data/app/views/spree/shared/_nav_bar.html.erb +9 -19
- data/app/views/spree/shared/_no_product_available.html.erb +1 -1
- data/app/views/spree/shared/_option_values.html.erb +2 -21
- data/app/views/spree/shared/_order_details.html.erb +117 -174
- data/app/views/spree/shared/_paths.html.erb +8 -0
- data/app/views/spree/shared/_payment.html.erb +2 -2
- data/app/views/spree/shared/_payment_sources.html.erb +2 -2
- data/app/views/spree/shared/_product_added_modal.html.erb +3 -3
- data/app/views/spree/shared/_properties.html.erb +4 -0
- data/app/views/spree/shared/_quantity_select.html.erb +2 -2
- data/app/views/spree/shared/_search.html.erb +9 -13
- data/app/views/spree/shared/_translations.html.erb +8 -7
- data/app/views/spree/shared/carousel/_single.html.erb +9 -14
- data/app/views/spree/shared/carousel/_thumbnails.html.erb +35 -39
- data/app/views/spree/shared/cms/pages/_edit_mode.html.erb +13 -0
- data/app/views/spree/shared/cms/sections/_featured_article.html.erb +27 -0
- data/app/views/spree/shared/cms/sections/_hero_image.html.erb +60 -0
- data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +171 -0
- data/app/views/spree/shared/cms/sections/_product_carousel.html.erb +5 -0
- data/app/views/spree/shared/cms/sections/_rich_text_content.html.erb +3 -0
- data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +118 -0
- data/app/views/spree/taxons/_header.html.erb +7 -2
- data/app/views/spree/users/_address.html.erb +16 -24
- data/app/views/spree/users/_address_controls.html.erb +10 -0
- data/app/views/spree/users/show.html.erb +21 -16
- data/config/initializers/admin_actions.rb +18 -0
- data/config/initializers/assets.rb +4 -13
- data/config/initializers/canonical_rails.rb +1 -1
- data/config/routes.rb +30 -26
- data/lib/generators/spree/frontend/copy_storefront/copy_storefront_generator.rb +1 -7
- data/lib/generators/spree/frontend/install/install_generator.rb +34 -0
- data/lib/generators/spree/frontend/install/templates/app/assets/config/manifest.js +2 -0
- data/lib/generators/spree/frontend/install/templates/vendor/assets/javascripts/spree/frontend/all.js +8 -0
- data/lib/generators/spree/frontend/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +9 -0
- data/lib/spree/frontend/configuration.rb +18 -0
- data/lib/spree/frontend/engine.rb +3 -1
- data/lib/spree/frontend/version.rb +9 -0
- data/lib/spree/frontend.rb +8 -4
- data/license.md +13 -0
- data/spec/fixtures/files/store_favicon.ico +0 -0
- data/spree_frontend.gemspec +26 -14
- data/vendor/assets/javascripts/cleave.js +8 -0
- data/vendor/assets/javascripts/fetch.umd.js +531 -0
- data/vendor/assets/javascripts/jquery.payment.js +652 -0
- data/vendor/assets/javascripts/jsuri.js +458 -0
- data/vendor/assets/javascripts/polyfill.min.js +1 -0
- metadata +224 -86
- data/app/assets/images/homepage/big_category_banner.jpg +0 -0
- data/app/assets/images/homepage/big_category_banner_mobile.jpg +0 -0
- data/app/assets/images/homepage/big_category_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/big_category_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower_mobile.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper_mobile.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/main_banner.jpg +0 -0
- data/app/assets/images/homepage/main_banner_mobile.jpg +0 -0
- data/app/assets/images/homepage/main_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/main_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left_mobile.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right_mobile.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right_tablet_portrait.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_left-first-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_left-second-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_left-third-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_right-first-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_right-second-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_right-third-category.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/noimage/category_banner.jpg +0 -0
- data/app/assets/images/noimage/category_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/category_banner_plp.jpg +0 -0
- data/app/assets/images/noimage/category_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/category_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/noimage/main_banner.jpg +0 -0
- data/app/assets/images/noimage/main_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/main_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/main_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/noimage/product_photo.jpg +0 -0
- data/app/assets/images/noimage/promo_banner.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_megamenu.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/spark-logo@3x.png +0 -0
- data/app/assets/stylesheets/spree/frontend/_glyphicons_urls_fix.scss +0 -10
- data/app/assets/stylesheets/spree/frontend/address_book.scss +0 -8
- data/app/models/spree/frontend_configuration.rb +0 -7
- data/app/views/spree/shared/_taxonomies.html.erb +0 -16
- /data/app/views/spree/{shared → errors}/forbidden.html.erb +0 -0
- /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
|
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,
|
10
|
-
|
11
|
-
|
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];
|
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
|
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
|
43
|
+
var zipcodeLabel = zipcodePara.find('label')
|
44
|
+
var zipcodeLabelText = zipcodeInput.attr('aria-label')
|
35
45
|
|
36
46
|
if (zipcodeRequired) {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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.
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
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 =
|
72
|
+
selected = stateSelect.val()
|
61
73
|
stateSelect.html('')
|
62
|
-
$.each(states, function
|
63
|
-
var opt = $(document.createElement('option')).attr('value', state.id).html(state.name)
|
64
|
-
if (selected.toString(
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
149
|
+
|
150
|
+
function getCountryId(region) {
|
125
151
|
return $('#' + region + 'country select').val()
|
126
152
|
}
|
127
153
|
}
|
@@ -1,56 +1,54 @@
|
|
1
|
-
(function ($) {
|
2
|
-
$(
|
3
|
-
|
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
|
-
|
7
|
-
|
5
|
+
hide_address_form('billing');
|
6
|
+
hide_address_form('shipping');
|
8
7
|
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
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
|
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
|
-
})
|
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
|
-
|
33
|
-
$(
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
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
|
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
|
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,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 = {}
|