No Description

H-ui.js 259KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817
  1. /*-----------H-ui前端框架-------------
  2. * H-ui.js v3.0.2
  3. * http://www.h-ui.net/
  4. * Created & Modified by guojunhui
  5. * Date modified 2017-01.19
  6. *
  7. * Copyright 2013-2017 北京颖杰联创科技有限公司 All rights reserved.
  8. * Licensed under MIT license.
  9. * http://opensource.org/licenses/MIT
  10. */
  11. /*
  12. Includes:
  13. jQuery.IEMobileHack.js
  14. jQuery.cookie.js v1.4.1
  15. jQuery.form.js v3.51.0
  16. jQuery.lazyload.js v1.9.3
  17. jQuery.responsive-nav.js v1.0.39
  18. jQuery.placeholder.js
  19. jQuery.Spinner.js
  20. jQuery.emailsuggest.js v1.0
  21. jQuery.format.js
  22. jQuery.togglePassword.js
  23. jQuery.iCheck.js
  24. jQuery.onePageNav.js
  25. jQuery.stickUp.js
  26. jQuery.HuiaddFavorite.js
  27. jQuery.Huisethome.js
  28. jQuery.Huisidenav.js
  29. jQuery.Huihover.js
  30. jQuery.Huifocusblur.js
  31. jQuery.Huiselect.js
  32. jQuery.Huitab.js
  33. jQuery.Huifold.js
  34. jQuery.Huitags.js
  35. jQuery.Huitagsmixed.js
  36. jQuery.Huitextarealength.js
  37. jQuery.Huipreview.js
  38. jQuery.Huimodalalert.js
  39. jQuery.Huialert.js
  40. jQuery.Huitotop.js
  41. jQuery.Huimarquee.js
  42. Bootstrap.modal.js v3.3.0
  43. Bootstrap.dropdown.js v3.3.0
  44. Bootstrap.transition.js v3.3.0
  45. Bootstrap.tooltip.js v3.3.0
  46. Bootstrap.popover.js v3.3.0
  47. Bootstrap.alert.js v3.3.0
  48. Bootstrap.slider.js v1.0.1
  49. Bootstrap.datetimepicker.js
  50. Bootstrap.Switch v1.3
  51. */
  52. /* =======================================================================
  53. * jQuery.IEMobileHack.js判断浏览器
  54. * ======================================================================== */
  55. !function(){
  56. if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  57. var msViewportStyle = document.createElement("style");
  58. msViewportStyle.appendChild(
  59. document.createTextNode(
  60. "@-ms-viewport{width:auto!important}"
  61. )
  62. );
  63. document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
  64. }
  65. } ();
  66. /* =======================================================================
  67. * jQuery.stopDefault.js 阻止默认浏览器动作
  68. * ======================================================================== */
  69. function stopDefault(e) {
  70. if (e && e.preventDefault) e.preventDefault();
  71. //IE中阻止函数器默认动作的方式
  72. else window.event.returnValue = false;
  73. return false;
  74. }
  75. /* =======================================================================
  76. * jQuery.cookie.js v1.4.1
  77. * https://github.com/carhartl/jQuery-cookie
  78. *
  79. * Copyright 2006, 2014 Klaus Hartl
  80. * Released under the MIT license
  81. * ======================================================================== */
  82. !(function(factory) {
  83. if (typeof define === 'function' && define.amd) {
  84. // AMD (Register as an anonymous module)
  85. define(['jquery'], factory);
  86. } else if (typeof exports === 'object') {
  87. // Node/CommonJS
  88. module.exports = factory(require('jquery'));
  89. } else {
  90. // Browser globals
  91. factory(jQuery);
  92. }
  93. }
  94. (function($){
  95. var pluses = /\+/g;
  96. function encode(s) {
  97. return config.raw ? s : encodeURIComponent(s);
  98. }
  99. function decode(s) {
  100. return config.raw ? s : decodeURIComponent(s);
  101. }
  102. function stringifyCookieValue(value) {
  103. return encode(config.json ? JSON.stringify(value) : String(value));
  104. }
  105. function parseCookieValue(s) {
  106. if (s.indexOf('"') === 0) {
  107. // This is a quoted cookie as according to RFC2068, unescape...
  108. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  109. }
  110. try {
  111. // Replace server-side written pluses with spaces.
  112. // If we can't decode the cookie, ignore it, it's unusable.
  113. // If we can't parse the cookie, ignore it, it's unusable.
  114. s = decodeURIComponent(s.replace(pluses, ' '));
  115. return config.json ? JSON.parse(s) : s;
  116. } catch(e) {}
  117. }
  118. function read(s, converter) {
  119. var value = config.raw ? s: parseCookieValue(s);
  120. return $.isFunction(converter) ? converter(value) : value;
  121. }
  122. var config = $.cookie = function(key, value, options) {
  123. // Write
  124. if (arguments.length > 1 && !$.isFunction(value)) {
  125. options = $.extend({},
  126. config.defaults, options);
  127. if (typeof options.expires === 'number') {
  128. var days = options.expires,
  129. t = options.expires = new Date();
  130. t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
  131. }
  132. return (document.cookie = [encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  133. options.path ? '; path=' + options.path: '', options.domain ? '; domain=' + options.domain: '', options.secure ? '; secure': ''].join(''));
  134. }
  135. // Read
  136. var result = key ? undefined: {},
  137. // To prevent the for loop in the first place assign an empty array
  138. // in case there are no cookies at all. Also prevents odd result when
  139. // calling $.cookie().
  140. cookies = document.cookie ? document.cookie.split('; ') : [],
  141. i = 0,
  142. l = cookies.length;
  143. for (; i < l; i++) {
  144. var parts = cookies[i].split('='),
  145. name = decode(parts.shift()),
  146. cookie = parts.join('=');
  147. if (key === name) {
  148. // If second argument (value) is a function it's a converter...
  149. result = read(cookie, value);
  150. break;
  151. }
  152. // Prevent storing a cookie that we couldn't decode.
  153. if (!key && (cookie = read(cookie)) !== undefined) {
  154. result[name] = cookie;
  155. }
  156. }
  157. return result;
  158. };
  159. config.defaults = {};
  160. $.removeCookie = function(key, options) {
  161. // Must not alter options, thus extending a fresh object...
  162. $.cookie(key, '', $.extend({},
  163. options, {
  164. expires: -1
  165. }));
  166. return ! $.cookie(key);
  167. };
  168. }));
  169. /* =======================================================================
  170. * jQuery.form.js Plugin v3.51.0 2014.06.20
  171. * Requires jQuery v1.5 or later
  172. * Copyright (c) 2014 M. Alsup
  173. * Examples and documentation at: http://malsup.com/jquery/form/
  174. * Project repository: https://github.com/malsup/form
  175. * Dual licensed under the MIT and GPL licenses.
  176. * https://github.com/malsup/form#copyright-and-license
  177. * ======================================================================== */
  178. // AMD support
  179. (function(factory) {
  180. "use strict";
  181. if (typeof define === 'function' && define.amd) {
  182. // using AMD; register as anon module
  183. define(['jquery'], factory);
  184. } else {
  185. // no AMD; invoke directly
  186. factory((typeof(jQuery) != 'undefined') ? jQuery: window.Zepto);
  187. }
  188. } (function($) {
  189. "use strict";
  190. /*
  191. Usage Note:
  192. -----------
  193. Do not use both ajaxSubmit and ajaxForm on the same form. These
  194. functions are mutually exclusive. Use ajaxSubmit if you want
  195. to bind your own submit handler to the form. For example,
  196. $(document).ready(function() {
  197. $('#myForm').on('submit', function(e) {
  198. e.preventDefault(); // <-- important
  199. $(this).ajaxSubmit({
  200. target: '#output'
  201. });
  202. });
  203. });
  204. Use ajaxForm when you want the plugin to manage all the event binding
  205. for you. For example,
  206. $(document).ready(function() {
  207. $('#myForm').ajaxForm({
  208. target: '#output'
  209. });
  210. });
  211. You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
  212. form does not have to exist when you invoke ajaxForm:
  213. $('#myForm').ajaxForm({
  214. delegation: true,
  215. target: '#output'
  216. });
  217. When using ajaxForm, the ajaxSubmit function will be invoked for you
  218. at the appropriate time.
  219. */
  220. /**
  221. * Feature detection
  222. */
  223. var feature = {};
  224. feature.fileapi = $("<input type='file'/>").get(0).files !== undefined;
  225. feature.formdata = window.FormData !== undefined;
  226. var hasProp = !!$.fn.prop;
  227. // attr2 uses prop when it can but checks the return type for
  228. // an expected string. this accounts for the case where a form
  229. // contains inputs with names like "action" or "method"; in those
  230. // cases "prop" returns the element
  231. $.fn.attr2 = function() {
  232. if (!hasProp) {
  233. return this.attr.apply(this, arguments);
  234. }
  235. var val = this.prop.apply(this, arguments);
  236. if ((val && val.jquery) || typeof val === 'string') {
  237. return val;
  238. }
  239. return this.attr.apply(this, arguments);
  240. };
  241. /**
  242. * ajaxSubmit() provides a mechanism for immediately submitting
  243. * an HTML form using AJAX.
  244. */
  245. $.fn.ajaxSubmit = function(options) {
  246. /*jshint scripturl:true */
  247. // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
  248. if (!this.length) {
  249. log('ajaxSubmit: skipping submit process - no element selected');
  250. return this;
  251. }
  252. var method, action, url, $form = this;
  253. if (typeof options == 'function') {
  254. options = {
  255. success: options
  256. };
  257. } else if (options === undefined) {
  258. options = {};
  259. }
  260. method = options.type || this.attr2('method');
  261. action = options.url || this.attr2('action');
  262. url = (typeof action === 'string') ? $.trim(action) : '';
  263. url = url || window.location.href || '';
  264. if (url) {
  265. // clean url (don't include hash vaue)
  266. url = (url.match(/^([^#]+)/) || [])[1];
  267. }
  268. options = $.extend(true, {
  269. url: url,
  270. success: $.ajaxSettings.success,
  271. type: method || $.ajaxSettings.type,
  272. iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false': 'about:blank'
  273. },
  274. options);
  275. // hook for manipulating the form data before it is extracted;
  276. // convenient for use with rich editors like tinyMCE or FCKEditor
  277. var veto = {};
  278. this.trigger('form-pre-serialize', [this, options, veto]);
  279. if (veto.veto) {
  280. log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
  281. return this;
  282. }
  283. // provide opportunity to alter form data before it is serialized
  284. if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
  285. log('ajaxSubmit: submit aborted via beforeSerialize callback');
  286. return this;
  287. }
  288. var traditional = options.traditional;
  289. if (traditional === undefined) {
  290. traditional = $.ajaxSettings.traditional;
  291. }
  292. var elements = [];
  293. var qx, a = this.formToArray(options.semantic, elements);
  294. if (options.data) {
  295. options.extraData = options.data;
  296. qx = $.param(options.data, traditional);
  297. }
  298. // give pre-submit callback an opportunity to abort the submit
  299. if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
  300. log('ajaxSubmit: submit aborted via beforeSubmit callback');
  301. return this;
  302. }
  303. // fire vetoable 'validate' event
  304. this.trigger('form-submit-validate', [a, this, options, veto]);
  305. if (veto.veto) {
  306. log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
  307. return this;
  308. }
  309. var q = $.param(a, traditional);
  310. if (qx) {
  311. q = (q ? (q + '&' + qx) : qx);
  312. }
  313. if (options.type.toUpperCase() == 'GET') {
  314. options.url += (options.url.indexOf('?') >= 0 ? '&': '?') + q;
  315. options.data = null; // data is null for 'get'
  316. } else {
  317. options.data = q; // data is the query string for 'post'
  318. }
  319. var callbacks = [];
  320. if (options.resetForm) {
  321. callbacks.push(function() {
  322. $form.resetForm();
  323. });
  324. }
  325. if (options.clearForm) {
  326. callbacks.push(function() {
  327. $form.clearForm(options.includeHidden);
  328. });
  329. }
  330. // perform a load on the target only if dataType is not provided
  331. if (!options.dataType && options.target) {
  332. var oldSuccess = options.success ||
  333. function() {};
  334. callbacks.push(function(data) {
  335. var fn = options.replaceTarget ? 'replaceWith': 'html';
  336. $(options.target)[fn](data).each(oldSuccess, arguments);
  337. });
  338. } else if (options.success) {
  339. callbacks.push(options.success);
  340. }
  341. options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
  342. var context = options.context || this; // jQuery 1.4+ supports scope context
  343. for (var i = 0,
  344. max = callbacks.length; i < max; i++) {
  345. callbacks[i].apply(context, [data, status, xhr || $form, $form]);
  346. }
  347. };
  348. if (options.error) {
  349. var oldError = options.error;
  350. options.error = function(xhr, status, error) {
  351. var context = options.context || this;
  352. oldError.apply(context, [xhr, status, error, $form]);
  353. };
  354. }
  355. if (options.complete) {
  356. var oldComplete = options.complete;
  357. options.complete = function(xhr, status) {
  358. var context = options.context || this;
  359. oldComplete.apply(context, [xhr, status, $form]);
  360. };
  361. }
  362. // are there files to upload?
  363. // [value] (issue #113), also see comment:
  364. // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
  365. var fileInputs = $('input[type=file]:enabled', this).filter(function() {
  366. return $(this).val() !== '';
  367. });
  368. var hasFileInputs = fileInputs.length > 0;
  369. var mp = 'multipart/form-data';
  370. var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
  371. var fileAPI = feature.fileapi && feature.formdata;
  372. log("fileAPI :" + fileAPI);
  373. var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
  374. var jqxhr;
  375. // options.iframe allows user to force iframe mode
  376. // 06-NOV-09: now defaulting to iframe mode if file input is detected
  377. if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
  378. // hack to fix Safari hang (thanks to Tim Molendijk for this)
  379. // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
  380. if (options.closeKeepAlive) {
  381. $.get(options.closeKeepAlive,
  382. function() {
  383. jqxhr = fileUploadIframe(a);
  384. });
  385. } else {
  386. jqxhr = fileUploadIframe(a);
  387. }
  388. } else if ((hasFileInputs || multipart) && fileAPI) {
  389. jqxhr = fileUploadXhr(a);
  390. } else {
  391. jqxhr = $.ajax(options);
  392. }
  393. $form.removeData('jqxhr').data('jqxhr', jqxhr);
  394. // clear element array
  395. for (var k = 0; k < elements.length; k++) {
  396. elements[k] = null;
  397. }
  398. // fire 'notify' event
  399. this.trigger('form-submit-notify', [this, options]);
  400. return this;
  401. // utility fn for deep serialization
  402. function deepSerialize(extraData) {
  403. var serialized = $.param(extraData, options.traditional).split('&');
  404. var len = serialized.length;
  405. var result = [];
  406. var i, part;
  407. for (i = 0; i < len; i++) {
  408. // #252; undo param space replacement
  409. serialized[i] = serialized[i].replace(/\+/g, ' ');
  410. part = serialized[i].split('=');
  411. // #278; use array instead of object storage, favoring array serializations
  412. result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
  413. }
  414. return result;
  415. }
  416. // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
  417. function fileUploadXhr(a) {
  418. var formdata = new FormData();
  419. for (var i = 0; i < a.length; i++) {
  420. formdata.append(a[i].name, a[i].value);
  421. }
  422. if (options.extraData) {
  423. var serializedData = deepSerialize(options.extraData);
  424. for (i = 0; i < serializedData.length; i++) {
  425. if (serializedData[i]) {
  426. formdata.append(serializedData[i][0], serializedData[i][1]);
  427. }
  428. }
  429. }
  430. options.data = null;
  431. var s = $.extend(true, {},
  432. $.ajaxSettings, options, {
  433. contentType: false,
  434. processData: false,
  435. cache: false,
  436. type: method || 'POST'
  437. });
  438. if (options.uploadProgress) {
  439. // workaround because jqXHR does not expose upload property
  440. s.xhr = function() {
  441. var xhr = $.ajaxSettings.xhr();
  442. if (xhr.upload) {
  443. xhr.upload.addEventListener('progress',
  444. function(event) {
  445. var percent = 0;
  446. var position = event.loaded || event.position;
  447. /*event.position is deprecated*/
  448. var total = event.total;
  449. if (event.lengthComputable) {
  450. percent = Math.ceil(position / total * 100);
  451. }
  452. options.uploadProgress(event, position, total, percent);
  453. },
  454. false);
  455. }
  456. return xhr;
  457. };
  458. }
  459. s.data = null;
  460. var beforeSend = s.beforeSend;
  461. s.beforeSend = function(xhr, o) {
  462. //Send FormData() provided by user
  463. if (options.formData) {
  464. o.data = options.formData;
  465. } else {
  466. o.data = formdata;
  467. }
  468. if (beforeSend) {
  469. beforeSend.call(this, xhr, o);
  470. }
  471. };
  472. return $.ajax(s);
  473. }
  474. // private function for handling file uploads (hat tip to YAHOO!)
  475. function fileUploadIframe(a) {
  476. var form = $form[0],
  477. el,
  478. i,
  479. s,
  480. g,
  481. id,
  482. $io,
  483. io,
  484. xhr,
  485. sub,
  486. n,
  487. timedOut,
  488. timeoutHandle;
  489. var deferred = $.Deferred();
  490. // #341
  491. deferred.abort = function(status) {
  492. xhr.abort(status);
  493. };
  494. if (a) {
  495. // ensure that every serialized input is still enabled
  496. for (i = 0; i < elements.length; i++) {
  497. el = $(elements[i]);
  498. if (hasProp) {
  499. el.prop('disabled', false);
  500. } else {
  501. el.removeAttr('disabled');
  502. }
  503. }
  504. }
  505. s = $.extend(true, {},
  506. $.ajaxSettings, options);
  507. s.context = s.context || s;
  508. id = 'jqFormIO' + (new Date().getTime());
  509. if (s.iframeTarget) {
  510. $io = $(s.iframeTarget);
  511. n = $io.attr2('name');
  512. if (!n) {
  513. $io.attr2('name', id);
  514. } else {
  515. id = n;
  516. }
  517. } else {
  518. $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />');
  519. $io.css({
  520. position: 'absolute',
  521. top: '-1000px',
  522. left: '-1000px'
  523. });
  524. }
  525. io = $io[0];
  526. xhr = { // mock object
  527. aborted: 0,
  528. responseText: null,
  529. responseXML: null,
  530. status: 0,
  531. statusText: 'n/a',
  532. getAllResponseHeaders: function() {},
  533. getResponseHeader: function() {},
  534. setRequestHeader: function() {},
  535. abort: function(status) {
  536. var e = (status === 'timeout' ? 'timeout': 'aborted');
  537. log('aborting upload... ' + e);
  538. this.aborted = 1;
  539. try { // #214, #257
  540. if (io.contentWindow.document.execCommand) {
  541. io.contentWindow.document.execCommand('Stop');
  542. }
  543. } catch(ignore) {}
  544. $io.attr('src', s.iframeSrc); // abort op in progress
  545. xhr.error = e;
  546. if (s.error) {
  547. s.error.call(s.context, xhr, e, status);
  548. }
  549. if (g) {
  550. $.event.trigger("ajaxError", [xhr, s, e]);
  551. }
  552. if (s.complete) {
  553. s.complete.call(s.context, xhr, e);
  554. }
  555. }
  556. };
  557. g = s.global;
  558. // trigger ajax global events so that activity/block indicators work like normal
  559. if (g && 0 === $.active++) {
  560. $.event.trigger("ajaxStart");
  561. }
  562. if (g) {
  563. $.event.trigger("ajaxSend", [xhr, s]);
  564. }
  565. if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
  566. if (s.global) {
  567. $.active--;
  568. }
  569. deferred.reject();
  570. return deferred;
  571. }
  572. if (xhr.aborted) {
  573. deferred.reject();
  574. return deferred;
  575. }
  576. // add submitting element to data if we know it
  577. sub = form.clk;
  578. if (sub) {
  579. n = sub.name;
  580. if (n && !sub.disabled) {
  581. s.extraData = s.extraData || {};
  582. s.extraData[n] = sub.value;
  583. if (sub.type == "image") {
  584. s.extraData[n + '.x'] = form.clk_x;
  585. s.extraData[n + '.y'] = form.clk_y;
  586. }
  587. }
  588. }
  589. var CLIENT_TIMEOUT_ABORT = 1;
  590. var SERVER_ABORT = 2;
  591. function getDoc(frame) {
  592. /* it looks like contentWindow or contentDocument do not
  593. * carry the protocol property in ie8, when running under ssl
  594. * frame.document is the only valid response document, since
  595. * the protocol is know but not on the other two objects. strange?
  596. * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
  597. */
  598. var doc = null;
  599. // IE8 cascading access check
  600. try {
  601. if (frame.contentWindow) {
  602. doc = frame.contentWindow.document;
  603. }
  604. } catch(err) {
  605. // IE8 access denied under ssl & missing protocol
  606. log('cannot get iframe.contentWindow document: ' + err);
  607. }
  608. if (doc) { // successful getting content
  609. return doc;
  610. }
  611. try { // simply checking may throw in ie8 under ssl or mismatched protocol
  612. doc = frame.contentDocument ? frame.contentDocument: frame.document;
  613. } catch(err) {
  614. // last attempt
  615. log('cannot get iframe.contentDocument: ' + err);
  616. doc = frame.document;
  617. }
  618. return doc;
  619. }
  620. // Rails CSRF hack (thanks to Yvan Barthelemy)
  621. var csrf_token = $('meta[name=csrf-token]').attr('content');
  622. var csrf_param = $('meta[name=csrf-param]').attr('content');
  623. if (csrf_param && csrf_token) {
  624. s.extraData = s.extraData || {};
  625. s.extraData[csrf_param] = csrf_token;
  626. }
  627. // take a breath so that pending repaints get some cpu time before the upload starts
  628. function doSubmit() {
  629. // make sure form attrs are set
  630. var t = $form.attr2('target'),
  631. a = $form.attr2('action'),
  632. mp = 'multipart/form-data',
  633. et = $form.attr('enctype') || $form.attr('encoding') || mp;
  634. // update form attrs in IE friendly way
  635. form.setAttribute('target', id);
  636. if (!method || /post/i.test(method)) {
  637. form.setAttribute('method', 'POST');
  638. }
  639. if (a != s.url) {
  640. form.setAttribute('action', s.url);
  641. }
  642. // ie borks in some cases when setting encoding
  643. if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {
  644. $form.attr({
  645. encoding: 'multipart/form-data',
  646. enctype: 'multipart/form-data'
  647. });
  648. }
  649. // support timout
  650. if (s.timeout) {
  651. timeoutHandle = setTimeout(function() {
  652. timedOut = true;
  653. cb(CLIENT_TIMEOUT_ABORT);
  654. },
  655. s.timeout);
  656. }
  657. // look for server aborts
  658. function checkState() {
  659. try {
  660. var state = getDoc(io).readyState;
  661. log('state = ' + state);
  662. if (state && state.toLowerCase() == 'uninitialized') {
  663. setTimeout(checkState, 50);
  664. }
  665. } catch(e) {
  666. log('Server abort: ', e, ' (', e.name, ')');
  667. cb(SERVER_ABORT);
  668. if (timeoutHandle) {
  669. clearTimeout(timeoutHandle);
  670. }
  671. timeoutHandle = undefined;
  672. }
  673. }
  674. // add "extra" data to form if provided in options
  675. var extraInputs = [];
  676. try {
  677. if (s.extraData) {
  678. for (var n in s.extraData) {
  679. if (s.extraData.hasOwnProperty(n)) {
  680. // if using the $.param format that allows for multiple values with the same name
  681. if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
  682. extraInputs.push($('<input type="hidden" name="' + s.extraData[n].name + '">').val(s.extraData[n].value).appendTo(form)[0]);
  683. } else {
  684. extraInputs.push($('<input type="hidden" name="' + n + '">').val(s.extraData[n]).appendTo(form)[0]);
  685. }
  686. }
  687. }
  688. }
  689. if (!s.iframeTarget) {
  690. // add iframe to doc and submit the form
  691. $io.appendTo('body');
  692. }
  693. if (io.attachEvent) {
  694. io.attachEvent('onload', cb);
  695. } else {
  696. io.addEventListener('load', cb, false);
  697. }
  698. setTimeout(checkState, 15);
  699. try {
  700. form.submit();
  701. } catch(err) {
  702. // just in case form has element with name/id of 'submit'
  703. var submitFn = document.createElement('form').submit;
  704. submitFn.apply(form);
  705. }
  706. } finally {
  707. // reset attrs and remove "extra" input elements
  708. form.setAttribute('action', a);
  709. form.setAttribute('enctype', et); // #380
  710. if (t) {
  711. form.setAttribute('target', t);
  712. } else {
  713. $form.removeAttr('target');
  714. }
  715. $(extraInputs).remove();
  716. }
  717. }
  718. if (s.forceSync) {
  719. doSubmit();
  720. } else {
  721. setTimeout(doSubmit, 10); // this lets dom updates render
  722. }
  723. var data, doc, domCheckCount = 50,
  724. callbackProcessed;
  725. function cb(e) {
  726. if (xhr.aborted || callbackProcessed) {
  727. return;
  728. }
  729. doc = getDoc(io);
  730. if (!doc) {
  731. log('cannot access response document');
  732. e = SERVER_ABORT;
  733. }
  734. if (e === CLIENT_TIMEOUT_ABORT && xhr) {
  735. xhr.abort('timeout');
  736. deferred.reject(xhr, 'timeout');
  737. return;
  738. } else if (e == SERVER_ABORT && xhr) {
  739. xhr.abort('server abort');
  740. deferred.reject(xhr, 'error', 'server abort');
  741. return;
  742. }
  743. if (!doc || doc.location.href == s.iframeSrc) {
  744. // response not received yet
  745. if (!timedOut) {
  746. return;
  747. }
  748. }
  749. if (io.detachEvent) {
  750. io.detachEvent('onload', cb);
  751. } else {
  752. io.removeEventListener('load', cb, false);
  753. }
  754. var status = 'success',
  755. errMsg;
  756. try {
  757. if (timedOut) {
  758. throw 'timeout';
  759. }
  760. var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
  761. log('isXml=' + isXml);
  762. if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
  763. if (--domCheckCount) {
  764. // in some browsers (Opera) the iframe DOM is not always traversable when
  765. // the onload callback fires, so we loop a bit to accommodate
  766. log('requeing onLoad callback, DOM not available');
  767. setTimeout(cb, 250);
  768. return;
  769. }
  770. // let this fall through because server response could be an empty document
  771. //log('Could not access iframe DOM after mutiple tries.');
  772. //throw 'DOMException: not available';
  773. }
  774. //log('response detected');
  775. var docRoot = doc.body ? doc.body: doc.documentElement;
  776. xhr.responseText = docRoot ? docRoot.innerHTML: null;
  777. xhr.responseXML = doc.XMLDocument ? doc.XMLDocument: doc;
  778. if (isXml) {
  779. s.dataType = 'xml';
  780. }
  781. xhr.getResponseHeader = function(header) {
  782. var headers = {
  783. 'content-type': s.dataType
  784. };
  785. return headers[header.toLowerCase()];
  786. };
  787. // support for XHR 'status' & 'statusText' emulation :
  788. if (docRoot) {
  789. xhr.status = Number(docRoot.getAttribute('status')) || xhr.status;
  790. xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
  791. }
  792. var dt = (s.dataType || '').toLowerCase();
  793. var scr = /(json|script|text)/.test(dt);
  794. if (scr || s.textarea) {
  795. // see if user embedded response in textarea
  796. var ta = doc.getElementsByTagName('textarea')[0];
  797. if (ta) {
  798. xhr.responseText = ta.value;
  799. // support for XHR 'status' & 'statusText' emulation :
  800. xhr.status = Number(ta.getAttribute('status')) || xhr.status;
  801. xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
  802. } else if (scr) {
  803. // account for browsers injecting pre around json response
  804. var pre = doc.getElementsByTagName('pre')[0];
  805. var b = doc.getElementsByTagName('body')[0];
  806. if (pre) {
  807. xhr.responseText = pre.textContent ? pre.textContent: pre.innerText;
  808. } else if (b) {
  809. xhr.responseText = b.textContent ? b.textContent: b.innerText;
  810. }
  811. }
  812. } else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
  813. xhr.responseXML = toXml(xhr.responseText);
  814. }
  815. try {
  816. data = httpData(xhr, dt, s);
  817. } catch(err) {
  818. status = 'parsererror';
  819. xhr.error = errMsg = (err || status);
  820. }
  821. } catch(err) {
  822. log('error caught: ', err);
  823. status = 'error';
  824. xhr.error = errMsg = (err || status);
  825. }
  826. if (xhr.aborted) {
  827. log('upload aborted');
  828. status = null;
  829. }
  830. if (xhr.status) { // we've set xhr.status
  831. status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success': 'error';
  832. }
  833. // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
  834. if (status === 'success') {
  835. if (s.success) {
  836. s.success.call(s.context, data, 'success', xhr);
  837. }
  838. deferred.resolve(xhr.responseText, 'success', xhr);
  839. if (g) {
  840. $.event.trigger("ajaxSuccess", [xhr, s]);
  841. }
  842. } else if (status) {
  843. if (errMsg === undefined) {
  844. errMsg = xhr.statusText;
  845. }
  846. if (s.error) {
  847. s.error.call(s.context, xhr, status, errMsg);
  848. }
  849. deferred.reject(xhr, 'error', errMsg);
  850. if (g) {
  851. $.event.trigger("ajaxError", [xhr, s, errMsg]);
  852. }
  853. }
  854. if (g) {
  855. $.event.trigger("ajaxComplete", [xhr, s]);
  856. }
  857. if (g && !--$.active) {
  858. $.event.trigger("ajaxStop");
  859. }
  860. if (s.complete) {
  861. s.complete.call(s.context, xhr, status);
  862. }
  863. callbackProcessed = true;
  864. if (s.timeout) {
  865. clearTimeout(timeoutHandle);
  866. }
  867. // clean up
  868. setTimeout(function() {
  869. if (!s.iframeTarget) {
  870. $io.remove();
  871. } else { //adding else to clean up existing iframe response.
  872. $io.attr('src', s.iframeSrc);
  873. }
  874. xhr.responseXML = null;
  875. },
  876. 100);
  877. }
  878. var toXml = $.parseXML ||
  879. function(s, doc) { // use parseXML if available (jQuery 1.5+)
  880. if (window.ActiveXObject) {
  881. doc = new ActiveXObject('Microsoft.XMLDOM');
  882. doc.async = 'false';
  883. doc.loadXML(s);
  884. } else {
  885. doc = (new DOMParser()).parseFromString(s, 'text/xml');
  886. }
  887. return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc: null;
  888. };
  889. var parseJSON = $.parseJSON ||
  890. function(s) {
  891. /*jslint evil:true */
  892. return window['eval']('(' + s + ')');
  893. };
  894. var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
  895. var ct = xhr.getResponseHeader('content-type') || '',
  896. xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
  897. data = xml ? xhr.responseXML: xhr.responseText;
  898. if (xml && data.documentElement.nodeName === 'parsererror') {
  899. if ($.error) {
  900. $.error('parsererror');
  901. }
  902. }
  903. if (s && s.dataFilter) {
  904. data = s.dataFilter(data, type);
  905. }
  906. if (typeof data === 'string') {
  907. if (type === 'json' || !type && ct.indexOf('json') >= 0) {
  908. data = parseJSON(data);
  909. } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
  910. $.globalEval(data);
  911. }
  912. }
  913. return data;
  914. };
  915. return deferred;
  916. }
  917. };
  918. /**
  919. * ajaxForm() provides a mechanism for fully automating form submission.
  920. *
  921. * The advantages of using this method instead of ajaxSubmit() are:
  922. *
  923. * 1: This method will include coordinates for <input type="image" /> elements (if the element
  924. * is used to submit the form).
  925. * 2. This method will include the submit element's name/value data (for the element that was
  926. * used to submit the form).
  927. * 3. This method binds the submit() method to the form for you.
  928. *
  929. * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
  930. * passes the options argument along after properly binding events for submit elements and
  931. * the form itself.
  932. */
  933. $.fn.ajaxForm = function(options) {
  934. options = options || {};
  935. options.delegation = options.delegation && $.isFunction($.fn.on);
  936. // in jQuery 1.3+ we can fix mistakes with the ready state
  937. if (!options.delegation && this.length === 0) {
  938. var o = {
  939. s: this.selector,
  940. c: this.context
  941. };
  942. if (!$.isReady && o.s) {
  943. log('DOM not ready, queuing ajaxForm');
  944. $(function() {
  945. $(o.s, o.c).ajaxForm(options);
  946. });
  947. return this;
  948. }
  949. // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
  950. log('terminating; zero elements found by selector' + ($.isReady ? '': ' (DOM not ready)'));
  951. return this;
  952. }
  953. if (options.delegation) {
  954. $(document).off('submit.form-plugin', this.selector, doAjaxSubmit).off('click.form-plugin', this.selector, captureSubmittingElement).on('submit.form-plugin', this.selector, options, doAjaxSubmit).on('click.form-plugin', this.selector, options, captureSubmittingElement);
  955. return this;
  956. }
  957. return this.ajaxFormUnbind().on('submit.form-plugin', options, doAjaxSubmit).on('click.form-plugin', options, captureSubmittingElement);
  958. };
  959. // private event handlers
  960. function doAjaxSubmit(e) {
  961. /*jshint validthis:true */
  962. var options = e.data;
  963. if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
  964. e.preventDefault();
  965. $(e.target).ajaxSubmit(options); // #365
  966. }
  967. }
  968. function captureSubmittingElement(e) {
  969. /*jshint validthis:true */
  970. var target = e.target;
  971. var $el = $(target);
  972. if (! ($el.is("[type=submit],[type=image]"))) {
  973. // is this a child element of the submit el? (ex: a span within a button)
  974. var t = $el.closest('[type=submit]');
  975. if (t.length === 0) {
  976. return;
  977. }
  978. target = t[0];
  979. }
  980. var form = this;
  981. form.clk = target;
  982. if (target.type == 'image') {
  983. if (e.offsetX !== undefined) {
  984. form.clk_x = e.offsetX;
  985. form.clk_y = e.offsetY;
  986. } else if (typeof $.fn.offset == 'function') {
  987. var offset = $el.offset();
  988. form.clk_x = e.pageX - offset.left;
  989. form.clk_y = e.pageY - offset.top;
  990. } else {
  991. form.clk_x = e.pageX - target.offsetLeft;
  992. form.clk_y = e.pageY - target.offsetTop;
  993. }
  994. }
  995. // clear form vars
  996. setTimeout(function() {
  997. form.clk = form.clk_x = form.clk_y = null;
  998. },
  999. 100);
  1000. }
  1001. // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
  1002. $.fn.ajaxFormUnbind = function() {
  1003. return this.unbind('submit.form-plugin click.form-plugin');
  1004. };
  1005. /**
  1006. * formToArray() gathers form element data into an array of objects that can
  1007. * be passed to any of the following ajax functions: $.get, $.post, or load.
  1008. * Each object in the array has both a 'name' and 'value' property. An example of
  1009. * an array for a simple login form might be:
  1010. *
  1011. * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
  1012. *
  1013. * It is this array that is passed to pre-submit callback functions provided to the
  1014. * ajaxSubmit() and ajaxForm() methods.
  1015. */
  1016. $.fn.formToArray = function(semantic, elements) {
  1017. var a = [];
  1018. if (this.length === 0) {
  1019. return a;
  1020. }
  1021. var form = this[0];
  1022. var formId = this.attr('id');
  1023. var els = semantic ? form.getElementsByTagName('*') : form.elements;
  1024. var els2;
  1025. if (els && !/MSIE [678]/.test(navigator.userAgent)) { // #390
  1026. els = $(els).get(); // convert to standard array
  1027. }
  1028. // #386; account for inputs outside the form which use the 'form' attribute
  1029. if (formId) {
  1030. els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
  1031. if (els2.length) {
  1032. els = (els || []).concat(els2);
  1033. }
  1034. }
  1035. if (!els || !els.length) {
  1036. return a;
  1037. }
  1038. var i, j, n, v, el, max, jmax;
  1039. for (i = 0, max = els.length; i < max; i++) {
  1040. el = els[i];
  1041. n = el.name;
  1042. if (!n || el.disabled) {
  1043. continue;
  1044. }
  1045. if (semantic && form.clk && el.type == "image") {
  1046. // handle image inputs on the fly when semantic == true
  1047. if (form.clk == el) {
  1048. a.push({
  1049. name: n,
  1050. value: $(el).val(),
  1051. type: el.type
  1052. });
  1053. a.push({
  1054. name: n + '.x',
  1055. value: form.clk_x
  1056. },
  1057. {
  1058. name: n + '.y',
  1059. value: form.clk_y
  1060. });
  1061. }
  1062. continue;
  1063. }
  1064. v = $.fieldValue(el, true);
  1065. if (v && v.constructor == Array) {
  1066. if (elements) {
  1067. elements.push(el);
  1068. }
  1069. for (j = 0, jmax = v.length; j < jmax; j++) {
  1070. a.push({
  1071. name: n,
  1072. value: v[j]
  1073. });
  1074. }
  1075. } else if (feature.fileapi && el.type == 'file') {
  1076. if (elements) {
  1077. elements.push(el);
  1078. }
  1079. var files = el.files;
  1080. if (files.length) {
  1081. for (j = 0; j < files.length; j++) {
  1082. a.push({
  1083. name: n,
  1084. value: files[j],
  1085. type: el.type
  1086. });
  1087. }
  1088. } else {
  1089. // #180
  1090. a.push({
  1091. name: n,
  1092. value: '',
  1093. type: el.type
  1094. });
  1095. }
  1096. } else if (v !== null && typeof v != 'undefined') {
  1097. if (elements) {
  1098. elements.push(el);
  1099. }
  1100. a.push({
  1101. name: n,
  1102. value: v,
  1103. type: el.type,
  1104. required: el.required
  1105. });
  1106. }
  1107. }
  1108. if (!semantic && form.clk) {
  1109. // input type=='image' are not found in elements array! handle it here
  1110. var $input = $(form.clk),
  1111. input = $input[0];
  1112. n = input.name;
  1113. if (n && !input.disabled && input.type == 'image') {
  1114. a.push({
  1115. name: n,
  1116. value: $input.val()
  1117. });
  1118. a.push({
  1119. name: n + '.x',
  1120. value: form.clk_x
  1121. },
  1122. {
  1123. name: n + '.y',
  1124. value: form.clk_y
  1125. });
  1126. }
  1127. }
  1128. return a;
  1129. };
  1130. /**
  1131. * Serializes form data into a 'submittable' string. This method will return a string
  1132. * in the format: name1=value1&amp;name2=value2
  1133. */
  1134. $.fn.formSerialize = function(semantic) {
  1135. //hand off to jQuery.param for proper encoding
  1136. return $.param(this.formToArray(semantic));
  1137. };
  1138. /**
  1139. * Serializes all field elements in the jQuery object into a query string.
  1140. * This method will return a string in the format: name1=value1&amp;name2=value2
  1141. */
  1142. $.fn.fieldSerialize = function(successful) {
  1143. var a = [];
  1144. this.each(function() {
  1145. var n = this.name;
  1146. if (!n) {
  1147. return;
  1148. }
  1149. var v = $.fieldValue(this, successful);
  1150. if (v && v.constructor == Array) {
  1151. for (var i = 0,
  1152. max = v.length; i < max; i++) {
  1153. a.push({
  1154. name: n,
  1155. value: v[i]
  1156. });
  1157. }
  1158. } else if (v !== null && typeof v != 'undefined') {
  1159. a.push({
  1160. name: this.name,
  1161. value: v
  1162. });
  1163. }
  1164. });
  1165. //hand off to jQuery.param for proper encoding
  1166. return $.param(a);
  1167. };
  1168. /**
  1169. * Returns the value(s) of the element in the matched set. For example, consider the following form:
  1170. *
  1171. * <form><fieldset>
  1172. * <input name="A" type="text" />
  1173. * <input name="A" type="text" />
  1174. * <input name="B" type="checkbox" value="B1" />
  1175. * <input name="B" type="checkbox" value="B2"/>
  1176. * <input name="C" type="radio" value="C1" />
  1177. * <input name="C" type="radio" value="C2" />
  1178. * </fieldset></form>
  1179. *
  1180. * var v = $('input[type=text]').fieldValue();
  1181. * // if no values are entered into the text inputs
  1182. * v == ['','']
  1183. * // if values entered into the text inputs are 'foo' and 'bar'
  1184. * v == ['foo','bar']
  1185. *
  1186. * var v = $('input[type=checkbox]').fieldValue();
  1187. * // if neither checkbox is checked
  1188. * v === undefined
  1189. * // if both checkboxes are checked
  1190. * v == ['B1', 'B2']
  1191. *
  1192. * var v = $('input[type=radio]').fieldValue();
  1193. * // if neither radio is checked
  1194. * v === undefined
  1195. * // if first radio is checked
  1196. * v == ['C1']
  1197. *
  1198. * The successful argument controls whether or not the field element must be 'successful'
  1199. * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
  1200. * The default value of the successful argument is true. If this value is false the value(s)
  1201. * for each element is returned.
  1202. *
  1203. * Note: This method *always* returns an array. If no valid value can be determined the
  1204. * array will be empty, otherwise it will contain one or more values.
  1205. */
  1206. $.fn.fieldValue = function(successful) {
  1207. for (var val = [], i = 0, max = this.length; i < max; i++) {
  1208. var el = this[i];
  1209. var v = $.fieldValue(el, successful);
  1210. if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
  1211. continue;
  1212. }
  1213. if (v.constructor == Array) {
  1214. $.merge(val, v);
  1215. } else {
  1216. val.push(v);
  1217. }
  1218. }
  1219. return val;
  1220. };
  1221. /**
  1222. * Returns the value of the field element.
  1223. */
  1224. $.fieldValue = function(el, successful) {
  1225. var n = el.name,
  1226. t = el.type,
  1227. tag = el.tagName.toLowerCase();
  1228. if (successful === undefined) {
  1229. successful = true;
  1230. }
  1231. if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || (t == 'checkbox' || t == 'radio') && !el.checked || (t == 'submit' || t == 'image') && el.form && el.form.clk != el || tag == 'select' && el.selectedIndex == -1)) {
  1232. return null;
  1233. }
  1234. if (tag == 'select') {
  1235. var index = el.selectedIndex;
  1236. if (index < 0) {
  1237. return null;
  1238. }
  1239. var a = [],
  1240. ops = el.options;
  1241. var one = (t == 'select-one');
  1242. var max = (one ? index + 1 : ops.length);
  1243. for (var i = (one ? index: 0); i < max; i++) {
  1244. var op = ops[i];
  1245. if (op.selected) {
  1246. var v = op.value;
  1247. if (!v) { // extra pain for IE...
  1248. v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text: op.value;
  1249. }
  1250. if (one) {
  1251. return v;
  1252. }
  1253. a.push(v);
  1254. }
  1255. }
  1256. return a;
  1257. }
  1258. return $(el).val();
  1259. };
  1260. /**
  1261. * Clears the form data. Takes the following actions on the form's input fields:
  1262. * - input text fields will have their 'value' property set to the empty string
  1263. * - select elements will have their 'selectedIndex' property set to -1
  1264. * - checkbox and radio inputs will have their 'checked' property set to false
  1265. * - inputs of type submit, button, reset, and hidden will *not* be effected
  1266. * - button elements will *not* be effected
  1267. */
  1268. $.fn.clearForm = function(includeHidden) {
  1269. return this.each(function() {
  1270. $('input,select,textarea', this).clearFields(includeHidden);
  1271. });
  1272. };
  1273. /**
  1274. * Clears the selected form elements.
  1275. */
  1276. $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
  1277. var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
  1278. return this.each(function() {
  1279. var t = this.type,
  1280. tag = this.tagName.toLowerCase();
  1281. if (re.test(t) || tag == 'textarea') {
  1282. this.value = '';
  1283. } else if (t == 'checkbox' || t == 'radio') {
  1284. this.checked = false;
  1285. } else if (tag == 'select') {
  1286. this.selectedIndex = -1;
  1287. } else if (t == "file") {
  1288. if (/MSIE/.test(navigator.userAgent)) {
  1289. $(this).replaceWith($(this).clone(true));
  1290. } else {
  1291. $(this).val('');
  1292. }
  1293. } else if (includeHidden) {
  1294. // includeHidden can be the value true, or it can be a selector string
  1295. // indicating a special test; for example:
  1296. // $('#myForm').clearForm('.special:hidden')
  1297. // the above would clean hidden inputs that have the class of 'special'
  1298. if ((includeHidden === true && /hidden/.test(t)) || (typeof includeHidden == 'string' && $(this).is(includeHidden))) {
  1299. this.value = '';
  1300. }
  1301. }
  1302. });
  1303. };
  1304. /**
  1305. * Resets the form data. Causes all form elements to be reset to their original value.
  1306. */
  1307. $.fn.resetForm = function() {
  1308. return this.each(function() {
  1309. // guard against an input with the name of 'reset'
  1310. // note that IE reports the reset function as an 'object'
  1311. if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
  1312. this.reset();
  1313. }
  1314. });
  1315. };
  1316. /**
  1317. * Enables or disables any matching elements.
  1318. */
  1319. $.fn.enable = function(b) {
  1320. if (b === undefined) {
  1321. b = true;
  1322. }
  1323. return this.each(function() {
  1324. this.disabled = !b;
  1325. });
  1326. };
  1327. /**
  1328. * Checks/unchecks any matching checkboxes or radio buttons and
  1329. * selects/deselects and matching option elements.
  1330. */
  1331. $.fn.selected = function(select) {
  1332. if (select === undefined) {
  1333. select = true;
  1334. }
  1335. return this.each(function() {
  1336. var t = this.type;
  1337. if (t == 'checkbox' || t == 'radio') {
  1338. this.checked = select;
  1339. } else if (this.tagName.toLowerCase() == 'option') {
  1340. var $sel = $(this).parent('select');
  1341. if (select && $sel[0] && $sel[0].type == 'select-one') {
  1342. // deselect all other options
  1343. $sel.find('option').selected(false);
  1344. }
  1345. this.selected = select;
  1346. }
  1347. });
  1348. };
  1349. // expose debug var
  1350. $.fn.ajaxSubmit.debug = false;
  1351. function log() {
  1352. if (!$.fn.ajaxSubmit.debug) {
  1353. return;
  1354. }
  1355. var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, '');
  1356. if (window.console && window.console.log) {
  1357. window.console.log(msg);
  1358. } else if (window.opera && window.opera.postError) {
  1359. window.opera.postError(msg);
  1360. }
  1361. }
  1362. }));
  1363. /* =======================================================================
  1364. * jQuery.lazyload v1.9.3
  1365. * Lazy Load - jQuery plugin for lazy loading images
  1366. * Copyright (c) 2007-2013 Mika Tuupola
  1367. * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
  1368. * Project home: http://www.appelsiini.net/projects/lazyload
  1369. * ======================================================================== */
  1370. ! (function($, window, document, undefined) {
  1371. var $window = $(window);
  1372. $.fn.lazyload = function(options) {
  1373. var elements = this;
  1374. var $container;
  1375. var settings = {
  1376. threshold: 0,
  1377. failure_limit: 0,
  1378. event: "scroll",
  1379. effect: "show",
  1380. container: window,
  1381. data_attribute: "original",
  1382. skip_invisible: true,
  1383. appear: null,
  1384. load: null,
  1385. placeholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
  1386. };
  1387. function update() {
  1388. var counter = 0;
  1389. elements.each(function() {
  1390. var $this = $(this);
  1391. if (settings.skip_invisible && !$this.is(":visible")) {
  1392. return;
  1393. }
  1394. if ($.abovethetop(this, settings) || $.leftofbegin(this, settings)) {
  1395. /* Nothing. */
  1396. } else if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) {
  1397. $this.trigger("appear");
  1398. /* if we found an image we'll load, reset the counter */
  1399. counter = 0;
  1400. } else {
  1401. if (++counter > settings.failure_limit) {
  1402. return false;
  1403. }
  1404. }
  1405. });
  1406. }
  1407. if (options) {
  1408. /* Maintain BC for a couple of versions. */
  1409. if (undefined !== options.failurelimit) {
  1410. options.failure_limit = options.failurelimit;
  1411. delete options.failurelimit;
  1412. }
  1413. if (undefined !== options.effectspeed) {
  1414. options.effect_speed = options.effectspeed;
  1415. delete options.effectspeed;
  1416. }
  1417. $.extend(settings, options);
  1418. }
  1419. /* Cache container as jQuery as object. */
  1420. $container = (settings.container === undefined || settings.container === window) ? $window: $(settings.container);
  1421. /* Fire one scroll event per scroll. Not one scroll event per image. */
  1422. if (0 === settings.event.indexOf("scroll")) {
  1423. $container.on(settings.event,
  1424. function() {
  1425. return update();
  1426. });
  1427. }
  1428. this.each(function() {
  1429. var self = this;
  1430. var $self = $(self);
  1431. self.loaded = false;
  1432. /* If no src attribute given use data:uri. */
  1433. if ($self.attr("src") === undefined || $self.attr("src") === false) {
  1434. if ($self.is("img")) {
  1435. $self.attr("src", settings.placeholder);
  1436. }
  1437. }
  1438. /* When appear is triggered load original image. */
  1439. $self.one("appear",
  1440. function() {
  1441. if (!this.loaded) {
  1442. if (settings.appear) {
  1443. var elements_left = elements.length;
  1444. settings.appear.call(self, elements_left, settings);
  1445. }
  1446. $("<img />").on("load",
  1447. function() {
  1448. var original = $self.attr("data-" + settings.data_attribute);
  1449. $self.hide();
  1450. if ($self.is("img")) {
  1451. $self.attr("src", original);
  1452. } else {
  1453. $self.css("background-image", "url('" + original + "')");
  1454. }
  1455. $self[settings.effect](settings.effect_speed);
  1456. self.loaded = true;
  1457. /* Remove image from array so it is not looped next time. */
  1458. var temp = $.grep(elements,
  1459. function(element) {
  1460. return ! element.loaded;
  1461. });
  1462. elements = $(temp);
  1463. if (settings.load) {
  1464. var elements_left = elements.length;
  1465. settings.load.call(self, elements_left, settings);
  1466. }
  1467. }).attr("src", $self.attr("data-" + settings.data_attribute));
  1468. }
  1469. });
  1470. /* When wanted event is triggered load original image */
  1471. /* by triggering appear. */
  1472. if (0 !== settings.event.indexOf("scroll")) {
  1473. $self.on(settings.event,
  1474. function() {
  1475. if (!self.loaded) {
  1476. $self.trigger("appear");
  1477. }
  1478. });
  1479. }
  1480. });
  1481. /* Check if something appears when window is resized. */
  1482. $window.on("resize",
  1483. function() {
  1484. update();
  1485. });
  1486. /* With IOS5 force loading images when navigating with back button. */
  1487. /* Non optimal workaround. */
  1488. if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
  1489. $window.on("pageshow",
  1490. function(event) {
  1491. if (event.originalEvent && event.originalEvent.persisted) {
  1492. elements.each(function() {
  1493. $(this).trigger("appear");
  1494. });
  1495. }
  1496. });
  1497. }
  1498. /* Force initial check if images should appear. */
  1499. $(document).ready(function() {
  1500. update();
  1501. });
  1502. return this;
  1503. };
  1504. /* Convenience methods in jQuery namespace. */
  1505. /* Use as $.belowthefold(element, {threshold : 100, container : window}) */
  1506. $.belowthefold = function(element, settings) {
  1507. var fold;
  1508. if (settings.container === undefined || settings.container === window) {
  1509. fold = (window.innerHeight ? window.innerHeight: $window.height()) + $window.scrollTop();
  1510. } else {
  1511. fold = $(settings.container).offset().top + $(settings.container).height();
  1512. }
  1513. return fold <= $(element).offset().top - settings.threshold;
  1514. };
  1515. $.rightoffold = function(element, settings) {
  1516. var fold;
  1517. if (settings.container === undefined || settings.container === window) {
  1518. fold = $window.width() + $window.scrollLeft();
  1519. } else {
  1520. fold = $(settings.container).offset().left + $(settings.container).width();
  1521. }
  1522. return fold <= $(element).offset().left - settings.threshold;
  1523. };
  1524. $.abovethetop = function(element, settings) {
  1525. var fold;
  1526. if (settings.container === undefined || settings.container === window) {
  1527. fold = $window.scrollTop();
  1528. } else {
  1529. fold = $(settings.container).offset().top;
  1530. }
  1531. return fold >= $(element).offset().top + settings.threshold + $(element).height();
  1532. };
  1533. $.leftofbegin = function(element, settings) {
  1534. var fold;
  1535. if (settings.container === undefined || settings.container === window) {
  1536. fold = $window.scrollLeft();
  1537. } else {
  1538. fold = $(settings.container).offset().left;
  1539. }
  1540. return fold >= $(element).offset().left + settings.threshold + $(element).width();
  1541. };
  1542. $.inviewport = function(element, settings) {
  1543. return ! $.rightoffold(element, settings) && !$.leftofbegin(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
  1544. };
  1545. /* Custom selectors for your convenience. */
  1546. /* Use as $("img:below-the-fold").something() or */
  1547. /* $("img").filter(":below-the-fold").something() which is faster */
  1548. $.extend($.expr[":"], {
  1549. "below-the-fold": function(a) {
  1550. return $.belowthefold(a, {
  1551. threshold: 0
  1552. });
  1553. },
  1554. "above-the-top": function(a) {
  1555. return ! $.belowthefold(a, {
  1556. threshold: 0
  1557. });
  1558. },
  1559. "right-of-screen": function(a) {
  1560. return $.rightoffold(a, {
  1561. threshold: 0
  1562. });
  1563. },
  1564. "left-of-screen": function(a) {
  1565. return ! $.rightoffold(a, {
  1566. threshold: 0
  1567. });
  1568. },
  1569. "in-viewport": function(a) {
  1570. return $.inviewport(a, {
  1571. threshold: 0
  1572. });
  1573. },
  1574. /* Maintain BC for couple of versions. */
  1575. "above-the-fold": function(a) {
  1576. return ! $.belowthefold(a, {
  1577. threshold: 0
  1578. });
  1579. },
  1580. "right-of-fold": function(a) {
  1581. return $.rightoffold(a, {
  1582. threshold: 0
  1583. });
  1584. },
  1585. "left-of-fold": function(a) {
  1586. return ! $.rightoffold(a, {
  1587. threshold: 0
  1588. });
  1589. }
  1590. });
  1591. })(jQuery, window, document);
  1592. /* =======================================================================
  1593. * jQuery.responsive-nav.js v1.0.39
  1594. * https://github.com/viljamis/responsive-nav.js
  1595. * http://responsive-nav.com
  1596. *
  1597. * Copyright (c) 2015 @viljamis
  1598. * Available under the MIT license
  1599. * ======================================================================== */
  1600. /* global Event */
  1601. (function(document, window, index) {
  1602. // Index is used to keep multiple navs on the same page namespaced
  1603. "use strict";
  1604. var responsiveNav = function(el, options) {
  1605. var computed = !!window.getComputedStyle;
  1606. /**
  1607. * getComputedStyle polyfill for old browsers
  1608. */
  1609. if (!computed) {
  1610. window.getComputedStyle = function(el) {
  1611. this.el = el;
  1612. this.getPropertyValue = function(prop) {
  1613. var re = /(\-([a-z]){1})/g;
  1614. if (prop === "float") {
  1615. prop = "styleFloat";
  1616. }
  1617. if (re.test(prop)) {
  1618. prop = prop.replace(re,
  1619. function() {
  1620. return arguments[2].toUpperCase();
  1621. });
  1622. }
  1623. return el.currentStyle[prop] ? el.currentStyle[prop] : null;
  1624. };
  1625. return this;
  1626. };
  1627. }
  1628. /* exported addEvent, removeEvent, getChildren, setAttributes, addClass, removeClass, forEach */
  1629. /**
  1630. * Add Event
  1631. * fn arg can be an object or a function, thanks to handleEvent
  1632. * read more at: http://www.thecssninja.com/javascript/handleevent
  1633. *
  1634. * @param {element} element
  1635. * @param {event} event
  1636. * @param {Function} fn
  1637. * @param {boolean} bubbling
  1638. */
  1639. var addEvent = function(el, evt, fn, bubble) {
  1640. if ("addEventListener" in el) {
  1641. // BBOS6 doesn't support handleEvent, catch and polyfill
  1642. try {
  1643. el.addEventListener(evt, fn, bubble);
  1644. } catch(e) {
  1645. if (typeof fn === "object" && fn.handleEvent) {
  1646. el.addEventListener(evt,
  1647. function(e) {
  1648. // Bind fn as this and set first arg as event object
  1649. fn.handleEvent.call(fn, e);
  1650. },
  1651. bubble);
  1652. } else {
  1653. throw e;
  1654. }
  1655. }
  1656. } else if ("attachEvent" in el) {
  1657. // check if the callback is an object and contains handleEvent
  1658. if (typeof fn === "object" && fn.handleEvent) {
  1659. el.attachEvent("on" + evt,
  1660. function() {
  1661. // Bind fn as this
  1662. fn.handleEvent.call(fn);
  1663. });
  1664. } else {
  1665. el.attachEvent("on" + evt, fn);
  1666. }
  1667. }
  1668. },
  1669. /**
  1670. * Remove Event
  1671. *
  1672. * @param {element} element
  1673. * @param {event} event
  1674. * @param {Function} fn
  1675. * @param {boolean} bubbling
  1676. */
  1677. removeEvent = function(el, evt, fn, bubble) {
  1678. if ("removeEventListener" in el) {
  1679. try {
  1680. el.removeEventListener(evt, fn, bubble);
  1681. } catch(e) {
  1682. if (typeof fn === "object" && fn.handleEvent) {
  1683. el.removeEventListener(evt,
  1684. function(e) {
  1685. fn.handleEvent.call(fn, e);
  1686. },
  1687. bubble);
  1688. } else {
  1689. throw e;
  1690. }
  1691. }
  1692. } else if ("detachEvent" in el) {
  1693. if (typeof fn === "object" && fn.handleEvent) {
  1694. el.detachEvent("on" + evt,
  1695. function() {
  1696. fn.handleEvent.call(fn);
  1697. });
  1698. } else {
  1699. el.detachEvent("on" + evt, fn);
  1700. }
  1701. }
  1702. },
  1703. /**
  1704. * Get the children of any element
  1705. *
  1706. * @param {element}
  1707. * @return {array} Returns matching elements in an array
  1708. */
  1709. getChildren = function(e) {
  1710. if (e.children.length < 1) {
  1711. throw new Error("The Nav container has no containing elements");
  1712. }
  1713. // Store all children in array
  1714. var children = [];
  1715. // Loop through children and store in array if child != TextNode
  1716. for (var i = 0; i < e.children.length; i++) {
  1717. if (e.children[i].nodeType === 1) {
  1718. children.push(e.children[i]);
  1719. }
  1720. }
  1721. return children;
  1722. },
  1723. /**
  1724. * Sets multiple attributes at once
  1725. *
  1726. * @param {element} element
  1727. * @param {attrs} attrs
  1728. */
  1729. setAttributes = function(el, attrs) {
  1730. for (var key in attrs) {
  1731. el.setAttribute(key, attrs[key]);
  1732. }
  1733. },
  1734. /**
  1735. * Adds a class to any element
  1736. *
  1737. * @param {element} element
  1738. * @param {string} class
  1739. */
  1740. addClass = function(el, cls) {
  1741. if (el.className.indexOf(cls) !== 0) {
  1742. el.className += " " + cls;
  1743. el.className = el.className.replace(/(^\s*)|(\s*$)/g, "");
  1744. }
  1745. },
  1746. /**
  1747. * Remove a class from any element
  1748. *
  1749. * @param {element} element
  1750. * @param {string} class
  1751. */
  1752. removeClass = function(el, cls) {
  1753. var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
  1754. el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g, "");
  1755. },
  1756. /**
  1757. * forEach method that passes back the stuff we need
  1758. *
  1759. * @param {array} array
  1760. * @param {Function} callback
  1761. * @param {scope} scope
  1762. */
  1763. forEach = function(array, callback, scope) {
  1764. for (var i = 0; i < array.length; i++) {
  1765. callback.call(scope, i, array[i]);
  1766. }
  1767. };
  1768. var nav, opts, navToggle, styleElement = document.createElement("style"),
  1769. htmlEl = document.documentElement,
  1770. hasAnimFinished,
  1771. isMobile,
  1772. navOpen;
  1773. var ResponsiveNav = function(el, options) {
  1774. var i;
  1775. /**
  1776. * Default options
  1777. * @type {Object}
  1778. */
  1779. this.options = {
  1780. animate: true,
  1781. // Boolean: Use CSS3 transitions, true or false
  1782. transition: 284,
  1783. // Integer: Speed of the transition, in milliseconds
  1784. label: "Menu",
  1785. // String: Label for the navigation toggle
  1786. insert: "before",
  1787. // String: Insert the toggle before or after the navigation
  1788. customToggle: "",
  1789. // Selector: Specify the ID of a custom toggle
  1790. closeOnNavClick: false,
  1791. // Boolean: Close the navigation when one of the links are clicked
  1792. openPos: "relative",
  1793. // String: Position of the opened nav, relative or static
  1794. navClass: "nav-collapse",
  1795. // String: Default CSS class. If changed, you need to edit the CSS too!
  1796. navActiveClass: "js-nav-active",
  1797. // String: Class that is added to <html> element when nav is active
  1798. jsClass: "js",
  1799. // String: 'JS enabled' class which is added to <html> element
  1800. init: function() {},
  1801. // Function: Init callback
  1802. open: function() {},
  1803. // Function: Open callback
  1804. close: function() {} // Function: Close callback
  1805. };
  1806. // User defined options
  1807. for (i in options) {
  1808. this.options[i] = options[i];
  1809. }
  1810. // Adds "js" class for <html>
  1811. addClass(htmlEl, this.options.jsClass);
  1812. // Wrapper
  1813. this.wrapperEl = el.replace("#", "");
  1814. // Try selecting ID first
  1815. if (document.getElementById(this.wrapperEl)) {
  1816. this.wrapper = document.getElementById(this.wrapperEl);
  1817. // If element with an ID doesn't exist, use querySelector
  1818. } else if (document.querySelector(this.wrapperEl)) {
  1819. this.wrapper = document.querySelector(this.wrapperEl);
  1820. // If element doesn't exists, stop here.
  1821. } else {
  1822. throw new Error("The nav element you are trying to select doesn't exist");
  1823. }
  1824. // Inner wrapper
  1825. this.wrapper.inner = getChildren(this.wrapper);
  1826. // For minification
  1827. opts = this.options;
  1828. nav = this.wrapper;
  1829. // Init
  1830. this._init(this);
  1831. };
  1832. ResponsiveNav.prototype = {
  1833. /**
  1834. * Unattaches events and removes any classes that were added
  1835. */
  1836. destroy: function() {
  1837. this._removeStyles();
  1838. removeClass(nav, "closed");
  1839. removeClass(nav, "opened");
  1840. removeClass(nav, opts.navClass);
  1841. removeClass(nav, opts.navClass + "-" + this.index);
  1842. removeClass(htmlEl, opts.navActiveClass);
  1843. nav.removeAttribute("style");
  1844. nav.removeAttribute("aria-hidden");
  1845. removeEvent(window, "resize", this, false);
  1846. removeEvent(window, "focus", this, false);
  1847. removeEvent(document.body, "touchmove", this, false);
  1848. removeEvent(navToggle, "touchstart", this, false);
  1849. removeEvent(navToggle, "touchend", this, false);
  1850. removeEvent(navToggle, "mouseup", this, false);
  1851. removeEvent(navToggle, "keyup", this, false);
  1852. removeEvent(navToggle, "click", this, false);
  1853. if (!opts.customToggle) {
  1854. navToggle.parentNode.removeChild(navToggle);
  1855. } else {
  1856. navToggle.removeAttribute("aria-hidden");
  1857. }
  1858. },
  1859. /**
  1860. * Toggles the navigation open/close
  1861. */
  1862. toggle: function() {
  1863. if (hasAnimFinished === true) {
  1864. if (!navOpen) {
  1865. this.open();
  1866. } else {
  1867. this.close();
  1868. }
  1869. }
  1870. },
  1871. /**
  1872. * Opens the navigation
  1873. */
  1874. open: function() {
  1875. if (!navOpen) {
  1876. removeClass(nav, "closed");
  1877. addClass(nav, "opened");
  1878. addClass(htmlEl, opts.navActiveClass);
  1879. addClass(navToggle, "active");
  1880. nav.style.position = opts.openPos;
  1881. setAttributes(nav, {
  1882. "aria-hidden": "false"
  1883. });
  1884. navOpen = true;
  1885. opts.open();
  1886. }
  1887. },
  1888. /**
  1889. * Closes the navigation
  1890. */
  1891. close: function() {
  1892. if (navOpen) {
  1893. addClass(nav, "closed");
  1894. removeClass(nav, "opened");
  1895. removeClass(htmlEl, opts.navActiveClass);
  1896. removeClass(navToggle, "active");
  1897. setAttributes(nav, {
  1898. "aria-hidden": "true"
  1899. });
  1900. // If animations are enabled, wait until they finish
  1901. if (opts.animate) {
  1902. hasAnimFinished = false;
  1903. setTimeout(function() {
  1904. nav.style.position = "absolute";
  1905. hasAnimFinished = true;
  1906. },
  1907. opts.transition + 10);
  1908. // Animations aren't enabled, we can do these immediately
  1909. } else {
  1910. nav.style.position = "absolute";
  1911. }
  1912. navOpen = false;
  1913. opts.close();
  1914. }
  1915. },
  1916. /**
  1917. * Resize is called on window resize and orientation change.
  1918. * It initializes the CSS styles and height calculations.
  1919. */
  1920. resize: function() {
  1921. // Resize watches navigation toggle's display state
  1922. if (window.getComputedStyle(navToggle, null).getPropertyValue("display") !== "none") {
  1923. isMobile = true;
  1924. setAttributes(navToggle, {
  1925. "aria-hidden": "false"
  1926. });
  1927. // If the navigation is hidden
  1928. if (nav.className.match(/(^|\s)closed(\s|$)/)) {
  1929. setAttributes(nav, {
  1930. "aria-hidden": "true"
  1931. });
  1932. nav.style.position = "absolute";
  1933. }
  1934. this._createStyles();
  1935. this._calcHeight();
  1936. } else {
  1937. isMobile = false;
  1938. setAttributes(navToggle, {
  1939. "aria-hidden": "true"
  1940. });
  1941. setAttributes(nav, {
  1942. "aria-hidden": "false"
  1943. });
  1944. nav.style.position = opts.openPos;
  1945. this._removeStyles();
  1946. }
  1947. },
  1948. /**
  1949. * Takes care of all even handling
  1950. *
  1951. * @param {event} event
  1952. * @return {type} returns the type of event that should be used
  1953. */
  1954. handleEvent: function(e) {
  1955. var evt = e || window.event;
  1956. switch (evt.type) {
  1957. case "touchstart":
  1958. this._onTouchStart(evt);
  1959. break;
  1960. case "touchmove":
  1961. this._onTouchMove(evt);
  1962. break;
  1963. case "touchend":
  1964. case "mouseup":
  1965. this._onTouchEnd(evt);
  1966. break;
  1967. case "click":
  1968. this._preventDefault(evt);
  1969. break;
  1970. case "keyup":
  1971. this._onKeyUp(evt);
  1972. break;
  1973. case "focus":
  1974. case "resize":
  1975. this.resize(evt);
  1976. break;
  1977. }
  1978. },
  1979. /**
  1980. * Initializes the widget
  1981. */
  1982. _init: function() {
  1983. this.index = index++;
  1984. addClass(nav, opts.navClass);
  1985. addClass(nav, opts.navClass + "-" + this.index);
  1986. addClass(nav, "closed");
  1987. hasAnimFinished = true;
  1988. navOpen = false;
  1989. this._closeOnNavClick();
  1990. this._createToggle();
  1991. this._transitions();
  1992. this.resize();
  1993. /**
  1994. * On IE8 the resize event triggers too early for some reason
  1995. * so it's called here again on init to make sure all the
  1996. * calculated styles are correct.
  1997. */
  1998. var self = this;
  1999. setTimeout(function() {
  2000. self.resize();
  2001. },
  2002. 20);
  2003. addEvent(window, "resize", this, false);
  2004. addEvent(window, "focus", this, false);
  2005. addEvent(document.body, "touchmove", this, false);
  2006. addEvent(navToggle, "touchstart", this, false);
  2007. addEvent(navToggle, "touchend", this, false);
  2008. addEvent(navToggle, "mouseup", this, false);
  2009. addEvent(navToggle, "keyup", this, false);
  2010. addEvent(navToggle, "click", this, false);
  2011. /**
  2012. * Init callback here
  2013. */
  2014. opts.init();
  2015. },
  2016. /**
  2017. * Creates Styles to the <head>
  2018. */
  2019. _createStyles: function() {
  2020. if (!styleElement.parentNode) {
  2021. styleElement.type = "text/css";
  2022. document.getElementsByTagName("head")[0].appendChild(styleElement);
  2023. }
  2024. },
  2025. /**
  2026. * Removes styles from the <head>
  2027. */
  2028. _removeStyles: function() {
  2029. if (styleElement.parentNode) {
  2030. styleElement.parentNode.removeChild(styleElement);
  2031. }
  2032. },
  2033. /**
  2034. * Creates Navigation Toggle
  2035. */
  2036. _createToggle: function() {
  2037. // If there's no toggle, let's create one
  2038. if (!opts.customToggle) {
  2039. var toggle = document.createElement("a");
  2040. toggle.innerHTML = opts.label;
  2041. setAttributes(toggle, {
  2042. "href": "#",
  2043. "class": "nav-toggle"
  2044. });
  2045. // Determine where to insert the toggle
  2046. if (opts.insert === "after") {
  2047. nav.parentNode.insertBefore(toggle, nav.nextSibling);
  2048. } else {
  2049. nav.parentNode.insertBefore(toggle, nav);
  2050. }
  2051. navToggle = toggle;
  2052. // There is a toggle already, let's use that one
  2053. } else {
  2054. var toggleEl = opts.customToggle.replace("#", "");
  2055. if (document.getElementById(toggleEl)) {
  2056. navToggle = document.getElementById(toggleEl);
  2057. } else if (document.querySelector(toggleEl)) {
  2058. navToggle = document.querySelector(toggleEl);
  2059. } else {
  2060. throw new Error("The custom nav toggle you are trying to select doesn't exist");
  2061. }
  2062. }
  2063. },
  2064. /**
  2065. * Closes the navigation when a link inside is clicked.
  2066. */
  2067. _closeOnNavClick: function() {
  2068. if (opts.closeOnNavClick) {
  2069. var links = nav.getElementsByTagName("a"),
  2070. self = this;
  2071. forEach(links,
  2072. function(i, el) {
  2073. addEvent(links[i], "click",
  2074. function() {
  2075. if (isMobile) {
  2076. self.toggle();
  2077. }
  2078. },
  2079. false);
  2080. });
  2081. }
  2082. },
  2083. /**
  2084. * Prevents the default functionality.
  2085. *
  2086. * @param {event} event
  2087. */
  2088. _preventDefault: function(e) {
  2089. if (e.preventDefault) {
  2090. if (e.stopImmediatePropagation) {
  2091. e.stopImmediatePropagation();
  2092. }
  2093. e.preventDefault();
  2094. e.stopPropagation();
  2095. return false;
  2096. // This is strictly for old IE
  2097. } else {
  2098. e.returnValue = false;
  2099. }
  2100. },
  2101. /**
  2102. * On touch start we get the location of the touch.
  2103. *
  2104. * @param {event} event
  2105. */
  2106. _onTouchStart: function(e) {
  2107. if (!Event.prototype.stopImmediatePropagation) {
  2108. this._preventDefault(e);
  2109. }
  2110. this.startX = e.touches[0].clientX;
  2111. this.startY = e.touches[0].clientY;
  2112. this.touchHasMoved = false;
  2113. /**
  2114. * Remove mouseup event completely here to avoid
  2115. * double triggering the event.
  2116. */
  2117. removeEvent(navToggle, "mouseup", this, false);
  2118. },
  2119. /**
  2120. * Check if the user is scrolling instead of tapping.
  2121. *
  2122. * @param {event} event
  2123. */
  2124. _onTouchMove: function(e) {
  2125. if (Math.abs(e.touches[0].clientX - this.startX) > 10 || Math.abs(e.touches[0].clientY - this.startY) > 10) {
  2126. this.touchHasMoved = true;
  2127. }
  2128. },
  2129. /**
  2130. * On touch end toggle the navigation.
  2131. *
  2132. * @param {event} event
  2133. */
  2134. _onTouchEnd: function(e) {
  2135. this._preventDefault(e);
  2136. if (!isMobile) {
  2137. return;
  2138. }
  2139. // If the user isn't scrolling
  2140. if (!this.touchHasMoved) {
  2141. // If the event type is touch
  2142. if (e.type === "touchend") {
  2143. this.toggle();
  2144. return;
  2145. // Event type was click, not touch
  2146. } else {
  2147. var evt = e || window.event;
  2148. // If it isn't a right click, do toggling
  2149. if (! (evt.which === 3 || evt.button === 2)) {
  2150. this.toggle();
  2151. }
  2152. }
  2153. }
  2154. },
  2155. /**
  2156. * For keyboard accessibility, toggle the navigation on Enter
  2157. * keypress too.
  2158. *
  2159. * @param {event} event
  2160. */
  2161. _onKeyUp: function(e) {
  2162. var evt = e || window.event;
  2163. if (evt.keyCode === 13) {
  2164. this.toggle();
  2165. }
  2166. },
  2167. /**
  2168. * Adds the needed CSS transitions if animations are enabled
  2169. */
  2170. _transitions: function() {
  2171. if (opts.animate) {
  2172. var objStyle = nav.style,
  2173. transition = "max-height " + opts.transition + "ms";
  2174. objStyle.WebkitTransition = objStyle.MozTransition = objStyle.OTransition = objStyle.transition = transition;
  2175. }
  2176. },
  2177. /**
  2178. * Calculates the height of the navigation and then creates
  2179. * styles which are later added to the page <head>
  2180. */
  2181. _calcHeight: function() {
  2182. var savedHeight = 0;
  2183. for (var i = 0; i < nav.inner.length; i++) {
  2184. savedHeight += nav.inner[i].offsetHeight;
  2185. }
  2186. var innerStyles = "." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important} ." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened.dropdown-active {max-height:9999px !important}";
  2187. if (styleElement.styleSheet) {
  2188. styleElement.styleSheet.cssText = innerStyles;
  2189. } else {
  2190. styleElement.innerHTML = innerStyles;
  2191. }
  2192. innerStyles = "";
  2193. }
  2194. };
  2195. /**
  2196. * Return new Responsive Nav
  2197. */
  2198. return new ResponsiveNav(el, options);
  2199. };
  2200. if (typeof module !== "undefined" && module.exports) {
  2201. module.exports = responsiveNav;
  2202. } else {
  2203. window.responsiveNav = responsiveNav;
  2204. }
  2205. } (document, window, 0));
  2206. /* =======================================================================
  2207. * jQuery.placeholder.js 兼容性处理
  2208. * ======================================================================== */
  2209. !function(window, document, $) {
  2210. var isInputSupported = 'placeholder' in document.createElement('input');
  2211. var isTextareaSupported = 'placeholder' in document.createElement('textarea');
  2212. var prototype = $.fn;
  2213. var valHooks = $.valHooks;
  2214. var propHooks = $.propHooks;
  2215. var hooks;
  2216. var placeholder;
  2217. if (isInputSupported && isTextareaSupported) {
  2218. placeholder = prototype.placeholder = function() {
  2219. return this;
  2220. };
  2221. placeholder.input = placeholder.textarea = true;
  2222. } else {
  2223. placeholder = prototype.placeholder = function() {
  2224. var $this = this;
  2225. $this.filter((isInputSupported ? 'textarea': ':input') + '[placeholder]').not('.placeholder').on({
  2226. 'focus.placeholder': clearPlaceholder,
  2227. 'blur.placeholder': setPlaceholder
  2228. }).data('placeholder-enabled', true).trigger('blur.placeholder');
  2229. return $this;
  2230. };
  2231. placeholder.input = isInputSupported;
  2232. placeholder.textarea = isTextareaSupported;
  2233. hooks = {
  2234. 'get': function(element) {
  2235. var $element = $(element);
  2236. var $passwordInput = $element.data('placeholder-password');
  2237. if ($passwordInput) {
  2238. return $passwordInput[0].value;
  2239. }
  2240. return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '': element.value;
  2241. },
  2242. 'set': function(element, value) {
  2243. var $element = $(element);
  2244. var $passwordInput = $element.data('placeholder-password');
  2245. if ($passwordInput) {
  2246. return $passwordInput[0].value = value;
  2247. }
  2248. if (!$element.data('placeholder-enabled')) {
  2249. return element.value = value;
  2250. }
  2251. if (value == '') {
  2252. element.value = value;
  2253. if (element != safeActiveElement()) {
  2254. setPlaceholder.call(element);
  2255. }
  2256. } else if ($element.hasClass('placeholder')) {
  2257. clearPlaceholder.call(element, true, value) || (element.value = value);
  2258. } else {
  2259. element.value = value;
  2260. }
  2261. return $element;
  2262. }
  2263. };
  2264. if (!isInputSupported) {
  2265. valHooks.input = hooks;
  2266. propHooks.value = hooks;
  2267. }
  2268. if (!isTextareaSupported) {
  2269. valHooks.textarea = hooks;
  2270. propHooks.value = hooks;
  2271. }
  2272. $(function() {
  2273. $(document).delegate('form', 'submit.placeholder',
  2274. function() {
  2275. var $inputs = $('.placeholder', this).each(clearPlaceholder);
  2276. setTimeout(function() {
  2277. $inputs.each(setPlaceholder);
  2278. },
  2279. 10);
  2280. });
  2281. });
  2282. $(window).on('beforeunload.placeholder',
  2283. function() {
  2284. $('.placeholder').each(function() {
  2285. this.value = '';
  2286. });
  2287. });
  2288. }
  2289. function args(elem) {
  2290. var newAttrs = {};
  2291. var rinlinejQuery = /^jQuery\d+$/;
  2292. $.each(elem.attributes,
  2293. function(i, attr) {
  2294. if (attr.specified && !rinlinejQuery.test(attr.name)) {
  2295. newAttrs[attr.name] = attr.value;
  2296. }
  2297. });
  2298. return newAttrs;
  2299. }
  2300. function clearPlaceholder(event, value) {
  2301. var input = this;
  2302. var $input = $(input);
  2303. if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
  2304. if ($input.data('placeholder-password')) {
  2305. $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
  2306. if (event === true) {
  2307. return $input[0].value = value;
  2308. }
  2309. $input.focus();
  2310. } else {
  2311. input.value = '';
  2312. $input.removeClass('placeholder');
  2313. input == safeActiveElement() && input.select();
  2314. }
  2315. }
  2316. }
  2317. function setPlaceholder() {
  2318. var $replacement;
  2319. var input = this;
  2320. var $input = $(input);
  2321. var id = this.id;
  2322. if (input.value == '') {
  2323. if (input.type == 'password') {
  2324. if (!$input.data('placeholder-textinput')) {
  2325. try {
  2326. $replacement = $input.clone().prop('type', 'text');
  2327. } catch(e) {
  2328. $replacement = $('<input>').prop($.extend(args(this), {
  2329. 'type': 'text'
  2330. }));
  2331. }
  2332. $replacement.removeAttr('name').data({
  2333. 'placeholder-password': $input,
  2334. 'placeholder-id': id
  2335. }).on('focus.placeholder', clearPlaceholder);
  2336. $input.data({
  2337. 'placeholder-textinput': $replacement,
  2338. 'placeholder-id': id
  2339. }).before($replacement);
  2340. }
  2341. $input = $input.removeAttr('id').hide().prev().attr('id', id).show();
  2342. }
  2343. $input.addClass('placeholder');
  2344. $input[0].value = $input.attr('placeholder');
  2345. } else {
  2346. $input.removeClass('placeholder');
  2347. }
  2348. }
  2349. function safeActiveElement() {
  2350. try {
  2351. return document.activeElement;
  2352. } catch(exception) {}
  2353. }
  2354. } (this, document, jQuery);
  2355. /* =======================================================================
  2356. * jquery.emailsuggest.js v1.0 邮箱自动提示
  2357. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2358. * ======================================================================== */
  2359. !function($) {
  2360. var
  2361. // 插件名
  2362. plugin = 'emailsuggest',
  2363. // 默认参数配置
  2364. defaults = {
  2365. sugClass: 'emailSug',
  2366. domains: ['163.com', '126.com', 'sohu.com', '139.com', 'sina.com', 'qq.com', 'gmail.com']
  2367. };
  2368. function EmailSug(elem, options) {
  2369. this.$field = $(elem);
  2370. this.options = $.extend(true, {},
  2371. defaults, options);
  2372. this._defaults = defaults;
  2373. this._domains = this.options.domains;
  2374. // 当前选中元素下标
  2375. this.selectedIndex = 0;
  2376. this.init();
  2377. }
  2378. EmailSug.prototype = {
  2379. init: function() {
  2380. this.addEvent();
  2381. },
  2382. addEvent: function() {
  2383. var that = this,
  2384. value;
  2385. this.$field.on('keyup.ema',
  2386. function(e) {
  2387. value = $.trim(this.value);
  2388. if (value) {
  2389. that.create(this, value);
  2390. that.doSelect(e.keyCode);
  2391. } else {
  2392. that.hide();
  2393. }
  2394. }).on('blur.ema',
  2395. function() {
  2396. setTimeout(function() {
  2397. that.hide();
  2398. },
  2399. 200);
  2400. });
  2401. },
  2402. create: function(elem, value) {
  2403. var that = this,
  2404. arr, len, fragment, ul = [],
  2405. offset,
  2406. left,
  2407. top,
  2408. width,
  2409. height,
  2410. style,
  2411. // 左右边框
  2412. borderWidth = 2;
  2413. elem = $(elem);
  2414. offset = elem.offset();
  2415. width = elem.outerWidth(true) - borderWidth;
  2416. height = elem.outerHeight(true);
  2417. left = offset.left;
  2418. top = offset.top + height;
  2419. style = 'left: ' + left + 'px; top: ' + top + 'px; width: ' + width + 'px; border: 1px solid #e2e2e2; border-top: 0; display: none';
  2420. fragment = $('<div class="' + this.options.sugClass + '-wrapper" style="' + style + '" />');
  2421. ul.push('<ul class="' + this.options.sugClass + '-list">');
  2422. arr = this.filter(value, this._domains);
  2423. len = arr.length;
  2424. $.each(arr,
  2425. function(i, domain) {
  2426. var _class = that.options.sugClass + '-item';
  2427. if (that.selectedIndex > len - 1) {
  2428. if (i === 0) {
  2429. _class += ' active';
  2430. that.selectedIndex = 0;
  2431. }
  2432. } else {
  2433. if (i === that.selectedIndex) {
  2434. _class += ' active';
  2435. }
  2436. }
  2437. ul.push('<li class="' + _class + '" data-index="' + i + '">' + value.replace(/@.*/, '') + '@' + domain + '</li>');
  2438. });
  2439. ul.push('</ul>');
  2440. ul = ul.join('');
  2441. if (this.$suggest) {
  2442. this.$suggest.empty();
  2443. this.$suggest.append(ul);
  2444. } else {
  2445. fragment.append(ul);
  2446. // 显示到页面
  2447. $('body').append(fragment);
  2448. this.$suggest = fragment;
  2449. this.$suggest.on('mouseenter click', '.' + this.options.sugClass + '-item',
  2450. function(e) {
  2451. var lis, li;
  2452. li = $(this);
  2453. lis = li.parent().children();
  2454. if (e.type === 'mouseenter') {
  2455. li.addClass('active').siblings().removeClass('active');
  2456. that.selectedIndex = $.inArray(this, lis);
  2457. } else {
  2458. // 当前选中
  2459. that.$field.val(lis.eq(that.selectedIndex).text());
  2460. // 隐藏email sug
  2461. that.hide();
  2462. }
  2463. });
  2464. }
  2465. this.show();
  2466. },
  2467. doSelect: function(keyCode) {
  2468. var elems = $('.' + this.options.sugClass + '-item', this.$suggest),
  2469. min = 0,
  2470. max = elems.length - 1;
  2471. switch (keyCode) {
  2472. case 13:
  2473. // 回车选中当前已选项
  2474. $('li.active', this.$suggest).trigger('click');
  2475. // 下标重置
  2476. this.selectedIndex = 0;
  2477. break;
  2478. // 向上
  2479. case 38:
  2480. this.selectedIndex--;
  2481. if (this.selectedIndex < min) {
  2482. this.selectedIndex = max;
  2483. }
  2484. elems.removeClass('active').eq(this.selectedIndex).addClass('active');
  2485. break;
  2486. // 向下
  2487. case 40:
  2488. this.selectedIndex++;
  2489. if (this.selectedIndex > max) {
  2490. this.selectedIndex = min;
  2491. }
  2492. elems.removeClass('active').eq(this.selectedIndex).addClass('active');
  2493. break;
  2494. default:
  2495. break;
  2496. }
  2497. },
  2498. filter: function(value, arr) {
  2499. var start, suffix, r = [];
  2500. start = value.indexOf('@');
  2501. if (start > -1) {
  2502. suffix = value.substring(start + 1);
  2503. $.each(arr,
  2504. function(i, str) {
  2505. if (str.indexOf(suffix) > -1) {
  2506. r.push(str);
  2507. }
  2508. });
  2509. } else {
  2510. r = arr;
  2511. }
  2512. return r;
  2513. },
  2514. show: function() {
  2515. if (this.$suggest) {
  2516. this.$suggest.show();
  2517. }
  2518. },
  2519. hide: function() {
  2520. if (this.$suggest) {
  2521. this.$suggest.hide();
  2522. }
  2523. }
  2524. }
  2525. $.fn[plugin] = function(options) {
  2526. return this.each(function() {
  2527. if (!$.data(this, plugin)) {
  2528. $.data(this, plugin, new EmailSug(this, options));
  2529. }
  2530. });
  2531. }
  2532. } (window.jQuery);
  2533. /* =======================================================================
  2534. * jQuery.Spinner.js 微调器
  2535. * ========================================================================*/
  2536. !function($) {
  2537. $.fn.Spinner = function(opts) {
  2538. var defaults = {
  2539. value: 1,
  2540. min: 1,
  2541. len: 3,
  2542. max: 99
  2543. }
  2544. var options = $.extend(defaults, opts);
  2545. var keyCodes = {
  2546. up: 38,
  2547. down: 40
  2548. }
  2549. return this.each(function() {
  2550. var a = $('<a></a>');
  2551. f(a, 0, "decrease", "-"); //加
  2552. var c = $('<a></a>');
  2553. f(c, 0, "increase", "+"); //减
  2554. var b = $('<input/>');
  2555. f(b, 1, "amount input-text");
  2556. cv(0); //值
  2557. $(this).append(a).append(b).append(c);
  2558. a.click(function() {
  2559. cv( - 1)
  2560. });
  2561. b.keyup(function() {
  2562. cv(0)
  2563. });
  2564. c.click(function() {
  2565. cv( + 1)
  2566. });
  2567. b.on('keyup paste change',
  2568. function(e) {
  2569. e.keyCode == keyCodes.up && cv( + 1);
  2570. e.keyCode == keyCodes.down && cv( - 1);
  2571. });
  2572. function cv(n) {
  2573. b.val(b.val().replace(/[^\d]/g, ''));
  2574. bv = parseInt(b.val() || options.min) + n;
  2575. bv >= options.min && bv <= options.max && b.val(bv);
  2576. if (bv <= options.min) {
  2577. b.val(options.min);
  2578. f(a, 2, "disDe", "decrease");
  2579. } else {
  2580. f(a, 2, "decrease", "disDe");
  2581. }
  2582. if (bv >= options.max) {
  2583. b.val(options.max);
  2584. f(c, 2, "disIn", "Increase");
  2585. } else {
  2586. f(c, 2, "increase", "disIn");
  2587. }
  2588. }
  2589. });
  2590. function f(o, t, c, s) {
  2591. t == 0 && o.addClass(c).attr("href", "javascript:void(0)").append("<i></i>").find("i").append(s);
  2592. t == 1 && o.addClass(c).attr({
  2593. "value": options.value,
  2594. "autocomplete": "off",
  2595. "maxlength": options.len
  2596. });
  2597. t == 2 && o.addClass(c).removeClass(s);
  2598. }
  2599. }
  2600. } (window.jQuery);
  2601. /* =======================================================================
  2602. * jQuery.format.js 金额格式化
  2603. * ========================================================================*/
  2604. !function($) {
  2605. $.extend({
  2606. format: function(str, step, splitor) {
  2607. str = str.toString();
  2608. var len = str.length;
  2609. if (len > step) {
  2610. var l1 = len % step,
  2611. l2 = parseInt(len / step),
  2612. arr = [],
  2613. first = str.substr(0, l1);
  2614. if (first != '') {
  2615. arr.push(first);
  2616. };
  2617. for (var i = 0; i < l2; i++) {
  2618. arr.push(str.substr(l1 + i * step, step));
  2619. };
  2620. str = arr.join(splitor);
  2621. };
  2622. return str;
  2623. }
  2624. });
  2625. } (window.jQuery);
  2626. /* =======================================================================
  2627. * jquery.togglePassword.js 隐藏显示密码
  2628. * type="password"
  2629. * ========================================================================*/
  2630. !function($) {
  2631. $.fn.togglePassword = function(options) {
  2632. var s = $.extend($.fn.togglePassword.defaults, options),
  2633. input = $(this);
  2634. $(s.el).on(s.ev,
  2635. function() {
  2636. "password" == $(input).attr("type") ? $(input).attr("type", "text") : $(input).attr("type", "password");
  2637. });
  2638. };
  2639. $.fn.togglePassword.defaults = {
  2640. ev: "click"
  2641. };
  2642. } (window.jQuery);
  2643. /* =======================================================================
  2644. * jQuery.iCheck.js v1.0.2, http://git.io/arlzeA
  2645. * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization
  2646. *
  2647. * (c) 2013 Damir Sultanov, http://fronteed.com
  2648. * MIT Licensed
  2649. * ======================================================================== */
  2650. !(function($) {
  2651. // Cached vars
  2652. var _iCheck = 'iCheck',
  2653. _iCheckHelper = _iCheck + '-helper',
  2654. _checkbox = 'checkbox',
  2655. _radio = 'radio',
  2656. _checked = 'checked',
  2657. _unchecked = 'un' + _checked,
  2658. _disabled = 'disabled',
  2659. _determinate = 'determinate',
  2660. _indeterminate = 'in' + _determinate,
  2661. _update = 'update',
  2662. _type = 'type',
  2663. _click = 'click',
  2664. _touch = 'touchbegin.i touchend.i',
  2665. _add = 'addClass',
  2666. _remove = 'removeClass',
  2667. _callback = 'trigger',
  2668. _label = 'label',
  2669. _cursor = 'cursor',
  2670. _mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
  2671. // Plugin init
  2672. $.fn[_iCheck] = function(options, fire) {
  2673. // Walker
  2674. var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
  2675. stack = $(),
  2676. walker = function(object) {
  2677. object.each(function() {
  2678. var self = $(this);
  2679. if (self.is(handle)) {
  2680. stack = stack.add(self);
  2681. } else {
  2682. stack = stack.add(self.find(handle));
  2683. }
  2684. });
  2685. };
  2686. // Check if we should operate with some method
  2687. if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
  2688. // Normalize method's name
  2689. options = options.toLowerCase();
  2690. // Find checkboxes and radio buttons
  2691. walker(this);
  2692. return stack.each(function() {
  2693. var self = $(this);
  2694. if (options == 'destroy') {
  2695. tidy(self, 'ifDestroyed');
  2696. } else {
  2697. operate(self, true, options);
  2698. }
  2699. // Fire method's callback
  2700. if ($.isFunction(fire)) {
  2701. fire();
  2702. }
  2703. });
  2704. // Customization
  2705. } else if (typeof options == 'object' || !options) {
  2706. // Check if any options were passed
  2707. var settings = $.extend({
  2708. checkedClass: _checked,
  2709. disabledClass: _disabled,
  2710. indeterminateClass: _indeterminate,
  2711. labelHover: true
  2712. },
  2713. options),
  2714. selector = settings.handle,
  2715. hoverClass = settings.hoverClass || 'hover',
  2716. focusClass = settings.focusClass || 'focus',
  2717. activeClass = settings.activeClass || 'active',
  2718. labelHover = !!settings.labelHover,
  2719. labelHoverClass = settings.labelHoverClass || 'hover',
  2720. // Setup clickable area
  2721. area = ('' + settings.increaseArea).replace('%', '') | 0;
  2722. // Selector limit
  2723. if (selector == _checkbox || selector == _radio) {
  2724. handle = 'input[type="' + selector + '"]';
  2725. }
  2726. // Clickable area limit
  2727. if (area < -50) {
  2728. area = -50;
  2729. }
  2730. // Walk around the selector
  2731. walker(this);
  2732. return stack.each(function() {
  2733. var self = $(this);
  2734. // If already customized
  2735. tidy(self);
  2736. var node = this,
  2737. id = node.id,
  2738. // Layer styles
  2739. offset = -area + '%',
  2740. size = 100 + (area * 2) + '%',
  2741. layer = {
  2742. position: 'absolute',
  2743. top: offset,
  2744. left: offset,
  2745. display: 'block',
  2746. width: size,
  2747. height: size,
  2748. margin: 0,
  2749. padding: 0,
  2750. background: '#fff',
  2751. border: 0,
  2752. opacity: 0
  2753. },
  2754. // Choose how to hide input
  2755. hide = _mobile ? {
  2756. position: 'absolute',
  2757. visibility: 'hidden'
  2758. }: area ? layer: {
  2759. position: 'absolute',
  2760. opacity: 0
  2761. },
  2762. // Get proper class
  2763. className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox: settings.radioClass || 'i' + _radio,
  2764. // Find assigned labels
  2765. label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
  2766. // Check ARIA option
  2767. aria = !!settings.aria,
  2768. // Set ARIA placeholder
  2769. ariaID = _iCheck + '-' + Math.random().toString(36).substr(2, 6),
  2770. // Parent & helper
  2771. parent = '<div class="' + className + '" ' + (aria ? 'role="' + node[_type] + '" ': ''),
  2772. helper;
  2773. // Set ARIA "labelledby"
  2774. if (aria) {
  2775. label.each(function() {
  2776. parent += 'aria-labelledby="';
  2777. if (this.id) {
  2778. parent += this.id;
  2779. } else {
  2780. this.id = ariaID;
  2781. parent += ariaID;
  2782. }
  2783. parent += '"';
  2784. });
  2785. }
  2786. // Wrap input
  2787. parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);
  2788. // Layer addition
  2789. helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);
  2790. // Finalize customization
  2791. self.data(_iCheck, {
  2792. o: settings,
  2793. s: self.attr('style')
  2794. }).css(hide); !! settings.inheritClass && parent[_add](node.className || ''); !! settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
  2795. parent.css('position') == 'static' && parent.css('position', 'relative');
  2796. operate(self, true, _update);
  2797. // Label events
  2798. if (label.length) {
  2799. label.on(_click + '.i mouseover.i mouseout.i ' + _touch,
  2800. function(event) {
  2801. var type = event[_type],
  2802. item = $(this);
  2803. // Do nothing if input is disabled
  2804. if (!node[_disabled]) {
  2805. // Click
  2806. if (type == _click) {
  2807. if ($(event.target).is('a')) {
  2808. return;
  2809. }
  2810. operate(self, false, true);
  2811. // Hover state
  2812. } else if (labelHover) {
  2813. // mouseout|touchend
  2814. if (/ut|nd/.test(type)) {
  2815. parent[_remove](hoverClass);
  2816. item[_remove](labelHoverClass);
  2817. } else {
  2818. parent[_add](hoverClass);
  2819. item[_add](labelHoverClass);
  2820. }
  2821. }
  2822. if (_mobile) {
  2823. event.stopPropagation();
  2824. } else {
  2825. return false;
  2826. }
  2827. }
  2828. });
  2829. }
  2830. // Input events
  2831. self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i',
  2832. function(event) {
  2833. var type = event[_type],
  2834. key = event.keyCode;
  2835. // Click
  2836. if (type == _click) {
  2837. return false;
  2838. // Keydown
  2839. } else if (type == 'keydown' && key == 32) {
  2840. if (! (node[_type] == _radio && node[_checked])) {
  2841. if (node[_checked]) {
  2842. off(self, _checked);
  2843. } else {
  2844. on(self, _checked);
  2845. }
  2846. }
  2847. return false;
  2848. // Keyup
  2849. } else if (type == 'keyup' && node[_type] == _radio) { ! node[_checked] && on(self, _checked);
  2850. // Focus/blur
  2851. } else if (/us|ur/.test(type)) {
  2852. parent[type == 'blur' ? _remove: _add](focusClass);
  2853. }
  2854. });
  2855. // Helper events
  2856. helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch,
  2857. function(event) {
  2858. var type = event[_type],
  2859. // mousedown|mouseup
  2860. toggle = /wn|up/.test(type) ? activeClass: hoverClass;
  2861. // Do nothing if input is disabled
  2862. if (!node[_disabled]) {
  2863. // Click
  2864. if (type == _click) {
  2865. operate(self, false, true);
  2866. // Active and hover states
  2867. } else {
  2868. // State is on
  2869. if (/wn|er|in/.test(type)) {
  2870. // mousedown|mouseover|touchbegin
  2871. parent[_add](toggle);
  2872. // State is off
  2873. } else {
  2874. parent[_remove](toggle + ' ' + activeClass);
  2875. }
  2876. // Label hover
  2877. if (label.length && labelHover && toggle == hoverClass) {
  2878. // mouseout|touchend
  2879. label[/ut|nd/.test(type) ? _remove: _add](labelHoverClass);
  2880. }
  2881. }
  2882. if (_mobile) {
  2883. event.stopPropagation();
  2884. } else {
  2885. return false;
  2886. }
  2887. }
  2888. });
  2889. });
  2890. } else {
  2891. return this;
  2892. }
  2893. };
  2894. // Do something with inputs
  2895. function operate(input, direct, method) {
  2896. var node = input[0],
  2897. state = /er/.test(method) ? _indeterminate: /bl/.test(method) ? _disabled: _checked,
  2898. active = method == _update ? {
  2899. checked: node[_checked],
  2900. disabled: node[_disabled],
  2901. indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
  2902. }: node[state];
  2903. // Check, disable or indeterminate
  2904. if (/^(ch|di|in)/.test(method) && !active) {
  2905. on(input, state);
  2906. // Uncheck, enable or determinate
  2907. } else if (/^(un|en|de)/.test(method) && active) {
  2908. off(input, state);
  2909. // Update
  2910. } else if (method == _update) {
  2911. // Handle states
  2912. for (var each in active) {
  2913. if (active[each]) {
  2914. on(input, each, true);
  2915. } else {
  2916. off(input, each, true);
  2917. }
  2918. }
  2919. } else if (!direct || method == 'toggle') {
  2920. // Helper or label was clicked
  2921. if (!direct) {
  2922. input[_callback]('ifClicked');
  2923. }
  2924. // Toggle checked state
  2925. if (active) {
  2926. if (node[_type] !== _radio) {
  2927. off(input, state);
  2928. }
  2929. } else {
  2930. on(input, state);
  2931. }
  2932. }
  2933. }
  2934. // Add checked, disabled or indeterminate state
  2935. function on(input, state, keep) {
  2936. var node = input[0],
  2937. parent = input.parent(),
  2938. checked = state == _checked,
  2939. indeterminate = state == _indeterminate,
  2940. disabled = state == _disabled,
  2941. callback = indeterminate ? _determinate: checked ? _unchecked: 'enabled',
  2942. regular = option(input, callback + capitalize(node[_type])),
  2943. specific = option(input, state + capitalize(node[_type]));
  2944. // Prevent unnecessary actions
  2945. if (node[state] !== true) {
  2946. // Toggle assigned radio buttons
  2947. if (!keep && state == _checked && node[_type] == _radio && node.name) {
  2948. var form = input.closest('form'),
  2949. inputs = 'input[name="' + node.name + '"]';
  2950. inputs = form.length ? form.find(inputs) : $(inputs);
  2951. inputs.each(function() {
  2952. if (this !== node && $(this).data(_iCheck)) {
  2953. off($(this), state);
  2954. }
  2955. });
  2956. }
  2957. // Indeterminate state
  2958. if (indeterminate) {
  2959. // Add indeterminate state
  2960. node[state] = true;
  2961. // Remove checked state
  2962. if (node[_checked]) {
  2963. off(input, _checked, 'force');
  2964. }
  2965. // Checked or disabled state
  2966. } else {
  2967. // Add checked or disabled state
  2968. if (!keep) {
  2969. node[state] = true;
  2970. }
  2971. // Remove indeterminate state
  2972. if (checked && node[_indeterminate]) {
  2973. off(input, _indeterminate, false);
  2974. }
  2975. }
  2976. // Trigger callbacks
  2977. callbacks(input, checked, state, keep);
  2978. }
  2979. // Add proper cursor
  2980. if (node[_disabled] && !!option(input, _cursor, true)) {
  2981. parent.find('.' + _iCheckHelper).css(_cursor, 'default');
  2982. }
  2983. // Add state class
  2984. parent[_add](specific || option(input, state) || '');
  2985. // Set ARIA attribute
  2986. if ( !! parent.attr('role') && !indeterminate) {
  2987. parent.attr('aria-' + (disabled ? _disabled: _checked), 'true');
  2988. }
  2989. // Remove regular state class
  2990. parent[_remove](regular || option(input, callback) || '');
  2991. }
  2992. // Remove checked, disabled or indeterminate state
  2993. function off(input, state, keep) {
  2994. var node = input[0],
  2995. parent = input.parent(),
  2996. checked = state == _checked,
  2997. indeterminate = state == _indeterminate,
  2998. disabled = state == _disabled,
  2999. callback = indeterminate ? _determinate: checked ? _unchecked: 'enabled',
  3000. regular = option(input, callback + capitalize(node[_type])),
  3001. specific = option(input, state + capitalize(node[_type]));
  3002. // Prevent unnecessary actions
  3003. if (node[state] !== false) {
  3004. // Toggle state
  3005. if (indeterminate || !keep || keep == 'force') {
  3006. node[state] = false;
  3007. }
  3008. // Trigger callbacks
  3009. callbacks(input, checked, callback, keep);
  3010. }
  3011. // Add proper cursor
  3012. if (!node[_disabled] && !!option(input, _cursor, true)) {
  3013. parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
  3014. }
  3015. // Remove state class
  3016. parent[_remove](specific || option(input, state) || '');
  3017. // Set ARIA attribute
  3018. if ( !! parent.attr('role') && !indeterminate) {
  3019. parent.attr('aria-' + (disabled ? _disabled: _checked), 'false');
  3020. }
  3021. // Add regular state class
  3022. parent[_add](regular || option(input, callback) || '');
  3023. }
  3024. // Remove all traces
  3025. function tidy(input, callback) {
  3026. if (input.data(_iCheck)) {
  3027. // Remove everything except input
  3028. input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
  3029. // Callback
  3030. if (callback) {
  3031. input[_callback](callback);
  3032. }
  3033. // Unbind events
  3034. input.off('.i').unwrap();
  3035. $(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
  3036. }
  3037. }
  3038. // Get some option
  3039. function option(input, state, regular) {
  3040. if (input.data(_iCheck)) {
  3041. return input.data(_iCheck).o[state + (regular ? '': 'Class')];
  3042. }
  3043. }
  3044. // Capitalize some string
  3045. function capitalize(string) {
  3046. return string.charAt(0).toUpperCase() + string.slice(1);
  3047. }
  3048. // Executable handlers
  3049. function callbacks(input, checked, callback, keep) {
  3050. if (!keep) {
  3051. if (checked) {
  3052. input[_callback]('ifToggled');
  3053. }
  3054. input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
  3055. }
  3056. }
  3057. })(window.jQuery || window.Zepto);
  3058. /* =======================================================================
  3059. * jQuery.raty.js v2.4.5- A Star Rating Plugin
  3060. * -------------------------------------------------------------------
  3061. * jQuery Raty is a plugin that generates a customizable star rating.
  3062. * Licensed under The MIT License
  3063. *
  3064. * @version 2.4.5
  3065. * @since 2010.06.11
  3066. * @author Washington Botelho
  3067. * @documentation wbotelhos.com/raty
  3068. * @twitter twitter.com/wbotelhos
  3069. *
  3070. * Usage:
  3071. * -------------------------------------------------------------------
  3072. * $('#star').raty();
  3073. * <div id="star"></div>
  3074. * ======================================================================== */
  3075. !(function($) {
  3076. var methods = {
  3077. init: function(settings) {
  3078. return this.each(function() {
  3079. var self = this,
  3080. $this = $(self).empty();
  3081. self.opt = $.extend(true, {},
  3082. $.fn.raty.defaults, settings);
  3083. $this.data('settings', self.opt);
  3084. self.opt.number = methods.between(self.opt.number, 0, 20);
  3085. if (self.opt.path.substring(self.opt.path.length - 1, self.opt.path.length) != '/') {
  3086. self.opt.path += '/';
  3087. }
  3088. if (typeof self.opt.score == 'function') {
  3089. self.opt.score = self.opt.score.call(self);
  3090. }
  3091. if (self.opt.score) {
  3092. self.opt.score = methods.between(self.opt.score, 0, self.opt.number);
  3093. }
  3094. for (var i = 1; i <= self.opt.number; i++) {
  3095. $('<img />', {
  3096. src: self.opt.path + ((!self.opt.score || self.opt.score < i) ? self.opt.starOff: self.opt.starOn),
  3097. alt: i,
  3098. title: (i <= self.opt.hints.length && self.opt.hints[i - 1] !== null) ? self.opt.hints[i - 1] : i
  3099. }).appendTo(self);
  3100. if (self.opt.space) {
  3101. $this.append((i < self.opt.number) ? '': '');
  3102. }
  3103. }
  3104. self.stars = $this.children('img:not(".raty-cancel")');
  3105. self.score = $('<input />', {
  3106. type: 'hidden',
  3107. name: self.opt.scoreName
  3108. }).appendTo(self);
  3109. if (self.opt.score && self.opt.score > 0) {
  3110. self.score.val(self.opt.score);
  3111. methods.roundStar.call(self, self.opt.score);
  3112. }
  3113. if (self.opt.iconRange) {
  3114. methods.fill.call(self, self.opt.score); }
  3115. methods.setTarget.call(self, self.opt.score, self.opt.targetKeep);
  3116. var space = self.opt.space ? 4 : 0,
  3117. width = self.opt.width || (self.opt.number * self.opt.size + self.opt.number * space);
  3118. if (self.opt.cancel) {
  3119. self.cancel = $('<img />', {
  3120. src: self.opt.path + self.opt.cancelOff,
  3121. alt: 'x',
  3122. title: self.opt.cancelHint,
  3123. 'class': 'raty-cancel'
  3124. });
  3125. if (self.opt.cancelPlace == 'left') {
  3126. //$this.prepend('&#160;').prepend(self.cancel);
  3127. } else {
  3128. //$this.append('&#160;').append(self.cancel);
  3129. }
  3130. width += (self.opt.size + space);
  3131. }
  3132. if (self.opt.readOnly) {
  3133. methods.fixHint.call(self);
  3134. if (self.cancel) {
  3135. self.cancel.hide();
  3136. }
  3137. } else {
  3138. $this.css('cursor', 'pointer');
  3139. methods.bindAction.call(self);
  3140. }
  3141. //$this.css('width', width);
  3142. });
  3143. },
  3144. between: function(value, min, max) {
  3145. return Math.min(Math.max(parseFloat(value), min), max);
  3146. },
  3147. bindAction: function() {
  3148. var self = this,
  3149. $this = $(self);
  3150. $this.mouseleave(function() {
  3151. var score = self.score.val() || undefined;
  3152. methods.initialize.call(self, score);
  3153. methods.setTarget.call(self, score, self.opt.targetKeep);
  3154. if (self.opt.mouseover) {
  3155. self.opt.mouseover.call(self, score);
  3156. }
  3157. });
  3158. var action = self.opt.half ? 'mousemove': 'mouseover';
  3159. if (self.opt.cancel) {
  3160. self.cancel.mouseenter(function() {
  3161. $(this).attr('src', self.opt.path + self.opt.cancelOn);
  3162. self.stars.attr('src', self.opt.path + self.opt.starOff);
  3163. methods.setTarget.call(self, null, true);
  3164. if (self.opt.mouseover) {
  3165. self.opt.mouseover.call(self, null);
  3166. }
  3167. }).mouseleave(function() {
  3168. $(this).attr('src', self.opt.path + self.opt.cancelOff);
  3169. if (self.opt.mouseover) {
  3170. self.opt.mouseover.call(self, self.score.val() || null);
  3171. }
  3172. }).click(function(evt) {
  3173. self.score.removeAttr('value');
  3174. if (self.opt.click) {
  3175. self.opt.click.call(self, null, evt);
  3176. }
  3177. });
  3178. }
  3179. self.stars.bind(action,
  3180. function(evt) {
  3181. var value = parseInt(this.alt, 10);
  3182. if (self.opt.half) {
  3183. var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size),
  3184. diff = (position > .5) ? 1 : .5;
  3185. value = parseFloat(this.alt) - 1 + diff;
  3186. methods.fill.call(self, value);
  3187. if (self.opt.precision) {
  3188. value = value - diff + position;
  3189. }
  3190. methods.showHalf.call(self, value);
  3191. } else {
  3192. methods.fill.call(self, value);
  3193. }
  3194. $this.data('score', value);
  3195. methods.setTarget.call(self, value, true);
  3196. if (self.opt.mouseover) {
  3197. self.opt.mouseover.call(self, value, evt);
  3198. }
  3199. }).click(function(evt) {
  3200. self.score.val((self.opt.half || self.opt.precision) ? $this.data('score') : this.alt);
  3201. if (self.opt.click) {
  3202. self.opt.click.call(self, self.score.val(), evt);
  3203. }
  3204. });
  3205. },
  3206. cancel: function(isClick) {
  3207. return $(this).each(function() {
  3208. var self = this,
  3209. $this = $(self);
  3210. if ($this.data('readonly') === true) {
  3211. return this;
  3212. }
  3213. if (isClick) {
  3214. methods.click.call(self, null);
  3215. } else {
  3216. methods.score.call(self, null);
  3217. }
  3218. self.score.removeAttr('value');
  3219. });
  3220. },
  3221. click: function(score) {
  3222. return $(this).each(function() {
  3223. if ($(this).data('readonly') === true) {
  3224. return this;
  3225. }
  3226. methods.initialize.call(this, score);
  3227. if (this.opt.click) {
  3228. this.opt.click.call(this, score);
  3229. } else {
  3230. methods.error.call(this, 'you must add the "click: function(score, evt) { }" callback.');
  3231. }
  3232. methods.setTarget.call(this, score, true);
  3233. });
  3234. },
  3235. error: function(message) {
  3236. $(this).html(message);
  3237. $.error(message);
  3238. },
  3239. fill: function(score) {
  3240. var self = this,
  3241. number = self.stars.length,
  3242. count = 0,
  3243. $star, star, icon;
  3244. for (var i = 1; i <= number; i++) {
  3245. $star = self.stars.eq(i - 1);
  3246. if (self.opt.iconRange && self.opt.iconRange.length > count) {
  3247. star = self.opt.iconRange[count];
  3248. if (self.opt.single) {
  3249. icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
  3250. } else {
  3251. icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
  3252. }
  3253. if (i <= star.range) {
  3254. $star.attr('src', self.opt.path + icon);
  3255. }
  3256. if (i == star.range) {
  3257. count++;
  3258. }
  3259. } else {
  3260. if (self.opt.single) {
  3261. icon = (i == score) ? self.opt.starOn: self.opt.starOff;
  3262. } else {
  3263. icon = (i <= score) ? self.opt.starOn: self.opt.starOff;
  3264. }
  3265. $star.attr('src', self.opt.path + icon);
  3266. }
  3267. }
  3268. },
  3269. fixHint: function() {
  3270. var $this = $(this),
  3271. score = parseInt(this.score.val(), 10),
  3272. hint = this.opt.noRatedMsg;
  3273. if (!isNaN(score) && score > 0) {
  3274. hint = (score <= this.opt.hints.length && this.opt.hints[score - 1] !== null) ? this.opt.hints[score - 1] : score;
  3275. }
  3276. $this.data('readonly', true).css('cursor', 'default').attr('title', hint);
  3277. this.score.attr('readonly', 'readonly');
  3278. this.stars.attr('title', hint);
  3279. },
  3280. getScore: function() {
  3281. var score = [],
  3282. value;
  3283. $(this).each(function() {
  3284. value = this.score.val();
  3285. score.push(value ? parseFloat(value) : undefined);
  3286. });
  3287. return (score.length > 1) ? score: score[0];
  3288. },
  3289. readOnly: function(isReadOnly) {
  3290. return this.each(function() {
  3291. var $this = $(this);
  3292. if ($this.data('readonly') === isReadOnly) {
  3293. return this;
  3294. }
  3295. if (this.cancel) {
  3296. if (isReadOnly) {
  3297. this.cancel.hide();
  3298. } else {
  3299. this.cancel.show();
  3300. }
  3301. }
  3302. if (isReadOnly) {
  3303. $this.unbind();
  3304. $this.children('img').unbind();
  3305. methods.fixHint.call(this);
  3306. } else {
  3307. methods.bindAction.call(this);
  3308. methods.unfixHint.call(this);
  3309. }
  3310. $this.data('readonly', isReadOnly);
  3311. });
  3312. },
  3313. reload: function() {
  3314. return methods.set.call(this, {});
  3315. },
  3316. roundStar: function(score) {
  3317. var diff = (score - Math.floor(score)).toFixed(2);
  3318. if (diff > this.opt.round.down) {
  3319. var icon = this.opt.starOn; // Full up: [x.76 .. x.99]
  3320. if (diff < this.opt.round.up && this.opt.halfShow) { // Half: [x.26 .. x.75]
  3321. icon = this.opt.starHalf;
  3322. } else if (diff < this.opt.round.full) { // Full down: [x.00 .. x.5]
  3323. icon = this.opt.starOff;
  3324. }
  3325. this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + icon);
  3326. } // Full down: [x.00 .. x.25]
  3327. },
  3328. score: function() {
  3329. return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this);
  3330. },
  3331. set: function(settings) {
  3332. this.each(function() {
  3333. var $this = $(this),
  3334. actual = $this.data('settings'),
  3335. clone = $this.clone().removeAttr('style').insertBefore($this);
  3336. $this.remove();
  3337. clone.raty($.extend(actual, settings));
  3338. });
  3339. return $(this.selector);
  3340. },
  3341. setScore: function(score) {
  3342. return $(this).each(function() {
  3343. if ($(this).data('readonly') === true) {
  3344. return this;
  3345. }
  3346. methods.initialize.call(this, score);
  3347. methods.setTarget.call(this, score, true);
  3348. });
  3349. },
  3350. setTarget: function(value, isKeep) {
  3351. if (this.opt.target) {
  3352. var $target = $(this.opt.target);
  3353. if ($target.length == 0) {
  3354. methods.error.call(this, '目标选择器无效或丢失!');
  3355. }
  3356. var score = value;
  3357. if (!isKeep || score === undefined) {
  3358. score = this.opt.targetText;
  3359. } else {
  3360. if (this.opt.targetType == 'hint') {
  3361. score = (score === null && this.opt.cancel) ? this.opt.cancelHint: this.opt.hints[Math.ceil(score - 1)];
  3362. } else {
  3363. score = this.opt.precision ? parseFloat(score).toFixed(1) : parseInt(score, 10);
  3364. }
  3365. }
  3366. if (this.opt.targetFormat.indexOf('{score}') < 0) {
  3367. methods.error.call(this, '模版 "{score}" 找不到!');
  3368. }
  3369. if (value !== null) {
  3370. score = this.opt.targetFormat.toString().replace('{score}', score);
  3371. }
  3372. if ($target.is(':input')) {
  3373. $target.val(score);
  3374. } else {
  3375. $target.html(score);
  3376. }
  3377. }
  3378. },
  3379. showHalf: function(score) {
  3380. var diff = (score - Math.floor(score)).toFixed(1);
  3381. if (diff > 0 && diff < .6) {
  3382. this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt.starHalf);
  3383. }
  3384. },
  3385. initialize: function(score) {
  3386. score = !score ? 0 : methods.between(score, 0, this.opt.number);
  3387. methods.fill.call(this, score);
  3388. if (score > 0) {
  3389. if (this.opt.halfShow) {
  3390. methods.roundStar.call(this, score);
  3391. }
  3392. this.score.val(score);
  3393. }
  3394. },
  3395. unfixHint: function() {
  3396. for (var i = 0; i < this.opt.number; i++) {
  3397. this.stars.eq(i).attr('title', (i < this.opt.hints.length && this.opt.hints[i] !== null) ? this.opt.hints[i] : i);
  3398. }
  3399. $(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title');
  3400. this.score.attr('readonly', 'readonly');
  3401. }
  3402. };
  3403. $.fn.raty = function(method) {
  3404. if (methods[method]) {
  3405. return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  3406. } else if (typeof method === 'object' || !method) {
  3407. return methods.init.apply(this, arguments);
  3408. } else {
  3409. $.error('方法 ' + method + ' 不存在!');
  3410. }
  3411. };
  3412. $.fn.raty.defaults = {
  3413. cancel: false,
  3414. cancelHint: '取消评级!',
  3415. cancelOff: 'cancel-off.png',
  3416. cancelOn: 'cancel-on.png',
  3417. cancelPlace: 'left',
  3418. click: undefined,
  3419. half: false,
  3420. halfShow: true,
  3421. hints: ['10', '20', '30', '40', '50', '60', '70', '80', '90', '100'],
  3422. iconRange: undefined,
  3423. mouseover: undefined,
  3424. noRatedMsg: '没有额定',
  3425. number: 10,
  3426. path: 'images/',
  3427. precision: false,
  3428. round: {
  3429. down: .25,
  3430. full: .6,
  3431. up: .76
  3432. },
  3433. readOnly: false,
  3434. score: undefined,
  3435. scoreName: 'score',
  3436. single: false,
  3437. size: 16,
  3438. space: true,
  3439. starHalf: 'star-half.png',
  3440. starOff: 'star-off.png',
  3441. starOn: 'star-on.png',
  3442. target: undefined,
  3443. targetFormat: '{score}',
  3444. targetKeep: false,
  3445. targetText: '',
  3446. targetType: 'hint',
  3447. width: undefined
  3448. };
  3449. })(jQuery);
  3450. /* =======================================================================
  3451. * jQuery.onePageNav.js v0.9One Page Nav Plugin
  3452. * http://github.com/davist11/jQuery-One-Page-Nav
  3453. * Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
  3454. * Dual licensed under the MIT and GPL licenses.
  3455. * Uses the same license as jQuery, see:
  3456. * http://jquery.org/license
  3457. * Example usage:
  3458. * $('#nav').onePageNav({
  3459. * currentClass: 'current',
  3460. * changeHash: false,
  3461. * scrollSpeed: 750
  3462. * });
  3463. * ========================================================================*/
  3464. !(function($) {
  3465. $.fn.onePageNav = function(options) {
  3466. var opts = $.extend({},
  3467. $.fn.onePageNav.defaults, options),
  3468. onePageNav = {};
  3469. onePageNav.sections = {};
  3470. onePageNav.bindNav = function($el, $this, o) {
  3471. var $par = $el.parent(),
  3472. newLoc = $el.attr('href'),
  3473. $win = $(window);
  3474. if (!$par.hasClass(o.currentClass)) {
  3475. if (o.begin) {
  3476. o.begin();
  3477. }
  3478. onePageNav.adjustNav($this, $par, o.currentClass);
  3479. $win.unbind('.onePageNav');
  3480. $.scrollTo(newLoc, o.scrollSpeed, {
  3481. easing: o.easing,
  3482. offset: {
  3483. top: -o.scrollOffset
  3484. },
  3485. onAfter: function() {
  3486. if (o.changeHash) {
  3487. window.location.hash = newLoc;
  3488. }
  3489. $win.bind('scroll.onePageNav',
  3490. function() {
  3491. onePageNav.scrollChange($this, o);
  3492. });
  3493. if (o.end) {
  3494. o.end();
  3495. }
  3496. }
  3497. });
  3498. }
  3499. };
  3500. onePageNav.adjustNav = function($this, $el, curClass) {
  3501. $this.find('.' + curClass).removeClass(curClass);
  3502. $el.addClass(curClass);
  3503. };
  3504. onePageNav.getPositions = function($this, o) {
  3505. var $nav = $this.find('a');
  3506. if (o.filter !== '') {
  3507. $nav = $nav.filter(o.filter);
  3508. }
  3509. $nav.each(function() {
  3510. var linkHref = $(this).attr('href'),
  3511. divPos = $(linkHref).offset(),
  3512. topPos = divPos.top;
  3513. onePageNav.sections[linkHref.substr(1)] = Math.round(topPos) - o.scrollOffset;
  3514. });
  3515. };
  3516. onePageNav.getSection = function(windowPos, o) {
  3517. var returnValue = '',
  3518. windowHeight = Math.round($(window).height() * o.scrollThreshold);
  3519. for (var section in onePageNav.sections) {
  3520. if ((onePageNav.sections[section] - windowHeight) < windowPos) {
  3521. returnValue = section;
  3522. }
  3523. }
  3524. return returnValue;
  3525. };
  3526. onePageNav.scrollChange = function($this, o) {
  3527. onePageNav.getPositions($this, o);
  3528. var windowTop = $(window).scrollTop(),
  3529. position = onePageNav.getSection(windowTop, o);
  3530. if (position !== '') {
  3531. onePageNav.adjustNav($this, $this.find('a[href=#' + position + ']').parent(), o.currentClass);
  3532. }
  3533. };
  3534. onePageNav.init = function($this, o) {
  3535. var didScroll = false,
  3536. $nav = $this.find('a');
  3537. if (o.filter !== '') {
  3538. $nav = $nav.filter(o.filter);
  3539. }
  3540. $nav.bind('click',
  3541. function(e) {
  3542. onePageNav.bindNav($(this), $this, o);
  3543. e.preventDefault();
  3544. });
  3545. onePageNav.getPositions($this, o);
  3546. $(window).bind('scroll.onePageNav',
  3547. function() {
  3548. didScroll = true;
  3549. });
  3550. setInterval(function() {
  3551. if (didScroll) {
  3552. didScroll = false;
  3553. onePageNav.scrollChange($this, o);
  3554. }
  3555. },
  3556. 250);
  3557. };
  3558. return this.each(function() {
  3559. var $this = $(this),
  3560. o = $.meta ? $.extend({},
  3561. opts, $this.data()) : opts;
  3562. onePageNav.init($this, o);
  3563. });
  3564. };
  3565. // default options
  3566. $.fn.onePageNav.defaults = {
  3567. currentClass: 'current',
  3568. changeHash: false,
  3569. easing: 'swing',
  3570. filter: '',
  3571. scrollSpeed: 750,
  3572. scrollOffset: 0,
  3573. scrollThreshold: 0.5,
  3574. begin: false,
  3575. end: false
  3576. };
  3577. })(jQuery);
  3578. /* =======================================================================
  3579. * jquery.HuiaddFavorite.js 添加收藏
  3580. * <a title="收藏本站" href="javascript:;" onClick="addFavoritepage('H-ui前端框架','http://www.h-ui.net/');">收藏本站</a>
  3581. * function shoucang(name,site){
  3582. $.addFavorite({
  3583. name:name,
  3584. site:site,
  3585. });
  3586. * ========================================================================*/
  3587. function HuiaddFavorite(obj) {
  3588. obj.site = obj.site || window.location.href;
  3589. obj.name = obj.name || document.title;
  3590. try {
  3591. window.external.addFavorite(obj.site, obj.name);
  3592. } catch(e) {
  3593. try {
  3594. window.sidebar.addPanel(name, site, "");
  3595. } catch(e) {
  3596. $.Huimodalalert("加入收藏失败,请使用Ctrl+D进行添加", 2000);
  3597. }
  3598. }
  3599. }
  3600. /* ========================================================================
  3601. * jQuery.Huisethome.js 设为首页
  3602. * ======================================================================== */
  3603. function Huisethome(obj){
  3604. try{
  3605. obj.style.behavior="url(#default#homepage)";
  3606. obj.setHomePage(webSite);
  3607. }
  3608. catch(e){
  3609. if(window.netscape){
  3610. try {
  3611. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  3612. }
  3613. catch(e){
  3614. $.Huimodalalert("此操作被浏览器拒绝!\n请在浏览器地址栏输入\"about:config\"并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。",2000);
  3615. }
  3616. var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
  3617. prefs.setCharPref('browser.startup.homepage',url);
  3618. }
  3619. }
  3620. }
  3621. /* =======================================================================
  3622. * jQuery.Huisidenav.js 左侧菜单-隐藏显示
  3623. * ======================================================================== */
  3624. function displaynavbar(obj){
  3625. if($(obj).hasClass("open")){
  3626. $(obj).removeClass("open");
  3627. $("body").removeClass("big-page");
  3628. } else {
  3629. $(obj).addClass("open");
  3630. $("body").addClass("big-page");
  3631. }
  3632. }
  3633. /* =======================================================================
  3634. * jQuery.Huihover.js 得到失去焦点
  3635. * ========================================================================*/
  3636. !function($) {
  3637. $.Huihover = function(obj) {
  3638. $(obj).hover(function() {
  3639. $(this).addClass("hover");
  3640. },
  3641. function() {
  3642. $(this).removeClass("hover");
  3643. });
  3644. }
  3645. } (window.jQuery);
  3646. /* =======================================================================
  3647. * jQuery.Huifocusblur.js 得到失去焦点
  3648. * ========================================================================*/
  3649. !function($) {
  3650. $.Huifocusblur = function(obj) {
  3651. $(obj).focus(function() {
  3652. $(this).addClass("focus").removeClass("inputError");
  3653. });
  3654. $(obj).blur(function() {
  3655. $(this).removeClass("focus");
  3656. });
  3657. }
  3658. } (window.jQuery);
  3659. $(function() {
  3660. /*****表单*****/
  3661. $.Huifocusblur(".input-text,.textarea");
  3662. });
  3663. /* =======================================================================
  3664. * jQuery.Huiselect.js 选择
  3665. * ========================================================================*/
  3666. !function($) {
  3667. $.Huiselect = function(divselectid, inputselectid) {
  3668. var inputselect = $(inputselectid);
  3669. $(divselectid + " cite").click(function() {
  3670. var ul = $(divselectid + " ul");
  3671. ul.slideToggle();
  3672. });
  3673. $(divselectid + " ul li a").click(function() {
  3674. var txt = $(this).text();
  3675. $(divselectid + " cite").html(txt);
  3676. var value = $(this).attr("selectid");
  3677. inputselect.val(value);
  3678. $(divselectid + " ul").hide();
  3679. });
  3680. $(document).click(function() {
  3681. $(divselectid + " ul").hide();
  3682. });
  3683. };
  3684. } (window.jQuery);
  3685. /* =======================================================================
  3686. * jQuery.Huitab.js 选项卡
  3687. * ========================================================================*/
  3688. !function($) {
  3689. $.Huitab = function(tabBar, tabCon, class_name, tabEvent, i) {
  3690. var $tab_menu = $(tabBar);
  3691. // 初始化操作
  3692. $tab_menu.removeClass(class_name);
  3693. $(tabBar).eq(i).addClass(class_name);
  3694. $(tabCon).hide();
  3695. $(tabCon).eq(i).show();
  3696. $tab_menu.on(tabEvent,
  3697. function() {
  3698. $tab_menu.removeClass(class_name);
  3699. $(this).addClass(class_name);
  3700. var index = $tab_menu.index(this);
  3701. $(tabCon).hide();
  3702. $(tabCon).eq(index).show();
  3703. });
  3704. }
  3705. } (window.jQuery);
  3706. /* =======================================================================
  3707. * jQuery.Huifold.js 折叠
  3708. * ========================================================================*/
  3709. !function($) {
  3710. $.Huifold = function(obj, obj_c, speed, obj_type, Event) {
  3711. if (obj_type == 2) {
  3712. $(obj + ":first").find("b").html("-");
  3713. $(obj_c + ":first").show();
  3714. }
  3715. $(obj).on(Event,
  3716. function() {
  3717. if ($(this).next().is(":visible")) {
  3718. if (obj_type == 2) {
  3719. return false;
  3720. } else {
  3721. $(this).next().slideUp(speed).end().removeClass("selected");
  3722. if ($(this).find("b")) {
  3723. $(this).find("b").html("+");
  3724. }
  3725. }
  3726. } else {
  3727. if (obj_type == 3) {
  3728. $(this).next().slideDown(speed).end().addClass("selected");
  3729. if ($(this).find("b")) {
  3730. $(this).find("b").html("-");
  3731. }
  3732. } else {
  3733. $(obj_c).slideUp(speed);
  3734. $(obj).removeClass("selected");
  3735. if ($(this).find("b")) {
  3736. $(obj).find("b").html("+");
  3737. }
  3738. $(this).next().slideDown(speed).end().addClass("selected");
  3739. if ($(this).find("b")) {
  3740. $(this).find("b").html("-");
  3741. }
  3742. }
  3743. }
  3744. });
  3745. }
  3746. } (window.jQuery);
  3747. /* =======================================================================
  3748. * jQuery.Huitags.js 标签
  3749. * ========================================================================*/
  3750. !function($) {
  3751. /*tag标签*/
  3752. var time1;
  3753. $(".Hui-tags-lable").show();
  3754. $(".Hui-tags-input").val("");
  3755. $(document).on("blur", ".Hui-tags-input",
  3756. function() {
  3757. time1 = setTimeout(function() {
  3758. $(this).parents(".Hui-tags").find(".Hui-tags-list").slideUp();
  3759. },
  3760. 400);
  3761. });
  3762. $(document).on("focus", ".Hui-tags-input",
  3763. function() {
  3764. clearTimeout(time1);
  3765. });
  3766. $(document).on("click", ".Hui-tags-input",
  3767. function() {
  3768. $(this).find(".Hui-tags-input").focus();
  3769. $(this).find(".Hui-tags-list").slideDown();
  3770. });
  3771. function gettagval(obj) {
  3772. var str = "";
  3773. var token = $(obj).parents(".Hui-tags").find(".Hui-tags-token");
  3774. if (token.length < 1) {
  3775. $(obj).parents(".Hui-tags").find(".Hui-tags-val").val("");
  3776. return false;
  3777. }
  3778. for (var i = 0; i < token.length; i++) {
  3779. str += token.eq(i).text() + ",";
  3780. $(obj).parents(".Hui-tags").find(".Hui-tags-val").val(str);
  3781. }
  3782. }
  3783. $(document).on("keydown", ".Hui-tags-input",
  3784. function(event) {
  3785. $(this).next().hide();
  3786. var v = $(this).val().replace(/\s+/g, "");
  3787. var reg = /^,|,$/gi;
  3788. v = v.replace(reg, "");
  3789. v = $.trim(v);
  3790. var token = $(this).parents(".Hui-tags").find(".Hui-tags-token");
  3791. if (v != '') {
  3792. if (event.keyCode == 13 || event.keyCode == 108 || event.keyCode == 32) {
  3793. $('<span class="Hui-tags-token">' + v + '</span>').insertBefore($(this).parents(".Hui-tags").find(".Hui-tags-iptwrap"));
  3794. $(this).val("");
  3795. gettagval(this);
  3796. }
  3797. } else {
  3798. if (event.keyCode == 8) {
  3799. if (token.length >= 1) {
  3800. $(this).parents(".Hui-tags").find(".Hui-tags-token:last").remove();
  3801. gettagval(this);
  3802. } else {
  3803. $(this).parents(".Hui-tags").find(".Hui-tags-lable").show();
  3804. return false;
  3805. }
  3806. }
  3807. }
  3808. });
  3809. $(document).on("click", ".Hui-tags-has span",
  3810. function() {
  3811. var taghasV = $(this).text();
  3812. taghasV = taghasV.replace(/(^\s*)|(\s*$)/g, "");
  3813. $('<span class="Hui-tags-token">' + taghasV + '</span>').insertBefore($(this).parents(".Hui-tags").find(".Hui-tags-iptwrap"));
  3814. gettagval(this);
  3815. $(this).parents(".Hui-tags").find(".Hui-tags-input").focus();
  3816. });
  3817. $(document).on("click", ".Hui-tags-token",
  3818. function() {
  3819. var token = $(this).parents(".Hui-tags").find(".Hui-tags-token");
  3820. var it = $(this).parents(".Hui-tags");
  3821. $(this).remove();
  3822. switch (token.length) {
  3823. case 1:
  3824. it.find(".Hui-tags-lable").show();
  3825. break;
  3826. }
  3827. var str = "";
  3828. var token = it.find(".Hui-tags-token");
  3829. if (token.length < 1) {
  3830. it.find(".Hui-tags-val").val("");
  3831. return false;
  3832. }
  3833. for (var i = 0; i < token.length; i++) {
  3834. str += token.eq(i).text() + ",";
  3835. it.find(".Hui-tags-val").val(str);
  3836. }
  3837. });
  3838. } (window.jQuery);
  3839. /* =======================================================================
  3840. * jQuery.Huitagsmixed.js 标签混排效果
  3841. * ========================================================================*/
  3842. !function($) {
  3843. $.Huitagsmixed = function(obj) {
  3844. $(obj).each(function() {
  3845. var x = 9;
  3846. var y = 0;
  3847. var rand = parseInt(Math.random() * (x - y + 1) + y);
  3848. $(this).addClass("tags" + rand);
  3849. });
  3850. }
  3851. } (window.jQuery);
  3852. /* =======================================================================
  3853. * jQuery.Huitextarealength.js 字数限制
  3854. * ========================================================================*/
  3855. !function($) {
  3856. $.Huitextarealength = function(obj, maxlength) {
  3857. var v = $(obj).val();
  3858. var l = v.length;
  3859. if (l > maxlength) {
  3860. v = v.substring(0, maxlength);
  3861. $(obj).val(v);
  3862. }
  3863. $(obj).parent().find(".textarea-length").text(v.length);
  3864. }
  3865. } (window.jQuery);
  3866. /* =======================================================================
  3867. * jQuery.Huipreview.js 图片预览
  3868. * ========================================================================*/
  3869. !function($) {
  3870. $.Huipreview = function(obj) {
  3871. /*图片预览*/
  3872. $(obj).hover(function() {
  3873. $(this).addClass("active");
  3874. $("#tooltip-preview").remove();
  3875. var winW = $(window).width();
  3876. var winW5 = winW / 2;
  3877. this.myTitle = this.title;
  3878. this.title = "";
  3879. var midimg = $(this).attr('data-preview');
  3880. if (midimg == '') {
  3881. return false;
  3882. } else {
  3883. var imgT = $(this).parents(".imgItem").offset().top;
  3884. var imgL = $(this).parents(".imgItem").offset().left;
  3885. var imgW = $(this).parents(".imgItem").width();
  3886. var imgH = $(this).parents(".imgItem").height();
  3887. var ww = (imgL + imgW / 2);
  3888. if (ww < winW5) {
  3889. var tooltipLeft = (imgW + imgL) + "px";
  3890. } else {
  3891. var tooltipRight = (winW - imgL) + "px";
  3892. }
  3893. var tooltip_keleyi_com = "<div id='tooltip-preview' style='top:" + imgT + "px;right:" + tooltipRight + ";left:" + tooltipLeft + "'><span id='tooltip-keleyi-div' class='loading' style='width:50px; height:50px'></span></div>";
  3894. $("body").append(tooltip_keleyi_com);
  3895. var midimgW = $(this).attr('data-width');
  3896. var midimgH = $(this).attr('data-height');
  3897. var imgTitle = this.myTitle ? "<br />" + this.myTitle + " 产品预览图": "";
  3898. /*图片预加载*/
  3899. var image = new Image();
  3900. /*创建一个Image对象*/
  3901. image.onload = function() {
  3902. if ($('a.preview.active').attr('data-preview') == midimg) {
  3903. var midingW2 = this.width;
  3904. var midingH2 = this.height;
  3905. $("#tooltip-keleyi-div").css({
  3906. "width": midingW2 + "px",
  3907. "height": midingH2 + "px"
  3908. });
  3909. $('#tooltip-keleyi-div').append(this);
  3910. }
  3911. };
  3912. image.src = midimg;
  3913. }
  3914. },
  3915. function() {
  3916. $(this).removeClass("active");
  3917. this.title = this.myTitle;
  3918. $("#tooltip-preview").remove();
  3919. });
  3920. }
  3921. } (window.jQuery);
  3922. /* =======================================================================
  3923. * jQuery.Huimodalalert.js alert
  3924. * ========================================================================*/
  3925. !function($) {
  3926. $.Huimodalalert = function(info, speed) {
  3927. if ($(".modal-alert").length > 0) {
  3928. $(".modal-alert").remove();
  3929. }
  3930. if (speed == 0 || typeof(speed) == "undefined") {
  3931. $(document.body).append('<div id="modal-alert" class="modal modal-alert radius">' + '<div class="modal-alert-info">' + info + '</div>' + '<div class="modal-footer"> <button class="btn btn-primary radius" onClick="$.Huimodal_alert.hide()">确定</button></div>' + '</div>');
  3932. $("#modal-alert").fadeIn();
  3933. } else {
  3934. $(document.body).append('<div id="modal-alert" class="modal modal-alert radius">' + '<div class="modal-alert-info">' + info + '</div>' + '</div>');
  3935. $("#modal-alert").fadeIn();
  3936. setTimeout($.Huimodalalert.hide, speed);
  3937. }
  3938. }
  3939. $.Huimodalalert.hide = function() {
  3940. $("#modal-alert").fadeOut("normal",
  3941. function() {
  3942. $("#modal-alert").remove();
  3943. });
  3944. }
  3945. } (window.jQuery);
  3946. /* =======================================================================
  3947. * jQuery.Huialert.js alert
  3948. * ========================================================================*/
  3949. !function($) {
  3950. $.Huialert = function() {
  3951. $.Huihover('.Huialert i');
  3952. $(".Huialert i").on("click",
  3953. function() {
  3954. var Huialert = $(this).parents(".Huialert");
  3955. Huialert.fadeOut("normal",
  3956. function() {
  3957. Huialert.remove();
  3958. });
  3959. });
  3960. }
  3961. $.Huialert();
  3962. } (window.jQuery);
  3963. /* =======================================================================
  3964. * jQuery.Huitotop.js 返回顶部
  3965. * ========================================================================*/
  3966. var $backToTopEle = $('<a href="javascript:void(0)" class="tools-right toTop Hui-iconfont" title="返回顶部" alt="返回顶部" style="display:none">&#xe684;</a>').appendTo($("body")).click(function() {
  3967. $("html, body").animate({
  3968. scrollTop: 0
  3969. },
  3970. 120);
  3971. });
  3972. var backToTopFun = function() {
  3973. var st = $(document).scrollTop(),
  3974. winh = $(window).height(); (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
  3975. /*IE6下的定位*/
  3976. if (!window.XMLHttpRequest) {
  3977. $backToTopEle.css("top", st + winh - 166);
  3978. }
  3979. };
  3980. /* =======================================================================
  3981. * jQuery.Huimarquee.js 滚动
  3982. * ========================================================================*/
  3983. !function($) {
  3984. $.Huimarquee = function(height, speed, delay) {
  3985. var scrollT;
  3986. var pause = false;
  3987. var ScrollBox = document.getElementById("marquee");
  3988. if (document.getElementById("holder").offsetHeight <= height) return;
  3989. var _tmp = ScrollBox.innerHTML.replace('holder', 'holder2');
  3990. ScrollBox.innerHTML += _tmp;
  3991. ScrollBox.onmouseover = function() {
  3992. pause = true;
  3993. }
  3994. ScrollBox.onmouseout = function() {
  3995. pause = false;
  3996. }
  3997. ScrollBox.scrollTop = 0;
  3998. var start = function() {
  3999. scrollT = setInterval(scrolling, speed);
  4000. if (!pause) ScrollBox.scrollTop += 2;
  4001. }
  4002. var scrolling = function() {
  4003. if (ScrollBox.scrollTop % height != 0) {
  4004. ScrollBox.scrollTop += 2;
  4005. if (ScrollBox.scrollTop >= ScrollBox.scrollHeight / 2) ScrollBox.scrollTop = 0;
  4006. } else {
  4007. clearInterval(scrollT);
  4008. setTimeout(start, delay);
  4009. }
  4010. }
  4011. setTimeout(start, delay);
  4012. }
  4013. } (window.jQuery);
  4014. $(function() {
  4015. /*全选*/
  4016. $("table thead th input:checkbox").on("click",function() {
  4017. $(this).closest("table").find("tr > td:first-child input:checkbox").prop("checked", $("table thead th input:checkbox").prop("checked"));
  4018. });
  4019. /*上传*/
  4020. $(document).on("change", ".input-file",function() {
  4021. var uploadVal = $(this).val();
  4022. $(this).parent().find(".upload-url").val(uploadVal).focus().blur();
  4023. });
  4024. });
  4025. /* ========================================================================
  4026. * Bootstrap.button.js v3.3.0
  4027. * http://getbootstrap.com/javascript/#buttons
  4028. * ========================================================================
  4029. * Copyright 2011-2014 Twitter, Inc.
  4030. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4031. * ======================================================================== */
  4032. !function($) {
  4033. 'use strict';
  4034. // BUTTON PUBLIC CLASS DEFINITION
  4035. // ==============================
  4036. var Button = function(element, options) {
  4037. this.$element = $(element);
  4038. this.options = $.extend({},Button.DEFAULTS, options);
  4039. this.isLoading = false;
  4040. }
  4041. Button.VERSION = '3.3.0'
  4042. Button.DEFAULTS = {
  4043. loadingText: 'loading...'
  4044. }
  4045. Button.prototype.setState = function(state) {
  4046. var d = 'disabled'
  4047. var $el = this.$element
  4048. var val = $el.is('input') ? 'val': 'html'
  4049. var data = $el.data();
  4050. state = state + 'Text';
  4051. if (data.resetText == null) $el.data('resetText', $el[val]());
  4052. // push to event loop to allow forms to submit
  4053. setTimeout($.proxy(function() {
  4054. $el[val](data[state] == null ? this.options[state] : data[state]);
  4055. if (state == 'loadingText') {
  4056. this.isLoading = true;
  4057. $el.addClass(d).attr(d, d);
  4058. } else if (this.isLoading) {
  4059. this.isLoading = false;
  4060. $el.removeClass(d).removeAttr(d);
  4061. }
  4062. },
  4063. this), 0)
  4064. }
  4065. Button.prototype.toggle = function() {
  4066. var changed = true;
  4067. var $parent = this.$element.closest('[data-toggle="buttons"]');
  4068. if ($parent.length) {
  4069. var $input = this.$element.find('input');
  4070. if ($input.prop('type') == 'radio') {
  4071. if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
  4072. else $parent.find('.active').removeClass('active')
  4073. }
  4074. if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
  4075. } else {
  4076. this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
  4077. }
  4078. if (changed) this.$element.toggleClass('active')
  4079. }
  4080. // BUTTON PLUGIN DEFINITION
  4081. // ========================
  4082. function Plugin(option) {
  4083. return this.each(function() {
  4084. var $this = $(this);
  4085. var data = $this.data('bs.button');
  4086. var options = typeof option == 'object' && option;
  4087. if (!data) $this.data('bs.button', (data = new Button(this, options)))
  4088. if (option == 'toggle') data.toggle()
  4089. else if (option) data.setState(option)
  4090. })
  4091. }
  4092. var old = $.fn.button;
  4093. $.fn.button = Plugin;
  4094. $.fn.button.Constructor = Button;
  4095. // BUTTON NO CONFLICT
  4096. // ==================
  4097. $.fn.button.noConflict = function() {
  4098. $.fn.button = old;
  4099. return this;
  4100. }
  4101. // BUTTON DATA-API
  4102. // ===============
  4103. $(document).on('click.bs.button.data-api', '[data-toggle^="button"]',
  4104. function(e) {
  4105. var $btn = $(e.target);
  4106. if (!$btn.hasClass('btn'));
  4107. $btn = $btn.closest('.btn');
  4108. Plugin.call($btn, 'toggle');
  4109. e.preventDefault();
  4110. }).on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]',
  4111. function(e) {
  4112. $(e.target).closest('.btn').toggleClass('focus', e.type == 'focus');
  4113. })
  4114. } (jQuery);
  4115. /* =======================================================================
  4116. * jQuery.stickUp.js v0.5.7 BETA by:LiranCohen
  4117. * https://github.com/LiranCohen/stickUp
  4118. * ======================================================================== */
  4119. jQuery(function($) {
  4120. $(document).ready(function(){
  4121. var contentButton = [];
  4122. var contentTop = [];
  4123. var content = [];
  4124. var lastScrollTop = 0;
  4125. var scrollDir = '';
  4126. var itemClass = '';
  4127. var itemHover = '';
  4128. var menuSize = null;
  4129. var stickyHeight = 0;
  4130. var stickyMarginB = 0;
  4131. var currentMarginT = 0;
  4132. var topMargin = 0;
  4133. var vartop = 0;
  4134. $(window).scroll(function(event){
  4135. var st = $(this).scrollTop();
  4136. if (st > lastScrollTop){
  4137. scrollDir = 'down';
  4138. } else {
  4139. scrollDir = 'up';
  4140. }
  4141. lastScrollTop = st;
  4142. });
  4143. $.fn.stickUp = function( options ) {
  4144. // adding a class to users div
  4145. $(this).addClass('stuckMenu');
  4146. //getting options
  4147. var objn = 0;
  4148. if(options != null) {
  4149. for(var o in options.parts) {
  4150. if (options.parts.hasOwnProperty(o)){
  4151. content[objn] = options.parts[objn];
  4152. objn++;
  4153. }
  4154. }
  4155. if(objn == 0) {
  4156. console.log('error:needs arguments');
  4157. }
  4158. itemClass = options.itemClass;
  4159. itemHover = options.itemHover;
  4160. if(options.topMargin != null) {
  4161. if(options.topMargin == 'auto') {
  4162. topMargin = parseInt($('.stuckMenu').css('margin-top'));
  4163. } else {
  4164. if(isNaN(options.topMargin) && options.topMargin.search("px") > 0){
  4165. topMargin = parseInt(options.topMargin.replace("px",""));
  4166. } else if(!isNaN(parseInt(options.topMargin))) {
  4167. topMargin = parseInt(options.topMargin);
  4168. } else {
  4169. console.log("incorrect argument, ignored.");
  4170. topMargin = 0;
  4171. }
  4172. }
  4173. } else {
  4174. topMargin = 0;
  4175. }
  4176. menuSize = $('.'+itemClass).size();
  4177. }
  4178. stickyHeight = parseInt($(this).height());
  4179. stickyMarginB = parseInt($(this).css('margin-bottom'));
  4180. currentMarginT = parseInt($(this).next().closest('div').css('margin-top'));
  4181. vartop = parseInt($(this).offset().top);
  4182. //$(this).find('*').removeClass(itemHover);
  4183. }
  4184. $(document).on('scroll', function() {
  4185. varscroll = parseInt($(document).scrollTop());
  4186. if(menuSize != null){
  4187. for(var i=0;i < menuSize;i++)
  4188. {
  4189. contentTop[i] = $('#'+content[i]+'').offset().top;
  4190. function bottomView(i) {
  4191. contentView = $('#'+content[i]+'').height()*.4;
  4192. testView = contentTop[i] - contentView;
  4193. //console.log(varscroll);
  4194. if(varscroll > testView){
  4195. $('.'+itemClass).removeClass(itemHover);
  4196. $('.'+itemClass+':eq('+i+')').addClass(itemHover);
  4197. } else if(varscroll < 50){
  4198. $('.'+itemClass).removeClass(itemHover);
  4199. $('.'+itemClass+':eq(0)').addClass(itemHover);
  4200. }
  4201. }
  4202. if(scrollDir == 'down' && varscroll > contentTop[i]-50 && varscroll < contentTop[i]+50) {
  4203. $('.'+itemClass).removeClass(itemHover);
  4204. $('.'+itemClass+':eq('+i+')').addClass(itemHover);
  4205. }
  4206. if(scrollDir == 'up') {
  4207. bottomView(i);
  4208. }
  4209. }
  4210. }
  4211. if(vartop < varscroll + topMargin){
  4212. $('.stuckMenu').addClass('isStuck');
  4213. $('.stuckMenu').next().closest('div').css({
  4214. 'margin-top': stickyHeight + stickyMarginB + currentMarginT + 'px'
  4215. }, 10);
  4216. $('.stuckMenu').css("position","fixed");
  4217. $('.isStuck').css({
  4218. top: '0px'
  4219. }, 10, function(){
  4220. });
  4221. };
  4222. if(varscroll + topMargin < vartop){
  4223. $('.stuckMenu').removeClass('isStuck');
  4224. $('.stuckMenu').next().closest('div').css({
  4225. 'margin-top': currentMarginT + 'px'
  4226. }, 10);
  4227. $('.stuckMenu').css("position","relative");
  4228. };
  4229. });
  4230. });
  4231. });
  4232. /* =======================================================================
  4233. * Bootstrap.modal.js v3.3.0
  4234. * http://getbootstrap.com/javascript/#modals
  4235. * ========================================================================
  4236. * Copyright 2011-2014 Twitter, Inc.
  4237. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4238. * ======================================================================== */
  4239. !function($) {
  4240. 'use strict';
  4241. // MODAL CLASS DEFINITION
  4242. // ======================
  4243. var Modal = function(element, options) {
  4244. this.options = options;
  4245. this.$body = $(document.body);
  4246. this.$element = $(element);
  4247. this.$backdrop =
  4248. this.isShown = null;
  4249. this.scrollbarWidth = 0;
  4250. if (this.options.remote) {
  4251. this.$element.find('.modal-content').load(this.options.remote, $.proxy(function() {
  4252. this.$element.trigger('loaded.bs.modal');
  4253. },
  4254. this))
  4255. }
  4256. }
  4257. Modal.VERSION = '3.3.0';
  4258. Modal.TRANSITION_DURATION = 300;
  4259. Modal.BACKDROP_TRANSITION_DURATION = 150;
  4260. Modal.DEFAULTS = {
  4261. backdrop: true,
  4262. keyboard: true,
  4263. show: true,
  4264. }
  4265. Modal.prototype.toggle = function(_relatedTarget) {
  4266. return this.isShown ? this.hide() : this.show(_relatedTarget)
  4267. }
  4268. Modal.prototype.show = function(_relatedTarget) {
  4269. var that = this;
  4270. var e = $.Event('show.bs.modal', {
  4271. relatedTarget: _relatedTarget
  4272. });
  4273. this.$element.trigger(e);
  4274. if (this.isShown || e.isDefaultPrevented()) return;
  4275. this.isShown = true;
  4276. this.checkScrollbar();
  4277. this.$body.addClass('modal-open');
  4278. this.setScrollbar();
  4279. this.escape();
  4280. this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this));
  4281. this.backdrop(function() {
  4282. var transition = $.support.transition && that.$element.hasClass('fade');
  4283. if (!that.$element.parent().length) {
  4284. that.$element.appendTo(that.$body); // don't move modals dom position
  4285. }
  4286. that.$element.show().scrollTop(0);
  4287. if (transition) {
  4288. that.$element[0].offsetWidth; // force reflow
  4289. }
  4290. that.$element.addClass('in').attr('aria-hidden', false);
  4291. that.enforceFocus();
  4292. var e = $.Event('shown.bs.modal', {
  4293. relatedTarget: _relatedTarget
  4294. })
  4295. transition ? that.$element.find('.modal-dialog') // wait for modal to slide in
  4296. .one('bsTransitionEnd',
  4297. function() {
  4298. that.$element.trigger('focus').trigger(e)
  4299. }).emulateTransitionEnd(Modal.TRANSITION_DURATION) : that.$element.trigger('focus').trigger(e)
  4300. })
  4301. }
  4302. Modal.prototype.hide = function(e) {
  4303. if (e) e.preventDefault();
  4304. e = $.Event('hide.bs.modal');
  4305. this.$element.trigger(e);
  4306. if (!this.isShown || e.isDefaultPrevented()) return;
  4307. this.isShown = false;
  4308. this.escape();
  4309. $(document).off('focusin.bs.modal');
  4310. this.$element.removeClass('in').attr('aria-hidden', true).off('click.dismiss.bs.modal');
  4311. $.support.transition && this.$element.hasClass('fade') ? this.$element.one('bsTransitionEnd', $.proxy(this.hideModal, this)).emulateTransitionEnd(Modal.TRANSITION_DURATION) : this.hideModal()
  4312. }
  4313. Modal.prototype.enforceFocus = function() {
  4314. $(document).off('focusin.bs.modal') // guard against infinite focus loop
  4315. .on('focusin.bs.modal', $.proxy(function(e) {
  4316. if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
  4317. this.$element.trigger('focus')
  4318. }
  4319. },
  4320. this))
  4321. }
  4322. Modal.prototype.escape = function() {
  4323. if (this.isShown && this.options.keyboard) {
  4324. this.$element.on('keydown.dismiss.bs.modal', $.proxy(function(e) {
  4325. e.which == 27 && this.hide()
  4326. },
  4327. this))
  4328. } else if (!this.isShown) {
  4329. this.$element.off('keydown.dismiss.bs.modal')
  4330. }
  4331. }
  4332. Modal.prototype.hideModal = function() {
  4333. var that = this;
  4334. this.$element.hide();
  4335. this.backdrop(function() {
  4336. that.$body.removeClass('modal-open');
  4337. that.resetScrollbar();
  4338. that.$element.trigger('hidden.bs.modal');
  4339. })
  4340. }
  4341. Modal.prototype.removeBackdrop = function() {
  4342. this.$backdrop && this.$backdrop.remove();
  4343. this.$backdrop = null;
  4344. }
  4345. Modal.prototype.backdrop = function(callback) {
  4346. var that = this
  4347. var animate = this.$element.hasClass('fade') ? 'fade': ''
  4348. if (this.isShown && this.options.backdrop) {
  4349. var doAnimate = $.support.transition && animate
  4350. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />').prependTo(this.$element).on('click.dismiss.bs.modal', $.proxy(function(e) {
  4351. if (e.target !== e.currentTarget) return this.options.backdrop == 'static' ? this.$element[0].focus.call(this.$element[0]) : this.hide.call(this)
  4352. },
  4353. this))
  4354. if (doAnimate) this.$backdrop[0].offsetWidth; // force reflow
  4355. this.$backdrop.addClass('in');
  4356. if (!callback) return;
  4357. doAnimate ? this.$backdrop.one('bsTransitionEnd', callback).emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : callback();
  4358. } else if (!this.isShown && this.$backdrop) {
  4359. this.$backdrop.removeClass('in');
  4360. var callbackRemove = function() {
  4361. that.removeBackdrop();
  4362. callback && callback();
  4363. }
  4364. $.support.transition && this.$element.hasClass('fade') ? this.$backdrop.one('bsTransitionEnd', callbackRemove).emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : callbackRemove()
  4365. } else if (callback) {
  4366. callback();
  4367. }
  4368. }
  4369. Modal.prototype.checkScrollbar = function() {
  4370. this.scrollbarWidth = this.measureScrollbar();
  4371. }
  4372. Modal.prototype.setScrollbar = function() {
  4373. var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10);
  4374. if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth);
  4375. }
  4376. Modal.prototype.resetScrollbar = function() {
  4377. this.$body.css('padding-right', '')
  4378. }
  4379. Modal.prototype.measureScrollbar = function() { // thx walsh
  4380. if (document.body.clientWidth >= window.innerWidth) return 0
  4381. var scrollDiv = document.createElement('div');
  4382. scrollDiv.className = 'modal-scrollbar-measure';
  4383. this.$body.append(scrollDiv);
  4384. var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
  4385. this.$body[0].removeChild(scrollDiv);
  4386. return scrollbarWidth;
  4387. }
  4388. // MODAL PLUGIN DEFINITION
  4389. // =======================
  4390. function Plugin(option, _relatedTarget) {
  4391. return this.each(function() {
  4392. var $this = $(this);
  4393. var data = $this.data('bs.modal');
  4394. var options = $.extend({},Modal.DEFAULTS, $this.data(), typeof option == 'object' && option);
  4395. if (!data) $this.data('bs.modal', (data = new Modal(this, options)));
  4396. if (typeof option == 'string') data[option](_relatedTarget);
  4397. else if (options.show) data.show(_relatedTarget);
  4398. })
  4399. }
  4400. var old = $.fn.modal;
  4401. $.fn.modal = Plugin;
  4402. $.fn.modal.Constructor = Modal;
  4403. // MODAL NO CONFLICT
  4404. // =================
  4405. $.fn.modal.noConflict = function() {
  4406. $.fn.modal = old;
  4407. return this;
  4408. }
  4409. // MODAL DATA-API
  4410. // ==============
  4411. $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]',
  4412. function(e) {
  4413. var $this = $(this);
  4414. var href = $this.attr('href');
  4415. var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))); // strip for ie7
  4416. var option = $target.data('bs.modal') ? 'toggle': $.extend({remote: !/#/.test(href) && href},$target.data(), $this.data());
  4417. if ($this.is('a')) e.preventDefault();
  4418. $target.one('show.bs.modal',function(showEvent) {
  4419. if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
  4420. $target.one('hidden.bs.modal',function() {
  4421. $this.is(':visible') && $this.trigger('focus');
  4422. });
  4423. });
  4424. Plugin.call($target, option, this);
  4425. });
  4426. } (window.jQuery);
  4427. /* =======================================================================
  4428. * Bootstrap.dropdown.js v3.3.0
  4429. * http://getbootstrap.com/javascript/#dropdowns
  4430. * ========================================================================
  4431. * Copyright 2011-2014 Twitter, Inc.
  4432. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4433. * ======================================================================== */
  4434. !function($) {
  4435. 'use strict';
  4436. var backdrop = '.dropdown-backdrop';
  4437. var toggle = '[data-toggle="dropdown"]';
  4438. var Dropdown = function(element) {
  4439. $(element).on('click.bs.dropdown', this.toggle)
  4440. }
  4441. Dropdown.VERSION = '3.3.5';
  4442. function getParent($this) {
  4443. var selector = $this.attr('data-target');
  4444. if (!selector) {
  4445. selector = $this.attr('href');
  4446. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
  4447. }
  4448. var $parent = selector && $(selector);
  4449. return $parent && $parent.length ? $parent: $this.parent();
  4450. }
  4451. function clearMenus(e) {
  4452. if (e && e.which === 3) return $(backdrop).remove();
  4453. $(toggle).each(function() {
  4454. var $this = $(this);
  4455. var $parent = getParent($this);
  4456. var relatedTarget = {
  4457. relatedTarget: this
  4458. }
  4459. if (!$parent.hasClass('open')) return;
  4460. if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget));
  4461. if (e.isDefaultPrevented()) return;
  4462. $this.attr('aria-expanded', 'false');
  4463. $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget);
  4464. });
  4465. }
  4466. Dropdown.prototype.toggle = function(e) {
  4467. var $this = $(this);
  4468. if ($this.is('.disabled, :disabled')) return;
  4469. var $parent = getParent($this);
  4470. var isActive = $parent.hasClass('open');
  4471. clearMenus();
  4472. if (!isActive) {
  4473. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  4474. // if mobile we use a backdrop because click events don't delegate
  4475. $(document.createElement('div')).addClass('dropdown-backdrop').insertAfter($(this)).on('click', clearMenus);
  4476. }
  4477. var relatedTarget = {
  4478. relatedTarget: this
  4479. }
  4480. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget));
  4481. if (e.isDefaultPrevented()) return $this.trigger('focus').attr('aria-expanded', 'true');
  4482. $parent.toggleClass('open').trigger('shown.bs.dropdown', relatedTarget);
  4483. }
  4484. return false;
  4485. }
  4486. Dropdown.prototype.keydown = function(e) {
  4487. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return;
  4488. var $this = $(this);
  4489. e.preventDefault();
  4490. e.stopPropagation();
  4491. if ($this.is('.disabled, :disabled')) return;
  4492. var $parent = getParent($this);
  4493. var isActive = $parent.hasClass('open');
  4494. if (!isActive && e.which != 27 || isActive && e.which == 27) {
  4495. if (e.which == 27)
  4496. $parent.find(toggle).trigger('focus');
  4497. return;
  4498. $this.trigger('click');
  4499. }
  4500. var desc = ' li:not(.disabled):visible a';
  4501. var $items = $parent.find('.dropdown-menu' + desc);
  4502. if (!$items.length) return;
  4503. var index = $items.index(e.target);
  4504. if (e.which == 38 && index > 0) index-- // up
  4505. if (e.which == 40 && index < $items.length - 1) index++; // down
  4506. if (!~index) index = 0;
  4507. $items.eq(index).trigger('focus');
  4508. }
  4509. function Plugin(option) {
  4510. return this.each(function() {
  4511. var $this = $(this);
  4512. var data = $this.data('bs.dropdown');
  4513. if (!data) {
  4514. $this.data('bs.dropdown', (data = new Dropdown(this)));
  4515. }
  4516. if (typeof option == 'string') {
  4517. data[option].call($this);
  4518. }
  4519. });
  4520. }
  4521. var old = $.fn.dropdown;
  4522. $.fn.dropdown = Plugin;
  4523. $.fn.dropdown.Constructor = Dropdown;
  4524. $.fn.dropdown.noConflict = function() {
  4525. $.fn.dropdown = old;
  4526. return this;
  4527. }
  4528. $(document).on('click.bs.dropdown.data-api', clearMenus).on('click.bs.dropdown.data-api', '.dropdown form',
  4529. function(e) {
  4530. e.stopPropagation()
  4531. }).on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle).on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown).on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown);
  4532. } (window.jQuery);
  4533. $(function() {
  4534. /*下拉菜单*/
  4535. $(document).on("mouseenter", ".dropDown",
  4536. function() {
  4537. $(this).addClass("hover");
  4538. });
  4539. $(document).on("mouseleave", ".dropDown",
  4540. function() {
  4541. $(this).removeClass("hover");
  4542. });
  4543. $(document).on("mouseenter", ".dropDown_hover",
  4544. function() {
  4545. $(this).addClass("open");
  4546. });
  4547. $(document).on("mouseleave", ".dropDown_hover",
  4548. function() {
  4549. $(this).removeClass("open");
  4550. });
  4551. $(document).on("click", ".dropDown-menu li a",
  4552. function() {
  4553. $(".dropDown").removeClass('open');
  4554. });
  4555. $(document).on("mouseenter", ".menu > li",
  4556. function() {
  4557. $(this).addClass("open");
  4558. });
  4559. $(document).on("mouseleave", ".menu > li",
  4560. function() {
  4561. $(this).removeClass("open");
  4562. });
  4563. });
  4564. /* =======================================================================
  4565. * Bootstrap.transition.js v3.3.0
  4566. * http://getbootstrap.com/javascript/#transitions
  4567. * ========================================================================
  4568. * Copyright 2011-2014 Twitter, Inc.
  4569. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4570. * ======================================================================== */
  4571. !function ($) {
  4572. 'use strict';
  4573. function transitionEnd() {
  4574. var el = document.createElement('bootstrap');
  4575. var transEndEventNames = {
  4576. WebkitTransition : 'webkitTransitionEnd',
  4577. MozTransition : 'transitionend',
  4578. OTransition : 'oTransitionEnd otransitionend',
  4579. transition : 'transitionend'
  4580. }
  4581. for (var name in transEndEventNames) {
  4582. if (el.style[name] !== undefined) {
  4583. return { end: transEndEventNames[name] }
  4584. }
  4585. }
  4586. return false // explicit for ie8 ( ._.)
  4587. }
  4588. // http://blog.alexmaccaw.com/css-transitions
  4589. $.fn.emulateTransitionEnd = function (duration) {
  4590. var called = false;
  4591. var $el = this;
  4592. $(this).one('bsTransitionEnd', function () { called = true })
  4593. var callback = function () {
  4594. if (!called) $($el).trigger($.support.transition.end)
  4595. }
  4596. setTimeout(callback, duration);
  4597. return this;
  4598. }
  4599. $(function () {
  4600. $.support.transition = transitionEnd();
  4601. if (!$.support.transition) return;
  4602. $.event.special.bsTransitionEnd = {
  4603. bindType: $.support.transition.end,
  4604. delegateType: $.support.transition.end,
  4605. handle: function (e) {
  4606. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments);
  4607. }
  4608. }
  4609. })
  4610. }(window.jQuery);
  4611. /* =======================================================================
  4612. * Bootstrap.tooltip.js v3.3.0
  4613. * http://getbootstrap.com/javascript/#tooltip
  4614. * Inspired by the original jQuery.tipsy by Jason Frame
  4615. * ========================================================================
  4616. * Copyright 2011-2014 Twitter, Inc.
  4617. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4618. * ======================================================================== */
  4619. !function($) {
  4620. 'use strict';
  4621. // TOOLTIP PUBLIC CLASS DEFINITION
  4622. // ===============================
  4623. var Tooltip = function(element, options) {
  4624. this.type = this.options = this.enabled = this.timeout = this.hoverState = this.$element = null;
  4625. this.init('tooltip', element, options);
  4626. }
  4627. Tooltip.VERSION = '3.3.0';
  4628. Tooltip.TRANSITION_DURATION = 150;
  4629. Tooltip.DEFAULTS = {
  4630. animation: true,
  4631. placement: 'top',
  4632. selector: false,
  4633. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  4634. trigger: 'hover focus',
  4635. title: '',
  4636. delay: 0,
  4637. html: false,
  4638. container: false,
  4639. viewport: {
  4640. selector: 'body',
  4641. padding: 0
  4642. }
  4643. }
  4644. Tooltip.prototype.init = function(type, element, options) {
  4645. this.enabled = true;
  4646. this.type = type;
  4647. this.$element = $(element);
  4648. this.options = this.getOptions(options);
  4649. this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport);
  4650. var triggers = this.options.trigger.split(' ');
  4651. for (var i = triggers.length; i--;) {
  4652. var trigger = triggers[i];
  4653. if (trigger == 'click') {
  4654. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this));
  4655. } else if (trigger != 'manual') {
  4656. var eventIn = trigger == 'hover' ? 'mouseenter': 'focusin';
  4657. var eventOut = trigger == 'hover' ? 'mouseleave': 'focusout';
  4658. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this));
  4659. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this));
  4660. }
  4661. }
  4662. this.options.selector ? (this._options = $.extend({},
  4663. this.options, {
  4664. trigger: 'manual',
  4665. selector: ''
  4666. })) : this.fixTitle()
  4667. }
  4668. Tooltip.prototype.getDefaults = function() {
  4669. return Tooltip.DEFAULTS;
  4670. }
  4671. Tooltip.prototype.getOptions = function(options) {
  4672. options = $.extend({},
  4673. this.getDefaults(), this.$element.data(), options);
  4674. if (options.delay && typeof options.delay == 'number') {
  4675. options.delay = {
  4676. show: options.delay,
  4677. hide: options.delay
  4678. }
  4679. }
  4680. return options;
  4681. }
  4682. Tooltip.prototype.getDelegateOptions = function() {
  4683. var options = {}
  4684. var defaults = this.getDefaults()
  4685. this._options && $.each(this._options,
  4686. function(key, value) {
  4687. if (defaults[key] != value) options[key] = value;
  4688. })
  4689. return options;
  4690. }
  4691. Tooltip.prototype.enter = function(obj) {
  4692. var self = obj instanceof this.constructor ?
  4693. obj: $(obj.currentTarget).data('bs.' + this.type);
  4694. if (self && self.$tip && self.$tip.is(':visible')) {
  4695. self.hoverState = 'in';
  4696. return;
  4697. }
  4698. if (!self) {
  4699. self = new this.constructor(obj.currentTarget, this.getDelegateOptions());
  4700. $(obj.currentTarget).data('bs.' + this.type, self);
  4701. }
  4702. clearTimeout(self.timeout);
  4703. self.hoverState = 'in';
  4704. if (!self.options.delay || !self.options.delay.show) return self.show()
  4705. self.timeout = setTimeout(function() {
  4706. if (self.hoverState == 'in') self.show();
  4707. },
  4708. self.options.delay.show);
  4709. }
  4710. Tooltip.prototype.leave = function(obj) {
  4711. var self = obj instanceof this.constructor ? obj: $(obj.currentTarget).data('bs.' + this.type);
  4712. if (!self) {
  4713. self = new this.constructor(obj.currentTarget, this.getDelegateOptions());
  4714. $(obj.currentTarget).data('bs.' + this.type, self);
  4715. }
  4716. clearTimeout(self.timeout);
  4717. self.hoverState = 'out';
  4718. if (!self.options.delay || !self.options.delay.hide) return self.hide();
  4719. self.timeout = setTimeout(function() {
  4720. if (self.hoverState == 'out') self.hide();
  4721. },
  4722. self.options.delay.hide);
  4723. }
  4724. Tooltip.prototype.show = function() {
  4725. var e = $.Event('show.bs.' + this.type);
  4726. if (this.hasContent() && this.enabled) {
  4727. this.$element.trigger(e);
  4728. var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]);
  4729. if (e.isDefaultPrevented() || !inDom) return;
  4730. var that = this;
  4731. var $tip = this.tip();
  4732. var tipId = this.getUID(this.type);
  4733. this.setContent();
  4734. $tip.attr('id', tipId);
  4735. this.$element.attr('aria-describedby', tipId);
  4736. if (this.options.animation) $tip.addClass('fade');
  4737. var placement = typeof this.options.placement == 'function' ? this.options.placement.call(this, $tip[0], this.$element[0]) : this.options.placement;
  4738. var autoToken = /\s?auto?\s?/i;
  4739. var autoPlace = autoToken.test(placement);
  4740. if (autoPlace) placement = placement.replace(autoToken, '') || 'top';
  4741. $tip.detach().css({
  4742. top: 0,
  4743. left: 0,
  4744. display: 'block'
  4745. }).addClass(placement).data('bs.' + this.type, this);
  4746. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element);
  4747. var pos = this.getPosition();
  4748. var actualWidth = $tip[0].offsetWidth;
  4749. var actualHeight = $tip[0].offsetHeight;
  4750. if (autoPlace) {
  4751. var orgPlacement = placement;
  4752. var $container = this.options.container ? $(this.options.container) : this.$element.parent();
  4753. var containerDim = this.getPosition($container);
  4754. placement = placement == 'bottom' && pos.bottom + actualHeight > containerDim.bottom ? 'top': placement == 'top' && pos.top - actualHeight < containerDim.top ? 'bottom': placement == 'right' && pos.right + actualWidth > containerDim.width ? 'left': placement == 'left' && pos.left - actualWidth < containerDim.left ? 'right': placement
  4755. $tip.removeClass(orgPlacement).addClass(placement);
  4756. }
  4757. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight);
  4758. this.applyPlacement(calculatedOffset, placement);
  4759. var complete = function() {
  4760. var prevHoverState = that.hoverState;
  4761. that.$element.trigger('shown.bs.' + that.type);
  4762. that.hoverState = null;
  4763. if (prevHoverState == 'out') that.leave(that);
  4764. }
  4765. $.support.transition && this.$tip.hasClass('fade') ? $tip.one('bsTransitionEnd', complete).emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : complete()
  4766. }
  4767. }
  4768. Tooltip.prototype.applyPlacement = function(offset, placement) {
  4769. var $tip = this.tip();
  4770. var width = $tip[0].offsetWidth;
  4771. var height = $tip[0].offsetHeight;
  4772. // manually read margins because getBoundingClientRect includes difference
  4773. var marginTop = parseInt($tip.css('margin-top'), 10);
  4774. var marginLeft = parseInt($tip.css('margin-left'), 10);
  4775. // we must check for NaN for ie 8/9
  4776. if (isNaN(marginTop)) marginTop = 0;
  4777. if (isNaN(marginLeft)) marginLeft = 0;
  4778. offset.top = offset.top + marginTop;
  4779. offset.left = offset.left + marginLeft;
  4780. // $.fn.offset doesn't round pixel values
  4781. // so we use setOffset directly with our own function B-0
  4782. $.offset.setOffset($tip[0], $.extend({
  4783. using: function(props) {
  4784. $tip.css({
  4785. top: Math.round(props.top),
  4786. left: Math.round(props.left)
  4787. })
  4788. }
  4789. },
  4790. offset), 0);
  4791. $tip.addClass('in');
  4792. // check to see if placing tip in new offset caused the tip to resize itself
  4793. var actualWidth = $tip[0].offsetWidth;
  4794. var actualHeight = $tip[0].offsetHeight;
  4795. if (placement == 'top' && actualHeight != height) {
  4796. offset.top = offset.top + height - actualHeight;
  4797. }
  4798. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight);
  4799. if (delta.left) offset.left += delta.left;
  4800. else offset.top += delta.top;
  4801. var isVertical = /top|bottom/.test(placement);
  4802. var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth: delta.top * 2 - height + actualHeight;
  4803. var arrowOffsetPosition = isVertical ? 'offsetWidth': 'offsetHeight';
  4804. $tip.offset(offset);
  4805. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical);
  4806. }
  4807. Tooltip.prototype.replaceArrow = function(delta, dimension, isHorizontal) {
  4808. this.arrow().css(isHorizontal ? 'left': 'top', 50 * (1 - delta / dimension) + '%').css(isHorizontal ? 'top': 'left', '');
  4809. }
  4810. Tooltip.prototype.setContent = function() {
  4811. var $tip = this.tip();
  4812. var title = this.getTitle();
  4813. $tip.find('.tooltip-inner')[this.options.html ? 'html': 'text'](title);
  4814. $tip.removeClass('fade in top bottom left right');
  4815. }
  4816. Tooltip.prototype.hide = function(callback) {
  4817. var that = this;
  4818. var $tip = this.tip();
  4819. var e = $.Event('hide.bs.' + this.type);
  4820. function complete() {
  4821. if (that.hoverState != 'in') $tip.detach();
  4822. that.$element.removeAttr('aria-describedby').trigger('hidden.bs.' + that.type);
  4823. callback && callback();
  4824. }
  4825. this.$element.trigger(e);
  4826. if (e.isDefaultPrevented()) return;
  4827. $tip.removeClass('in');
  4828. $.support.transition && this.$tip.hasClass('fade') ? $tip.one('bsTransitionEnd', complete).emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : complete();
  4829. this.hoverState = null;
  4830. return this;
  4831. }
  4832. Tooltip.prototype.fixTitle = function() {
  4833. var $e = this.$element
  4834. if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
  4835. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  4836. }
  4837. }
  4838. Tooltip.prototype.hasContent = function() {
  4839. return this.getTitle();
  4840. }
  4841. Tooltip.prototype.getPosition = function($element) {
  4842. $element = $element || this.$element;
  4843. var el = $element[0];
  4844. var isBody = el.tagName == 'BODY';
  4845. var elRect = el.getBoundingClientRect();
  4846. if (elRect.width == null) {
  4847. // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
  4848. elRect = $.extend({},
  4849. elRect, {
  4850. width: elRect.right - elRect.left,
  4851. height: elRect.bottom - elRect.top
  4852. });
  4853. }
  4854. var elOffset = isBody ? {
  4855. top: 0,
  4856. left: 0
  4857. }: $element.offset();
  4858. var scroll = {
  4859. scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop: $element.scrollTop()
  4860. }
  4861. var outerDims = isBody ? {
  4862. width: $(window).width(),
  4863. height: $(window).height()
  4864. }: null
  4865. return $.extend({},
  4866. elRect, scroll, outerDims, elOffset)
  4867. }
  4868. Tooltip.prototype.getCalculatedOffset = function(placement, pos, actualWidth, actualHeight) {
  4869. return placement == 'bottom' ? {
  4870. top: pos.top + pos.height,
  4871. left: pos.left + pos.width / 2 - actualWidth / 2
  4872. }: placement == 'top' ? {
  4873. top: pos.top - actualHeight,
  4874. left: pos.left + pos.width / 2 - actualWidth / 2
  4875. }: placement == 'left' ? {
  4876. top: pos.top + pos.height / 2 - actualHeight / 2,
  4877. left: pos.left - actualWidth
  4878. }:
  4879. /* placement == 'right' */
  4880. {
  4881. top: pos.top + pos.height / 2 - actualHeight / 2,
  4882. left: pos.left + pos.width
  4883. }
  4884. }
  4885. Tooltip.prototype.getViewportAdjustedDelta = function(placement, pos, actualWidth, actualHeight) {
  4886. var delta = {
  4887. top: 0,
  4888. left: 0
  4889. }
  4890. if (!this.$viewport) return delta;
  4891. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0;
  4892. var viewportDimensions = this.getPosition(this.$viewport);
  4893. if (/right|left/.test(placement)) {
  4894. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll;
  4895. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight;
  4896. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  4897. delta.top = viewportDimensions.top - topEdgeOffset;
  4898. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  4899. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset;
  4900. }
  4901. } else {
  4902. var leftEdgeOffset = pos.left - viewportPadding;
  4903. var rightEdgeOffset = pos.left + viewportPadding + actualWidth;
  4904. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  4905. delta.left = viewportDimensions.left - leftEdgeOffset;
  4906. } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
  4907. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset;
  4908. }
  4909. }
  4910. return delta
  4911. }
  4912. Tooltip.prototype.getTitle = function() {
  4913. var title;
  4914. var $e = this.$element;
  4915. var o = this.options;
  4916. title = $e.attr('data-original-title') || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  4917. return title;
  4918. }
  4919. Tooltip.prototype.getUID = function(prefix) {
  4920. do prefix += ~~ (Math.random() * 1000000);
  4921. while (document.getElementById(prefix));
  4922. return prefix;
  4923. }
  4924. Tooltip.prototype.tip = function() {
  4925. return (this.$tip = this.$tip || $(this.options.template));
  4926. }
  4927. Tooltip.prototype.arrow = function() {
  4928. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'));
  4929. }
  4930. Tooltip.prototype.enable = function() {
  4931. this.enabled = true;
  4932. }
  4933. Tooltip.prototype.disable = function() {
  4934. this.enabled = false;
  4935. }
  4936. Tooltip.prototype.toggleEnabled = function() {
  4937. this.enabled = !this.enabled;
  4938. }
  4939. Tooltip.prototype.toggle = function(e) {
  4940. var self = this;
  4941. if (e) {
  4942. self = $(e.currentTarget).data('bs.' + this.type);
  4943. if (!self) {
  4944. self = new this.constructor(e.currentTarget, this.getDelegateOptions());
  4945. $(e.currentTarget).data('bs.' + this.type, self);
  4946. }
  4947. }
  4948. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  4949. }
  4950. Tooltip.prototype.destroy = function() {
  4951. var that = this;
  4952. clearTimeout(this.timeout);
  4953. this.hide(function() {
  4954. that.$element.off('.' + that.type).removeData('bs.' + that.type);
  4955. });
  4956. }
  4957. // TOOLTIP PLUGIN DEFINITION
  4958. // =========================
  4959. function Plugin(option) {
  4960. return this.each(function() {
  4961. var $this = $(this);
  4962. var data = $this.data('bs.tooltip');
  4963. var options = typeof option == 'object' && option;
  4964. var selector = options && options.selector;
  4965. if (!data && option == 'destroy') return;
  4966. if (selector) {
  4967. if (!data) $this.data('bs.tooltip', (data = {}));
  4968. if (!data[selector]) data[selector] = new Tooltip(this, options);
  4969. } else {
  4970. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)));
  4971. }
  4972. if (typeof option == 'string') data[option]()
  4973. })
  4974. }
  4975. var old = $.fn.tooltip;
  4976. $.fn.tooltip = Plugin;
  4977. $.fn.tooltip.Constructor = Tooltip;
  4978. // TOOLTIP NO CONFLICT
  4979. // ===================
  4980. $.fn.tooltip.noConflict = function() {
  4981. $.fn.tooltip = old;
  4982. return this;
  4983. }
  4984. } (window.jQuery);
  4985. $(function() {
  4986. $("[data-toggle='tooltip']").tooltip();
  4987. });
  4988. /* =======================================================================
  4989. * Bootstrap.popover.js v3.3.0
  4990. * http://getbootstrap.com/javascript/#popovers
  4991. * ========================================================================
  4992. * Copyright 2011-2014 Twitter, Inc.
  4993. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4994. * ======================================================================== */
  4995. !
  4996. function($) {
  4997. 'use strict';
  4998. // POPOVER PUBLIC CLASS DEFINITION
  4999. // ===============================
  5000. var Popover = function(element, options) {
  5001. this.init('popover', element, options)
  5002. }
  5003. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js');
  5004. Popover.VERSION = '3.3.0';
  5005. Popover.DEFAULTS = $.extend({},
  5006. $.fn.tooltip.Constructor.DEFAULTS, {
  5007. placement: 'right',
  5008. trigger: 'click',
  5009. content: '',
  5010. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  5011. })
  5012. // NOTE: POPOVER EXTENDS tooltip.js
  5013. // ================================
  5014. Popover.prototype = $.extend({},$.fn.tooltip.Constructor.prototype);
  5015. Popover.prototype.constructor = Popover;
  5016. Popover.prototype.getDefaults = function() {
  5017. return Popover.DEFAULTS;
  5018. }
  5019. Popover.prototype.setContent = function() {
  5020. var $tip = this.tip();
  5021. var title = this.getTitle();
  5022. var content = this.getContent();
  5023. $tip.find('.popover-title')[this.options.html ? 'html': 'text'](title);
  5024. $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
  5025. this.options.html ? (typeof content == 'string' ? 'html': 'append') : 'text'](content)
  5026. $tip.removeClass('fade top bottom left right in');
  5027. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  5028. // this manually by checking the contents.
  5029. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide();
  5030. }
  5031. Popover.prototype.hasContent = function() {
  5032. return this.getTitle() || this.getContent()
  5033. }
  5034. Popover.prototype.getContent = function() {
  5035. var $e = this.$element;
  5036. var o = this.options;
  5037. return $e.attr('data-content') || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
  5038. }
  5039. Popover.prototype.arrow = function() {
  5040. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  5041. }
  5042. Popover.prototype.tip = function() {
  5043. if (!this.$tip) this.$tip = $(this.options.template);
  5044. return this.$tip;
  5045. }
  5046. // POPOVER PLUGIN DEFINITION
  5047. // =========================
  5048. function Plugin(option) {
  5049. return this.each(function() {
  5050. var $this = $(this);
  5051. var data = $this.data('bs.popover');
  5052. var options = typeof option == 'object' && option;
  5053. var selector = options && options.selector;
  5054. if (!data && option == 'destroy') return;
  5055. if (selector) {
  5056. if (!data) $this.data('bs.popover', (data = {}));
  5057. if (!data[selector]) data[selector] = new Popover(this, options);
  5058. } else {
  5059. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  5060. }
  5061. if (typeof option == 'string') data[option]()
  5062. })
  5063. }
  5064. var old = $.fn.popover
  5065. $.fn.popover = Plugin;
  5066. $.fn.popover.Constructor = Popover;
  5067. // POPOVER NO CONFLICT
  5068. // ===================
  5069. $.fn.popover.noConflict = function() {
  5070. $.fn.popover = old;
  5071. return this;
  5072. }
  5073. } (window.jQuery);
  5074. $(function() {
  5075. $("[data-toggle='popover']").popover();
  5076. });
  5077. /* =======================================================================
  5078. * Bootstrap.alert.js v3.3.0
  5079. * http://getbootstrap.com/javascript/#alerts
  5080. * ========================================================================
  5081. * Copyright 2011-2014 Twitter, Inc.
  5082. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5083. * ======================================================================== */
  5084. !function($) {
  5085. 'use strict';
  5086. // ALERT CLASS DEFINITION
  5087. // ======================
  5088. var dismiss = '[data-dismiss="alert"]'
  5089. var Alert = function(el) {
  5090. $(el).on('click', dismiss, this.close)
  5091. }
  5092. Alert.VERSION = '3.3.0'
  5093. Alert.TRANSITION_DURATION = 150
  5094. Alert.prototype.close = function(e) {
  5095. var $this = $(this);
  5096. var selector = $this.attr('data-target');
  5097. if (!selector) {
  5098. selector = $this.attr('href');
  5099. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
  5100. }
  5101. var $parent = $(selector);
  5102. if (e) e.preventDefault();
  5103. if (!$parent.length) {
  5104. $parent = $this.closest('.alert');
  5105. }
  5106. $parent.trigger(e = $.Event('close.bs.alert'))
  5107. if (e.isDefaultPrevented()) return;
  5108. $parent.removeClass('in');
  5109. function removeElement() {
  5110. // detach from parent, fire event then clean up data
  5111. $parent.detach().trigger('closed.bs.alert').remove();
  5112. }
  5113. $.support.transition && $parent.hasClass('fade') ? $parent.one('bsTransitionEnd', removeElement).emulateTransitionEnd(Alert.TRANSITION_DURATION) : removeElement()
  5114. }
  5115. // ALERT PLUGIN DEFINITION
  5116. // =======================
  5117. function Plugin(option) {
  5118. return this.each(function() {
  5119. var $this = $(this);
  5120. var data = $this.data('bs.alert');
  5121. if (!data) $this.data('bs.alert', (data = new Alert(this)));
  5122. if (typeof option == 'string') data[option].call($this);
  5123. })
  5124. }
  5125. var old = $.fn.alert;
  5126. $.fn.alert = Plugin;
  5127. $.fn.alert.Constructor = Alert;
  5128. // ALERT NO CONFLICT
  5129. // =================
  5130. $.fn.alert.noConflict = function() {
  5131. $.fn.alert = old;
  5132. return this;
  5133. }
  5134. // ALERT DATA-API
  5135. // ==============
  5136. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  5137. } (window.jQuery);
  5138. /* =========================================================
  5139. * Bootstrap.slider.js v1.0.1
  5140. * Maintainers:
  5141. * Kyle Kemp
  5142. * - Twitter: @seiyria
  5143. * - Github: seiyria
  5144. * Rohit Kalkur
  5145. * - Twitter: @Rovolutionary
  5146. * - Github: rovolution
  5147. *
  5148. * =========================================================
  5149. *
  5150. * Licensed under the Apache License, Version 2.0 (the "License");
  5151. * you may not use this file except in compliance with the License.
  5152. * You may obtain a copy of the License at
  5153. *
  5154. * http://www.apache.org/licenses/LICENSE-2.0
  5155. *
  5156. * Unless required by applicable law or agreed to in writing, software
  5157. * distributed under the License is distributed on an "AS IS" BASIS,
  5158. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5159. * See the License for the specific language governing permissions and
  5160. * limitations under the License.
  5161. * Bridget makes jQuery widgets
  5162. * MIT license
  5163. * ========================================================= */
  5164. (function(root, factory) {
  5165. if (typeof define === "function" && define.amd) {
  5166. define(["jquery"], factory);
  5167. } else if (typeof module === "object" && module.exports) {
  5168. var jQuery;
  5169. try {
  5170. jQuery = require("jquery");
  5171. } catch(err) {
  5172. jQuery = null;
  5173. }
  5174. module.exports = factory(jQuery);
  5175. } else {
  5176. root.Slider = factory(root.jQuery);
  5177. }
  5178. } (this,
  5179. function($) {
  5180. // Reference to Slider constructor
  5181. var Slider; (function($) {
  5182. 'use strict';
  5183. // -------------------------- utils -------------------------- //
  5184. var slice = Array.prototype.slice;
  5185. function noop() {}
  5186. // -------------------------- definition -------------------------- //
  5187. function defineBridget($) {
  5188. // bail if no jQuery
  5189. if (!$) {
  5190. return;
  5191. }
  5192. // -------------------------- addOptionMethod -------------------------- //
  5193. /**
  5194. * adds option method -> $().plugin('option', {...})
  5195. * @param {Function} PluginClass - constructor class
  5196. */
  5197. function addOptionMethod(PluginClass) {
  5198. // don't overwrite original option method
  5199. if (PluginClass.prototype.option) {
  5200. return;
  5201. }
  5202. // option setter
  5203. PluginClass.prototype.option = function(opts) {
  5204. // bail out if not an object
  5205. if (!$.isPlainObject(opts)) {
  5206. return;
  5207. }
  5208. this.options = $.extend(true, this.options, opts);
  5209. };
  5210. }
  5211. // -------------------------- plugin bridge -------------------------- //
  5212. // helper function for logging errors
  5213. // $.error breaks jQuery chaining
  5214. var logError = typeof console === 'undefined' ? noop: function(message) {
  5215. console.error(message);
  5216. };
  5217. /**
  5218. * jQuery plugin bridge, access methods like $elem.plugin('method')
  5219. * @param {String} namespace - plugin name
  5220. * @param {Function} PluginClass - constructor class
  5221. */
  5222. function bridge(namespace, PluginClass) {
  5223. // add to jQuery fn namespace
  5224. $.fn[namespace] = function(options) {
  5225. if (typeof options === 'string') {
  5226. // call plugin method when first argument is a string
  5227. // get arguments for method
  5228. var args = slice.call(arguments, 1);
  5229. for (var i = 0,
  5230. len = this.length; i < len; i++) {
  5231. var elem = this[i];
  5232. var instance = $.data(elem, namespace);
  5233. if (!instance) {
  5234. logError("cannot call methods on " + namespace + " prior to initialization; " + "attempted to call '" + options + "'");
  5235. continue;
  5236. }
  5237. if (!$.isFunction(instance[options]) || options.charAt(0) === '_') {
  5238. logError("no such method '" + options + "' for " + namespace + " instance");
  5239. continue;
  5240. }
  5241. // trigger method with arguments
  5242. var returnValue = instance[options].apply(instance, args);
  5243. // break look and return first value if provided
  5244. if (returnValue !== undefined && returnValue !== instance) {
  5245. return returnValue;
  5246. }
  5247. }
  5248. // return this if no return value
  5249. return this;
  5250. } else {
  5251. var objects = this.map(function() {
  5252. var instance = $.data(this, namespace);
  5253. if (instance) {
  5254. // apply options & init
  5255. instance.option(options);
  5256. instance._init();
  5257. } else {
  5258. // initialize new instance
  5259. instance = new PluginClass(this, options);
  5260. $.data(this, namespace, instance);
  5261. }
  5262. return $(this);
  5263. });
  5264. if (!objects || objects.length > 1) {
  5265. return objects;
  5266. } else {
  5267. return objects[0];
  5268. }
  5269. }
  5270. };
  5271. }
  5272. // -------------------------- bridget -------------------------- //
  5273. /**
  5274. * converts a Prototypical class into a proper jQuery plugin
  5275. * the class must have a ._init method
  5276. * @param {String} namespace - plugin name, used in $().pluginName
  5277. * @param {Function} PluginClass - constructor class
  5278. */
  5279. $.bridget = function(namespace, PluginClass) {
  5280. addOptionMethod(PluginClass);
  5281. bridge(namespace, PluginClass);
  5282. };
  5283. return $.bridget;
  5284. }
  5285. // get jquery from browser global
  5286. defineBridget($);
  5287. })($);
  5288. /*************************************************
  5289. BOOTSTRAP-SLIDER SOURCE CODE
  5290. **************************************************/
  5291. (function($) {
  5292. var ErrorMsgs = {
  5293. formatInvalidInputErrorMsg: function(input) {
  5294. return "Invalid input value '" + input + "' passed in";
  5295. },
  5296. callingContextNotSliderInstance: "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method"
  5297. };
  5298. /*************************************************
  5299. CONSTRUCTOR
  5300. **************************************************/
  5301. Slider = function(element, options) {
  5302. createNewSlider.call(this, element, options);
  5303. return this;
  5304. };
  5305. function createNewSlider(element, options) {
  5306. /*************************************************
  5307. Create Markup
  5308. **************************************************/
  5309. if (typeof element === "string") {
  5310. this.element = document.querySelector(element);
  5311. } else if (element instanceof HTMLElement) {
  5312. this.element = element;
  5313. }
  5314. var origWidth = this.element.style.width;
  5315. var updateSlider = false;
  5316. var parent = this.element.parentNode;
  5317. var sliderTrackSelection;
  5318. var sliderMinHandle;
  5319. var sliderMaxHandle;
  5320. if (this.sliderElem) {
  5321. updateSlider = true;
  5322. } else {
  5323. /* Create elements needed for slider */
  5324. this.sliderElem = document.createElement("div");
  5325. this.sliderElem.className = "slider";
  5326. /* Create slider track elements */
  5327. var sliderTrack = document.createElement("div");
  5328. sliderTrack.className = "slider-track";
  5329. sliderTrackSelection = document.createElement("div");
  5330. sliderTrackSelection.className = "slider-selection";
  5331. sliderMinHandle = document.createElement("div");
  5332. sliderMinHandle.className = "slider-handle min-slider-handle";
  5333. sliderMaxHandle = document.createElement("div");
  5334. sliderMaxHandle.className = "slider-handle max-slider-handle";
  5335. sliderTrack.appendChild(sliderTrackSelection);
  5336. sliderTrack.appendChild(sliderMinHandle);
  5337. sliderTrack.appendChild(sliderMaxHandle);
  5338. var createAndAppendTooltipSubElements = function(tooltipElem) {
  5339. var arrow = document.createElement("div");
  5340. arrow.className = "tooltip-arrow";
  5341. var inner = document.createElement("div");
  5342. inner.className = "tooltip-inner";
  5343. tooltipElem.appendChild(arrow);
  5344. tooltipElem.appendChild(inner);
  5345. };
  5346. /* Create tooltip elements */
  5347. var sliderTooltip = document.createElement("div");
  5348. sliderTooltip.className = "tooltip tooltip-main";
  5349. createAndAppendTooltipSubElements(sliderTooltip);
  5350. var sliderTooltipMin = document.createElement("div");
  5351. sliderTooltipMin.className = "tooltip tooltip-min";
  5352. createAndAppendTooltipSubElements(sliderTooltipMin);
  5353. var sliderTooltipMax = document.createElement("div");
  5354. sliderTooltipMax.className = "tooltip tooltip-max";
  5355. createAndAppendTooltipSubElements(sliderTooltipMax);
  5356. /* Append components to sliderElem */
  5357. this.sliderElem.appendChild(sliderTrack);
  5358. this.sliderElem.appendChild(sliderTooltip);
  5359. this.sliderElem.appendChild(sliderTooltipMin);
  5360. this.sliderElem.appendChild(sliderTooltipMax);
  5361. /* Append slider element to parent container, right before the original <input> element */
  5362. parent.insertBefore(this.sliderElem, this.element);
  5363. /* Hide original <input> element */
  5364. this.element.style.display = "none";
  5365. }
  5366. /* If JQuery exists, cache JQ references */
  5367. if ($) {
  5368. this.$element = $(this.element);
  5369. this.$sliderElem = $(this.sliderElem);
  5370. }
  5371. /*************************************************
  5372. Process Options
  5373. **************************************************/
  5374. options = options ? options: {};
  5375. var optionTypes = Object.keys(this.defaultOptions);
  5376. for (var i = 0; i < optionTypes.length; i++) {
  5377. var optName = optionTypes[i];
  5378. // First check if an option was passed in via the constructor
  5379. var val = options[optName];
  5380. // If no data attrib, then check data atrributes
  5381. val = (typeof val !== 'undefined') ? val : getDataAttrib(this.element, optName);
  5382. // Finally, if nothing was specified, use the defaults
  5383. val = (val !== null) ? val : this.defaultOptions[optName];
  5384. // Set all options on the instance of the Slider
  5385. if (!this.options) {
  5386. this.options = {};
  5387. }
  5388. this.options[optName] = val;
  5389. }
  5390. function getDataAttrib(element, optName) {
  5391. var dataName = "data-slider-" + optName;
  5392. var dataValString = element.getAttribute(dataName);
  5393. try {
  5394. return JSON.parse(dataValString);
  5395. } catch(err) {
  5396. return dataValString;
  5397. }
  5398. }
  5399. /*************************************************
  5400. Setup
  5401. **************************************************/
  5402. this.eventToCallbackMap = {};
  5403. this.sliderElem.id = this.options.id;
  5404. this.touchCapable = 'ontouchstart' in window || (window.DocumentTouch && document instanceof window.DocumentTouch);
  5405. this.tooltip = this.sliderElem.querySelector('.tooltip-main');
  5406. this.tooltipInner = this.tooltip.querySelector('.tooltip-inner');
  5407. this.tooltip_min = this.sliderElem.querySelector('.tooltip-min');
  5408. this.tooltipInner_min = this.tooltip_min.querySelector('.tooltip-inner');
  5409. this.tooltip_max = this.sliderElem.querySelector('.tooltip-max');
  5410. this.tooltipInner_max = this.tooltip_max.querySelector('.tooltip-inner');
  5411. if (updateSlider === true) {
  5412. // Reset classes
  5413. this._removeClass(this.sliderElem, 'slider-horizontal');
  5414. this._removeClass(this.sliderElem, 'slider-vertical');
  5415. this._removeClass(this.tooltip, 'hide');
  5416. this._removeClass(this.tooltip_min, 'hide');
  5417. this._removeClass(this.tooltip_max, 'hide');
  5418. // Undo existing inline styles for track
  5419. ["left", "top", "width", "height"].forEach(function(prop) {
  5420. this._removeProperty(this.trackSelection, prop);
  5421. },
  5422. this);
  5423. // Undo inline styles on handles
  5424. [this.handle1, this.handle2].forEach(function(handle) {
  5425. this._removeProperty(handle, 'left');
  5426. this._removeProperty(handle, 'top');
  5427. },
  5428. this);
  5429. // Undo inline styles and classes on tooltips
  5430. [this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function(tooltip) {
  5431. this._removeProperty(tooltip, 'left');
  5432. this._removeProperty(tooltip, 'top');
  5433. this._removeProperty(tooltip, 'margin-left');
  5434. this._removeProperty(tooltip, 'margin-top');
  5435. this._removeClass(tooltip, 'right');
  5436. this._removeClass(tooltip, 'top');
  5437. },
  5438. this);
  5439. }
  5440. if (this.options.orientation === 'vertical') {
  5441. this._addClass(this.sliderElem, 'slider-vertical');
  5442. this.stylePos = 'top';
  5443. this.mousePos = 'pageY';
  5444. this.sizePos = 'offsetHeight';
  5445. this._addClass(this.tooltip, 'right');
  5446. this.tooltip.style.left = '100%';
  5447. this._addClass(this.tooltip_min, 'right');
  5448. this.tooltip_min.style.left = '100%';
  5449. this._addClass(this.tooltip_max, 'right');
  5450. this.tooltip_max.style.left = '100%';
  5451. } else {
  5452. this._addClass(this.sliderElem, 'slider-horizontal');
  5453. this.sliderElem.style.width = origWidth;
  5454. this.options.orientation = 'horizontal';
  5455. this.stylePos = 'left';
  5456. this.mousePos = 'pageX';
  5457. this.sizePos = 'offsetWidth';
  5458. this._addClass(this.tooltip, 'top');
  5459. this.tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
  5460. this._addClass(this.tooltip_min, 'top');
  5461. this.tooltip_min.style.top = -this.tooltip_min.outerHeight - 14 + 'px';
  5462. this._addClass(this.tooltip_max, 'top');
  5463. this.tooltip_max.style.top = -this.tooltip_max.outerHeight - 14 + 'px';
  5464. }
  5465. if (this.options.value instanceof Array) {
  5466. this.options.range = true;
  5467. } else if (this.options.range) {
  5468. // User wants a range, but value is not an array
  5469. this.options.value = [this.options.value, this.options.max];
  5470. }
  5471. this.trackSelection = sliderTrackSelection || this.trackSelection;
  5472. if (this.options.selection === 'none') {
  5473. this._addClass(this.trackSelection, 'hide');
  5474. }
  5475. this.handle1 = sliderMinHandle || this.handle1;
  5476. this.handle2 = sliderMaxHandle || this.handle2;
  5477. if (updateSlider === true) {
  5478. // Reset classes
  5479. this._removeClass(this.handle1, 'round triangle');
  5480. this._removeClass(this.handle2, 'round triangle hide');
  5481. }
  5482. var availableHandleModifiers = ['round', 'triangle', 'custom'];
  5483. var isValidHandleType = availableHandleModifiers.indexOf(this.options.handle) !== -1;
  5484. if (isValidHandleType) {
  5485. this._addClass(this.handle1, this.options.handle);
  5486. this._addClass(this.handle2, this.options.handle);
  5487. }
  5488. this.offset = this._offset(this.sliderElem);
  5489. this.size = this.sliderElem[this.sizePos];
  5490. this.setValue(this.options.value);
  5491. /******************************************
  5492. Bind Event Listeners
  5493. ******************************************/
  5494. // Bind keyboard handlers
  5495. this.handle1Keydown = this._keydown.bind(this, 0);
  5496. this.handle1.addEventListener("keydown", this.handle1Keydown, false);
  5497. this.handle2Keydown = this._keydown.bind(this, 1);
  5498. this.handle2.addEventListener("keydown", this.handle2Keydown, false);
  5499. if (this.touchCapable) {
  5500. // Bind touch handlers
  5501. this.mousedown = this._mousedown.bind(this);
  5502. this.sliderElem.addEventListener("touchstart", this.mousedown, false);
  5503. } else {
  5504. // Bind mouse handlers
  5505. this.mousedown = this._mousedown.bind(this);
  5506. this.sliderElem.addEventListener("mousedown", this.mousedown, false);
  5507. }
  5508. // Bind tooltip-related handlers
  5509. if (this.options.tooltip === 'hide') {
  5510. this._addClass(this.tooltip, 'hide');
  5511. this._addClass(this.tooltip_min, 'hide');
  5512. this._addClass(this.tooltip_max, 'hide');
  5513. } else if (this.options.tooltip === 'always') {
  5514. this._showTooltip();
  5515. this._alwaysShowTooltip = true;
  5516. } else {
  5517. this.showTooltip = this._showTooltip.bind(this);
  5518. this.hideTooltip = this._hideTooltip.bind(this);
  5519. this.sliderElem.addEventListener("mouseenter", this.showTooltip, false);
  5520. this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false);
  5521. this.handle1.addEventListener("focus", this.showTooltip, false);
  5522. this.handle1.addEventListener("blur", this.hideTooltip, false);
  5523. this.handle2.addEventListener("focus", this.showTooltip, false);
  5524. this.handle2.addEventListener("blur", this.hideTooltip, false);
  5525. }
  5526. if (this.options.enabled) {
  5527. this.enable();
  5528. } else {
  5529. this.disable();
  5530. }
  5531. }
  5532. /*************************************************
  5533. INSTANCE PROPERTIES/METHODS
  5534. - Any methods bound to the prototype are considered
  5535. part of the plugin's `public` interface
  5536. **************************************************/
  5537. Slider.prototype = {
  5538. _init: function() {},
  5539. // NOTE: Must exist to support bridget
  5540. constructor: Slider,
  5541. defaultOptions: {
  5542. id: "",
  5543. min: 0,
  5544. max: 10,
  5545. step: 1,
  5546. precision: 0,
  5547. orientation: 'horizontal',
  5548. value: 5,
  5549. range: false,
  5550. selection: 'before',
  5551. tooltip: 'show',
  5552. tooltip_split: false,
  5553. handle: 'round',
  5554. reversed: false,
  5555. enabled: true,
  5556. formatter: function(val) {
  5557. if (val instanceof Array) {
  5558. return val[0] + " : " + val[1];
  5559. } else {
  5560. return val;
  5561. }
  5562. },
  5563. natural_arrow_keys: false
  5564. },
  5565. over: false,
  5566. inDrag: false,
  5567. getValue: function() {
  5568. if (this.options.range) {
  5569. return this.options.value;
  5570. }
  5571. return this.options.value[0];
  5572. },
  5573. setValue: function(val, triggerSlideEvent) {
  5574. if (!val) {
  5575. val = 0;
  5576. }
  5577. var oldValue = this.getValue();
  5578. this.options.value = this._validateInputValue(val);
  5579. var applyPrecision = this._applyPrecision.bind(this);
  5580. if (this.options.range) {
  5581. this.options.value[0] = applyPrecision(this.options.value[0]);
  5582. this.options.value[1] = applyPrecision(this.options.value[1]);
  5583. this.options.value[0] = Math.max(this.options.min, Math.min(this.options.max, this.options.value[0]));
  5584. this.options.value[1] = Math.max(this.options.min, Math.min(this.options.max, this.options.value[1]));
  5585. } else {
  5586. this.options.value = applyPrecision(this.options.value);
  5587. this.options.value = [Math.max(this.options.min, Math.min(this.options.max, this.options.value))];
  5588. this._addClass(this.handle2, 'hide');
  5589. if (this.options.selection === 'after') {
  5590. this.options.value[1] = this.options.max;
  5591. } else {
  5592. this.options.value[1] = this.options.min;
  5593. }
  5594. }
  5595. this.diff = this.options.max - this.options.min;
  5596. if (this.diff > 0) {
  5597. this.percentage = [
  5598. (this.options.value[0] - this.options.min) * 100 / this.diff,
  5599. (this.options.value[1] - this.options.min) * 100 / this.diff,
  5600. this.options.step * 100 / this.diff];
  5601. } else {
  5602. this.percentage = [0, 0, 100];
  5603. }
  5604. this._layout();
  5605. var newValue = this.options.range ? this.options.value : this.options.value[0];
  5606. if (triggerSlideEvent === true) {
  5607. this._trigger('slide', newValue);
  5608. }
  5609. if (oldValue !== newValue) {
  5610. this._trigger('change', {
  5611. oldValue: oldValue,
  5612. newValue: newValue
  5613. });
  5614. }
  5615. this._setDataVal(newValue);
  5616. return this;
  5617. },
  5618. destroy: function() {
  5619. // Remove event handlers on slider elements
  5620. this._removeSliderEventHandlers();
  5621. // Remove the slider from the DOM
  5622. this.sliderElem.parentNode.removeChild(this.sliderElem);
  5623. /* Show original <input> element */
  5624. this.element.style.display = "";
  5625. // Clear out custom event bindings
  5626. this._cleanUpEventCallbacksMap();
  5627. // Remove data values
  5628. this.element.removeAttribute("data");
  5629. // Remove JQuery handlers/data
  5630. if ($) {
  5631. this._unbindJQueryEventHandlers();
  5632. this.$element.removeData('slider');
  5633. }
  5634. },
  5635. disable: function() {
  5636. this.options.enabled = false;
  5637. this.handle1.removeAttribute("tabindex");
  5638. this.handle2.removeAttribute("tabindex");
  5639. this._addClass(this.sliderElem, 'slider-disabled');
  5640. this._trigger('slideDisabled');
  5641. return this;
  5642. },
  5643. enable: function() {
  5644. this.options.enabled = true;
  5645. this.handle1.setAttribute("tabindex", 0);
  5646. this.handle2.setAttribute("tabindex", 0);
  5647. this._removeClass(this.sliderElem, 'slider-disabled');
  5648. this._trigger('slideEnabled');
  5649. return this;
  5650. },
  5651. toggle: function() {
  5652. if (this.options.enabled) {
  5653. this.disable();
  5654. } else {
  5655. this.enable();
  5656. }
  5657. return this;
  5658. },
  5659. isEnabled: function() {
  5660. return this.options.enabled;
  5661. },
  5662. on: function(evt, callback) {
  5663. if ($) {
  5664. this.$element.on(evt, callback);
  5665. this.$sliderElem.on(evt, callback);
  5666. } else {
  5667. this._bindNonQueryEventHandler(evt, callback);
  5668. }
  5669. return this;
  5670. },
  5671. getAttribute: function(attribute) {
  5672. if (attribute) {
  5673. return this.options[attribute];
  5674. } else {
  5675. return this.options;
  5676. }
  5677. },
  5678. setAttribute: function(attribute, value) {
  5679. this.options[attribute] = value;
  5680. return this;
  5681. },
  5682. refresh: function() {
  5683. this._removeSliderEventHandlers();
  5684. createNewSlider.call(this, this.element, this.options);
  5685. if ($) {
  5686. // Bind new instance of slider to the element
  5687. $.data(this.element, 'slider', this);
  5688. }
  5689. return this;
  5690. },
  5691. relayout: function() {
  5692. this._layout();
  5693. return this;
  5694. },
  5695. /******************************+
  5696. HELPERS
  5697. - Any method that is not part of the public interface.
  5698. - Place it underneath this comment block and write its signature like so:
  5699. _fnName : function() {...}
  5700. ********************************/
  5701. _removeSliderEventHandlers: function() {
  5702. // Remove event listeners from handle1
  5703. this.handle1.removeEventListener("keydown", this.handle1Keydown, false);
  5704. this.handle1.removeEventListener("focus", this.showTooltip, false);
  5705. this.handle1.removeEventListener("blur", this.hideTooltip, false);
  5706. // Remove event listeners from handle2
  5707. this.handle2.removeEventListener("keydown", this.handle2Keydown, false);
  5708. this.handle2.removeEventListener("focus", this.handle2Keydown, false);
  5709. this.handle2.removeEventListener("blur", this.handle2Keydown, false);
  5710. // Remove event listeners from sliderElem
  5711. this.sliderElem.removeEventListener("mouseenter", this.showTooltip, false);
  5712. this.sliderElem.removeEventListener("mouseleave", this.hideTooltip, false);
  5713. this.sliderElem.removeEventListener("touchstart", this.mousedown, false);
  5714. this.sliderElem.removeEventListener("mousedown", this.mousedown, false);
  5715. },
  5716. _bindNonQueryEventHandler: function(evt, callback) {
  5717. if (this.eventToCallbackMap[evt] === undefined) {
  5718. this.eventToCallbackMap[evt] = [];
  5719. }
  5720. this.eventToCallbackMap[evt].push(callback);
  5721. },
  5722. _cleanUpEventCallbacksMap: function() {
  5723. var eventNames = Object.keys(this.eventToCallbackMap);
  5724. for (var i = 0; i < eventNames.length; i++) {
  5725. var eventName = eventNames[i];
  5726. this.eventToCallbackMap[eventName] = null;
  5727. }
  5728. },
  5729. _showTooltip: function() {
  5730. if (this.options.tooltip_split === false) {
  5731. this._addClass(this.tooltip, 'in');
  5732. } else {
  5733. this._addClass(this.tooltip_min, 'in');
  5734. this._addClass(this.tooltip_max, 'in');
  5735. }
  5736. this.over = true;
  5737. },
  5738. _hideTooltip: function() {
  5739. if (this.inDrag === false && this.alwaysShowTooltip !== true) {
  5740. this._removeClass(this.tooltip, 'in');
  5741. this._removeClass(this.tooltip_min, 'in');
  5742. this._removeClass(this.tooltip_max, 'in');
  5743. }
  5744. this.over = false;
  5745. },
  5746. _layout: function() {
  5747. var positionPercentages;
  5748. if (this.options.reversed) {
  5749. positionPercentages = [100 - this.percentage[0], this.percentage[1]];
  5750. } else {
  5751. positionPercentages = [this.percentage[0], this.percentage[1]];
  5752. }
  5753. this.handle1.style[this.stylePos] = positionPercentages[0] + '%';
  5754. this.handle2.style[this.stylePos] = positionPercentages[1] + '%';
  5755. if (this.options.orientation === 'vertical') {
  5756. this.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
  5757. this.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
  5758. } else {
  5759. this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
  5760. this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
  5761. var offset_min = this.tooltip_min.getBoundingClientRect();
  5762. var offset_max = this.tooltip_max.getBoundingClientRect();
  5763. if (offset_min.right > offset_max.left) {
  5764. this._removeClass(this.tooltip_max, 'top');
  5765. this._addClass(this.tooltip_max, 'bottom');
  5766. this.tooltip_max.style.top = 18 + 'px';
  5767. } else {
  5768. this._removeClass(this.tooltip_max, 'bottom');
  5769. this._addClass(this.tooltip_max, 'top');
  5770. this.tooltip_max.style.top = this.tooltip_min.style.top;
  5771. }
  5772. }
  5773. var formattedTooltipVal;
  5774. if (this.options.range) {
  5775. formattedTooltipVal = this.options.formatter(this.options.value);
  5776. this._setText(this.tooltipInner, formattedTooltipVal);
  5777. this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + '%';
  5778. if (this.options.orientation === 'vertical') {
  5779. this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
  5780. } else {
  5781. this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
  5782. }
  5783. if (this.options.orientation === 'vertical') {
  5784. this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
  5785. } else {
  5786. this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
  5787. }
  5788. var innerTooltipMinText = this.options.formatter(this.options.value[0]);
  5789. this._setText(this.tooltipInner_min, innerTooltipMinText);
  5790. var innerTooltipMaxText = this.options.formatter(this.options.value[1]);
  5791. this._setText(this.tooltipInner_max, innerTooltipMaxText);
  5792. this.tooltip_min.style[this.stylePos] = positionPercentages[0] + '%';
  5793. if (this.options.orientation === 'vertical') {
  5794. this._css(this.tooltip_min, 'margin-top', -this.tooltip_min.offsetHeight / 2 + 'px');
  5795. } else {
  5796. this._css(this.tooltip_min, 'margin-left', -this.tooltip_min.offsetWidth / 2 + 'px');
  5797. }
  5798. this.tooltip_max.style[this.stylePos] = positionPercentages[1] + '%';
  5799. if (this.options.orientation === 'vertical') {
  5800. this._css(this.tooltip_max, 'margin-top', -this.tooltip_max.offsetHeight / 2 + 'px');
  5801. } else {
  5802. this._css(this.tooltip_max, 'margin-left', -this.tooltip_max.offsetWidth / 2 + 'px');
  5803. }
  5804. } else {
  5805. formattedTooltipVal = this.options.formatter(this.options.value[0]);
  5806. this._setText(this.tooltipInner, formattedTooltipVal);
  5807. this.tooltip.style[this.stylePos] = positionPercentages[0] + '%';
  5808. if (this.options.orientation === 'vertical') {
  5809. this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
  5810. } else {
  5811. this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
  5812. }
  5813. }
  5814. },
  5815. _removeProperty: function(element, prop) {
  5816. if (element.style.removeProperty) {
  5817. element.style.removeProperty(prop);
  5818. } else {
  5819. element.style.removeAttribute(prop);
  5820. }
  5821. },
  5822. _mousedown: function(ev) {
  5823. if (!this.options.enabled) {
  5824. return false;
  5825. }
  5826. this._triggerFocusOnHandle();
  5827. this.offset = this._offset(this.sliderElem);
  5828. this.size = this.sliderElem[this.sizePos];
  5829. var percentage = this._getPercentage(ev);
  5830. if (this.options.range) {
  5831. var diff1 = Math.abs(this.percentage[0] - percentage);
  5832. var diff2 = Math.abs(this.percentage[1] - percentage);
  5833. this.dragged = (diff1 < diff2) ? 0 : 1;
  5834. } else {
  5835. this.dragged = 0;
  5836. }
  5837. this.percentage[this.dragged] = this.options.reversed ? 100 - percentage: percentage;
  5838. this._layout();
  5839. if (this.touchCapable) {
  5840. document.removeEventListener("touchmove", this.mousemove, false);
  5841. document.removeEventListener("touchend", this.mouseup, false);
  5842. }
  5843. if (this.mousemove) {
  5844. document.removeEventListener("mousemove", this.mousemove, false);
  5845. }
  5846. if (this.mouseup) {
  5847. document.removeEventListener("mouseup", this.mouseup, false);
  5848. }
  5849. this.mousemove = this._mousemove.bind(this);
  5850. this.mouseup = this._mouseup.bind(this);
  5851. if (this.touchCapable) {
  5852. // Touch: Bind touch events:
  5853. document.addEventListener("touchmove", this.mousemove, false);
  5854. document.addEventListener("touchend", this.mouseup, false);
  5855. }
  5856. // Bind mouse events:
  5857. document.addEventListener("mousemove", this.mousemove, false);
  5858. document.addEventListener("mouseup", this.mouseup, false);
  5859. this.inDrag = true;
  5860. var newValue = this._calculateValue();
  5861. this._trigger('slideStart', newValue);
  5862. this._setDataVal(newValue);
  5863. this.setValue(newValue);
  5864. this._pauseEvent(ev);
  5865. return true;
  5866. },
  5867. _triggerFocusOnHandle: function(handleIdx) {
  5868. if (handleIdx === 0) {
  5869. this.handle1.focus();
  5870. }
  5871. if (handleIdx === 1) {
  5872. this.handle2.focus();
  5873. }
  5874. },
  5875. _keydown: function(handleIdx, ev) {
  5876. if (!this.options.enabled) {
  5877. return false;
  5878. }
  5879. var dir;
  5880. switch (ev.keyCode) {
  5881. case 37:
  5882. // left
  5883. case 40:
  5884. // down
  5885. dir = -1;
  5886. break;
  5887. case 39:
  5888. // right
  5889. case 38:
  5890. // up
  5891. dir = 1;
  5892. break;
  5893. }
  5894. if (!dir) {
  5895. return;
  5896. }
  5897. // use natural arrow keys instead of from min to max
  5898. if (this.options.natural_arrow_keys) {
  5899. var ifVerticalAndNotReversed = (this.options.orientation === 'vertical' && !this.options.reversed);
  5900. var ifHorizontalAndReversed = (this.options.orientation === 'horizontal' && this.options.reversed);
  5901. if (ifVerticalAndNotReversed || ifHorizontalAndReversed) {
  5902. dir = dir * -1;
  5903. }
  5904. }
  5905. var oneStepValuePercentageChange = dir * this.percentage[2];
  5906. var percentage = this.percentage[handleIdx] + oneStepValuePercentageChange;
  5907. if (percentage > 100) {
  5908. percentage = 100;
  5909. } else if (percentage < 0) {
  5910. percentage = 0;
  5911. }
  5912. this.dragged = handleIdx;
  5913. this._adjustPercentageForRangeSliders(percentage);
  5914. this.percentage[this.dragged] = percentage;
  5915. this._layout();
  5916. var val = this._calculateValue();
  5917. this._trigger('slideStart', val);
  5918. this._setDataVal(val);
  5919. this.setValue(val, true);
  5920. this._trigger('slideStop', val);
  5921. this._setDataVal(val);
  5922. this._pauseEvent(ev);
  5923. return false;
  5924. },
  5925. _pauseEvent: function(ev) {
  5926. if (ev.stopPropagation) {
  5927. ev.stopPropagation();
  5928. }
  5929. if (ev.preventDefault) {
  5930. ev.preventDefault();
  5931. }
  5932. ev.cancelBubble = true;
  5933. ev.returnValue = false;
  5934. },
  5935. _mousemove: function(ev) {
  5936. if (!this.options.enabled) {
  5937. return false;
  5938. }
  5939. var percentage = this._getPercentage(ev);
  5940. this._adjustPercentageForRangeSliders(percentage);
  5941. this.percentage[this.dragged] = this.options.reversed ? 100 - percentage: percentage;
  5942. this._layout();
  5943. var val = this._calculateValue();
  5944. this.setValue(val, true);
  5945. return false;
  5946. },
  5947. _adjustPercentageForRangeSliders: function(percentage) {
  5948. if (this.options.range) {
  5949. if (this.dragged === 0 && this.percentage[1] < percentage) {
  5950. this.percentage[0] = this.percentage[1];
  5951. this.dragged = 1;
  5952. } else if (this.dragged === 1 && this.percentage[0] > percentage) {
  5953. this.percentage[1] = this.percentage[0];
  5954. this.dragged = 0;
  5955. }
  5956. }
  5957. },
  5958. _mouseup: function() {
  5959. if (!this.options.enabled) {
  5960. return false;
  5961. }
  5962. if (this.touchCapable) {
  5963. // Touch: Unbind touch event handlers:
  5964. document.removeEventListener("touchmove", this.mousemove, false);
  5965. document.removeEventListener("touchend", this.mouseup, false);
  5966. }
  5967. // Unbind mouse event handlers:
  5968. document.removeEventListener("mousemove", this.mousemove, false);
  5969. document.removeEventListener("mouseup", this.mouseup, false);
  5970. this.inDrag = false;
  5971. if (this.over === false) {
  5972. this._hideTooltip();
  5973. }
  5974. var val = this._calculateValue();
  5975. this._layout();
  5976. this._trigger('slideStop', val);
  5977. this._setDataVal(val);
  5978. return false;
  5979. },
  5980. _calculateValue: function() {
  5981. var val;
  5982. if (this.options.range) {
  5983. val = [this.options.min, this.options.max];
  5984. if (this.percentage[0] !== 0) {
  5985. val[0] = (Math.max(this.options.min, this.options.min + Math.round((this.diff * this.percentage[0] / 100) / this.options.step) * this.options.step));
  5986. val[0] = this._applyPrecision(val[0]);
  5987. }
  5988. if (this.percentage[1] !== 100) {
  5989. val[1] = (Math.min(this.options.max, this.options.min + Math.round((this.diff * this.percentage[1] / 100) / this.options.step) * this.options.step));
  5990. val[1] = this._applyPrecision(val[1]);
  5991. }
  5992. } else {
  5993. val = (this.options.min + Math.round((this.diff * this.percentage[0] / 100) / this.options.step) * this.options.step);
  5994. if (val < this.options.min) {
  5995. val = this.options.min;
  5996. } else if (val > this.options.max) {
  5997. val = this.options.max;
  5998. }
  5999. val = parseFloat(val);
  6000. val = this._applyPrecision(val);
  6001. }
  6002. return val;
  6003. },
  6004. _applyPrecision: function(val) {
  6005. var precision = this.options.precision || this._getNumDigitsAfterDecimalPlace(this.options.step);
  6006. return this._applyToFixedAndParseFloat(val, precision);
  6007. },
  6008. _getNumDigitsAfterDecimalPlace: function(num) {
  6009. var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  6010. if (!match) {
  6011. return 0;
  6012. }
  6013. return Math.max(0, (match[1] ? match[1].length: 0) - (match[2] ? +match[2] : 0));
  6014. },
  6015. _applyToFixedAndParseFloat: function(num, toFixedInput) {
  6016. var truncatedNum = num.toFixed(toFixedInput);
  6017. return parseFloat(truncatedNum);
  6018. },
  6019. /*
  6020. Credits to Mike Samuel for the following method!
  6021. Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
  6022. */
  6023. _getPercentage: function(ev) {
  6024. if (this.touchCapable && (ev.type === 'touchstart' || ev.type === 'touchmove')) {
  6025. ev = ev.touches[0];
  6026. }
  6027. var percentage = (ev[this.mousePos] - this.offset[this.stylePos]) * 100 / this.size;
  6028. percentage = Math.round(percentage / this.percentage[2]) * this.percentage[2];
  6029. return Math.max(0, Math.min(100, percentage));
  6030. },
  6031. _validateInputValue: function(val) {
  6032. if (typeof val === 'number') {
  6033. return val;
  6034. } else if (val instanceof Array) {
  6035. this._validateArray(val);
  6036. return val;
  6037. } else {
  6038. throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(val));
  6039. }
  6040. },
  6041. _validateArray: function(val) {
  6042. for (var i = 0; i < val.length; i++) {
  6043. var input = val[i];
  6044. if (typeof input !== 'number') {
  6045. throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(input));
  6046. }
  6047. }
  6048. },
  6049. _setDataVal: function(val) {
  6050. var value = "value: '" + val + "'";
  6051. this.element.setAttribute('data', value);
  6052. this.element.setAttribute('value', val);
  6053. },
  6054. _trigger: function(evt, val) {
  6055. val = (val || val === 0) ? val: undefined;
  6056. var callbackFnArray = this.eventToCallbackMap[evt];
  6057. if (callbackFnArray && callbackFnArray.length) {
  6058. for (var i = 0; i < callbackFnArray.length; i++) {
  6059. var callbackFn = callbackFnArray[i];
  6060. callbackFn(val);
  6061. }
  6062. }
  6063. /* If JQuery exists, trigger JQuery events */
  6064. if ($) {
  6065. this._triggerJQueryEvent(evt, val);
  6066. }
  6067. },
  6068. _triggerJQueryEvent: function(evt, val) {
  6069. var eventData = {
  6070. type: evt,
  6071. value: val
  6072. };
  6073. this.$element.trigger(eventData);
  6074. this.$sliderElem.trigger(eventData);
  6075. },
  6076. _unbindJQueryEventHandlers: function() {
  6077. this.$element.off();
  6078. this.$sliderElem.off();
  6079. },
  6080. _setText: function(element, text) {
  6081. if (typeof element.innerText !== "undefined") {
  6082. element.innerText = text;
  6083. } else if (typeof element.textContent !== "undefined") {
  6084. element.textContent = text;
  6085. }
  6086. },
  6087. _removeClass: function(element, classString) {
  6088. var classes = classString.split(" ");
  6089. var newClasses = element.className;
  6090. for (var i = 0; i < classes.length; i++) {
  6091. var classTag = classes[i];
  6092. var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
  6093. newClasses = newClasses.replace(regex, " ");
  6094. }
  6095. element.className = newClasses.trim();
  6096. },
  6097. _addClass: function(element, classString) {
  6098. var classes = classString.split(" ");
  6099. var newClasses = element.className;
  6100. for (var i = 0; i < classes.length; i++) {
  6101. var classTag = classes[i];
  6102. var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
  6103. var ifClassExists = regex.test(newClasses);
  6104. if (!ifClassExists) {
  6105. newClasses += " " + classTag;
  6106. }
  6107. }
  6108. element.className = newClasses.trim();
  6109. },
  6110. _offset: function(obj) {
  6111. var ol = 0;
  6112. var ot = 0;
  6113. if (obj.offsetParent) {
  6114. do {
  6115. ol += obj.offsetLeft;
  6116. ot += obj.offsetTop;
  6117. } while ( obj = obj . offsetParent );
  6118. }
  6119. return {
  6120. left: ol,
  6121. top: ot
  6122. };
  6123. },
  6124. _css: function(elementRef, styleName, value) {
  6125. if ($) {
  6126. $.style(elementRef, styleName, value);
  6127. } else {
  6128. var style = styleName.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi,
  6129. function(all, letter) {
  6130. return letter.toUpperCase();
  6131. });
  6132. elementRef.style[style] = value;
  6133. }
  6134. }
  6135. };
  6136. /*********************************
  6137. Attach to global namespace
  6138. *********************************/
  6139. if ($) {
  6140. var namespace = $.fn.slider ? 'bootstrapSlider': 'slider';
  6141. $.bridget(namespace, Slider);
  6142. }
  6143. })($);
  6144. return Slider;
  6145. }));
  6146. /* =========================================================
  6147. * Bootstrap.datetimepicker.js
  6148. * =========================================================
  6149. * Copyright 2012 Stefan Petre
  6150. *
  6151. * Improvements by Andrew Rowls
  6152. * Improvements by Sébastien Malot
  6153. * Improvements by Yun Lai
  6154. * Improvements by Kenneth Henderick
  6155. * Improvements by CuGBabyBeaR
  6156. * Improvements by Christian Vaas <auspex@auspex.eu>
  6157. *
  6158. * Project URL : http://www.malot.fr/bootstrap-datetimepicker
  6159. *
  6160. * Licensed under the Apache License, Version 2.0 (the "License");
  6161. * you may not use this file except in compliance with the License.
  6162. * You may obtain a copy of the License at
  6163. *
  6164. * http://www.apache.org/licenses/LICENSE-2.0
  6165. *
  6166. * Unless required by applicable law or agreed to in writing, software
  6167. * distributed under the License is distributed on an "AS IS" BASIS,
  6168. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6169. * See the License for the specific language governing permissions and
  6170. * limitations under the License.
  6171. * ========================================================= */
  6172. ! (function(factory) {
  6173. if (typeof define === 'function' && define.amd) define(['jquery'], factory);
  6174. else if (typeof exports === 'object') factory(require('jquery'));
  6175. else factory(jQuery);
  6176. } (function($, undefined) {
  6177. // Add ECMA262-5 Array methods if not supported natively (IE8)
  6178. if (! ('indexOf' in Array.prototype)) {
  6179. Array.prototype.indexOf = function(find, i) {
  6180. if (i === undefined) i = 0;
  6181. if (i < 0) i += this.length;
  6182. if (i < 0) i = 0;
  6183. for (var n = this.length; i < n; i++) {
  6184. if (i in this && this[i] === find) {
  6185. return i;
  6186. }
  6187. }
  6188. return - 1;
  6189. }
  6190. }
  6191. function elementOrParentIsFixed(element) {
  6192. var $element = $(element);
  6193. var $checkElements = $element.add($element.parents());
  6194. var isFixed = false;
  6195. $checkElements.each(function() {
  6196. if ($(this).css('position') === 'fixed') {
  6197. isFixed = true;
  6198. return false;
  6199. }
  6200. });
  6201. return isFixed;
  6202. }
  6203. function UTCDate() {
  6204. return new Date(Date.UTC.apply(Date, arguments));
  6205. }
  6206. function UTCToday() {
  6207. var today = new Date();
  6208. return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), today.getUTCHours(), today.getUTCMinutes(), today.getUTCSeconds(), 0);
  6209. }
  6210. // Picker object
  6211. var Datetimepicker = function(element, options) {
  6212. var that = this;
  6213. this.element = $(element);
  6214. // add container for single page application
  6215. // when page switch the datetimepicker div will be removed also.
  6216. this.container = options.container || 'body';
  6217. this.language = options.language || this.element.data('date-language') || 'en';
  6218. this.language = this.language in dates ? this.language: this.language.split('-')[0]; // fr-CA fallback to fr
  6219. this.language = this.language in dates ? this.language: 'en';
  6220. this.isRTL = dates[this.language].rtl || false;
  6221. this.formatType = options.formatType || this.element.data('format-type') || 'standard';
  6222. this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || dates[this.language].format || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
  6223. this.isInline = false;
  6224. this.isVisible = false;
  6225. this.isInput = this.element.is('input');
  6226. this.fontAwesome = options.fontAwesome || this.element.data('font-awesome') || false;
  6227. this.bootcssVer = options.bootcssVer || (this.isInput ? (this.element.is('.form-control') ? 3 : 2) : (this.bootcssVer = this.element.is('.input-group') ? 3 : 2));
  6228. this.component = this.element.is('.date') ? (this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-remove, .input-group-addon .glyphicon-calendar, .input-group-addon .fa-calendar, .input-group-addon .fa-clock-o').parent() : this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar, .add-on .fa-calendar, .add-on .fa-clock-o').parent()) : false;
  6229. this.componentReset = this.element.is('.date') ? (this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-remove, .input-group-addon .fa-times').parent() : this.element.find('.add-on .icon-remove, .add-on .fa-times').parent()) : false;
  6230. this.hasInput = this.component && this.element.find('input').length;
  6231. if (this.component && this.component.length === 0) {
  6232. this.component = false;
  6233. }
  6234. this.linkField = options.linkField || this.element.data('link-field') || false;
  6235. this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
  6236. this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
  6237. this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
  6238. this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
  6239. this.initialDate = options.initialDate || new Date();
  6240. this.zIndex = options.zIndex || this.element.data('z-index') || undefined;
  6241. this.title = typeof options.title === 'undefined' ? false: options.title;
  6242. this.defaultTimeZone = (new Date).toString().split('(')[1].slice(0, -1);
  6243. this.timezone = options.timezone || this.defaultTimeZone;
  6244. this.icons = {
  6245. leftArrow: this.fontAwesome ? 'fa-arrow-left': (this.bootcssVer === 3 ? 'glyphicon-arrow-left': 'icon-arrow-left'),
  6246. rightArrow: this.fontAwesome ? 'fa-arrow-right': (this.bootcssVer === 3 ? 'glyphicon-arrow-right': 'icon-arrow-right')
  6247. }
  6248. this.icontype = this.fontAwesome ? 'fa': 'glyphicon';
  6249. this._attachEvents();
  6250. this.clickedOutside = function(e) {
  6251. // Clicked outside the datetimepicker, hide it
  6252. if ($(e.target).closest('.datetimepicker').length === 0) {
  6253. that.hide();
  6254. }
  6255. }
  6256. this.formatViewType = 'datetime';
  6257. if ('formatViewType' in options) {
  6258. this.formatViewType = options.formatViewType;
  6259. } else if ('formatViewType' in this.element.data()) {
  6260. this.formatViewType = this.element.data('formatViewType');
  6261. }
  6262. this.minView = 0;
  6263. if ('minView' in options) {
  6264. this.minView = options.minView;
  6265. } else if ('minView' in this.element.data()) {
  6266. this.minView = this.element.data('min-view');
  6267. }
  6268. this.minView = DPGlobal.convertViewMode(this.minView);
  6269. this.maxView = DPGlobal.modes.length - 1;
  6270. if ('maxView' in options) {
  6271. this.maxView = options.maxView;
  6272. } else if ('maxView' in this.element.data()) {
  6273. this.maxView = this.element.data('max-view');
  6274. }
  6275. this.maxView = DPGlobal.convertViewMode(this.maxView);
  6276. this.wheelViewModeNavigation = false;
  6277. if ('wheelViewModeNavigation' in options) {
  6278. this.wheelViewModeNavigation = options.wheelViewModeNavigation;
  6279. } else if ('wheelViewModeNavigation' in this.element.data()) {
  6280. this.wheelViewModeNavigation = this.element.data('view-mode-wheel-navigation');
  6281. }
  6282. this.wheelViewModeNavigationInverseDirection = false;
  6283. if ('wheelViewModeNavigationInverseDirection' in options) {
  6284. this.wheelViewModeNavigationInverseDirection = options.wheelViewModeNavigationInverseDirection;
  6285. } else if ('wheelViewModeNavigationInverseDirection' in this.element.data()) {
  6286. this.wheelViewModeNavigationInverseDirection = this.element.data('view-mode-wheel-navigation-inverse-dir');
  6287. }
  6288. this.wheelViewModeNavigationDelay = 100;
  6289. if ('wheelViewModeNavigationDelay' in options) {
  6290. this.wheelViewModeNavigationDelay = options.wheelViewModeNavigationDelay;
  6291. } else if ('wheelViewModeNavigationDelay' in this.element.data()) {
  6292. this.wheelViewModeNavigationDelay = this.element.data('view-mode-wheel-navigation-delay');
  6293. }
  6294. this.startViewMode = 2;
  6295. if ('startView' in options) {
  6296. this.startViewMode = options.startView;
  6297. } else if ('startView' in this.element.data()) {
  6298. this.startViewMode = this.element.data('start-view');
  6299. }
  6300. this.startViewMode = DPGlobal.convertViewMode(this.startViewMode);
  6301. this.viewMode = this.startViewMode;
  6302. this.viewSelect = this.minView;
  6303. if ('viewSelect' in options) {
  6304. this.viewSelect = options.viewSelect;
  6305. } else if ('viewSelect' in this.element.data()) {
  6306. this.viewSelect = this.element.data('view-select');
  6307. }
  6308. this.viewSelect = DPGlobal.convertViewMode(this.viewSelect);
  6309. this.forceParse = true;
  6310. if ('forceParse' in options) {
  6311. this.forceParse = options.forceParse;
  6312. } else if ('dateForceParse' in this.element.data()) {
  6313. this.forceParse = this.element.data('date-force-parse');
  6314. }
  6315. var template = this.bootcssVer === 3 ? DPGlobal.templateV3: DPGlobal.template;
  6316. while (template.indexOf('{iconType}') !== -1) {
  6317. template = template.replace('{iconType}', this.icontype);
  6318. }
  6319. while (template.indexOf('{leftArrow}') !== -1) {
  6320. template = template.replace('{leftArrow}', this.icons.leftArrow);
  6321. }
  6322. while (template.indexOf('{rightArrow}') !== -1) {
  6323. template = template.replace('{rightArrow}', this.icons.rightArrow);
  6324. }
  6325. this.picker = $(template).appendTo(this.isInline ? this.element: this.container) // 'body')
  6326. .on({
  6327. click: $.proxy(this.click, this),
  6328. mousedown: $.proxy(this.mousedown, this)
  6329. });
  6330. if (this.wheelViewModeNavigation) {
  6331. if ($.fn.mousewheel) {
  6332. this.picker.on({
  6333. mousewheel: $.proxy(this.mousewheel, this)
  6334. });
  6335. } else {
  6336. console.log('Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option');
  6337. }
  6338. }
  6339. if (this.isInline) {
  6340. this.picker.addClass('datetimepicker-inline');
  6341. } else {
  6342. this.picker.addClass('datetimepicker-dropdown-' + this.pickerPosition + ' dropdown-menu');
  6343. }
  6344. if (this.isRTL) {
  6345. this.picker.addClass('datetimepicker-rtl');
  6346. var selector = this.bootcssVer === 3 ? '.prev span, .next span': '.prev i, .next i';
  6347. this.picker.find(selector).toggleClass(this.icons.leftArrow + ' ' + this.icons.rightArrow);
  6348. }
  6349. $(document).on('mousedown', this.clickedOutside);
  6350. this.autoclose = false;
  6351. if ('autoclose' in options) {
  6352. this.autoclose = options.autoclose;
  6353. } else if ('dateAutoclose' in this.element.data()) {
  6354. this.autoclose = this.element.data('date-autoclose');
  6355. }
  6356. this.keyboardNavigation = true;
  6357. if ('keyboardNavigation' in options) {
  6358. this.keyboardNavigation = options.keyboardNavigation;
  6359. } else if ('dateKeyboardNavigation' in this.element.data()) {
  6360. this.keyboardNavigation = this.element.data('date-keyboard-navigation');
  6361. }
  6362. this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
  6363. this.clearBtn = (options.clearBtn || this.element.data('date-clear-btn') || false);
  6364. this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
  6365. this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
  6366. this.weekEnd = ((this.weekStart + 6) % 7);
  6367. this.startDate = -Infinity;
  6368. this.endDate = Infinity;
  6369. this.datesDisabled = [];
  6370. this.daysOfWeekDisabled = [];
  6371. this.setStartDate(options.startDate || this.element.data('date-startdate'));
  6372. this.setEndDate(options.endDate || this.element.data('date-enddate'));
  6373. this.setDatesDisabled(options.datesDisabled || this.element.data('date-dates-disabled'));
  6374. this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
  6375. this.setMinutesDisabled(options.minutesDisabled || this.element.data('date-minute-disabled'));
  6376. this.setHoursDisabled(options.hoursDisabled || this.element.data('date-hour-disabled'));
  6377. this.fillDow();
  6378. this.fillMonths();
  6379. this.update();
  6380. this.showMode();
  6381. if (this.isInline) {
  6382. this.show();
  6383. }
  6384. };
  6385. Datetimepicker.prototype = {
  6386. constructor: Datetimepicker,
  6387. _events: [],
  6388. _attachEvents: function() {
  6389. this._detachEvents();
  6390. if (this.isInput) { // single input
  6391. this._events = [[this.element, {
  6392. focus: $.proxy(this.show, this),
  6393. keyup: $.proxy(this.update, this),
  6394. keydown: $.proxy(this.keydown, this)
  6395. }]];
  6396. } else if (this.component && this.hasInput) { // component: input + button
  6397. this._events = [
  6398. // For components that are not readonly, allow keyboard nav
  6399. [this.element.find('input'), {
  6400. focus: $.proxy(this.show, this),
  6401. keyup: $.proxy(this.update, this),
  6402. keydown: $.proxy(this.keydown, this)
  6403. }], [this.component, {
  6404. click: $.proxy(this.show, this)
  6405. }]];
  6406. if (this.componentReset) {
  6407. this._events.push([this.componentReset, {
  6408. click: $.proxy(this.reset, this)
  6409. }]);
  6410. }
  6411. } else if (this.element.is('div')) { // inline datetimepicker
  6412. this.isInline = true;
  6413. } else {
  6414. this._events = [[this.element, {
  6415. click: $.proxy(this.show, this)
  6416. }]];
  6417. }
  6418. for (var i = 0,
  6419. el, ev; i < this._events.length; i++) {
  6420. el = this._events[i][0];
  6421. ev = this._events[i][1];
  6422. el.on(ev);
  6423. }
  6424. },
  6425. _detachEvents: function() {
  6426. for (var i = 0,
  6427. el, ev; i < this._events.length; i++) {
  6428. el = this._events[i][0];
  6429. ev = this._events[i][1];
  6430. el.off(ev);
  6431. }
  6432. this._events = [];
  6433. },
  6434. show: function(e) {
  6435. this.picker.show();
  6436. this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
  6437. if (this.forceParse) {
  6438. this.update();
  6439. }
  6440. this.place();
  6441. $(window).on('resize', $.proxy(this.place, this));
  6442. if (e) {
  6443. e.stopPropagation();
  6444. e.preventDefault();
  6445. }
  6446. this.isVisible = true;
  6447. this.element.trigger({
  6448. type: 'show',
  6449. date: this.date
  6450. });
  6451. },
  6452. hide: function(e) {
  6453. if (!this.isVisible) return;
  6454. if (this.isInline) return;
  6455. this.picker.hide();
  6456. $(window).off('resize', this.place);
  6457. this.viewMode = this.startViewMode;
  6458. this.showMode();
  6459. if (!this.isInput) {
  6460. $(document).off('mousedown', this.hide);
  6461. }
  6462. if (this.forceParse && (this.isInput && this.element.val() || this.hasInput && this.element.find('input').val())) this.setValue();
  6463. this.isVisible = false;
  6464. this.element.trigger({
  6465. type: 'hide',
  6466. date: this.date
  6467. });
  6468. },
  6469. remove: function() {
  6470. this._detachEvents();
  6471. $(document).off('mousedown', this.clickedOutside);
  6472. this.picker.remove();
  6473. delete this.picker;
  6474. delete this.element.data().datetimepicker;
  6475. },
  6476. getDate: function() {
  6477. var d = this.getUTCDate();
  6478. return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
  6479. },
  6480. getUTCDate: function() {
  6481. return this.date;
  6482. },
  6483. getInitialDate: function() {
  6484. return this.initialDate
  6485. },
  6486. setInitialDate: function(initialDate) {
  6487. this.initialDate = initialDate;
  6488. },
  6489. setDate: function(d) {
  6490. this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset() * 60000)));
  6491. },
  6492. setUTCDate: function(d) {
  6493. if (d >= this.startDate && d <= this.endDate) {
  6494. this.date = d;
  6495. this.setValue();
  6496. this.viewDate = this.date;
  6497. this.fill();
  6498. } else {
  6499. this.element.trigger({
  6500. type: 'outOfRange',
  6501. date: d,
  6502. startDate: this.startDate,
  6503. endDate: this.endDate
  6504. });
  6505. }
  6506. },
  6507. setFormat: function(format) {
  6508. this.format = DPGlobal.parseFormat(format, this.formatType);
  6509. var element;
  6510. if (this.isInput) {
  6511. element = this.element;
  6512. } else if (this.component) {
  6513. element = this.element.find('input');
  6514. }
  6515. if (element && element.val()) {
  6516. this.setValue();
  6517. }
  6518. },
  6519. setValue: function() {
  6520. var formatted = this.getFormattedDate();
  6521. if (!this.isInput) {
  6522. if (this.component) {
  6523. this.element.find('input').val(formatted);
  6524. }
  6525. this.element.data('date', formatted);
  6526. } else {
  6527. this.element.val(formatted);
  6528. }
  6529. if (this.linkField) {
  6530. $('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
  6531. }
  6532. },
  6533. getFormattedDate: function(format) {
  6534. if (format == undefined) format = this.format;
  6535. return DPGlobal.formatDate(this.date, format, this.language, this.formatType, this.timezone);
  6536. },
  6537. setStartDate: function(startDate) {
  6538. this.startDate = startDate || -Infinity;
  6539. if (this.startDate !== -Infinity) {
  6540. this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language, this.formatType, this.timezone);
  6541. }
  6542. this.update();
  6543. this.updateNavArrows();
  6544. },
  6545. setEndDate: function(endDate) {
  6546. this.endDate = endDate || Infinity;
  6547. if (this.endDate !== Infinity) {
  6548. this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language, this.formatType, this.timezone);
  6549. }
  6550. this.update();
  6551. this.updateNavArrows();
  6552. },
  6553. setDatesDisabled: function(datesDisabled) {
  6554. this.datesDisabled = datesDisabled || [];
  6555. if (!$.isArray(this.datesDisabled)) {
  6556. this.datesDisabled = this.datesDisabled.split(/,\s*/);
  6557. }
  6558. this.datesDisabled = $.map(this.datesDisabled,
  6559. function(d) {
  6560. return DPGlobal.parseDate(d, this.format, this.language, this.formatType, this.timezone).toDateString();
  6561. });
  6562. this.update();
  6563. this.updateNavArrows();
  6564. },
  6565. setTitle: function(selector, value) {
  6566. return this.picker.find(selector).find('th:eq(1)').text(this.title === false ? value: this.title);
  6567. },
  6568. setDaysOfWeekDisabled: function(daysOfWeekDisabled) {
  6569. this.daysOfWeekDisabled = daysOfWeekDisabled || [];
  6570. if (!$.isArray(this.daysOfWeekDisabled)) {
  6571. this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
  6572. }
  6573. this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled,
  6574. function(d) {
  6575. return parseInt(d, 10);
  6576. });
  6577. this.update();
  6578. this.updateNavArrows();
  6579. },
  6580. setMinutesDisabled: function(minutesDisabled) {
  6581. this.minutesDisabled = minutesDisabled || [];
  6582. if (!$.isArray(this.minutesDisabled)) {
  6583. this.minutesDisabled = this.minutesDisabled.split(/,\s*/);
  6584. }
  6585. this.minutesDisabled = $.map(this.minutesDisabled,
  6586. function(d) {
  6587. return parseInt(d, 10);
  6588. });
  6589. this.update();
  6590. this.updateNavArrows();
  6591. },
  6592. setHoursDisabled: function(hoursDisabled) {
  6593. this.hoursDisabled = hoursDisabled || [];
  6594. if (!$.isArray(this.hoursDisabled)) {
  6595. this.hoursDisabled = this.hoursDisabled.split(/,\s*/);
  6596. }
  6597. this.hoursDisabled = $.map(this.hoursDisabled,
  6598. function(d) {
  6599. return parseInt(d, 10);
  6600. });
  6601. this.update();
  6602. this.updateNavArrows();
  6603. },
  6604. place: function() {
  6605. if (this.isInline) return;
  6606. if (!this.zIndex) {
  6607. var index_highest = 0;
  6608. $('div').each(function() {
  6609. var index_current = parseInt($(this).css('zIndex'), 10);
  6610. if (index_current > index_highest) {
  6611. index_highest = index_current;
  6612. }
  6613. });
  6614. this.zIndex = index_highest + 10;
  6615. }
  6616. var offset, top, left, containerOffset;
  6617. if (this.container instanceof $) {
  6618. containerOffset = this.container.offset();
  6619. } else {
  6620. containerOffset = $(this.container).offset();
  6621. }
  6622. if (this.component) {
  6623. offset = this.component.offset();
  6624. left = offset.left;
  6625. if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {
  6626. left += this.component.outerWidth() - this.picker.outerWidth();
  6627. }
  6628. } else {
  6629. offset = this.element.offset();
  6630. left = offset.left;
  6631. if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {
  6632. left += this.element.outerWidth() - this.picker.outerWidth();
  6633. }
  6634. }
  6635. var bodyWidth = document.body.clientWidth || window.innerWidth;
  6636. if (left + 220 > bodyWidth) {
  6637. left = bodyWidth - 220;
  6638. }
  6639. if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {
  6640. top = offset.top - this.picker.outerHeight();
  6641. } else {
  6642. top = offset.top + this.height;
  6643. }
  6644. top = top - containerOffset.top;
  6645. left = left - containerOffset.left;
  6646. this.picker.css({
  6647. top: top,
  6648. left: left,
  6649. zIndex: this.zIndex
  6650. });
  6651. },
  6652. update: function() {
  6653. var date, fromArgs = false;
  6654. if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
  6655. date = arguments[0];
  6656. fromArgs = true;
  6657. } else {
  6658. date = (this.isInput ? this.element.val() : this.element.find('input').val()) || this.element.data('date') || this.initialDate;
  6659. if (typeof date == 'string' || date instanceof String) {
  6660. date = date.replace(/^\s+|\s+$/g, '');
  6661. }
  6662. }
  6663. if (!date) {
  6664. date = new Date();
  6665. fromArgs = false;
  6666. }
  6667. this.date = DPGlobal.parseDate(date, this.format, this.language, this.formatType, this.timezone);
  6668. if (fromArgs) this.setValue();
  6669. if (this.date < this.startDate) {
  6670. this.viewDate = new Date(this.startDate);
  6671. } else if (this.date > this.endDate) {
  6672. this.viewDate = new Date(this.endDate);
  6673. } else {
  6674. this.viewDate = new Date(this.date);
  6675. }
  6676. this.fill();
  6677. },
  6678. fillDow: function() {
  6679. var dowCnt = this.weekStart,
  6680. html = '<tr>';
  6681. while (dowCnt < this.weekStart + 7) {
  6682. html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>';
  6683. }
  6684. html += '</tr>';
  6685. this.picker.find('.datetimepicker-days thead').append(html);
  6686. },
  6687. fillMonths: function() {
  6688. var html = '',
  6689. i = 0;
  6690. while (i < 12) {
  6691. html += '<span class="month">' + dates[this.language].monthsShort[i++] + '</span>';
  6692. }
  6693. this.picker.find('.datetimepicker-months td').html(html);
  6694. },
  6695. fill: function() {
  6696. if (this.date == null || this.viewDate == null) {
  6697. return;
  6698. }
  6699. var d = new Date(this.viewDate),
  6700. year = d.getUTCFullYear(),
  6701. month = d.getUTCMonth(),
  6702. dayMonth = d.getUTCDate(),
  6703. hours = d.getUTCHours(),
  6704. minutes = d.getUTCMinutes(),
  6705. startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
  6706. startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
  6707. endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
  6708. endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() + 1 : Infinity,
  6709. currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
  6710. today = new Date();
  6711. this.setTitle('.datetimepicker-days', dates[this.language].months[month] + ' ' + year);
  6712. if (this.formatViewType == 'time') {
  6713. var formatted = this.getFormattedDate();
  6714. this.setTitle('.datetimepicker-hours', formatted);
  6715. this.setTitle('.datetimepicker-minutes', formatted);
  6716. } else {
  6717. this.setTitle('.datetimepicker-hours', dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
  6718. this.setTitle('.datetimepicker-minutes', dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
  6719. }
  6720. this.picker.find('tfoot th.today').text(dates[this.language].today || dates['en'].today).toggle(this.todayBtn !== false);
  6721. this.picker.find('tfoot th.clear').text(dates[this.language].clear || dates['en'].clear).toggle(this.clearBtn !== false);
  6722. this.updateNavArrows();
  6723. this.fillMonths();
  6724. /*var prevMonth = UTCDate(year, month, 0,0,0,0,0);
  6725. prevMonth.setUTCDate(prevMonth.getDate() - (prevMonth.getUTCDay() - this.weekStart + 7)%7);*/
  6726. var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
  6727. day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
  6728. prevMonth.setUTCDate(day);
  6729. prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
  6730. var nextMonth = new Date(prevMonth);
  6731. nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
  6732. nextMonth = nextMonth.valueOf();
  6733. var html = [];
  6734. var clsName;
  6735. while (prevMonth.valueOf() < nextMonth) {
  6736. if (prevMonth.getUTCDay() == this.weekStart) {
  6737. html.push('<tr>');
  6738. }
  6739. clsName = '';
  6740. if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
  6741. clsName += ' old';
  6742. } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
  6743. clsName += ' new';
  6744. }
  6745. // Compare internal UTC date with local today, not UTC today
  6746. if (this.todayHighlight && prevMonth.getUTCFullYear() == today.getFullYear() && prevMonth.getUTCMonth() == today.getMonth() && prevMonth.getUTCDate() == today.getDate()) {
  6747. clsName += ' today';
  6748. }
  6749. if (prevMonth.valueOf() == currentDate) {
  6750. clsName += ' active';
  6751. }
  6752. if ((prevMonth.valueOf() + 86400000) <= this.startDate || prevMonth.valueOf() > this.endDate || $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1 || $.inArray(prevMonth.toDateString(), this.datesDisabled) !== -1) {
  6753. clsName += ' disabled';
  6754. }
  6755. html.push('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + '</td>');
  6756. if (prevMonth.getUTCDay() == this.weekEnd) {
  6757. html.push('</tr>');
  6758. }
  6759. prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
  6760. }
  6761. this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
  6762. html = [];
  6763. var txt = '',
  6764. meridian = '',
  6765. meridianOld = '';
  6766. var hoursDisabled = this.hoursDisabled || [];
  6767. for (var i = 0; i < 24; i++) {
  6768. if (hoursDisabled.indexOf(i) !== -1) continue;
  6769. var actual = UTCDate(year, month, dayMonth, i);
  6770. clsName = '';
  6771. // We want the previous hour for the startDate
  6772. if ((actual.valueOf() + 3600000) <= this.startDate || actual.valueOf() > this.endDate) {
  6773. clsName += ' disabled';
  6774. } else if (hours == i) {
  6775. clsName += ' active';
  6776. }
  6777. if (this.showMeridian && dates[this.language].meridiem.length == 2) {
  6778. meridian = (i < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
  6779. if (meridian != meridianOld) {
  6780. if (meridianOld != '') {
  6781. html.push('</fieldset>');
  6782. }
  6783. html.push('<fieldset class="hour"><legend>' + meridian.toUpperCase() + '</legend>');
  6784. }
  6785. meridianOld = meridian;
  6786. txt = (i % 12 ? i % 12 : 12);
  6787. html.push('<span class="hour' + clsName + ' hour_' + (i < 12 ? 'am': 'pm') + '">' + txt + '</span>');
  6788. if (i == 23) {
  6789. html.push('</fieldset>');
  6790. }
  6791. } else {
  6792. txt = i + ':00';
  6793. html.push('<span class="hour' + clsName + '">' + txt + '</span>');
  6794. }
  6795. }
  6796. this.picker.find('.datetimepicker-hours td').html(html.join(''));
  6797. html = [];
  6798. txt = '',
  6799. meridian = '',
  6800. meridianOld = '';
  6801. var minutesDisabled = this.minutesDisabled || [];
  6802. for (var i = 0; i < 60; i += this.minuteStep) {
  6803. if (minutesDisabled.indexOf(i) !== -1) continue;
  6804. var actual = UTCDate(year, month, dayMonth, hours, i, 0);
  6805. clsName = '';
  6806. if (actual.valueOf() < this.startDate || actual.valueOf() > this.endDate) {
  6807. clsName += ' disabled';
  6808. } else if (Math.floor(minutes / this.minuteStep) == Math.floor(i / this.minuteStep)) {
  6809. clsName += ' active';
  6810. }
  6811. if (this.showMeridian && dates[this.language].meridiem.length == 2) {
  6812. meridian = (hours < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
  6813. if (meridian != meridianOld) {
  6814. if (meridianOld != '') {
  6815. html.push('</fieldset>');
  6816. }
  6817. html.push('<fieldset class="minute"><legend>' + meridian.toUpperCase() + '</legend>');
  6818. }
  6819. meridianOld = meridian;
  6820. txt = (hours % 12 ? hours % 12 : 12);
  6821. //html.push('<span class="minute'+clsName+' minute_'+(hours<12?'am':'pm')+'">'+txt+'</span>');
  6822. html.push('<span class="minute' + clsName + '">' + txt + ':' + (i < 10 ? '0' + i: i) + '</span>');
  6823. if (i == 59) {
  6824. html.push('</fieldset>');
  6825. }
  6826. } else {
  6827. txt = i + ':00';
  6828. //html.push('<span class="hour'+clsName+'">'+txt+'</span>');
  6829. html.push('<span class="minute' + clsName + '">' + hours + ':' + (i < 10 ? '0' + i: i) + '</span>');
  6830. }
  6831. }
  6832. this.picker.find('.datetimepicker-minutes td').html(html.join(''));
  6833. var currentYear = this.date.getUTCFullYear();
  6834. var months = this.setTitle('.datetimepicker-months', year).end().find('span').removeClass('active');
  6835. if (currentYear == year) {
  6836. // getUTCMonths() returns 0 based, and we need to select the next one
  6837. // To cater bootstrap 2 we don't need to select the next one
  6838. var offset = months.length - 12;
  6839. months.eq(this.date.getUTCMonth() + offset).addClass('active');
  6840. }
  6841. if (year < startYear || year > endYear) {
  6842. months.addClass('disabled');
  6843. }
  6844. if (year == startYear) {
  6845. months.slice(0, startMonth).addClass('disabled');
  6846. }
  6847. if (year == endYear) {
  6848. months.slice(endMonth).addClass('disabled');
  6849. }
  6850. html = '';
  6851. year = parseInt(year / 10, 10) * 10;
  6852. var yearCont = this.setTitle('.datetimepicker-years', year + '-' + (year + 9)).end().find('td');
  6853. year -= 1;
  6854. for (var i = -1; i < 11; i++) {
  6855. html += '<span class="year' + (i == -1 || i == 10 ? ' old': '') + (currentYear == year ? ' active': '') + (year < startYear || year > endYear ? ' disabled': '') + '">' + year + '</span>';
  6856. year += 1;
  6857. }
  6858. yearCont.html(html);
  6859. this.place();
  6860. },
  6861. updateNavArrows: function() {
  6862. var d = new Date(this.viewDate),
  6863. year = d.getUTCFullYear(),
  6864. month = d.getUTCMonth(),
  6865. day = d.getUTCDate(),
  6866. hour = d.getUTCHours();
  6867. switch (this.viewMode) {
  6868. case 0:
  6869. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth() && day <= this.startDate.getUTCDate() && hour <= this.startDate.getUTCHours()) {
  6870. this.picker.find('.prev').css({
  6871. visibility: 'hidden'
  6872. });
  6873. } else {
  6874. this.picker.find('.prev').css({
  6875. visibility: 'visible'
  6876. });
  6877. }
  6878. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth() && day >= this.endDate.getUTCDate() && hour >= this.endDate.getUTCHours()) {
  6879. this.picker.find('.next').css({
  6880. visibility: 'hidden'
  6881. });
  6882. } else {
  6883. this.picker.find('.next').css({
  6884. visibility: 'visible'
  6885. });
  6886. }
  6887. break;
  6888. case 1:
  6889. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth() && day <= this.startDate.getUTCDate()) {
  6890. this.picker.find('.prev').css({
  6891. visibility: 'hidden'
  6892. });
  6893. } else {
  6894. this.picker.find('.prev').css({
  6895. visibility: 'visible'
  6896. });
  6897. }
  6898. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth() && day >= this.endDate.getUTCDate()) {
  6899. this.picker.find('.next').css({
  6900. visibility: 'hidden'
  6901. });
  6902. } else {
  6903. this.picker.find('.next').css({
  6904. visibility: 'visible'
  6905. });
  6906. }
  6907. break;
  6908. case 2:
  6909. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
  6910. this.picker.find('.prev').css({
  6911. visibility: 'hidden'
  6912. });
  6913. } else {
  6914. this.picker.find('.prev').css({
  6915. visibility: 'visible'
  6916. });
  6917. }
  6918. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
  6919. this.picker.find('.next').css({
  6920. visibility: 'hidden'
  6921. });
  6922. } else {
  6923. this.picker.find('.next').css({
  6924. visibility: 'visible'
  6925. });
  6926. }
  6927. break;
  6928. case 3:
  6929. case 4:
  6930. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
  6931. this.picker.find('.prev').css({
  6932. visibility: 'hidden'
  6933. });
  6934. } else {
  6935. this.picker.find('.prev').css({
  6936. visibility: 'visible'
  6937. });
  6938. }
  6939. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
  6940. this.picker.find('.next').css({
  6941. visibility: 'hidden'
  6942. });
  6943. } else {
  6944. this.picker.find('.next').css({
  6945. visibility: 'visible'
  6946. });
  6947. }
  6948. break;
  6949. }
  6950. },
  6951. mousewheel: function(e) {
  6952. e.preventDefault();
  6953. e.stopPropagation();
  6954. if (this.wheelPause) {
  6955. return;
  6956. }
  6957. this.wheelPause = true;
  6958. var originalEvent = e.originalEvent;
  6959. var delta = originalEvent.wheelDelta;
  6960. var mode = delta > 0 ? 1 : (delta === 0) ? 0 : -1;
  6961. if (this.wheelViewModeNavigationInverseDirection) {
  6962. mode = -mode;
  6963. }
  6964. this.showMode(mode);
  6965. setTimeout($.proxy(function() {
  6966. this.wheelPause = false
  6967. },
  6968. this), this.wheelViewModeNavigationDelay);
  6969. },
  6970. click: function(e) {
  6971. e.stopPropagation();
  6972. e.preventDefault();
  6973. var target = $(e.target).closest('span, td, th, legend');
  6974. if (target.is('.' + this.icontype)) {
  6975. target = $(target).parent().closest('span, td, th, legend');
  6976. }
  6977. if (target.length == 1) {
  6978. if (target.is('.disabled')) {
  6979. this.element.trigger({
  6980. type: 'outOfRange',
  6981. date: this.viewDate,
  6982. startDate: this.startDate,
  6983. endDate: this.endDate
  6984. });
  6985. return;
  6986. }
  6987. switch (target[0].nodeName.toLowerCase()) {
  6988. case 'th':
  6989. switch (target[0].className) {
  6990. case 'switch':
  6991. this.showMode(1);
  6992. break;
  6993. case 'prev':
  6994. case 'next':
  6995. var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
  6996. switch (this.viewMode) {
  6997. case 0:
  6998. this.viewDate = this.moveHour(this.viewDate, dir);
  6999. break;
  7000. case 1:
  7001. this.viewDate = this.moveDate(this.viewDate, dir);
  7002. break;
  7003. case 2:
  7004. this.viewDate = this.moveMonth(this.viewDate, dir);
  7005. break;
  7006. case 3:
  7007. case 4:
  7008. this.viewDate = this.moveYear(this.viewDate, dir);
  7009. break;
  7010. }
  7011. this.fill();
  7012. this.element.trigger({
  7013. type: target[0].className + ':' + this.convertViewModeText(this.viewMode),
  7014. date: this.viewDate,
  7015. startDate: this.startDate,
  7016. endDate: this.endDate
  7017. });
  7018. break;
  7019. case 'clear':
  7020. this.reset();
  7021. if (this.autoclose) {
  7022. this.hide();
  7023. }
  7024. break;
  7025. case 'today':
  7026. var date = new Date();
  7027. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
  7028. // Respect startDate and endDate.
  7029. if (date < this.startDate) date = this.startDate;
  7030. else if (date > this.endDate) date = this.endDate;
  7031. this.viewMode = this.startViewMode;
  7032. this.showMode(0);
  7033. this._setDate(date);
  7034. this.fill();
  7035. if (this.autoclose) {
  7036. this.hide();
  7037. }
  7038. break;
  7039. }
  7040. break;
  7041. case 'span':
  7042. if (!target.is('.disabled')) {
  7043. var year = this.viewDate.getUTCFullYear(),
  7044. month = this.viewDate.getUTCMonth(),
  7045. day = this.viewDate.getUTCDate(),
  7046. hours = this.viewDate.getUTCHours(),
  7047. minutes = this.viewDate.getUTCMinutes(),
  7048. seconds = this.viewDate.getUTCSeconds();
  7049. if (target.is('.month')) {
  7050. this.viewDate.setUTCDate(1);
  7051. month = target.parent().find('span').index(target);
  7052. day = this.viewDate.getUTCDate();
  7053. this.viewDate.setUTCMonth(month);
  7054. this.element.trigger({
  7055. type: 'changeMonth',
  7056. date: this.viewDate
  7057. });
  7058. if (this.viewSelect >= 3) {
  7059. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7060. }
  7061. } else if (target.is('.year')) {
  7062. this.viewDate.setUTCDate(1);
  7063. year = parseInt(target.text(), 10) || 0;
  7064. this.viewDate.setUTCFullYear(year);
  7065. this.element.trigger({
  7066. type: 'changeYear',
  7067. date: this.viewDate
  7068. });
  7069. if (this.viewSelect >= 4) {
  7070. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7071. }
  7072. } else if (target.is('.hour')) {
  7073. hours = parseInt(target.text(), 10) || 0;
  7074. if (target.hasClass('hour_am') || target.hasClass('hour_pm')) {
  7075. if (hours == 12 && target.hasClass('hour_am')) {
  7076. hours = 0;
  7077. } else if (hours != 12 && target.hasClass('hour_pm')) {
  7078. hours += 12;
  7079. }
  7080. }
  7081. this.viewDate.setUTCHours(hours);
  7082. this.element.trigger({
  7083. type: 'changeHour',
  7084. date: this.viewDate
  7085. });
  7086. if (this.viewSelect >= 1) {
  7087. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7088. }
  7089. } else if (target.is('.minute')) {
  7090. minutes = parseInt(target.text().substr(target.text().indexOf(':') + 1), 10) || 0;
  7091. this.viewDate.setUTCMinutes(minutes);
  7092. this.element.trigger({
  7093. type: 'changeMinute',
  7094. date: this.viewDate
  7095. });
  7096. if (this.viewSelect >= 0) {
  7097. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7098. }
  7099. }
  7100. if (this.viewMode != 0) {
  7101. var oldViewMode = this.viewMode;
  7102. this.showMode( - 1);
  7103. this.fill();
  7104. if (oldViewMode == this.viewMode && this.autoclose) {
  7105. this.hide();
  7106. }
  7107. } else {
  7108. this.fill();
  7109. if (this.autoclose) {
  7110. this.hide();
  7111. }
  7112. }
  7113. }
  7114. break;
  7115. case 'td':
  7116. if (target.is('.day') && !target.is('.disabled')) {
  7117. var day = parseInt(target.text(), 10) || 1;
  7118. var year = this.viewDate.getUTCFullYear(),
  7119. month = this.viewDate.getUTCMonth(),
  7120. hours = this.viewDate.getUTCHours(),
  7121. minutes = this.viewDate.getUTCMinutes(),
  7122. seconds = this.viewDate.getUTCSeconds();
  7123. if (target.is('.old')) {
  7124. if (month === 0) {
  7125. month = 11;
  7126. year -= 1;
  7127. } else {
  7128. month -= 1;
  7129. }
  7130. } else if (target.is('.new')) {
  7131. if (month == 11) {
  7132. month = 0;
  7133. year += 1;
  7134. } else {
  7135. month += 1;
  7136. }
  7137. }
  7138. this.viewDate.setUTCFullYear(year);
  7139. this.viewDate.setUTCMonth(month, day);
  7140. this.element.trigger({
  7141. type: 'changeDay',
  7142. date: this.viewDate
  7143. });
  7144. if (this.viewSelect >= 2) {
  7145. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7146. }
  7147. }
  7148. var oldViewMode = this.viewMode;
  7149. this.showMode( - 1);
  7150. this.fill();
  7151. if (oldViewMode == this.viewMode && this.autoclose) {
  7152. this.hide();
  7153. }
  7154. break;
  7155. }
  7156. }
  7157. },
  7158. _setDate: function(date, which) {
  7159. if (!which || which == 'date') this.date = date;
  7160. if (!which || which == 'view') this.viewDate = date;
  7161. this.fill();
  7162. this.setValue();
  7163. var element;
  7164. if (this.isInput) {
  7165. element = this.element;
  7166. } else if (this.component) {
  7167. element = this.element.find('input');
  7168. }
  7169. if (element) {
  7170. element.change();
  7171. if (this.autoclose && (!which || which == 'date')) {
  7172. //this.hide();
  7173. }
  7174. }
  7175. this.element.trigger({
  7176. type: 'changeDate',
  7177. date: this.getDate()
  7178. });
  7179. if (date == null) this.date = this.viewDate;
  7180. },
  7181. moveMinute: function(date, dir) {
  7182. if (!dir) return date;
  7183. var new_date = new Date(date.valueOf());
  7184. //dir = dir > 0 ? 1 : -1;
  7185. new_date.setUTCMinutes(new_date.getUTCMinutes() + (dir * this.minuteStep));
  7186. return new_date;
  7187. },
  7188. moveHour: function(date, dir) {
  7189. if (!dir) return date;
  7190. var new_date = new Date(date.valueOf());
  7191. //dir = dir > 0 ? 1 : -1;
  7192. new_date.setUTCHours(new_date.getUTCHours() + dir);
  7193. return new_date;
  7194. },
  7195. moveDate: function(date, dir) {
  7196. if (!dir) return date;
  7197. var new_date = new Date(date.valueOf());
  7198. //dir = dir > 0 ? 1 : -1;
  7199. new_date.setUTCDate(new_date.getUTCDate() + dir);
  7200. return new_date;
  7201. },
  7202. moveMonth: function(date, dir) {
  7203. if (!dir) return date;
  7204. var new_date = new Date(date.valueOf()),
  7205. day = new_date.getUTCDate(),
  7206. month = new_date.getUTCMonth(),
  7207. mag = Math.abs(dir),
  7208. new_month,
  7209. test;
  7210. dir = dir > 0 ? 1 : -1;
  7211. if (mag == 1) {
  7212. test = dir == -1
  7213. // If going back one month, make sure month is not current month
  7214. // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
  7215. ?
  7216. function() {
  7217. return new_date.getUTCMonth() == month;
  7218. }
  7219. // If going forward one month, make sure month is as expected
  7220. // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
  7221. : function() {
  7222. return new_date.getUTCMonth() != new_month;
  7223. };
  7224. new_month = month + dir;
  7225. new_date.setUTCMonth(new_month);
  7226. // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
  7227. if (new_month < 0 || new_month > 11) new_month = (new_month + 12) % 12;
  7228. } else {
  7229. // For magnitudes >1, move one month at a time...
  7230. for (var i = 0; i < mag; i++)
  7231. // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
  7232. new_date = this.moveMonth(new_date, dir);
  7233. // ...then reset the day, keeping it in the new month
  7234. new_month = new_date.getUTCMonth();
  7235. new_date.setUTCDate(day);
  7236. test = function() {
  7237. return new_month != new_date.getUTCMonth();
  7238. };
  7239. }
  7240. // Common date-resetting loop -- if date is beyond end of month, make it
  7241. // end of month
  7242. while (test()) {
  7243. new_date.setUTCDate(--day);
  7244. new_date.setUTCMonth(new_month);
  7245. }
  7246. return new_date;
  7247. },
  7248. moveYear: function(date, dir) {
  7249. return this.moveMonth(date, dir * 12);
  7250. },
  7251. dateWithinRange: function(date) {
  7252. return date >= this.startDate && date <= this.endDate;
  7253. },
  7254. keydown: function(e) {
  7255. if (this.picker.is(':not(:visible)')) {
  7256. if (e.keyCode == 27) // allow escape to hide and re-show picker
  7257. this.show();
  7258. return;
  7259. }
  7260. var dateChanged = false,
  7261. dir, day, month, newDate, newViewDate;
  7262. switch (e.keyCode) {
  7263. case 27:
  7264. // escape
  7265. this.hide();
  7266. e.preventDefault();
  7267. break;
  7268. case 37:
  7269. // left
  7270. case 39:
  7271. // right
  7272. if (!this.keyboardNavigation) break;
  7273. dir = e.keyCode == 37 ? -1 : 1;
  7274. viewMode = this.viewMode;
  7275. if (e.ctrlKey) {
  7276. viewMode += 2;
  7277. } else if (e.shiftKey) {
  7278. viewMode += 1;
  7279. }
  7280. if (viewMode == 4) {
  7281. newDate = this.moveYear(this.date, dir);
  7282. newViewDate = this.moveYear(this.viewDate, dir);
  7283. } else if (viewMode == 3) {
  7284. newDate = this.moveMonth(this.date, dir);
  7285. newViewDate = this.moveMonth(this.viewDate, dir);
  7286. } else if (viewMode == 2) {
  7287. newDate = this.moveDate(this.date, dir);
  7288. newViewDate = this.moveDate(this.viewDate, dir);
  7289. } else if (viewMode == 1) {
  7290. newDate = this.moveHour(this.date, dir);
  7291. newViewDate = this.moveHour(this.viewDate, dir);
  7292. } else if (viewMode == 0) {
  7293. newDate = this.moveMinute(this.date, dir);
  7294. newViewDate = this.moveMinute(this.viewDate, dir);
  7295. }
  7296. if (this.dateWithinRange(newDate)) {
  7297. this.date = newDate;
  7298. this.viewDate = newViewDate;
  7299. this.setValue();
  7300. this.update();
  7301. e.preventDefault();
  7302. dateChanged = true;
  7303. }
  7304. break;
  7305. case 38:
  7306. // up
  7307. case 40:
  7308. // down
  7309. if (!this.keyboardNavigation) break;
  7310. dir = e.keyCode == 38 ? -1 : 1;
  7311. viewMode = this.viewMode;
  7312. if (e.ctrlKey) {
  7313. viewMode += 2;
  7314. } else if (e.shiftKey) {
  7315. viewMode += 1;
  7316. }
  7317. if (viewMode == 4) {
  7318. newDate = this.moveYear(this.date, dir);
  7319. newViewDate = this.moveYear(this.viewDate, dir);
  7320. } else if (viewMode == 3) {
  7321. newDate = this.moveMonth(this.date, dir);
  7322. newViewDate = this.moveMonth(this.viewDate, dir);
  7323. } else if (viewMode == 2) {
  7324. newDate = this.moveDate(this.date, dir * 7);
  7325. newViewDate = this.moveDate(this.viewDate, dir * 7);
  7326. } else if (viewMode == 1) {
  7327. if (this.showMeridian) {
  7328. newDate = this.moveHour(this.date, dir * 6);
  7329. newViewDate = this.moveHour(this.viewDate, dir * 6);
  7330. } else {
  7331. newDate = this.moveHour(this.date, dir * 4);
  7332. newViewDate = this.moveHour(this.viewDate, dir * 4);
  7333. }
  7334. } else if (viewMode == 0) {
  7335. newDate = this.moveMinute(this.date, dir * 4);
  7336. newViewDate = this.moveMinute(this.viewDate, dir * 4);
  7337. }
  7338. if (this.dateWithinRange(newDate)) {
  7339. this.date = newDate;
  7340. this.viewDate = newViewDate;
  7341. this.setValue();
  7342. this.update();
  7343. e.preventDefault();
  7344. dateChanged = true;
  7345. }
  7346. break;
  7347. case 13:
  7348. // enter
  7349. if (this.viewMode != 0) {
  7350. var oldViewMode = this.viewMode;
  7351. this.showMode( - 1);
  7352. this.fill();
  7353. if (oldViewMode == this.viewMode && this.autoclose) {
  7354. this.hide();
  7355. }
  7356. } else {
  7357. this.fill();
  7358. if (this.autoclose) {
  7359. this.hide();
  7360. }
  7361. }
  7362. e.preventDefault();
  7363. break;
  7364. case 9:
  7365. // tab
  7366. this.hide();
  7367. break;
  7368. }
  7369. if (dateChanged) {
  7370. var element;
  7371. if (this.isInput) {
  7372. element = this.element;
  7373. } else if (this.component) {
  7374. element = this.element.find('input');
  7375. }
  7376. if (element) {
  7377. element.change();
  7378. }
  7379. this.element.trigger({
  7380. type: 'changeDate',
  7381. date: this.getDate()
  7382. });
  7383. }
  7384. },
  7385. showMode: function(dir) {
  7386. if (dir) {
  7387. var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
  7388. if (newViewMode >= this.minView && newViewMode <= this.maxView) {
  7389. this.element.trigger({
  7390. type: 'changeMode',
  7391. date: this.viewDate,
  7392. oldViewMode: this.viewMode,
  7393. newViewMode: newViewMode
  7394. });
  7395. this.viewMode = newViewMode;
  7396. }
  7397. }
  7398. /*
  7399. vitalets: fixing bug of very special conditions:
  7400. jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
  7401. Method show() does not set display css correctly and datetimepicker is not shown.
  7402. Changed to .css('display', 'block') solve the problem.
  7403. See https://github.com/vitalets/x-editable/issues/37
  7404. In jquery 1.7.2+ everything works fine.
  7405. */
  7406. //this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
  7407. this.picker.find('>div').hide().filter('.datetimepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
  7408. this.updateNavArrows();
  7409. },
  7410. reset: function(e) {
  7411. this._setDate(null, 'date');
  7412. },
  7413. convertViewModeText: function(viewMode) {
  7414. switch (viewMode) {
  7415. case 4:
  7416. return 'decade';
  7417. case 3:
  7418. return 'year';
  7419. case 2:
  7420. return 'month';
  7421. case 1:
  7422. return 'day';
  7423. case 0:
  7424. return 'hour';
  7425. }
  7426. }
  7427. };
  7428. var old = $.fn.datetimepicker;
  7429. $.fn.datetimepicker = function(option) {
  7430. var args = Array.apply(null, arguments);
  7431. args.shift();
  7432. var internal_return;
  7433. this.each(function() {
  7434. var $this = $(this),
  7435. data = $this.data('datetimepicker'),
  7436. options = typeof option == 'object' && option;
  7437. if (!data) {
  7438. $this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({},
  7439. $.fn.datetimepicker.defaults, options))));
  7440. }
  7441. if (typeof option == 'string' && typeof data[option] == 'function') {
  7442. internal_return = data[option].apply(data, args);
  7443. if (internal_return !== undefined) {
  7444. return false;
  7445. }
  7446. }
  7447. });
  7448. if (internal_return !== undefined) return internal_return;
  7449. else return this;
  7450. };
  7451. $.fn.datetimepicker.defaults = {};
  7452. $.fn.datetimepicker.Constructor = Datetimepicker;
  7453. var dates = $.fn.datetimepicker.dates = {
  7454. en: {
  7455. days: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'],
  7456. daysShort: ['日', '一', '二', '三', '四', '五', '六', '日'],
  7457. daysMin: ['日', '一', '二', '三', '四', '五', '六', '日'],
  7458. months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
  7459. monthsShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  7460. meridiem: ['上午', '下午'],
  7461. suffix: ['st', 'nd', 'rd', 'th'],
  7462. today: '今天',
  7463. clear: '清空'
  7464. }
  7465. };
  7466. var DPGlobal = {
  7467. modes: [{
  7468. clsName: 'minutes',
  7469. navFnc: 'Hours',
  7470. navStep: 1
  7471. },
  7472. {
  7473. clsName: 'hours',
  7474. navFnc: 'Date',
  7475. navStep: 1
  7476. },
  7477. {
  7478. clsName: 'days',
  7479. navFnc: 'Month',
  7480. navStep: 1
  7481. },
  7482. {
  7483. clsName: 'months',
  7484. navFnc: 'FullYear',
  7485. navStep: 1
  7486. },
  7487. {
  7488. clsName: 'years',
  7489. navFnc: 'FullYear',
  7490. navStep: 10
  7491. }],
  7492. isLeapYear: function(year) {
  7493. return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
  7494. },
  7495. getDaysInMonth: function(year, month) {
  7496. return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
  7497. },
  7498. getDefaultFormat: function(type, field) {
  7499. if (type == 'standard') {
  7500. if (field == 'input') return 'yyyy-mm-dd hh:ii';
  7501. else return 'yyyy-mm-dd hh:ii:ss';
  7502. } else if (type == 'php') {
  7503. if (field == 'input') return 'Y-m-d H:i';
  7504. else return 'Y-m-d H:i:s';
  7505. } else {
  7506. throw new Error('Invalid format type.');
  7507. }
  7508. },
  7509. validParts: function(type) {
  7510. if (type == 'standard') {
  7511. return /t|hh?|HH?|p|P|z|Z|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
  7512. } else if (type == 'php') {
  7513. return /[dDjlNwzFmMnStyYaABgGhHis]/g;
  7514. } else {
  7515. throw new Error('Invalid format type.');
  7516. }
  7517. },
  7518. nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
  7519. parseFormat: function(format, type) {
  7520. // IE treats \0 as a string end in inputs (truncating the value),
  7521. // so it's a bad format delimiter, anyway
  7522. var separators = format.replace(this.validParts(type), '\0').split('\0'),
  7523. parts = format.match(this.validParts(type));
  7524. if (!separators || !separators.length || !parts || parts.length == 0) {
  7525. throw new Error('Invalid date format.');
  7526. }
  7527. return {
  7528. separators: separators,
  7529. parts: parts
  7530. };
  7531. },
  7532. parseDate: function(date, format, language, type, timezone) {
  7533. if (date instanceof Date) {
  7534. var dateUTC = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
  7535. dateUTC.setMilliseconds(0);
  7536. return dateUTC;
  7537. }
  7538. if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
  7539. format = this.parseFormat('yyyy-mm-dd', type);
  7540. }
  7541. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
  7542. format = this.parseFormat('yyyy-mm-dd hh:ii', type);
  7543. }
  7544. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
  7545. format = this.parseFormat('yyyy-mm-dd hh:ii:ss', type);
  7546. }
  7547. if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
  7548. var part_re = /([-+]\d+)([dmwy])/,
  7549. parts = date.match(/([-+]\d+)([dmwy])/g),
  7550. part,
  7551. dir;
  7552. date = new Date();
  7553. for (var i = 0; i < parts.length; i++) {
  7554. part = part_re.exec(parts[i]);
  7555. dir = parseInt(part[1]);
  7556. switch (part[2]) {
  7557. case 'd':
  7558. date.setUTCDate(date.getUTCDate() + dir);
  7559. break;
  7560. case 'm':
  7561. date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
  7562. break;
  7563. case 'w':
  7564. date.setUTCDate(date.getUTCDate() + dir * 7);
  7565. break;
  7566. case 'y':
  7567. date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
  7568. break;
  7569. }
  7570. }
  7571. return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), 0);
  7572. }
  7573. var parts = date && date.toString().match(this.nonpunctuation) || [],
  7574. date = new Date(0, 0, 0, 0, 0, 0, 0),
  7575. parsed = {},
  7576. setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'D', 'DD', 'd', 'dd', 'H', 'HH', 'p', 'P', 'z', 'Z'],
  7577. setters_map = {
  7578. hh: function(d, v) {
  7579. return d.setUTCHours(v);
  7580. },
  7581. h: function(d, v) {
  7582. return d.setUTCHours(v);
  7583. },
  7584. HH: function(d, v) {
  7585. return d.setUTCHours(v == 12 ? 0 : v);
  7586. },
  7587. H: function(d, v) {
  7588. return d.setUTCHours(v == 12 ? 0 : v);
  7589. },
  7590. ii: function(d, v) {
  7591. return d.setUTCMinutes(v);
  7592. },
  7593. i: function(d, v) {
  7594. return d.setUTCMinutes(v);
  7595. },
  7596. ss: function(d, v) {
  7597. return d.setUTCSeconds(v);
  7598. },
  7599. s: function(d, v) {
  7600. return d.setUTCSeconds(v);
  7601. },
  7602. yyyy: function(d, v) {
  7603. return d.setUTCFullYear(v);
  7604. },
  7605. yy: function(d, v) {
  7606. return d.setUTCFullYear(2000 + v);
  7607. },
  7608. m: function(d, v) {
  7609. v -= 1;
  7610. while (v < 0) v += 12;
  7611. v %= 12;
  7612. d.setUTCMonth(v);
  7613. while (d.getUTCMonth() != v) if (isNaN(d.getUTCMonth())) return d;
  7614. else d.setUTCDate(d.getUTCDate() - 1);
  7615. return d;
  7616. },
  7617. d: function(d, v) {
  7618. return d.setUTCDate(v);
  7619. },
  7620. p: function(d, v) {
  7621. return d.setUTCHours(v == 1 ? d.getUTCHours() + 12 : d.getUTCHours());
  7622. },
  7623. z: function() {
  7624. return timezone
  7625. }
  7626. },
  7627. val,
  7628. filtered,
  7629. part;
  7630. setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
  7631. setters_map['dd'] = setters_map['d'];
  7632. setters_map['P'] = setters_map['p'];
  7633. setters_map['Z'] = setters_map['z'];
  7634. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
  7635. if (parts.length == format.parts.length) {
  7636. for (var i = 0,
  7637. cnt = format.parts.length; i < cnt; i++) {
  7638. val = parseInt(parts[i], 10);
  7639. part = format.parts[i];
  7640. if (isNaN(val)) {
  7641. switch (part) {
  7642. case 'MM':
  7643. filtered = $(dates[language].months).filter(function() {
  7644. var m = this.slice(0, parts[i].length),
  7645. p = parts[i].slice(0, m.length);
  7646. return m == p;
  7647. });
  7648. val = $.inArray(filtered[0], dates[language].months) + 1;
  7649. break;
  7650. case 'M':
  7651. filtered = $(dates[language].monthsShort).filter(function() {
  7652. var m = this.slice(0, parts[i].length),
  7653. p = parts[i].slice(0, m.length);
  7654. return m.toLowerCase() == p.toLowerCase();
  7655. });
  7656. val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
  7657. break;
  7658. case 'p':
  7659. case 'P':
  7660. val = $.inArray(parts[i].toLowerCase(), dates[language].meridiem);
  7661. break;
  7662. case 'z':
  7663. case 'Z':
  7664. timezone;
  7665. break;
  7666. }
  7667. }
  7668. parsed[part] = val;
  7669. }
  7670. for (var i = 0,
  7671. s; i < setters_order.length; i++) {
  7672. s = setters_order[i];
  7673. if (s in parsed && !isNaN(parsed[s])) setters_map[s](date, parsed[s])
  7674. }
  7675. }
  7676. return date;
  7677. },
  7678. formatDate: function(date, format, language, type, timezone) {
  7679. if (date == null) {
  7680. return '';
  7681. }
  7682. var val;
  7683. if (type == 'standard') {
  7684. val = {
  7685. t: date.getTime(),
  7686. // year
  7687. yy: date.getUTCFullYear().toString().substring(2),
  7688. yyyy: date.getUTCFullYear(),
  7689. // month
  7690. m: date.getUTCMonth() + 1,
  7691. M: dates[language].monthsShort[date.getUTCMonth()],
  7692. MM: dates[language].months[date.getUTCMonth()],
  7693. // day
  7694. d: date.getUTCDate(),
  7695. D: dates[language].daysShort[date.getUTCDay()],
  7696. DD: dates[language].days[date.getUTCDay()],
  7697. p: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
  7698. // hour
  7699. h: date.getUTCHours(),
  7700. // minute
  7701. i: date.getUTCMinutes(),
  7702. // second
  7703. s: date.getUTCSeconds(),
  7704. // timezone
  7705. z: timezone
  7706. };
  7707. if (dates[language].meridiem.length == 2) {
  7708. val.H = (val.h % 12 == 0 ? 12 : val.h % 12);
  7709. } else {
  7710. val.H = val.h;
  7711. }
  7712. val.HH = (val.H < 10 ? '0': '') + val.H;
  7713. val.P = val.p.toUpperCase();
  7714. val.Z = val.z;
  7715. val.hh = (val.h < 10 ? '0': '') + val.h;
  7716. val.ii = (val.i < 10 ? '0': '') + val.i;
  7717. val.ss = (val.s < 10 ? '0': '') + val.s;
  7718. val.dd = (val.d < 10 ? '0': '') + val.d;
  7719. val.mm = (val.m < 10 ? '0': '') + val.m;
  7720. } else if (type == 'php') {
  7721. // php format
  7722. val = {
  7723. // year
  7724. y: date.getUTCFullYear().toString().substring(2),
  7725. Y: date.getUTCFullYear(),
  7726. // month
  7727. F: dates[language].months[date.getUTCMonth()],
  7728. M: dates[language].monthsShort[date.getUTCMonth()],
  7729. n: date.getUTCMonth() + 1,
  7730. t: DPGlobal.getDaysInMonth(date.getUTCFullYear(), date.getUTCMonth()),
  7731. // day
  7732. j: date.getUTCDate(),
  7733. l: dates[language].days[date.getUTCDay()],
  7734. D: dates[language].daysShort[date.getUTCDay()],
  7735. w: date.getUTCDay(),
  7736. // 0 -> 6
  7737. N: (date.getUTCDay() == 0 ? 7 : date.getUTCDay()),
  7738. // 1 -> 7
  7739. S: (date.getUTCDate() % 10 <= dates[language].suffix.length ? dates[language].suffix[date.getUTCDate() % 10 - 1] : ''),
  7740. // hour
  7741. a: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
  7742. g: (date.getUTCHours() % 12 == 0 ? 12 : date.getUTCHours() % 12),
  7743. G: date.getUTCHours(),
  7744. // minute
  7745. i: date.getUTCMinutes(),
  7746. // second
  7747. s: date.getUTCSeconds()
  7748. };
  7749. val.m = (val.n < 10 ? '0': '') + val.n;
  7750. val.d = (val.j < 10 ? '0': '') + val.j;
  7751. val.A = val.a.toString().toUpperCase();
  7752. val.h = (val.g < 10 ? '0': '') + val.g;
  7753. val.H = (val.G < 10 ? '0': '') + val.G;
  7754. val.i = (val.i < 10 ? '0': '') + val.i;
  7755. val.s = (val.s < 10 ? '0': '') + val.s;
  7756. } else {
  7757. throw new Error('Invalid format type.');
  7758. }
  7759. var date = [],
  7760. seps = $.extend([], format.separators);
  7761. for (var i = 0,
  7762. cnt = format.parts.length; i < cnt; i++) {
  7763. if (seps.length) {
  7764. date.push(seps.shift());
  7765. }
  7766. date.push(val[format.parts[i]]);
  7767. }
  7768. if (seps.length) {
  7769. date.push(seps.shift());
  7770. }
  7771. return date.join('');
  7772. },
  7773. convertViewMode: function(viewMode) {
  7774. switch (viewMode) {
  7775. case 4:
  7776. case 'decade':
  7777. viewMode = 4;
  7778. break;
  7779. case 3:
  7780. case 'year':
  7781. viewMode = 3;
  7782. break;
  7783. case 2:
  7784. case 'month':
  7785. viewMode = 2;
  7786. break;
  7787. case 1:
  7788. case 'day':
  7789. viewMode = 1;
  7790. break;
  7791. case 0:
  7792. case 'hour':
  7793. viewMode = 0;
  7794. break;
  7795. }
  7796. return viewMode;
  7797. },
  7798. headTemplate: '<thead>' + '<tr>' + '<th class="prev"><i class="{iconType} {leftArrow}"/></th>' + '<th colspan="5" class="switch"></th>' + '<th class="next"><i class="{iconType} {rightArrow}"/></th>' + '</tr>' + '</thead>',
  7799. headTemplateV3: '<thead>' + '<tr>' + '<th class="prev"><span class="{iconType} {leftArrow}"></span> </th>' + '<th colspan="5" class="switch"></th>' + '<th class="next"><span class="{iconType} {rightArrow}"></span> </th>' + '</tr>' + '</thead>',
  7800. contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
  7801. footTemplate: '<tfoot>' + '<tr><th colspan="7" class="today"></th></tr>' + '<tr><th colspan="7" class="clear"></th></tr>' + '</tfoot>'
  7802. };
  7803. DPGlobal.template = '<div class="datetimepicker">' + '<div class="datetimepicker-minutes">' + '<table class=" table-condensed">' + DPGlobal.headTemplate + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-hours">' + '<table class=" table-condensed">' + DPGlobal.headTemplate + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-days">' + '<table class=" table-condensed">' + DPGlobal.headTemplate + '<tbody></tbody>' + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-months">' + '<table class="table-condensed">' + DPGlobal.headTemplate + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-years">' + '<table class="table-condensed">' + DPGlobal.headTemplate + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '</div>';
  7804. DPGlobal.templateV3 = '<div class="datetimepicker">' + '<div class="datetimepicker-minutes">' + '<table class=" table-condensed">' + DPGlobal.headTemplateV3 + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-hours">' + '<table class=" table-condensed">' + DPGlobal.headTemplateV3 + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-days">' + '<table class=" table-condensed">' + DPGlobal.headTemplateV3 + '<tbody></tbody>' + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-months">' + '<table class="table-condensed">' + DPGlobal.headTemplateV3 + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '<div class="datetimepicker-years">' + '<table class="table-condensed">' + DPGlobal.headTemplateV3 + DPGlobal.contTemplate + DPGlobal.footTemplate + '</table>' + '</div>' + '</div>';
  7805. $.fn.datetimepicker.DPGlobal = DPGlobal;
  7806. /* DATETIMEPICKER NO CONFLICT
  7807. * =================== */
  7808. $.fn.datetimepicker.noConflict = function() {
  7809. $.fn.datetimepicker = old;
  7810. return this;
  7811. };
  7812. /* DATETIMEPICKER DATA-API
  7813. * ================== */
  7814. $(document).on('focus.datetimepicker.data-api click.datetimepicker.data-api', '[data-provide="datetimepicker"]',
  7815. function(e) {
  7816. var $this = $(this);
  7817. if ($this.data('datetimepicker')) return;
  7818. e.preventDefault();
  7819. // component click requires us to explicitly show it
  7820. $this.datetimepicker('show');
  7821. });
  7822. $(function() {
  7823. $('[data-provide="datetimepicker-inline"]').datetimepicker();
  7824. });
  7825. }));
  7826. /* ============================================================
  7827. * Bootstrap.Switch v1.3 by Larentis Mattia @spiritualGuru
  7828. * http://www.larentis.eu/switch/
  7829. * ============================================================
  7830. * Licensed under the Apache License, Version 2.0
  7831. * http://www.apache.org/licenses/LICENSE-2.0
  7832. * ============================================================ */
  7833. !function($) {
  7834. "use strict";
  7835. $.fn['bootstrapSwitch'] = function(method) {
  7836. var methods = {
  7837. init: function() {
  7838. return this.each(function() {
  7839. var $element = $(this),
  7840. $div,
  7841. $switchLeft,
  7842. $switchRight,
  7843. $label,
  7844. myClasses = "",
  7845. classes = $element.attr('class'),
  7846. color,
  7847. moving,
  7848. onLabel = "ON",
  7849. offLabel = "OFF",
  7850. icon = false;
  7851. $.each(['size-MINI', 'size-S', 'size-L'],
  7852. function(i, el) {
  7853. if (classes.indexOf(el) >= 0) myClasses = el;
  7854. });
  7855. $element.addClass('has-switch');
  7856. if ($element.data('on') !== undefined) color = "switch-" + $element.data('on');
  7857. if ($element.data('on-label') !== undefined) onLabel = $element.data('on-label');
  7858. if ($element.data('off-label') !== undefined) offLabel = $element.data('off-label');
  7859. if ($element.data('icon') !== undefined) icon = $element.data('icon');
  7860. $switchLeft = $('<span>').addClass("switch-left").addClass(myClasses).addClass(color).html(onLabel);
  7861. color = '';
  7862. if ($element.data('off') !== undefined) color = "switch-" + $element.data('off');
  7863. $switchRight = $('<span>').addClass("switch-right").addClass(myClasses).addClass(color).html(offLabel);
  7864. $label = $('<label>').html("&nbsp;").addClass(myClasses).attr('for', $element.find('input').attr('id'));
  7865. if (icon) {
  7866. $label.html('<i class="icon icon-' + icon + '"></i>');
  7867. }
  7868. $div = $element.find(':checkbox').wrap($('<div>')).parent().data('animated', false);
  7869. if ($element.data('animated') !== false) $div.addClass('switch-animate').data('animated', true);
  7870. $div.append($switchLeft).append($label).append($switchRight);
  7871. $element.find('>div').addClass($element.find('input').is(':checked') ? 'switch-on': 'switch-off');
  7872. if ($element.find('input').is(':disabled')) $(this).addClass('deactivate');
  7873. var changeStatus = function($this) {
  7874. $this.siblings('label').trigger('mousedown').trigger('mouseup').trigger('click');
  7875. };
  7876. $element.on('keydown',
  7877. function(e) {
  7878. if (e.keyCode === 32) {
  7879. e.stopImmediatePropagation();
  7880. e.preventDefault();
  7881. changeStatus($(e.target).find('span:first'));
  7882. }
  7883. });
  7884. $switchLeft.on('click',
  7885. function(e) {
  7886. changeStatus($(this));
  7887. });
  7888. $switchRight.on('click',
  7889. function(e) {
  7890. changeStatus($(this));
  7891. });
  7892. $element.find('input').on('change',
  7893. function(e) {
  7894. var $this = $(this),
  7895. $element = $this.parent(),
  7896. thisState = $this.is(':checked'),
  7897. state = $element.is('.switch-off');
  7898. e.preventDefault();
  7899. $element.css('left', '');
  7900. if (state === thisState) {
  7901. if (thisState) $element.removeClass('switch-off').addClass('switch-on');
  7902. else $element.removeClass('switch-on').addClass('switch-off');
  7903. if ($element.data('animated') !== false) $element.addClass("switch-animate");
  7904. $element.parent().trigger('switch-change', {
  7905. 'el': $this,
  7906. 'value': thisState
  7907. })
  7908. }
  7909. });
  7910. $element.find('label').on('mousedown touchstart',
  7911. function(e) {
  7912. var $this = $(this);
  7913. moving = false;
  7914. e.preventDefault();
  7915. e.stopImmediatePropagation();
  7916. $this.closest('div').removeClass('switch-animate');
  7917. if ($this.closest('.has-switch').is('.deactivate')) $this.unbind('click');
  7918. else {
  7919. $this.on('mousemove touchmove',
  7920. function(e) {
  7921. var $element = $(this).closest('.switch'),
  7922. relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $element.offset().left,
  7923. percent = (relativeX / $element.width()) * 100,
  7924. left = 25,
  7925. right = 75;
  7926. moving = true;
  7927. if (percent < left) percent = left;
  7928. else if (percent > right) percent = right;
  7929. $element.find('>div').css('left', (percent - right) + "%")
  7930. });
  7931. $this.on('click touchend',
  7932. function(e) {
  7933. var $this = $(this),
  7934. $target = $(e.target),
  7935. $myCheckBox = $target.siblings('input');
  7936. e.stopImmediatePropagation();
  7937. e.preventDefault();
  7938. $this.unbind('mouseleave');
  7939. if (moving) $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
  7940. else $myCheckBox.prop("checked", !$myCheckBox.is(":checked"));
  7941. moving = false;
  7942. $myCheckBox.trigger('change');
  7943. });
  7944. $this.on('mouseleave',
  7945. function(e) {
  7946. var $this = $(this),
  7947. $myCheckBox = $this.siblings('input');
  7948. e.preventDefault();
  7949. e.stopImmediatePropagation();
  7950. $this.unbind('mouseleave');
  7951. $this.trigger('mouseup');
  7952. $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
  7953. });
  7954. $this.on('mouseup',
  7955. function(e) {
  7956. e.stopImmediatePropagation();
  7957. e.preventDefault();
  7958. $(this).unbind('mousemove');
  7959. });
  7960. }
  7961. });
  7962. });
  7963. },
  7964. toggleActivation: function() {
  7965. $(this).toggleClass('deactivate');
  7966. },
  7967. isActive: function() {
  7968. return ! $(this).hasClass('deactivate');
  7969. },
  7970. setActive: function(active) {
  7971. if (active) $(this).removeClass('deactivate');
  7972. else $(this).addClass('deactivate');
  7973. },
  7974. toggleState: function(skipOnChange) {
  7975. var $input = $(this).find('input:checkbox');
  7976. $input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
  7977. },
  7978. setState: function(value, skipOnChange) {
  7979. $(this).find('input:checkbox').prop('checked', value).trigger('change', skipOnChange);
  7980. },
  7981. status: function() {
  7982. return $(this).find('input:checkbox').is(':checked');
  7983. },
  7984. destroy: function() {
  7985. var $div = $(this).find('div'),
  7986. $checkbox;
  7987. $div.find(':not(input:checkbox)').remove();
  7988. $checkbox = $div.children();
  7989. $checkbox.unwrap().unwrap();
  7990. $checkbox.unbind('change');
  7991. return $checkbox;
  7992. }
  7993. };
  7994. if (methods[method]) return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  7995. else if (typeof method === 'object' || !method) return methods.init.apply(this, arguments);
  7996. else $.error('Method ' + method + ' does not exist!');
  7997. };
  7998. } (jQuery);
  7999. $(function() {
  8000. $('.switch')['bootstrapSwitch']();
  8001. });