piggybak_coupons 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,9 +11,7 @@ TODO
11
11
 
12
12
  * Document installation notes
13
13
 
14
- * Modify JS so that coupon doesn't trigger AJAX if recently looked up
15
-
16
- * Add coupon success message
14
+ * Modify JS to not require addition of "inputs", complete via backend filter instead.
17
15
 
18
16
 
19
17
  Copyright
@@ -1,46 +1,29 @@
1
1
  $(function() {
2
2
  $('#coupon_code').change(function() {
3
- $(this).data('changed', true);
3
+ piggybak_coupons.apply_coupon();
4
4
  });
5
5
  piggybak.shipping_els.live('change', function() {
6
6
  if($('#coupon_code').val() != '') {
7
7
  setTimeout(function() {
8
- $('#coupon_code').data('changed', true);
9
- piggybak_coupons.apply_coupon(false);
8
+ piggybak_coupons.apply_coupon();
10
9
  }, 500);
11
10
  }
12
11
  });
13
12
  $('#shipping select').live('change', function() {
14
- $('#coupon_code').data('changed', true);
15
- piggybak_coupons.apply_coupon(false);
16
- });
17
- $('#apply_coupon').click(function() {
18
- piggybak_coupons.apply_coupon(false);
19
- return false;
20
- });
21
- $('#submit input').unbind('click').click(function() {
22
- piggybak_coupons.apply_coupon(true);
23
- return false;
13
+ piggybak_coupons.apply_coupon();
24
14
  });
25
15
  setTimeout(function() {
26
16
  if($('#coupon_code').val() != '') {
27
- $('#coupon_code').data('changed', true);
28
- piggybak_coupons.apply_coupon(false);
17
+ piggybak_coupons.apply_coupon();
29
18
  }
30
19
  }, 500);
31
20
  });
32
21
 
33
22
  var piggybak_coupons = {
34
- apply_coupon: function(on_submit) {
35
- if(!$('#coupon_code').data('changed')) {
36
- if(on_submit) {
37
- $('#new_piggybak_order').submit();
38
- }
39
- return;
40
- }
41
- $('#coupon_code').data('changed', false);
23
+ apply_coupon: function() {
42
24
  $('#coupon input[type=hidden]').remove();
43
25
  $('#coupon_response').hide();
26
+ $('#coupon_ajax').show();
44
27
  $.ajax({
45
28
  url: coupon_lookup,
46
29
  cached: false,
@@ -55,7 +38,7 @@ var piggybak_coupons = {
55
38
  var el2 = $('<input>').attr('type', 'hidden').attr('name', 'piggybak_order[line_items_attributes][2][coupon_application_attributes][code]').val($('#coupon_code').val());
56
39
  $('#coupon').append(el1);
57
40
  $('#coupon').append(el2);
58
- $('#coupon_response').html('Coupon successfully applied to order.');
41
+ $('#coupon_response').html('Coupon successfully applied to order.').show();
59
42
  $('#coupon_application_total').html('-$' + (-1*parseFloat(data.amount)).toFixed(2));
60
43
  $('#coupon_application_row').show();
61
44
  piggybak.update_totals();
@@ -67,12 +50,10 @@ var piggybak_coupons = {
67
50
  $('#coupon_application_row').hide();
68
51
  piggybak.update_totals();
69
52
  }
70
- if(on_submit) {
71
- $('#new_piggybak_order').submit();
72
- }
53
+ $('#coupon_ajax').hide();
73
54
  },
74
55
  error: function() {
75
- //do nothing right now
56
+ $('#coupon_ajax').hide();
76
57
  }
77
58
  });
78
59
  }
@@ -3,7 +3,9 @@
3
3
  <div id="piggybak_coupon_apply_box">
4
4
  <div id="coupon_response" style="display:none;"></div>
5
5
  <input type="text" name="piggybak_coupon_code" id="coupon_code" value="<%= params.has_key?(:piggybak_coupon_code) ? params[:piggybak_coupon_code] : '' %>" />
6
- <input type="submit" value="Apply Coupon" id="apply_coupon" />
6
+ <%= image_tag "ajax-loader.gif", :style => "display:none;" %>
7
+ <br />
8
+ <small>This will be applied automatically when modified.</small>
7
9
  </div>
8
10
 
9
11
  <script type="text/javascript">
@@ -1,3 +1,3 @@
1
1
  module PiggybakCoupons
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piggybak_coupons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2012-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  segments:
97
97
  - 0
98
- hash: -1746874936992918947
98
+ hash: 221606661625238227
99
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  segments:
106
106
  - 0
107
- hash: -1746874936992918947
107
+ hash: 221606661625238227
108
108
  requirements: []
109
109
  rubyforge_project:
110
110
  rubygems_version: 1.8.23