nimbleshop_simply 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ $ ->
2
+ $("#creditcard_number").validateCreditCard (result) ->
3
+ if (result.length_valid && result.luhn_valid)
4
+ $('#creditcard_number').addClass('valid')
5
+ else
6
+ $('#creditcard_number').removeClass('valid')
@@ -3,3 +3,5 @@ $ ->
3
3
  openEffect: "none"
4
4
  closeEffect: "none"
5
5
  cyclic: true
6
+
7
+
@@ -3,7 +3,7 @@ window.NimbleshopSimply = window.NimbleshopSimply || {}
3
3
  class NimbleshopSimply.manageStates
4
4
 
5
5
  stateCodeField: ($country) ->
6
- $country.parents("div.well").find("[name$='[state_code]']")
6
+ $country.parents('[data-behavior~=well]').find("[name$='[state_code]']")
7
7
 
8
8
  createOption: (state) ->
9
9
  ($ "<option />", text: state[0], value: state[1])
@@ -1,5 +1,5 @@
1
1
  $ ->
2
- $("a.remove-item").on "click", ->
2
+ $('[data-behavior~=remove-item-from-cart]').on 'click', ->
3
3
  $this = $(this)
4
4
  permalink = $this.data("permalink")
5
5
  $("#updates_" + permalink).val 0
@@ -20,3 +20,5 @@
20
20
  //= require nimbleshop_simply/load_states
21
21
  //= require nimbleshop_simply/order
22
22
  //= require nimbleshop_simply/enable_fancybox
23
+ //= require nimbleshop_simply/creditcard
24
+ //= require nimbleshop_simply/vendor/jquery.creditCardValidator
@@ -1,7 +1,7 @@
1
1
  # mouse enter on thumbnail displays the image on the product show page
2
2
 
3
3
  $ ->
4
- $("img.thumb").on "mouseenter", ->
4
+ $('[data-behavior~=product-image-thumbnail]').on 'mouseenter', ->
5
5
  $this = $(this)
6
6
  itemIndex = $(".thumb").index($this) + 1
7
7
  $(".thumbnails li:nth-child(" + itemIndex + ")").show().siblings().hide()
@@ -0,0 +1,130 @@
1
+ ###
2
+ jQuery Credit Card Validator
3
+
4
+ Copyright 2012 Pawel Decowski
5
+
6
+ This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
7
+ Unported License. To view a copy of this license, visit:
8
+
9
+ http://creativecommons.org/licenses/by-sa/3.0/
10
+
11
+ or send a letter to:
12
+
13
+ Creative Commons, 444 Castro Street, Suite 900,
14
+ Mountain View, California, 94041, USA.
15
+ ###
16
+
17
+ $ = jQuery
18
+
19
+ $.fn.validateCreditCard = (callback) ->
20
+ card_types = [
21
+ {
22
+ name: 'amex'
23
+ pattern: /^3[47]/
24
+ valid_length: [ 15 ]
25
+ }
26
+ {
27
+ name: 'diners_club_carte_blanche'
28
+ pattern: /^30[0-5]/
29
+ valid_length: [ 14 ]
30
+ }
31
+ {
32
+ name: 'diners_club_international'
33
+ pattern: /^36/
34
+ valid_length: [ 14 ]
35
+ }
36
+ {
37
+ name: 'jcb'
38
+ pattern: /^35(2[89]|[3-8][0-9])/
39
+ valid_length: [ 16 ]
40
+ }
41
+ {
42
+ name: 'laser'
43
+ pattern: /^(6304|670[69]|6771)/
44
+ valid_length: [ 16..19 ]
45
+ }
46
+ {
47
+ name: 'visa_electron'
48
+ pattern: /^(4026|417500|4508|4844|491(3|7))/
49
+ valid_length: [ 16 ]
50
+ }
51
+ {
52
+ name: 'visa'
53
+ pattern: /^4/
54
+ valid_length: [ 16 ]
55
+ }
56
+ {
57
+ name: 'mastercard'
58
+ pattern: /^5[1-5]/
59
+ valid_length: [ 16 ]
60
+ }
61
+ {
62
+ name: 'maestro'
63
+ pattern: /^(5018|5020|5038|6304|6759|676[1-3])/
64
+ valid_length: [ 12..19 ]
65
+ }
66
+ {
67
+ name: 'discover'
68
+ pattern: /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/
69
+ valid_length: [ 16 ]
70
+ }
71
+ ]
72
+
73
+ get_card_type = (number) ->
74
+ for card_type in card_types
75
+ if number.match card_type.pattern
76
+ return card_type
77
+
78
+ null
79
+
80
+ is_valid_luhn = (number) ->
81
+ sum = 0
82
+
83
+ for digit, n in number.split('').reverse()
84
+ digit = +digit # the + casts the string to int
85
+ if n % 2
86
+ digit *= 2
87
+ if digit < 10 then sum += digit else sum += digit - 9
88
+ else
89
+ sum += digit
90
+
91
+ sum % 10 == 0
92
+
93
+ is_valid_length = (number, card_type) ->
94
+ number.length in card_type.valid_length
95
+
96
+ validate_number = (number) ->
97
+ card_type = get_card_type number
98
+ luhn_valid = false
99
+ length_valid = false
100
+
101
+ if card_type?
102
+ luhn_valid = is_valid_luhn number
103
+ length_valid = is_valid_length number, card_type
104
+
105
+ callback
106
+ card_type: card_type
107
+ luhn_valid: luhn_valid
108
+ length_valid: length_valid
109
+
110
+ validate = ->
111
+ number = normalize $(this).val()
112
+ validate_number number
113
+
114
+ normalize = (number) ->
115
+ number.replace /[ -]/g, ''
116
+
117
+ this.bind('input', ->
118
+ $(this).unbind('keyup') # if input event is fired (so is supported) then unbind keyup
119
+ validate.call this
120
+ )
121
+
122
+ # bind keyup in case input event isn't supported
123
+ this.bind('keyup', ->
124
+ validate.call this
125
+ )
126
+
127
+ # run validation straight away in case the card number is prefilled
128
+ validate.call this unless this.length is 0
129
+
130
+ this
@@ -0,0 +1,3 @@
1
+ #creditcard_number.valid {
2
+ background: url("/assets/nimbleshop_simply/tick.png") 255px center no-repeat;
3
+ }
@@ -9,6 +9,7 @@
9
9
  *= require nimbleshop_simply/custom
