(function(d){var b=0;function a(e,f){return e+".touchspin_"+f}function c(e,f){return d.map(e,function(g){return a(g,f)})}d.fn.TouchSpin=function(f){if(f==="destroy"){this.each(function(){var h=d(this),i=h.data();d(document).off(c(["mouseup","touchend","touchcancel","mousemove","touchmove","scroll","scrollstart"],i.spinnerid).join(" "))});return}var g={min:0,max:100,initval:"",replacementval:"",step:1,decimals:0,stepinterval:100,forcestepdivisibility:"round",stepintervaldelay:500,verticalbuttons:false,verticalupclass:"glyphicon glyphicon-chevron-up",verticaldownclass:"glyphicon glyphicon-chevron-down",prefix:"",postfix:"",prefix_extraclass:"",postfix_extraclass:"",booster:true,boostat:10,maxboostedstep:false,mousewheel:true,buttondown_class:"btn btn-default",buttonup_class:"btn btn-default",buttondown_txt:"-",buttonup_txt:"+"};var e={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 J,w=d(this),u=w.data(),y,A,C,n,x,o,D,G=0,j=false;H();function H(){if(w.data("alreadyinitialized")){return}w.data("alreadyinitialized",true);b+=1;w.data("spinnerid",b);if(!w.is("input")){console.log("Must be an input.");return}i();l();t();m();k();I();N();q();A.input.css("display","block")}function l(){if(J.initval!==""&&w.val()===""){w.val(J.initval)}}function z(P){v(P);t();var O=A.input.val();if(O!==""){O=Number(A.input.val());A.input.val(O.toFixed(J.decimals))}}function i(){J=d.extend({},g,u,K(),f)}function K(){var O={};d.each(e,function(Q,R){var P="bts-"+R+"";if(w.is("[data-"+P+"]")){O[Q]=w.data(P)}});return O}function v(O){J=d.extend({},J,O)}function m(){var P=w.val(),O=w.parent();if(P!==""){P=Number(P).toFixed(J.decimals)}w.data("initvalue",P).val(P);w.addClass("form-control");if(O.hasClass("input-group")){h(O)}else{s()}}function h(P){P.addClass("bootstrap-touchspin");var S=w.prev(),R=w.next();var U,O,Q=''+J.prefix+"",T=''+J.postfix+"";if(S.hasClass("input-group-btn")){U='";S.append(U)}else{U='";d(U).insertBefore(w)}if(R.hasClass("input-group-btn")){O='";R.prepend(O)}else{O='";d(O).insertAfter(w)}d(Q).insertBefore(w);d(T).insertAfter(w);y=P}function s(){var O;if(J.verticalbuttons){O='
'+J.prefix+''+J.postfix+'
'}else{O='
'+J.prefix+''+J.postfix+'
"}y=d(O).insertBefore(w);d(".bootstrap-touchspin-prefix",y).after(w);if(w.hasClass("input-sm")){y.addClass("input-group-sm")}else{if(w.hasClass("input-lg")){y.addClass("input-group-lg")}}}function k(){A={down:d(".bootstrap-touchspin-down",y),up:d(".bootstrap-touchspin-up",y),input:d("input",y),prefix:d(".bootstrap-touchspin-prefix",y).addClass(J.prefix_extraclass),postfix:d(".bootstrap-touchspin-postfix",y).addClass(J.postfix_extraclass)}}function I(){if(J.prefix===""){A.prefix.hide()}if(J.postfix===""){A.postfix.hide()}}function N(){w.on("keydown",function(P){var O=P.keyCode||P.which;if(O===38){if(j!=="up"){B();E()}P.preventDefault()}else{if(O===40){if(j!=="down"){L();M()}P.preventDefault()}}});w.on("keyup",function(P){var O=P.keyCode||P.which;if(O===38){p()}else{if(O===40){p()}}});w.on("blur",function(){t()});A.down.on("keydown",function(P){var O=P.keyCode||P.which;if(O===32||O===13){if(j!=="down"){L();M()}P.preventDefault()}});A.down.on("keyup",function(P){var O=P.keyCode||P.which;if(O===32||O===13){p()}});A.up.on("keydown",function(P){var O=P.keyCode||P.which;if(O===32||O===13){if(j!=="up"){B();E()}P.preventDefault()}});A.up.on("keyup",function(P){var O=P.keyCode||P.which;if(O===32||O===13){p()}});A.down.on("mousedown.touchspin",function(O){A.down.off("touchstart.touchspin");if(w.is(":disabled")){return}L();M();O.preventDefault();O.stopPropagation()});A.down.on("touchstart.touchspin",function(O){A.down.off("mousedown.touchspin");if(w.is(":disabled")){return}L();M();O.preventDefault();O.stopPropagation()});A.up.on("mousedown.touchspin",function(O){A.up.off("touchstart.touchspin");if(w.is(":disabled")){return}B();E();O.preventDefault();O.stopPropagation()});A.up.on("touchstart.touchspin",function(O){A.up.off("mousedown.touchspin");if(w.is(":disabled")){return}B();E();O.preventDefault();O.stopPropagation()});A.up.on("mouseout touchleave touchend touchcancel",function(O){if(!j){return}O.stopPropagation();p()});A.down.on("mouseout touchleave touchend touchcancel",function(O){if(!j){return}O.stopPropagation();p()});A.down.on("mousemove touchmove",function(O){if(!j){return}O.stopPropagation();O.preventDefault()});A.up.on("mousemove touchmove",function(O){if(!j){return}O.stopPropagation();O.preventDefault()});d(document).on(c(["mouseup","touchend","touchcancel"],b).join(" "),function(O){if(!j){return}O.preventDefault();p()});d(document).on(c(["mousemove","touchmove","scroll","scrollstart"],b).join(" "),function(O){if(!j){return}O.preventDefault();p()});w.on("mousewheel DOMMouseScroll",function(O){if(!J.mousewheel||!w.is(":focus")){return}var P=O.originalEvent.wheelDelta||-O.originalEvent.deltaY||-O.originalEvent.detail;O.stopPropagation();O.preventDefault();if(P<0){L()}else{B()}})}function q(){w.on("touchspin.uponce",function(){p();B()});w.on("touchspin.downonce",function(){p();L()});w.on("touchspin.startupspin",function(){E()});w.on("touchspin.startdownspin",function(){M()});w.on("touchspin.stopspin",function(){p()});w.on("touchspin.updatesettings",function(O,P){z(P)})}function F(O){switch(J.forcestepdivisibility){case"round":return(Math.round(O/J.step)*J.step).toFixed(J.decimals);case"floor":return(Math.floor(O/J.step)*J.step).toFixed(J.decimals);case"ceil":return(Math.ceil(O/J.step)*J.step).toFixed(J.decimals);default:return O}}function t(){var Q,O,P;Q=w.val();if(Q===""){if(J.replacementval!==""){w.val(J.replacementval);w.trigger("change")}return}if(J.decimals>0&&Q==="."){return}O=parseFloat(Q);if(isNaN(O)){if(J.replacementval!==""){O=J.replacementval}else{O=0}}P=O;if(O.toString()!==Q){P=O}if(OJ.max){P=J.max}P=F(P);if(Number(Q).toString()!==P.toString()){w.val(P);w.trigger("change")}}function r(){if(!J.booster){return J.step}else{var O=Math.pow(2,Math.floor(G/J.boostat))*J.step;if(J.maxboostedstep){if(O>J.maxboostedstep){O=J.maxboostedstep;C=Math.round((C/O))*O}}return Math.max(J.step,O)}}function B(){t();C=parseFloat(A.input.val());if(isNaN(C)){C=0}var P=C,O=r();C=C+O;if(C>J.max){C=J.max;w.trigger("touchspin.on.max");p()}A.input.val(Number(C).toFixed(J.decimals));if(P!==C){w.trigger("change")}}function L(){t();C=parseFloat(A.input.val());if(isNaN(C)){C=0}var P=C,O=r();C=C-O;if(C