solidus_subscription_boxes 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecc09ca103d4127a8ebfba86d20afe7a9263cd9e
4
- data.tar.gz: 42488b406d836d45933cdd817995e94784314736
3
+ metadata.gz: 2836da4d5150e9f767ac835fe75739db469ab79d
4
+ data.tar.gz: e5a1107c69b9de3b7dba8dbf9a9d9f5a15992db1
5
5
  SHA512:
6
- metadata.gz: 5f14736fb0832fde423dc2ba26e74d1ece531f75d886f7733ee24d5fa9796d9ce3b284abda6cac442ef554f90e6839467ccba20e7ca0dd49e5c4cef52f6e284a
7
- data.tar.gz: 442cbb6301afb08d76ceee9b47d2015f12519ebf9c4a6124e1059baee434181f854ab82e62fcc1cfd95285cca8d49ecdfbf73a713768d289f37c443bea17faa4
6
+ metadata.gz: 8b70438cc13cbf6df3853ec6489060b5d276a1f0e48c62e3d2e043b7a66e3a5748107ef21aff975ef7262a9359cec5ca803a694123ee4693b44ca871f61029c2
7
+ data.tar.gz: 55222ea93489ad4efb21fbc5eabc7bd903a12c72ca4503a4b6cc5122ee98410294b75ee708eb8037025ee37ca458a7ce444ce24e6b2683c69108fce932798a60
@@ -1,64 +1,82 @@
1
1
  // Meal Selection Page
2
2
  function subscriptionFormatDate(date) {
3
3
  var monthNames = [
4
- "January", "February", "March",
5
- "April", "May", "June", "July",
6
- "August", "September", "October",
7
- "November", "December"
4
+ "January",
5
+ "February",
6
+ "March",
7
+ "April",
8
+ "May",
9
+ "June",
10
+ "July",
11
+ "August",
12
+ "September",
13
+ "October",
14
+ "November",
15
+ "December"
8
16
  ];
9
17
 
10
18
  var day = date.getDate();
11
19
  var monthIndex = date.getMonth();
12
-
13
- return monthNames[monthIndex] + ' ' + day;
20
+
21
+ return monthNames[monthIndex] + " " + day;
14
22
  }
15
23
 
16
- $('.box-controls i').click(function(event) {
17
- var value = parseInt($(this).siblings('input').val());
18
- if(this.classList.contains('add')) {
19
- value = Math.min(value + 1, 9);
20
- } else {
21
- value = Math.max(value - 1, 0);
22
- }
23
- $(this).siblings('input').val(value);
24
+ var setupMealSelection = function() {
25
+ $(".box-controls i").click(function(event) {
26
+ var value = parseInt(
27
+ $(this)
28
+ .siblings("input")
29
+ .val()
30
+ );
31
+ if (this.classList.contains("add")) {
32
+ value = Math.min(value + 1, 9);
33
+ } else {
34
+ value = Math.max(value - 1, 0);
35
+ }
36
+ $(this)
37
+ .siblings("input")
38
+ .val(value);
24
39
 
40
+ var numberOfMeals = function() {
41
+ var total = 0;
42
+ $(".box-controls input").each(function(element) {
43
+ total = total + parseInt(this.value);
44
+ });
45
+ return total;
46
+ };
25
47
 
26
- var numberOfMeals = function() {
27
- var total = 0;
28
- $('.box-controls input').each( function(element) {
29
- total = total + parseInt(this.value);
30
- });
31
- return total;
32
- }
48
+ if ($("body.get_started").length > 0) {
49
+ var submitButtonText = "Buy Now";
50
+ } else {
51
+ var submitButtonText = "Update My Order";
52
+ }
33
53
 
34
- if( $('body.get_started').length > 0 ) {
35
- var submitButtonText = "Buy Now";
36
- } else {
37
- var submitButtonText = "Update My Order";
38
- }
54
+ if (numberOfMeals() >= 1) {
55
+ $("input[type=submit].meal-update").removeAttr("disabled");
56
+ $("input[type=submit].meal-update").attr("value", submitButtonText);
57
+ } else {
58
+ $("input[type=submit].meal-update").attr("disabled", "disabled");
59
+ $("input[type=submit].meal-update").attr(
60
+ "value",
61
+ "Choose " + Math.max(3 - numberOfMeals(), 0).toString() + " More"
62
+ );
63
+ }
39
64
 
40
- if( numberOfMeals() >= 1 ) {
41
- $('input[type=submit].meal-update').removeAttr('disabled');
42
- $('input[type=submit].meal-update').attr("value",submitButtonText);
43
- } else {
44
- $('input[type=submit].meal-update').attr("disabled","disabled");
45
- $('input[type=submit].meal-update').attr("value","Choose " + (Math.max(3 - numberOfMeals(), 0)).toString() + " More");
46
- }
65
+ $(".number_more_meals").text(1 - numberOfMeals());
66
+ });
67
+ };
47
68
 
48
- $('.number_more_meals').text(1 - numberOfMeals());
49
- });
69
+ $(document).on("turbolinks:load", setupMealSelection);
50
70
 
51
- $(document).ajaxSuccess(function( event, xhr, settings ) {
52
- if( settings.url.match(/\/api\/v1\/subscriptions\/\d*\/skip/) ) {
71
+ $(document).ajaxSuccess(function(event, xhr, settings) {
72
+ if (settings.url.match(/\/api\/v1\/subscriptions\/\d*\/skip/)) {
53
73
  var actionableDate = new Date(Date.parse(xhr.responseJSON.actionable_date));
54
- $('.actionable-date-update').text(subscriptionFormatDate(actionableDate));
74
+ $(".actionable-date-update").text(subscriptionFormatDate(actionableDate));
55
75
  }
56
- if( settings.url.match(/\/api\/v1\/subscriptions\/\d*\/cancel/) ) {
57
- $('.manage-subscription').remove();
76
+ if (settings.url.match(/\/api\/v1\/subscriptions\/\d*\/cancel/)) {
77
+ $(".manage-subscription").remove();
58
78
  }
59
- if( settings.url.match(/\/api\/v1\/subscriptions\/\d*$/)) {
60
- alert("You've updated your subscription.")
79
+ if (settings.url.match(/\/api\/v1\/subscriptions\/\d*$/)) {
80
+ alert("You've updated your subscription.");
61
81
  }
62
82
  });
63
-
64
-
@@ -1,3 +1,3 @@
1
1
  module SolidusSubscriptionBoxes
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_subscription_boxes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Jackson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2018-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus
@@ -211,6 +211,6 @@ signing_key:
211
211
  specification_version: 4
212
212
  summary: Add subscription box support to Solidus
213
213
  test_files:
214
- - test/integration/navigation_test.rb
215
214
  - test/solidus_subscription_boxes_test.rb
215
+ - test/integration/navigation_test.rb
216
216
  - test/test_helper.rb