mobiscroll-2.17.1-new.js 153 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492
  1. //**mobiscroll.core.js
  2. /*!
  3. * Mobiscroll v2.17.1
  4. * http://mobiscroll.com
  5. *
  6. * Copyright 2010-2015, Acid Media
  7. * Licensed under the MIT license.
  8. *
  9. */
  10. (function ($, undefined) {
  11. function testProps(props) {
  12. var i;
  13. for (i in props) {
  14. if (mod[props[i]] !== undefined) {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. function testPrefix() {
  21. var prefixes = ['Webkit', 'Moz', 'O', 'ms'],
  22. p;
  23. for (p in prefixes) {
  24. if (testProps([prefixes[p] + 'Transform'])) {
  25. return '-' + prefixes[p].toLowerCase() + '-';
  26. }
  27. }
  28. return '';
  29. }
  30. function init(that, options, args) {
  31. var ret = that;
  32. // Init
  33. if (typeof options === 'object') {
  34. return that.each(function () {
  35. if (instances[this.id]) {
  36. instances[this.id].destroy();
  37. }
  38. new $.mobiscroll.classes[options.component || 'Scroller'](this, options);
  39. });
  40. }
  41. // Method call
  42. if (typeof options === 'string') {
  43. that.each(function () {
  44. var r,
  45. inst = instances[this.id];
  46. if (inst && inst[options]) {
  47. r = inst[options].apply(this, Array.prototype.slice.call(args, 1));
  48. if (r !== undefined) {
  49. ret = r;
  50. return false;
  51. }
  52. }
  53. });
  54. }
  55. return ret;
  56. }
  57. var ms,
  58. id = +new Date(),
  59. instances = {},
  60. extend = $.extend,
  61. mod = document.createElement('modernizr').style,
  62. has3d = testProps(['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']),
  63. hasFlex = testProps(['flex', 'msFlex', 'WebkitBoxDirection']),
  64. prefix = testPrefix(),
  65. pr = prefix.replace(/^\-/, '').replace(/\-$/, '').replace('moz', 'Moz');
  66. $.fn.mobiscroll = function (method) {
  67. extend(this, $.mobiscroll.components);
  68. return init(this, method, arguments);
  69. };
  70. ms = $.mobiscroll = $.mobiscroll || {
  71. version: '2.17.1',
  72. util: {
  73. prefix: prefix,
  74. jsPrefix: pr,
  75. has3d: has3d,
  76. hasFlex: hasFlex,
  77. isOldAndroid: /android [1-3]/i.test(navigator.userAgent),
  78. preventClick: function () {
  79. // Prevent ghost click
  80. ms.tapped++;
  81. setTimeout(function () {
  82. ms.tapped--;
  83. }, 500);
  84. },
  85. testTouch: function (e, elm) {
  86. if (e.type == 'touchstart') {
  87. $(elm).attr('data-touch', '1');
  88. } else if ($(elm).attr('data-touch')) {
  89. $(elm).removeAttr('data-touch');
  90. return false;
  91. }
  92. return true;
  93. },
  94. objectToArray: function (obj) {
  95. var arr = [],
  96. i;
  97. for (i in obj) {
  98. arr.push(obj[i]);
  99. }
  100. return arr;
  101. },
  102. arrayToObject: function (arr) {
  103. var obj = {},
  104. i;
  105. if (arr) {
  106. for (i = 0; i < arr.length; i++) {
  107. obj[arr[i]] = arr[i];
  108. }
  109. }
  110. return obj;
  111. },
  112. isNumeric: function (a) {
  113. return a - parseFloat(a) >= 0;
  114. },
  115. isString: function (s) {
  116. return typeof s === 'string';
  117. },
  118. getCoord: function (e, c, page) {
  119. var ev = e.originalEvent || e,
  120. prop = (page ? 'page' : 'client') + c;
  121. return ev.changedTouches ? ev.changedTouches[0][prop] : e[prop];
  122. },
  123. getPosition: function (t, vertical) {
  124. var style = window.getComputedStyle ? getComputedStyle(t[0]) : t[0].style,
  125. matrix,
  126. px;
  127. if (has3d) {
  128. $.each(['t', 'webkitT', 'MozT', 'OT', 'msT'], function (i, v) {
  129. if (style[v + 'ransform'] !== undefined) {
  130. matrix = style[v + 'ransform'];
  131. return false;
  132. }
  133. });
  134. matrix = matrix.split(')')[0].split(', ');
  135. px = vertical ? (matrix[13] || matrix[5]) : (matrix[12] || matrix[4]);
  136. } else {
  137. px = vertical ? style.top.replace('px', '') : style.left.replace('px', '');
  138. }
  139. return px;
  140. },
  141. addIcon: function ($control, ic) {
  142. var icons = {},
  143. $parent = $control.parent(),
  144. errorMsg = $parent.find('.mbsc-err-msg'),
  145. align = $control.attr('data-icon-align') || 'left',
  146. icon = $control.attr('data-icon');
  147. // Wrap input
  148. $('<span class="mbsc-input-wrap"></span>').insertAfter($control).append($control);
  149. if (errorMsg) {
  150. $parent.find('.mbsc-input-wrap').append(errorMsg);
  151. }
  152. if (icon) {
  153. if (icon.indexOf('{') !== -1) {
  154. icons = JSON.parse(icon);
  155. } else {
  156. icons[align] = icon;
  157. }
  158. extend(icons, ic);
  159. $parent
  160. .addClass((icons.right ? 'mbsc-ic-right ' : '') + (icons.left ? ' mbsc-ic-left' : ''))
  161. .find('.mbsc-input-wrap')
  162. .append(icons.left ? '<span class="mbsc-input-ic mbsc-left-ic mbsc-ic mbsc-ic-' + icons.left + '"></span>' : '')
  163. .append(icons.right ? '<span class="mbsc-input-ic mbsc-right-ic mbsc-ic mbsc-ic-' + icons.right + '"></span>' : '');
  164. }
  165. },
  166. constrain: function (val, min, max) {
  167. return Math.max(min, Math.min(val, max));
  168. },
  169. vibrate: function (time) {
  170. if ('vibrate' in navigator) {
  171. navigator.vibrate(time || 50);
  172. }
  173. }
  174. },
  175. tapped: 0,
  176. autoTheme: 'mobiscroll',
  177. presets: {
  178. scroller: {},
  179. numpad: {},
  180. listview: {},
  181. menustrip: {}
  182. },
  183. themes: {
  184. form: {},
  185. frame: {},
  186. listview: {},
  187. menustrip: {},
  188. progress: {}
  189. },
  190. i18n: {},
  191. instances: instances,
  192. classes: {},
  193. components: {},
  194. defaults: {
  195. context: 'body',
  196. mousewheel: true,
  197. vibrate: true
  198. },
  199. setDefaults: function (o) {
  200. extend(this.defaults, o);
  201. },
  202. presetShort: function (name, c, p) {
  203. this.components[name] = function (s) {
  204. return init(this, extend(s, {
  205. component: c,
  206. preset: p === false ? undefined : name
  207. }), arguments);
  208. };
  209. }
  210. };
  211. $.mobiscroll.classes.Base = function (el, settings) {
  212. var lang,
  213. preset,
  214. s,
  215. theme,
  216. themeName,
  217. defaults,
  218. ms = $.mobiscroll,
  219. util = ms.util,
  220. getCoord = util.getCoord,
  221. that = this;
  222. that.settings = {};
  223. that._presetLoad = function () {};
  224. that._init = function (ss) {
  225. s = that.settings;
  226. // Update original user settings
  227. extend(settings, ss);
  228. // Load user defaults
  229. if (that._hasDef) {
  230. defaults = ms.defaults;
  231. }
  232. // Create settings object
  233. extend(s, that._defaults, defaults, settings);
  234. // Get theme defaults
  235. if (that._hasTheme) {
  236. themeName = s.theme;
  237. if (themeName == 'auto' || !themeName) {
  238. themeName = ms.autoTheme;
  239. }
  240. if (themeName == 'default') {
  241. themeName = 'mobiscroll';
  242. }
  243. settings.theme = themeName;
  244. theme = ms.themes[that._class] ? ms.themes[that._class][themeName] : {};
  245. }
  246. // Get language defaults
  247. if (that._hasLang) {
  248. lang = ms.i18n[s.lang];
  249. }
  250. if (that._hasTheme) {
  251. that.trigger('onThemeLoad', [lang, settings]);
  252. }
  253. // Update settings object
  254. extend(s, theme, lang, defaults, settings);
  255. // Load preset settings
  256. if (that._hasPreset) {
  257. that._presetLoad(s);
  258. preset = ms.presets[that._class][s.preset];
  259. if (preset) {
  260. preset = preset.call(el, that);
  261. extend(s, preset, settings);
  262. }
  263. }
  264. };
  265. that._destroy = function () {
  266. that.trigger('onDestroy', []);
  267. // Delete scroller instance
  268. delete instances[el.id];
  269. that = null;
  270. };
  271. /**
  272. * Attach tap event to the given element.
  273. */
  274. that.tap = function (el, handler, prevent) {
  275. var startX,
  276. startY,
  277. target,
  278. moved;
  279. function onStart(ev) {
  280. if (!target) {
  281. // Can't always call preventDefault here, it kills page scroll
  282. if (prevent) {
  283. ev.preventDefault();
  284. }
  285. target = this;
  286. startX = getCoord(ev, 'X');
  287. startY = getCoord(ev, 'Y');
  288. moved = false;
  289. if (ev.type == 'pointerdown') {
  290. $(document)
  291. .on('pointermove', onMove)
  292. .on('pointerup', onEnd);
  293. }
  294. }
  295. }
  296. function onMove(ev) {
  297. // If movement is more than 20px, don't fire the click event handler
  298. if (target && !moved && Math.abs(getCoord(ev, 'X') - startX) > 9 || Math.abs(getCoord(ev, 'Y') - startY) > 9) {
  299. moved = true;
  300. }
  301. }
  302. function onEnd(ev) {
  303. if (target) {
  304. if (!moved) {
  305. ev.preventDefault();
  306. handler.call(target, ev, that);
  307. }
  308. if (ev.type == 'pointerup') {
  309. $(document)
  310. .off('pointermove', onMove)
  311. .off('pointerup', onEnd);
  312. }
  313. target = false;
  314. util.preventClick();
  315. }
  316. }
  317. function onCancel() {
  318. target = false;
  319. }
  320. if (s.tap) {
  321. el
  322. .on('touchstart.dw pointerdown.dw', onStart)
  323. .on('touchcancel.dw pointercancel.dw', onCancel)
  324. .on('touchmove.dw', onMove)
  325. .on('touchend.dw', onEnd);
  326. }
  327. el.on('click.dw', function (ev) {
  328. ev.preventDefault();
  329. // If handler was not called on touchend, call it on click;
  330. handler.call(this, ev, that);
  331. });
  332. };
  333. /**
  334. * Triggers an event
  335. */
  336. that.trigger = function (name, args) {
  337. var ret;
  338. args.push(that);
  339. $.each([defaults, theme, preset, settings], function (i, v) {
  340. if (v && v[name]) { // Call preset event
  341. ret = v[name].apply(el, args);
  342. }
  343. });
  344. return ret;
  345. };
  346. /**
  347. * Sets one ore more options.
  348. */
  349. that.option = function (opt, value) {
  350. var obj = {};
  351. if (typeof opt === 'object') {
  352. obj = opt;
  353. } else {
  354. obj[opt] = value;
  355. }
  356. that.init(obj);
  357. };
  358. /**
  359. * Returns the mobiscroll instance.
  360. */
  361. that.getInst = function () {
  362. return that;
  363. };
  364. settings = settings || {};
  365. $(el).addClass('mbsc-comp');
  366. // Autogenerate id
  367. if (!el.id) {
  368. el.id = 'mobiscroll' + (++id);
  369. }
  370. // Save instance
  371. instances[el.id] = that;
  372. };
  373. // Prevent standard behaviour on body click
  374. function preventClick(ev) {
  375. // Textarea needs the mousedown event
  376. if (ms.tapped && !ev.tap && !(ev.target.nodeName == 'TEXTAREA' && ev.type == 'mousedown')) {
  377. ev.stopPropagation();
  378. ev.preventDefault();
  379. return false;
  380. }
  381. }
  382. if (document.addEventListener) {
  383. $.each(['mouseover', 'mousedown', 'mouseup', 'click'], function (i, ev) {
  384. document.addEventListener(ev, preventClick, true);
  385. });
  386. }
  387. })(jQuery);
  388. //**mobiscroll.frame.js
  389. (function ($, window, document, undefined) {
  390. var $activeElm,
  391. preventShow,
  392. ms = $.mobiscroll,
  393. util = ms.util,
  394. pr = util.jsPrefix,
  395. has3d = util.has3d,
  396. constrain = util.constrain,
  397. isString = util.isString,
  398. isOldAndroid = util.isOldAndroid,
  399. isIOS8 = /(iphone|ipod|ipad).* os 8_/i.test(navigator.userAgent),
  400. animEnd = 'webkitAnimationEnd animationend',
  401. empty = function () {},
  402. prevdef = function (ev) {
  403. ev.preventDefault();
  404. };
  405. ms.classes.Frame = function (el, settings, inherit) {
  406. var $ariaDiv,
  407. $ctx,
  408. $header,
  409. $markup,
  410. $overlay,
  411. $persp,
  412. $popup,
  413. $wnd,
  414. $wrapper,
  415. buttons,
  416. btn,
  417. doAnim,
  418. event,
  419. hasButtons,
  420. isModal,
  421. modalWidth,
  422. modalHeight,
  423. posEvents,
  424. preventPos,
  425. s,
  426. scrollLock,
  427. setReadOnly,
  428. wndWidth,
  429. wndHeight,
  430. that = this,
  431. $elm = $(el),
  432. elmList = [],
  433. posDebounce = {};
  434. function onBtnStart(ev) {
  435. // Can't call preventDefault here, it kills page scroll
  436. if (btn) {
  437. btn.removeClass('dwb-a');
  438. }
  439. btn = $(this);
  440. // Active button
  441. if (!btn.hasClass('dwb-d') && !btn.hasClass('dwb-nhl')) {
  442. btn.addClass('dwb-a');
  443. }
  444. if (ev.type === 'mousedown') {
  445. $(document).on('mouseup', onBtnEnd);
  446. } else if (ev.type === 'pointerdown') {
  447. $(document).on('pointerup', onBtnEnd);
  448. }
  449. }
  450. function onBtnEnd(ev) {
  451. if (btn) {
  452. btn.removeClass('dwb-a');
  453. btn = null;
  454. }
  455. if (ev.type === 'mouseup') {
  456. $(document).off('mouseup', onBtnEnd);
  457. } else if (ev.type === 'pointerup') {
  458. $(document).off('pointerup', onBtnEnd);
  459. }
  460. }
  461. function onWndKeyDown(ev) {
  462. if (ev.keyCode == 13) {
  463. that.select();
  464. } else if (ev.keyCode == 27) {
  465. that.cancel();
  466. }
  467. }
  468. function onShow(prevFocus) {
  469. if (!prevFocus) {
  470. $popup.focus();
  471. }
  472. that.ariaMessage(s.ariaMessage);
  473. }
  474. function onHide(prevAnim) {
  475. var activeEl,
  476. value,
  477. type,
  478. focus = s.focusOnClose;
  479. setTimeout(function(){
  480. that._markupRemove();
  481. $markup.remove();
  482. },500);
  483. if ($activeElm && !prevAnim) {
  484. setTimeout(function () {
  485. if (focus === undefined || focus === true) {
  486. preventShow = true;
  487. activeEl = $activeElm[0];
  488. type = activeEl.type;
  489. value = activeEl.value;
  490. try {
  491. activeEl.type = 'button';
  492. } catch (ex) {}
  493. $activeElm.focus();
  494. activeEl.type = type;
  495. activeEl.value = value;
  496. } else if (focus) {
  497. $(focus).focus();
  498. }
  499. }, 200);
  500. }
  501. that._isVisible = false;
  502. event('onHide', []);
  503. }
  504. function onPosition(ev) {
  505. clearTimeout(posDebounce[ev.type]);
  506. posDebounce[ev.type] = setTimeout(function () {
  507. var isScroll = ev.type == 'scroll';
  508. if (isScroll && !scrollLock) {
  509. return;
  510. }
  511. that.position(!isScroll);
  512. }, 200);
  513. }
  514. function onFocus(ev) {
  515. if (ev.target.nodeType && !$popup[0].contains(ev.target)) {
  516. $popup.focus();
  517. }
  518. }
  519. function onBlur() {
  520. $(this).off('blur', onBlur);
  521. setTimeout(function () {
  522. that.position();
  523. }, 100);
  524. }
  525. function show(beforeShow, $elm) {
  526. if (beforeShow) {
  527. beforeShow();
  528. }
  529. // Hide virtual keyboard
  530. if ($(document.activeElement).is('input,textarea')) {
  531. $(document.activeElement).blur();
  532. }
  533. if (that.show() !== false) {
  534. $activeElm = $elm;
  535. setTimeout(function () {
  536. preventShow = false;
  537. }, 300); // With jQuery < 1.9 focus is fired twice in IE
  538. }
  539. }
  540. function set() {
  541. that._fillValue();
  542. event('onSelect', [that._value]);
  543. }
  544. function cancel() {
  545. event('onCancel', [that._value]);
  546. }
  547. function clear() {
  548. that.setVal(null, true);
  549. }
  550. // Call the parent constructor
  551. ms.classes.Base.call(this, el, settings, true);
  552. /**
  553. * Positions the scroller on the screen.
  554. */
  555. that.position = function (check) {
  556. var w,
  557. l,
  558. t,
  559. anchor,
  560. aw, // anchor width
  561. ah, // anchor height
  562. ap, // anchor position
  563. at, // anchor top
  564. al, // anchor left
  565. arr, // arrow
  566. arrw, // arrow width
  567. arrl, // arrow left
  568. dh,
  569. scroll,
  570. sl, // scroll left
  571. st, // scroll top
  572. totalw = 0,
  573. minw = 0,
  574. css = {},
  575. nw = Math.min($wnd[0].innerWidth || $wnd.innerWidth(), $persp.width()), //$persp.width(), // To get the width without scrollbar
  576. nh = $wnd[0].innerHeight || $wnd.innerHeight(),
  577. $focused = $(document.activeElement);
  578. if ($focused.is('input,textarea') && !/(button|submit|checkbox|radio)/.test($focused.attr('type'))) {
  579. $focused.on('blur', onBlur);
  580. return;
  581. }
  582. if ((wndWidth === nw && wndHeight === nh && check) || preventPos) {
  583. return;
  584. }
  585. if (that._isFullScreen || /top|bottom/.test(s.display)) {
  586. // Set width, if document is larger than viewport, needs to be set before onPosition (for calendar)
  587. $popup.width(nw);
  588. }
  589. if (event('onPosition', [$markup, nw, nh]) === false || !isModal) {
  590. return;
  591. }
  592. sl = $wnd.scrollLeft();
  593. st = $wnd.scrollTop();
  594. anchor = s.anchor === undefined ? $elm : $(s.anchor);
  595. // Set / unset liquid layout based on screen width, but only if not set explicitly by the user
  596. if (that._isLiquid && s.layout !== 'liquid') {
  597. if (nw < 400) {
  598. $markup.addClass('dw-liq');
  599. } else {
  600. $markup.removeClass('dw-liq');
  601. }
  602. }
  603. if (!that._isFullScreen && /modal|bubble/.test(s.display)) {
  604. $wrapper.width('');
  605. $('.mbsc-w-p', $markup).each(function () {
  606. w = $(this).outerWidth(true);
  607. totalw += w;
  608. minw = (w > minw) ? w : minw;
  609. });
  610. w = totalw > nw ? minw : totalw;
  611. $wrapper.width(w + 1).css('white-space', totalw > nw ? '' : 'nowrap');
  612. }
  613. modalWidth = $popup.outerWidth();
  614. modalHeight = $popup.outerHeight(true);
  615. scrollLock = modalHeight <= nh && modalWidth <= nw;
  616. that.scrollLock = scrollLock;
  617. if (scrollLock) {
  618. $ctx.addClass('mbsc-fr-lock');
  619. } else {
  620. $ctx.removeClass('mbsc-fr-lock');
  621. }
  622. if (s.display == 'modal') {
  623. l = Math.max(0, sl + (nw - modalWidth) / 2);
  624. t = st + (nh - modalHeight) / 2;
  625. } else if (s.display == 'bubble') {
  626. // Scroll only if width also changed
  627. // to prevent scroll when address bar appears / hides
  628. scroll = wndWidth !== nw;
  629. arr = $('.dw-arrw-i', $markup);
  630. ap = anchor.offset();
  631. at = Math.abs($ctx.offset().top - ap.top);
  632. al = Math.abs($ctx.offset().left - ap.left);
  633. // horizontal positioning
  634. aw = anchor.outerWidth();
  635. ah = anchor.outerHeight();
  636. l = constrain(al - ($popup.outerWidth(true) - aw) / 2, sl + 3, sl + nw - modalWidth - 3);
  637. // vertical positioning
  638. t = at - modalHeight; // above the input
  639. if ((t < st) || (at > st + nh)) { // if doesn't fit above or the input is out of the screen
  640. $popup.removeClass('dw-bubble-top').addClass('dw-bubble-bottom');
  641. t = at + ah; // below the input
  642. } else {
  643. $popup.removeClass('dw-bubble-bottom').addClass('dw-bubble-top');
  644. }
  645. // Calculate Arrow position
  646. arrw = arr.outerWidth();
  647. arrl = constrain(al + aw / 2 - (l + (modalWidth - arrw) / 2), 0, arrw);
  648. // Limit Arrow position
  649. $('.dw-arr', $markup).css({
  650. left: arrl
  651. });
  652. } else {
  653. l = sl;
  654. if (s.display == 'top') {
  655. t = st;
  656. } else if (s.display == 'bottom') {
  657. t = st + nh - modalHeight;
  658. }
  659. }
  660. t = t < 0 ? 0 : t;
  661. css.top = t;
  662. css.left = l;
  663. $popup.css(css);
  664. // If top + modal height > doc height, increase doc height
  665. $persp.height(0);
  666. dh = Math.max(t + modalHeight, s.context == 'body' ? $(document).height() : $ctx[0].scrollHeight);
  667. $persp.css({
  668. height: dh
  669. });
  670. // Scroll needed
  671. if (scroll && ((t + modalHeight > st + nh) || (at > st + nh))) {
  672. preventPos = true;
  673. setTimeout(function () {
  674. preventPos = false;
  675. }, 300);
  676. $wnd.scrollTop(Math.min(at, t + modalHeight - nh, dh - nh));
  677. }
  678. wndWidth = nw;
  679. wndHeight = nh;
  680. // Call position for nested mobiscroll components
  681. $('.mbsc-comp', $markup).each(function () {
  682. var inst = $(this).mobiscroll('getInst');
  683. if (inst !== that && inst.position) {
  684. inst.position();
  685. }
  686. });
  687. };
  688. /**
  689. * Show mobiscroll on focus and click event of the parameter.
  690. * @param {jQuery} $elm - Events will be attached to this element.
  691. * @param {Function} [beforeShow=undefined] - Optional function to execute before showing mobiscroll.
  692. */
  693. that.attachShow = function ($elm, beforeShow) {
  694. elmList.push({
  695. readOnly: $elm.prop('readonly'),
  696. el: $elm
  697. });
  698. if (s.display !== 'inline') {
  699. if (setReadOnly && $elm.is('input')) {
  700. $elm.prop('readonly', true).on('mousedown.dw', function (ev) {
  701. // Prevent input to get focus on tap (virtual keyboard pops up on some devices)
  702. ev.preventDefault();
  703. });
  704. }
  705. if (s.showOnFocus) {
  706. $elm.on('focus.dw', function () {
  707. if (!preventShow) {
  708. show(beforeShow, $elm);
  709. }
  710. });
  711. }
  712. if (s.showOnTap) {
  713. $elm.on('keydown.dw', function (ev) {
  714. if (ev.keyCode == 32 || ev.keyCode == 13) { // Space or Enter
  715. ev.preventDefault();
  716. ev.stopPropagation();
  717. show(beforeShow, $elm);
  718. }
  719. });
  720. that.tap($elm, function () {
  721. show(beforeShow, $elm);
  722. });
  723. }
  724. }
  725. };
  726. /**
  727. * Set button handler.
  728. */
  729. that.select = function () {
  730. if (isModal) {
  731. that.hide(false, 'set', false, set);
  732. } else {
  733. set();
  734. }
  735. };
  736. /**
  737. * Cancel and hide the scroller instance.
  738. */
  739. that.cancel = function () {
  740. if (isModal) {
  741. that.hide(false, 'cancel', false, cancel);
  742. } else {
  743. set();
  744. }
  745. };
  746. /**
  747. * Clear button handler.
  748. */
  749. that.clear = function () {
  750. event('onClear', [$markup]);
  751. if (isModal && that._isVisible && !that.live) {
  752. that.hide(false, 'clear', false, clear);
  753. } else {
  754. clear();
  755. }
  756. };
  757. /**
  758. * Enables the scroller and the associated input.
  759. */
  760. that.enable = function () {
  761. s.disabled = false;
  762. if (that._isInput) {
  763. $elm.prop('disabled', false);
  764. }
  765. };
  766. /**
  767. * Disables the scroller and the associated input.
  768. */
  769. that.disable = function () {
  770. s.disabled = true;
  771. if (that._isInput) {
  772. $elm.prop('disabled', true);
  773. }
  774. };
  775. /**
  776. * Shows the scroller instance.
  777. * @param {Boolean} prevAnim - Prevent animation if true
  778. * @param {Boolean} prevFocus - Prevent focusing if true
  779. */
  780. that.show = function (prevAnim, prevFocus) {
  781. // Create wheels
  782. var html;
  783. if (s.disabled || that._isVisible) {
  784. return;
  785. }
  786. // Parse value from input
  787. that._readValue();
  788. if (event('onBeforeShow', []) === false) {
  789. return false;
  790. }
  791. doAnim = isOldAndroid ? false : s.animate;
  792. /*if (doAnim !== false) {
  793. if (s.display == 'top') {
  794. doAnim = 'slidedown';
  795. }
  796. if (s.display == 'bottom') {
  797. doAnim = 'slideup';
  798. }
  799. }*/
  800. // Create wheels containers
  801. html = '<div lang="' + s.lang + '" class="mbsc-' + s.theme + (s.baseTheme ? ' mbsc-' + s.baseTheme : '') + ' dw-' + s.display + ' ' +
  802. (s.cssClass || '') +
  803. (that._isLiquid ? ' dw-liq' : '') +
  804. (isOldAndroid ? ' mbsc-old' : '') +
  805. (hasButtons ? '' : ' dw-nobtn') + '">' +
  806. '<div class="dw-persp">' +
  807. (isModal ? '<div class="dwo"></div>' : '') + // Overlay
  808. '<div' + (isModal ? ' role="dialog" tabindex="-1"' : '') + ' class="dw' + (s.rtl ? ' dw-rtl' : ' dw-ltr') + '">' + // Popup
  809. (s.display === 'bubble' ? '<div class="dw-arrw"><div class="dw-arrw-i"><div class="dw-arr"></div></div></div>' : '') + // Bubble arrow
  810. '<div class="dwwr">' + // Popup content
  811. '<div aria-live="assertive" class="dw-aria dw-hidden"></div>' +
  812. (s.headerText ? '<div class="dwv">' + (isString(s.headerText) ? s.headerText : '') + '</div>' : '') + // Header
  813. '<div class="dwcc">'; // Wheel group container
  814. html += that._generateContent();
  815. html += '</div>';
  816. if (hasButtons) {
  817. html += '<div class="dwbc">';
  818. $.each(buttons, function (i, b) {
  819. b = isString(b) ? that.buttons[b] : b;
  820. if (b.handler === 'set') {
  821. b.parentClass = 'dwb-s';
  822. }
  823. if (b.handler === 'cancel') {
  824. b.parentClass = 'dwb-c';
  825. }
  826. html += '<div' + (s.btnWidth ? ' style="width:' + (100 / buttons.length) + '%"' : '') + ' class="dwbw ' + (b.parentClass || '') + '"><div tabindex="0" role="button" class="dwb' + i + ' dwb-e ' + (b.cssClass === undefined ? s.btnClass : b.cssClass) + (b.icon ? ' mbsc-ic mbsc-ic-' + b.icon : '') + '">' + (b.text || '') + '</div></div>';
  827. });
  828. html += '</div>';
  829. }
  830. html += '</div></div></div></div>';
  831. $markup = $(html);
  832. $persp = $('.dw-persp', $markup);
  833. $overlay = $('.dwo', $markup);
  834. $wrapper = $('.dwwr', $markup);
  835. $header = $('.dwv', $markup);
  836. $popup = $('.dw', $markup);
  837. $ariaDiv = $('.dw-aria', $markup);
  838. that._markup = $markup;
  839. that._header = $header;
  840. that._isVisible = true;
  841. posEvents = 'orientationchange resize';
  842. that._markupReady($markup);
  843. event('onMarkupReady', [$markup]);
  844. // Show
  845. if (isModal) {
  846. // Enter / ESC
  847. $(window).on('keydown', onWndKeyDown);
  848. // Prevent scroll if not specified otherwise
  849. if (s.scrollLock) {
  850. $markup.on('touchmove mousewheel wheel', function (ev) {
  851. if (scrollLock) {
  852. ev.preventDefault();
  853. }
  854. });
  855. }
  856. // Disable inputs to prevent bleed through (Android bug)
  857. if (pr !== 'Moz') {
  858. $('input,select,button', $ctx).each(function () {
  859. if (!this.disabled) {
  860. $(this).addClass('dwtd').prop('disabled', true);
  861. }
  862. });
  863. }
  864. if (ms.activeInstance) {
  865. ms.activeInstance.hide();
  866. }
  867. posEvents += ' scroll';
  868. ms.activeInstance = that;
  869. $markup.appendTo($ctx);
  870. if (s.focusTrap) {
  871. $wnd.on('focusin', onFocus);
  872. }
  873. if (has3d && doAnim && !prevAnim) {
  874. $markup.addClass('dw-in dw-trans').on(animEnd, function () {
  875. $markup.off(animEnd).removeClass('dw-in dw-trans').find('.dw').removeClass('dw-' + doAnim);
  876. onShow(prevFocus);
  877. }).find('.dw').addClass('dw-' + doAnim);
  878. }
  879. } else if ($elm.is('div') && !that._hasContent) {
  880. $elm.html($markup);
  881. } else {
  882. $markup.insertAfter($elm);
  883. }
  884. that._markupInserted($markup);
  885. event('onMarkupInserted', [$markup]);
  886. // Set position
  887. that.position();
  888. $wnd.on(posEvents, onPosition);
  889. // Events
  890. $markup
  891. .on('selectstart mousedown', prevdef) // Prevents blue highlight on Android and text selection in IE
  892. .on('click', '.dwb-e', prevdef)
  893. .on('keydown', '.dwb-e', function (ev) {
  894. if (ev.keyCode == 32) { // Space
  895. ev.preventDefault();
  896. ev.stopPropagation();
  897. $(this).click();
  898. }
  899. })
  900. .on('keydown', function (ev) { // Trap focus inside modal
  901. if (ev.keyCode == 32) { // Space
  902. ev.preventDefault();
  903. } else if (ev.keyCode == 9 && isModal && s.focusTrap) { // Tab
  904. var $focusable = $markup.find('[tabindex="0"]').filter(function () {
  905. return this.offsetWidth > 0 || this.offsetHeight > 0;
  906. }),
  907. index = $focusable.index($(':focus', $markup)),
  908. i = $focusable.length - 1,
  909. target = 0;
  910. if (ev.shiftKey) {
  911. i = 0;
  912. target = -1;
  913. }
  914. if (index === i) {
  915. $focusable.eq(target).focus();
  916. ev.preventDefault();
  917. }
  918. }
  919. });
  920. $('input,select,textarea', $markup).on('selectstart mousedown', function (ev) {
  921. ev.stopPropagation();
  922. }).on('keydown', function (ev) {
  923. if (ev.keyCode == 32) { // Space
  924. ev.stopPropagation();
  925. }
  926. });
  927. //setTimeout(function () {
  928. // Init buttons
  929. $.each(buttons, function (i, b) {
  930. that.tap($('.dwb' + i, $markup), function (ev) {
  931. b = isString(b) ? that.buttons[b] : b;
  932. (isString(b.handler) ? that.handlers[b.handler] : b.handler).call(this, ev, that);
  933. }, true);
  934. });
  935. if (s.closeOnOverlay) {
  936. that.tap($overlay, function () {
  937. that.cancel();
  938. });
  939. }
  940. if (isModal && !doAnim) {
  941. onShow(prevFocus);
  942. }
  943. $markup
  944. .on('touchstart mousedown pointerdown', '.dwb-e', onBtnStart)
  945. .on('touchend', '.dwb-e', onBtnEnd);
  946. that._attachEvents($markup);
  947. //}, 300);
  948. event('onShow', [$markup, that._tempValue]);
  949. };
  950. /**
  951. * Hides the scroller instance.
  952. */
  953. that.hide = function (prevAnim, btn, force, callback) {
  954. // If onClose handler returns false, prevent hide
  955. if (!that._isVisible || (!force && !that._isValid && btn == 'set') || (!force && event('onBeforeClose', [that._tempValue, btn]) === false)) {
  956. return false;
  957. }
  958. // Hide wheels and overlay
  959. if ($markup) {
  960. // Re-enable temporary disabled fields
  961. if (pr !== 'Moz') {
  962. $('.dwtd', $ctx).each(function () {
  963. $(this).prop('disabled', false).removeClass('dwtd');
  964. });
  965. }
  966. if (has3d && isModal && doAnim && !prevAnim && !$markup.hasClass('dw-trans')) { // If dw-trans class was not removed, means that there was no animation
  967. $markup.addClass('dw-out dw-trans').on(animEnd, function () {
  968. onHide(prevAnim);
  969. }).find('.dw').addClass('dw-' + doAnim);
  970. } else {
  971. onHide(prevAnim);
  972. }
  973. // Stop positioning on window resize
  974. $wnd
  975. .off(posEvents, onPosition)
  976. .off('focusin', onFocus);
  977. }
  978. if (isModal) {
  979. $ctx.removeClass('mbsc-fr-lock');
  980. $(window).off('keydown', onWndKeyDown);
  981. delete ms.activeInstance;
  982. }
  983. if (callback) {
  984. callback();
  985. }
  986. event('onClosed', [that._value]);
  987. };
  988. that.ariaMessage = function (txt) {
  989. $ariaDiv.html('');
  990. setTimeout(function () {
  991. $ariaDiv.html(txt);
  992. }, 100);
  993. };
  994. /**
  995. * Return true if the scroller is currently visible.
  996. */
  997. that.isVisible = function () {
  998. return that._isVisible;
  999. };
  1000. // Protected functions to override
  1001. that.setVal = empty;
  1002. that.getVal = empty;
  1003. that._generateContent = empty;
  1004. that._attachEvents = empty;
  1005. that._readValue = empty;
  1006. that._fillValue = empty;
  1007. that._markupReady = empty;
  1008. that._markupInserted = empty;
  1009. that._markupRemove = empty;
  1010. that._processSettings = empty;
  1011. that._presetLoad = function (s) {
  1012. // Add default buttons
  1013. s.buttons = s.buttons || (s.display !== 'inline' ? ['set', 'cancel'] : []);
  1014. // Hide header text in inline mode by default
  1015. s.headerText = s.headerText === undefined ? (s.display !== 'inline' ? '{value}' : false) : s.headerText;
  1016. };
  1017. // Generic frame functions
  1018. /**
  1019. * Destroys the mobiscroll instance.
  1020. */
  1021. that.destroy = function () {
  1022. // Force hide without animation
  1023. that.hide(true, false, true);
  1024. // Remove all events from elements
  1025. $.each(elmList, function (i, v) {
  1026. v.el.off('.dw').prop('readonly', v.readOnly);
  1027. });
  1028. that._destroy();
  1029. };
  1030. /**
  1031. * Scroller initialization.
  1032. */
  1033. that.init = function (ss) {
  1034. // @deprecated since 2.17.0, backward compatibility code
  1035. // ---
  1036. if (ss.onClose) {
  1037. ss.onBeforeClose = ss.onClose;
  1038. }
  1039. // ---
  1040. that._init(ss);
  1041. that._isLiquid = (s.layout || (/top|bottom/.test(s.display) ? 'liquid' : '')) === 'liquid';
  1042. that._processSettings();
  1043. // Unbind all events (if re-init)
  1044. $elm.off('.dw');
  1045. buttons = s.buttons || [];
  1046. isModal = s.display !== 'inline';
  1047. setReadOnly = s.showOnFocus || s.showOnTap;
  1048. that._window = $wnd = $(s.context == 'body' ? window : s.context);
  1049. that._context = $ctx = $(s.context);
  1050. that.live = true;
  1051. // If no set button is found, live mode is activated
  1052. $.each(buttons, function (i, b) {
  1053. if (b == 'ok' || b == 'set' || b.handler == 'set') {
  1054. that.live = false;
  1055. return false;
  1056. }
  1057. });
  1058. that.buttons.set = {
  1059. text: s.setText,
  1060. handler: 'set'
  1061. };
  1062. that.buttons.cancel = {
  1063. text: (that.live) ? s.closeText : s.cancelText,
  1064. handler: 'cancel'
  1065. };
  1066. that.buttons.clear = {
  1067. text: s.clearText,
  1068. handler: 'clear'
  1069. };
  1070. that._isInput = $elm.is('input');
  1071. hasButtons = buttons.length > 0;
  1072. if (that._isVisible) {
  1073. that.hide(true, false, true);
  1074. }
  1075. event('onInit', []);
  1076. if (isModal) {
  1077. that._readValue();
  1078. if (!that._hasContent) {
  1079. that.attachShow($elm);
  1080. }
  1081. } else {
  1082. that.show();
  1083. }
  1084. $elm.on('change.dw', function () {
  1085. if (!that._preventChange) {
  1086. that.setVal($elm.val(), true, false);
  1087. }
  1088. that._preventChange = false;
  1089. });
  1090. };
  1091. that.buttons = {};
  1092. that.handlers = {
  1093. set: that.select,
  1094. cancel: that.cancel,
  1095. clear: that.clear
  1096. };
  1097. that._value = null;
  1098. that._isValid = true;
  1099. that._isVisible = false;
  1100. // Constructor
  1101. s = that.settings;
  1102. event = that.trigger;
  1103. if (!inherit) {
  1104. that.init(settings);
  1105. }
  1106. };
  1107. ms.classes.Frame.prototype._defaults = {
  1108. // Localization
  1109. lang: 'en',
  1110. setText: 'Set',
  1111. selectedText: '{count} selected',
  1112. closeText: 'Close',
  1113. cancelText: 'Cancel',
  1114. clearText: 'Clear',
  1115. // Options
  1116. disabled: false,
  1117. closeOnOverlay: true,
  1118. showOnFocus: false,
  1119. showOnTap: true,
  1120. display: 'bottom',
  1121. scrollLock: true,
  1122. tap: true,
  1123. btnClass: 'dwb',
  1124. btnWidth: false,
  1125. focusTrap: true,
  1126. focusOnClose: !isIOS8 // Temporary for iOS8
  1127. };
  1128. ms.themes.frame.mobiscroll = {
  1129. rows: 5,
  1130. showLabel: false,
  1131. headerText: false,
  1132. btnWidth: false,
  1133. selectedLineHeight: true,
  1134. selectedLineBorder: 1,
  1135. dateOrder: 'MMddyy',
  1136. weekDays: 'min',
  1137. checkIcon: 'ion-ios7-checkmark-empty',
  1138. btnPlusClass: 'mbsc-ic mbsc-ic-arrow-down5',
  1139. btnMinusClass: 'mbsc-ic mbsc-ic-arrow-up5',
  1140. btnCalPrevClass: 'mbsc-ic mbsc-ic-arrow-left5',
  1141. btnCalNextClass: 'mbsc-ic mbsc-ic-arrow-right5'
  1142. };
  1143. // Prevent re-show on window focus
  1144. $(window).on('focus', function () {
  1145. if ($activeElm) {
  1146. preventShow = true;
  1147. }
  1148. });
  1149. })(jQuery, window, document);
  1150. //**mobiscroll.scroller.js
  1151. (function ($, window, document, undefined) {
  1152. var ms = $.mobiscroll,
  1153. classes = ms.classes,
  1154. util = ms.util,
  1155. pr = util.jsPrefix,
  1156. has3d = util.has3d,
  1157. hasFlex = util.hasFlex,
  1158. getCoord = util.getCoord,
  1159. constrain = util.constrain,
  1160. testTouch = util.testTouch;
  1161. ms.presetShort('scroller', 'Scroller', false);
  1162. classes.Scroller = function (el, settings, inherit) {
  1163. var $markup,
  1164. btn,
  1165. isScrollable,
  1166. itemHeight,
  1167. multiple,
  1168. pixels,
  1169. s,
  1170. scrollDebounce,
  1171. trigger,
  1172. click,
  1173. moved,
  1174. start,
  1175. startTime,
  1176. stop,
  1177. p,
  1178. min,
  1179. max,
  1180. target,
  1181. index,
  1182. lines,
  1183. timer,
  1184. that = this,
  1185. $elm = $(el),
  1186. iv = {},
  1187. pos = {},
  1188. wheels = [];
  1189. // Event handlers
  1190. function onStart(ev) {
  1191. // Scroll start
  1192. if (testTouch(ev, this) && !target && !click && !btn && !isReadOnly(this)) {
  1193. // Prevent touch highlight
  1194. ev.preventDefault();
  1195. // Better performance if there are tap events on document
  1196. ev.stopPropagation();
  1197. isScrollable = s.mode != 'clickpick';
  1198. target = $('.dw-ul', this);
  1199. setGlobals(target);
  1200. moved = iv[index] !== undefined; // Don't allow tap, if still moving
  1201. p = moved ? getCurrentPosition(target) : pos[index];
  1202. start = getCoord(ev, 'Y', true);
  1203. startTime = new Date();
  1204. stop = start;
  1205. scroll(target, index, p, 0.001);
  1206. if (isScrollable) {
  1207. target.closest('.dwwl').addClass('dwa');
  1208. }
  1209. if (ev.type === 'mousedown') {
  1210. $(document).on('mousemove', onMove).on('mouseup', onEnd);
  1211. }
  1212. }
  1213. }
  1214. function onMove(ev) {
  1215. if (target) {
  1216. if (isScrollable) {
  1217. // Prevent scroll
  1218. ev.preventDefault();
  1219. ev.stopPropagation();
  1220. stop = getCoord(ev, 'Y', true);
  1221. if (Math.abs(stop - start) > 3 || moved) {
  1222. scroll(target, index, constrain(p + (start - stop) / itemHeight, min - 1, max + 1));
  1223. moved = true;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. function onEnd(ev) {
  1229. if (target) {
  1230. var time = new Date() - startTime,
  1231. curr = constrain(Math.round(p + (start - stop) / itemHeight), min - 1, max + 1),
  1232. val = curr,
  1233. speed,
  1234. dist,
  1235. ttop = target.offset().top;
  1236. // Better performance if there are tap events on document
  1237. ev.stopPropagation();
  1238. if (ev.type === 'mouseup') {
  1239. $(document).off('mousemove', onMove).off('mouseup', onEnd);
  1240. }
  1241. if (has3d && time < 300) {
  1242. speed = (stop - start) / time;
  1243. dist = (speed * speed) / s.speedUnit;
  1244. if (stop - start < 0) {
  1245. dist = -dist;
  1246. }
  1247. } else {
  1248. dist = stop - start;
  1249. }
  1250. if (!moved) { // this is a "tap"
  1251. var idx = Math.floor((stop - ttop) / itemHeight),
  1252. li = $($('.dw-li', target)[idx]),
  1253. valid = li.hasClass('dw-v'),
  1254. hl = isScrollable;
  1255. time = 0.1;
  1256. if (trigger('onValueTap', [li]) !== false && valid) {
  1257. val = idx;
  1258. } else {
  1259. hl = true;
  1260. }
  1261. if (hl && valid) {
  1262. li.addClass('dw-hl'); // Highlight
  1263. setTimeout(function () {
  1264. li.removeClass('dw-hl');
  1265. }, 100);
  1266. }
  1267. if (!multiple && (s.confirmOnTap === true || s.confirmOnTap[index]) && li.hasClass('dw-sel')) {
  1268. that.select();
  1269. target = false;
  1270. return;
  1271. }
  1272. } else {
  1273. val = constrain(Math.round(p - dist / itemHeight), min, max);
  1274. time = speed ? Math.max(0.1, Math.abs((val - curr) / speed) * s.timeUnit) : 0.1;
  1275. }
  1276. if (isScrollable) {
  1277. calc(target, index, val, 0, time, true);
  1278. }
  1279. target = false;
  1280. }
  1281. }
  1282. function onBtnStart(ev) {
  1283. btn = $(this);
  1284. // +/- buttons
  1285. if (testTouch(ev, this)) {
  1286. step(ev, btn.closest('.dwwl'), btn.hasClass('dwwbp') ? plus : minus);
  1287. }
  1288. if (ev.type === 'mousedown') {
  1289. $(document).on('mouseup', onBtnEnd);
  1290. }
  1291. }
  1292. function onBtnEnd(ev) {
  1293. btn = null;
  1294. if (click) {
  1295. clearInterval(timer);
  1296. click = false;
  1297. }
  1298. if (ev.type === 'mouseup') {
  1299. $(document).off('mouseup', onBtnEnd);
  1300. }
  1301. }
  1302. function onKeyDown(ev) {
  1303. if (ev.keyCode == 38) { // up
  1304. step(ev, $(this), minus);
  1305. } else if (ev.keyCode == 40) { // down
  1306. step(ev, $(this), plus);
  1307. }
  1308. }
  1309. function onKeyUp() {
  1310. if (click) {
  1311. clearInterval(timer);
  1312. click = false;
  1313. }
  1314. }
  1315. function onScroll(ev) {
  1316. if (!isReadOnly(this)) {
  1317. ev.preventDefault();
  1318. ev = ev.originalEvent || ev;
  1319. var delta = ev.deltaY || ev.wheelDelta || ev.detail,
  1320. t = $('.dw-ul', this);
  1321. setGlobals(t);
  1322. scroll(t, index, constrain(((delta < 0 ? -20 : 20) - pixels[index]) / itemHeight, min - 1, max + 1));
  1323. clearTimeout(scrollDebounce);
  1324. scrollDebounce = setTimeout(function () {
  1325. calc(t, index, Math.round(pos[index]), delta > 0 ? 1 : 2, 0.1);
  1326. }, 200);
  1327. }
  1328. }
  1329. // Private functions
  1330. function step(ev, w, func) {
  1331. ev.stopPropagation();
  1332. ev.preventDefault();
  1333. if (!click && !isReadOnly(w) && !w.hasClass('dwa')) {
  1334. click = true;
  1335. // + Button
  1336. var t = w.find('.dw-ul');
  1337. setGlobals(t);
  1338. clearInterval(timer);
  1339. timer = setInterval(function () {
  1340. func(t);
  1341. }, s.delay);
  1342. func(t);
  1343. }
  1344. }
  1345. function isReadOnly(wh) {
  1346. if ($.isArray(s.readonly)) {
  1347. var i = $('.dwwl', $markup).index(wh);
  1348. return s.readonly[i];
  1349. }
  1350. return s.readonly;
  1351. }
  1352. function generateWheelItems(i) {
  1353. var html = '<div class="dw-bf">',
  1354. w = wheels[i],
  1355. l = 1,
  1356. labels = w.labels || [],
  1357. values = w.values || [],
  1358. keys = w.keys || values;
  1359. $.each(values, function (j, v) {
  1360. if (l % 20 === 0) {
  1361. html += '</div><div class="dw-bf">';
  1362. }
  1363. if(s.customWheels){
  1364. var keysHtml="{keys:\'" + keys[j] + "\',values:\'"+ values[j] +"\'}";
  1365. }else{
  1366. var keysHtml=keys[j];
  1367. }
  1368. html += '<div role="option" aria-selected="false" class="dw-li dw-v" data-val="' + keysHtml + '"' + (labels[j] ? ' aria-label="' + labels[j] + '"' : '') + ' style="height:' + itemHeight + 'px;line-height:' + itemHeight + 'px;">' +
  1369. '<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>';
  1370. l++;
  1371. /*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;">' +
  1372. '<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>';
  1373. l++;*/
  1374. });
  1375. html += '</div>';
  1376. return html;
  1377. }
  1378. function setGlobals(t) {
  1379. multiple = t.closest('.dwwl').hasClass('dwwms');
  1380. min = $('.dw-li', t).index($(multiple ? '.dw-li' : '.dw-v', t).eq(0));
  1381. 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));
  1382. index = $('.dw-ul', $markup).index(t);
  1383. }
  1384. function formatHeader(v) {
  1385. var t = s.headerText;
  1386. return t ? (typeof t === 'function' ? t.call(el, v) : t.replace(/\{value\}/i, v)) : '';
  1387. }
  1388. function getCurrentPosition(t) {
  1389. return Math.round(-util.getPosition(t, true) / itemHeight);
  1390. }
  1391. function ready(t, i) {
  1392. clearTimeout(iv[i]);
  1393. delete iv[i];
  1394. t.closest('.dwwl').removeClass('dwa');
  1395. }
  1396. function scroll(t, index, val, time, active) {
  1397. var px = -val * itemHeight,
  1398. style = t[0].style;
  1399. if (px == pixels[index] && iv[index]) {
  1400. return;
  1401. }
  1402. //if (time && px != pixels[index]) {
  1403. // Trigger animation start event
  1404. //trigger('onAnimStart', [$markup, index, time]);
  1405. //}
  1406. pixels[index] = px;
  1407. if (has3d) {
  1408. style[pr + 'Transition'] = util.prefix + 'transform ' + (time ? time.toFixed(3) : 0) + 's ease-out';
  1409. style[pr + 'Transform'] = 'translate3d(0,' + px + 'px,0)';
  1410. } else {
  1411. style.top = px + 'px';
  1412. }
  1413. if (iv[index]) {
  1414. ready(t, index);
  1415. }
  1416. if (time && active) {
  1417. t.closest('.dwwl').addClass('dwa');
  1418. iv[index] = setTimeout(function () {
  1419. ready(t, index);
  1420. }, time * 1000);
  1421. }
  1422. pos[index] = val;
  1423. }
  1424. function getValid(val, t, dir, multiple, select) {
  1425. var selected,
  1426. cell = $('.dw-li[data-val="' + val + '"]', t),
  1427. cells = $('.dw-li', t),
  1428. v = cells.index(cell),
  1429. l = cells.length;
  1430. if (multiple) {
  1431. setGlobals(t);
  1432. } else if (!cell.hasClass('dw-v')) { // Scroll to a valid cell
  1433. var cell1 = cell,
  1434. cell2 = cell,
  1435. dist1 = 0,
  1436. dist2 = 0;
  1437. while (v - dist1 >= 0 && !cell1.hasClass('dw-v')) {
  1438. dist1++;
  1439. cell1 = cells.eq(v - dist1);
  1440. }
  1441. while (v + dist2 < l && !cell2.hasClass('dw-v')) {
  1442. dist2++;
  1443. cell2 = cells.eq(v + dist2);
  1444. }
  1445. // If we have direction (+/- or mouse wheel), the distance does not count
  1446. if (((dist2 < dist1 && dist2 && dir !== 2) || !dist1 || (v - dist1 < 0) || dir == 1) && cell2.hasClass('dw-v')) {
  1447. cell = cell2;
  1448. v = v + dist2;
  1449. } else {
  1450. cell = cell1;
  1451. v = v - dist1;
  1452. }
  1453. }
  1454. selected = cell.hasClass('dw-sel');
  1455. if (select) {
  1456. if (!multiple) {
  1457. $('.dw-sel', t).removeAttr('aria-selected');
  1458. cell.attr('aria-selected', 'true');
  1459. }
  1460. // Add selected class to cell
  1461. $('.dw-sel', t).removeClass('dw-sel');
  1462. cell.addClass('dw-sel');
  1463. }
  1464. return {
  1465. selected: selected,
  1466. v: multiple ? constrain(v, min, max) : v,
  1467. val: cell.hasClass('dw-v') || multiple ? cell.attr('data-val') : null
  1468. };
  1469. }
  1470. function scrollToPos(time, index, manual, dir, active) {
  1471. // Call validation event
  1472. if (trigger('validate', [$markup, index, time, dir]) !== false) {
  1473. // Set scrollers to position
  1474. $('.dw-ul', $markup).each(function (i) {
  1475. var t = $(this),
  1476. multiple = t.closest('.dwwl').hasClass('dwwms'),
  1477. sc = i == index || index === undefined,
  1478. res = getValid(that._tempWheelArray[i], t, dir, multiple, true),
  1479. selected = res.selected;
  1480. if (!selected || sc) {
  1481. // Set valid value
  1482. that._tempWheelArray[i] = res.val;
  1483. // Scroll to position
  1484. scroll(t, i, res.v, sc ? time : 0.1, sc ? active : false);
  1485. }
  1486. });
  1487. trigger('onValidated', [index]);
  1488. // Reformat value if validation changed something
  1489. that._tempValue = s.formatValue(that._tempWheelArray, that);
  1490. if (that.live) {
  1491. that._hasValue = manual || that._hasValue;
  1492. setValue(manual, manual, 0, true);
  1493. }
  1494. that._header.html(formatHeader(that._tempValue));
  1495. if (manual) {
  1496. trigger('onChange', [that._tempValue]);
  1497. }
  1498. }
  1499. }
  1500. function calc(t, idx, val, dir, time, active) {
  1501. //val = constrain(val, min, max);
  1502. // Set selected scroller value
  1503. that._tempWheelArray[idx] = $('.dw-li', t).eq(val).attr('data-val');
  1504. //scroll(t, idx, val, time, active);
  1505. setTimeout(function () {
  1506. // Validate
  1507. scrollToPos(time, idx, true, dir, active);
  1508. }, 10);
  1509. }
  1510. function plus(t) {
  1511. var val = pos[index] + 1;
  1512. calc(t, index, val > max ? min : val, 1, 0.1);
  1513. }
  1514. function minus(t) {
  1515. var val = pos[index] - 1;
  1516. calc(t, index, val < min ? max : val, 2, 0.1);
  1517. }
  1518. function setValue(fill, change, time, noscroll, temp) {
  1519. if (that._isVisible && !noscroll) {
  1520. scrollToPos(time);
  1521. }
  1522. that._tempValue = s.formatValue(that._tempWheelArray, that);
  1523. if (!temp) {
  1524. that._wheelArray = that._tempWheelArray.slice(0);
  1525. that._value = that._hasValue ? that._tempValue : null;
  1526. }
  1527. if (fill) {
  1528. trigger('onValueFill', [that._hasValue ? that._tempValue : '', change]);
  1529. if (that._isInput) {
  1530. $elm.val(that._hasValue ? that._tempValue : '');
  1531. }
  1532. if (change) {
  1533. that._preventChange = true;
  1534. $elm.change();
  1535. }
  1536. }
  1537. }
  1538. // Call the parent constructor
  1539. classes.Frame.call(this, el, settings, true);
  1540. // Public functions
  1541. /**
  1542. * Gets the selected wheel values, formats it, and set the value of the scroller instance.
  1543. * If input parameter is true, populates the associated input element.
  1544. * @param {Array} values Wheel values.
  1545. * @param {Boolean} [fill=false] Also set the value of the associated input element.
  1546. * @param {Number} [time=0] Animation time
  1547. * @param {Boolean} [temp=false] If true, then only set the temporary value.(only scroll there but not set the value)
  1548. * @param {Boolean} [change=false] Trigger change on the input element
  1549. */
  1550. that.setVal = that._setVal = function (val, fill, change, temp, time) {
  1551. that._hasValue = val !== null && val !== undefined;
  1552. that._tempWheelArray = $.isArray(val) ? val.slice(0) : s.parseValue.call(el, val, that) || [];
  1553. setValue(fill, change === undefined ? fill : change, time, false, temp);
  1554. };
  1555. /**
  1556. * Returns the selected value
  1557. */
  1558. that.getVal = that._getVal = function (temp) {
  1559. var val = that._hasValue || temp ? that[temp ? '_tempValue' : '_value'] : null;
  1560. return util.isNumeric(val) ? +val : val;
  1561. };
  1562. /*
  1563. * Sets the wheel values (passed as an array)
  1564. */
  1565. that.setArrayVal = that.setVal;
  1566. /*
  1567. * Returns the selected wheel values as an array
  1568. */
  1569. that.getArrayVal = function (temp) {
  1570. return temp ? that._tempWheelArray : that._wheelArray;
  1571. };
  1572. // @deprecated since 2.14.0, backward compatibility code
  1573. // ---
  1574. that.setValue = function (val, fill, time, temp, change) {
  1575. that.setVal(val, fill, change, temp, time);
  1576. };
  1577. /**
  1578. * Return the selected wheel values.
  1579. */
  1580. that.getValue = that.getArrayVal;
  1581. // ---
  1582. /**
  1583. * Changes the values of a wheel, and scrolls to the correct position
  1584. * @param {Array} idx Indexes of the wheels to change.
  1585. * @param {Number} [time=0] Animation time when scrolling to the selected value on the new wheel.
  1586. * @param {Boolean} [manual=false] Indicates that the change was triggered by the user or from code.
  1587. */
  1588. that.changeWheel = function (idx, time, manual) {
  1589. if ($markup) {
  1590. var i = 0,
  1591. nr = idx.length;
  1592. $.each(s.wheels, function (j, wg) {
  1593. $.each(wg, function (k, w) {
  1594. if ($.inArray(i, idx) > -1) {
  1595. wheels[i] = w;
  1596. $('.dw-ul', $markup).eq(i).html(generateWheelItems(i));
  1597. nr--;
  1598. if (!nr) {
  1599. that.position();
  1600. scrollToPos(time, undefined, manual);
  1601. return false;
  1602. }
  1603. }
  1604. i++;
  1605. });
  1606. if (!nr) {
  1607. return false;
  1608. }
  1609. });
  1610. }
  1611. };
  1612. that.selectWheel = function (keyVal, time, manual) {
  1613. $.each(s.wheels, function (j, wg) {
  1614. $.each(wg, function (k, w) {
  1615. $.each(w.keys,function(l,d){
  1616. if(keyVal[k]==d){
  1617. var $el=$('.dwfl',that._markup).eq(k);
  1618. calc($el, k, l, 1, 0.1);
  1619. }
  1620. });
  1621. });
  1622. });
  1623. };
  1624. /**
  1625. * Returns the closest valid cell.
  1626. */
  1627. that.getValidCell = getValid;
  1628. that.scroll = scroll;
  1629. // Protected overrides
  1630. that._generateContent = function () {
  1631. var lbl,
  1632. html = '',
  1633. l = 0;
  1634. $.each(s.wheels, function (i, wg) { // Wheel groups
  1635. html += '<div class="mbsc-w-p dwc' + (s.mode != 'scroller' ? ' dwpm' : ' dwsc') + (s.showLabel ? '' : ' dwhl') + '">' +
  1636. '<div class="dwwc"' + (s.maxWidth ? '' : ' style="max-width:600px;"') + '>' +
  1637. (hasFlex ? '' : '<table class="dw-tbl" cellpadding="0" cellspacing="0"><tr>');
  1638. $.each(wg, function (j, w) { // Wheels
  1639. wheels[l] = w;
  1640. lbl = w.label !== undefined ? w.label : j;
  1641. html += '<' + (hasFlex ? 'div' : 'td') + ' class="dwfl"' + ' style="' +
  1642. (s.fixedWidth ? ('width:' + (s.fixedWidth[l] || s.fixedWidth) + 'px;') :
  1643. (s.minWidth ? ('min-width:' + (s.minWidth[l] || s.minWidth) + 'px;') : 'min-width:' + s.width + 'px;') +
  1644. (s.maxWidth ? ('max-width:' + (s.maxWidth[l] || s.maxWidth) + 'px;') : '')) + '">' +
  1645. '<div class="dwwl dwwl' + l + (w.multiple ? ' dwwms' : '') + '">' +
  1646. (s.mode != 'scroller' ?
  1647. '<div class="dwb-e dwwb dwwbp ' + (s.btnPlusClass || '') + '" style="height:' + itemHeight + 'px;line-height:' + itemHeight + 'px;"><span>+</span></div>' + // + button
  1648. '<div class="dwb-e dwwb dwwbm ' + (s.btnMinusClass || '') + '" style="height:' + itemHeight + 'px;line-height:' + itemHeight + 'px;"><span>&ndash;</span></div>' : '') + // - button
  1649. '<div class="dwl">' + lbl + '</div>' + // Wheel label
  1650. '<div tabindex="0" aria-live="off" aria-label="' + lbl + '" role="listbox" class="dwww">' +
  1651. '<div class="dww" style="height:' + (s.rows * itemHeight) + 'px;">' +
  1652. '<div class="dw-ul" style="margin-top:' + (w.multiple ? (s.mode == 'scroller' ? 0 : itemHeight) : s.rows / 2 * itemHeight - itemHeight / 2) + 'px;">';
  1653. // Create wheel values
  1654. html += generateWheelItems(l) +
  1655. '</div></div><div class="dwwo"></div></div><div class="dwwol"' +
  1656. (s.selectedLineHeight ? ' style="height:' + itemHeight + 'px;margin-top:-' + (itemHeight / 2 + (s.selectedLineBorder || 0)) + 'px;"' : '') + '></div></div>' +
  1657. (hasFlex ? '</div>' : '</td>');
  1658. l++;
  1659. });
  1660. html += (hasFlex ? '' : '</tr></table>') + '</div></div>';
  1661. });
  1662. return html;
  1663. };
  1664. that._attachEvents = function ($markup) {
  1665. $markup
  1666. .on('keydown', '.dwwl', onKeyDown)
  1667. .on('keyup', '.dwwl', onKeyUp)
  1668. .on('touchstart mousedown', '.dwwl', onStart)
  1669. .on('touchmove', '.dwwl', onMove)
  1670. .on('touchend', '.dwwl', onEnd)
  1671. .on('touchstart mousedown', '.dwwb', onBtnStart)
  1672. .on('touchend touchcancel', '.dwwb', onBtnEnd);
  1673. if (s.mousewheel) {
  1674. $markup.on('wheel mousewheel', '.dwwl', onScroll);
  1675. }
  1676. };
  1677. that._markupReady = function ($m) {
  1678. $markup = $m;
  1679. pixels = {};
  1680. scrollToPos();
  1681. };
  1682. that._fillValue = function () {
  1683. that._hasValue = true;
  1684. setValue(true, true, 0, true);
  1685. };
  1686. that._readValue = function () {
  1687. var v = $elm.val() || '';
  1688. if (v !== '') {
  1689. that._hasValue = true;
  1690. }
  1691. that._tempWheelArray = that._hasValue && that._wheelArray ? that._wheelArray.slice(0) : s.parseValue.call(el, v, that) || [];
  1692. setValue();
  1693. };
  1694. that._processSettings = function () {
  1695. s = that.settings;
  1696. trigger = that.trigger;
  1697. itemHeight = s.height;
  1698. lines = s.multiline;
  1699. that._isLiquid = (s.layout || (/top|bottom/.test(s.display) && s.wheels.length == 1 ? 'liquid' : '')) === 'liquid';
  1700. // @deprecated since 2.15.0, backward compatibility code
  1701. // ---
  1702. if (s.formatResult) {
  1703. s.formatValue = s.formatResult;
  1704. }
  1705. // ---
  1706. if (lines > 1) {
  1707. s.cssClass = (s.cssClass || '') + ' dw-ml';
  1708. }
  1709. // Ensure a minimum number of 3 items if clickpick buttons present
  1710. if (s.mode != 'scroller') {
  1711. s.rows = Math.max(3, s.rows);
  1712. }
  1713. };
  1714. // Properties
  1715. that._selectedValues = {};
  1716. // Constructor
  1717. if (!inherit) {
  1718. that.init(settings);
  1719. }
  1720. };
  1721. // Extend defaults
  1722. classes.Scroller.prototype = {
  1723. _hasDef: true,
  1724. _hasTheme: true,
  1725. _hasLang: true,
  1726. _hasPreset: true,
  1727. _class: 'scroller',
  1728. _defaults: $.extend({}, classes.Frame.prototype._defaults, {
  1729. // Options
  1730. minWidth: 80,
  1731. height: 40,
  1732. rows: 3,
  1733. multiline: 1,
  1734. delay: 300,
  1735. readonly: false,
  1736. showLabel: false,
  1737. confirmOnTap: true,
  1738. wheels: [],
  1739. mode: 'scroller',
  1740. preset: '',
  1741. speedUnit: 0.0012,
  1742. timeUnit: 0.08,
  1743. formatValue: function (d) {
  1744. return d.join(' ');
  1745. },
  1746. parseValue: function (value, inst) {
  1747. var val = [],
  1748. ret = [],
  1749. i = 0,
  1750. found,
  1751. keys;
  1752. if (value !== null && value !== undefined) {
  1753. val = (value + '').split(' ');
  1754. }
  1755. $.each(inst.settings.wheels, function (j, wg) {
  1756. $.each(wg, function (k, w) {
  1757. keys = w.keys || w.values;
  1758. found = keys[0]; // Default to first wheel value if not found
  1759. $.each(keys, function (l, key) {
  1760. if (val[i] == key) { // Don't do strict comparison
  1761. found = key;
  1762. return false;
  1763. }
  1764. });
  1765. ret.push(found);
  1766. i++;
  1767. });
  1768. });
  1769. return ret;
  1770. }
  1771. })
  1772. };
  1773. ms.themes.scroller = ms.themes.frame;
  1774. })(jQuery, window, document);
  1775. //**mobiscroll.util.datetime.js
  1776. (function ($, undefined) {
  1777. var ms = $.mobiscroll;
  1778. ms.datetime = {
  1779. defaults: {
  1780. shortYearCutoff: '+10',
  1781. monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  1782. monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  1783. dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  1784. dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  1785. dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  1786. amText: 'am',
  1787. pmText: 'pm',
  1788. getYear: function (d) { return d.getFullYear(); },
  1789. getMonth: function (d) { return d.getMonth(); },
  1790. getDay: function (d) { return d.getDate(); },
  1791. getDate: function (y, m, d, h, i, s, u) { return new Date(y, m, d, h || 0, i || 0, s || 0, u || 0); },
  1792. getMaxDayOfMonth: function (y, m) { return 32 - new Date(y, m, 32).getDate(); },
  1793. getWeekNumber: function (d) {
  1794. // Copy date so don't modify original
  1795. d = new Date(d);
  1796. d.setHours(0, 0, 0);
  1797. // Set to nearest Thursday: current date + 4 - current day number
  1798. // Make Sunday's day number 7
  1799. d.setDate(d.getDate() + 4 - (d.getDay() || 7));
  1800. // Get first day of year
  1801. var yearStart = new Date(d.getFullYear(), 0, 1);
  1802. // Calculate full weeks to nearest Thursday
  1803. return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
  1804. }
  1805. },
  1806. /**
  1807. * Format a date into a string value with a specified format.
  1808. * @param {String} format Output format.
  1809. * @param {Date} date Date to format.
  1810. * @param {Object} [settings={}] Settings.
  1811. * @return {String} Returns the formatted date string.
  1812. */
  1813. formatDate: function (format, date, settings) {
  1814. if (!date) {
  1815. return null;
  1816. }
  1817. var s = $.extend({}, ms.datetime.defaults, settings),
  1818. look = function (m) { // Check whether a format character is doubled
  1819. var n = 0;
  1820. while (i + 1 < format.length && format.charAt(i + 1) == m) {
  1821. n++;
  1822. i++;
  1823. }
  1824. return n;
  1825. },
  1826. f1 = function (m, val, len) { // Format a number, with leading zero if necessary
  1827. var n = '' + val;
  1828. if (look(m)) {
  1829. while (n.length < len) {
  1830. n = '0' + n;
  1831. }
  1832. }
  1833. return n;
  1834. },
  1835. f2 = function (m, val, s, l) { // Format a name, short or long as requested
  1836. return (look(m) ? l[val] : s[val]);
  1837. },
  1838. i,
  1839. year,
  1840. output = '',
  1841. literal = false;
  1842. for (i = 0; i < format.length; i++) {
  1843. if (literal) {
  1844. if (format.charAt(i) == "'" && !look("'")) {
  1845. literal = false;
  1846. } else {
  1847. output += format.charAt(i);
  1848. }
  1849. } else {
  1850. switch (format.charAt(i)) {
  1851. case 'd':
  1852. output += f1('d', s.getDay(date), 2);
  1853. break;
  1854. case 'D':
  1855. output += f2('D', date.getDay(), s.dayNamesShort, s.dayNames);
  1856. break;
  1857. case 'o':
  1858. output += f1('o', (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
  1859. break;
  1860. case 'm':
  1861. output += f1('m', s.getMonth(date) + 1, 2);
  1862. break;
  1863. case 'M':
  1864. output += f2('M', s.getMonth(date), s.monthNamesShort, s.monthNames);
  1865. break;
  1866. case 'y':
  1867. year = s.getYear(date);
  1868. output += (look('y') ? year : (year % 100 < 10 ? '0' : '') + year % 100);
  1869. //output += (look('y') ? date.getFullYear() : (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
  1870. break;
  1871. case 'h':
  1872. var h = date.getHours();
  1873. output += f1('h', (h > 12 ? (h - 12) : (h === 0 ? 12 : h)), 2);
  1874. break;
  1875. case 'H':
  1876. output += f1('H', date.getHours(), 2);
  1877. break;
  1878. case 'i':
  1879. output += f1('i', date.getMinutes(), 2);
  1880. break;
  1881. case 's':
  1882. output += f1('s', date.getSeconds(), 2);
  1883. break;
  1884. case 'a':
  1885. output += date.getHours() > 11 ? s.pmText : s.amText;
  1886. break;
  1887. case 'A':
  1888. output += date.getHours() > 11 ? s.pmText.toUpperCase() : s.amText.toUpperCase();
  1889. break;
  1890. case "'":
  1891. if (look("'")) {
  1892. output += "'";
  1893. } else {
  1894. literal = true;
  1895. }
  1896. break;
  1897. default:
  1898. output += format.charAt(i);
  1899. }
  1900. }
  1901. }
  1902. return output;
  1903. },
  1904. /**
  1905. * Extract a date from a string value with a specified format.
  1906. * @param {String} format Input format.
  1907. * @param {String} value String to parse.
  1908. * @param {Object} [settings={}] Settings.
  1909. * @return {Date} Returns the extracted date.
  1910. */
  1911. parseDate: function (format, value, settings) {
  1912. var s = $.extend({}, ms.datetime.defaults, settings),
  1913. def = s.defaultValue || new Date();
  1914. if (!format || !value) {
  1915. return def;
  1916. }
  1917. // If already a date object
  1918. if (value.getTime) {
  1919. return value;
  1920. }
  1921. value = (typeof value == 'object' ? value.toString() : value + '');
  1922. var shortYearCutoff = s.shortYearCutoff,
  1923. year = s.getYear(def),
  1924. month = s.getMonth(def) + 1,
  1925. day = s.getDay(def),
  1926. doy = -1,
  1927. hours = def.getHours(),
  1928. minutes = def.getMinutes(),
  1929. seconds = 0, //def.getSeconds(),
  1930. ampm = -1,
  1931. literal = false, // Check whether a format character is doubled
  1932. lookAhead = function (match) {
  1933. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  1934. if (matches) {
  1935. iFormat++;
  1936. }
  1937. return matches;
  1938. },
  1939. getNumber = function (match) { // Extract a number from the string value
  1940. lookAhead(match);
  1941. var size = (match == '@' ? 14 : (match == '!' ? 20 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)))),
  1942. digits = new RegExp('^\\d{1,' + size + '}'),
  1943. num = value.substr(iValue).match(digits);
  1944. if (!num) {
  1945. return 0;
  1946. }
  1947. iValue += num[0].length;
  1948. return parseInt(num[0], 10);
  1949. },
  1950. getName = function (match, s, l) { // Extract a name from the string value and convert to an index
  1951. var names = (lookAhead(match) ? l : s),
  1952. i;
  1953. for (i = 0; i < names.length; i++) {
  1954. if (value.substr(iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) {
  1955. iValue += names[i].length;
  1956. return i + 1;
  1957. }
  1958. }
  1959. return 0;
  1960. },
  1961. checkLiteral = function () {
  1962. iValue++;
  1963. },
  1964. iValue = 0,
  1965. iFormat;
  1966. for (iFormat = 0; iFormat < format.length; iFormat++) {
  1967. if (literal) {
  1968. if (format.charAt(iFormat) == "'" && !lookAhead("'")) {
  1969. literal = false;
  1970. } else {
  1971. checkLiteral();
  1972. }
  1973. } else {
  1974. switch (format.charAt(iFormat)) {
  1975. case 'd':
  1976. day = getNumber('d');
  1977. break;
  1978. case 'D':
  1979. getName('D', s.dayNamesShort, s.dayNames);
  1980. break;
  1981. case 'o':
  1982. doy = getNumber('o');
  1983. break;
  1984. case 'm':
  1985. month = getNumber('m');
  1986. break;
  1987. case 'M':
  1988. month = getName('M', s.monthNamesShort, s.monthNames);
  1989. break;
  1990. case 'y':
  1991. year = getNumber('y');
  1992. break;
  1993. case 'H':
  1994. hours = getNumber('H');
  1995. break;
  1996. case 'h':
  1997. hours = getNumber('h');
  1998. break;
  1999. case 'i':
  2000. minutes = getNumber('i');
  2001. break;
  2002. case 's':
  2003. seconds = getNumber('s');
  2004. break;
  2005. case 'a':
  2006. ampm = getName('a', [s.amText, s.pmText], [s.amText, s.pmText]) - 1;
  2007. break;
  2008. case 'A':
  2009. ampm = getName('A', [s.amText, s.pmText], [s.amText, s.pmText]) - 1;
  2010. break;
  2011. case "'":
  2012. if (lookAhead("'")) {
  2013. checkLiteral();
  2014. } else {
  2015. literal = true;
  2016. }
  2017. break;
  2018. default:
  2019. checkLiteral();
  2020. }
  2021. }
  2022. }
  2023. if (year < 100) {
  2024. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  2025. (year <= (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)) ? 0 : -100);
  2026. }
  2027. if (doy > -1) {
  2028. month = 1;
  2029. day = doy;
  2030. do {
  2031. var dim = 32 - new Date(year, month - 1, 32).getDate();
  2032. if (day <= dim) {
  2033. break;
  2034. }
  2035. month++;
  2036. day -= dim;
  2037. } while (true);
  2038. }
  2039. hours = (ampm == -1) ? hours : ((ampm && hours < 12) ? (hours + 12) : (!ampm && hours == 12 ? 0 : hours));
  2040. var date = s.getDate(year, month - 1, day, hours, minutes, seconds);
  2041. if (s.getYear(date) != year || s.getMonth(date) + 1 != month || s.getDay(date) != day) {
  2042. return def; // Invalid date
  2043. }
  2044. return date;
  2045. }
  2046. };
  2047. // @deprecated since 2.11.0, backward compatibility code
  2048. // ---
  2049. ms.formatDate = ms.datetime.formatDate;
  2050. ms.parseDate = ms.datetime.parseDate;
  2051. // ---
  2052. })(jQuery);
  2053. //**mobiscroll.datetimebase.js
  2054. (function ($, undefined) {
  2055. var ms = $.mobiscroll,
  2056. datetime = ms.datetime,
  2057. date = new Date(),
  2058. defaults = {
  2059. startYear: date.getFullYear() - 100,
  2060. endYear: date.getFullYear() + 1,
  2061. separator: ' ',
  2062. // Localization
  2063. dateFormat: 'mm/dd/yy',
  2064. dateOrder: 'mmddy',
  2065. timeWheels: 'hhiiA',
  2066. timeFormat: 'hh:ii A',
  2067. dayText: 'Day',
  2068. monthText: 'Month',
  2069. yearText: 'Year',
  2070. hourText: 'Hours',
  2071. minuteText: 'Minutes',
  2072. ampmText: '&nbsp;',
  2073. secText: 'Seconds',
  2074. nowText: 'Now'
  2075. },
  2076. /**
  2077. * @class Mobiscroll.datetime
  2078. * @extends Mobiscroll
  2079. * Mobiscroll Datetime component
  2080. */
  2081. preset = function (inst) {
  2082. var that = $(this),
  2083. html5def = {},
  2084. format;
  2085. // Force format for html5 date inputs (experimental)
  2086. if (that.is('input')) {
  2087. switch (that.attr('type')) {
  2088. case 'date':
  2089. format = 'yy-mm-dd';
  2090. break;
  2091. case 'datetime':
  2092. format = 'yy-mm-ddTHH:ii:ssZ';
  2093. break;
  2094. case 'datetime-local':
  2095. format = 'yy-mm-ddTHH:ii:ss';
  2096. break;
  2097. case 'month':
  2098. format = 'yy-mm';
  2099. html5def.dateOrder = 'mmyy';
  2100. break;
  2101. case 'time':
  2102. format = 'HH:ii:ss';
  2103. break;
  2104. }
  2105. // Check for min/max attributes
  2106. var min = that.attr('min'),
  2107. max = that.attr('max');
  2108. if (min) {
  2109. html5def.minDate = datetime.parseDate(format, min);
  2110. }
  2111. if (max) {
  2112. html5def.maxDate = datetime.parseDate(format, max);
  2113. }
  2114. }
  2115. // Set year-month-day order
  2116. var i,
  2117. k,
  2118. keys,
  2119. values,
  2120. wg,
  2121. start,
  2122. end,
  2123. hasTime,
  2124. mins,
  2125. maxs,
  2126. orig = $.extend({}, inst.settings),
  2127. s = $.extend(inst.settings, ms.datetime.defaults, defaults, html5def, orig),
  2128. offset = 0,
  2129. validValues = [],
  2130. wheels = [],
  2131. ord = [],
  2132. o = {},
  2133. innerValues = {},
  2134. f = {
  2135. y: getYear,
  2136. m: getMonth,
  2137. d: getDay,
  2138. h: getHour,
  2139. i: getMinute,
  2140. s: getSecond,
  2141. u: getMillisecond,
  2142. a: getAmPm
  2143. },
  2144. invalid = s.invalid,
  2145. valid = s.valid,
  2146. p = s.preset,
  2147. dord = s.dateOrder,
  2148. tord = s.timeWheels,
  2149. regen = dord.match(/D/),
  2150. ampm = tord.match(/a/i),
  2151. hampm = tord.match(/h/),
  2152. hformat = p == 'datetime' ? s.dateFormat + s.separator + s.timeFormat : p == 'time' ? s.timeFormat : s.dateFormat,
  2153. defd = new Date(),
  2154. steps = s.steps || {},
  2155. stepH = steps.hour || s.stepHour || 1,
  2156. stepM = steps.minute || s.stepMinute || 1,
  2157. stepS = steps.second || s.stepSecond || 1,
  2158. zeroBased = steps.zeroBased,
  2159. mind = s.minDate || new Date(s.startYear, 0, 1),
  2160. maxd = s.maxDate || new Date(s.endYear, 11, 31, 23, 59, 59),
  2161. minH = zeroBased ? 0 : mind.getHours() % stepH,
  2162. minM = zeroBased ? 0 : mind.getMinutes() % stepM,
  2163. minS = zeroBased ? 0 : mind.getSeconds() % stepS,
  2164. maxH = getMax(stepH, minH, (hampm ? 11 : 23)),
  2165. maxM = getMax(stepM, minM, 59),
  2166. maxS = getMax(stepM, minM, 59);
  2167. format = format || hformat;
  2168. if (p.match(/date/i)) {
  2169. // Determine the order of year, month, day wheels
  2170. $.each(['y', 'm', 'd'], function (j, v) {
  2171. i = dord.search(new RegExp(v, 'i'));
  2172. if (i > -1) {
  2173. ord.push({
  2174. o: i,
  2175. v: v
  2176. });
  2177. }
  2178. });
  2179. ord.sort(function (a, b) {
  2180. return a.o > b.o ? 1 : -1;
  2181. });
  2182. $.each(ord, function (i, v) {
  2183. o[v.v] = i;
  2184. });
  2185. wg = [];
  2186. for (k = 0; k < 3; k++) {
  2187. if (k == o.y) {
  2188. offset++;
  2189. values = [];
  2190. keys = [];
  2191. start = s.getYear(mind);
  2192. end = s.getYear(maxd);
  2193. for (i = start; i <= end; i++) {
  2194. keys.push(i);
  2195. values.push((dord.match(/yy/i) ? i : (i + '').substr(2, 2)) + (s.yearSuffix || ''));
  2196. }
  2197. addWheel(wg, keys, values, s.yearText);
  2198. } else if (k == o.m) {
  2199. offset++;
  2200. values = [];
  2201. keys = [];
  2202. for (i = 0; i < 12; i++) {
  2203. var str = dord.replace(/[dy]/gi, '').replace(/mm/, (i < 9 ? '0' + (i + 1) : i + 1) + (s.monthSuffix || '')).replace(/m/, i + 1 + (s.monthSuffix || ''));
  2204. keys.push(i);
  2205. values.push(str.match(/MM/) ? str.replace(/MM/, '<span class="dw-mon">' + s.monthNames[i] + '</span>') : str.replace(/M/, '<span class="dw-mon">' + s.monthNamesShort[i] + '</span>'));
  2206. }
  2207. addWheel(wg, keys, values, s.monthText);
  2208. } else if (k == o.d) {
  2209. offset++;
  2210. values = [];
  2211. keys = [];
  2212. for (i = 1; i < 32; i++) {
  2213. keys.push(i);
  2214. values.push((dord.match(/dd/i) && i < 10 ? '0' + i : i) + (s.daySuffix || ''));
  2215. }
  2216. addWheel(wg, keys, values, s.dayText);
  2217. }
  2218. }
  2219. wheels.push(wg);
  2220. }
  2221. if (p.match(/time/i)) {
  2222. hasTime = true;
  2223. // Determine the order of hours, minutes, seconds wheels
  2224. ord = [];
  2225. $.each(['h', 'i', 's', 'a'], function (i, v) {
  2226. i = tord.search(new RegExp(v, 'i'));
  2227. if (i > -1) {
  2228. ord.push({
  2229. o: i,
  2230. v: v
  2231. });
  2232. }
  2233. });
  2234. ord.sort(function (a, b) {
  2235. return a.o > b.o ? 1 : -1;
  2236. });
  2237. $.each(ord, function (i, v) {
  2238. o[v.v] = offset + i;
  2239. });
  2240. wg = [];
  2241. for (k = offset; k < offset + 4; k++) {
  2242. if (k == o.h) {
  2243. offset++;
  2244. values = [];
  2245. keys = [];
  2246. for (i = minH; i < (hampm ? 12 : 24); i += stepH) {
  2247. keys.push(i);
  2248. values.push(hampm && i === 0 ? 12 : tord.match(/hh/i) && i < 10 ? '0' + i : i);
  2249. }
  2250. addWheel(wg, keys, values, s.hourText);
  2251. } else if (k == o.i) {
  2252. offset++;
  2253. values = [];
  2254. keys = [];
  2255. for (i = minM; i < 60; i += stepM) {
  2256. keys.push(i);
  2257. values.push(tord.match(/ii/) && i < 10 ? '0' + i : i);
  2258. }
  2259. addWheel(wg, keys, values, s.minuteText);
  2260. } else if (k == o.s) {
  2261. offset++;
  2262. values = [];
  2263. keys = [];
  2264. for (i = minS; i < 60; i += stepS) {
  2265. keys.push(i);
  2266. values.push(tord.match(/ss/) && i < 10 ? '0' + i : i);
  2267. }
  2268. addWheel(wg, keys, values, s.secText);
  2269. } else if (k == o.a) {
  2270. offset++;
  2271. var upper = tord.match(/A/);
  2272. addWheel(wg, [0, 1], upper ? [s.amText.toUpperCase(), s.pmText.toUpperCase()] : [s.amText, s.pmText], s.ampmText);
  2273. }
  2274. }
  2275. wheels.push(wg);
  2276. }
  2277. function get(d, i, def) {
  2278. if (o[i] !== undefined) {
  2279. return +d[o[i]];
  2280. }
  2281. if (innerValues[i] !== undefined) {
  2282. return innerValues[i];
  2283. }
  2284. if (def !== undefined) {
  2285. return def;
  2286. }
  2287. return f[i](defd);
  2288. }
  2289. function addWheel(wg, k, v, lbl) {
  2290. wg.push({
  2291. values: v,
  2292. keys: k,
  2293. label: lbl
  2294. });
  2295. }
  2296. function step(v, st, min, max) {
  2297. return Math.min(max, Math.floor(v / st) * st + min);
  2298. }
  2299. function getYear(d) {
  2300. return s.getYear(d);
  2301. }
  2302. function getMonth(d) {
  2303. return s.getMonth(d);
  2304. }
  2305. function getDay(d) {
  2306. return s.getDay(d);
  2307. }
  2308. function getHour(d) {
  2309. var hour = d.getHours();
  2310. hour = hampm && hour >= 12 ? hour - 12 : hour;
  2311. return step(hour, stepH, minH, maxH);
  2312. }
  2313. function getMinute(d) {
  2314. return step(d.getMinutes(), stepM, minM, maxM);
  2315. }
  2316. function getSecond(d) {
  2317. return step(d.getSeconds(), stepS, minS, maxS);
  2318. }
  2319. function getMillisecond(d) {
  2320. return d.getMilliseconds();
  2321. }
  2322. function getAmPm(d) {
  2323. return ampm && d.getHours() > 11 ? 1 : 0;
  2324. }
  2325. function getDate(d) {
  2326. if (d === null) {
  2327. return d;
  2328. }
  2329. var year = get(d, 'y'),
  2330. month = get(d, 'm'),
  2331. day = Math.min(get(d, 'd'), s.getMaxDayOfMonth(year, month)),
  2332. hour = get(d, 'h', 0);
  2333. return s.getDate(year, month, day, get(d, 'a', 0) ? hour + 12 : hour, get(d, 'i', 0), get(d, 's', 0), get(d, 'u', 0));
  2334. }
  2335. function getMax(step, min, max) {
  2336. return Math.floor((max - min) / step) * step + min;
  2337. }
  2338. function getClosestValidDate(d, dir) {
  2339. var next,
  2340. prev,
  2341. nextValid = false,
  2342. prevValid = false,
  2343. up = 0,
  2344. down = 0;
  2345. // Normalize min and max dates for comparing later (set default values where there are no values from wheels)
  2346. mind = getDate(getArray(mind));
  2347. maxd = getDate(getArray(maxd));
  2348. if (isValid(d)) {
  2349. return d;
  2350. }
  2351. if (d < mind) {
  2352. d = mind;
  2353. }
  2354. if (d > maxd) {
  2355. d = maxd;
  2356. }
  2357. next = d;
  2358. prev = d;
  2359. if (dir !== 2) {
  2360. nextValid = isValid(next);
  2361. while (!nextValid && next < maxd) {
  2362. next = new Date(next.getTime() + 1000 * 60 * 60 * 24);
  2363. nextValid = isValid(next);
  2364. up++;
  2365. }
  2366. }
  2367. if (dir !== 1) {
  2368. prevValid = isValid(prev);
  2369. while (!prevValid && prev > mind) {
  2370. prev = new Date(prev.getTime() - 1000 * 60 * 60 * 24);
  2371. prevValid = isValid(prev);
  2372. down++;
  2373. }
  2374. }
  2375. if (dir === 1 && nextValid) {
  2376. return next;
  2377. }
  2378. if (dir === 2 && prevValid) {
  2379. return prev;
  2380. }
  2381. return down <= up && prevValid ? prev : next;
  2382. }
  2383. function isValid(d) {
  2384. if (d < mind) {
  2385. return false;
  2386. }
  2387. if (d > maxd) {
  2388. return false;
  2389. }
  2390. if (isInObj(d, valid)) {
  2391. return true;
  2392. }
  2393. if (isInObj(d, invalid)) {
  2394. return false;
  2395. }
  2396. return true;
  2397. }
  2398. function isInObj(d, obj) {
  2399. var curr,
  2400. j,
  2401. v;
  2402. if (obj) {
  2403. for (j = 0; j < obj.length; j++) {
  2404. curr = obj[j];
  2405. v = curr + '';
  2406. if (!curr.start) {
  2407. if (curr.getTime) { // Exact date
  2408. if (d.getFullYear() == curr.getFullYear() && d.getMonth() == curr.getMonth() && d.getDate() == curr.getDate()) {
  2409. return true;
  2410. }
  2411. } else if (!v.match(/w/i)) { // Day of month
  2412. v = v.split('/');
  2413. if (v[1]) {
  2414. if ((v[0] - 1) == d.getMonth() && v[1] == d.getDate()) {
  2415. return true;
  2416. }
  2417. } else if (v[0] == d.getDate()) {
  2418. return true;
  2419. }
  2420. } else { // Day of week
  2421. v = +v.replace('w', '');
  2422. if (v == d.getDay()) {
  2423. return true;
  2424. }
  2425. }
  2426. }
  2427. }
  2428. }
  2429. return false;
  2430. }
  2431. function validateDates(obj, y, m, first, maxdays, idx, val) {
  2432. var j, d, v;
  2433. if (obj) {
  2434. for (j = 0; j < obj.length; j++) {
  2435. d = obj[j];
  2436. v = d + '';
  2437. if (!d.start) {
  2438. if (d.getTime) { // Exact date
  2439. if (s.getYear(d) == y && s.getMonth(d) == m) {
  2440. idx[s.getDay(d) - 1] = val;
  2441. }
  2442. } else if (!v.match(/w/i)) { // Day of month
  2443. v = v.split('/');
  2444. if (v[1]) {
  2445. if (v[0] - 1 == m) {
  2446. idx[v[1] - 1] = val;
  2447. }
  2448. } else {
  2449. idx[v[0] - 1] = val;
  2450. }
  2451. } else { // Day of week
  2452. v = +v.replace('w', '');
  2453. for (k = v - first; k < maxdays; k += 7) {
  2454. if (k >= 0) {
  2455. idx[k] = val;
  2456. }
  2457. }
  2458. }
  2459. }
  2460. }
  2461. }
  2462. }
  2463. function validateTimes(vobj, i, v, temp, y, m, d, target, valid) {
  2464. var dd, ss, str, parts1, parts2, prop1, prop2, v1, v2, j, i1, i2, add, remove, all, hours1, hours2, hours3,
  2465. spec = {},
  2466. steps = {
  2467. h: stepH,
  2468. i: stepM,
  2469. s: stepS,
  2470. a: 1
  2471. },
  2472. day = s.getDate(y, m, d),
  2473. w = ['a', 'h', 'i', 's'];
  2474. if (vobj) {
  2475. $.each(vobj, function (i, obj) {
  2476. if (obj.start) {
  2477. obj.apply = false;
  2478. dd = obj.d;
  2479. ss = dd + '';
  2480. str = ss.split('/');
  2481. if (dd && ((dd.getTime && y == s.getYear(dd) && m == s.getMonth(dd) && d == s.getDay(dd)) || // Exact date
  2482. (!ss.match(/w/i) && ((str[1] && d == str[1] && m == str[0] - 1) || (!str[1] && d == str[0]))) || // Day of month
  2483. (ss.match(/w/i) && day.getDay() == +ss.replace('w', '')) // Day of week
  2484. )) {
  2485. obj.apply = true;
  2486. spec[day] = true; // Prevent applying generic rule on day, if specific exists
  2487. }
  2488. }
  2489. });
  2490. $.each(vobj, function (x, obj) {
  2491. add = 0;
  2492. remove = 0;
  2493. i1 = 0;
  2494. i2 = undefined;
  2495. prop1 = true;
  2496. prop2 = true;
  2497. all = false;
  2498. if (obj.start && (obj.apply || (!obj.d && !spec[day]))) {
  2499. // Define time parts
  2500. parts1 = obj.start.split(':');
  2501. parts2 = obj.end.split(':');
  2502. for (j = 0; j < 3; j++) {
  2503. if (parts1[j] === undefined) {
  2504. parts1[j] = 0;
  2505. }
  2506. if (parts2[j] === undefined) {
  2507. parts2[j] = 59;
  2508. }
  2509. parts1[j] = +parts1[j];
  2510. parts2[j] = +parts2[j];
  2511. }
  2512. parts1.unshift(parts1[0] > 11 ? 1 : 0);
  2513. parts2.unshift(parts2[0] > 11 ? 1 : 0);
  2514. if (hampm) {
  2515. if (parts1[1] >= 12) {
  2516. parts1[1] = parts1[1] - 12;
  2517. }
  2518. if (parts2[1] >= 12) {
  2519. parts2[1] = parts2[1] - 12;
  2520. }
  2521. }
  2522. // Look behind
  2523. for (j = 0; j < i; j++) {
  2524. if (validValues[j] !== undefined) {
  2525. v1 = step(parts1[j], steps[w[j]], mins[w[j]], maxs[w[j]]);
  2526. v2 = step(parts2[j], steps[w[j]], mins[w[j]], maxs[w[j]]);
  2527. hours1 = 0;
  2528. hours2 = 0;
  2529. hours3 = 0;
  2530. if (hampm && j == 1) {
  2531. hours1 = parts1[0] ? 12 : 0;
  2532. hours2 = parts2[0] ? 12 : 0;
  2533. hours3 = validValues[0] ? 12 : 0;
  2534. }
  2535. if (!prop1) {
  2536. v1 = 0;
  2537. }
  2538. if (!prop2) {
  2539. v2 = maxs[w[j]];
  2540. }
  2541. if ((prop1 || prop2) && (v1 + hours1 < validValues[j] + hours3 && validValues[j] + hours3 < v2 + hours2)) {
  2542. all = true;
  2543. }
  2544. if (validValues[j] != v1) {
  2545. prop1 = false;
  2546. }
  2547. if (validValues[j] != v2) {
  2548. prop2 = false;
  2549. }
  2550. }
  2551. }
  2552. // Look ahead
  2553. if (!valid) {
  2554. for (j = i + 1; j < 4; j++) {
  2555. if (parts1[j] > 0) {
  2556. add = steps[v];
  2557. }
  2558. if (parts2[j] < maxs[w[j]]) {
  2559. remove = steps[v];
  2560. }
  2561. }
  2562. }
  2563. if (!all) {
  2564. // Calculate min and max values
  2565. v1 = step(parts1[i], steps[v], mins[v], maxs[v]) + add;
  2566. v2 = step(parts2[i], steps[v], mins[v], maxs[v]) - remove;
  2567. if (prop1) {
  2568. i1 = getValidIndex(target, v1, maxs[v], 0);
  2569. }
  2570. if (prop2) {
  2571. i2 = getValidIndex(target, v2, maxs[v], 1);
  2572. }
  2573. }
  2574. // Disable values
  2575. if (prop1 || prop2 || all) {
  2576. if (valid) {
  2577. $('.dw-li', target).slice(i1, i2).addClass('dw-v');
  2578. } else {
  2579. $('.dw-li', target).slice(i1, i2).removeClass('dw-v');
  2580. }
  2581. }
  2582. }
  2583. });
  2584. }
  2585. }
  2586. function getIndex(t, v) {
  2587. return $('.dw-li', t).index($('.dw-li[data-val="' + v + '"]', t));
  2588. }
  2589. function getValidIndex(t, v, max, add) {
  2590. if (v < 0) {
  2591. return 0;
  2592. }
  2593. if (v > max) {
  2594. return $('.dw-li', t).length;
  2595. }
  2596. return getIndex(t, v) + add;
  2597. }
  2598. function getArray(d, fillInner) {
  2599. var ret = [];
  2600. if (d === null || d === undefined) {
  2601. return d;
  2602. }
  2603. $.each(['y', 'm', 'd', 'a', 'h', 'i', 's', 'u'], function (x, i) {
  2604. if (o[i] !== undefined) {
  2605. ret[o[i]] = f[i](d);
  2606. }
  2607. if (fillInner) {
  2608. innerValues[i] = f[i](d);
  2609. }
  2610. });
  2611. return ret;
  2612. }
  2613. function convertRanges(arr) {
  2614. var i, v, start,
  2615. ret = [];
  2616. if (arr) {
  2617. for (i = 0; i < arr.length; i++) {
  2618. v = arr[i];
  2619. if (v.start && v.start.getTime) {
  2620. start = new Date(v.start);
  2621. while (start <= v.end) {
  2622. ret.push(new Date(start.getFullYear(), start.getMonth(), start.getDate()));
  2623. start.setDate(start.getDate() + 1);
  2624. }
  2625. } else {
  2626. ret.push(v);
  2627. }
  2628. }
  2629. return ret;
  2630. }
  2631. return arr;
  2632. }
  2633. // Extended methods
  2634. // ---
  2635. inst.getVal = function (temp) {
  2636. return inst._hasValue || temp ? getDate(inst.getArrayVal(temp)) : null;
  2637. };
  2638. /**
  2639. * Sets the selected date
  2640. *
  2641. * @param {Date} d Date to select.
  2642. * @param {Boolean} [fill=false] Also set the value of the associated input element. Default is true.
  2643. * @param {Number} [time=0] Animation time to scroll to the selected date.
  2644. * @param {Boolean} [temp=false] Set temporary value only.
  2645. * @param {Boolean} [change=fill] Trigger change on input element.
  2646. */
  2647. inst.setDate = function (d, fill, time, temp, change) {
  2648. inst.setArrayVal(getArray(d), fill, change, temp, time);
  2649. };
  2650. /**
  2651. * Returns the selected date.
  2652. *
  2653. * @param {Boolean} [temp=false] If true, return the currently shown date on the picker, otherwise the last selected one.
  2654. * @return {Date}
  2655. */
  2656. inst.getDate = inst.getVal;
  2657. // ---
  2658. // Initializations
  2659. // ---
  2660. inst.format = hformat;
  2661. inst.order = o;
  2662. inst.handlers.now = function () {
  2663. inst.setDate(new Date(), false, 0.3, true, true);
  2664. };
  2665. inst.buttons.now = {
  2666. text: s.nowText,
  2667. handler: 'now'
  2668. };
  2669. invalid = convertRanges(invalid);
  2670. valid = convertRanges(valid);
  2671. mins = {
  2672. y: mind.getFullYear(),
  2673. m: 0,
  2674. d: 1,
  2675. h: minH,
  2676. i: minM,
  2677. s: minS,
  2678. a: 0
  2679. };
  2680. maxs = {
  2681. y: maxd.getFullYear(),
  2682. m: 11,
  2683. d: 31,
  2684. h: maxH,
  2685. i: maxM,
  2686. s: maxS,
  2687. a: 1
  2688. };
  2689. // ---
  2690. return {
  2691. wheels: wheels,
  2692. headerText: s.headerText ? function () {
  2693. return datetime.formatDate(hformat, getDate(inst.getArrayVal(true)), s);
  2694. } : false,
  2695. formatValue: function (d) {
  2696. return datetime.formatDate(format, getDate(d), s);
  2697. },
  2698. parseValue: function (val) {
  2699. if (!val) {
  2700. innerValues = {};
  2701. }
  2702. return getArray(val ? datetime.parseDate(format, val, s) : (s.defaultValue || new Date()), !!val && !!val.getTime);
  2703. },
  2704. validate: function (dw, i, time, dir) {
  2705. var validated = getClosestValidDate(getDate(inst.getArrayVal(true)), dir),
  2706. temp = getArray(validated),
  2707. y = get(temp, 'y'),
  2708. m = get(temp, 'm'),
  2709. minprop = true,
  2710. maxprop = true;
  2711. $.each(['y', 'm', 'd', 'a', 'h', 'i', 's'], function (x, i) {
  2712. if (o[i] !== undefined) {
  2713. var min = mins[i],
  2714. max = maxs[i],
  2715. maxdays = 31,
  2716. val = get(temp, i),
  2717. t = $('.dw-ul', dw).eq(o[i]);
  2718. if (i == 'd') {
  2719. maxdays = s.getMaxDayOfMonth(y, m);
  2720. max = maxdays;
  2721. if (regen) {
  2722. $('.dw-li', t).each(function () {
  2723. var that = $(this),
  2724. d = that.data('val'),
  2725. w = s.getDate(y, m, d).getDay(),
  2726. str = dord.replace(/[my]/gi, '').replace(/dd/, (d < 10 ? '0' + d : d) + (s.daySuffix || '')).replace(/d/, d + (s.daySuffix || ''));
  2727. $('.dw-i', that).html(str.match(/DD/) ? str.replace(/DD/, '<span class="dw-day">' + s.dayNames[w] + '</span>') : str.replace(/D/, '<span class="dw-day">' + s.dayNamesShort[w] + '</span>'));
  2728. });
  2729. }
  2730. }
  2731. if (minprop && mind) {
  2732. min = f[i](mind);
  2733. }
  2734. if (maxprop && maxd) {
  2735. max = f[i](maxd);
  2736. }
  2737. if (i != 'y') {
  2738. var i1 = getIndex(t, min),
  2739. i2 = getIndex(t, max);
  2740. $('.dw-li', t).removeClass('dw-v').slice(i1, i2 + 1).addClass('dw-v');
  2741. if (i == 'd') { // Hide days not in month
  2742. $('.dw-li', t).removeClass('dw-h').slice(maxdays).addClass('dw-h');
  2743. }
  2744. }
  2745. if (val < min) {
  2746. val = min;
  2747. }
  2748. if (val > max) {
  2749. val = max;
  2750. }
  2751. if (minprop) {
  2752. minprop = val == min;
  2753. }
  2754. if (maxprop) {
  2755. maxprop = val == max;
  2756. }
  2757. // Disable some days
  2758. if (i == 'd') {
  2759. var first = s.getDate(y, m, 1).getDay(),
  2760. idx = {};
  2761. // Set invalid indexes
  2762. validateDates(invalid, y, m, first, maxdays, idx, 1);
  2763. // Delete indexes which are valid
  2764. validateDates(valid, y, m, first, maxdays, idx, 0);
  2765. $.each(idx, function (i, v) {
  2766. if (v) {
  2767. $('.dw-li', t).eq(i).removeClass('dw-v');
  2768. }
  2769. });
  2770. }
  2771. }
  2772. });
  2773. // Invalid times
  2774. if (hasTime) {
  2775. $.each(['a', 'h', 'i', 's'], function (i, v) {
  2776. var val = get(temp, v),
  2777. d = get(temp, 'd'),
  2778. t = $('.dw-ul', dw).eq(o[v]);
  2779. if (o[v] !== undefined) {
  2780. validateTimes(invalid, i, v, temp, y, m, d, t, 0);
  2781. validateTimes(valid, i, v, temp, y, m, d, t, 1);
  2782. // Get valid value
  2783. validValues[i] = +inst.getValidCell(val, t, dir).val;
  2784. }
  2785. });
  2786. }
  2787. inst._tempWheelArray = temp;
  2788. }
  2789. };
  2790. };
  2791. $.each(['date', 'time', 'datetime'], function (i, v) {
  2792. ms.presets.scroller[v] = preset;
  2793. });
  2794. })(jQuery);
  2795. //**mobiscroll.datetime.js
  2796. (function ($) {
  2797. $.each(['date', 'time', 'datetime'], function (i, v) {
  2798. $.mobiscroll.presetShort(v);
  2799. });
  2800. })(jQuery);
  2801. //**mobiscroll.select.js
  2802. (function ($, undefined) {
  2803. var ms = $.mobiscroll,
  2804. util = ms.util,
  2805. isString = util.isString,
  2806. defaults = {
  2807. batch: 40,
  2808. inputClass: '',
  2809. invalid: [],
  2810. rtl: false,
  2811. showInput: true,
  2812. groupLabel: 'Groups',
  2813. checkIcon: 'checkmark',
  2814. dataText: 'text',
  2815. dataValue: 'value',
  2816. dataGroup: 'group',
  2817. dataDisabled: 'disabled'
  2818. };
  2819. ms.presetShort('select');
  2820. ms.presets.scroller.select = function (inst) {
  2821. var change,
  2822. defaultValue,
  2823. group,
  2824. groupArray,
  2825. groupChanged,
  2826. groupTap,
  2827. groupWheelIdx,
  2828. i,
  2829. input,
  2830. optionArray,
  2831. optionWheelIdx,
  2832. option,
  2833. origValues,
  2834. prevGroup,
  2835. timer,
  2836. batchChanged = {},
  2837. batchStart = {},
  2838. batchEnd = {},
  2839. tempBatchStart = {},
  2840. tempBatchEnd = {},
  2841. orig = $.extend({}, inst.settings),
  2842. s = $.extend(inst.settings, defaults, orig),
  2843. batch = s.batch,
  2844. layout = s.layout || (/top|bottom/.test(s.display) ? 'liquid' : ''),
  2845. isLiquid = layout == 'liquid',
  2846. elm = $(this),
  2847. multiple = s.multiple || elm.prop('multiple'),
  2848. maxSelect = util.isNumeric(s.multiple) ? s.multiple : Infinity,
  2849. id = this.id + '_dummy',
  2850. lbl = $('label[for="' + this.id + '"]').attr('for', id),
  2851. label = s.label !== undefined ? s.label : (lbl.length ? lbl.text() : elm.attr('name')),
  2852. selectedClass = 'dw-msel mbsc-ic mbsc-ic-' + s.checkIcon,
  2853. origReadOnly = s.readonly,
  2854. data = s.data,
  2855. hasData = !!data,
  2856. hasGroups = hasData ? !!s.group : $('optgroup', elm).length,
  2857. groupSetup = s.group,
  2858. groupWheel = hasGroups && groupSetup && groupSetup.groupWheel !== false,
  2859. groupSep = hasGroups && groupSetup && groupWheel && groupSetup.clustered === true,
  2860. groupHdr = hasGroups && (!groupSetup || (groupSetup.header !== false && !groupSep)),
  2861. values = elm.val() || [],
  2862. invalid = [],
  2863. selectedValues = {},
  2864. options = {},
  2865. groups = {};
  2866. function prepareData() {
  2867. var gr,
  2868. lbl,
  2869. opt,
  2870. txt,
  2871. val,
  2872. l = 0,
  2873. c = 0,
  2874. groupIndexes = {};
  2875. options = {};
  2876. groups = {};
  2877. optionArray = [];
  2878. groupArray = [];
  2879. // Reset invalids
  2880. invalid.length = 0;
  2881. if (hasData) {
  2882. $.each(s.data, function (i, v) {
  2883. txt = v[s.dataText];
  2884. val = v[s.dataValue];
  2885. lbl = v[s.dataGroup];
  2886. opt = {
  2887. value: val,
  2888. text: txt,
  2889. index: i
  2890. };
  2891. options[val] = opt;
  2892. optionArray.push(opt);
  2893. if (hasGroups) {
  2894. if (groupIndexes[lbl] === undefined) {
  2895. gr = {
  2896. text: lbl,
  2897. value: c,
  2898. options: [],
  2899. index: c
  2900. };
  2901. groups[c] = gr;
  2902. groupIndexes[lbl] = c;
  2903. groupArray.push(gr);
  2904. c++;
  2905. } else {
  2906. gr = groups[groupIndexes[lbl]];
  2907. }
  2908. if (groupSep) {
  2909. opt.index = gr.options.length;
  2910. }
  2911. opt.group = groupIndexes[lbl];
  2912. gr.options.push(opt);
  2913. }
  2914. if (v[s.dataDisabled]) {
  2915. invalid.push(val);
  2916. }
  2917. });
  2918. } else {
  2919. if (hasGroups) {
  2920. $('optgroup', elm).each(function (i) {
  2921. groups[i] = {
  2922. text: this.label,
  2923. value: i,
  2924. options: [],
  2925. index: i
  2926. };
  2927. groupArray.push(groups[i]);
  2928. $('option', this).each(function (j) {
  2929. opt = {
  2930. value: this.value,
  2931. text: this.text,
  2932. index: groupSep ? j : l++,
  2933. group: i
  2934. };
  2935. options[this.value] = opt;
  2936. optionArray.push(opt);
  2937. groups[i].options.push(opt);
  2938. if (this.disabled) {
  2939. invalid.push(this.value);
  2940. }
  2941. });
  2942. });
  2943. } else {
  2944. $('option', elm).each(function (i) {
  2945. opt = {
  2946. value: this.value,
  2947. text: this.text,
  2948. index: i
  2949. };
  2950. options[this.value] = opt;
  2951. optionArray.push(opt);
  2952. if (this.disabled) {
  2953. invalid.push(this.value);
  2954. }
  2955. });
  2956. }
  2957. }
  2958. if (optionArray.length) {
  2959. defaultValue = optionArray[0].value;
  2960. }
  2961. if (groupHdr) {
  2962. optionArray = [];
  2963. l = 0;
  2964. $.each(groups, function (i, gr) {
  2965. val = '__group' + i;
  2966. opt = {
  2967. text: gr.text,
  2968. value: val,
  2969. group: i,
  2970. index: l++
  2971. };
  2972. options[val] = opt;
  2973. optionArray.push(opt);
  2974. invalid.push(opt.value);
  2975. $.each(gr.options, function (j, opt) {
  2976. opt.index = l++;
  2977. optionArray.push(opt);
  2978. });
  2979. });
  2980. }
  2981. }
  2982. function genValues(w, data, dataMap, value, index, multiple, label) {
  2983. var i,
  2984. wheel,
  2985. keys = [],
  2986. values = [],
  2987. selectedIndex = dataMap[value] !== undefined ? dataMap[value].index : 0,
  2988. start = Math.max(0, selectedIndex - batch),
  2989. end = Math.min(data.length - 1, start + batch * 2);
  2990. if (batchStart[index] !== start || batchEnd[index] !== end) {
  2991. for (i = start; i <= end; i++) {
  2992. values.push(data[i].text);
  2993. keys.push(data[i].value);
  2994. }
  2995. batchChanged[index] = true;
  2996. tempBatchStart[index] = start;
  2997. tempBatchEnd[index] = end;
  2998. wheel = {
  2999. multiple: multiple,
  3000. values: values,
  3001. keys: keys,
  3002. label: label
  3003. };
  3004. if (isLiquid) {
  3005. w[0][index] = wheel;
  3006. } else {
  3007. w[index] = [wheel];
  3008. }
  3009. } else {
  3010. batchChanged[index] = false;
  3011. }
  3012. }
  3013. function genGroupWheel(w) {
  3014. genValues(w, groupArray, groups, group, groupWheelIdx, false, s.groupLabel);
  3015. }
  3016. function genOptWheel(w) {
  3017. genValues(w, groupSep ? groups[group].options : optionArray, options, option, optionWheelIdx, multiple, label);
  3018. }
  3019. function genWheels() {
  3020. var w = [
  3021. []
  3022. ];
  3023. if (groupWheel) {
  3024. genGroupWheel(w);
  3025. }
  3026. genOptWheel(w);
  3027. return w;
  3028. }
  3029. function getOption(v) {
  3030. if (multiple) {
  3031. if (v && isString(v)) {
  3032. v = v.split(',');
  3033. }
  3034. if ($.isArray(v)) {
  3035. v = v[0];
  3036. }
  3037. }
  3038. option = v === undefined || v === null || v === '' || !options[v] ? defaultValue : v;
  3039. if (groupWheel) {
  3040. group = options[option] ? options[option].group : null;
  3041. prevGroup = group;
  3042. }
  3043. }
  3044. function getVal(temp, group) {
  3045. var val = temp ? inst._tempWheelArray : (inst._hasValue ? inst._wheelArray : null);
  3046. return val ? (s.group && group ? val : val[optionWheelIdx]) : null;
  3047. }
  3048. function onFill() {
  3049. var txt,
  3050. val,
  3051. sel = [],
  3052. i = 0;
  3053. if (multiple) {
  3054. val = [];
  3055. for (i in selectedValues) {
  3056. sel.push(options[i] ? options[i].text : '');
  3057. val.push(i);
  3058. }
  3059. txt = sel.join(', ');
  3060. } else {
  3061. val = option;
  3062. txt = options[option] ? options[option].text : '';
  3063. }
  3064. inst._tempValue = val;
  3065. input.val(txt);
  3066. elm.val(val);
  3067. }
  3068. function onTap(li) {
  3069. var val = li.attr('data-val'),
  3070. selected = li.hasClass('dw-msel');
  3071. if (multiple && li.closest('.dwwl').hasClass('dwwms')) {
  3072. if (li.hasClass('dw-v')) {
  3073. if (selected) {
  3074. li.removeClass(selectedClass).removeAttr('aria-selected');
  3075. delete selectedValues[val];
  3076. } else if (util.objectToArray(selectedValues).length < maxSelect) {
  3077. li.addClass(selectedClass).attr('aria-selected', 'true');
  3078. selectedValues[val] = val;
  3079. }
  3080. }
  3081. return false;
  3082. } else if (li.hasClass('dw-w-gr')) {
  3083. groupTap = li.attr('data-val');
  3084. }
  3085. }
  3086. if (!s.invalid.length) {
  3087. s.invalid = invalid;
  3088. }
  3089. if (groupWheel) {
  3090. groupWheelIdx = 0;
  3091. optionWheelIdx = 1;
  3092. } else {
  3093. groupWheelIdx = -1;
  3094. optionWheelIdx = 0;
  3095. }
  3096. if (multiple) {
  3097. elm.prop('multiple', true);
  3098. if (values && isString(values)) {
  3099. values = values.split(',');
  3100. }
  3101. for (i = 0; i < values.length; i++) {
  3102. selectedValues[values[i]] = values[i];
  3103. }
  3104. }
  3105. prepareData();
  3106. getOption(elm.val());
  3107. $('#' + id).remove();
  3108. if (elm.next().is('input.mbsc-control')) {
  3109. input = elm.off('.mbsc-form').next().removeAttr('tabindex');
  3110. } else {
  3111. input = $('<input type="text" id="' + id + '" class="mbsc-control mbsc-control-ev ' + s.inputClass + '" readonly />');
  3112. if (s.showInput) {
  3113. input.insertBefore(elm);
  3114. }
  3115. }
  3116. inst.attachShow(input.attr('placeholder', s.placeholder || ''));
  3117. elm.addClass('dw-hsel').attr('tabindex', -1).closest('.ui-field-contain').trigger('create');
  3118. onFill();
  3119. // Extended methods
  3120. // ---
  3121. inst.setVal = function (val, fill, change, temp, time) {
  3122. if (multiple) {
  3123. if (val && isString(val)) {
  3124. val = val.split(',');
  3125. }
  3126. selectedValues = util.arrayToObject(val);
  3127. val = val ? val[0] : null;
  3128. }
  3129. inst._setVal(val, fill, change, temp, time);
  3130. };
  3131. inst.getVal = function (temp, group) {
  3132. if (multiple) {
  3133. return util.objectToArray(selectedValues);
  3134. }
  3135. return getVal(temp, group);
  3136. };
  3137. inst.refresh = function () {
  3138. prepareData();
  3139. batchStart = {};
  3140. batchEnd = {};
  3141. s.wheels = genWheels();
  3142. batchStart[groupWheelIdx] = tempBatchStart[groupWheelIdx];
  3143. batchEnd[groupWheelIdx] = tempBatchEnd[groupWheelIdx];
  3144. batchStart[optionWheelIdx] = tempBatchStart[optionWheelIdx];
  3145. batchEnd[optionWheelIdx] = tempBatchEnd[optionWheelIdx];
  3146. // Prevent wheel generation on initial validation
  3147. change = true;
  3148. getOption(option);
  3149. inst._tempWheelArray = groupWheel ? [group, option] : [option];
  3150. if (inst._isVisible) {
  3151. inst.changeWheel(groupWheel ? [groupWheelIdx, optionWheelIdx] : [optionWheelIdx]);
  3152. }
  3153. };
  3154. // @deprecated since 2.14.0, backward compatibility code
  3155. // ---
  3156. inst.getValues = inst.getVal;
  3157. inst.getValue = getVal;
  3158. // ---
  3159. // ---
  3160. return {
  3161. width: 50,
  3162. layout: layout,
  3163. headerText: false,
  3164. anchor: input,
  3165. confirmOnTap: groupWheel ? [false, true] : true,
  3166. formatValue: function (d) {
  3167. var i,
  3168. opt,
  3169. sel = [];
  3170. if (multiple) {
  3171. for (i in selectedValues) {
  3172. sel.push(options[i] ? options[i].text : '');
  3173. }
  3174. return sel.join(', ');
  3175. }
  3176. opt = d[optionWheelIdx];
  3177. return options[opt] ? options[opt].text : '';
  3178. },
  3179. parseValue: function (val) {
  3180. getOption(val === undefined ? elm.val() : val);
  3181. return groupWheel ? [group, option] : [option];
  3182. },
  3183. onValueTap: onTap,
  3184. onValueFill: onFill,
  3185. onBeforeShow: function () {
  3186. if (multiple && s.counter) {
  3187. s.headerText = function () {
  3188. var length = 0;
  3189. $.each(selectedValues, function () {
  3190. length++;
  3191. });
  3192. return (length > 1 ? s.selectedPluralText || s.selectedText : s.selectedText).replace(/{count}/, length);
  3193. };
  3194. }
  3195. getOption(elm.val());
  3196. if (groupWheel) {
  3197. inst._tempWheelArray = [group, option];
  3198. }
  3199. inst.refresh();
  3200. },
  3201. onMarkupReady: function (dw) {
  3202. dw.addClass('dw-select');
  3203. $('.dwwl' + groupWheelIdx, dw).on('mousedown touchstart', function () {
  3204. clearTimeout(timer);
  3205. });
  3206. $('.dwwl' + optionWheelIdx, dw).on('mousedown touchstart', function () {
  3207. if (!groupChanged) {
  3208. clearTimeout(timer);
  3209. }
  3210. });
  3211. if (groupHdr) {
  3212. $('.dwwl' + optionWheelIdx, dw).addClass('dw-select-gr');
  3213. }
  3214. if (multiple) {
  3215. dw.addClass('dwms');
  3216. $('.dwwl', dw).on('keydown', function (e) {
  3217. if (e.keyCode == 32) { // Space
  3218. e.preventDefault();
  3219. e.stopPropagation();
  3220. onTap($('.dw-sel', this));
  3221. }
  3222. }).eq(optionWheelIdx).attr('aria-multiselectable', 'true');
  3223. origValues = $.extend({}, selectedValues);
  3224. }
  3225. },
  3226. validate: function (dw, i, time, dir) {
  3227. var j,
  3228. v,
  3229. changes = [],
  3230. temp = inst.getArrayVal(true),
  3231. tempGr = temp[groupWheelIdx],
  3232. tempOpt = temp[optionWheelIdx],
  3233. t1 = $('.dw-ul', dw).eq(groupWheelIdx),
  3234. t2 = $('.dw-ul', dw).eq(optionWheelIdx);
  3235. if (batchStart[groupWheelIdx] > 1) {
  3236. $('.dw-li', t1).slice(0, 2).removeClass('dw-v').addClass('dw-fv');
  3237. }
  3238. if (batchEnd[groupWheelIdx] < groupArray.length - 2) {
  3239. $('.dw-li', t1).slice(-2).removeClass('dw-v').addClass('dw-fv');
  3240. }
  3241. if (batchStart[optionWheelIdx] > 1) {
  3242. $('.dw-li', t2).slice(0, 2).removeClass('dw-v').addClass('dw-fv');
  3243. }
  3244. if (batchEnd[optionWheelIdx] < (groupSep ? groups[tempGr].options : optionArray).length - 2) {
  3245. $('.dw-li', t2).slice(-2).removeClass('dw-v').addClass('dw-fv');
  3246. }
  3247. if (!change) {
  3248. option = tempOpt;
  3249. if (groupWheel) {
  3250. group = options[option].group;
  3251. // If group changed, load group options
  3252. if (i === undefined || i === groupWheelIdx) {
  3253. group = +temp[groupWheelIdx];
  3254. groupChanged = false;
  3255. if (group !== prevGroup) {
  3256. option = groups[group].options[0].value;
  3257. batchStart[optionWheelIdx] = null;
  3258. batchEnd[optionWheelIdx] = null;
  3259. groupChanged = true;
  3260. s.readonly = [false, true];
  3261. } else {
  3262. s.readonly = origReadOnly;
  3263. }
  3264. }
  3265. }
  3266. // Adjust value to the first group option if group header was selected
  3267. if (hasGroups && (/__group/.test(option) || groupTap)) {
  3268. option = groups[options[groupTap || option].group].options[0].value;
  3269. tempOpt = option;
  3270. groupTap = false;
  3271. }
  3272. // Update values if changed
  3273. // Don't set the new option yet (if group changed), because it's not on the wheel yet
  3274. inst._tempWheelArray = groupWheel ? [tempGr, tempOpt] : [tempOpt];
  3275. // Generate new wheel batches
  3276. if (groupWheel) {
  3277. genGroupWheel(s.wheels);
  3278. if (batchChanged[groupWheelIdx]) {
  3279. changes.push(groupWheelIdx);
  3280. }
  3281. }
  3282. genOptWheel(s.wheels);
  3283. if (batchChanged[optionWheelIdx]) {
  3284. changes.push(optionWheelIdx);
  3285. }
  3286. clearTimeout(timer);
  3287. timer = setTimeout(function () {
  3288. if (changes.length) {
  3289. change = true;
  3290. groupChanged = false;
  3291. prevGroup = group;
  3292. // Save current batch boundaries
  3293. batchStart[groupWheelIdx] = tempBatchStart[groupWheelIdx];
  3294. batchEnd[groupWheelIdx] = tempBatchEnd[groupWheelIdx];
  3295. batchStart[optionWheelIdx] = tempBatchStart[optionWheelIdx];
  3296. batchEnd[optionWheelIdx] = tempBatchEnd[optionWheelIdx];
  3297. // Set the updated values
  3298. inst._tempWheelArray = groupWheel ? [tempGr, option] : [option];
  3299. // Change the wheels
  3300. inst.changeWheel(changes, 0, i !== undefined);
  3301. }
  3302. if (groupWheel) {
  3303. if (i === optionWheelIdx) {
  3304. inst.scroll(t1, groupWheelIdx, inst.getValidCell(group, t1, dir, false, true).v, 0.1);
  3305. }
  3306. inst._tempWheelArray[groupWheelIdx] = group;
  3307. }
  3308. // Restore readonly status
  3309. s.readonly = origReadOnly;
  3310. }, i === undefined ? 100 : time * 1000);
  3311. if (changes.length) {
  3312. return groupChanged ? false : true;
  3313. }
  3314. }
  3315. // Add selected styling to selected elements in case of multiselect
  3316. if (i === undefined && multiple) {
  3317. v = selectedValues;
  3318. j = 0;
  3319. $('.dwwl' + optionWheelIdx + ' .dw-li', dw).removeClass(selectedClass).removeAttr('aria-selected');
  3320. for (j in v) {
  3321. $('.dwwl' + optionWheelIdx + ' .dw-li[data-val="' + v[j] + '"]', dw).addClass(selectedClass).attr('aria-selected', 'true');
  3322. }
  3323. }
  3324. // Add styling to group headers
  3325. if (groupHdr) {
  3326. $('.dw-li[data-val^="__group"]', dw).addClass('dw-w-gr');
  3327. }
  3328. // Disable invalid options
  3329. $.each(s.invalid, function (i, v) {
  3330. $('.dw-li[data-val="' + v + '"]', t2).removeClass('dw-v dw-fv');
  3331. });
  3332. change = false;
  3333. },
  3334. onValidated: function () {
  3335. option = inst._tempWheelArray[optionWheelIdx];
  3336. },
  3337. onClear: function (dw) {
  3338. selectedValues = {};
  3339. input.val('');
  3340. $('.dwwl' + optionWheelIdx + ' .dw-li', dw).removeClass(selectedClass).removeAttr('aria-selected');
  3341. },
  3342. onCancel: function () {
  3343. if (!inst.live && multiple) {
  3344. selectedValues = $.extend({}, origValues);
  3345. }
  3346. },
  3347. onDestroy: function () {
  3348. if (!input.hasClass('mbsc-control')) {
  3349. input.remove();
  3350. }
  3351. elm.removeClass('dw-hsel').removeAttr('tabindex');
  3352. }
  3353. };
  3354. };
  3355. })(jQuery);
  3356. //**mobiscroll.listbase.js
  3357. (function ($, undefined) {
  3358. var ms = $.mobiscroll,
  3359. defaults = {
  3360. invalid: [],
  3361. showInput: true,
  3362. inputClass: ''
  3363. };
  3364. ms.presets.scroller.list = function (inst) {
  3365. var orig = $.extend({}, inst.settings),
  3366. s = $.extend(inst.settings, defaults, orig),
  3367. layout = s.layout || (/top|bottom/.test(s.display) ? 'liquid' : ''),
  3368. isLiquid = layout == 'liquid',
  3369. origReadOnly = s.readonly,
  3370. elm = $(this),
  3371. input,
  3372. prevent,
  3373. id = this.id + '_dummy',
  3374. lvl = 0,
  3375. ilvl = 0,
  3376. timer = {},
  3377. currLevel,
  3378. currWheelVector = [],
  3379. wa = s.wheelArray || createWheelArray(elm),
  3380. labels = generateLabels(lvl),
  3381. fwv = firstWheelVector(wa),
  3382. w = generateWheelsFromVector(fwv, lvl);
  3383. /**
  3384. * Disables the invalid items on the wheels
  3385. * @param {Object} dw - the jQuery mobiscroll object
  3386. * @param {Number} nrWheels - the number of the current wheels
  3387. * @param {Array} whArray - The wheel array objects containing the wheel tree
  3388. * @param {Array} whVector - the wheel vector containing the current keys
  3389. */
  3390. function setDisabled(dw, nrWheels, whArray, whVector) {
  3391. var j,
  3392. i = 0;
  3393. while (i < nrWheels) {
  3394. var currWh = $('.dwwl' + i, dw),
  3395. inv = getInvalidKeys(whVector, i, whArray);
  3396. for (j = 0; j < inv.length; j++) {
  3397. $('.dw-li[data-val="' + inv[j] + '"]', currWh).removeClass('dw-v');
  3398. }
  3399. i++;
  3400. }
  3401. }
  3402. /**
  3403. * Returns the invalid keys of one wheel as an array
  3404. * @param {Array} whVector - the wheel vector used to search for the wheel in the wheel array
  3405. * @param {Number} index - index of the wheel in the wheel vector, that we are interested in
  3406. * @param {Array} whArray - the wheel array we are searching in
  3407. * @return {Array} - list of invalid keys
  3408. */
  3409. function getInvalidKeys(whVector, index, whArray) {
  3410. var i = 0,
  3411. n,
  3412. whObjA = whArray,
  3413. invalids = [];
  3414. while (i < index) {
  3415. var ii = whVector[i];
  3416. //whObjA = whObjA[ii].children;
  3417. for (n in whObjA) {
  3418. if (whObjA[n].key == ii) {
  3419. whObjA = whObjA[n].children;
  3420. break;
  3421. }
  3422. }
  3423. i++;
  3424. }
  3425. i = 0;
  3426. while (i < whObjA.length) {
  3427. if (whObjA[i].invalid) {
  3428. invalids.push(whObjA[i].key);
  3429. }
  3430. i++;
  3431. }
  3432. return invalids;
  3433. }
  3434. /**
  3435. * Creates a Boolean vector with true values (except one) that can be used as the readonly vector
  3436. * n - the length of the vector
  3437. * i - the index of the value that's going to be false
  3438. */
  3439. function createROVector(n, i) {
  3440. var a = [];
  3441. while (n) {
  3442. a[--n] = true;
  3443. }
  3444. a[i] = false;
  3445. return a;
  3446. }
  3447. /**
  3448. * Creates a labels vector, from values if they are defined, otherwise from numbers
  3449. * l - the length of the vector
  3450. */
  3451. function generateLabels(l) {
  3452. var a = [],
  3453. i;
  3454. for (i = 0; i < l; i++) {
  3455. a[i] = s.labels && s.labels[i] ? s.labels[i] : i;
  3456. }
  3457. return a;
  3458. }
  3459. /**
  3460. * Creates the wheel array from the vector provided
  3461. * wv - wheel vector containing the values that should be selected on the wheels
  3462. * l - the length of the wheel array
  3463. */
  3464. function generateWheelsFromVector(wv, l, index) {
  3465. var i = 0,
  3466. j, obj, chInd,
  3467. w = [
  3468. []
  3469. ],
  3470. wtObjA = wa;
  3471. if (l) { // if length is defined we need to generate that many wheels (even if they are empty)
  3472. for (j = 0; j < l; j++) {
  3473. if (isLiquid) {
  3474. w[0][j] = {};
  3475. } else {
  3476. w[j] = [{}];
  3477. }
  3478. }
  3479. }
  3480. while (i < wv.length) { // we generate the wheels until the length of the wheel vector
  3481. if (isLiquid) {
  3482. w[0][i] = getWheelFromObjA(wtObjA, labels[i]);
  3483. } else {
  3484. w[i] = [getWheelFromObjA(wtObjA, labels[i])];
  3485. }
  3486. j = 0;
  3487. chInd = undefined;
  3488. while (j < wtObjA.length && chInd === undefined) {
  3489. if (wtObjA[j].key == wv[i] && ((index !== undefined && i <= index) || index === undefined)) {
  3490. chInd = j;
  3491. }
  3492. j++;
  3493. }
  3494. if (chInd !== undefined && wtObjA[chInd].children) {
  3495. i++;
  3496. wtObjA = wtObjA[chInd].children;
  3497. } else if ((obj = getFirstValidItemObjOrInd(wtObjA)) && obj.children) {
  3498. i++;
  3499. wtObjA = obj.children;
  3500. } else {
  3501. return w;
  3502. }
  3503. }
  3504. return w;
  3505. }
  3506. /**
  3507. * Returns the first valid Wheel Node Object or its index from a Wheel Node Object Array
  3508. * getInd - if it is true then the return value is going to be the index, otherwise the object itself
  3509. */
  3510. function getFirstValidItemObjOrInd(wtObjA, getInd) {
  3511. if (!wtObjA) {
  3512. return false;
  3513. }
  3514. var i = 0,
  3515. obj;
  3516. while (i < wtObjA.length) {
  3517. if (!(obj = wtObjA[i++]).invalid) {
  3518. return getInd ? i - 1 : obj;
  3519. }
  3520. }
  3521. return false;
  3522. }
  3523. function getWheelFromObjA(objA, lbl) {
  3524. var wheel = {
  3525. keys: [],
  3526. values: [],
  3527. label: lbl
  3528. },
  3529. j = 0;
  3530. while (j < objA.length) {
  3531. wheel.values.push(objA[j].value);
  3532. wheel.keys.push(objA[j].key);
  3533. j++;
  3534. }
  3535. return wheel;
  3536. }
  3537. /**
  3538. * Hides the last i number of wheels
  3539. * i - the last number of wheels that has to be hidden
  3540. */
  3541. function hideWheels(dw, i) {
  3542. $('.dwfl', dw).css('display', '').slice(i).hide();
  3543. }
  3544. /**
  3545. * Generates the first wheel vector from the wheeltree
  3546. * wt - the wheel tree object
  3547. * uses the lvl global variable to determine the length of the vector
  3548. */
  3549. function firstWheelVector(wa) {
  3550. var t = [],
  3551. ndObjA = wa,
  3552. obj,
  3553. ok = true,
  3554. i = 0;
  3555. while (ok) {
  3556. obj = getFirstValidItemObjOrInd(ndObjA);
  3557. t[i++] = obj.key;
  3558. ok = obj.children;
  3559. if (ok) {
  3560. ndObjA = ok;
  3561. }
  3562. }
  3563. return t;
  3564. }
  3565. /**
  3566. * Calculates the level of a wheel vector and the new wheel vector, depending on current wheel vector and the index of the changed wheel
  3567. * wv - current wheel vector
  3568. * index - index of the changed wheel
  3569. */
  3570. function calcLevelOfVector2(wv, index) {
  3571. var t = [],
  3572. ndObjA = wa,
  3573. lvl = 0,
  3574. next = false,
  3575. i,
  3576. childName,
  3577. chInd;
  3578. if (wv[lvl] !== undefined && lvl <= index) {
  3579. i = 0;
  3580. childName = wv[lvl];
  3581. chInd = undefined;
  3582. while (i < ndObjA.length && chInd === undefined) {
  3583. if (ndObjA[i].key == wv[lvl] && !ndObjA[i].invalid) {
  3584. chInd = i;
  3585. }
  3586. i++;
  3587. }
  3588. } else {
  3589. chInd = getFirstValidItemObjOrInd(ndObjA, true);
  3590. childName = ndObjA[chInd].key;
  3591. }
  3592. next = chInd !== undefined ? ndObjA[chInd].children : false;
  3593. t[lvl] = childName;
  3594. while (next) {
  3595. ndObjA = ndObjA[chInd].children;
  3596. lvl++;
  3597. next = false;
  3598. chInd = undefined;
  3599. if (wv[lvl] !== undefined && lvl <= index) {
  3600. i = 0;
  3601. childName = wv[lvl];
  3602. chInd = undefined;
  3603. while (i < ndObjA.length && chInd === undefined) {
  3604. if (ndObjA[i].key == wv[lvl] && !ndObjA[i].invalid) {
  3605. chInd = i;
  3606. }
  3607. i++;
  3608. }
  3609. } else {
  3610. chInd = getFirstValidItemObjOrInd(ndObjA, true);
  3611. chInd = chInd === false ? undefined : chInd;
  3612. childName = ndObjA[chInd].key;
  3613. }
  3614. next = chInd !== undefined && getFirstValidItemObjOrInd(ndObjA[chInd].children) ? ndObjA[chInd].children : false;
  3615. t[lvl] = childName;
  3616. }
  3617. return {
  3618. lvl: lvl + 1,
  3619. nVector: t
  3620. }; // return the calculated level and the wheel vector as an object
  3621. }
  3622. function createWheelArray(ul) {
  3623. var wheelArray = [];
  3624. lvl = lvl > ilvl++ ? lvl : ilvl;
  3625. ul.children('li').each(function (index) {
  3626. var that = $(this),
  3627. c = that.clone();
  3628. c.children('ul,ol').remove();
  3629. var v = inst._processMarkup ? inst._processMarkup(c) : c.html().replace(/^\s\s*/, '').replace(/\s\s*$/, ''),
  3630. inv = that.attr('data-invalid') ? true : false,
  3631. wheelObj = {
  3632. key: that.attr('data-val') === undefined || that.attr('data-val') === null ? index : that.attr('data-val'),
  3633. value: v,
  3634. invalid: inv,
  3635. children: null
  3636. },
  3637. nest = that.children('ul,ol');
  3638. if (nest.length) {
  3639. wheelObj.children = createWheelArray(nest);
  3640. }
  3641. wheelArray.push(wheelObj);
  3642. });
  3643. ilvl--;
  3644. return wheelArray;
  3645. }
  3646. $('#' + id).remove(); // Remove input if exists
  3647. if (s.showInput) {
  3648. input = $('<input type="text" id="' + id + '" value="" class="' + s.inputClass + '" placeholder="' + (s.placeholder || '') + '" readonly />').insertBefore(elm);
  3649. s.anchor = input; // give the core the input element for the bubble positioning
  3650. inst.attachShow(input);
  3651. }
  3652. if (!s.wheelArray) {
  3653. elm.hide().closest('.ui-field-contain').trigger('create');
  3654. }
  3655. return {
  3656. width: 50,
  3657. wheels: w,
  3658. layout: layout,
  3659. headerText: false,
  3660. formatValue: function (d) {
  3661. if (currLevel === undefined) {
  3662. currLevel = calcLevelOfVector2(d, d.length).lvl;
  3663. }
  3664. return d.slice(0, currLevel).join(' ');
  3665. },
  3666. parseValue: function (value) {
  3667. return value ? (value + '').split(' ') : (s.defaultValue || fwv).slice(0);
  3668. },
  3669. onBeforeShow: function () {
  3670. var t = inst.getArrayVal(true);
  3671. currWheelVector = t.slice(0);
  3672. s.wheels = generateWheelsFromVector(t, lvl, lvl);
  3673. prevent = true;
  3674. },
  3675. onValueFill: function (v) {
  3676. currLevel = undefined;
  3677. if (input) {
  3678. input.val(v);
  3679. }
  3680. },
  3681. onShow: function (dw) {
  3682. $('.dwwl', dw).on('mousedown touchstart', function () {
  3683. clearTimeout(timer[$('.dwwl', dw).index(this)]);
  3684. });
  3685. },
  3686. onDestroy: function () {
  3687. if (input) {
  3688. input.remove();
  3689. }
  3690. elm.show();
  3691. },
  3692. validate: function (dw, index, time) {
  3693. var args = [],
  3694. t = inst.getArrayVal(true),
  3695. i = (index || 0) + 1,
  3696. j,
  3697. o;
  3698. if ((index !== undefined && currWheelVector[index] != t[index]) || (index === undefined && !prevent)) {
  3699. s.wheels = generateWheelsFromVector(t, null, index);
  3700. o = calcLevelOfVector2(t, index === undefined ? t.length : index);
  3701. currLevel = o.lvl;
  3702. for (j = 0; j < t.length; j++) {
  3703. t[j] = o.nVector[j] || 0;
  3704. }
  3705. while (i < o.lvl) {
  3706. args.push(i++);
  3707. }
  3708. if (args.length) {
  3709. s.readonly = createROVector(lvl, index);
  3710. clearTimeout(timer[index]);
  3711. timer[index] = setTimeout(function () {
  3712. prevent = true;
  3713. hideWheels(dw, o.lvl);
  3714. currWheelVector = t.slice(0);
  3715. inst.changeWheel(args, index === undefined ? time : 0, index !== undefined);
  3716. s.readonly = origReadOnly;
  3717. }, index === undefined ? 0 : time * 1000);
  3718. return false;
  3719. }
  3720. } else {
  3721. o = calcLevelOfVector2(t, t.length);
  3722. currLevel = o.lvl;
  3723. }
  3724. currWheelVector = t.slice(0);
  3725. setDisabled(dw, o.lvl, wa, t);
  3726. hideWheels(dw, o.lvl);
  3727. prevent = false;
  3728. }
  3729. };
  3730. };
  3731. })(jQuery);
  3732. //**mobiscroll.image.js
  3733. (function ($) {
  3734. var ms = $.mobiscroll,
  3735. presets = ms.presets.scroller;
  3736. ms.presetShort('image');
  3737. presets.image = function (inst) {
  3738. if (inst.settings.enhance) {
  3739. inst._processMarkup = function (li) {
  3740. var hasIcon = li.attr('data-icon');
  3741. li.children().each(function (i, v) {
  3742. v = $(v);
  3743. if (v.is('img')) {
  3744. $('<div class="mbsc-img-c"></div>').insertAfter(v).append(v.addClass('mbsc-img'));
  3745. } else if (v.is('p')) {
  3746. v.addClass('mbsc-img-txt');
  3747. }
  3748. });
  3749. if (hasIcon) {
  3750. li.prepend('<div class="mbsc-ic mbsc-ic-' + hasIcon + '"></div');
  3751. }
  3752. li.html('<div class="mbsc-img-w">' + li.html() + '</div>');
  3753. return li.html();
  3754. };
  3755. }
  3756. return presets.list.call(this, inst);
  3757. };
  3758. })(jQuery);
  3759. //**mobiscroll.treelist.js
  3760. (function ($) {
  3761. var ms = $.mobiscroll,
  3762. presets = ms.presets.scroller;
  3763. presets.treelist = presets.list;
  3764. ms.presetShort('list');
  3765. ms.presetShort('treelist');
  3766. })(jQuery);
  3767. //**mobiscroll.frame.android.js
  3768. (function ($) {
  3769. $.mobiscroll.themes.frame.android = {
  3770. dateOrder: 'Mddyy',
  3771. mode: 'clickpick',
  3772. height: 50,
  3773. showLabel: false,
  3774. btnStartClass: 'mbsc-ic mbsc-ic-play3',
  3775. btnStopClass: 'mbsc-ic mbsc-ic-pause2',
  3776. btnResetClass: 'mbsc-ic mbsc-ic-stop2',
  3777. btnLapClass: 'mbsc-ic mbsc-ic-loop2'
  3778. };
  3779. })(jQuery);
  3780. //**mobiscroll.frame.android-holo.js
  3781. (function ($) {
  3782. var themes = $.mobiscroll.themes.frame,
  3783. theme = {
  3784. dateOrder: 'Mddyy',
  3785. //mode: 'mixed',
  3786. rows: 5,
  3787. minWidth: 76,
  3788. height: 36,
  3789. showLabel: false,
  3790. selectedLineHeight: true,
  3791. selectedLineBorder: 2,
  3792. useShortLabels: true,
  3793. icon: { filled: 'star3', empty: 'star' },
  3794. btnPlusClass: 'mbsc-ic mbsc-ic-arrow-down6',
  3795. btnMinusClass: 'mbsc-ic mbsc-ic-arrow-up6',
  3796. // @deprecated since 2.12.0, backward compatibility code
  3797. // ---
  3798. onThemeLoad: function (lang, s) {
  3799. if (s.theme) {
  3800. s.theme = s.theme.replace('android-ics', 'android-holo');
  3801. }
  3802. },
  3803. // ---
  3804. onMarkupReady: function (markup) {
  3805. markup.addClass('mbsc-android-holo');
  3806. }
  3807. };
  3808. themes['android-holo'] = theme;
  3809. themes['android-holo-light'] = theme;
  3810. // @deprecated since 2.12.0, backward compatibility code
  3811. themes['android-ics'] = theme;
  3812. themes['android-ics light'] = theme;
  3813. themes['android-holo light'] = theme;
  3814. })(jQuery);
  3815. //**i18n/mobiscroll.i18n.zh.js
  3816. (function ($) {
  3817. $.mobiscroll.i18n.zh = {
  3818. // Core
  3819. setText: '确定',
  3820. cancelText: '取消',
  3821. clearText: '明确',
  3822. selectedText: '{count} 选',
  3823. // Datetime component
  3824. dateFormat: 'yy/mm/dd',
  3825. dateOrder: 'yymmdd',
  3826. dayNames: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
  3827. dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
  3828. dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
  3829. dayText: '日',
  3830. hourText: '时',
  3831. minuteText: '分',
  3832. monthNames: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  3833. monthNamesShort: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
  3834. monthText: '月',
  3835. secText: '秒',
  3836. timeFormat: 'HH:ii',
  3837. timeWheels: 'HHii',
  3838. yearText: '年',
  3839. nowText: '当前',
  3840. pmText: '下午',
  3841. amText: '上午',
  3842. // Calendar component
  3843. dateText: '日',
  3844. timeText: '时间',
  3845. calendarText: '日历',
  3846. closeText: '关闭',
  3847. // Daterange component
  3848. fromText: '开始时间',
  3849. toText: '结束时间',
  3850. // Measurement components
  3851. wholeText: '合计',
  3852. fractionText: '分数',
  3853. unitText: '单位',
  3854. // Time / Timespan component
  3855. labels: ['年', '月', '日', '小时', '分钟', '秒', ''],
  3856. labelsShort: ['年', '月', '日', '点', '分', '秒', ''],
  3857. // Timer component
  3858. startText: '开始',
  3859. stopText: '停止',
  3860. resetText: '重置',
  3861. lapText: '圈',
  3862. hideText: '隐藏',
  3863. // Listview
  3864. backText: '背部',
  3865. undoText: '复原',
  3866. // Form
  3867. offText: '关闭',
  3868. onText: '开启',
  3869. // Numpad
  3870. decimalSeparator: ',',
  3871. thousandsSeparator: ' '
  3872. };
  3873. })(jQuery);