Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/domains/marisgoldunisexboutique.com/public_html/assets/js/ |
var mod_pagespeed_$vLPKCELfX = "// Ion.RangeSlider\r\n// version 2.1.7 Build: 371\r\n// © Denis Ineshin, 2017\r\n// https://github.com/IonDen\r\n//\r\n// Project page: http://ionden.com/a/plugins/ion.rangeSlider/en.html\r\n// GitHub page: https://github.com/IonDen/ion.rangeSlider\r\n//\r\n// Released under MIT licence:\r\n// http://ionden.com/a/plugins/licence-en.html\r\n// =====================================================================================================================\r\n\r\n;(function(factory) {\r\n if (typeof define === \"function\" && define.amd) {\r\n define([\"jquery\"], function (jQuery) {\r\n return factory(jQuery, document, window, navigator);\r\n });\r\n } else if (typeof exports === \"object\") {\r\n factory(require(\"jquery\"), document, window, navigator);\r\n } else {\r\n factory(jQuery, document, window, navigator);\r\n }\r\n} (function ($, document, window, navigator, undefined) {\r\n \"use strict\";\r\n\r\n // =================================================================================================================\r\n // Service\r\n\r\n var plugin_count = 0;\r\n\r\n // IE8 fix\r\n var is_old_ie = (function () {\r\n var n = navigator.userAgent,\r\n r = /msie\\s\\d+/i,\r\n v;\r\n if (n.search(r) > 0) {\r\n v = r.exec(n).toString();\r\n v = v.split(\" \")[1];\r\n if (v < 9) {\r\n $(\"html\").addClass(\"lt-ie9\");\r\n return true;\r\n }\r\n }\r\n return false;\r\n } ());\r\n if (!Function.prototype.bind) {\r\n Function.prototype.bind = function bind(that) {\r\n\r\n var target = this;\r\n var slice = [].slice;\r\n\r\n if (typeof target != \"function\") {\r\n throw new TypeError();\r\n }\r\n\r\n var args = slice.call(arguments, 1),\r\n bound = function () {\r\n\r\n if (this instanceof bound) {\r\n\r\n var F = function(){};\r\n F.prototype = target.prototype;\r\n var self = new F();\r\n\r\n var result = target.apply(\r\n self,\r\n args.concat(slice.call(arguments))\r\n );\r\n if (Object(result) === result) {\r\n return result;\r\n }\r\n return self;\r\n\r\n } else {\r\n\r\n return target.apply(\r\n that,\r\n args.concat(slice.call(arguments))\r\n );\r\n\r\n }\r\n\r\n };\r\n\r\n return bound;\r\n };\r\n }\r\n if (!Array.prototype.indexOf) {\r\n Array.prototype.indexOf = function(searchElement, fromIndex) {\r\n var k;\r\n if (this == null) {\r\n throw new TypeError('\"this\" is null or not defined');\r\n }\r\n var O = Object(this);\r\n var len = O.length >>> 0;\r\n if (len === 0) {\r\n return -1;\r\n }\r\n var n = +fromIndex || 0;\r\n if (Math.abs(n) === Infinity) {\r\n n = 0;\r\n }\r\n if (n >= len) {\r\n return -1;\r\n }\r\n k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);\r\n while (k < len) {\r\n if (k in O && O[k] === searchElement) {\r\n return k;\r\n }\r\n k++;\r\n }\r\n return -1;\r\n };\r\n }\r\n\r\n\r\n\r\n // =================================================================================================================\r\n // Template\r\n\r\n var base_html =\r\n '<span class=\"irs\">' +\r\n '<span class=\"irs-line\" tabindex=\"-1\"><span class=\"irs-line-left\"></span><span class=\"irs-line-mid\"></span><span class=\"irs-line-right\"></span></span>' +\r\n '<span class=\"irs-min\">0</span><span class=\"irs-max\">1</span>' +\r\n '<span class=\"irs-from\">0</span><span class=\"irs-to\">0</span><span class=\"irs-single\">0</span>' +\r\n '</span>' +\r\n '<span class=\"irs-grid\"></span>' +\r\n '<span class=\"irs-bar\"></span>';\r\n\r\n var single_html =\r\n '<span class=\"irs-bar-edge\"></span>' +\r\n '<span class=\"irs-shadow shadow-single\"></span>' +\r\n '<span class=\"irs-slider single\"></span>';\r\n\r\n var double_html =\r\n '<span class=\"irs-shadow shadow-from\"></span>' +\r\n '<span class=\"irs-shadow shadow-to\"></span>' +\r\n '<span class=\"irs-slider from\"></span>' +\r\n '<span class=\"irs-slider to\"></span>';\r\n\r\n var disable_html =\r\n '<span class=\"irs-disable-mask\"></span>';\r\n\r\n\r\n\r\n // =================================================================================================================\r\n // Core\r\n\r\n /**\r\n * Main plugin constructor\r\n *\r\n * @param input {Object} link to base input element\r\n * @param options {Object} slider config\r\n * @param plugin_count {Number}\r\n * @constructor\r\n */\r\n var IonRangeSlider = function (input, options, plugin_count) {\r\n this.VERSION = \"2.1.7\";\r\n this.input = input;\r\n this.plugin_count = plugin_count;\r\n this.current_plugin = 0;\r\n this.calc_count = 0;\r\n this.update_tm = 0;\r\n this.old_from = 0;\r\n this.old_to = 0;\r\n this.old_min_interval = null;\r\n this.raf_id = null;\r\n this.dragging = false;\r\n this.force_redraw = false;\r\n this.no_diapason = false;\r\n this.is_key = false;\r\n this.is_update = false;\r\n this.is_start = true;\r\n this.is_finish = false;\r\n this.is_active = false;\r\n this.is_resize = false;\r\n this.is_click = false;\r\n\r\n options = options || {};\r\n\r\n // cache for links to all DOM elements\r\n this.$cache = {\r\n win: $(window),\r\n body: $(document.body),\r\n input: $(input),\r\n cont: null,\r\n rs: null,\r\n min: null,\r\n max: null,\r\n from: null,\r\n to: null,\r\n single: null,\r\n bar: null,\r\n line: null,\r\n s_single: null,\r\n s_from: null,\r\n s_to: null,\r\n shad_single: null,\r\n shad_from: null,\r\n shad_to: null,\r\n edge: null,\r\n grid: null,\r\n grid_labels: []\r\n };\r\n\r\n // storage for measure variables\r\n this.coords = {\r\n // left\r\n x_gap: 0,\r\n x_pointer: 0,\r\n\r\n // width\r\n w_rs: 0,\r\n w_rs_old: 0,\r\n w_handle: 0,\r\n\r\n // percents\r\n p_gap: 0,\r\n p_gap_left: 0,\r\n p_gap_right: 0,\r\n p_step: 0,\r\n p_pointer: 0,\r\n p_handle: 0,\r\n p_single_fake: 0,\r\n p_single_real: 0,\r\n p_from_fake: 0,\r\n p_from_real: 0,\r\n p_to_fake: 0,\r\n p_to_real: 0,\r\n p_bar_x: 0,\r\n p_bar_w: 0,\r\n\r\n // grid\r\n grid_gap: 0,\r\n big_num: 0,\r\n big: [],\r\n big_w: [],\r\n big_p: [],\r\n big_x: []\r\n };\r\n\r\n // storage for labels measure variables\r\n this.labels = {\r\n // width\r\n w_min: 0,\r\n w_max: 0,\r\n w_from: 0,\r\n w_to: 0,\r\n w_single: 0,\r\n\r\n // percents\r\n p_min: 0,\r\n p_max: 0,\r\n p_from_fake: 0,\r\n p_from_left: 0,\r\n p_to_fake: 0,\r\n p_to_left: 0,\r\n p_single_fake: 0,\r\n p_single_left: 0\r\n };\r\n\r\n\r\n\r\n /**\r\n * get and validate config\r\n */\r\n var $inp = this.$cache.input,\r\n val = $inp.prop(\"value\"),\r\n config, config_from_data, prop;\r\n\r\n // default config\r\n config = {\r\n type: \"single\",\r\n\r\n min: 10,\r\n max: 100,\r\n from: null,\r\n to: null,\r\n step: 1,\r\n\r\n min_interval: 0,\r\n max_interval: 0,\r\n drag_interval: false,\r\n\r\n values: [],\r\n p_values: [],\r\n\r\n from_fixed: false,\r\n from_min: null,\r\n from_max: null,\r\n from_shadow: false,\r\n\r\n to_fixed: false,\r\n to_min: null,\r\n to_max: null,\r\n to_shadow: false,\r\n\r\n prettify_enabled: true,\r\n prettify_separator: \" \",\r\n prettify: null,\r\n\r\n force_edges: false,\r\n\r\n keyboard: false,\r\n keyboard_step: 5,\r\n\r\n grid: false,\r\n grid_margin: true,\r\n grid_num: 4,\r\n grid_snap: false,\r\n\r\n hide_min_max: false,\r\n hide_from_to: false,\r\n\r\n prefix: \"\",\r\n postfix: \"\",\r\n max_postfix: \"\",\r\n decorate_both: true,\r\n values_separator: \" — \",\r\n\r\n input_values_separator: \";\",\r\n\r\n disable: false,\r\n\r\n onStart: null,\r\n onChange: null,\r\n onFinish: null,\r\n onUpdate: null\r\n };\r\n\r\n\r\n // check if base element is input\r\n if ($inp[0].nodeName !== \"INPUT\") {\r\n console && console.warn && console.warn(\"Base element should be <input>!\", $inp[0]);\r\n }\r\n\r\n\r\n // config from data-attributes extends js config\r\n config_from_data = {\r\n type: $inp.data(\"type\"),\r\n\r\n min: $inp.data(\"min\"),\r\n max: $inp.data(\"max\"),\r\n from: $inp.data(\"from\"),\r\n to: $inp.data(\"to\"),\r\n step: $inp.data(\"step\"),\r\n\r\n min_interval: $inp.data(\"minInterval\"),\r\n max_interval: $inp.data(\"maxInterval\"),\r\n drag_interval: $inp.data(\"dragInterval\"),\r\n\r\n values: $inp.data(\"values\"),\r\n\r\n from_fixed: $inp.data(\"fromFixed\"),\r\n from_min: $inp.data(\"fromMin\"),\r\n from_max: $inp.data(\"fromMax\"),\r\n from_shadow: $inp.data(\"fromShadow\"),\r\n\r\n to_fixed: $inp.data(\"toFixed\"),\r\n to_min: $inp.data(\"toMin\"),\r\n to_max: $inp.data(\"toMax\"),\r\n to_shadow: $inp.data(\"toShadow\"),\r\n\r\n prettify_enabled: $inp.data(\"prettifyEnabled\"),\r\n prettify_separator: $inp.data(\"prettifySeparator\"),\r\n\r\n force_edges: $inp.data(\"forceEdges\"),\r\n\r\n keyboard: $inp.data(\"keyboard\"),\r\n keyboard_step: $inp.data(\"keyboardStep\"),\r\n\r\n grid: $inp.data(\"grid\"),\r\n grid_margin: $inp.data(\"gridMargin\"),\r\n grid_num: $inp.data(\"gridNum\"),\r\n grid_snap: $inp.data(\"gridSnap\"),\r\n\r\n hide_min_max: $inp.data(\"hideMinMax\"),\r\n hide_from_to: $inp.data(\"hideFromTo\"),\r\n\r\n prefix: $inp.data(\"prefix\"),\r\n postfix: $inp.data(\"postfix\"),\r\n max_postfix: $inp.data(\"maxPostfix\"),\r\n decorate_both: $inp.data(\"decorateBoth\"),\r\n values_separator: $inp.data(\"valuesSeparator\"),\r\n\r\n input_values_separator: $inp.data(\"inputValuesSeparator\"),\r\n\r\n disable: $inp.data(\"disable\")\r\n };\r\n config_from_data.values = config_from_data.values && config_from_data.values.split(\",\");\r\n\r\n for (prop in config_from_data) {\r\n if (config_from_data.hasOwnProperty(prop)) {\r\n if (config_from_data[prop] === undefined || config_from_data[prop] === \"\") {\r\n delete config_from_data[prop];\r\n }\r\n }\r\n }\r\n\r\n\r\n // input value extends default config\r\n if (val !== undefined && val !== \"\") {\r\n val = val.split(config_from_data.input_values_separator || options.input_values_separator || \";\");\r\n\r\n if (val[0] && val[0] == +val[0]) {\r\n val[0] = +val[0];\r\n }\r\n if (val[1] && val[1] == +val[1]) {\r\n val[1] = +val[1];\r\n }\r\n\r\n if (options && options.values && options.values.length) {\r\n config.from = val[0] && options.values.indexOf(val[0]);\r\n config.to = val[1] && options.values.indexOf(val[1]);\r\n } else {\r\n config.from = val[0] && +val[0];\r\n config.to = val[1] && +val[1];\r\n }\r\n }\r\n\r\n\r\n\r\n // js config extends default config\r\n $.extend(config, options);\r\n\r\n\r\n // data config extends config\r\n $.extend(config, config_from_data);\r\n this.options = config;\r\n\r\n\r\n\r\n // validate config, to be sure that all data types are correct\r\n this.update_check = {};\r\n this.validate();\r\n\r\n\r\n\r\n // default result object, returned to callbacks\r\n this.result = {\r\n input: this.$cache.input,\r\n slider: null,\r\n\r\n min: this.options.min,\r\n max: this.options.max,\r\n\r\n from: this.options.from,\r\n from_percent: 0,\r\n from_value: null,\r\n\r\n to: this.options.to,\r\n to_percent: 0,\r\n to_value: null\r\n };\r\n\r\n\r\n\r\n this.init();\r\n };\r\n\r\n IonRangeSlider.prototype = {\r\n\r\n /**\r\n * Starts or updates the plugin instance\r\n *\r\n * @param [is_update] {boolean}\r\n */\r\n init: function (is_update) {\r\n this.no_diapason = false;\r\n this.coords.p_step = this.convertToPercent(this.options.step, true);\r\n\r\n this.target = \"base\";\r\n\r\n this.toggleInput();\r\n this.append();\r\n this.setMinMax();\r\n\r\n if (is_update) {\r\n this.force_redraw = true;\r\n this.calc(true);\r\n\r\n // callbacks called\r\n this.callOnUpdate();\r\n } else {\r\n this.force_redraw = true;\r\n this.calc(true);\r\n\r\n // callbacks called\r\n this.callOnStart();\r\n }\r\n\r\n this.updateScene();\r\n },\r\n\r\n /**\r\n * Appends slider template to a DOM\r\n */\r\n append: function () {\r\n var container_html = '<span class=\"irs js-irs-' + this.plugin_count + '\"></span>';\r\n this.$cache.input.before(container_html);\r\n this.$cache.input.prop(\"readonly\", true);\r\n this.$cache.cont = this.$cache.input.prev();\r\n this.result.slider = this.$cache.cont;\r\n\r\n this.$cache.cont.html(base_html);\r\n this.$cache.rs = this.$cache.cont.find(\".irs\");\r\n this.$cache.min = this.$cache.cont.find(\".irs-min\");\r\n this.$cache.max = this.$cache.cont.find(\".irs-max\");\r\n this.$cache.from = this.$cache.cont.find(\".irs-from\");\r\n this.$cache.to = this.$cache.cont.find(\".irs-to\");\r\n this.$cache.single = this.$cache.cont.find(\".irs-single\");\r\n this.$cache.bar = this.$cache.cont.find(\".irs-bar\");\r\n this.$cache.line = this.$cache.cont.find(\".irs-line\");\r\n this.$cache.grid = this.$cache.cont.find(\".irs-grid\");\r\n\r\n if (this.options.type === \"single\") {\r\n this.$cache.cont.append(single_html);\r\n this.$cache.edge = this.$cache.cont.find(\".irs-bar-edge\");\r\n this.$cache.s_single = this.$cache.cont.find(\".single\");\r\n this.$cache.from[0].style.visibility = \"hidden\";\r\n this.$cache.to[0].style.visibility = \"hidden\";\r\n this.$cache.shad_single = this.$cache.cont.find(\".shadow-single\");\r\n } else {\r\n this.$cache.cont.append(double_html);\r\n this.$cache.s_from = this.$cache.cont.find(\".from\");\r\n this.$cache.s_to = this.$cache.cont.find(\".to\");\r\n this.$cache.shad_from = this.$cache.cont.find(\".shadow-from\");\r\n this.$cache.shad_to = this.$cache.cont.find(\".shadow-to\");\r\n\r\n this.setTopHandler();\r\n }\r\n\r\n if (this.options.hide_from_to) {\r\n this.$cache.from[0].style.display = \"none\";\r\n this.$cache.to[0].style.display = \"none\";\r\n this.$cache.single[0].style.display = \"none\";\r\n }\r\n\r\n this.appendGrid();\r\n\r\n if (this.options.disable) {\r\n this.appendDisableMask();\r\n this.$cache.input[0].disabled = true;\r\n } else {\r\n this.$cache.cont.removeClass(\"irs-disabled\");\r\n this.$cache.input[0].disabled = false;\r\n this.bindEvents();\r\n }\r\n\r\n if (this.options.drag_interval) {\r\n this.$cache.bar[0].style.cursor = \"ew-resize\";\r\n }\r\n },\r\n\r\n /**\r\n * Determine which handler has a priority\r\n * works only for double slider type\r\n */\r\n setTopHandler: function () {\r\n var min = this.options.min,\r\n max = this.options.max,\r\n from = this.options.from,\r\n to = this.options.to;\r\n\r\n if (from > min && to === max) {\r\n this.$cache.s_from.addClass(\"type_last\");\r\n } else if (to < max) {\r\n this.$cache.s_to.addClass(\"type_last\");\r\n }\r\n },\r\n\r\n /**\r\n * Determine which handles was clicked last\r\n * and which handler should have hover effect\r\n *\r\n * @param target {String}\r\n */\r\n changeLevel: function (target) {\r\n switch (target) {\r\n case \"single\":\r\n this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_single_fake);\r\n break;\r\n case \"from\":\r\n this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_from_fake);\r\n this.$cache.s_from.addClass(\"state_hover\");\r\n this.$cache.s_from.addClass(\"type_last\");\r\n this.$cache.s_to.removeClass(\"type_last\");\r\n break;\r\n case \"to\":\r\n this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_to_fake);\r\n this.$cache.s_to.addClass(\"state_hover\");\r\n this.$cache.s_to.addClass(\"type_last\");\r\n this.$cache.s_from.removeClass(\"type_last\");\r\n break;\r\n case \"both\":\r\n this.coords.p_gap_left = this.toFixed(this.coords.p_pointer - this.coords.p_from_fake);\r\n this.coords.p_gap_right = this.toFixed(this.coords.p_to_fake - this.coords.p_pointer);\r\n this.$cache.s_to.removeClass(\"type_last\");\r\n this.$cache.s_from.removeClass(\"type_last\");\r\n break;\r\n }\r\n },\r\n\r\n /**\r\n * Then slider is disabled\r\n * appends extra layer with opacity\r\n */\r\n appendDisableMask: function () {\r\n this.$cache.cont.append(disable_html);\r\n this.$cache.cont.addClass(\"irs-disabled\");\r\n },\r\n\r\n /**\r\n * Remove slider instance\r\n * and ubind all events\r\n */\r\n remove: function () {\r\n this.$cache.cont.remove();\r\n this.$cache.cont = null;\r\n\r\n this.$cache.line.off(\"keydown.irs_\" + this.plugin_count);\r\n\r\n this.$cache.body.off(\"touchmove.irs_\" + this.plugin_count);\r\n this.$cache.body.off(\"mousemove.irs_\" + this.plugin_count);\r\n\r\n this.$cache.win.off(\"touchend.irs_\" + this.plugin_count);\r\n this.$cache.win.off(\"mouseup.irs_\" + this.plugin_count);\r\n\r\n if (is_old_ie) {\r\n this.$cache.body.off(\"mouseup.irs_\" + this.plugin_count);\r\n this.$cache.body.off(\"mouseleave.irs_\" + this.plugin_count);\r\n }\r\n\r\n this.$cache.grid_labels = [];\r\n this.coords.big = [];\r\n this.coords.big_w = [];\r\n this.coords.big_p = [];\r\n this.coords.big_x = [];\r\n\r\n cancelAnimationFrame(this.raf_id);\r\n },\r\n\r\n /**\r\n * bind all slider events\r\n */\r\n bindEvents: function () {\r\n if (this.no_diapason) {\r\n return;\r\n }\r\n\r\n this.$cache.body.on(\"touchmove.irs_\" + this.plugin_count, this.pointerMove.bind(this));\r\n this.$cache.body.on(\"mousemove.irs_\" + this.plugin_count, this.pointerMove.bind(this));\r\n\r\n this.$cache.win.on(\"touchend.irs_\" + this.plugin_count, this.pointerUp.bind(this));\r\n this.$cache.win.on(\"mouseup.irs_\" + this.plugin_count, this.pointerUp.bind(this));\r\n\r\n this.$cache.line.on(\"touchstart.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n this.$cache.line.on(\"mousedown.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n\r\n if (this.options.drag_interval && this.options.type === \"double\") {\r\n this.$cache.bar.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"both\"));\r\n this.$cache.bar.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"both\"));\r\n } else {\r\n this.$cache.bar.on(\"touchstart.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n this.$cache.bar.on(\"mousedown.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n }\r\n\r\n if (this.options.type === \"single\") {\r\n this.$cache.single.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"single\"));\r\n this.$cache.s_single.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"single\"));\r\n this.$cache.shad_single.on(\"touchstart.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n\r\n this.$cache.single.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"single\"));\r\n this.$cache.s_single.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"single\"));\r\n this.$cache.edge.on(\"mousedown.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n this.$cache.shad_single.on(\"mousedown.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n } else {\r\n this.$cache.single.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, null));\r\n this.$cache.single.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, null));\r\n\r\n this.$cache.from.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"from\"));\r\n this.$cache.s_from.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"from\"));\r\n this.$cache.to.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"to\"));\r\n this.$cache.s_to.on(\"touchstart.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"to\"));\r\n this.$cache.shad_from.on(\"touchstart.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n this.$cache.shad_to.on(\"touchstart.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n\r\n this.$cache.from.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"from\"));\r\n this.$cache.s_from.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"from\"));\r\n this.$cache.to.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"to\"));\r\n this.$cache.s_to.on(\"mousedown.irs_\" + this.plugin_count, this.pointerDown.bind(this, \"to\"));\r\n this.$cache.shad_from.on(\"mousedown.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n this.$cache.shad_to.on(\"mousedown.irs_\" + this.plugin_count, this.pointerClick.bind(this, \"click\"));\r\n }\r\n\r\n if (this.options.keyboard) {\r\n this.$cache.line.on(\"keydown.irs_\" + this.plugin_count, this.key.bind(this, \"keyboard\"));\r\n }\r\n\r\n if (is_old_ie) {\r\n this.$cache.body.on(\"mouseup.irs_\" + this.plugin_count, this.pointerUp.bind(this));\r\n this.$cache.body.on(\"mouseleave.irs_\" + this.plugin_count, this.pointerUp.bind(this));\r\n }\r\n },\r\n\r\n /**\r\n * Mousemove or touchmove\r\n * only for handlers\r\n *\r\n * @param e {Object} event object\r\n */\r\n pointerMove: function (e) {\r\n if (!this.dragging) {\r\n return;\r\n }\r\n\r\n var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;\r\n this.coords.x_pointer = x - this.coords.x_gap;\r\n\r\n this.calc();\r\n },\r\n\r\n /**\r\n * Mouseup or touchend\r\n * only for handlers\r\n *\r\n * @param e {Object} event object\r\n */\r\n pointerUp: function (e) {\r\n if (this.current_plugin !== this.plugin_count) {\r\n return;\r\n }\r\n\r\n if (this.is_active) {\r\n this.is_active = false;\r\n } else {\r\n return;\r\n }\r\n\r\n this.$cache.cont.find(\".state_hover\").removeClass(\"state_hover\");\r\n\r\n this.force_redraw = true;\r\n\r\n if (is_old_ie) {\r\n $(\"*\").prop(\"unselectable\", false);\r\n }\r\n\r\n this.updateScene();\r\n this.restoreOriginalMinInterval();\r\n\r\n // callbacks call\r\n if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {\r\n this.callOnFinish();\r\n }\r\n \r\n this.dragging = false;\r\n },\r\n\r\n /**\r\n * Mousedown or touchstart\r\n * only for handlers\r\n *\r\n * @param target {String|null}\r\n * @param e {Object} event object\r\n */\r\n pointerDown: function (target, e) {\r\n e.preventDefault();\r\n var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;\r\n if (e.button === 2) {\r\n return;\r\n }\r\n\r\n if (target === \"both\") {\r\n this.setTempMinInterval();\r\n }\r\n\r\n if (!target) {\r\n target = this.target || \"from\";\r\n }\r\n\r\n this.current_plugin = this.plugin_count;\r\n this.target = target;\r\n\r\n this.is_active = true;\r\n this.dragging = true;\r\n\r\n this.coords.x_gap = this.$cache.rs.offset().left;\r\n this.coords.x_pointer = x - this.coords.x_gap;\r\n\r\n this.calcPointerPercent();\r\n this.changeLevel(target);\r\n\r\n if (is_old_ie) {\r\n $(\"*\").prop(\"unselectable\", true);\r\n }\r\n\r\n this.$cache.line.trigger(\"focus\");\r\n\r\n this.updateScene();\r\n },\r\n\r\n /**\r\n * Mousedown or touchstart\r\n * for other slider elements, like diapason line\r\n *\r\n * @param target {String}\r\n * @param e {Object} event object\r\n */\r\n pointerClick: function (target, e) {\r\n e.preventDefault();\r\n var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;\r\n if (e.button === 2) {\r\n return;\r\n }\r\n\r\n this.current_plugin = this.plugin_count;\r\n this.target = target;\r\n\r\n this.is_click = true;\r\n this.coords.x_gap = this.$cache.rs.offset().left;\r\n this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();\r\n\r\n this.force_redraw = true;\r\n this.calc();\r\n\r\n this.$cache.line.trigger(\"focus\");\r\n },\r\n\r\n /**\r\n * Keyborard controls for focused slider\r\n *\r\n * @param target {String}\r\n * @param e {Object} event object\r\n * @returns {boolean|undefined}\r\n */\r\n key: function (target, e) {\r\n if (this.current_plugin !== this.plugin_count || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {\r\n return;\r\n }\r\n\r\n switch (e.which) {\r\n case 83: // W\r\n case 65: // A\r\n case 40: // DOWN\r\n case 37: // LEFT\r\n e.preventDefault();\r\n this.moveByKey(false);\r\n break;\r\n\r\n case 87: // S\r\n case 68: // D\r\n case 38: // UP\r\n case 39: // RIGHT\r\n e.preventDefault();\r\n this.moveByKey(true);\r\n break;\r\n }\r\n\r\n return true;\r\n },\r\n\r\n /**\r\n * Move by key. Beta\r\n * @todo refactor than have plenty of time\r\n *\r\n * @param right {boolean} direction to move\r\n */\r\n moveByKey: function (right) {\r\n var p = this.coords.p_pointer;\r\n\r\n if (right) {\r\n p += this.options.keyboard_step;\r\n } else {\r\n p -= this.options.keyboard_step;\r\n }\r\n\r\n this.coords.x_pointer = this.toFixed(this.coords.w_rs / 100 * p);\r\n this.is_key = true;\r\n this.calc();\r\n },\r\n\r\n /**\r\n * Set visibility and content\r\n * of Min and Max labels\r\n */\r\n setMinMax: function () {\r\n if (!this.options) {\r\n return;\r\n }\r\n\r\n if (this.options.hide_min_max) {\r\n this.$cache.min[0].style.display = \"none\";\r\n this.$cache.max[0].style.display = \"none\";\r\n return;\r\n }\r\n\r\n if (this.options.values.length) {\r\n this.$cache.min.html(this.decorate(this.options.p_values[this.options.min]));\r\n this.$cache.max.html(this.decorate(this.options.p_values[this.options.max]));\r\n } else {\r\n this.$cache.min.html(this.decorate(this._prettify(this.options.min), this.options.min));\r\n this.$cache.max.html(this.decorate(this._prettify(this.options.max), this.options.max));\r\n }\r\n\r\n this.labels.w_min = this.$cache.min.outerWidth(false);\r\n this.labels.w_max = this.$cache.max.outerWidth(false);\r\n },\r\n\r\n /**\r\n * Then dragging interval, prevent interval collapsing\r\n * using min_interval option\r\n */\r\n setTempMinInterval: function () {\r\n var interval = this.result.to - this.result.from;\r\n\r\n if (this.old_min_interval === null) {\r\n this.old_min_interval = this.options.min_interval;\r\n }\r\n\r\n this.options.min_interval = interval;\r\n },\r\n\r\n /**\r\n * Restore min_interval option to original\r\n */\r\n restoreOriginalMinInterval: function () {\r\n if (this.old_min_interval !== null) {\r\n this.options.min_interval = this.old_min_interval;\r\n this.old_min_interval = null;\r\n }\r\n },\r\n\r\n\r\n\r\n // =============================================================================================================\r\n // Calculations\r\n\r\n /**\r\n * All calculations and measures start here\r\n *\r\n * @param update {boolean=}\r\n */\r\n calc: function (update) {\r\n if (!this.options) {\r\n return;\r\n }\r\n\r\n this.calc_count++;\r\n\r\n if (this.calc_count === 10 || update) {\r\n this.calc_count = 0;\r\n this.coords.w_rs = this.$cache.rs.outerWidth(false);\r\n\r\n this.calcHandlePercent();\r\n }\r\n\r\n if (!this.coords.w_rs) {\r\n return;\r\n }\r\n\r\n this.calcPointerPercent();\r\n var handle_x = this.getHandleX();\r\n\r\n\r\n if (this.target === \"both\") {\r\n this.coords.p_gap = 0;\r\n handle_x = this.getHandleX();\r\n }\r\n\r\n if (this.target === \"click\") {\r\n this.coords.p_gap = this.coords.p_handle / 2;\r\n handle_x = this.getHandleX();\r\n\r\n if (this.options.drag_interval) {\r\n this.target = \"both_one\";\r\n } else {\r\n this.target = this.chooseHandle(handle_x);\r\n }\r\n }\r\n\r\n switch (this.target) {\r\n case \"base\":\r\n var w = (this.options.max - this.options.min) / 100,\r\n f = (this.result.from - this.options.min) / w,\r\n t = (this.result.to - this.options.min) / w;\r\n\r\n this.coords.p_single_real = this.toFixed(f);\r\n this.coords.p_from_real = this.toFixed(f);\r\n this.coords.p_to_real = this.toFixed(t);\r\n\r\n this.coords.p_single_real = this.checkDiapason(this.coords.p_single_real, this.options.from_min, this.options.from_max);\r\n this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);\r\n this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);\r\n\r\n this.coords.p_single_fake = this.convertToFakePercent(this.coords.p_single_real);\r\n this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);\r\n this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);\r\n\r\n this.target = null;\r\n\r\n break;\r\n\r\n case \"single\":\r\n if (this.options.from_fixed) {\r\n break;\r\n }\r\n\r\n this.coords.p_single_real = this.convertToRealPercent(handle_x);\r\n this.coords.p_single_real = this.calcWithStep(this.coords.p_single_real);\r\n this.coords.p_single_real = this.checkDiapason(this.coords.p_single_real, this.options.from_min, this.options.from_max);\r\n\r\n this.coords.p_single_fake = this.convertToFakePercent(this.coords.p_single_real);\r\n\r\n break;\r\n\r\n case \"from\":\r\n if (this.options.from_fixed) {\r\n break;\r\n }\r\n\r\n this.coords.p_from_real = this.convertToRealPercent(handle_x);\r\n this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real);\r\n if (this.coords.p_from_real > this.coords.p_to_real) {\r\n this.coords.p_from_real = this.coords.p_to_real;\r\n }\r\n this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);\r\n this.coords.p_from_real = this.checkMinInterval(this.coords.p_from_real, this.coords.p_to_real, \"from\");\r\n this.coords.p_from_real = this.checkMaxInterval(this.coords.p_from_real, this.coords.p_to_real, \"from\");\r\n\r\n this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);\r\n\r\n break;\r\n\r\n case \"to\":\r\n if (this.options.to_fixed) {\r\n break;\r\n }\r\n\r\n this.coords.p_to_real = this.convertToRealPercent(handle_x);\r\n this.coords.p_to_real = this.calcWithStep(this.coords.p_to_real);\r\n if (this.coords.p_to_real < this.coords.p_from_real) {\r\n this.coords.p_to_real = this.coords.p_from_real;\r\n }\r\n this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);\r\n this.coords.p_to_real = this.checkMinInterval(this.coords.p_to_real, this.coords.p_from_real, \"to\");\r\n this.coords.p_to_real = this.checkMaxInterval(this.coords.p_to_real, this.coords.p_from_real, \"to\");\r\n\r\n this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);\r\n\r\n break;\r\n\r\n case \"both\":\r\n if (this.options.from_fixed || this.options.to_fixed) {\r\n break;\r\n }\r\n\r\n handle_x = this.toFixed(handle_x + (this.coords.p_handle * 0.001));\r\n\r\n this.coords.p_from_real = this.convertToRealPercent(handle_x) - this.coords.p_gap_left;\r\n this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real);\r\n this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);\r\n this.coords.p_from_real = this.checkMinInterval(this.coords.p_from_real, this.coords.p_to_real, \"from\");\r\n this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);\r\n\r\n this.coords.p_to_real = this.convertToRealPercent(handle_x) + this.coords.p_gap_right;\r\n this.coords.p_to_real = this.calcWithStep(this.coords.p_to_real);\r\n this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);\r\n this.coords.p_to_real = this.checkMinInterval(this.coords.p_to_real, this.coords.p_from_real, \"to\");\r\n this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);\r\n\r\n break;\r\n\r\n case \"both_one\":\r\n if (this.options.from_fixed || this.options.to_fixed) {\r\n break;\r\n }\r\n\r\n var real_x = this.convertToRealPercent(handle_x),\r\n from = this.result.from_percent,\r\n to = this.result.to_percent,\r\n full = to - from,\r\n half = full / 2,\r\n new_from = real_x - half,\r\n new_to = real_x + half;\r\n\r\n if (new_from < 0) {\r\n new_from = 0;\r\n new_to = new_from + full;\r\n }\r\n\r\n if (new_to > 100) {\r\n new_to = 100;\r\n new_from = new_to - full;\r\n }\r\n\r\n this.coords.p_from_real = this.calcWithStep(new_from);\r\n this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max);\r\n this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real);\r\n\r\n this.coords.p_to_real = this.calcWithStep(new_to);\r\n this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max);\r\n this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real);\r\n\r\n break;\r\n }\r\n\r\n if (this.options.type === \"single\") {\r\n this.coords.p_bar_x = (this.coords.p_handle / 2);\r\n this.coords.p_bar_w = this.coords.p_single_fake;\r\n\r\n this.result.from_percent = this.coords.p_single_real;\r\n this.result.from = this.convertToValue(this.coords.p_single_real);\r\n\r\n if (this.options.values.length) {\r\n this.result.from_value = this.options.values[this.result.from];\r\n }\r\n } else {\r\n this.coords.p_bar_x = this.toFixed(this.coords.p_from_fake + (this.coords.p_handle / 2));\r\n this.coords.p_bar_w = this.toFixed(this.coords.p_to_fake - this.coords.p_from_fake);\r\n\r\n this.result.from_percent = this.coords.p_from_real;\r\n this.result.from = this.convertToValue(this.coords.p_from_real);\r\n this.result.to_percent = this.coords.p_to_real;\r\n this.result.to = this.convertToValue(this.coords.p_to_real);\r\n\r\n if (this.options.values.length) {\r\n this.result.from_value = this.options.values[this.result.from];\r\n this.result.to_value = this.options.values[this.result.to];\r\n }\r\n }\r\n\r\n this.calcMinMax();\r\n this.calcLabels();\r\n },\r\n\r\n\r\n /**\r\n * calculates pointer X in percent\r\n */\r\n calcPointerPercent: function () {\r\n if (!this.coords.w_rs) {\r\n this.coords.p_pointer = 0;\r\n return;\r\n }\r\n\r\n if (this.coords.x_pointer < 0 || isNaN(this.coords.x_pointer) ) {\r\n this.coords.x_pointer = 0;\r\n } else if (this.coords.x_pointer > this.coords.w_rs) {\r\n this.coords.x_pointer = this.coords.w_rs;\r\n }\r\n\r\n this.coords.p_pointer = this.toFixed(this.coords.x_pointer / this.coords.w_rs * 100);\r\n },\r\n\r\n convertToRealPercent: function (fake) {\r\n var full = 100 - this.coords.p_handle;\r\n return fake / full * 100;\r\n },\r\n\r\n convertToFakePercent: function (real) {\r\n var full = 100 - this.coords.p_handle;\r\n return real / 100 * full;\r\n },\r\n\r\n getHandleX: function () {\r\n var max = 100 - this.coords.p_handle,\r\n x = this.toFixed(this.coords.p_pointer - this.coords.p_gap);\r\n\r\n if (x < 0) {\r\n x = 0;\r\n } else if (x > max) {\r\n x = max;\r\n }\r\n\r\n return x;\r\n },\r\n\r\n calcHandlePercent: function () {\r\n if (this.options.type === \"single\") {\r\n this.coords.w_handle = this.$cache.s_single.outerWidth(false);\r\n } else {\r\n this.coords.w_handle = this.$cache.s_from.outerWidth(false);\r\n }\r\n\r\n this.coords.p_handle = this.toFixed(this.coords.w_handle / this.coords.w_rs * 100);\r\n },\r\n\r\n /**\r\n * Find closest handle to pointer click\r\n *\r\n * @param real_x {Number}\r\n * @returns {String}\r\n */\r\n chooseHandle: function (real_x) {\r\n if (this.options.type === \"single\") {\r\n return \"single\";\r\n } else {\r\n var m_point = this.coords.p_from_real + ((this.coords.p_to_real - this.coords.p_from_real) / 2);\r\n if (real_x >= m_point) {\r\n return this.options.to_fixed ? \"from\" : \"to\";\r\n } else {\r\n return this.options.from_fixed ? \"to\" : \"from\";\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Measure Min and Max labels width in percent\r\n */\r\n calcMinMax: function () {\r\n if (!this.coords.w_rs) {\r\n return;\r\n }\r\n\r\n this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100;\r\n this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100;\r\n },\r\n\r\n /**\r\n * Measure labels width and X in percent\r\n */\r\n calcLabels: function () {\r\n if (!this.coords.w_rs || this.options.hide_from_to) {\r\n return;\r\n }\r\n\r\n if (this.options.type === \"single\") {\r\n\r\n this.labels.w_single = this.$cache.single.outerWidth(false);\r\n this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;\r\n this.labels.p_single_left = this.coords.p_single_fake + (this.coords.p_handle / 2) - (this.labels.p_single_fake / 2);\r\n this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);\r\n\r\n } else {\r\n\r\n this.labels.w_from = this.$cache.from.outerWidth(false);\r\n this.labels.p_from_fake = this.labels.w_from / this.coords.w_rs * 100;\r\n this.labels.p_from_left = this.coords.p_from_fake + (this.coords.p_handle / 2) - (this.labels.p_from_fake / 2);\r\n this.labels.p_from_left = this.toFixed(this.labels.p_from_left);\r\n this.labels.p_from_left = this.checkEdges(this.labels.p_from_left, this.labels.p_from_fake);\r\n\r\n this.labels.w_to = this.$cache.to.outerWidth(false);\r\n this.labels.p_to_fake = this.labels.w_to / this.coords.w_rs * 100;\r\n this.labels.p_to_left = this.coords.p_to_fake + (this.coords.p_handle / 2) - (this.labels.p_to_fake / 2);\r\n this.labels.p_to_left = this.toFixed(this.labels.p_to_left);\r\n this.labels.p_to_left = this.checkEdges(this.labels.p_to_left, this.labels.p_to_fake);\r\n\r\n this.labels.w_single = this.$cache.single.outerWidth(false);\r\n this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;\r\n this.labels.p_single_left = ((this.labels.p_from_left + this.labels.p_to_left + this.labels.p_to_fake) / 2) - (this.labels.p_single_fake / 2);\r\n this.labels.p_single_left = this.toFixed(this.labels.p_single_left);\r\n this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);\r\n\r\n }\r\n },\r\n\r\n\r\n\r\n // =============================================================================================================\r\n // Drawings\r\n\r\n /**\r\n * Main function called in request animation frame\r\n * to update everything\r\n */\r\n updateScene: function () {\r\n if (this.raf_id) {\r\n cancelAnimationFrame(this.raf_id);\r\n this.raf_id = null;\r\n }\r\n\r\n clearTimeout(this.update_tm);\r\n this.update_tm = null;\r\n\r\n if (!this.options) {\r\n return;\r\n }\r\n\r\n this.drawHandles();\r\n\r\n if (this.is_active) {\r\n this.raf_id = requestAnimationFrame(this.updateScene.bind(this));\r\n } else {\r\n this.update_tm = setTimeout(this.updateScene.bind(this), 300);\r\n }\r\n },\r\n\r\n /**\r\n * Draw handles\r\n */\r\n drawHandles: function () {\r\n this.coords.w_rs = this.$cache.rs.outerWidth(false);\r\n\r\n if (!this.coords.w_rs) {\r\n return;\r\n }\r\n\r\n if (this.coords.w_rs !== this.coords.w_rs_old) {\r\n this.target = \"base\";\r\n this.is_resize = true;\r\n }\r\n\r\n if (this.coords.w_rs !== this.coords.w_rs_old || this.force_redraw) {\r\n this.setMinMax();\r\n this.calc(true);\r\n this.drawLabels();\r\n if (this.options.grid) {\r\n this.calcGridMargin();\r\n this.calcGridLabels();\r\n }\r\n this.force_redraw = true;\r\n this.coords.w_rs_old = this.coords.w_rs;\r\n this.drawShadow();\r\n }\r\n\r\n if (!this.coords.w_rs) {\r\n return;\r\n }\r\n\r\n if (!this.dragging && !this.force_redraw && !this.is_key) {\r\n return;\r\n }\r\n\r\n if (this.old_from !== this.result.from || this.old_to !== this.result.to || this.force_redraw || this.is_key) {\r\n\r\n this.drawLabels();\r\n\r\n this.$cache.bar[0].style.left = this.coords.p_bar_x + \"%\";\r\n this.$cache.bar[0].style.width = this.coords.p_bar_w + \"%\";\r\n\r\n if (this.options.type === \"single\") {\r\n this.$cache.s_single[0].style.left = this.coords.p_single_fake + \"%\";\r\n\r\n this.$cache.single[0].style.left = this.labels.p_single_left + \"%\";\r\n } else {\r\n this.$cache.s_from[0].style.left = this.coords.p_from_fake + \"%\";\r\n this.$cache.s_to[0].style.left = this.coords.p_to_fake + \"%\";\r\n\r\n if (this.old_from !== this.result.from || this.force_redraw) {\r\n this.$cache.from[0].style.left = this.labels.p_from_left + \"%\";\r\n }\r\n if (this.old_to !== this.result.to || this.force_redraw) {\r\n this.$cache.to[0].style.left = this.labels.p_to_left + \"%\";\r\n }\r\n\r\n this.$cache.single[0].style.left = this.labels.p_single_left + \"%\";\r\n }\r\n\r\n this.writeToInput();\r\n\r\n if ((this.old_from !== this.result.from || this.old_to !== this.result.to) && !this.is_start) {\r\n this.$cache.input.trigger(\"change\");\r\n this.$cache.input.trigger(\"input\");\r\n }\r\n\r\n this.old_from = this.result.from;\r\n this.old_to = this.result.to;\r\n\r\n // callbacks call\r\n if (!this.is_resize && !this.is_update && !this.is_start && !this.is_finish) {\r\n this.callOnChange();\r\n }\r\n if (this.is_key || this.is_click) {\r\n this.is_key = false;\r\n this.is_click = false;\r\n this.callOnFinish();\r\n }\r\n\r\n this.is_update = false;\r\n this.is_resize = false;\r\n this.is_finish = false;\r\n }\r\n\r\n this.is_start = false;\r\n this.is_key = false;\r\n this.is_click = false;\r\n this.force_redraw = false;\r\n },\r\n\r\n /**\r\n * Draw labels\r\n * measure labels collisions\r\n * collapse close labels\r\n */\r\n drawLabels: function () {\r\n if (!this.options) {\r\n return;\r\n }\r\n\r\n var values_num = this.options.values.length,\r\n p_values = this.options.p_values,\r\n text_single,\r\n text_from,\r\n text_to;\r\n\r\n if (this.options.hide_from_to) {\r\n return;\r\n }\r\n\r\n if (this.options.type === \"single\") {\r\n\r\n if (values_num) {\r\n text_single = this.decorate(p_values[this.result.from]);\r\n this.$cache.single.html(text_single);\r\n } else {\r\n text_single = this.decorate(this._prettify(this.result.from), this.result.from);\r\n this.$cache.single.html(text_single);\r\n }\r\n\r\n this.calcLabels();\r\n\r\n if (this.labels.p_single_left < this.labels.p_min + 1) {\r\n this.$cache.min[0].style.visibility = \"hidden\";\r\n } else {\r\n this.$cache.min[0].style.visibility = \"visible\";\r\n }\r\n\r\n if (this.labels.p_single_left + this.labels.p_single_fake > 100 - this.labels.p_max - 1) {\r\n this.$cache.max[0].style.visibility = \"hidden\";\r\n } else {\r\n this.$cache.max[0].style.visibility = \"visible\";\r\n }\r\n\r\n } else {\r\n\r\n if (values_num) {\r\n\r\n if (this.options.decorate_both) {\r\n text_single = this.decorate(p_values[this.result.from]);\r\n text_single += this.options.values_separator;\r\n text_single += this.decorate(p_values[this.result.to]);\r\n } else {\r\n text_single = this.decorate(p_values[this.result.from] + this.options.values_separator + p_values[this.result.to]);\r\n }\r\n text_from = this.decorate(p_values[this.result.from]);\r\n text_to = this.decorate(p_values[this.result.to]);\r\n\r\n this.$cache.single.html(text_single);\r\n this.$cache.from.html(text_from);\r\n this.$cache.to.html(text_to);\r\n\r\n } else {\r\n\r\n if (this.options.decorate_both) {\r\n text_single = this.decorate(this._prettify(this.result.from), this.result.from);\r\n text_single += this.options.values_separator;\r\n text_single += this.decorate(this._prettify(this.result.to), this.result.to);\r\n } else {\r\n text_single = this.decorate(this._prettify(this.result.from) + this.options.values_separator + this._prettify(this.result.to), this.result.to);\r\n }\r\n text_from = this.decorate(this._prettify(this.result.from), this.result.from);\r\n text_to = this.decorate(this._prettify(this.result.to), this.result.to);\r\n\r\n this.$cache.single.html(text_single);\r\n this.$cache.from.html(text_from);\r\n this.$cache.to.html(text_to);\r\n\r\n }\r\n\r\n this.calcLabels();\r\n\r\n var min = Math.min(this.labels.p_single_left, this.labels.p_from_left),\r\n single_left = this.labels.p_single_left + this.labels.p_single_fake,\r\n to_left = this.labels.p_to_left + this.labels.p_to_fake,\r\n max = Math.max(single_left, to_left);\r\n\r\n if (this.labels.p_from_left + this.labels.p_from_fake >= this.labels.p_to_left) {\r\n this.$cache.from[0].style.visibility = \"hidden\";\r\n this.$cache.to[0].style.visibility = \"hidden\";\r\n this.$cache.single[0].style.visibility = \"visible\";\r\n\r\n if (this.result.from === this.result.to) {\r\n if (this.target === \"from\") {\r\n this.$cache.from[0].style.visibility = \"visible\";\r\n } else if (this.target === \"to\") {\r\n this.$cache.to[0].style.visibility = \"visible\";\r\n } else if (!this.target) {\r\n this.$cache.from[0].style.visibility = \"visible\";\r\n }\r\n this.$cache.single[0].style.visibility = \"hidden\";\r\n max = to_left;\r\n } else {\r\n this.$cache.from[0].style.visibility = \"hidden\";\r\n this.$cache.to[0].style.visibility = \"hidden\";\r\n this.$cache.single[0].style.visibility = \"visible\";\r\n max = Math.max(single_left, to_left);\r\n }\r\n } else {\r\n this.$cache.from[0].style.visibility = \"visible\";\r\n this.$cache.to[0].style.visibility = \"visible\";\r\n this.$cache.single[0].style.visibility = \"hidden\";\r\n }\r\n\r\n if (min < this.labels.p_min + 1) {\r\n this.$cache.min[0].style.visibility = \"hidden\";\r\n } else {\r\n this.$cache.min[0].style.visibility = \"visible\";\r\n }\r\n\r\n if (max > 100 - this.labels.p_max - 1) {\r\n this.$cache.max[0].style.visibility = \"hidden\";\r\n } else {\r\n this.$cache.max[0].style.visibility = \"visible\";\r\n }\r\n\r\n }\r\n },\r\n\r\n /**\r\n * Draw shadow intervals\r\n */\r\n drawShadow: function () {\r\n var o = this.options,\r\n c = this.$cache,\r\n\r\n is_from_min = typeof o.from_min === \"number\" && !isNaN(o.from_min),\r\n is_from_max = typeof o.from_max === \"number\" && !isNaN(o.from_max),\r\n is_to_min = typeof o.to_min === \"number\" && !isNaN(o.to_min),\r\n is_to_max = typeof o.to_max === \"number\" && !isNaN(o.to_max),\r\n\r\n from_min,\r\n from_max,\r\n to_min,\r\n to_max;\r\n\r\n if (o.type === \"single\") {\r\n if (o.from_shadow && (is_from_min || is_from_max)) {\r\n from_min = this.convertToPercent(is_from_min ? o.from_min : o.min);\r\n from_max = this.convertToPercent(is_from_max ? o.from_max : o.max) - from_min;\r\n from_min = this.toFixed(from_min - (this.coords.p_handle / 100 * from_min));\r\n from_max = this.toFixed(from_max - (this.coords.p_handle / 100 * from_max));\r\n from_min = from_min + (this.coords.p_handle / 2);\r\n\r\n c.shad_single[0].style.display = \"block\";\r\n c.shad_single[0].style.left = from_min + \"%\";\r\n c.shad_single[0].style.width = from_max + \"%\";\r\n } else {\r\n c.shad_single[0].style.display = \"none\";\r\n }\r\n } else {\r\n if (o.from_shadow && (is_from_min || is_from_max)) {\r\n from_min = this.convertToPercent(is_from_min ? o.from_min : o.min);\r\n from_max = this.convertToPercent(is_from_max ? o.from_max : o.max) - from_min;\r\n from_min = this.toFixed(from_min - (this.coords.p_handle / 100 * from_min));\r\n from_max = this.toFixed(from_max - (this.coords.p_handle / 100 * from_max));\r\n from_min = from_min + (this.coords.p_handle / 2);\r\n\r\n c.shad_from[0].style.display = \"block\";\r\n c.shad_from[0].style.left = from_min + \"%\";\r\n c.shad_from[0].style.width = from_max + \"%\";\r\n } else {\r\n c.shad_from[0].style.display = \"none\";\r\n }\r\n\r\n if (o.to_shadow && (is_to_min || is_to_max)) {\r\n to_min = this.convertToPercent(is_to_min ? o.to_min : o.min);\r\n to_max = this.convertToPercent(is_to_max ? o.to_max : o.max) - to_min;\r\n to_min = this.toFixed(to_min - (this.coords.p_handle / 100 * to_min));\r\n to_max = this.toFixed(to_max - (this.coords.p_handle / 100 * to_max));\r\n to_min = to_min + (this.coords.p_handle / 2);\r\n\r\n c.shad_to[0].style.display = \"block\";\r\n c.shad_to[0].style.left = to_min + \"%\";\r\n c.shad_to[0].style.width = to_max + \"%\";\r\n } else {\r\n c.shad_to[0].style.display = \"none\";\r\n }\r\n }\r\n },\r\n\r\n\r\n\r\n /**\r\n * Write values to input element\r\n */\r\n writeToInput: function () {\r\n if (this.options.type === \"single\") {\r\n if (this.options.values.length) {\r\n this.$cache.input.prop(\"value\", this.result.from_value);\r\n } else {\r\n this.$cache.input.prop(\"value\", this.result.from);\r\n }\r\n this.$cache.input.data(\"from\", this.result.from);\r\n } else {\r\n if (this.options.values.length) {\r\n this.$cache.input.prop(\"value\", this.result.from_value + this.options.input_values_separator + this.result.to_value);\r\n } else {\r\n this.$cache.input.prop(\"value\", this.result.from + this.options.input_values_separator + this.result.to);\r\n }\r\n this.$cache.input.data(\"from\", this.result.from);\r\n this.$cache.input.data(\"to\", this.result.to);\r\n }\r\n },\r\n\r\n\r\n\r\n // =============================================================================================================\r\n // Callbacks\r\n\r\n callOnStart: function () {\r\n this.writeToInput();\r\n\r\n if (this.options.onStart && typeof this.options.onStart === \"function\") {\r\n this.options.onStart(this.result);\r\n }\r\n },\r\n callOnChange: function () {\r\n this.writeToInput();\r\n\r\n if (this.options.onChange && typeof this.options.onChange === \"function\") {\r\n this.options.onChange(this.result);\r\n }\r\n },\r\n callOnFinish: function () {\r\n this.writeToInput();\r\n\r\n if (this.options.onFinish && typeof this.options.onFinish === \"function\") {\r\n this.options.onFinish(this.result);\r\n }\r\n },\r\n callOnUpdate: function () {\r\n this.writeToInput();\r\n\r\n if (this.options.onUpdate && typeof this.options.onUpdate === \"function\") {\r\n this.options.onUpdate(this.result);\r\n }\r\n },\r\n\r\n\r\n\r\n\r\n // =============================================================================================================\r\n // Service methods\r\n\r\n toggleInput: function () {\r\n this.$cache.input.toggleClass(\"irs-hidden-input\");\r\n },\r\n\r\n /**\r\n * Convert real value to percent\r\n *\r\n * @param value {Number} X in real\r\n * @param no_min {boolean=} don't use min value\r\n * @returns {Number} X in percent\r\n */\r\n convertToPercent: function (value, no_min) {\r\n var diapason = this.options.max - this.options.min,\r\n one_percent = diapason / 100,\r\n val, percent;\r\n\r\n if (!diapason) {\r\n this.no_diapason = true;\r\n return 0;\r\n }\r\n\r\n if (no_min) {\r\n val = value;\r\n } else {\r\n val = value - this.options.min;\r\n }\r\n\r\n percent = val / one_percent;\r\n\r\n return this.toFixed(percent);\r\n },\r\n\r\n /**\r\n * Convert percent to real values\r\n *\r\n * @param percent {Number} X in percent\r\n * @returns {Number} X in real\r\n */\r\n convertToValue: function (percent) {\r\n var min = this.options.min,\r\n max = this.options.max,\r\n min_decimals = min.toString().split(\".\")[1],\r\n max_decimals = max.toString().split(\".\")[1],\r\n min_length, max_length,\r\n avg_decimals = 0,\r\n abs = 0;\r\n\r\n if (percent === 0) {\r\n return this.options.min;\r\n }\r\n if (percent === 100) {\r\n return this.options.max;\r\n }\r\n\r\n\r\n if (min_decimals) {\r\n min_length = min_decimals.length;\r\n avg_decimals = min_length;\r\n }\r\n if (max_decimals) {\r\n max_length = max_decimals.length;\r\n avg_decimals = max_length;\r\n }\r\n if (min_length && max_length) {\r\n avg_decimals = (min_length >= max_length) ? min_length : max_length;\r\n }\r\n\r\n if (min < 0) {\r\n abs = Math.abs(min);\r\n min = +(min + abs).toFixed(avg_decimals);\r\n max = +(max + abs).toFixed(avg_decimals);\r\n }\r\n\r\n var number = ((max - min) / 100 * percent) + min,\r\n string = this.options.step.toString().split(\".\")[1],\r\n result;\r\n\r\n if (string) {\r\n number = +number.toFixed(string.length);\r\n } else {\r\n number = number / this.options.step;\r\n number = number * this.options.step;\r\n\r\n number = +number.toFixed(0);\r\n }\r\n\r\n if (abs) {\r\n number -= abs;\r\n }\r\n\r\n if (string) {\r\n result = +number.toFixed(string.length);\r\n } else {\r\n result = this.toFixed(number);\r\n }\r\n\r\n if (result < this.options.min) {\r\n result = this.options.min;\r\n } else if (result > this.options.max) {\r\n result = this.options.max;\r\n }\r\n\r\n return result;\r\n },\r\n\r\n /**\r\n * Round percent value with step\r\n *\r\n * @param percent {Number}\r\n * @returns percent {Number} rounded\r\n */\r\n calcWithStep: function (percent) {\r\n var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step;\r\n\r\n if (rounded > 100) {\r\n rounded = 100;\r\n }\r\n if (percent === 100) {\r\n rounded = 100;\r\n }\r\n\r\n return this.toFixed(rounded);\r\n },\r\n\r\n checkMinInterval: function (p_current, p_next, type) {\r\n var o = this.options,\r\n current,\r\n next;\r\n\r\n if (!o.min_interval) {\r\n return p_current;\r\n }\r\n\r\n current = this.convertToValue(p_current);\r\n next = this.convertToValue(p_next);\r\n\r\n if (type === \"from\") {\r\n\r\n if (next - current < o.min_interval) {\r\n current = next - o.min_interval;\r\n }\r\n\r\n } else {\r\n\r\n if (current - next < o.min_interval) {\r\n current = next + o.min_interval;\r\n }\r\n\r\n }\r\n\r\n return this.convertToPercent(current);\r\n },\r\n\r\n checkMaxInterval: function (p_current, p_next, type) {\r\n var o = this.options,\r\n current,\r\n next;\r\n\r\n if (!o.max_interval) {\r\n return p_current;\r\n }\r\n\r\n current = this.convertToValue(p_current);\r\n next = this.convertToValue(p_next);\r\n\r\n if (type === \"from\") {\r\n\r\n if (next - current > o.max_interval) {\r\n current = next - o.max_interval;\r\n }\r\n\r\n } else {\r\n\r\n if (current - next > o.max_interval) {\r\n current = next + o.max_interval;\r\n }\r\n\r\n }\r\n\r\n return this.convertToPercent(current);\r\n },\r\n\r\n checkDiapason: function (p_num, min, max) {\r\n var num = this.convertToValue(p_num),\r\n o = this.options;\r\n\r\n if (typeof min !== \"number\") {\r\n min = o.min;\r\n }\r\n\r\n if (typeof max !== \"number\") {\r\n max = o.max;\r\n }\r\n\r\n if (num < min) {\r\n num = min;\r\n }\r\n\r\n if (num > max) {\r\n num = max;\r\n }\r\n\r\n return this.convertToPercent(num);\r\n },\r\n\r\n toFixed: function (num) {\r\n num = num.toFixed(20);\r\n return +num;\r\n },\r\n\r\n _prettify: function (num) {\r\n if (!this.options.prettify_enabled) {\r\n return num;\r\n }\r\n\r\n if (this.options.prettify && typeof this.options.prettify === \"function\") {\r\n return this.options.prettify(num);\r\n } else {\r\n return this.prettify(num);\r\n }\r\n },\r\n\r\n prettify: function (num) {\r\n var n = num.toString();\r\n return n.replace(/(\\d{1,3}(?=(?:\\d\\d\\d)+(?!\\d)))/g, \"$1\" + this.options.prettify_separator);\r\n },\r\n\r\n checkEdges: function (left, width) {\r\n if (!this.options.force_edges) {\r\n return this.toFixed(left);\r\n }\r\n\r\n if (left < 0) {\r\n left = 0;\r\n } else if (left > 100 - width) {\r\n left = 100 - width;\r\n }\r\n\r\n return this.toFixed(left);\r\n },\r\n\r\n validate: function () {\r\n var o = this.options,\r\n r = this.result,\r\n v = o.values,\r\n vl = v.length,\r\n value,\r\n i;\r\n\r\n if (typeof o.min === \"string\") o.min = +o.min;\r\n if (typeof o.max === \"string\") o.max = +o.max;\r\n if (typeof o.from === \"string\") o.from = +o.from;\r\n if (typeof o.to === \"string\") o.to = +o.to;\r\n if (typeof o.step === \"string\") o.step = +o.step;\r\n\r\n if (typeof o.from_min === \"string\") o.from_min = +o.from_min;\r\n if (typeof o.from_max === \"string\") o.from_max = +o.from_max;\r\n if (typeof o.to_min === \"string\") o.to_min = +o.to_min;\r\n if (typeof o.to_max === \"string\") o.to_max = +o.to_max;\r\n\r\n if (typeof o.keyboard_step === \"string\") o.keyboard_step = +o.keyboard_step;\r\n if (typeof o.grid_num === \"string\") o.grid_num = +o.grid_num;\r\n\r\n if (o.max < o.min) {\r\n o.max = o.min;\r\n }\r\n\r\n if (vl) {\r\n o.p_values = [];\r\n o.min = 0;\r\n o.max = vl - 1;\r\n o.step = 1;\r\n o.grid_num = o.max;\r\n o.grid_snap = true;\r\n\r\n for (i = 0; i < vl; i++) {\r\n value = +v[i];\r\n\r\n if (!isNaN(value)) {\r\n v[i] = value;\r\n value = this._prettify(value);\r\n } else {\r\n value = v[i];\r\n }\r\n\r\n o.p_values.push(value);\r\n }\r\n }\r\n\r\n if (typeof o.from !== \"number\" || isNaN(o.from)) {\r\n o.from = o.min;\r\n }\r\n\r\n if (typeof o.to !== \"number\" || isNaN(o.to)) {\r\n o.to = o.max;\r\n }\r\n\r\n if (o.type === \"single\") {\r\n\r\n if (o.from < o.min) o.from = o.min;\r\n if (o.from > o.max) o.from = o.max;\r\n\r\n } else {\r\n\r\n if (o.from < o.min) o.from = o.min;\r\n if (o.from > o.max) o.from = o.max;\r\n\r\n if (o.to < o.min) o.to = o.min;\r\n if (o.to > o.max) o.to = o.max;\r\n\r\n if (this.update_check.from) {\r\n\r\n if (this.update_check.from !== o.from) {\r\n if (o.from > o.to) o.from = o.to;\r\n }\r\n if (this.update_check.to !== o.to) {\r\n if (o.to < o.from) o.to = o.from;\r\n }\r\n\r\n }\r\n\r\n if (o.from > o.to) o.from = o.to;\r\n if (o.to < o.from) o.to = o.from;\r\n\r\n }\r\n\r\n if (typeof o.step !== \"number\" || isNaN(o.step) || !o.step || o.step < 0) {\r\n o.step = 1;\r\n }\r\n\r\n if (typeof o.keyboard_step !== \"number\" || isNaN(o.keyboard_step) || !o.keyboard_step || o.keyboard_step < 0) {\r\n o.keyboard_step = 5;\r\n }\r\n\r\n if (typeof o.from_min === \"number\" && o.from < o.from_min) {\r\n o.from = o.from_min;\r\n }\r\n\r\n if (typeof o.from_max === \"number\" && o.from > o.from_max) {\r\n o.from = o.from_max;\r\n }\r\n\r\n if (typeof o.to_min === \"number\" && o.to < o.to_min) {\r\n o.to = o.to_min;\r\n }\r\n\r\n if (typeof o.to_max === \"number\" && o.from > o.to_max) {\r\n o.to = o.to_max;\r\n }\r\n\r\n if (r) {\r\n if (r.min !== o.min) {\r\n r.min = o.min;\r\n }\r\n\r\n if (r.max !== o.max) {\r\n r.max = o.max;\r\n }\r\n\r\n if (r.from < r.min || r.from > r.max) {\r\n r.from = o.from;\r\n }\r\n\r\n if (r.to < r.min || r.to > r.max) {\r\n r.to = o.to;\r\n }\r\n }\r\n\r\n if (typeof o.min_interval !== \"number\" || isNaN(o.min_interval) || !o.min_interval || o.min_interval < 0) {\r\n o.min_interval = 0;\r\n }\r\n\r\n if (typeof o.max_interval !== \"number\" || isNaN(o.max_interval) || !o.max_interval || o.max_interval < 0) {\r\n o.max_interval = 0;\r\n }\r\n\r\n if (o.min_interval && o.min_interval > o.max - o.min) {\r\n o.min_interval = o.max - o.min;\r\n }\r\n\r\n if (o.max_interval && o.max_interval > o.max - o.min) {\r\n o.max_interval = o.max - o.min;\r\n }\r\n },\r\n\r\n decorate: function (num, original) {\r\n var decorated = \"\",\r\n o = this.options;\r\n\r\n if (o.prefix) {\r\n decorated += o.prefix;\r\n }\r\n\r\n decorated += num;\r\n\r\n if (o.max_postfix) {\r\n if (o.values.length && num === o.p_values[o.max]) {\r\n decorated += o.max_postfix;\r\n if (o.postfix) {\r\n decorated += \" \";\r\n }\r\n } else if (original === o.max) {\r\n decorated += o.max_postfix;\r\n if (o.postfix) {\r\n decorated += \" \";\r\n }\r\n }\r\n }\r\n\r\n if (o.postfix) {\r\n decorated += o.postfix;\r\n }\r\n\r\n return decorated;\r\n },\r\n\r\n updateFrom: function () {\r\n this.result.from = this.options.from;\r\n this.result.from_percent = this.convertToPercent(this.result.from);\r\n if (this.options.values) {\r\n this.result.from_value = this.options.values[this.result.from];\r\n }\r\n },\r\n\r\n updateTo: function () {\r\n this.result.to = this.options.to;\r\n this.result.to_percent = this.convertToPercent(this.result.to);\r\n if (this.options.values) {\r\n this.result.to_value = this.options.values[this.result.to];\r\n }\r\n },\r\n\r\n updateResult: function () {\r\n this.result.min = this.options.min;\r\n this.result.max = this.options.max;\r\n this.updateFrom();\r\n this.updateTo();\r\n },\r\n\r\n\r\n // =============================================================================================================\r\n // Grid\r\n\r\n appendGrid: function () {\r\n if (!this.options.grid) {\r\n return;\r\n }\r\n\r\n var o = this.options,\r\n i, z,\r\n\r\n total = o.max - o.min,\r\n big_num = o.grid_num,\r\n big_p = 0,\r\n big_w = 0,\r\n\r\n small_max = 4,\r\n local_small_max,\r\n small_p,\r\n small_w = 0,\r\n\r\n result,\r\n html = '';\r\n\r\n\r\n\r\n this.calcGridMargin();\r\n\r\n if (o.grid_snap) {\r\n\r\n if (total > 50) {\r\n big_num = 50 / o.step;\r\n big_p = this.toFixed(o.step / 0.5);\r\n } else {\r\n big_num = total / o.step;\r\n big_p = this.toFixed(o.step / (total / 100));\r\n }\r\n\r\n } else {\r\n big_p = this.toFixed(100 / big_num);\r\n }\r\n\r\n if (big_num > 4) {\r\n small_max = 3;\r\n }\r\n if (big_num > 7) {\r\n small_max = 2;\r\n }\r\n if (big_num > 14) {\r\n small_max = 1;\r\n }\r\n if (big_num > 28) {\r\n small_max = 0;\r\n }\r\n\r\n for (i = 0; i < big_num + 1; i++) {\r\n local_small_max = small_max;\r\n\r\n big_w = this.toFixed(big_p * i);\r\n\r\n if (big_w > 100) {\r\n big_w = 100;\r\n\r\n local_small_max -= 2;\r\n if (local_small_max < 0) {\r\n local_small_max = 0;\r\n }\r\n }\r\n this.coords.big[i] = big_w;\r\n\r\n small_p = (big_w - (big_p * (i - 1))) / (local_small_max + 1);\r\n\r\n for (z = 1; z <= local_small_max; z++) {\r\n if (big_w === 0) {\r\n break;\r\n }\r\n\r\n small_w = this.toFixed(big_w - (small_p * z));\r\n\r\n html += '<span class=\"irs-grid-pol small\" style=\"left: ' + small_w + '%\"></span>';\r\n }\r\n\r\n html += '<span class=\"irs-grid-pol\" style=\"left: ' + big_w + '%\"></span>';\r\n\r\n result = this.convertToValue(big_w);\r\n if (o.values.length) {\r\n result = o.p_values[result];\r\n } else {\r\n result = this._prettify(result);\r\n }\r\n\r\n html += '<span class=\"irs-grid-text js-grid-text-' + i + '\" style=\"left: ' + big_w + '%\">' + result + '</span>';\r\n }\r\n this.coords.big_num = Math.ceil(big_num + 1);\r\n\r\n\r\n\r\n this.$cache.cont.addClass(\"irs-with-grid\");\r\n this.$cache.grid.html(html);\r\n this.cacheGridLabels();\r\n },\r\n\r\n cacheGridLabels: function () {\r\n var $label, i,\r\n num = this.coords.big_num;\r\n\r\n for (i = 0; i < num; i++) {\r\n $label = this.$cache.grid.find(\".js-grid-text-\" + i);\r\n this.$cache.grid_labels.push($label);\r\n }\r\n\r\n this.calcGridLabels();\r\n },\r\n\r\n calcGridLabels: function () {\r\n var i, label, start = [], finish = [],\r\n num = this.coords.big_num;\r\n\r\n for (i = 0; i < num; i++) {\r\n this.coords.big_w[i] = this.$cache.grid_labels[i].outerWidth(false);\r\n this.coords.big_p[i] = this.toFixed(this.coords.big_w[i] / this.coords.w_rs * 100);\r\n this.coords.big_x[i] = this.toFixed(this.coords.big_p[i] / 2);\r\n\r\n start[i] = this.toFixed(this.coords.big[i] - this.coords.big_x[i]);\r\n finish[i] = this.toFixed(start[i] + this.coords.big_p[i]);\r\n }\r\n\r\n if (this.options.force_edges) {\r\n if (start[0] < -this.coords.grid_gap) {\r\n start[0] = -this.coords.grid_gap;\r\n finish[0] = this.toFixed(start[0] + this.coords.big_p[0]);\r\n\r\n this.coords.big_x[0] = this.coords.grid_gap;\r\n }\r\n\r\n if (finish[num - 1] > 100 + this.coords.grid_gap) {\r\n finish[num - 1] = 100 + this.coords.grid_gap;\r\n start[num - 1] = this.toFixed(finish[num - 1] - this.coords.big_p[num - 1]);\r\n\r\n this.coords.big_x[num - 1] = this.toFixed(this.coords.big_p[num - 1] - this.coords.grid_gap);\r\n }\r\n }\r\n\r\n this.calcGridCollision(2, start, finish);\r\n this.calcGridCollision(4, start, finish);\r\n\r\n for (i = 0; i < num; i++) {\r\n label = this.$cache.grid_labels[i][0];\r\n\r\n if (this.coords.big_x[i] !== Number.POSITIVE_INFINITY) {\r\n label.style.marginLeft = -this.coords.big_x[i] + \"%\";\r\n }\r\n }\r\n },\r\n\r\n // Collisions Calc Beta\r\n // TODO: Refactor then have plenty of time\r\n calcGridCollision: function (step, start, finish) {\r\n var i, next_i, label,\r\n num = this.coords.big_num;\r\n\r\n for (i = 0; i < num; i += step) {\r\n next_i = i + (step / 2);\r\n if (next_i >= num) {\r\n break;\r\n }\r\n\r\n label = this.$cache.grid_labels[next_i][0];\r\n\r\n if (finish[i] <= start[next_i]) {\r\n label.style.visibility = \"visible\";\r\n } else {\r\n label.style.visibility = \"hidden\";\r\n }\r\n }\r\n },\r\n\r\n calcGridMargin: function () {\r\n if (!this.options.grid_margin) {\r\n return;\r\n }\r\n\r\n this.coords.w_rs = this.$cache.rs.outerWidth(false);\r\n if (!this.coords.w_rs) {\r\n return;\r\n }\r\n\r\n if (this.options.type === \"single\") {\r\n this.coords.w_handle = this.$cache.s_single.outerWidth(false);\r\n } else {\r\n this.coords.w_handle = this.$cache.s_from.outerWidth(false);\r\n }\r\n this.coords.p_handle = this.toFixed(this.coords.w_handle / this.coords.w_rs * 100);\r\n this.coords.grid_gap = this.toFixed((this.coords.p_handle / 2) - 0.1);\r\n\r\n this.$cache.grid[0].style.width = this.toFixed(100 - this.coords.p_handle) + \"%\";\r\n this.$cache.grid[0].style.left = this.coords.grid_gap + \"%\";\r\n },\r\n\r\n\r\n\r\n // =============================================================================================================\r\n // Public methods\r\n\r\n update: function (options) {\r\n if (!this.input) {\r\n return;\r\n }\r\n\r\n this.is_update = true;\r\n\r\n this.options.from = this.result.from;\r\n this.options.to = this.result.to;\r\n this.update_check.from = this.result.from;\r\n this.update_check.to = this.result.to;\r\n\r\n this.options = $.extend(this.options, options);\r\n this.validate();\r\n this.updateResult(options);\r\n\r\n this.toggleInput();\r\n this.remove();\r\n this.init(true);\r\n },\r\n\r\n reset: function () {\r\n if (!this.input) {\r\n return;\r\n }\r\n\r\n this.updateResult();\r\n this.update();\r\n },\r\n\r\n destroy: function () {\r\n if (!this.input) {\r\n return;\r\n }\r\n\r\n this.toggleInput();\r\n this.$cache.input.prop(\"readonly\", false);\r\n $.data(this.input, \"ionRangeSlider\", null);\r\n\r\n this.remove();\r\n this.input = null;\r\n this.options = null;\r\n }\r\n };\r\n\r\n $.fn.ionRangeSlider = function (options) {\r\n return this.each(function() {\r\n if (!$.data(this, \"ionRangeSlider\")) {\r\n $.data(this, \"ionRangeSlider\", new IonRangeSlider(this, options, plugin_count++));\r\n }\r\n });\r\n };\r\n\r\n\r\n\r\n // =================================================================================================================\r\n // http://paulirish.com/2011/requestanimationframe-for-smart-animating/\r\n // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\r\n\r\n // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel\r\n\r\n // MIT license\r\n\r\n (function() {\r\n var lastTime = 0;\r\n var vendors = ['ms', 'moz', 'webkit', 'o'];\r\n for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\r\n window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];\r\n window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']\r\n || window[vendors[x]+'CancelRequestAnimationFrame'];\r\n }\r\n\r\n if (!window.requestAnimationFrame)\r\n window.requestAnimationFrame = function(callback, element) {\r\n var currTime = new Date().getTime();\r\n var timeToCall = Math.max(0, 16 - (currTime - lastTime));\r\n var id = window.setTimeout(function() { callback(currTime + timeToCall); },\r\n timeToCall);\r\n lastTime = currTime + timeToCall;\r\n return id;\r\n };\r\n\r\n if (!window.cancelAnimationFrame)\r\n window.cancelAnimationFrame = function(id) {\r\n clearTimeout(id);\r\n };\r\n }());\r\n\r\n}));\r\n\r\n\r\n\r\n// Trigger\r\n\r\n$(function () {\r\n \r\nvar $range = $(\".js-range-slider\"),\r\n $inputFrom = $(\".js-input-from\"),\r\n $inputTo = $(\".js-input-to\"),\r\n instance,\r\n min = 0,\r\n max = 1000,\r\n from = 10,\r\n to = 100;\r\n\r\n$range.ionRangeSlider({\r\n type: \"double\",\r\n min: min,\r\n max: max,\r\n from: 0,\r\n to: 500,\r\n prefix: '$ ',\r\n onStart: updateInputs,\r\n onChange: updateInputs,\r\n step: 1,\r\n prettify_enabled: true,\r\n prettify_separator: \".\",\r\n values_separator: \" - \",\r\n force_edges: true\r\n \r\n\r\n});\r\n\r\ninstance = $range.data(\"ionRangeSlider\");\r\n\r\nfunction updateInputs (data) {\r\n from = data.from;\r\n to = data.to;\r\n \r\n $inputFrom.prop(\"value\", from);\r\n $inputTo.prop(\"value\", to); \r\n}\r\n\r\n$inputFrom.on(\"input\", function () {\r\n var val = $(this).prop(\"value\");\r\n \r\n // validate\r\n if (val < min) {\r\n val = min;\r\n } else if (val > to) {\r\n val = to;\r\n }\r\n \r\n instance.update({\r\n from: val\r\n });\r\n});\r\n\r\n$inputTo.on(\"input\", function () {\r\n var val = $(this).prop(\"value\");\r\n \r\n // validate\r\n if (val < from) {\r\n val = from;\r\n } else if (val > max) {\r\n val = max;\r\n }\r\n \r\n instance.update({\r\n to: val\r\n });\r\n});\r\n\r\n });";
var mod_pagespeed_r$0zAtSkZg = "$(document).ready(function(){\r\n \r\n (function($) {\r\n \"use strict\";\r\n\r\n \r\n jQuery.validator.addMethod('answercheck', function (value, element) {\r\n return this.optional(element) || /^\\bcat\\b$/.test(value)\r\n }, \"type the correct answer -_-\");\r\n\r\n // validate contactForm form\r\n $(function() {\r\n $('#contactForm').validate({\r\n rules: {\r\n name: {\r\n required: true,\r\n minlength: 2\r\n },\r\n subject: {\r\n required: true,\r\n minlength: 4\r\n },\r\n number: {\r\n required: true,\r\n minlength: 5\r\n },\r\n email: {\r\n required: true,\r\n email: true\r\n },\r\n message: {\r\n required: true,\r\n minlength: 20\r\n }\r\n },\r\n messages: {\r\n name: {\r\n required: \"come on, you have a name, don't you?\",\r\n minlength: \"your name must consist of at least 2 characters\"\r\n },\r\n subject: {\r\n required: \"come on, you have a subject, don't you?\",\r\n minlength: \"your subject must consist of at least 4 characters\"\r\n },\r\n number: {\r\n required: \"come on, you have a number, don't you?\",\r\n minlength: \"your Number must consist of at least 5 characters\"\r\n },\r\n email: {\r\n required: \"no email, no message\"\r\n },\r\n message: {\r\n required: \"um...yea, you have to write something to send this form.\",\r\n minlength: \"thats all? really?\"\r\n }\r\n },\r\n submitHandler: function(form) {\r\n $(form).ajaxSubmit({\r\n type:\"POST\",\r\n data: $(form).serialize(),\r\n url:\"contact_process.php\",\r\n success: function() {\r\n $('#contactForm :input').attr('disabled', 'disabled');\r\n $('#contactForm').fadeTo( \"slow\", 1, function() {\r\n $(this).find(':input').attr('disabled', 'disabled');\r\n $(this).find('label').css('cursor','default');\r\n $('#success').fadeIn()\r\n $('.modal').modal('hide');\r\n $('#success').modal('show');\r\n })\r\n },\r\n error: function() {\r\n $('#contactForm').fadeTo( \"slow\", 1, function() {\r\n $('#error').fadeIn()\r\n $('.modal').modal('hide');\r\n $('#error').modal('show');\r\n })\r\n }\r\n })\r\n }\r\n })\r\n })\r\n \r\n })(jQuery)\r\n})";