diff --git a/app/assets/javascripts/darkswarm/directives/integer.js.coffee b/app/assets/javascripts/darkswarm/directives/integer.js.coffee new file mode 100644 index 0000000000..e162246122 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/integer.js.coffee @@ -0,0 +1,5 @@ +Darkswarm.directive "integer", -> + restrict: 'A' + link: (scope, elem, attr) -> + elem.bind 'input', -> + elem.val Math.round(elem.val()) diff --git a/app/assets/javascripts/templates/shop_variant.html.haml b/app/assets/javascripts/templates/shop_variant.html.haml index 6d050d0bde..04048f3cd0 100644 --- a/app/assets/javascripts/templates/shop_variant.html.haml +++ b/app/assets/javascripts/templates/shop_variant.html.haml @@ -11,6 +11,7 @@ .small-5.medium-3.large-3.columns.text-right{"bo-if" => "!variant.product.group_buy"} %input{type: :number, + integer: true, value: nil, min: 0, placeholder: "0", @@ -26,14 +27,17 @@ %span.bulk-input %input.bulk.first{type: :number, value: nil, + integer: true, min: 0, "ng-model" => "variant.line_item.quantity", placeholder: "min", "ofn-disable-scroll" => true, max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"} - %span.bulk-input{"bo-if" => "variant.product.group_buy"} + %span.bulk-input %input.bulk.second{type: :number, + "ng-disabled" => "!variant.line_item.quantity", + integer: true, min: 0, "ng-model" => "variant.line_item.max_quantity", placeholder: "max",