/* * Bootstrap TouchSpin - v4.2.1 * A mobile and touch friendly input spinner component for Bootstrap 3 & 4. * http://www.virtuosoft.eu/code/bootstrap-touchspin/ * * Made by István Ujj-Mészáros * Under Apache License v2.0 License */ !function(o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof module&&module.exports?module.exports=function(t,n){return void 0===n&&(n="undefined"!=typeof window?require("jquery"):require("jquery")(t)),o(n),n}:o(jQuery)}(function(y){"use strict";var k=0;y.fn.TouchSpin=function(m){var w={min:0,max:100,initval:"",replacementval:"",step:1,decimals:0,stepinterval:100,forcestepdivisibility:"round",stepintervaldelay:500,verticalbuttons:!1,verticalup:"+",verticaldown:"-",verticalupclass:"",verticaldownclass:"",prefix:"",postfix:"",prefix_extraclass:"",postfix_extraclass:"",booster:!0,boostat:10,maxboostedstep:!1,mousewheel:!0,buttondown_class:"btn btn-primary",buttonup_class:"btn btn-primary",buttondown_txt:"-",buttonup_txt:"+",callback_before_calculation:function(t){return t},callback_after_calculation:function(t){return t}},_={min:"min",max:"max",initval:"init-val",replacementval:"replacement-val",step:"step",decimals:"decimals",stepinterval:"step-interval",verticalbuttons:"vertical-buttons",verticalupclass:"vertical-up-class",verticaldownclass:"vertical-down-class",forcestepdivisibility:"force-step-divisibility",stepintervaldelay:"step-interval-delay",prefix:"prefix",postfix:"postfix",prefix_extraclass:"prefix-extra-class",postfix_extraclass:"postfix-extra-class",booster:"booster",boostat:"boostat",maxboostedstep:"max-boosted-step",mousewheel:"mouse-wheel",buttondown_class:"button-down-class",buttonup_class:"button-up-class",buttondown_txt:"button-down-txt",buttonup_txt:"button-up-txt"};return this.each(function(){var i,u,a,o,t,n,s,p,r=y(this),e=r.data(),c=0,l=!1;function d(){var t,n,o;""!==(t=i.callback_before_calculation(r.val()))?0i.max&&(o=i.max),o=function(t){switch(i.forcestepdivisibility){case"round":return(Math.round(t/i.step)*i.step).toFixed(i.decimals);case"floor":return(Math.floor(t/i.step)*i.step).toFixed(i.decimals);case"ceil":return(Math.ceil(t/i.step)*i.step).toFixed(i.decimals);default:return t}}(o),Number(t).toString()!==o.toString()&&(r.val(o),r.trigger("change"))):""!==i.replacementval&&(r.val(i.replacementval),r.trigger("change"))}function f(){if(i.booster){var t=Math.pow(2,Math.floor(c/i.boostat))*i.step;return i.maxboostedstep&&t>i.maxboostedstep&&(t=i.maxboostedstep,o=Math.round(o/t)*t),Math.max(i.step,t)}return i.step}function b(){d(),o=parseFloat(i.callback_before_calculation(a.input.val())),isNaN(o)&&(o=0);var t=o,n=f();o+=n,null!==i.max&&o>i.max&&(o=i.max,r.trigger("touchspin.on.max"),g()),a.input.val(i.callback_after_calculation(Number(o).toFixed(i.decimals))),t!==o&&r.trigger("change")}function h(){d(),o=parseFloat(i.callback_before_calculation(a.input.val())),isNaN(o)&&(o=0);var t=o,n=f();o-=n,null!==i.min&&o'+i.prefix+"",e=''+i.postfix+"";s.hasClass("input-group-btn")||s.hasClass("input-group-prepend")?(n='",s.append(n)):(n='",y(n).insertBefore(r));a.hasClass("input-group-btn")||a.hasClass("input-group-append")?(o='",a.prepend(o)):(o='",y(o).insertAfter(r));y(p).insertBefore(r),y(e).insertAfter(r),u=t}(n):function(){var t,n="";r.hasClass("input-sm")&&(n="input-group-sm");r.hasClass("input-lg")&&(n="input-group-lg");t=i.verticalbuttons?'
'+i.prefix+''+i.postfix+'
":'
'+i.prefix+''+i.postfix+'
";u=y(t).insertBefore(r),y(".bootstrap-touchspin-prefix",u).after(r),r.hasClass("input-sm")?u.addClass("input-group-sm"):r.hasClass("input-lg")&&u.addClass("input-group-lg")}()}(),a={down:y(".bootstrap-touchspin-down",u),up:y(".bootstrap-touchspin-up",u),input:y("input",u),prefix:y(".bootstrap-touchspin-prefix",u).addClass(i.prefix_extraclass),postfix:y(".bootstrap-touchspin-postfix",u).addClass(i.postfix_extraclass)},function(){""===i.prefix&&a.prefix.hide();""===i.postfix&&a.postfix.hide()}(),r.on("keydown.touchspin",function(t){var n=t.keyCode||t.which;38===n?("up"!==l&&(b(),x()),t.preventDefault()):40===n&&("down"!==l&&(h(),v()),t.preventDefault())}),r.on("keyup.touchspin",function(t){var n=t.keyCode||t.which;38===n?g():40===n&&g()}),r.on("blur.touchspin",function(){d(),r.val(i.callback_after_calculation(r.val()))}),a.down.on("keydown",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||("down"!==l&&(h(),v()),t.preventDefault())}),a.down.on("keyup.touchspin",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||g()}),a.up.on("keydown.touchspin",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||("up"!==l&&(b(),x()),t.preventDefault())}),a.up.on("keyup.touchspin",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||g()}),a.down.on("mousedown.touchspin",function(t){a.down.off("touchstart.touchspin"),r.is(":disabled")||(h(),v(),t.preventDefault(),t.stopPropagation())}),a.down.on("touchstart.touchspin",function(t){a.down.off("mousedown.touchspin"),r.is(":disabled")||(h(),v(),t.preventDefault(),t.stopPropagation())}),a.up.on("mousedown.touchspin",function(t){a.up.off("touchstart.touchspin"),r.is(":disabled")||(b(),x(),t.preventDefault(),t.stopPropagation())}),a.up.on("touchstart.touchspin",function(t){a.up.off("mousedown.touchspin"),r.is(":disabled")||(b(),x(),t.preventDefault(),t.stopPropagation())}),a.up.on("mouseout.touchspin touchleave.touchspin touchend.touchspin touchcancel.touchspin",function(t){l&&(t.stopPropagation(),g())}),a.down.on("mouseout.touchspin touchleave.touchspin touchend.touchspin touchcancel.touchspin",function(t){l&&(t.stopPropagation(),g())}),a.down.on("mousemove.touchspin touchmove.touchspin",function(t){l&&(t.stopPropagation(),t.preventDefault())}),a.up.on("mousemove.touchspin touchmove.touchspin",function(t){l&&(t.stopPropagation(),t.preventDefault())}),r.on("mousewheel.touchspin DOMMouseScroll.touchspin",function(t){if(i.mousewheel&&r.is(":focus")){var n=t.originalEvent.wheelDelta||-t.originalEvent.deltaY||-t.originalEvent.detail;t.stopPropagation(),t.preventDefault(),n<0?h():b()}}),r.on("touchspin.destroy",function(){var t;t=r.parent(),g(),r.off(".touchspin"),t.hasClass("bootstrap-touchspin-injected")?(r.siblings().remove(),r.unwrap()):(y(".bootstrap-touchspin-injected",t).remove(),t.removeClass("bootstrap-touchspin")),r.data("alreadyinitialized",!1)}),r.on("touchspin.uponce",function(){g(),b()}),r.on("touchspin.downonce",function(){g(),h()}),r.on("touchspin.startupspin",function(){x()}),r.on("touchspin.startdownspin",function(){v()}),r.on("touchspin.stopspin",function(){g()}),r.on("touchspin.updatesettings",function(t,n){!function(t){var n;n=t,i=y.extend({},i,n),n.postfix&&r.parent().find(".bootstrap-touchspin-postfix").text(n.postfix),n.prefix&&r.parent().find(".bootstrap-touchspin-prefix").text(n.prefix),d();var o=a.input.val();""!==o&&(o=Number(i.callback_before_calculation(a.input.val())),a.input.val(i.callback_after_calculation(Number(o).toFixed(i.decimals))))}(n)});var s}()})}});