piggybak_giftcerts 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,47 +1,32 @@
1
1
  $(function() {
2
2
  $('#giftcert_code').change(function() {
3
- $(this).data('changed', true);
3
+ piggybak_giftcerts.apply_giftcert();
4
4
  });
5
5
  piggybak.shipping_els.live('change', function() {
6
6
  if($('#giftcert_code').val() != '') {
7
7
  setTimeout(function() {
8
- $('#giftcert_code').data('changed', true);
9
- piggybak_giftcerts.apply_giftcert(false);
8
+ piggybak_giftcerts.apply_giftcert();
10
9
  }, 500);
11
10
  }
12
11
  });
13
12
  $('#shipping select').live('change', function() {
14
- $('#giftcert_code').data('changed', true);
15
- piggybak_giftcerts.apply_giftcert(false);
16
- });
17
- $('#apply_giftcert').click(function() {
18
- piggybak_giftcerts.apply_giftcert(false);
19
- return false;
20
- });
21
- $('#submit input').unbind('click').click(function(e) {
22
- if($('#coupon_code').length) {
23
- piggybak_coupons.apply_coupon(false);
24
- }
25
- piggybak_giftcerts.apply_giftcert(true);
26
- return false;
13
+ piggybak_giftcerts.apply_giftcert();
27
14
  });
28
15
  setTimeout(function() {
29
16
  if($('#giftcert_code').val() != '') {
30
- $('#giftcert_code').data('changed', true);
31
- piggybak_giftcerts.apply_giftcert(false);
17
+ piggybak_giftcerts.apply_giftcert();
32
18
  }
33
19
  }, 500);
20
+ $('#coupon_code').change(function() {
21
+ setTimeout(function() {
22
+ piggybak_giftcerts.apply_giftcert();
23
+ }, 500);
24
+ });
34
25
  });
35
26
 
36
27
  var piggybak_giftcerts = {
37
- apply_giftcert: function(on_submit) {
38
- if(!$('#giftcert_code').data('changed')) {
39
- if(on_submit) {
40
- $('#new_piggybak_order').submit();
41
- }
42
- return;
43
- }
44
- $('#giftcert_code').data('changed', false);
28
+ apply_giftcert: function() {
29
+ $('#giftcert_ajax').show();
45
30
  $('#giftcert input[type=hidden]').remove();
46
31
  $('#giftcert_response, #giftcert_application_row').hide();
47
32
  $('#giftcert_application_total').html('$0.00');
@@ -64,7 +49,7 @@ var piggybak_giftcerts = {
64
49
  var el2 = $('<input>').attr('type', 'hidden').attr('name', 'piggybak_order[line_items_attributes][3][giftcert_application_attributes][code]').val($('#giftcert_code').val());
65
50
  $('#giftcert').append(el1);
66
51
  $('#giftcert').append(el2);
67
- $('#giftcert_response').html('Coupon successfully applied to order.');
52
+ $('#giftcert_response').html('Gift Certificate successfully applied to order.').show();
68
53
  $('#giftcert_application_total').html('-$' + (-1*parseFloat(data.amount)).toFixed(2));
69
54
  $('#giftcert_application_row').show();
70
55
  piggybak.update_totals();
@@ -78,12 +63,10 @@ var piggybak_giftcerts = {
78
63
  }
79
64
  piggybak.update_totals();
80
65
  }
81
- if(on_submit) {
82
- $('#new_piggybak_order').submit();
83
- }
66
+ $('#giftcert_ajax').hide();
84
67
  },
85
68
  error: function() {
86
- //do nothing right now
69
+ $('#giftcert_ajax').hide();
87
70
  }
88
71
  });
89
72
  }
@@ -3,7 +3,9 @@
3
3
  <div id="piggybak_giftcert_apply_box">
4
4
  <div id="giftcert_response" style="display:none;"></div>
5
5
  <input type="text" name="piggybak_giftcert_code" id="giftcert_code" value="<%= params.has_key?(:piggybak_giftcert_code) ? params[:piggybak_giftcert_code] : '' %>" />
6
- <input type="submit" value="Apply Gift Certificate" id="apply_giftcert" />
6
+ <%= image_tag "ajax-loader.gif", { :id => "giftcert_ajax", :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 PiggybakGiftcerts
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piggybak_giftcerts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -4129374793690141103
134
+ hash: -355042258588563082
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: -4129374793690141103
143
+ hash: -355042258588563082
144
144
  requirements: []
145
145
  rubyforge_project:
146
146
  rubygems_version: 1.8.23