mobiscroll.scroller.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. (function ($, window, document, undefined) {
  2. var move,
  3. ms = $.mobiscroll,
  4. classes = ms.classes,
  5. util = ms.util,
  6. pr = util.jsPrefix,
  7. has3d = util.has3d,
  8. hasFlex = util.hasFlex,
  9. getCoord = util.getCoord,
  10. constrain = util.constrain,
  11. testTouch = util.testTouch;
  12. ms.presetShort('scroller', 'Scroller', false);
  13. classes.Scroller = function (el, settings, inherit) {
  14. var $markup,
  15. btn,
  16. isScrollable,
  17. itemHeight,
  18. multiple,
  19. s,
  20. scrollDebounce,
  21. trigger,
  22. click,
  23. moved,
  24. start,
  25. startTime,
  26. stop,
  27. p,
  28. min,
  29. max,
  30. target,
  31. index,
  32. lines,
  33. timer,
  34. that = this,
  35. $elm = $(el),
  36. iv = {},
  37. pos = {},
  38. pixels = {},
  39. wheels = [];
  40. // Event handlers
  41. function onStart(ev) {
  42. // Scroll start
  43. if (testTouch(ev, this) && !move && !click && !btn && !isReadOnly(this)) {
  44. // Prevent touch highlight
  45. ev.preventDefault();
  46. // Better performance if there are tap events on document
  47. ev.stopPropagation();
  48. move = true;
  49. isScrollable = s.mode != 'clickpick';
  50. target = $('.dw-ul', this);
  51. setGlobals(target);
  52. moved = iv[index] !== undefined; // Don't allow tap, if still moving
  53. p = moved ? getCurrentPosition(target) : pos[index];
  54. start = getCoord(ev, 'Y');
  55. startTime = new Date();
  56. stop = start;
  57. scroll(target, index, p, 0.001);
  58. if (isScrollable) {
  59. target.closest('.dwwl').addClass('dwa');
  60. }
  61. if (ev.type === 'mousedown') {
  62. $(document).on('mousemove', onMove).on('mouseup', onEnd);
  63. }
  64. }
  65. }
  66. function onMove(ev) {
  67. if (move) {
  68. if (isScrollable) {
  69. // Prevent scroll
  70. ev.preventDefault();
  71. ev.stopPropagation();
  72. stop = getCoord(ev, 'Y');
  73. if (Math.abs(stop - start) > 3 || moved) {
  74. scroll(target, index, constrain(p + (start - stop) / itemHeight, min - 1, max + 1));
  75. moved = true;
  76. }
  77. }
  78. }
  79. }
  80. function onEnd(ev) {
  81. if (move) {
  82. var time = new Date() - startTime,
  83. curr = constrain(Math.round(p + (start - stop) / itemHeight), min - 1, max + 1),
  84. val = curr,
  85. speed,
  86. dist,
  87. ttop = target.offset().top;
  88. // Better performance if there are tap events on document
  89. ev.stopPropagation();
  90. move = false;
  91. if (ev.type === 'mouseup') {
  92. $(document).off('mousemove', onMove).off('mouseup', onEnd);
  93. }
  94. if (has3d && time < 300) {
  95. speed = (stop - start) / time;
  96. dist = (speed * speed) / s.speedUnit;
  97. if (stop - start < 0) {
  98. dist = -dist;
  99. }
  100. } else {
  101. dist = stop - start;
  102. }
  103. if (!moved) { // this is a "tap"
  104. var idx = Math.floor((stop - ttop) / itemHeight),
  105. li = $($('.dw-li', target)[idx]),
  106. valid = li.hasClass('dw-v'),
  107. hl = isScrollable;
  108. time = 0.1;
  109. if (trigger('onValueTap', [li]) !== false && valid) {
  110. val = idx;
  111. } else {
  112. hl = true;
  113. }
  114. if (hl && valid) {
  115. li.addClass('dw-hl'); // Highlight
  116. setTimeout(function () {
  117. li.removeClass('dw-hl');
  118. }, 100);
  119. }
  120. if (!multiple && (s.confirmOnTap === true || s.confirmOnTap[index]) && li.hasClass('dw-sel')) {
  121. that.select();
  122. return;
  123. }
  124. } else {
  125. val = constrain(Math.round(p - dist / itemHeight), min, max);
  126. time = speed ? Math.max(0.1, Math.abs((val - curr) / speed) * s.timeUnit) : 0.1;
  127. }
  128. if (isScrollable) {
  129. calc(target, index, val, 0, time, true);
  130. }
  131. }
  132. }
  133. function onBtnStart(ev) {
  134. btn = $(this);
  135. // +/- buttons
  136. if (testTouch(ev, this)) {
  137. step(ev, btn.closest('.dwwl'), btn.hasClass('dwwbp') ? plus : minus);
  138. }
  139. if (ev.type === 'mousedown') {
  140. $(document).on('mouseup', onBtnEnd);
  141. }
  142. }
  143. function onBtnEnd(ev) {
  144. btn = null;
  145. if (click) {
  146. clearInterval(timer);
  147. click = false;
  148. }
  149. if (ev.type === 'mouseup') {
  150. $(document).off('mouseup', onBtnEnd);
  151. }
  152. }
  153. function onKeyDown(ev) {
  154. if (ev.keyCode == 38) { // up
  155. step(ev, $(this), minus);
  156. } else if (ev.keyCode == 40) { // down
  157. step(ev, $(this), plus);
  158. }
  159. }
  160. function onKeyUp() {
  161. if (click) {
  162. clearInterval(timer);
  163. click = false;
  164. }
  165. }
  166. function onScroll(ev) {
  167. if (!isReadOnly(this)) {
  168. ev.preventDefault();
  169. ev = ev.originalEvent || ev;
  170. var delta = ev.deltaY || ev.wheelDelta || ev.detail,
  171. t = $('.dw-ul', this);
  172. setGlobals(t);
  173. scroll(t, index, constrain(((delta < 0 ? -20 : 20) - pixels[index]) / itemHeight, min - 1, max + 1));
  174. clearTimeout(scrollDebounce);
  175. scrollDebounce = setTimeout(function () {
  176. calc(t, index, Math.round(pos[index]), delta > 0 ? 1 : 2, 0.1);
  177. }, 200);
  178. }
  179. }
  180. // Private functions
  181. function step(ev, w, func) {
  182. ev.stopPropagation();
  183. ev.preventDefault();
  184. if (!click && !isReadOnly(w) && !w.hasClass('dwa')) {
  185. click = true;
  186. // + Button
  187. var t = w.find('.dw-ul');
  188. setGlobals(t);
  189. clearInterval(timer);
  190. timer = setInterval(function () { func(t); }, s.delay);
  191. func(t);
  192. }
  193. }
  194. function isReadOnly(wh) {
  195. if ($.isArray(s.readonly)) {
  196. var i = $('.dwwl', $markup).index(wh);
  197. return s.readonly[i];
  198. }
  199. return s.readonly;
  200. }
  201. function generateWheelItems(i) {
  202. var html = '<div class="dw-bf">',
  203. w = wheels[i],
  204. l = 1,
  205. labels = w.labels || [],
  206. values = w.values || [],
  207. keys = w.keys || values;
  208. $.each(values, function (j, v) {
  209. if (l % 20 === 0) {
  210. html += '</div><div class="dw-bf">';
  211. }
  212. html += '<div role="option" aria-selected="false" class="dw-li dw-v" data-val="' + keys[j] + '"' + (labels[j] ? ' aria-label="' + labels[j] + '"' : '') + ' style="height:' + itemHeight + 'px;line-height:' + itemHeight + 'px;">' +
  213. '<div class="dw-i"' + (lines > 1 ? ' style="line-height:' + Math.round(itemHeight / lines) + 'px;font-size:' + Math.round(itemHeight / lines * 0.8) + 'px;"' : '') + '>' + v + '</div></div>';
  214. l++;
  215. });
  216. html += '</div>';
  217. return html;
  218. }
  219. function setGlobals(t) {
  220. multiple = t.closest('.dwwl').hasClass('dwwms');
  221. min = $('.dw-li', t).index($(multiple ? '.dw-li' : '.dw-v', t).eq(0));
  222. max = Math.max(min, $('.dw-li', t).index($(multiple ? '.dw-li' : '.dw-v', t).eq(-1)) - (multiple ? s.rows - (s.mode == 'scroller' ? 1 : 3) : 0));
  223. index = $('.dw-ul', $markup).index(t);
  224. }
  225. function formatHeader(v) {
  226. var t = s.headerText;
  227. return t ? (typeof t === 'function' ? t.call(el, v) : t.replace(/\{value\}/i, v)) : '';
  228. }
  229. function getCurrentPosition(t) {
  230. return Math.round(-util.getPosition(t, true) / itemHeight);
  231. }
  232. function ready(t, i) {
  233. clearTimeout(iv[i]);
  234. delete iv[i];
  235. t.closest('.dwwl').removeClass('dwa');
  236. }
  237. function scroll(t, index, val, time, active) {
  238. var px = -val * itemHeight,
  239. style = t[0].style;
  240. if (px == pixels[index] && iv[index]) {
  241. return;
  242. }
  243. //if (time && px != pixels[index]) {
  244. // Trigger animation start event
  245. //trigger('onAnimStart', [$markup, index, time]);
  246. //}
  247. pixels[index] = px;
  248. if (has3d) {
  249. style[pr + 'Transition'] = util.prefix + 'transform ' + (time ? time.toFixed(3) : 0) + 's ease-out';
  250. style[pr + 'Transform'] = 'translate3d(0,' + px + 'px,0)';
  251. } else {
  252. style.top = px + 'px';
  253. }
  254. if (iv[index]) {
  255. ready(t, index);
  256. }
  257. if (time && active) {
  258. t.closest('.dwwl').addClass('dwa');
  259. iv[index] = setTimeout(function () {
  260. ready(t, index);
  261. }, time * 1000);
  262. }
  263. pos[index] = val;
  264. }
  265. function getValid(val, t, dir, multiple, select) {
  266. var selected,
  267. cell = $('.dw-li[data-val="' + val + '"]', t),
  268. cells = $('.dw-li', t),
  269. v = cells.index(cell),
  270. l = cells.length;
  271. if (multiple) {
  272. setGlobals(t);
  273. } else if (!cell.hasClass('dw-v')) { // Scroll to a valid cell
  274. var cell1 = cell,
  275. cell2 = cell,
  276. dist1 = 0,
  277. dist2 = 0;
  278. while (v - dist1 >= 0 && !cell1.hasClass('dw-v')) {
  279. dist1++;
  280. cell1 = cells.eq(v - dist1);
  281. }
  282. while (v + dist2 < l && !cell2.hasClass('dw-v')) {
  283. dist2++;
  284. cell2 = cells.eq(v + dist2);
  285. }
  286. // If we have direction (+/- or mouse wheel), the distance does not count
  287. if (((dist2 < dist1 && dist2 && dir !== 2) || !dist1 || (v - dist1 < 0) || dir == 1) && cell2.hasClass('dw-v')) {
  288. cell = cell2;
  289. v = v + dist2;
  290. } else {
  291. cell = cell1;
  292. v = v - dist1;
  293. }
  294. }
  295. selected = cell.hasClass('dw-sel');
  296. if (select) {
  297. if (!multiple) {
  298. $('.dw-sel', t).removeAttr('aria-selected');
  299. cell.attr('aria-selected', 'true');
  300. }
  301. // Add selected class to cell
  302. $('.dw-sel', t).removeClass('dw-sel');
  303. cell.addClass('dw-sel');
  304. }
  305. return {
  306. selected: selected,
  307. v: multiple ? constrain(v, min, max) : v,
  308. val: cell.hasClass('dw-v') ? cell.attr('data-val') : null
  309. };
  310. }
  311. function scrollToPos(time, index, manual, dir, active) {
  312. // Call validation event
  313. if (trigger('validate', [$markup, index, time, dir]) !== false) {
  314. // Set scrollers to position
  315. $('.dw-ul', $markup).each(function (i) {
  316. var t = $(this),
  317. multiple = t.closest('.dwwl').hasClass('dwwms'),
  318. sc = i == index || index === undefined,
  319. res = getValid(that._tempWheelArray[i], t, dir, multiple, true),
  320. selected = res.selected;
  321. if (!selected || sc) {
  322. // Set valid value
  323. that._tempWheelArray[i] = res.val;
  324. // Scroll to position
  325. scroll(t, i, res.v, sc ? time : 0.1, sc ? active : false);
  326. }
  327. });
  328. trigger('onValidated', []);
  329. // Reformat value if validation changed something
  330. that._tempValue = s.formatValue(that._tempWheelArray, that);
  331. if (that.live) {
  332. that._hasValue = manual || that._hasValue;
  333. setValue(manual, manual, 0, true);
  334. }
  335. that._header.html(formatHeader(that._tempValue));
  336. if (manual) {
  337. trigger('onChange', [that._tempValue]);
  338. }
  339. }
  340. }
  341. function calc(t, idx, val, dir, time, active) {
  342. val = constrain(val, min, max);
  343. // Set selected scroller value
  344. that._tempWheelArray[idx] = $('.dw-li', t).eq(val).attr('data-val');
  345. scroll(t, idx, val, time, active);
  346. setTimeout(function () {
  347. // Validate
  348. scrollToPos(time, idx, true, dir, active);
  349. }, 10);
  350. }
  351. function plus(t) {
  352. var val = pos[index] + 1;
  353. calc(t, index, val > max ? min : val, 1, 0.1);
  354. }
  355. function minus(t) {
  356. var val = pos[index] - 1;
  357. calc(t, index, val < min ? max : val, 2, 0.1);
  358. }
  359. function setValue(fill, change, time, noscroll, temp) {
  360. if (that._isVisible && !noscroll) {
  361. scrollToPos(time);
  362. }
  363. that._tempValue = s.formatValue(that._tempWheelArray, that);
  364. if (!temp) {
  365. that._wheelArray = that._tempWheelArray.slice(0);
  366. that._value = that._hasValue ? that._tempValue : null;
  367. }
  368. if (fill) {
  369. trigger('onValueFill', [that._hasValue ? that._tempValue : '', change]);
  370. if (that._isInput) {
  371. $elm.val(that._hasValue ? that._tempValue : '');
  372. }
  373. if (change) {
  374. that._preventChange = true;
  375. $elm.change();
  376. }
  377. }
  378. }
  379. // Call the parent constructor
  380. classes.Frame.call(this, el, settings, true);
  381. // Public functions
  382. /**
  383. * Gets the selected wheel values, formats it, and set the value of the scroller instance.
  384. * If input parameter is true, populates the associated input element.
  385. * @param {Array} values Wheel values.
  386. * @param {Boolean} [fill=false] Also set the value of the associated input element.
  387. * @param {Number} [time=0] Animation time
  388. * @param {Boolean} [temp=false] If true, then only set the temporary value.(only scroll there but not set the value)
  389. * @param {Boolean} [change=false] Trigger change on the input element
  390. */
  391. that.setVal = that._setVal = function (val, fill, change, temp, time) {
  392. that._hasValue = val !== null && val !== undefined;
  393. that._tempWheelArray = $.isArray(val) ? val.slice(0) : s.parseValue.call(el, val, that) || [];
  394. setValue(fill, change === undefined ? fill : change, time, false, temp);
  395. };
  396. /**
  397. * Returns the selected value
  398. */
  399. that.getVal = that._getVal = function (temp) {
  400. var val = that._hasValue || temp ? that[temp ? '_tempValue' : '_value'] : null;
  401. return util.isNumeric(val) ? +val : val;
  402. };
  403. /*
  404. * Sets the wheel values (passed as an array)
  405. */
  406. that.setArrayVal = that.setVal;
  407. /*
  408. * Returns the selected wheel values as an array
  409. */
  410. that.getArrayVal = function (temp) {
  411. return temp ? that._tempWheelArray : that._wheelArray;
  412. };
  413. // @deprecated since 2.14.0, backward compatibility code
  414. // ---
  415. that.setValue = function (val, fill, time, temp, change) {
  416. that.setVal(val, fill, change, temp, time);
  417. };
  418. /**
  419. * Return the selected wheel values.
  420. */
  421. that.getValue = that.getArrayVal;
  422. // ---
  423. /**
  424. * Changes the values of a wheel, and scrolls to the correct position
  425. * @param {Array} idx Indexes of the wheels to change.
  426. * @param {Number} [time=0] Animation time when scrolling to the selected value on the new wheel.
  427. * @param {Boolean} [manual=false] Indicates that the change was triggered by the user or from code.
  428. */
  429. that.changeWheel = function (idx, time, manual) {
  430. if ($markup) {
  431. var i = 0,
  432. nr = idx.length;
  433. $.each(s.wheels, function (j, wg) {
  434. $.each(wg, function (k, w) {
  435. if ($.inArray(i, idx) > -1) {
  436. wheels[i] = w;
  437. $('.dw-ul', $markup).eq(i).html(generateWheelItems(i));
  438. nr--;
  439. if (!nr) {
  440. that.position();
  441. scrollToPos(time, undefined, manual);
  442. return false;
  443. }
  444. }
  445. i++;
  446. });
  447. if (!nr) {
  448. return false;
  449. }
  450. });
  451. }
  452. };
  453. /**
  454. * Returns the closest valid cell.
  455. */
  456. that.getValidCell = getValid;
  457. that.scroll = scroll;
  458. // Protected overrides
  459. that._generateContent = function () {
  460. var lbl,
  461. html = '',
  462. l = 0;
  463. $.each(s.wheels, function (i, wg) { // Wheel groups
  464. html += '<div class="mbsc-w-p dwc' + (s.mode != 'scroller' ? ' dwpm' : ' dwsc') + (s.showLabel ? '' : ' dwhl') + '">' +
  465. '<div class="dwwc"' + (s.maxWidth ? '' : ' style="max-width:600px;"') + '>' +
  466. (hasFlex ? '' : '<table class="dw-tbl" cellpadding="0" cellspacing="0"><tr>');
  467. $.each(wg, function (j, w) { // Wheels
  468. wheels[l] = w;
  469. lbl = w.label !== undefined ? w.label : j;
  470. html += '<' + (hasFlex ? 'div' : 'td') + ' class="dwfl"' + ' style="' +
  471. (s.fixedWidth ? ('width:' + (s.fixedWidth[l] || s.fixedWidth) + 'px;') :
  472. (s.minWidth ? ('min-width:' + (s.minWidth[l] || s.minWidth) + 'px;') : 'min-width:' + s.width + 'px;') +
  473. (s.maxWidth ? ('max-width:' + (s.maxWidth[l] || s.maxWidth) + 'px;') : '')) + '">' +
  474. '<div class="dwwl dwwl' + l + (w.multiple ? ' dwwms' : '') + '">' +
  475. (s.mode != 'scroller' ?
  476. '<div class="dwb-e dwwb dwwbp ' + (s.btnPlusClass || '') + '" style="height:' + itemHeight + 'px;line-height:' + itemHeight + 'px;"><span>+</span></div>' + // + button
  477. '<div class="dwb-e dwwb dwwbm ' + (s.btnMinusClass || '') + '" style="height:' + itemHeight + 'px;line-height:' + itemHeight + 'px;"><span>&ndash;</span></div>' : '') + // - button
  478. '<div class="dwl">' + lbl + '</div>' + // Wheel label
  479. '<div tabindex="0" aria-live="off" aria-label="' + lbl + '" role="listbox" class="dwww">' +
  480. '<div class="dww" style="height:' + (s.rows * itemHeight) + 'px;">' +
  481. '<div class="dw-ul" style="margin-top:' + (w.multiple ? (s.mode == 'scroller' ? 0 : itemHeight) : s.rows / 2 * itemHeight - itemHeight / 2) + 'px;">';
  482. // Create wheel values
  483. html += generateWheelItems(l) +
  484. '</div></div><div class="dwwo"></div></div><div class="dwwol"' +
  485. (s.selectedLineHeight ? ' style="height:' + itemHeight + 'px;margin-top:-' + (itemHeight / 2 + (s.selectedLineBorder || 0)) + 'px;"' : '') + '></div></div>' +
  486. (hasFlex ? '</div>' : '</td>');
  487. l++;
  488. });
  489. html += (hasFlex ? '' : '</tr></table>') + '</div></div>';
  490. });
  491. return html;
  492. };
  493. that._attachEvents = function ($markup) {
  494. $markup
  495. .on('keydown', '.dwwl', onKeyDown)
  496. .on('keyup', '.dwwl', onKeyUp)
  497. .on('touchstart mousedown', '.dwwl', onStart)
  498. .on('touchmove', '.dwwl', onMove)
  499. .on('touchend', '.dwwl', onEnd)
  500. .on('touchstart mousedown', '.dwwb', onBtnStart)
  501. .on('touchend', '.dwwb', onBtnEnd);
  502. if (s.mousewheel) {
  503. $markup.on('wheel mousewheel', '.dwwl', onScroll);
  504. }
  505. };
  506. that._markupReady = function ($m) {
  507. $markup = $m;
  508. scrollToPos();
  509. };
  510. that._fillValue = function () {
  511. that._hasValue = true;
  512. setValue(true, true, 0, true);
  513. };
  514. that._readValue = function () {
  515. var v = $elm.val() || '';
  516. if (v !== '') {
  517. that._hasValue = true;
  518. }
  519. that._tempWheelArray = that._hasValue && that._wheelArray ? that._wheelArray.slice(0) : s.parseValue.call(el, v, that) || [];
  520. setValue();
  521. };
  522. that._processSettings = function () {
  523. s = that.settings;
  524. trigger = that.trigger;
  525. itemHeight = s.height;
  526. lines = s.multiline;
  527. that._isLiquid = (s.layout || (/top|bottom/.test(s.display) && s.wheels.length == 1 ? 'liquid' : '')) === 'liquid';
  528. // @deprecated since 2.15.0, backward compatibility code
  529. // ---
  530. if (s.formatResult) {
  531. s.formatValue = s.formatResult;
  532. }
  533. // ---
  534. if (lines > 1) {
  535. s.cssClass = (s.cssClass || '') + ' dw-ml';
  536. }
  537. // Ensure a minimum number of 3 items if clickpick buttons present
  538. if (s.mode != 'scroller') {
  539. s.rows = Math.max(3, s.rows);
  540. }
  541. };
  542. // Properties
  543. that._selectedValues = {};
  544. // Constructor
  545. if (!inherit) {
  546. that.init(settings);
  547. }
  548. };
  549. // Extend defaults
  550. classes.Scroller.prototype = {
  551. _hasDef: true,
  552. _hasTheme: true,
  553. _hasLang: true,
  554. _hasPreset: true,
  555. _class: 'scroller',
  556. _defaults: $.extend({}, classes.Frame.prototype._defaults, {
  557. // Options
  558. minWidth: 80,
  559. height: 40,
  560. rows: 3,
  561. multiline: 1,
  562. delay: 300,
  563. readonly: false,
  564. showLabel: true,
  565. confirmOnTap: true,
  566. wheels: [],
  567. mode: 'scroller',
  568. preset: '',
  569. speedUnit: 0.0012,
  570. timeUnit: 0.08,
  571. formatValue: function (d) {
  572. return d.join(' ');
  573. },
  574. parseValue: function (value, inst) {
  575. var val = [],
  576. ret = [],
  577. i = 0,
  578. found,
  579. keys;
  580. if (value !== null && value !== undefined) {
  581. val = (value + '').split(' ');
  582. }
  583. $.each(inst.settings.wheels, function (j, wg) {
  584. $.each(wg, function (k, w) {
  585. keys = w.keys || w.values;
  586. found = keys[0]; // Default to first wheel value if not found
  587. $.each(keys, function (l, key) {
  588. if (val[i] == key) { // Don't do strict comparison
  589. found = key;
  590. return false;
  591. }
  592. });
  593. ret.push(found);
  594. i++;
  595. });
  596. });
  597. return ret;
  598. }
  599. })
  600. };
  601. ms.themes.scroller = ms.themes.frame;
  602. })(jQuery, window, document);