10
10
  *= require nimbleshop_simply/cart_button
11
11
  *= require nimbleshop_simply/cart
12
+ *= require nimbleshop_simply/creditcard
12
13
  *= require_self
13
14
  */
14
15
 
@@ -9,6 +9,7 @@ module NimbleshopSimply
9
9
  @page_sub_title = 'All payments are secure and encrypted. We never store your credit card information.'
10
10
  @creditcard = Creditcard.new
11
11
  @show_shipping_and_tax_info = true
12
+ @payment_methods = PaymentMethod.enabled.ascending
12
13
  render text: 'No payment method has been setup. Please setup atleast one payment method.' if PaymentMethod.count == 0
13
14
  end
14
15
 
@@ -6,7 +6,12 @@ module NimbleshopSimply
6
6
  layout 'nimbleshop_simply/mailer'
7
7
 
8
8
  default from: lambda { Shop.current.from_email }
9
- default_url_options[:host] = Nimbleshop.config.bare_url_with_port
9
+
10
+ # for some mysterious reason travis ci loads this file while
11
+ # generating the test app and it finds that Nimbleshop.config is nil
12
+ # and the code blows up. The temporary fix is to use respong_to?
13
+ default_url_options[:host] = Nimbleshop.respond_to?(:config) && Nimbleshop.config.bare_url_with_port
14
+
10
15
  default_url_options[:protocol] = 'http'
11
16
 
12
17
  def order_notification_to_buyer(order_number)
@@ -10,7 +10,7 @@
10
10
  <%= link_to line_item.product_name, line_item.product, title: line_item.product_name %>
11
11
  </strong>
12
12
  <br />
13
- <%= link_to 'Remove', '#', title: 'Remove', class: 'delete remove-item', 'data-permalink' => line_item.product_id %>
13
+ <%= link_to 'Remove', '#', title: 'Remove', class: 'delete remove-item', 'data-permalink' => line_item.product_id, 'data-behavior' => 'remove-item-from-cart' %>
14
14
  </div>
15
15
 
16
16
  <div class="span2">
@@ -5,7 +5,7 @@
5
5
  <div class='well'>
6
6
  <div class='control-group'>
7
7
  <div class='controls'>
