bachelorthesis/Webseiten/Docker - Build, Ship, and Run Any App, Anywhere_files/jquery-ui-slider-pips.min.js

3 lines
6.2 KiB
JavaScript
Raw Normal View History

2016-06-15 12:40:15 +00:00
/*! jQuery-ui-Slider-Pips - v1.10.7 - 2015-08-20
* Copyright (c) 2015 Simon Goellner <simey.me@gmail.com>; Licensed MIT */
!function(a){"use strict";var b={pips:function(b){function c(b){var c,d,e,f,g,h=[],i=0;if(q&&q.length){for(e=l.element.slider("values"),f=a.map(e,function(a){return Math.abs(a-b)}),g=Math.min.apply(Math,f),c=0;c<f.length;c++)f[c]===g&&h.push(c);for(i=h[0],d=0;d<h.length;d++)l._lastChangedValue===h[d]&&(i=h[d]);l.options.range&&2===h.length&&(b>e[1]?i=h[1]:b<e[0]&&(i=h[0]))}return i}function d(){l.element.off(".selectPip").on("mousedown.slider",l.element.data("mousedown-original")).removeClass("ui-slider-pips").find(".ui-slider-pip").remove()}function e(b){if(!l.option("disabled")){var d=a(b).data("value"),e=c(d);q&&q.length?l.element.slider("values",e,d):l.element.slider("value",d),l._lastChangedValue=e}}function f(b){var c,d,e=b,f="ui-slider-pip",h="";"first"===b?e=0:"last"===b&&(e=r);var i=n+l.options.step*e,j=i.toString().replace(".","-");if(c="array"===a.type(t.labels)?t.labels[e]||"":"object"===a.type(t.labels)?"first"===b?t.labels.first||"":"last"===b?t.labels.last||"":"array"===a.type(t.labels.rest)?t.labels.rest[e-1]||"":i:i,"first"===b?(d="0%",f+=" ui-slider-pip-first",f+="label"===t.first?" ui-slider-pip-label":"",f+=!1===t.first?" ui-slider-pip-hide":""):"last"===b?(d="100%",f+=" ui-slider-pip-last",f+="label"===t.last?" ui-slider-pip-label":"",f+=!1===t.last?" ui-slider-pip-hide":""):(d=(100/r*b).toFixed(4)+"%",f+="label"===t.rest?" ui-slider-pip-label":"",f+=!1===t.rest?" ui-slider-pip-hide":""),f+=" ui-slider-pip-"+j,q&&q.length){for(g=0;g<q.length;g++)i===q[g]&&(f+=" ui-slider-pip-initial-"+(g+1),f+=" ui-slider-pip-selected-"+(g+1));l.options.range&&i>q[0]&&i<q[1]&&(f+=" ui-slider-pip-inrange")}else i===p&&(f+=" ui-slider-pip-initial",f+=" ui-slider-pip-selected"),l.options.range&&("min"===l.options.range&&p>i||"max"===l.options.range&&i>p)&&(f+=" ui-slider-pip-inrange");return h="horizontal"===l.options.orientation?"left: "+d:"bottom: "+d,'<span class="'+f+'" style="'+h+'"><span class="ui-slider-line"></span><span class="ui-slider-label" data-value="'+i+'">'+t.formatLabel(c)+"</span></span>"}var g,h,i,j,k,l=this,m="",n=l._valueMin(),o=l._valueMax(),p=l._value(),q=l._values(),r=(o-n)/l.options.step,s=l.element.find(".ui-slider-handle"),t={first:"label",last:"label",rest:"pip",labels:!1,prefix:"",suffix:"",step:r>100?Math.floor(.05*r):1,formatLabel:function(a){return this.prefix+a+this.suffix}};if("object"!==a.type(b)&&"undefined"!==a.type(b))return void("destroy"===b&&d());a.extend(t,b),l.options.pipStep=Math.round(t.step),l.element.off(".selectPip").addClass("ui-slider-pips").find(".ui-slider-pip").remove();var u={single:function(b){this.resetClasses(),k.filter(".ui-slider-pip-"+this.classLabel(b)).addClass("ui-slider-pip-selected"),l.options.range&&k.each(function(c,d){var e=a(d).children(".ui-slider-label").data("value");("min"===l.options.range&&b>e||"max"===l.options.range&&e>b)&&a(d).addClass("ui-slider-pip-inrange")})},range:function(b){for(this.resetClasses(),g=0;g<b.length;g++)k.filter(".ui-slider-pip-"+this.classLabel(b[g])).addClass("ui-slider-pip-selected-"+(g+1));l.options.range&&k.each(function(c,d){var e=a(d).children(".ui-slider-label").data("value");e>b[0]&&e<b[1]&&a(d).addClass("ui-slider-pip-inrange")})},classLabel:function(a){return a.toString().replace(".","-")},resetClasses:function(){var a=/(^|\s*)(ui-slider-pip-selected|ui-slider-pip-inrange)(-{1,2}\d+|\s|$)/gi;k.removeClass(function(b,c){return(c.match(a)||[]).join(" ")})}};for(m+=f("first"),i=1;r>i;i++)i%l.options.pipStep===0&&(m+=f(i));for(m+=f("last"),l.element.append(m),k=l.element.find(".ui-slider-pip"),j=a._data(l.element.get(0),"events").mousedown&&a._data(l.element.get(0),"events").mousedown.length?a._data(l.element.get(0),"events").mousedown:l.element.data("mousedown-handlers"),l.element.data("mousedown-handlers",j.slice()),h=0;h<j.length;h++)"slider"===j[h].namespace&&l.element.data("mousedown-original",j[h].handler);l.element.off("mousedown.slider").on("mousedown.selectPip",function(b){var d=a(b.target),f=c(d.data("value")),g=s.eq(f);if(g.addClass("ui-state-active"),d.is(".ui-slider-label"))e(d),l.element.one("mouseup.s