/* * Bootstrap TouchSpin - v4.3.0 * 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(D){"use strict";var N=0;D.fn.TouchSpin=function(k){var C={min:0,max:100,initval:"",replacementval:"",firstclickvalueifempty:null,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-light",buttonup_class:"btn btn-light",buttondown_txt:"-",buttonup_txt:"+",callback_before_calculation:function(t){return t},callback_after_calculation:function(t){return t}},j={min:"min",max:"max",initval:"init-val",replacementval:"replacement-val",firstclickvalueifempty:"first-click-value-if-empty",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,o,s,u,p,a,t,n,e,r,c=D(this),l=c.data(),d=0,f=!1;function b(){""===i.prefix&&(o=p.prefix.detach()),""===i.postfix&&(s=p.postfix.detach())}function h(){var t,n,o;""!==(t=i.callback_before_calculation(c.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.toFixed(i.decimals)}}(o),Number(t).toString()!==o.toString()&&(c.val(o),c.trigger("change"))):""!==i.replacementval&&(c.val(i.replacementval),c.trigger("change"))}function v(){if(i.booster){var t=Math.pow(2,Math.floor(d/i.boostat))*i.step;return i.maxboostedstep&&t>i.maxboostedstep&&(t=i.maxboostedstep,a=Math.round(a/t)*t),Math.max(i.step,t)}return i.step}function x(){return"number"==typeof i.firstclickvalueifempty?i.firstclickvalueifempty:(i.min+i.max)/2}function g(){h();var t,n=a=parseFloat(i.callback_before_calculation(p.input.val()));isNaN(a)?a=x():(t=v(),a+=t),null!==i.max&&a>i.max&&(a=i.max,c.trigger("touchspin.on.max"),y()),p.input.val(i.callback_after_calculation(Number(a).toFixed(i.decimals))),n!==a&&c.trigger("change")}function m(){h();var t,n=a=parseFloat(i.callback_before_calculation(p.input.val()));isNaN(a)?a=x():(t=v(),a-=t),null!==i.min&&a'+i.prefix+"",e=''+i.postfix+"";s.hasClass("input-group-btn")||s.hasClass("input-group-prepend")?(n='",s.append(n)):(n='",D(n).insertBefore(c));p.hasClass("input-group-btn")||p.hasClass("input-group-append")?(o='",p.prepend(o)):(o='",D(o).insertAfter(c));D(a).insertBefore(c),D(e).insertAfter(c),u=t}(n):function(){var t,n="";c.hasClass("form-control-sm")&&(n="input-group-sm");c.hasClass("form-control-lg")&&(n="input-group-lg");t=i.verticalbuttons?'
'+i.prefix+''+i.postfix+'
":'
'+i.prefix+''+i.postfix+'
";u=D(t).insertBefore(c),D(".bootstrap-touchspin-prefix",u).after(c),c.hasClass("form-control-sm")?u.addClass("input-group-sm"):c.hasClass("form-control-lg")&&u.addClass("input-group-lg")}()}(),p={down:D(".bootstrap-touchspin-down",u),up:D(".bootstrap-touchspin-up",u),input:D("input",u),prefix:D(".bootstrap-touchspin-prefix",u).addClass(i.prefix_extraclass),postfix:D(".bootstrap-touchspin-postfix",u).addClass(i.postfix_extraclass)},b(),c.on("keydown.touchspin",function(t){var n=t.keyCode||t.which;38===n?("up"!==f&&(g(),_()),t.preventDefault()):40===n&&("down"!==f&&(m(),w()),t.preventDefault())}),c.on("keyup.touchspin",function(t){var n=t.keyCode||t.which;38!==n&&40!==n||y()}),c.on("blur.touchspin",function(){h(),c.val(i.callback_after_calculation(c.val()))}),p.down.on("keydown",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||("down"!==f&&(m(),w()),t.preventDefault())}),p.down.on("keyup.touchspin",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||y()}),p.up.on("keydown.touchspin",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||("up"!==f&&(g(),_()),t.preventDefault())}),p.up.on("keyup.touchspin",function(t){var n=t.keyCode||t.which;32!==n&&13!==n||y()}),p.down.on("mousedown.touchspin",function(t){p.down.off("touchstart.touchspin"),c.is(":disabled")||(m(),w(),t.preventDefault(),t.stopPropagation())}),p.down.on("touchstart.touchspin",function(t){p.down.off("mousedown.touchspin"),c.is(":disabled")||(m(),w(),t.preventDefault(),t.stopPropagation())}),p.up.on("mousedown.touchspin",function(t){p.up.off("touchstart.touchspin"),c.is(":disabled")||(g(),_(),t.preventDefault(),t.stopPropagation())}),p.up.on("touchstart.touchspin",function(t){p.up.off("mousedown.touchspin"),c.is(":disabled")||(g(),_(),t.preventDefault(),t.stopPropagation())}),p.up.on("mouseup.touchspin mouseout.touchspin touchleave.touchspin touchend.touchspin touchcancel.touchspin",function(t){f&&(t.stopPropagation(),y())}),p.down.on("mouseup.touchspin mouseout.touchspin touchleave.touchspin touchend.touchspin touchcancel.touchspin",function(t){f&&(t.stopPropagation(),y())}),p.down.on("mousemove.touchspin touchmove.touchspin",function(t){f&&(t.stopPropagation(),t.preventDefault())}),p.up.on("mousemove.touchspin touchmove.touchspin",function(t){f&&(t.stopPropagation(),t.preventDefault())}),c.on("mousewheel.touchspin DOMMouseScroll.touchspin",function(t){if(i.mousewheel&&c.is(":focus")){var n=t.originalEvent.wheelDelta||-t.originalEvent.deltaY||-t.originalEvent.detail;t.stopPropagation(),t.preventDefault(),(n<0?m:g)()}}),c.on("touchspin.destroy",function(){!function(){var t=c.parent();y(),c.off(".touchspin"),t.hasClass("bootstrap-touchspin-injected")?(c.siblings().remove(),c.unwrap()):(D(".bootstrap-touchspin-injected",t).remove(),t.removeClass("bootstrap-touchspin"));c.data("alreadyinitialized",!1)}()}),c.on("touchspin.uponce",function(){y(),g()}),c.on("touchspin.downonce",function(){y(),m()}),c.on("touchspin.startupspin",function(){_()}),c.on("touchspin.startdownspin",function(){w()}),c.on("touchspin.stopspin",function(){y()}),c.on("touchspin.updatesettings",function(t,n){!function(t){(function(t){if(i=D.extend({},i,t),t.postfix){0===c.parent().find(".bootstrap-touchspin-postfix").length&&s.insertAfter(c),c.parent().find(".bootstrap-touchspin-postfix .input-group-text").text(t.postfix)}if(t.prefix){0===c.parent().find(".bootstrap-touchspin-prefix").length&&o.insertBefore(c),c.parent().find(".bootstrap-touchspin-prefix .input-group-text").text(t.prefix)}b()})(t),h();var n=p.input.val();""!==n&&(n=Number(i.callback_before_calculation(p.input.val())),p.input.val(i.callback_after_calculation(Number(n).toFixed(i.decimals))))}(n)})}()})}});