8
- <% PaymentMethod.order('name desc').each do |payment_method| %>
8
+ <% @payment_methods.each do |payment_method| %>
9
9
  <%= self.send("nimbleshop_#{payment_method.demodulized_underscore}_payment_form", current_order) %>
10
10
  <% end %>
11
11
  </div>
@@ -1,4 +1,4 @@
1
- <div class='well' id='billing_well'>
1
+ <div class='well' id='billing_well' data-behavior='well' >
2
2
 
3
3
  <%= f.fields_for :billing_address do |billing_form| %>
4
4
 
@@ -1,4 +1,4 @@
1
- <div class='well'>
1
+ <div class='well' data-behavior='well'>
2
2
 
3
3
  <%= f.fields_for :shipping_address do |shipping_form| %>
4
4
 
@@ -10,7 +10,6 @@
10
10
  <%= link_to(image_tag(picture.picture_url(:large), alt: @product.name), picture.picture_url(:large_plus),
11
11
  class: 'thumbnail fancybox',
12
12
  rel: 'gallery1') %>
13
-
14
13
  </li>
15
14
  <% end %>
16
15
  </ul>
@@ -24,7 +23,7 @@
24
23
  <% if picture.blank? %>
25
24
  &nbsp;
26
25
  <% else %>
27
- <%= image_tag picture.picture_url(:small), alt: @product.name, class: 'thumb thumbnail' %>
26
+ <%= image_tag picture.picture_url(:small), alt: @product.name, class: 'thumb thumbnail', 'data-behavior' => 'product-image-thumbnail' %>
28
27
  <% end %>
29
28
  </td>
30
29
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimbleshop_simply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,14 +10,14 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-23 00:00:00.000000000 Z
13
+ date: 2012-11-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jquery-rails
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - '='
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.1.1
23
23
  type: :runtime
@@ -25,7 +25,7 @@ dependencies:
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - '='
28
+ - - ~>
29
29
  - !ruby/object:Gem::Version
30
30
  version: 2.1.1
31
31
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,9 @@ files:
57
57
  - app/assets/images/nimbleshop_simply/facebook.png
58
58
  - app/assets/images/nimbleshop_simply/lock.png
59
59
  - app/assets/images/nimbleshop_simply/mail.png
60
+ - app/assets/images/nimbleshop_simply/tick.png
60
61
  - app/assets/images/nimbleshop_simply/twitter.png
62
+ - app/assets/javascripts/nimbleshop_simply/creditcard.js.coffee
61
63
  - app/assets/javascripts/nimbleshop_simply/enable_fancybox.js.coffee
62
64
  - app/assets/javascripts/nimbleshop_simply/load_states.js.coffee
63
65
  - app/assets/javascripts/nimbleshop_simply/order.js.coffee
@@ -65,8 +67,10 @@ files:
65
67
  - app/assets/javascripts/nimbleshop_simply/shipping_address_same_as_billing_address.js.coffee
66
68
  - app/assets/javascripts/nimbleshop_simply/simply.js
67
69
  - app/assets/javascripts/nimbleshop_simply/thumbnail.js.coffee
70
+ - app/assets/javascripts/nimbleshop_simply/vendor/jquery.creditCardValidator.coffee
68
71
  - app/assets/stylesheets/nimbleshop_simply/cart.css.scss
69
72
  - app/assets/stylesheets/nimbleshop_simply/cart_button.css.scss
73
+ - app/assets/stylesheets/nimbleshop_simply/creditcard.css.scss
70
74
  - app/assets/stylesheets/nimbleshop_simply/custom.css.scss
71
75
  - app/assets/stylesheets/nimbleshop_simply/mobile.simply.css
72
76
  - app/assets/stylesheets/nimbleshop_simply/mobile_simply.css
@@ -161,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
165
  version: '0'
162
166
  segments:
163
167
  - 0
164
- hash: 1303579852650865556
168
+ hash: 3798655515712139213
165
169
  required_rubygems_version: !ruby/object:Gem::Requirement
166
170
  none: false
167
171
  requirements:
@@ -170,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
174
  version: '0'
171
175
  segments:
172
176
  - 0
173
- hash: 1303579852650865556
177
+ hash: 3798655515712139213
174
178
  requirements: []
175
179
  rubyforge_project:
176
180
  rubygems_version: 1.8.24