ion.rangeSlider.min.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  1. // Ion.RangeSlider | version 2.0.6 | https://github.com/IonDen/ion.rangeSlider
  2. (function (g, q, h, r, u) {
  3. var t = 0,
  4. n = (function () {
  5. var a = r.userAgent,
  6. b = /msie\s\d+/i;
  7. return 0 < a.search(b) &&
  8. ((a = b.exec(a).toString()), (a = a.split(" ")[1]), 9 > a)
  9. ? (g("html").addClass("lt-ie9"), !0)
  10. : !1;
  11. })();
  12. Function.prototype.bind ||
  13. (Function.prototype.bind = function (a) {
  14. var b = this,
  15. c = [].slice;
  16. if ("function" != typeof b) throw new TypeError();
  17. var d = c.call(arguments, 1),
  18. e = function () {
  19. if (this instanceof e) {
  20. var f = function () {};
  21. f.prototype = b.prototype;
  22. var f = new f(),
  23. k = b.apply(f, d.concat(c.call(arguments)));
  24. return Object(k) === k ? k : f;
  25. }
  26. return b.apply(a, d.concat(c.call(arguments)));
  27. };
  28. return e;
  29. });
  30. Array.prototype.indexOf ||
  31. (Array.prototype.indexOf = function (a, b) {
  32. var c;
  33. if (null == this) throw new TypeError('"this" is null or not defined');
  34. var d = Object(this),
  35. e = d.length >>> 0;
  36. if (0 === e) return -1;
  37. c = +b || 0;
  38. Infinity === Math.abs(c) && (c = 0);
  39. if (c >= e) return -1;
  40. for (c = Math.max(0 <= c ? c : e - Math.abs(c), 0); c < e; ) {
  41. if (c in d && d[c] === a) return c;
  42. c++;
  43. }
  44. return -1;
  45. });
  46. var p = function (a, b, c) {
  47. this.VERSION = "2.0.6";
  48. this.input = a;
  49. this.plugin_count = c;
  50. this.old_to = this.old_from = this.calc_count = this.current_plugin = 0;
  51. this.raf_id = null;
  52. this.is_update = this.is_key = this.force_redraw = this.dragging = !1;
  53. this.is_start = !0;
  54. this.is_click = this.is_resize = this.is_active = !1;
  55. this.$cache = {
  56. win: g(h),
  57. body: g(q.body),
  58. input: g(a),
  59. cont: null,
  60. rs: null,
  61. min: null,
  62. max: null,
  63. from: null,
  64. to: null,
  65. single: null,
  66. bar: null,
  67. line: null,
  68. s_single: null,
  69. s_from: null,
  70. s_to: null,
  71. shad_single: null,
  72. shad_from: null,
  73. shad_to: null,
  74. grid: null,
  75. grid_labels: [],
  76. };
  77. c = this.$cache.input;
  78. a = {
  79. type: c.data("type"),
  80. min: c.data("min"),
  81. max: c.data("max"),
  82. from: c.data("from"),
  83. to: c.data("to"),
  84. step: c.data("step"),
  85. min_interval: c.data("minInterval"),
  86. max_interval: c.data("maxInterval"),
  87. drag_interval: c.data("dragInterval"),
  88. values: c.data("values"),
  89. from_fixed: c.data("fromFixed"),
  90. from_min: c.data("fromMin"),
  91. from_max: c.data("fromMax"),
  92. from_shadow: c.data("fromShadow"),
  93. to_fixed: c.data("toFixed"),
  94. to_min: c.data("toMin"),
  95. to_max: c.data("toMax"),
  96. to_shadow: c.data("toShadow"),
  97. prettify_enabled: c.data("prettifyEnabled"),
  98. prettify_separator: c.data("prettifySeparator"),
  99. force_edges: c.data("forceEdges"),
  100. keyboard: c.data("keyboard"),
  101. keyboard_step: c.data("keyboardStep"),
  102. grid: c.data("grid"),
  103. grid_margin: c.data("gridMargin"),
  104. grid_num: c.data("gridNum"),
  105. grid_snap: c.data("gridSnap"),
  106. hide_min_max: c.data("hideMinMax"),
  107. hide_from_to: c.data("hideFromTo"),
  108. prefix: c.data("prefix"),
  109. postfix: c.data("postfix"),
  110. max_postfix: c.data("maxPostfix"),
  111. decorate_both: c.data("decorateBoth"),
  112. values_separator: c.data("valuesSeparator"),
  113. disable: c.data("disable"),
  114. };
  115. a.values = a.values && a.values.split(",");
  116. b = g.extend(a, b);
  117. if ((c = c.prop("value")))
  118. (c = c.split(";")),
  119. c[0] && c[0] == +c[0] && (c[0] = +c[0]),
  120. c[1] && c[1] == +c[1] && (c[1] = +c[1]),
  121. b.values && b.values.length
  122. ? ((a.from = c[0] && b.values.indexOf(c[0])),
  123. (a.to = c[1] && b.values.indexOf(c[1])))
  124. : ((a.from = c[0] && +c[0]), (a.to = c[1] && +c[1]));
  125. this.options = g.extend(
  126. {
  127. type: "single",
  128. min: 10,
  129. max: 100,
  130. from: null,
  131. to: null,
  132. step: 1,
  133. min_interval: 0,
  134. max_interval: 0,
  135. drag_interval: !1,
  136. values: [],
  137. p_values: [],
  138. from_fixed: !1,
  139. from_min: null,
  140. from_max: null,
  141. from_shadow: !1,
  142. to_fixed: !1,
  143. to_min: null,
  144. to_max: null,
  145. to_shadow: !1,
  146. prettify_enabled: !0,
  147. prettify_separator: " ",
  148. prettify: null,
  149. force_edges: !1,
  150. keyboard: !1,
  151. keyboard_step: 5,
  152. grid: !1,
  153. grid_margin: !0,
  154. grid_num: 4,
  155. grid_snap: !1,
  156. hide_min_max: !1,
  157. hide_from_to: !1,
  158. prefix: "",
  159. postfix: "",
  160. max_postfix: "",
  161. decorate_both: !0,
  162. values_separator: " \u2014 ",
  163. disable: !1,
  164. onStart: null,
  165. onChange: null,
  166. onFinish: null,
  167. onUpdate: null,
  168. },
  169. b
  170. );
  171. this.validate();
  172. this.result = {
  173. input: this.$cache.input,
  174. slider: null,
  175. min: this.options.min,
  176. max: this.options.max,
  177. from: this.options.from,
  178. from_percent: 0,
  179. from_value: null,
  180. to: this.options.to,
  181. to_percent: 0,
  182. to_value: null,
  183. };
  184. this.coords = {
  185. x_gap: 0,
  186. x_pointer: 0,
  187. w_rs: 0,
  188. w_rs_old: 0,
  189. w_handle: 0,
  190. p_gap: 0,
  191. p_gap_left: 0,
  192. p_gap_right: 0,
  193. p_step: 0,
  194. p_pointer: 0,
  195. p_handle: 0,
  196. p_single: 0,
  197. p_single_real: 0,
  198. p_from: 0,
  199. p_from_real: 0,
  200. p_to: 0,
  201. p_to_real: 0,
  202. p_bar_x: 0,
  203. p_bar_w: 0,
  204. grid_gap: 0,
  205. big_num: 0,
  206. big: [],
  207. big_w: [],
  208. big_p: [],
  209. big_x: [],
  210. };
  211. this.labels = {
  212. w_min: 0,
  213. w_max: 0,
  214. w_from: 0,
  215. w_to: 0,
  216. w_single: 0,
  217. p_min: 0,
  218. p_max: 0,
  219. p_from: 0,
  220. p_from_left: 0,
  221. p_to: 0,
  222. p_to_left: 0,
  223. p_single: 0,
  224. p_single_left: 0,
  225. };
  226. this.init();
  227. };
  228. p.prototype = {
  229. init: function (a) {
  230. this.coords.p_step =
  231. this.options.step / ((this.options.max - this.options.min) / 100);
  232. this.target = "base";
  233. this.toggleInput();
  234. this.append();
  235. this.setMinMax();
  236. if (a) {
  237. if (
  238. ((this.force_redraw = !0),
  239. this.calc(!0),
  240. this.options.onUpdate && "function" === typeof this.options.onUpdate)
  241. )
  242. this.options.onUpdate(this.result);
  243. } else if (
  244. ((this.force_redraw = !0),
  245. this.calc(!0),
  246. this.options.onStart && "function" === typeof this.options.onStart)
  247. )
  248. this.options.onStart(this.result);
  249. this.updateScene();
  250. this.raf_id = requestAnimationFrame(this.updateScene.bind(this));
  251. },
  252. append: function () {
  253. this.$cache.input.before(
  254. '<span class="irs js-irs-' + this.plugin_count + '"></span>'
  255. );
  256. this.$cache.input.prop("readonly", !0);
  257. this.$cache.cont = this.$cache.input.prev();
  258. this.result.slider = this.$cache.cont;
  259. this.$cache.cont.html(
  260. '<span class="irs"><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><span class="irs-min">0</span><span class="irs-max">1</span><span class="irs-from">0</span><span class="irs-to">0</span><span class="irs-single">0</span></span><span class="irs-grid"></span><span class="irs-bar"></span>'
  261. );
  262. this.$cache.rs = this.$cache.cont.find(".irs");
  263. this.$cache.min = this.$cache.cont.find(".irs-min");
  264. this.$cache.max = this.$cache.cont.find(".irs-max");
  265. this.$cache.from = this.$cache.cont.find(".irs-from");
  266. this.$cache.to = this.$cache.cont.find(".irs-to");
  267. this.$cache.single = this.$cache.cont.find(".irs-single");
  268. this.$cache.bar = this.$cache.cont.find(".irs-bar");
  269. this.$cache.line = this.$cache.cont.find(".irs-line");
  270. this.$cache.grid = this.$cache.cont.find(".irs-grid");
  271. "single" === this.options.type
  272. ? (this.$cache.cont.append(
  273. '<span class="irs-bar-edge"></span><span class="irs-shadow shadow-single"></span><span class="irs-slider single"></span>'
  274. ),
  275. (this.$cache.s_single = this.$cache.cont.find(".single")),
  276. (this.$cache.from[0].style.visibility = "hidden"),
  277. (this.$cache.to[0].style.visibility = "hidden"),
  278. (this.$cache.shad_single = this.$cache.cont.find(".shadow-single")))
  279. : (this.$cache.cont.append(
  280. '<span class="irs-shadow shadow-from"></span><span class="irs-shadow shadow-to"></span><span class="irs-slider from"></span><span class="irs-slider to"></span>'
  281. ),
  282. (this.$cache.s_from = this.$cache.cont.find(".from")),
  283. (this.$cache.s_to = this.$cache.cont.find(".to")),
  284. (this.$cache.shad_from = this.$cache.cont.find(".shadow-from")),
  285. (this.$cache.shad_to = this.$cache.cont.find(".shadow-to")));
  286. this.options.hide_from_to &&
  287. ((this.$cache.from[0].style.display = "none"),
  288. (this.$cache.to[0].style.display = "none"),
  289. (this.$cache.single[0].style.display = "none"));
  290. this.appendGrid();
  291. this.options.disable
  292. ? (this.appendDisableMask(), (this.$cache.input[0].disabled = !0))
  293. : (this.$cache.cont.removeClass("irs-disabled"),
  294. (this.$cache.input[0].disabled = !1),
  295. this.bindEvents());
  296. },
  297. appendDisableMask: function () {
  298. this.$cache.cont.append('<span class="irs-disable-mask"></span>');
  299. this.$cache.cont.addClass("irs-disabled");
  300. },
  301. remove: function () {
  302. this.$cache.cont.remove();
  303. this.$cache.cont = null;
  304. this.$cache.line.off("keydown.irs_" + this.plugin_count);
  305. this.$cache.body.off("touchmove.irs_" + this.plugin_count);
  306. this.$cache.body.off("mousemove.irs_" + this.plugin_count);
  307. this.$cache.win.off("touchend.irs_" + this.plugin_count);
  308. this.$cache.win.off("mouseup.irs_" + this.plugin_count);
  309. n &&
  310. (this.$cache.body.off("mouseup.irs_" + this.plugin_count),
  311. this.$cache.body.off("mouseleave.irs_" + this.plugin_count));
  312. this.$cache.grid_labels = [];
  313. this.coords.big = [];
  314. this.coords.big_w = [];
  315. this.coords.big_p = [];
  316. this.coords.big_x = [];
  317. cancelAnimationFrame(this.raf_id);
  318. },
  319. bindEvents: function () {
  320. this.$cache.body.on(
  321. "touchmove.irs_" + this.plugin_count,
  322. this.pointerMove.bind(this)
  323. );
  324. this.$cache.body.on(
  325. "mousemove.irs_" + this.plugin_count,
  326. this.pointerMove.bind(this)
  327. );
  328. this.$cache.win.on(
  329. "touchend.irs_" + this.plugin_count,
  330. this.pointerUp.bind(this)
  331. );
  332. this.$cache.win.on(
  333. "mouseup.irs_" + this.plugin_count,
  334. this.pointerUp.bind(this)
  335. );
  336. this.$cache.line.on(
  337. "touchstart.irs_" + this.plugin_count,
  338. this.pointerClick.bind(this, "click")
  339. );
  340. this.$cache.line.on(
  341. "mousedown.irs_" + this.plugin_count,
  342. this.pointerClick.bind(this, "click")
  343. );
  344. this.options.drag_interval && "double" === this.options.type
  345. ? (this.$cache.bar.on(
  346. "touchstart.irs_" + this.plugin_count,
  347. this.pointerDown.bind(this, "both")
  348. ),
  349. this.$cache.bar.on(
  350. "mousedown.irs_" + this.plugin_count,
  351. this.pointerDown.bind(this, "both")
  352. ))
  353. : (this.$cache.bar.on(
  354. "touchstart.irs_" + this.plugin_count,
  355. this.pointerClick.bind(this, "click")
  356. ),
  357. this.$cache.bar.on(
  358. "mousedown.irs_" + this.plugin_count,
  359. this.pointerClick.bind(this, "click")
  360. ));
  361. "single" === this.options.type
  362. ? (this.$cache.s_single.on(
  363. "touchstart.irs_" + this.plugin_count,
  364. this.pointerDown.bind(this, "single")
  365. ),
  366. this.$cache.shad_single.on(
  367. "touchstart.irs_" + this.plugin_count,
  368. this.pointerClick.bind(this, "click")
  369. ),
  370. this.$cache.s_single.on(
  371. "mousedown.irs_" + this.plugin_count,
  372. this.pointerDown.bind(this, "single")
  373. ),
  374. this.$cache.shad_single.on(
  375. "mousedown.irs_" + this.plugin_count,
  376. this.pointerClick.bind(this, "click")
  377. ))
  378. : (this.$cache.s_from.on(
  379. "touchstart.irs_" + this.plugin_count,
  380. this.pointerDown.bind(this, "from")
  381. ),
  382. this.$cache.s_to.on(
  383. "touchstart.irs_" + this.plugin_count,
  384. this.pointerDown.bind(this, "to")
  385. ),
  386. this.$cache.shad_from.on(
  387. "touchstart.irs_" + this.plugin_count,
  388. this.pointerClick.bind(this, "click")
  389. ),
  390. this.$cache.shad_to.on(
  391. "touchstart.irs_" + this.plugin_count,
  392. this.pointerClick.bind(this, "click")
  393. ),
  394. this.$cache.s_from.on(
  395. "mousedown.irs_" + this.plugin_count,
  396. this.pointerDown.bind(this, "from")
  397. ),
  398. this.$cache.s_to.on(
  399. "mousedown.irs_" + this.plugin_count,
  400. this.pointerDown.bind(this, "to")
  401. ),
  402. this.$cache.shad_from.on(
  403. "mousedown.irs_" + this.plugin_count,
  404. this.pointerClick.bind(this, "click")
  405. ),
  406. this.$cache.shad_to.on(
  407. "mousedown.irs_" + this.plugin_count,
  408. this.pointerClick.bind(this, "click")
  409. ));
  410. if (this.options.keyboard)
  411. this.$cache.line.on(
  412. "keydown.irs_" + this.plugin_count,
  413. this.key.bind(this, "keyboard")
  414. );
  415. n &&
  416. (this.$cache.body.on(
  417. "mouseup.irs_" + this.plugin_count,
  418. this.pointerUp.bind(this)
  419. ),
  420. this.$cache.body.on(
  421. "mouseleave.irs_" + this.plugin_count,
  422. this.pointerUp.bind(this)
  423. ));
  424. },
  425. pointerMove: function (a) {
  426. this.dragging &&
  427. ((this.coords.x_pointer =
  428. (a.pageX ||
  429. (a.originalEvent.touches && a.originalEvent.touches[0].pageX)) -
  430. this.coords.x_gap),
  431. this.calc());
  432. },
  433. pointerUp: function (a) {
  434. if (this.current_plugin === this.plugin_count && this.is_active) {
  435. this.is_active = !1;
  436. var b =
  437. this.options.onFinish && "function" === typeof this.options.onFinish;
  438. a = g.contains(this.$cache.cont[0], a.target) || this.dragging;
  439. if (b && a) this.options.onFinish(this.result);
  440. this.$cache.cont.find(".state_hover").removeClass("state_hover");
  441. this.force_redraw = !0;
  442. this.dragging = !1;
  443. n && g("*").prop("unselectable", !1);
  444. }
  445. },
  446. pointerDown: function (a, b) {
  447. b.preventDefault();
  448. var c =
  449. b.pageX ||
  450. (b.originalEvent.touches && b.originalEvent.touches[0].pageX);
  451. if (2 !== b.button) {
  452. this.current_plugin = this.plugin_count;
  453. this.target = a;
  454. this.dragging = this.is_active = !0;
  455. this.coords.x_gap = this.$cache.rs.offset().left;
  456. this.coords.x_pointer = c - this.coords.x_gap;
  457. this.calcPointer();
  458. switch (a) {
  459. case "single":
  460. this.coords.p_gap = this.toFixed(
  461. this.coords.p_pointer - this.coords.p_single
  462. );
  463. break;
  464. case "from":
  465. this.coords.p_gap = this.toFixed(
  466. this.coords.p_pointer - this.coords.p_from
  467. );
  468. this.$cache.s_from.addClass("state_hover");
  469. this.$cache.s_from.addClass("type_last");
  470. this.$cache.s_to.removeClass("type_last");
  471. break;
  472. case "to":
  473. this.coords.p_gap = this.toFixed(
  474. this.coords.p_pointer - this.coords.p_to
  475. );
  476. this.$cache.s_to.addClass("state_hover");
  477. this.$cache.s_to.addClass("type_last");
  478. this.$cache.s_from.removeClass("type_last");
  479. break;
  480. case "both":
  481. (this.coords.p_gap_left = this.toFixed(
  482. this.coords.p_pointer - this.coords.p_from
  483. )),
  484. (this.coords.p_gap_right = this.toFixed(
  485. this.coords.p_to - this.coords.p_pointer
  486. )),
  487. this.$cache.s_to.removeClass("type_last"),
  488. this.$cache.s_from.removeClass("type_last");
  489. }
  490. n && g("*").prop("unselectable", !0);
  491. this.$cache.line.trigger("focus");
  492. }
  493. },
  494. pointerClick: function (a, b) {
  495. b.preventDefault();
  496. var c =
  497. b.pageX ||
  498. (b.originalEvent.touches && b.originalEvent.touches[0].pageX);
  499. 2 !== b.button &&
  500. ((this.current_plugin = this.plugin_count),
  501. (this.target = a),
  502. (this.is_click = !0),
  503. (this.coords.x_gap = this.$cache.rs.offset().left),
  504. (this.coords.x_pointer = +(c - this.coords.x_gap).toFixed()),
  505. (this.force_redraw = !0),
  506. this.calc(),
  507. this.$cache.line.trigger("focus"));
  508. },
  509. key: function (a, b) {
  510. if (
  511. !(
  512. this.current_plugin !== this.plugin_count ||
  513. b.altKey ||
  514. b.ctrlKey ||
  515. b.shiftKey ||
  516. b.metaKey
  517. )
  518. ) {
  519. switch (b.which) {
  520. case 83:
  521. case 65:
  522. case 40:
  523. case 37:
  524. b.preventDefault();
  525. this.moveByKey(!1);
  526. break;
  527. case 87:
  528. case 68:
  529. case 38:
  530. case 39:
  531. b.preventDefault(), this.moveByKey(!0);
  532. }
  533. return !0;
  534. }
  535. },
  536. moveByKey: function (a) {
  537. var b = this.coords.p_pointer,
  538. b = a ? b + this.options.keyboard_step : b - this.options.keyboard_step;
  539. this.coords.x_pointer = this.toFixed((this.coords.w_rs / 100) * b);
  540. this.is_key = !0;
  541. this.calc();
  542. },
  543. setMinMax: function () {
  544. this.options &&
  545. (this.options.hide_min_max
  546. ? ((this.$cache.min[0].style.display = "none"),
  547. (this.$cache.max[0].style.display = "none"))
  548. : (this.options.values.length
  549. ? (this.$cache.min.html(
  550. this.decorate(this.options.p_values[this.options.min])
  551. ),
  552. this.$cache.max.html(
  553. this.decorate(this.options.p_values[this.options.max])
  554. ))
  555. : (this.$cache.min.html(
  556. this.decorate(
  557. this._prettify(this.options.min),
  558. this.options.min
  559. )
  560. ),
  561. this.$cache.max.html(
  562. this.decorate(
  563. this._prettify(this.options.max),
  564. this.options.max
  565. )
  566. )),
  567. (this.labels.w_min = this.$cache.min.outerWidth(!1)),
  568. (this.labels.w_max = this.$cache.max.outerWidth(!1))));
  569. },
  570. calc: function (a) {
  571. if (this.options) {
  572. this.calc_count++;
  573. if (10 === this.calc_count || a)
  574. (this.calc_count = 0),
  575. (this.coords.w_rs = this.$cache.rs.outerWidth(!1)),
  576. (this.coords.w_handle =
  577. "single" === this.options.type
  578. ? this.$cache.s_single.outerWidth(!1)
  579. : this.$cache.s_from.outerWidth(!1));
  580. if (this.coords.w_rs) {
  581. this.calcPointer();
  582. this.coords.p_handle = this.toFixed(
  583. (this.coords.w_handle / this.coords.w_rs) * 100
  584. );
  585. a = 100 - this.coords.p_handle;
  586. var b = this.toFixed(this.coords.p_pointer - this.coords.p_gap);
  587. "click" === this.target &&
  588. ((b = this.toFixed(
  589. this.coords.p_pointer - this.coords.p_handle / 2
  590. )),
  591. (this.target = this.chooseHandle(b)));
  592. 0 > b ? (b = 0) : b > a && (b = a);
  593. switch (this.target) {
  594. case "base":
  595. b = (this.options.max - this.options.min) / 100;
  596. a = (this.result.from - this.options.min) / b;
  597. b = (this.result.to - this.options.min) / b;
  598. this.coords.p_single_real = this.toFixed(a);
  599. this.coords.p_from_real = this.toFixed(a);
  600. this.coords.p_to_real = this.toFixed(b);
  601. this.coords.p_single_real = this.checkDiapason(
  602. this.coords.p_single_real,
  603. this.options.from_min,
  604. this.options.from_max
  605. );
  606. this.coords.p_from_real = this.checkDiapason(
  607. this.coords.p_from_real,
  608. this.options.from_min,
  609. this.options.from_max
  610. );
  611. this.coords.p_to_real = this.checkDiapason(
  612. this.coords.p_to_real,
  613. this.options.to_min,
  614. this.options.to_max
  615. );
  616. this.coords.p_single = this.toFixed(
  617. a - (this.coords.p_handle / 100) * a
  618. );
  619. this.coords.p_from = this.toFixed(
  620. a - (this.coords.p_handle / 100) * a
  621. );
  622. this.coords.p_to = this.toFixed(
  623. b - (this.coords.p_handle / 100) * b
  624. );
  625. this.target = null;
  626. break;
  627. case "single":
  628. if (this.options.from_fixed) break;
  629. this.coords.p_single_real = this.calcWithStep((b / a) * 100);
  630. this.coords.p_single_real = this.checkDiapason(
  631. this.coords.p_single_real,
  632. this.options.from_min,
  633. this.options.from_max
  634. );
  635. this.coords.p_single = this.toFixed(
  636. (this.coords.p_single_real / 100) * a
  637. );
  638. break;
  639. case "from":
  640. if (this.options.from_fixed) break;
  641. this.coords.p_from_real = this.calcWithStep((b / a) * 100);
  642. this.coords.p_from_real > this.coords.p_to_real &&
  643. (this.coords.p_from_real = this.coords.p_to_real);
  644. this.coords.p_from_real = this.checkDiapason(
  645. this.coords.p_from_real,
  646. this.options.from_min,
  647. this.options.from_max
  648. );
  649. this.coords.p_from_real = this.checkMinInterval(
  650. this.coords.p_from_real,
  651. this.coords.p_to_real,
  652. "from"
  653. );
  654. this.coords.p_from_real = this.checkMaxInterval(
  655. this.coords.p_from_real,
  656. this.coords.p_to_real,
  657. "from"
  658. );
  659. this.coords.p_from = this.toFixed(
  660. (this.coords.p_from_real / 100) * a
  661. );
  662. break;
  663. case "to":
  664. if (this.options.to_fixed) break;
  665. this.coords.p_to_real = this.calcWithStep((b / a) * 100);
  666. this.coords.p_to_real < this.coords.p_from_real &&
  667. (this.coords.p_to_real = this.coords.p_from_real);
  668. this.coords.p_to_real = this.checkDiapason(
  669. this.coords.p_to_real,
  670. this.options.to_min,
  671. this.options.to_max
  672. );
  673. this.coords.p_to_real = this.checkMinInterval(
  674. this.coords.p_to_real,
  675. this.coords.p_from_real,
  676. "to"
  677. );
  678. this.coords.p_to_real = this.checkMaxInterval(
  679. this.coords.p_to_real,
  680. this.coords.p_from_real,
  681. "to"
  682. );
  683. this.coords.p_to = this.toFixed(
  684. (this.coords.p_to_real / 100) * a
  685. );
  686. break;
  687. case "both":
  688. (b = this.toFixed(b + 0.1 * this.coords.p_handle)),
  689. (this.coords.p_from_real = this.calcWithStep(
  690. ((b - this.coords.p_gap_left) / a) * 100
  691. )),
  692. (this.coords.p_from_real = this.checkDiapason(
  693. this.coords.p_from_real,
  694. this.options.from_min,
  695. this.options.from_max
  696. )),
  697. (this.coords.p_from_real = this.checkMinInterval(
  698. this.coords.p_from_real,
  699. this.coords.p_to_real,
  700. "from"
  701. )),
  702. (this.coords.p_from = this.toFixed(
  703. (this.coords.p_from_real / 100) * a
  704. )),
  705. (this.coords.p_to_real = this.calcWithStep(
  706. ((b + this.coords.p_gap_right) / a) * 100
  707. )),
  708. (this.coords.p_to_real = this.checkDiapason(
  709. this.coords.p_to_real,
  710. this.options.to_min,
  711. this.options.to_max
  712. )),
  713. (this.coords.p_to_real = this.checkMinInterval(
  714. this.coords.p_to_real,
  715. this.coords.p_from_real,
  716. "to"
  717. )),
  718. (this.coords.p_to = this.toFixed(
  719. (this.coords.p_to_real / 100) * a
  720. ));
  721. }
  722. "single" === this.options.type
  723. ? ((this.coords.p_bar_x = this.coords.p_handle / 2),
  724. (this.coords.p_bar_w = this.coords.p_single),
  725. (this.result.from_percent = this.coords.p_single_real),
  726. (this.result.from = this.calcReal(this.coords.p_single_real)),
  727. this.options.values.length &&
  728. (this.result.from_value =
  729. this.options.values[this.result.from]))
  730. : ((this.coords.p_bar_x = this.toFixed(
  731. this.coords.p_from + this.coords.p_handle / 2
  732. )),
  733. (this.coords.p_bar_w = this.toFixed(
  734. this.coords.p_to - this.coords.p_from
  735. )),
  736. (this.result.from_percent = this.coords.p_from_real),
  737. (this.result.from = this.calcReal(this.coords.p_from_real)),
  738. (this.result.to_percent = this.coords.p_to_real),
  739. (this.result.to = this.calcReal(this.coords.p_to_real)),
  740. this.options.values.length &&
  741. ((this.result.from_value =
  742. this.options.values[this.result.from]),
  743. (this.result.to_value = this.options.values[this.result.to])));
  744. this.calcMinMax();
  745. this.calcLabels();
  746. }
  747. }
  748. },
  749. calcPointer: function () {
  750. this.coords.w_rs
  751. ? (0 > this.coords.x_pointer || isNaN(this.coords.x_pointer)
  752. ? (this.coords.x_pointer = 0)
  753. : this.coords.x_pointer > this.coords.w_rs &&
  754. (this.coords.x_pointer = this.coords.w_rs),
  755. (this.coords.p_pointer = this.toFixed(
  756. (this.coords.x_pointer / this.coords.w_rs) * 100
  757. )))
  758. : (this.coords.p_pointer = 0);
  759. },
  760. chooseHandle: function (a) {
  761. return "single" === this.options.type
  762. ? "single"
  763. : a >=
  764. this.coords.p_from_real +
  765. (this.coords.p_to_real - this.coords.p_from_real) / 2
  766. ? "to"
  767. : "from";
  768. },
  769. calcMinMax: function () {
  770. this.coords.w_rs &&
  771. ((this.labels.p_min = (this.labels.w_min / this.coords.w_rs) * 100),
  772. (this.labels.p_max = (this.labels.w_max / this.coords.w_rs) * 100));
  773. },
  774. calcLabels: function () {
  775. this.coords.w_rs &&
  776. !this.options.hide_from_to &&
  777. ("single" === this.options.type
  778. ? ((this.labels.w_single = this.$cache.single.outerWidth(!1)),
  779. (this.labels.p_single =
  780. (this.labels.w_single / this.coords.w_rs) * 100),
  781. (this.labels.p_single_left =
  782. this.coords.p_single +
  783. this.coords.p_handle / 2 -
  784. this.labels.p_single / 2))
  785. : ((this.labels.w_from = this.$cache.from.outerWidth(!1)),
  786. (this.labels.p_from =
  787. (this.labels.w_from / this.coords.w_rs) * 100),
  788. (this.labels.p_from_left =
  789. this.coords.p_from +
  790. this.coords.p_handle / 2 -
  791. this.labels.p_from / 2),
  792. (this.labels.p_from_left = this.toFixed(this.labels.p_from_left)),
  793. (this.labels.p_from_left = this.checkEdges(
  794. this.labels.p_from_left,
  795. this.labels.p_from
  796. )),
  797. (this.labels.w_to = this.$cache.to.outerWidth(!1)),
  798. (this.labels.p_to = (this.labels.w_to / this.coords.w_rs) * 100),
  799. (this.labels.p_to_left =
  800. this.coords.p_to +
  801. this.coords.p_handle / 2 -
  802. this.labels.p_to / 2),
  803. (this.labels.p_to_left = this.toFixed(this.labels.p_to_left)),
  804. (this.labels.p_to_left = this.checkEdges(
  805. this.labels.p_to_left,
  806. this.labels.p_to
  807. )),
  808. (this.labels.w_single = this.$cache.single.outerWidth(!1)),
  809. (this.labels.p_single =
  810. (this.labels.w_single / this.coords.w_rs) * 100),
  811. (this.labels.p_single_left =
  812. (this.labels.p_from_left +
  813. this.labels.p_to_left +
  814. this.labels.p_to) /
  815. 2 -
  816. this.labels.p_single / 2),
  817. (this.labels.p_single_left = this.toFixed(
  818. this.labels.p_single_left
  819. ))),
  820. (this.labels.p_single_left = this.checkEdges(
  821. this.labels.p_single_left,
  822. this.labels.p_single
  823. )));
  824. },
  825. updateScene: function () {
  826. this.options &&
  827. (this.drawHandles(),
  828. (this.raf_id = requestAnimationFrame(this.updateScene.bind(this))));
  829. },
  830. drawHandles: function () {
  831. this.coords.w_rs = this.$cache.rs.outerWidth(!1);
  832. if (this.coords.w_rs) {
  833. this.coords.w_rs !== this.coords.w_rs_old &&
  834. ((this.target = "base"), (this.is_resize = !0));
  835. if (this.coords.w_rs !== this.coords.w_rs_old || this.force_redraw)
  836. this.setMinMax(),
  837. this.calc(!0),
  838. this.drawLabels(),
  839. this.options.grid && (this.calcGridMargin(), this.calcGridLabels()),
  840. (this.force_redraw = !0),
  841. (this.coords.w_rs_old = this.coords.w_rs),
  842. this.drawShadow();
  843. if (
  844. this.coords.w_rs &&
  845. (this.dragging || this.force_redraw || this.is_key)
  846. ) {
  847. if (
  848. this.old_from !== this.result.from ||
  849. this.old_to !== this.result.to ||
  850. this.force_redraw ||
  851. this.is_key
  852. ) {
  853. this.drawLabels();
  854. this.$cache.bar[0].style.left = this.coords.p_bar_x + "%";
  855. this.$cache.bar[0].style.width = this.coords.p_bar_w + "%";
  856. if ("single" === this.options.type)
  857. (this.$cache.s_single[0].style.left = this.coords.p_single + "%"),
  858. (this.$cache.single[0].style.left =
  859. this.labels.p_single_left + "%"),
  860. this.options.values.length
  861. ? (this.$cache.input.prop("value", this.result.from_value),
  862. this.$cache.input.data("from", this.result.from_value))
  863. : (this.$cache.input.prop("value", this.result.from),
  864. this.$cache.input.data("from", this.result.from));
  865. else {
  866. this.$cache.s_from[0].style.left = this.coords.p_from + "%";
  867. this.$cache.s_to[0].style.left = this.coords.p_to + "%";
  868. if (this.old_from !== this.result.from || this.force_redraw)
  869. this.$cache.from[0].style.left = this.labels.p_from_left + "%";
  870. if (this.old_to !== this.result.to || this.force_redraw)
  871. this.$cache.to[0].style.left = this.labels.p_to_left + "%";
  872. this.$cache.single[0].style.left =
  873. this.labels.p_single_left + "%";
  874. this.options.values.length
  875. ? (this.$cache.input.prop(
  876. "value",
  877. this.result.from_value + ";" + this.result.to_value
  878. ),
  879. this.$cache.input.data("from", this.result.from_value),
  880. this.$cache.input.data("to", this.result.to_value))
  881. : (this.$cache.input.prop(
  882. "value",
  883. this.result.from + ";" + this.result.to
  884. ),
  885. this.$cache.input.data("from", this.result.from),
  886. this.$cache.input.data("to", this.result.to));
  887. }
  888. (this.old_from === this.result.from &&
  889. this.old_to === this.result.to) ||
  890. this.is_start ||
  891. this.$cache.input.trigger("change");
  892. this.old_from = this.result.from;
  893. this.old_to = this.result.to;
  894. if (
  895. this.options.onChange &&
  896. "function" === typeof this.options.onChange &&
  897. !this.is_resize &&
  898. !this.is_update &&
  899. !this.is_start
  900. )
  901. this.options.onChange(this.result);
  902. if (
  903. this.options.onFinish &&
  904. "function" === typeof this.options.onFinish &&
  905. (this.is_key || this.is_click)
  906. )
  907. this.options.onFinish(this.result);
  908. this.is_resize = this.is_update = !1;
  909. }
  910. this.force_redraw = this.is_click = this.is_key = this.is_start = !1;
  911. }
  912. }
  913. },
  914. drawLabels: function () {
  915. if (this.options) {
  916. var a = this.options.values.length,
  917. b = this.options.p_values,
  918. c;
  919. if (!this.options.hide_from_to)
  920. if ("single" === this.options.type)
  921. (a = a
  922. ? this.decorate(b[this.result.from])
  923. : this.decorate(
  924. this._prettify(this.result.from),
  925. this.result.from
  926. )),
  927. this.$cache.single.html(a),
  928. this.calcLabels(),
  929. (this.$cache.min[0].style.visibility =
  930. this.labels.p_single_left < this.labels.p_min + 1
  931. ? "hidden"
  932. : "visible"),
  933. (this.$cache.max[0].style.visibility =
  934. this.labels.p_single_left + this.labels.p_single >
  935. 100 - this.labels.p_max - 1
  936. ? "hidden"
  937. : "visible");
  938. else {
  939. a
  940. ? (this.options.decorate_both
  941. ? ((a = this.decorate(b[this.result.from])),
  942. (a += this.options.values_separator),
  943. (a += this.decorate(b[this.result.to])))
  944. : (a = this.decorate(
  945. b[this.result.from] +
  946. this.options.values_separator +
  947. b[this.result.to]
  948. )),
  949. (c = this.decorate(b[this.result.from])),
  950. (b = this.decorate(b[this.result.to])))
  951. : (this.options.decorate_both
  952. ? ((a = this.decorate(this._prettify(this.result.from))),
  953. (a += this.options.values_separator),
  954. (a += this.decorate(this._prettify(this.result.to))))
  955. : (a = this.decorate(
  956. this._prettify(this.result.from) +
  957. this.options.values_separator +
  958. this._prettify(this.result.to),
  959. this.result.from
  960. )),
  961. (c = this.decorate(
  962. this._prettify(this.result.from),
  963. this.result.from
  964. )),
  965. (b = this.decorate(
  966. this._prettify(this.result.to),
  967. this.result.to
  968. )));
  969. this.$cache.single.html(a);
  970. this.$cache.from.html(c);
  971. this.$cache.to.html(b);
  972. this.calcLabels();
  973. b = Math.min(this.labels.p_single_left, this.labels.p_from_left);
  974. a = this.labels.p_single_left + this.labels.p_single;
  975. c = this.labels.p_to_left + this.labels.p_to;
  976. var d = Math.max(a, c);
  977. this.labels.p_from_left + this.labels.p_from >=
  978. this.labels.p_to_left
  979. ? ((this.$cache.from[0].style.visibility = "hidden"),
  980. (this.$cache.to[0].style.visibility = "hidden"),
  981. (this.$cache.single[0].style.visibility = "visible"),
  982. this.result.from === this.result.to
  983. ? ((this.$cache.from[0].style.visibility = "visible"),
  984. (this.$cache.single[0].style.visibility = "hidden"),
  985. (d = c))
  986. : ((this.$cache.from[0].style.visibility = "hidden"),
  987. (this.$cache.single[0].style.visibility = "visible"),
  988. (d = Math.max(a, c))))
  989. : ((this.$cache.from[0].style.visibility = "visible"),
  990. (this.$cache.to[0].style.visibility = "visible"),
  991. (this.$cache.single[0].style.visibility = "hidden"));
  992. this.$cache.min[0].style.visibility =
  993. b < this.labels.p_min + 1 ? "hidden" : "visible";
  994. this.$cache.max[0].style.visibility =
  995. d > 100 - this.labels.p_max - 1 ? "hidden" : "visible";
  996. }
  997. }
  998. },
  999. drawShadow: function () {
  1000. var a = this.options,
  1001. b = this.$cache,
  1002. c = "number" === typeof a.from_min && !isNaN(a.from_min),
  1003. d = "number" === typeof a.from_max && !isNaN(a.from_max),
  1004. e = "number" === typeof a.to_min && !isNaN(a.to_min),
  1005. f = "number" === typeof a.to_max && !isNaN(a.to_max);
  1006. "single" === a.type
  1007. ? a.from_shadow && (c || d)
  1008. ? ((c = this.calcPercent(a.from_min || a.min)),
  1009. (d = this.calcPercent(a.from_max || a.max) - c),
  1010. (c = this.toFixed(c - (this.coords.p_handle / 100) * c)),
  1011. (d = this.toFixed(d - (this.coords.p_handle / 100) * d)),
  1012. (c += this.coords.p_handle / 2),
  1013. (b.shad_single[0].style.display = "block"),
  1014. (b.shad_single[0].style.left = c + "%"),
  1015. (b.shad_single[0].style.width = d + "%"))
  1016. : (b.shad_single[0].style.display = "none")
  1017. : (a.from_shadow && (c || d)
  1018. ? ((c = this.calcPercent(a.from_min || a.min)),
  1019. (d = this.calcPercent(a.from_max || a.max) - c),
  1020. (c = this.toFixed(c - (this.coords.p_handle / 100) * c)),
  1021. (d = this.toFixed(d - (this.coords.p_handle / 100) * d)),
  1022. (c += this.coords.p_handle / 2),
  1023. (b.shad_from[0].style.display = "block"),
  1024. (b.shad_from[0].style.left = c + "%"),
  1025. (b.shad_from[0].style.width = d + "%"))
  1026. : (b.shad_from[0].style.display = "none"),
  1027. a.to_shadow && (e || f)
  1028. ? ((e = this.calcPercent(a.to_min || a.min)),
  1029. (a = this.calcPercent(a.to_max || a.max) - e),
  1030. (e = this.toFixed(e - (this.coords.p_handle / 100) * e)),
  1031. (a = this.toFixed(a - (this.coords.p_handle / 100) * a)),
  1032. (e += this.coords.p_handle / 2),
  1033. (b.shad_to[0].style.display = "block"),
  1034. (b.shad_to[0].style.left = e + "%"),
  1035. (b.shad_to[0].style.width = a + "%"))
  1036. : (b.shad_to[0].style.display = "none"));
  1037. },
  1038. toggleInput: function () {
  1039. this.$cache.input.toggleClass("irs-hidden-input");
  1040. },
  1041. calcPercent: function (a) {
  1042. return this.toFixed(
  1043. (a - this.options.min) / ((this.options.max - this.options.min) / 100)
  1044. );
  1045. },
  1046. calcReal: function (a) {
  1047. var b = this.options.min,
  1048. c = this.options.max,
  1049. d = 0;
  1050. 0 > b && ((d = Math.abs(b)), (b += d), (c += d));
  1051. a = ((c - b) / 100) * a + b;
  1052. (b = this.options.step.toString().split(".")[1])
  1053. ? (a = +a.toFixed(b.length))
  1054. : ((a /= this.options.step),
  1055. (a *= this.options.step),
  1056. (a = +a.toFixed(0)));
  1057. d && (a -= d);
  1058. a < this.options.min
  1059. ? (a = this.options.min)
  1060. : a > this.options.max && (a = this.options.max);
  1061. return b ? +a.toFixed(b.length) : this.toFixed(a);
  1062. },
  1063. calcWithStep: function (a) {
  1064. var b = Math.round(a / this.coords.p_step) * this.coords.p_step;
  1065. 100 < b && (b = 100);
  1066. 100 === a && (b = 100);
  1067. return this.toFixed(b);
  1068. },
  1069. checkMinInterval: function (a, b, c) {
  1070. var d = this.options;
  1071. if (!d.min_interval) return a;
  1072. a = this.calcReal(a);
  1073. b = this.calcReal(b);
  1074. "from" === c
  1075. ? b - a < d.min_interval && (a = b - d.min_interval)
  1076. : a - b < d.min_interval && (a = b + d.min_interval);
  1077. return this.calcPercent(a);
  1078. },
  1079. checkMaxInterval: function (a, b, c) {
  1080. var d = this.options;
  1081. if (!d.max_interval) return a;
  1082. a = this.calcReal(a);
  1083. b = this.calcReal(b);
  1084. "from" === c
  1085. ? b - a > d.max_interval && (a = b - d.max_interval)
  1086. : a - b > d.max_interval && (a = b + d.max_interval);
  1087. return this.calcPercent(a);
  1088. },
  1089. checkDiapason: function (a, b, c) {
  1090. a = this.calcReal(a);
  1091. var d = this.options;
  1092. (b && "number" === typeof b) || (b = d.min);
  1093. (c && "number" === typeof c) || (c = d.max);
  1094. a < b && (a = b);
  1095. a > c && (a = c);
  1096. return this.calcPercent(a);
  1097. },
  1098. toFixed: function (a) {
  1099. a = a.toFixed(5);
  1100. return +a;
  1101. },
  1102. _prettify: function (a) {
  1103. return this.options.prettify_enabled
  1104. ? this.options.prettify && "function" === typeof this.options.prettify
  1105. ? this.options.prettify(a)
  1106. : this.prettify(a)
  1107. : a;
  1108. },
  1109. prettify: function (a) {
  1110. return a
  1111. .toString()
  1112. .replace(
  1113. /(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g,
  1114. "$1" + this.options.prettify_separator
  1115. );
  1116. },
  1117. checkEdges: function (a, b) {
  1118. if (!this.options.force_edges) return this.toFixed(a);
  1119. 0 > a ? (a = 0) : a > 100 - b && (a = 100 - b);
  1120. return this.toFixed(a);
  1121. },
  1122. validate: function () {
  1123. var a = this.options,
  1124. b = this.result,
  1125. c = a.values,
  1126. d = c.length,
  1127. e,
  1128. f;
  1129. "string" === typeof a.min && (a.min = +a.min);
  1130. "string" === typeof a.max && (a.max = +a.max);
  1131. "string" === typeof a.from && (a.from = +a.from);
  1132. "string" === typeof a.to && (a.to = +a.to);
  1133. "string" === typeof a.step && (a.step = +a.step);
  1134. "string" === typeof a.from_min && (a.from_min = +a.from_min);
  1135. "string" === typeof a.from_max && (a.from_max = +a.from_max);
  1136. "string" === typeof a.to_min && (a.to_min = +a.to_min);
  1137. "string" === typeof a.to_max && (a.to_max = +a.to_max);
  1138. "string" === typeof a.keyboard_step &&
  1139. (a.keyboard_step = +a.keyboard_step);
  1140. "string" === typeof a.grid_num && (a.grid_num = +a.grid_num);
  1141. a.max <= a.min && ((a.max = a.min ? 2 * a.min : a.min + 1), (a.step = 1));
  1142. if (d)
  1143. for (
  1144. a.p_values = [],
  1145. a.min = 0,
  1146. a.max = d - 1,
  1147. a.step = 1,
  1148. a.grid_num = a.max,
  1149. a.grid_snap = !0,
  1150. f = 0;
  1151. f < d;
  1152. f++
  1153. )
  1154. (e = +c[f]),
  1155. isNaN(e) ? (e = c[f]) : ((c[f] = e), (e = this._prettify(e))),
  1156. a.p_values.push(e);
  1157. if ("number" !== typeof a.from || isNaN(a.from)) a.from = a.min;
  1158. if ("number" !== typeof a.to || isNaN(a.from)) a.to = a.max;
  1159. if (a.from < a.min || a.from > a.max) a.from = a.min;
  1160. if (a.to > a.max || a.to < a.min) a.to = a.max;
  1161. "double" === a.type && a.from > a.to && (a.from = a.to);
  1162. if ("number" !== typeof a.step || isNaN(a.step) || !a.step || 0 > a.step)
  1163. a.step = 1;
  1164. if (
  1165. "number" !== typeof a.keyboard_step ||
  1166. isNaN(a.keyboard_step) ||
  1167. !a.keyboard_step ||
  1168. 0 > a.keyboard_step
  1169. )
  1170. a.keyboard_step = 5;
  1171. a.from_min && a.from < a.from_min && (a.from = a.from_min);
  1172. a.from_max && a.from > a.from_max && (a.from = a.from_max);
  1173. a.to_min && a.to < a.to_min && (a.to = a.to_min);
  1174. a.to_max && a.from > a.to_max && (a.to = a.to_max);
  1175. if (b) {
  1176. b.min !== a.min && (b.min = a.min);
  1177. b.max !== a.max && (b.max = a.max);
  1178. if (b.from < b.min || b.from > b.max) b.from = a.from;
  1179. if (b.to < b.min || b.to > b.max) b.to = a.to;
  1180. }
  1181. if (
  1182. "number" !== typeof a.min_interval ||
  1183. isNaN(a.min_interval) ||
  1184. !a.min_interval ||
  1185. 0 > a.min_interval
  1186. )
  1187. a.min_interval = 0;
  1188. if (
  1189. "number" !== typeof a.max_interval ||
  1190. isNaN(a.max_interval) ||
  1191. !a.max_interval ||
  1192. 0 > a.max_interval
  1193. )
  1194. a.max_interval = 0;
  1195. a.min_interval &&
  1196. a.min_interval > a.max - a.min &&
  1197. (a.min_interval = a.max - a.min);
  1198. a.max_interval &&
  1199. a.max_interval > a.max - a.min &&
  1200. (a.max_interval = a.max - a.min);
  1201. },
  1202. decorate: function (a, b) {
  1203. var c = "",
  1204. d = this.options;
  1205. d.prefix && (c += d.prefix);
  1206. c += a;
  1207. d.max_postfix &&
  1208. (d.values.length && a === d.p_values[d.max]
  1209. ? ((c += d.max_postfix), d.postfix && (c += " "))
  1210. : b === d.max && ((c += d.max_postfix), d.postfix && (c += " ")));
  1211. d.postfix && (c += d.postfix);
  1212. return c;
  1213. },
  1214. updateFrom: function () {
  1215. this.result.from = this.options.from;
  1216. this.result.from_percent = this.calcPercent(this.result.from);
  1217. this.options.values &&
  1218. (this.result.from_value = this.options.values[this.result.from]);
  1219. },
  1220. updateTo: function () {
  1221. this.result.to = this.options.to;
  1222. this.result.to_percent = this.calcPercent(this.result.to);
  1223. this.options.values &&
  1224. (this.result.to_value = this.options.values[this.result.to]);
  1225. },
  1226. updateResult: function () {
  1227. this.result.min = this.options.min;
  1228. this.result.max = this.options.max;
  1229. this.updateFrom();
  1230. this.updateTo();
  1231. },
  1232. appendGrid: function () {
  1233. if (this.options.grid) {
  1234. var a = this.options,
  1235. b,
  1236. c;
  1237. b = a.max - a.min;
  1238. var d = a.grid_num,
  1239. e = 0,
  1240. f = 0,
  1241. k = 4,
  1242. g,
  1243. h,
  1244. l = 0,
  1245. m = "";
  1246. this.calcGridMargin();
  1247. a.grid_snap
  1248. ? ((d = b / a.step), (e = this.toFixed(a.step / (b / 100))))
  1249. : (e = this.toFixed(100 / d));
  1250. 4 < d && (k = 3);
  1251. 7 < d && (k = 2);
  1252. 14 < d && (k = 1);
  1253. 28 < d && (k = 0);
  1254. for (b = 0; b < d + 1; b++) {
  1255. g = k;
  1256. f = this.toFixed(e * b);
  1257. 100 < f && ((f = 100), (g -= 2), 0 > g && (g = 0));
  1258. this.coords.big[b] = f;
  1259. h = (f - e * (b - 1)) / (g + 1);
  1260. for (c = 1; c <= g && 0 !== f; c++)
  1261. (l = this.toFixed(f - h * c)),
  1262. (m +=
  1263. '<span class="irs-grid-pol small" style="left: ' +
  1264. l +
  1265. '%"></span>');
  1266. m += '<span class="irs-grid-pol" style="left: ' + f + '%"></span>';
  1267. l = this.calcReal(f);
  1268. l = a.values.length ? a.p_values[l] : this._prettify(l);
  1269. m +=
  1270. '<span class="irs-grid-text js-grid-text-' +
  1271. b +
  1272. '" style="left: ' +
  1273. f +
  1274. '%">' +
  1275. l +
  1276. "</span>";
  1277. }
  1278. this.coords.big_num = Math.ceil(d + 1);
  1279. this.$cache.cont.addClass("irs-with-grid");
  1280. this.$cache.grid.html(m);
  1281. this.cacheGridLabels();
  1282. }
  1283. },
  1284. cacheGridLabels: function () {
  1285. var a,
  1286. b,
  1287. c = this.coords.big_num;
  1288. for (b = 0; b < c; b++)
  1289. (a = this.$cache.grid.find(".js-grid-text-" + b)),
  1290. this.$cache.grid_labels.push(a);
  1291. this.calcGridLabels();
  1292. },
  1293. calcGridLabels: function () {
  1294. var a, b;
  1295. b = [];
  1296. var c = [],
  1297. d = this.coords.big_num;
  1298. for (a = 0; a < d; a++)
  1299. (this.coords.big_w[a] = this.$cache.grid_labels[a].outerWidth(!1)),
  1300. (this.coords.big_p[a] = this.toFixed(
  1301. (this.coords.big_w[a] / this.coords.w_rs) * 100
  1302. )),
  1303. (this.coords.big_x[a] = this.toFixed(this.coords.big_p[a] / 2)),
  1304. (b[a] = this.toFixed(this.coords.big[a] - this.coords.big_x[a])),
  1305. (c[a] = this.toFixed(b[a] + this.coords.big_p[a]));
  1306. this.options.force_edges &&
  1307. (b[0] < this.coords.grid_gap &&
  1308. ((b[0] = this.coords.grid_gap),
  1309. (c[0] = this.toFixed(b[0] + this.coords.big_p[0])),
  1310. (this.coords.big_x[0] = this.coords.grid_gap)),
  1311. c[d - 1] > 100 - this.coords.grid_gap &&
  1312. ((c[d - 1] = 100 - this.coords.grid_gap),
  1313. (b[d - 1] = this.toFixed(c[d - 1] - this.coords.big_p[d - 1])),
  1314. (this.coords.big_x[d - 1] = this.toFixed(
  1315. this.coords.big_p[d - 1] - this.coords.grid_gap
  1316. ))));
  1317. this.calcGridCollision(2, b, c);
  1318. this.calcGridCollision(4, b, c);
  1319. for (a = 0; a < d; a++)
  1320. (b = this.$cache.grid_labels[a][0]),
  1321. (b.style.marginLeft = -this.coords.big_x[a] + "%");
  1322. },
  1323. calcGridCollision: function (a, b, c) {
  1324. var d,
  1325. e,
  1326. f,
  1327. g = this.coords.big_num;
  1328. for (d = 0; d < g; d += a) {
  1329. e = d + a / 2;
  1330. if (e >= g) break;
  1331. f = this.$cache.grid_labels[e][0];
  1332. f.style.visibility = c[d] <= b[e] ? "visible" : "hidden";
  1333. }
  1334. },
  1335. calcGridMargin: function () {
  1336. this.options.grid_margin &&
  1337. ((this.coords.w_rs = this.$cache.rs.outerWidth(!1)),
  1338. this.coords.w_rs &&
  1339. ((this.coords.w_handle =
  1340. "single" === this.options.type
  1341. ? this.$cache.s_single.outerWidth(!1)
  1342. : this.$cache.s_from.outerWidth(!1)),
  1343. (this.coords.p_handle = this.toFixed(
  1344. (this.coords.w_handle / this.coords.w_rs) * 100
  1345. )),
  1346. (this.coords.grid_gap = this.toFixed(this.coords.p_handle / 2 - 0.1)),
  1347. (this.$cache.grid[0].style.width =
  1348. this.toFixed(100 - this.coords.p_handle) + "%"),
  1349. (this.$cache.grid[0].style.left = this.coords.grid_gap + "%")));
  1350. },
  1351. update: function (a) {
  1352. this.input &&
  1353. ((this.is_update = !0),
  1354. (this.options.from = this.result.from),
  1355. (this.options.to = this.result.to),
  1356. (this.options = g.extend(this.options, a)),
  1357. this.validate(),
  1358. this.updateResult(a),
  1359. this.toggleInput(),
  1360. this.remove(),
  1361. this.init(!0));
  1362. },
  1363. reset: function () {
  1364. this.input && (this.updateResult(), this.update());
  1365. },
  1366. destroy: function () {
  1367. this.input &&
  1368. (this.toggleInput(),
  1369. this.$cache.input.prop("readonly", !1),
  1370. g.data(this.input, "ionRangeSlider", null),
  1371. this.remove(),
  1372. (this.options = this.input = null));
  1373. },
  1374. };
  1375. g.fn.ionRangeSlider = function (a) {
  1376. return this.each(function () {
  1377. g.data(this, "ionRangeSlider") ||
  1378. g.data(this, "ionRangeSlider", new p(this, a, t++));
  1379. });
  1380. };
  1381. (function () {
  1382. for (
  1383. var a = 0, b = ["ms", "moz", "webkit", "o"], c = 0;
  1384. c < b.length && !h.requestAnimationFrame;
  1385. ++c
  1386. )
  1387. (h.requestAnimationFrame = h[b[c] + "RequestAnimationFrame"]),
  1388. (h.cancelAnimationFrame =
  1389. h[b[c] + "CancelAnimationFrame"] ||
  1390. h[b[c] + "CancelRequestAnimationFrame"]);
  1391. h.requestAnimationFrame ||
  1392. (h.requestAnimationFrame = function (b, c) {
  1393. var f = new Date().getTime(),
  1394. g = Math.max(0, 16 - (f - a)),
  1395. n = h.setTimeout(function () {
  1396. b(f + g);
  1397. }, g);
  1398. a = f + g;
  1399. return n;
  1400. });
  1401. h.cancelAnimationFrame ||
  1402. (h.cancelAnimationFrame = function (a) {
  1403. clearTimeout(a);
  1404. });
  1405. })();
  1406. })(jQuery, document, window, navigator);