H-ui.js 272 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293
  1. /*-----------H-ui前端框架-------------
  2. * H-ui.js v3.1.3
  3. * http://www.h-ui.net/
  4. * Created & Modified by guojunhui
  5. * Date modified 2017.05.26
  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.emailsuggest.js v1.0
  20. jQuery.format.js
  21. jQuery.togglePassword.js
  22. jQuery.iCheck.js
  23. jQuery.raty.js v2.4.5
  24. jQuery.onePageNav.js
  25. jQuery.stickUp.js
  26. jQuery.ColorPicker.js
  27. jQuery.HuiaddFavorite.js
  28. jQuery.Huisethome.js
  29. jQuery.Huisidenav.js
  30. jQuery.Huihover.js v2.0
  31. jQuery.Huifocusblur.js V2.0
  32. jQuery.Huiselect.js
  33. jQuery.Huitab.js v2.0
  34. jQuery.Huifold.js v2.0
  35. jQuery.Huitags.js v2.0
  36. jQuery.Huitagsmixed.js
  37. jQuery.Huitextarealength.js v2.0
  38. jQuery.Huipreview.js v2.0
  39. jQuery.Huimodalalert.js
  40. jQuery.Huialert.js
  41. jQuery.Huitotop.js v2.0
  42. jQuery.Huimarquee.js
  43. jQuery.Huispinner.js v2.0
  44. Bootstrap.modal.js v3.3.0
  45. Bootstrap.dropdown.js v3.3.0
  46. Bootstrap.transition.js v3.3.0
  47. Bootstrap.tooltip.js v3.3.0
  48. Bootstrap.popover.js v3.3.0
  49. Bootstrap.alert.js v3.3.0
  50. Bootstrap.slider.js v1.0.1
  51. Bootstrap.datetimepicker.js
  52. Bootstrap.Switch v1.3
  53. */
  54. /* =======================================================================
  55. * jQuery.IEMobileHack.js判断浏览器
  56. * ======================================================================== */
  57. !function(){
  58. if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  59. var msViewportStyle = document.createElement("style");
  60. msViewportStyle.appendChild(
  61. document.createTextNode(
  62. "@-ms-viewport{width:auto!important}"
  63. )
  64. );
  65. document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
  66. }
  67. } ();
  68. /* =======================================================================
  69. * jQuery.stopDefault.js 阻止默认浏览器动作
  70. * ======================================================================== */
  71. function stopDefault(e) {
  72. if (e && e.preventDefault) e.preventDefault();
  73. //IE中阻止函数器默认动作的方式
  74. else window.event.returnValue = false;
  75. return false;
  76. }
  77. /* =======================================================================
  78. * jQuery.cookie.js v1.4.1
  79. * https://github.com/carhartl/jQuery-cookie
  80. *
  81. * Copyright 2006, 2014 Klaus Hartl
  82. * Released under the MIT license
  83. * ======================================================================== */
  84. !(function(factory) {
  85. if (typeof define === 'function' && define.amd) {
  86. // AMD (Register as an anonymous module)
  87. define(['jquery'], factory);
  88. } else if (typeof exports === 'object') {
  89. // Node/CommonJS
  90. module.exports = factory(require('jquery'));
  91. } else {
  92. // Browser globals
  93. factory(jQuery);
  94. }
  95. }
  96. (function($){
  97. var pluses = /\+/g;
  98. function encode(s) {
  99. return config.raw ? s : encodeURIComponent(s);
  100. }
  101. function decode(s) {
  102. return config.raw ? s : decodeURIComponent(s);
  103. }
  104. function stringifyCookieValue(value) {
  105. return encode(config.json ? JSON.stringify(value) : String(value));
  106. }
  107. function parseCookieValue(s) {
  108. if (s.indexOf('"') === 0) {
  109. // This is a quoted cookie as according to RFC2068, unescape...
  110. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  111. }
  112. try {
  113. // Replace server-side written pluses with spaces.
  114. // If we can't decode the cookie, ignore it, it's unusable.
  115. // If we can't parse the cookie, ignore it, it's unusable.
  116. s = decodeURIComponent(s.replace(pluses, ' '));
  117. return config.json ? JSON.parse(s) : s;
  118. } catch(e) {}
  119. }
  120. function read(s, converter) {
  121. var value = config.raw ? s: parseCookieValue(s);
  122. return $.isFunction(converter) ? converter(value) : value;
  123. }
  124. var config = $.cookie = function(key, value, options) {
  125. // Write
  126. if (arguments.length > 1 && !$.isFunction(value)) {
  127. options = $.extend({},
  128. config.defaults, options);
  129. if (typeof options.expires === 'number') {
  130. var days = options.expires,
  131. t = options.expires = new Date();
  132. t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
  133. }
  134. return (document.cookie = [encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  135. options.path ? '; path=' + options.path: '', options.domain ? '; domain=' + options.domain: '', options.secure ? '; secure': ''].join(''));
  136. }
  137. // Read
  138. var result = key ? undefined: {},
  139. // To prevent the for loop in the first place assign an empty array
  140. // in case there are no cookies at all. Also prevents odd result when
  141. // calling $.cookie().
  142. cookies = document.cookie ? document.cookie.split('; ') : [],
  143. i = 0,
  144. l = cookies.length;
  145. for (; i < l; i++) {
  146. var parts = cookies[i].split('='),
  147. name = decode(parts.shift()),
  148. cookie = parts.join('=');
  149. if (key === name) {
  150. // If second argument (value) is a function it's a converter...
  151. result = read(cookie, value);
  152. break;
  153. }
  154. // Prevent storing a cookie that we couldn't decode.
  155. if (!key && (cookie = read(cookie)) !== undefined) {
  156. result[name] = cookie;
  157. }
  158. }
  159. return result;
  160. };
  161. config.defaults = {};
  162. $.removeCookie = function(key, options) {
  163. // Must not alter options, thus extending a fresh object...
  164. $.cookie(key, '', $.extend({},
  165. options, {
  166. expires: -1
  167. }));
  168. return ! $.cookie(key);
  169. };
  170. }));
  171. /* =======================================================================
  172. * jQuery.form.js Plugin v3.51.0 2014.06.20
  173. * Requires jQuery v1.5 or later
  174. * Copyright (c) 2014 M. Alsup
  175. * Examples and documentation at: http://malsup.com/jquery/form/
  176. * Project repository: https://github.com/malsup/form
  177. * Dual licensed under the MIT and GPL licenses.
  178. * https://github.com/malsup/form#copyright-and-license
  179. * ======================================================================== */
  180. // AMD support
  181. (function(factory) {
  182. "use strict";
  183. if (typeof define === 'function' && define.amd) {
  184. // using AMD; register as anon module
  185. define(['jquery'], factory);
  186. } else {
  187. // no AMD; invoke directly
  188. factory((typeof(jQuery) != 'undefined') ? jQuery: window.Zepto);
  189. }
  190. } (function($) {
  191. "use strict";
  192. /*
  193. Usage Note:
  194. -----------
  195. Do not use both ajaxSubmit and ajaxForm on the same form. These
  196. functions are mutually exclusive. Use ajaxSubmit if you want
  197. to bind your own submit handler to the form. For example,
  198. $(document).ready(function() {
  199. $('#myForm').on('submit', function(e) {
  200. e.preventDefault(); // <-- important
  201. $(this).ajaxSubmit({
  202. target: '#output'
  203. });
  204. });
  205. });
  206. Use ajaxForm when you want the plugin to manage all the event binding
  207. for you. For example,
  208. $(document).ready(function() {
  209. $('#myForm').ajaxForm({
  210. target: '#output'
  211. });
  212. });
  213. You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
  214. form does not have to exist when you invoke ajaxForm:
  215. $('#myForm').ajaxForm({
  216. delegation: true,
  217. target: '#output'
  218. });
  219. When using ajaxForm, the ajaxSubmit function will be invoked for you
  220. at the appropriate time.
  221. */
  222. /**
  223. * Feature detection
  224. */
  225. var feature = {};
  226. feature.fileapi = $("<input type='file'/>").get(0).files !== undefined;
  227. feature.formdata = window.FormData !== undefined;
  228. var hasProp = !!$.fn.prop;
  229. // attr2 uses prop when it can but checks the return type for
  230. // an expected string. this accounts for the case where a form
  231. // contains inputs with names like "action" or "method"; in those
  232. // cases "prop" returns the element
  233. $.fn.attr2 = function() {
  234. if (!hasProp) {
  235. return this.attr.apply(this, arguments);
  236. }
  237. var val = this.prop.apply(this, arguments);
  238. if ((val && val.jquery) || typeof val === 'string') {
  239. return val;
  240. }
  241. return this.attr.apply(this, arguments);
  242. };
  243. /**
  244. * ajaxSubmit() provides a mechanism for immediately submitting
  245. * an HTML form using AJAX.
  246. */
  247. $.fn.ajaxSubmit = function(options) {
  248. /*jshint scripturl:true */
  249. // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
  250. if (!this.length) {
  251. log('ajaxSubmit: skipping submit process - no element selected');
  252. return this;
  253. }
  254. var method, action, url, $form = this;
  255. if (typeof options == 'function') {
  256. options = {
  257. success: options
  258. };
  259. } else if (options === undefined) {
  260. options = {};
  261. }
  262. method = options.type || this.attr2('method');
  263. action = options.url || this.attr2('action');
  264. url = (typeof action === 'string') ? $.trim(action) : '';
  265. url = url || window.location.href || '';
  266. if (url) {
  267. // clean url (don't include hash vaue)
  268. url = (url.match(/^([^#]+)/) || [])[1];
  269. }
  270. options = $.extend(true, {
  271. url: url,
  272. success: $.ajaxSettings.success,
  273. type: method || $.ajaxSettings.type,
  274. iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false': 'about:blank'
  275. },
  276. options);
  277. // hook for manipulating the form data before it is extracted;
  278. // convenient for use with rich editors like tinyMCE or FCKEditor
  279. var veto = {};
  280. this.trigger('form-pre-serialize', [this, options, veto]);
  281. if (veto.veto) {
  282. log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
  283. return this;
  284. }
  285. // provide opportunity to alter form data before it is serialized
  286. if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
  287. log('ajaxSubmit: submit aborted via beforeSerialize callback');
  288. return this;
  289. }
  290. var traditional = options.traditional;
  291. if (traditional === undefined) {
  292. traditional = $.ajaxSettings.traditional;
  293. }
  294. var elements = [];
  295. var qx, a = this.formToArray(options.semantic, elements);
  296. if (options.data) {
  297. options.extraData = options.data;
  298. qx = $.param(options.data, traditional);
  299. }
  300. // give pre-submit callback an opportunity to abort the submit
  301. if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
  302. log('ajaxSubmit: submit aborted via beforeSubmit callback');
  303. return this;
  304. }
  305. // fire vetoable 'validate' event
  306. this.trigger('form-submit-validate', [a, this, options, veto]);
  307. if (veto.veto) {
  308. log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
  309. return this;
  310. }
  311. var q = $.param(a, traditional);
  312. if (qx) {
  313. q = (q ? (q + '&' + qx) : qx);
  314. }
  315. if (options.type.toUpperCase() == 'GET') {
  316. options.url += (options.url.indexOf('?') >= 0 ? '&': '?') + q;
  317. options.data = null; // data is null for 'get'
  318. } else {
  319. options.data = q; // data is the query string for 'post'
  320. }
  321. var callbacks = [];
  322. if (options.resetForm) {
  323. callbacks.push(function() {
  324. $form.resetForm();
  325. });
  326. }
  327. if (options.clearForm) {
  328. callbacks.push(function() {
  329. $form.clearForm(options.includeHidden);
  330. });
  331. }
  332. // perform a load on the target only if dataType is not provided
  333. if (!options.dataType && options.target) {
  334. var oldSuccess = options.success ||
  335. function() {};
  336. callbacks.push(function(data) {
  337. var fn = options.replaceTarget ? 'replaceWith': 'html';
  338. $(options.target)[fn](data).each(oldSuccess, arguments);
  339. });
  340. } else if (options.success) {
  341. callbacks.push(options.success);
  342. }
  343. options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
  344. var context = options.context || this; // jQuery 1.4+ supports scope context
  345. for (var i = 0,
  346. max = callbacks.length; i < max; i++) {
  347. callbacks[i].apply(context, [data, status, xhr || $form, $form]);
  348. }
  349. };
  350. if (options.error) {
  351. var oldError = options.error;
  352. options.error = function(xhr, status, error) {
  353. var context = options.context || this;
  354. oldError.apply(context, [xhr, status, error, $form]);
  355. };
  356. }
  357. if (options.complete) {
  358. var oldComplete = options.complete;
  359. options.complete = function(xhr, status) {
  360. var context = options.context || this;
  361. oldComplete.apply(context, [xhr, status, $form]);
  362. };
  363. }
  364. // are there files to upload?
  365. // [value] (issue #113), also see comment:
  366. // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
  367. var fileInputs = $('input[type=file]:enabled', this).filter(function() {
  368. return $(this).val() !== '';
  369. });
  370. var hasFileInputs = fileInputs.length > 0;
  371. var mp = 'multipart/form-data';
  372. var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
  373. var fileAPI = feature.fileapi && feature.formdata;
  374. log("fileAPI :" + fileAPI);
  375. var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
  376. var jqxhr;
  377. // options.iframe allows user to force iframe mode
  378. // 06-NOV-09: now defaulting to iframe mode if file input is detected
  379. if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
  380. // hack to fix Safari hang (thanks to Tim Molendijk for this)
  381. // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
  382. if (options.closeKeepAlive) {
  383. $.get(options.closeKeepAlive,
  384. function() {
  385. jqxhr = fileUploadIframe(a);
  386. });
  387. } else {
  388. jqxhr = fileUploadIframe(a);
  389. }
  390. } else if ((hasFileInputs || multipart) && fileAPI) {
  391. jqxhr = fileUploadXhr(a);
  392. } else {
  393. jqxhr = $.ajax(options);
  394. }
  395. $form.removeData('jqxhr').data('jqxhr', jqxhr);
  396. // clear element array
  397. for (var k = 0; k < elements.length; k++) {
  398. elements[k] = null;
  399. }
  400. // fire 'notify' event
  401. this.trigger('form-submit-notify', [this, options]);
  402. return this;
  403. // utility fn for deep serialization
  404. function deepSerialize(extraData) {
  405. var serialized = $.param(extraData, options.traditional).split('&');
  406. var len = serialized.length;
  407. var result = [];
  408. var i, part;
  409. for (i = 0; i < len; i++) {
  410. // #252; undo param space replacement
  411. serialized[i] = serialized[i].replace(/\+/g, ' ');
  412. part = serialized[i].split('=');
  413. // #278; use array instead of object storage, favoring array serializations
  414. result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
  415. }
  416. return result;
  417. }
  418. // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
  419. function fileUploadXhr(a) {
  420. var formdata = new FormData();
  421. for (var i = 0; i < a.length; i++) {
  422. formdata.append(a[i].name, a[i].value);
  423. }
  424. if (options.extraData) {
  425. var serializedData = deepSerialize(options.extraData);
  426. for (i = 0; i < serializedData.length; i++) {
  427. if (serializedData[i]) {
  428. formdata.append(serializedData[i][0], serializedData[i][1]);
  429. }
  430. }
  431. }
  432. options.data = null;
  433. var s = $.extend(true, {},
  434. $.ajaxSettings, options, {
  435. contentType: false,
  436. processData: false,
  437. cache: false,
  438. type: method || 'POST'
  439. });
  440. if (options.uploadProgress) {
  441. // workaround because jqXHR does not expose upload property
  442. s.xhr = function() {
  443. var xhr = $.ajaxSettings.xhr();
  444. if (xhr.upload) {
  445. xhr.upload.addEventListener('progress',
  446. function(event) {
  447. var percent = 0;
  448. var position = event.loaded || event.position;
  449. /*event.position is deprecated*/
  450. var total = event.total;
  451. if (event.lengthComputable) {
  452. percent = Math.ceil(position / total * 100);
  453. }
  454. options.uploadProgress(event, position, total, percent);
  455. },
  456. false);
  457. }
  458. return xhr;
  459. };
  460. }
  461. s.data = null;
  462. var beforeSend = s.beforeSend;
  463. s.beforeSend = function(xhr, o) {
  464. //Send FormData() provided by user
  465. if (options.formData) {
  466. o.data = options.formData;
  467. } else {
  468. o.data = formdata;
  469. }
  470. if (beforeSend) {
  471. beforeSend.call(this, xhr, o);
  472. }
  473. };
  474. return $.ajax(s);
  475. }
  476. // private function for handling file uploads (hat tip to YAHOO!)
  477. function fileUploadIframe(a) {
  478. var form = $form[0],
  479. el,
  480. i,
  481. s,
  482. g,
  483. id,
  484. $io,
  485. io,
  486. xhr,
  487. sub,
  488. n,
  489. timedOut,
  490. timeoutHandle;
  491. var deferred = $.Deferred();
  492. // #341
  493. deferred.abort = function(status) {
  494. xhr.abort(status);
  495. };
  496. if (a) {
  497. // ensure that every serialized input is still enabled
  498. for (i = 0; i < elements.length; i++) {
  499. el = $(elements[i]);
  500. if (hasProp) {
  501. el.prop('disabled', false);
  502. } else {
  503. el.removeAttr('disabled');
  504. }
  505. }
  506. }
  507. s = $.extend(true, {},
  508. $.ajaxSettings, options);
  509. s.context = s.context || s;
  510. id = 'jqFormIO' + (new Date().getTime());
  511. if (s.iframeTarget) {
  512. $io = $(s.iframeTarget);
  513. n = $io.attr2('name');
  514. if (!n) {
  515. $io.attr2('name', id);
  516. } else {
  517. id = n;
  518. }
  519. } else {
  520. $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />');
  521. $io.css({
  522. position: 'absolute',
  523. top: '-1000px',
  524. left: '-1000px'
  525. });
  526. }
  527. io = $io[0];
  528. xhr = { // mock object
  529. aborted: 0,
  530. responseText: null,
  531. responseXML: null,
  532. status: 0,
  533. statusText: 'n/a',
  534. getAllResponseHeaders: function() {},
  535. getResponseHeader: function() {},
  536. setRequestHeader: function() {},
  537. abort: function(status) {
  538. var e = (status === 'timeout' ? 'timeout': 'aborted');
  539. log('aborting upload... ' + e);
  540. this.aborted = 1;
  541. try { // #214, #257
  542. if (io.contentWindow.document.execCommand) {
  543. io.contentWindow.document.execCommand('Stop');
  544. }
  545. } catch(ignore) {}
  546. $io.attr('src', s.iframeSrc); // abort op in progress
  547. xhr.error = e;
  548. if (s.error) {
  549. s.error.call(s.context, xhr, e, status);
  550. }
  551. if (g) {
  552. $.event.trigger("ajaxError", [xhr, s, e]);
  553. }
  554. if (s.complete) {
  555. s.complete.call(s.context, xhr, e);
  556. }
  557. }
  558. };
  559. g = s.global;
  560. // trigger ajax global events so that activity/block indicators work like normal
  561. if (g && 0 === $.active++) {
  562. $.event.trigger("ajaxStart");
  563. }
  564. if (g) {
  565. $.event.trigger("ajaxSend", [xhr, s]);
  566. }
  567. if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
  568. if (s.global) {
  569. $.active--;
  570. }
  571. deferred.reject();
  572. return deferred;
  573. }
  574. if (xhr.aborted) {
  575. deferred.reject();
  576. return deferred;
  577. }
  578. // add submitting element to data if we know it
  579. sub = form.clk;
  580. if (sub) {
  581. n = sub.name;
  582. if (n && !sub.disabled) {
  583. s.extraData = s.extraData || {};
  584. s.extraData[n] = sub.value;
  585. if (sub.type == "image") {
  586. s.extraData[n + '.x'] = form.clk_x;
  587. s.extraData[n + '.y'] = form.clk_y;
  588. }
  589. }
  590. }
  591. var CLIENT_TIMEOUT_ABORT = 1;
  592. var SERVER_ABORT = 2;
  593. function getDoc(frame) {
  594. /* it looks like contentWindow or contentDocument do not
  595. * carry the protocol property in ie8, when running under ssl
  596. * frame.document is the only valid response document, since
  597. * the protocol is know but not on the other two objects. strange?
  598. * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
  599. */
  600. var doc = null;
  601. // IE8 cascading access check
  602. try {
  603. if (frame.contentWindow) {
  604. doc = frame.contentWindow.document;
  605. }
  606. } catch(err) {
  607. // IE8 access denied under ssl & missing protocol
  608. log('cannot get iframe.contentWindow document: ' + err);
  609. }
  610. if (doc) { // successful getting content
  611. return doc;
  612. }
  613. try { // simply checking may throw in ie8 under ssl or mismatched protocol
  614. doc = frame.contentDocument ? frame.contentDocument: frame.document;
  615. } catch(err) {
  616. // last attempt
  617. log('cannot get iframe.contentDocument: ' + err);
  618. doc = frame.document;
  619. }
  620. return doc;
  621. }
  622. // Rails CSRF hack (thanks to Yvan Barthelemy)
  623. var csrf_token = $('meta[name=csrf-token]').attr('content');
  624. var csrf_param = $('meta[name=csrf-param]').attr('content');
  625. if (csrf_param && csrf_token) {
  626. s.extraData = s.extraData || {};
  627. s.extraData[csrf_param] = csrf_token;
  628. }
  629. // take a breath so that pending repaints get some cpu time before the upload starts
  630. function doSubmit() {
  631. // make sure form attrs are set
  632. var t = $form.attr2('target'),
  633. a = $form.attr2('action'),
  634. mp = 'multipart/form-data',
  635. et = $form.attr('enctype') || $form.attr('encoding') || mp;
  636. // update form attrs in IE friendly way
  637. form.setAttribute('target', id);
  638. if (!method || /post/i.test(method)) {
  639. form.setAttribute('method', 'POST');
  640. }
  641. if (a != s.url) {
  642. form.setAttribute('action', s.url);
  643. }
  644. // ie borks in some cases when setting encoding
  645. if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {
  646. $form.attr({
  647. encoding: 'multipart/form-data',
  648. enctype: 'multipart/form-data'
  649. });
  650. }
  651. // support timout
  652. if (s.timeout) {
  653. timeoutHandle = setTimeout(function() {
  654. timedOut = true;
  655. cb(CLIENT_TIMEOUT_ABORT);
  656. },
  657. s.timeout);
  658. }
  659. // look for server aborts
  660. function checkState() {
  661. try {
  662. var state = getDoc(io).readyState;
  663. log('state = ' + state);
  664. if (state && state.toLowerCase() == 'uninitialized') {
  665. setTimeout(checkState, 50);
  666. }
  667. } catch(e) {
  668. log('Server abort: ', e, ' (', e.name, ')');
  669. cb(SERVER_ABORT);
  670. if (timeoutHandle) {
  671. clearTimeout(timeoutHandle);
  672. }
  673. timeoutHandle = undefined;
  674. }
  675. }
  676. // add "extra" data to form if provided in options
  677. var extraInputs = [];
  678. try {
  679. if (s.extraData) {
  680. for (var n in s.extraData) {
  681. if (s.extraData.hasOwnProperty(n)) {
  682. // if using the $.param format that allows for multiple values with the same name
  683. if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
  684. extraInputs.push($('<input type="hidden" name="' + s.extraData[n].name + '">').val(s.extraData[n].value).appendTo(form)[0]);
  685. } else {
  686. extraInputs.push($('<input type="hidden" name="' + n + '">').val(s.extraData[n]).appendTo(form)[0]);
  687. }
  688. }
  689. }
  690. }
  691. if (!s.iframeTarget) {
  692. // add iframe to doc and submit the form
  693. $io.appendTo('body');
  694. }
  695. if (io.attachEvent) {
  696. io.attachEvent('onload', cb);
  697. } else {
  698. io.addEventListener('load', cb, false);
  699. }
  700. setTimeout(checkState, 15);
  701. try {
  702. form.submit();
  703. } catch(err) {
  704. // just in case form has element with name/id of 'submit'
  705. var submitFn = document.createElement('form').submit;
  706. submitFn.apply(form);
  707. }
  708. } finally {
  709. // reset attrs and remove "extra" input elements
  710. form.setAttribute('action', a);
  711. form.setAttribute('enctype', et); // #380
  712. if (t) {
  713. form.setAttribute('target', t);
  714. } else {
  715. $form.removeAttr('target');
  716. }
  717. $(extraInputs).remove();
  718. }
  719. }
  720. if (s.forceSync) {
  721. doSubmit();
  722. } else {
  723. setTimeout(doSubmit, 10); // this lets dom updates render
  724. }
  725. var data, doc, domCheckCount = 50,
  726. callbackProcessed;
  727. function cb(e) {
  728. if (xhr.aborted || callbackProcessed) {
  729. return;
  730. }
  731. doc = getDoc(io);
  732. if (!doc) {
  733. log('cannot access response document');
  734. e = SERVER_ABORT;
  735. }
  736. if (e === CLIENT_TIMEOUT_ABORT && xhr) {
  737. xhr.abort('timeout');
  738. deferred.reject(xhr, 'timeout');
  739. return;
  740. } else if (e == SERVER_ABORT && xhr) {
  741. xhr.abort('server abort');
  742. deferred.reject(xhr, 'error', 'server abort');
  743. return;
  744. }
  745. if (!doc || doc.location.href == s.iframeSrc) {
  746. // response not received yet
  747. if (!timedOut) {
  748. return;
  749. }
  750. }
  751. if (io.detachEvent) {
  752. io.detachEvent('onload', cb);
  753. } else {
  754. io.removeEventListener('load', cb, false);
  755. }
  756. var status = 'success',
  757. errMsg;
  758. try {
  759. if (timedOut) {
  760. throw 'timeout';
  761. }
  762. var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
  763. log('isXml=' + isXml);
  764. if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
  765. if (--domCheckCount) {
  766. // in some browsers (Opera) the iframe DOM is not always traversable when
  767. // the onload callback fires, so we loop a bit to accommodate
  768. log('requeing onLoad callback, DOM not available');
  769. setTimeout(cb, 250);
  770. return;
  771. }
  772. // let this fall through because server response could be an empty document
  773. //log('Could not access iframe DOM after mutiple tries.');
  774. //throw 'DOMException: not available';
  775. }
  776. //log('response detected');
  777. var docRoot = doc.body ? doc.body: doc.documentElement;
  778. xhr.responseText = docRoot ? docRoot.innerHTML: null;
  779. xhr.responseXML = doc.XMLDocument ? doc.XMLDocument: doc;
  780. if (isXml) {
  781. s.dataType = 'xml';
  782. }
  783. xhr.getResponseHeader = function(header) {
  784. var headers = {
  785. 'content-type': s.dataType
  786. };
  787. return headers[header.toLowerCase()];
  788. };
  789. // support for XHR 'status' & 'statusText' emulation :
  790. if (docRoot) {
  791. xhr.status = Number(docRoot.getAttribute('status')) || xhr.status;
  792. xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
  793. }
  794. var dt = (s.dataType || '').toLowerCase();
  795. var scr = /(json|script|text)/.test(dt);
  796. if (scr || s.textarea) {
  797. // see if user embedded response in textarea
  798. var ta = doc.getElementsByTagName('textarea')[0];
  799. if (ta) {
  800. xhr.responseText = ta.value;
  801. // support for XHR 'status' & 'statusText' emulation :
  802. xhr.status = Number(ta.getAttribute('status')) || xhr.status;
  803. xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
  804. } else if (scr) {
  805. // account for browsers injecting pre around json response
  806. var pre = doc.getElementsByTagName('pre')[0];
  807. var b = doc.getElementsByTagName('body')[0];
  808. if (pre) {
  809. xhr.responseText = pre.textContent ? pre.textContent: pre.innerText;
  810. } else if (b) {
  811. xhr.responseText = b.textContent ? b.textContent: b.innerText;
  812. }
  813. }
  814. } else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
  815. xhr.responseXML = toXml(xhr.responseText);
  816. }
  817. try {
  818. data = httpData(xhr, dt, s);
  819. } catch(err) {
  820. status = 'parsererror';
  821. xhr.error = errMsg = (err || status);
  822. }
  823. } catch(err) {
  824. log('error caught: ', err);
  825. status = 'error';
  826. xhr.error = errMsg = (err || status);
  827. }
  828. if (xhr.aborted) {
  829. log('upload aborted');
  830. status = null;
  831. }
  832. if (xhr.status) { // we've set xhr.status
  833. status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success': 'error';
  834. }
  835. // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
  836. if (status === 'success') {
  837. if (s.success) {
  838. s.success.call(s.context, data, 'success', xhr);
  839. }
  840. deferred.resolve(xhr.responseText, 'success', xhr);
  841. if (g) {
  842. $.event.trigger("ajaxSuccess", [xhr, s]);
  843. }
  844. } else if (status) {
  845. if (errMsg === undefined) {
  846. errMsg = xhr.statusText;
  847. }
  848. if (s.error) {
  849. s.error.call(s.context, xhr, status, errMsg);
  850. }
  851. deferred.reject(xhr, 'error', errMsg);
  852. if (g) {
  853. $.event.trigger("ajaxError", [xhr, s, errMsg]);
  854. }
  855. }
  856. if (g) {
  857. $.event.trigger("ajaxComplete", [xhr, s]);
  858. }
  859. if (g && !--$.active) {
  860. $.event.trigger("ajaxStop");
  861. }
  862. if (s.complete) {
  863. s.complete.call(s.context, xhr, status);
  864. }
  865. callbackProcessed = true;
  866. if (s.timeout) {
  867. clearTimeout(timeoutHandle);
  868. }
  869. // clean up
  870. setTimeout(function() {
  871. if (!s.iframeTarget) {
  872. $io.remove();
  873. } else { //adding else to clean up existing iframe response.
  874. $io.attr('src', s.iframeSrc);
  875. }
  876. xhr.responseXML = null;
  877. },
  878. 100);
  879. }
  880. var toXml = $.parseXML ||
  881. function(s, doc) { // use parseXML if available (jQuery 1.5+)
  882. if (window.ActiveXObject) {
  883. doc = new ActiveXObject('Microsoft.XMLDOM');
  884. doc.async = 'false';
  885. doc.loadXML(s);
  886. } else {
  887. doc = (new DOMParser()).parseFromString(s, 'text/xml');
  888. }
  889. return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc: null;
  890. };
  891. var parseJSON = $.parseJSON ||
  892. function(s) {
  893. /*jslint evil:true */
  894. return window['eval']('(' + s + ')');
  895. };
  896. var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
  897. var ct = xhr.getResponseHeader('content-type') || '',
  898. xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
  899. data = xml ? xhr.responseXML: xhr.responseText;
  900. if (xml && data.documentElement.nodeName === 'parsererror') {
  901. if ($.error) {
  902. $.error('parsererror');
  903. }
  904. }
  905. if (s && s.dataFilter) {
  906. data = s.dataFilter(data, type);
  907. }
  908. if (typeof data === 'string') {
  909. if (type === 'json' || !type && ct.indexOf('json') >= 0) {
  910. data = parseJSON(data);
  911. } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
  912. $.globalEval(data);
  913. }
  914. }
  915. return data;
  916. };
  917. return deferred;
  918. }
  919. };
  920. /**
  921. * ajaxForm() provides a mechanism for fully automating form submission.
  922. *
  923. * The advantages of using this method instead of ajaxSubmit() are:
  924. *
  925. * 1: This method will include coordinates for <input type="image" /> elements (if the element
  926. * is used to submit the form).
  927. * 2. This method will include the submit element's name/value data (for the element that was
  928. * used to submit the form).
  929. * 3. This method binds the submit() method to the form for you.
  930. *
  931. * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
  932. * passes the options argument along after properly binding events for submit elements and
  933. * the form itself.
  934. */
  935. $.fn.ajaxForm = function(options) {
  936. options = options || {};
  937. options.delegation = options.delegation && $.isFunction($.fn.on);
  938. // in jQuery 1.3+ we can fix mistakes with the ready state
  939. if (!options.delegation && this.length === 0) {
  940. var o = {
  941. s: this.selector,
  942. c: this.context
  943. };
  944. if (!$.isReady && o.s) {
  945. log('DOM not ready, queuing ajaxForm');
  946. $(function() {
  947. $(o.s, o.c).ajaxForm(options);
  948. });
  949. return this;
  950. }
  951. // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
  952. log('terminating; zero elements found by selector' + ($.isReady ? '': ' (DOM not ready)'));
  953. return this;
  954. }
  955. if (options.delegation) {
  956. $(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);
  957. return this;
  958. }
  959. return this.ajaxFormUnbind().on('submit.form-plugin', options, doAjaxSubmit).on('click.form-plugin', options, captureSubmittingElement);
  960. };
  961. // private event handlers
  962. function doAjaxSubmit(e) {
  963. /*jshint validthis:true */
  964. var options = e.data;
  965. if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
  966. e.preventDefault();
  967. $(e.target).ajaxSubmit(options); // #365
  968. }
  969. }
  970. function captureSubmittingElement(e) {
  971. /*jshint validthis:true */
  972. var target = e.target;
  973. var $el = $(target);
  974. if (! ($el.is("[type=submit],[type=image]"))) {
  975. // is this a child element of the submit el? (ex: a span within a button)
  976. var t = $el.closest('[type=submit]');
  977. if (t.length === 0) {
  978. return;
  979. }
  980. target = t[0];
  981. }
  982. var form = this;
  983. form.clk = target;
  984. if (target.type == 'image') {
  985. if (e.offsetX !== undefined) {
  986. form.clk_x = e.offsetX;
  987. form.clk_y = e.offsetY;
  988. } else if (typeof $.fn.offset == 'function') {
  989. var offset = $el.offset();
  990. form.clk_x = e.pageX - offset.left;
  991. form.clk_y = e.pageY - offset.top;
  992. } else {
  993. form.clk_x = e.pageX - target.offsetLeft;
  994. form.clk_y = e.pageY - target.offsetTop;
  995. }
  996. }
  997. // clear form vars
  998. setTimeout(function() {
  999. form.clk = form.clk_x = form.clk_y = null;
  1000. },
  1001. 100);
  1002. }
  1003. // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
  1004. $.fn.ajaxFormUnbind = function() {
  1005. return this.unbind('submit.form-plugin click.form-plugin');
  1006. };
  1007. /**
  1008. * formToArray() gathers form element data into an array of objects that can
  1009. * be passed to any of the following ajax functions: $.get, $.post, or load.
  1010. * Each object in the array has both a 'name' and 'value' property. An example of
  1011. * an array for a simple login form might be:
  1012. *
  1013. * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
  1014. *
  1015. * It is this array that is passed to pre-submit callback functions provided to the
  1016. * ajaxSubmit() and ajaxForm() methods.
  1017. */
  1018. $.fn.formToArray = function(semantic, elements) {
  1019. var a = [];
  1020. if (this.length === 0) {
  1021. return a;
  1022. }
  1023. var form = this[0];
  1024. var formId = this.attr('id');
  1025. var els = semantic ? form.getElementsByTagName('*') : form.elements;
  1026. var els2;
  1027. if (els && !/MSIE [678]/.test(navigator.userAgent)) { // #390
  1028. els = $(els).get(); // convert to standard array
  1029. }
  1030. // #386; account for inputs outside the form which use the 'form' attribute
  1031. if (formId) {
  1032. els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
  1033. if (els2.length) {
  1034. els = (els || []).concat(els2);
  1035. }
  1036. }
  1037. if (!els || !els.length) {
  1038. return a;
  1039. }
  1040. var i, j, n, v, el, max, jmax;
  1041. for (i = 0, max = els.length; i < max; i++) {
  1042. el = els[i];
  1043. n = el.name;
  1044. if (!n || el.disabled) {
  1045. continue;
  1046. }
  1047. if (semantic && form.clk && el.type == "image") {
  1048. // handle image inputs on the fly when semantic == true
  1049. if (form.clk == el) {
  1050. a.push({
  1051. name: n,
  1052. value: $(el).val(),
  1053. type: el.type
  1054. });
  1055. a.push({
  1056. name: n + '.x',
  1057. value: form.clk_x
  1058. },
  1059. {
  1060. name: n + '.y',
  1061. value: form.clk_y
  1062. });
  1063. }
  1064. continue;
  1065. }
  1066. v = $.fieldValue(el, true);
  1067. if (v && v.constructor == Array) {
  1068. if (elements) {
  1069. elements.push(el);
  1070. }
  1071. for (j = 0, jmax = v.length; j < jmax; j++) {
  1072. a.push({
  1073. name: n,
  1074. value: v[j]
  1075. });
  1076. }
  1077. } else if (feature.fileapi && el.type == 'file') {
  1078. if (elements) {
  1079. elements.push(el);
  1080. }
  1081. var files = el.files;
  1082. if (files.length) {
  1083. for (j = 0; j < files.length; j++) {
  1084. a.push({
  1085. name: n,
  1086. value: files[j],
  1087. type: el.type
  1088. });
  1089. }
  1090. } else {
  1091. // #180
  1092. a.push({
  1093. name: n,
  1094. value: '',
  1095. type: el.type
  1096. });
  1097. }
  1098. } else if (v !== null && typeof v != 'undefined') {
  1099. if (elements) {
  1100. elements.push(el);
  1101. }
  1102. a.push({
  1103. name: n,
  1104. value: v,
  1105. type: el.type,
  1106. required: el.required
  1107. });
  1108. }
  1109. }
  1110. if (!semantic && form.clk) {
  1111. // input type=='image' are not found in elements array! handle it here
  1112. var $input = $(form.clk),
  1113. input = $input[0];
  1114. n = input.name;
  1115. if (n && !input.disabled && input.type == 'image') {
  1116. a.push({
  1117. name: n,
  1118. value: $input.val()
  1119. });
  1120. a.push({
  1121. name: n + '.x',
  1122. value: form.clk_x
  1123. },
  1124. {
  1125. name: n + '.y',
  1126. value: form.clk_y
  1127. });
  1128. }
  1129. }
  1130. return a;
  1131. };
  1132. /**
  1133. * Serializes form data into a 'submittable' string. This method will return a string
  1134. * in the format: name1=value1&amp;name2=value2
  1135. */
  1136. $.fn.formSerialize = function(semantic) {
  1137. //hand off to jQuery.param for proper encoding
  1138. return $.param(this.formToArray(semantic));
  1139. };
  1140. /**
  1141. * Serializes all field elements in the jQuery object into a query string.
  1142. * This method will return a string in the format: name1=value1&amp;name2=value2
  1143. */
  1144. $.fn.fieldSerialize = function(successful) {
  1145. var a = [];
  1146. this.each(function() {
  1147. var n = this.name;
  1148. if (!n) {
  1149. return;
  1150. }
  1151. var v = $.fieldValue(this, successful);
  1152. if (v && v.constructor == Array) {
  1153. for (var i = 0,
  1154. max = v.length; i < max; i++) {
  1155. a.push({
  1156. name: n,
  1157. value: v[i]
  1158. });
  1159. }
  1160. } else if (v !== null && typeof v != 'undefined') {
  1161. a.push({
  1162. name: this.name,
  1163. value: v
  1164. });
  1165. }
  1166. });
  1167. //hand off to jQuery.param for proper encoding
  1168. return $.param(a);
  1169. };
  1170. /**
  1171. * Returns the value(s) of the element in the matched set. For example, consider the following form:
  1172. *
  1173. * <form><fieldset>
  1174. * <input name="A" type="text" />
  1175. * <input name="A" type="text" />
  1176. * <input name="B" type="checkbox" value="B1" />
  1177. * <input name="B" type="checkbox" value="B2"/>
  1178. * <input name="C" type="radio" value="C1" />
  1179. * <input name="C" type="radio" value="C2" />
  1180. * </fieldset></form>
  1181. *
  1182. * var v = $('input[type=text]').fieldValue();
  1183. * // if no values are entered into the text inputs
  1184. * v == ['','']
  1185. * // if values entered into the text inputs are 'foo' and 'bar'
  1186. * v == ['foo','bar']
  1187. *
  1188. * var v = $('input[type=checkbox]').fieldValue();
  1189. * // if neither checkbox is checked
  1190. * v === undefined
  1191. * // if both checkboxes are checked
  1192. * v == ['B1', 'B2']
  1193. *
  1194. * var v = $('input[type=radio]').fieldValue();
  1195. * // if neither radio is checked
  1196. * v === undefined
  1197. * // if first radio is checked
  1198. * v == ['C1']
  1199. *
  1200. * The successful argument controls whether or not the field element must be 'successful'
  1201. * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
  1202. * The default value of the successful argument is true. If this value is false the value(s)
  1203. * for each element is returned.
  1204. *
  1205. * Note: This method *always* returns an array. If no valid value can be determined the
  1206. * array will be empty, otherwise it will contain one or more values.
  1207. */
  1208. $.fn.fieldValue = function(successful) {
  1209. for (var val = [], i = 0, max = this.length; i < max; i++) {
  1210. var el = this[i];
  1211. var v = $.fieldValue(el, successful);
  1212. if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
  1213. continue;
  1214. }
  1215. if (v.constructor == Array) {
  1216. $.merge(val, v);
  1217. } else {
  1218. val.push(v);
  1219. }
  1220. }
  1221. return val;
  1222. };
  1223. /**
  1224. * Returns the value of the field element.
  1225. */
  1226. $.fieldValue = function(el, successful) {
  1227. var n = el.name,
  1228. t = el.type,
  1229. tag = el.tagName.toLowerCase();
  1230. if (successful === undefined) {
  1231. successful = true;
  1232. }
  1233. 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)) {
  1234. return null;
  1235. }
  1236. if (tag == 'select') {
  1237. var index = el.selectedIndex;
  1238. if (index < 0) {
  1239. return null;
  1240. }
  1241. var a = [],
  1242. ops = el.options;
  1243. var one = (t == 'select-one');
  1244. var max = (one ? index + 1 : ops.length);
  1245. for (var i = (one ? index: 0); i < max; i++) {
  1246. var op = ops[i];
  1247. if (op.selected) {
  1248. var v = op.value;
  1249. if (!v) { // extra pain for IE...
  1250. v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text: op.value;
  1251. }
  1252. if (one) {
  1253. return v;
  1254. }
  1255. a.push(v);
  1256. }
  1257. }
  1258. return a;
  1259. }
  1260. return $(el).val();
  1261. };
  1262. /**
  1263. * Clears the form data. Takes the following actions on the form's input fields:
  1264. * - input text fields will have their 'value' property set to the empty string
  1265. * - select elements will have their 'selectedIndex' property set to -1
  1266. * - checkbox and radio inputs will have their 'checked' property set to false
  1267. * - inputs of type submit, button, reset, and hidden will *not* be effected
  1268. * - button elements will *not* be effected
  1269. */
  1270. $.fn.clearForm = function(includeHidden) {
  1271. return this.each(function() {
  1272. $('input,select,textarea', this).clearFields(includeHidden);
  1273. });
  1274. };
  1275. /**
  1276. * Clears the selected form elements.
  1277. */
  1278. $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
  1279. var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
  1280. return this.each(function() {
  1281. var t = this.type,
  1282. tag = this.tagName.toLowerCase();
  1283. if (re.test(t) || tag == 'textarea') {
  1284. this.value = '';
  1285. } else if (t == 'checkbox' || t == 'radio') {
  1286. this.checked = false;
  1287. } else if (tag == 'select') {
  1288. this.selectedIndex = -1;
  1289. } else if (t == "file") {
  1290. if (/MSIE/.test(navigator.userAgent)) {
  1291. $(this).replaceWith($(this).clone(true));
  1292. } else {
  1293. $(this).val('');
  1294. }
  1295. } else if (includeHidden) {
  1296. // includeHidden can be the value true, or it can be a selector string
  1297. // indicating a special test; for example:
  1298. // $('#myForm').clearForm('.special:hidden')
  1299. // the above would clean hidden inputs that have the class of 'special'
  1300. if ((includeHidden === true && /hidden/.test(t)) || (typeof includeHidden == 'string' && $(this).is(includeHidden))) {
  1301. this.value = '';
  1302. }
  1303. }
  1304. });
  1305. };
  1306. /**
  1307. * Resets the form data. Causes all form elements to be reset to their original value.
  1308. */
  1309. $.fn.resetForm = function() {
  1310. return this.each(function() {
  1311. // guard against an input with the name of 'reset'
  1312. // note that IE reports the reset function as an 'object'
  1313. if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
  1314. this.reset();
  1315. }
  1316. });
  1317. };
  1318. /**
  1319. * Enables or disables any matching elements.
  1320. */
  1321. $.fn.enable = function(b) {
  1322. if (b === undefined) {
  1323. b = true;
  1324. }
  1325. return this.each(function() {
  1326. this.disabled = !b;
  1327. });
  1328. };
  1329. /**
  1330. * Checks/unchecks any matching checkboxes or radio buttons and
  1331. * selects/deselects and matching option elements.
  1332. */
  1333. $.fn.selected = function(select) {
  1334. if (select === undefined) {
  1335. select = true;
  1336. }
  1337. return this.each(function() {
  1338. var t = this.type;
  1339. if (t == 'checkbox' || t == 'radio') {
  1340. this.checked = select;
  1341. } else if (this.tagName.toLowerCase() == 'option') {
  1342. var $sel = $(this).parent('select');
  1343. if (select && $sel[0] && $sel[0].type == 'select-one') {
  1344. // deselect all other options
  1345. $sel.find('option').selected(false);
  1346. }
  1347. this.selected = select;
  1348. }
  1349. });
  1350. };
  1351. // expose debug var
  1352. $.fn.ajaxSubmit.debug = false;
  1353. function log() {
  1354. if (!$.fn.ajaxSubmit.debug) {
  1355. return;
  1356. }
  1357. var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, '');
  1358. if (window.console && window.console.log) {
  1359. window.console.log(msg);
  1360. } else if (window.opera && window.opera.postError) {
  1361. window.opera.postError(msg);
  1362. }
  1363. }
  1364. }));
  1365. /* =======================================================================
  1366. * jQuery.lazyload v1.9.3
  1367. * Lazy Load - jQuery plugin for lazy loading images
  1368. * Copyright (c) 2007-2013 Mika Tuupola
  1369. * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
  1370. * Project home: http://www.appelsiini.net/projects/lazyload
  1371. * ======================================================================== */
  1372. ! (function($, window, document, undefined) {
  1373. var $window = $(window);
  1374. $.fn.lazyload = function(options) {
  1375. var elements = this;
  1376. var $container;
  1377. var settings = {
  1378. threshold: 0,
  1379. failure_limit: 0,
  1380. event: "scroll",
  1381. effect: "show",
  1382. container: window,
  1383. data_attribute: "original",
  1384. skip_invisible: true,
  1385. appear: null,
  1386. load: null,
  1387. placeholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
  1388. };
  1389. function update() {
  1390. var counter = 0;
  1391. elements.each(function() {
  1392. var $this = $(this);
  1393. if (settings.skip_invisible && !$this.is(":visible")) {
  1394. return;
  1395. }
  1396. if ($.abovethetop(this, settings) || $.leftofbegin(this, settings)) {
  1397. /* Nothing. */
  1398. } else if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) {
  1399. $this.trigger("appear");
  1400. /* if we found an image we'll load, reset the counter */
  1401. counter = 0;
  1402. } else {
  1403. if (++counter > settings.failure_limit) {
  1404. return false;
  1405. }
  1406. }
  1407. });
  1408. }
  1409. if (options) {
  1410. /* Maintain BC for a couple of versions. */
  1411. if (undefined !== options.failurelimit) {
  1412. options.failure_limit = options.failurelimit;
  1413. delete options.failurelimit;
  1414. }
  1415. if (undefined !== options.effectspeed) {
  1416. options.effect_speed = options.effectspeed;
  1417. delete options.effectspeed;
  1418. }
  1419. $.extend(settings, options);
  1420. }
  1421. /* Cache container as jQuery as object. */
  1422. $container = (settings.container === undefined || settings.container === window) ? $window: $(settings.container);
  1423. /* Fire one scroll event per scroll. Not one scroll event per image. */
  1424. if (0 === settings.event.indexOf("scroll")) {
  1425. $container.on(settings.event,
  1426. function() {
  1427. return update();
  1428. });
  1429. }
  1430. this.each(function() {
  1431. var self = this;
  1432. var $self = $(self);
  1433. self.loaded = false;
  1434. /* If no src attribute given use data:uri. */
  1435. if ($self.attr("src") === undefined || $self.attr("src") === false) {
  1436. if ($self.is("img")) {
  1437. $self.attr("src", settings.placeholder);
  1438. }
  1439. }
  1440. /* When appear is triggered load original image. */
  1441. $self.one("appear",
  1442. function() {
  1443. if (!this.loaded) {
  1444. if (settings.appear) {
  1445. var elements_left = elements.length;
  1446. settings.appear.call(self, elements_left, settings);
  1447. }
  1448. $("<img />").on("load",
  1449. function() {
  1450. var original = $self.attr("data-" + settings.data_attribute);
  1451. $self.hide();
  1452. if ($self.is("img")) {
  1453. $self.attr("src", original);
  1454. } else {
  1455. $self.css("background-image", "url('" + original + "')");
  1456. }
  1457. $self[settings.effect](settings.effect_speed);
  1458. self.loaded = true;
  1459. /* Remove image from array so it is not looped next time. */
  1460. var temp = $.grep(elements,
  1461. function(element) {
  1462. return ! element.loaded;
  1463. });
  1464. elements = $(temp);
  1465. if (settings.load) {
  1466. var elements_left = elements.length;
  1467. settings.load.call(self, elements_left, settings);
  1468. }
  1469. }).attr("src", $self.attr("data-" + settings.data_attribute));
  1470. }
  1471. });
  1472. /* When wanted event is triggered load original image */
  1473. /* by triggering appear. */
  1474. if (0 !== settings.event.indexOf("scroll")) {
  1475. $self.on(settings.event,
  1476. function() {
  1477. if (!self.loaded) {
  1478. $self.trigger("appear");
  1479. }
  1480. });
  1481. }
  1482. });
  1483. /* Check if something appears when window is resized. */
  1484. $window.on("resize",
  1485. function() {
  1486. update();
  1487. });
  1488. /* With IOS5 force loading images when navigating with back button. */
  1489. /* Non optimal workaround. */
  1490. if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
  1491. $window.on("pageshow",
  1492. function(event) {
  1493. if (event.originalEvent && event.originalEvent.persisted) {
  1494. elements.each(function() {
  1495. $(this).trigger("appear");
  1496. });
  1497. }
  1498. });
  1499. }
  1500. /* Force initial check if images should appear. */
  1501. $(document).ready(function() {
  1502. update();
  1503. });
  1504. return this;
  1505. };
  1506. /* Convenience methods in jQuery namespace. */
  1507. /* Use as $.belowthefold(element, {threshold : 100, container : window}) */
  1508. $.belowthefold = function(element, settings) {
  1509. var fold;
  1510. if (settings.container === undefined || settings.container === window) {
  1511. fold = (window.innerHeight ? window.innerHeight: $window.height()) + $window.scrollTop();
  1512. } else {
  1513. fold = $(settings.container).offset().top + $(settings.container).height();
  1514. }
  1515. return fold <= $(element).offset().top - settings.threshold;
  1516. };
  1517. $.rightoffold = function(element, settings) {
  1518. var fold;
  1519. if (settings.container === undefined || settings.container === window) {
  1520. fold = $window.width() + $window.scrollLeft();
  1521. } else {
  1522. fold = $(settings.container).offset().left + $(settings.container).width();
  1523. }
  1524. return fold <= $(element).offset().left - settings.threshold;
  1525. };
  1526. $.abovethetop = function(element, settings) {
  1527. var fold;
  1528. if (settings.container === undefined || settings.container === window) {
  1529. fold = $window.scrollTop();
  1530. } else {
  1531. fold = $(settings.container).offset().top;
  1532. }
  1533. return fold >= $(element).offset().top + settings.threshold + $(element).height();
  1534. };
  1535. $.leftofbegin = function(element, settings) {
  1536. var fold;
  1537. if (settings.container === undefined || settings.container === window) {
  1538. fold = $window.scrollLeft();
  1539. } else {
  1540. fold = $(settings.container).offset().left;
  1541. }
  1542. return fold >= $(element).offset().left + settings.threshold + $(element).width();
  1543. };
  1544. $.inviewport = function(element, settings) {
  1545. return ! $.rightoffold(element, settings) && !$.leftofbegin(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
  1546. };
  1547. /* Custom selectors for your convenience. */
  1548. /* Use as $("img:below-the-fold").something() or */
  1549. /* $("img").filter(":below-the-fold").something() which is faster */
  1550. $.extend($.expr[":"], {
  1551. "below-the-fold": function(a) {
  1552. return $.belowthefold(a, {
  1553. threshold: 0
  1554. });
  1555. },
  1556. "above-the-top": function(a) {
  1557. return ! $.belowthefold(a, {
  1558. threshold: 0
  1559. });
  1560. },
  1561. "right-of-screen": function(a) {
  1562. return $.rightoffold(a, {
  1563. threshold: 0
  1564. });
  1565. },
  1566. "left-of-screen": function(a) {
  1567. return ! $.rightoffold(a, {
  1568. threshold: 0
  1569. });
  1570. },
  1571. "in-viewport": function(a) {
  1572. return $.inviewport(a, {
  1573. threshold: 0
  1574. });
  1575. },
  1576. /* Maintain BC for couple of versions. */
  1577. "above-the-fold": function(a) {
  1578. return ! $.belowthefold(a, {
  1579. threshold: 0
  1580. });
  1581. },
  1582. "right-of-fold": function(a) {
  1583. return $.rightoffold(a, {
  1584. threshold: 0
  1585. });
  1586. },
  1587. "left-of-fold": function(a) {
  1588. return ! $.rightoffold(a, {
  1589. threshold: 0
  1590. });
  1591. }
  1592. });
  1593. })(jQuery, window, document);
  1594. /* =======================================================================
  1595. * jQuery.responsive-nav.js v1.0.39
  1596. * https://github.com/viljamis/responsive-nav.js
  1597. * http://responsive-nav.com
  1598. *
  1599. * Copyright (c) 2015 @viljamis
  1600. * Available under the MIT license
  1601. * ======================================================================== */
  1602. /* global Event */
  1603. (function(document, window, index) {
  1604. // Index is used to keep multiple navs on the same page namespaced
  1605. "use strict";
  1606. var responsiveNav = function(el, options) {
  1607. var computed = !!window.getComputedStyle;
  1608. /**
  1609. * getComputedStyle polyfill for old browsers
  1610. */
  1611. if (!computed) {
  1612. window.getComputedStyle = function(el) {
  1613. this.el = el;
  1614. this.getPropertyValue = function(prop) {
  1615. var re = /(\-([a-z]){1})/g;
  1616. if (prop === "float") {
  1617. prop = "styleFloat";
  1618. }
  1619. if (re.test(prop)) {
  1620. prop = prop.replace(re,
  1621. function() {
  1622. return arguments[2].toUpperCase();
  1623. });
  1624. }
  1625. return el.currentStyle[prop] ? el.currentStyle[prop] : null;
  1626. };
  1627. return this;
  1628. };
  1629. }
  1630. /* exported addEvent, removeEvent, getChildren, setAttributes, addClass, removeClass, forEach */
  1631. /**
  1632. * Add Event
  1633. * fn arg can be an object or a function, thanks to handleEvent
  1634. * read more at: http://www.thecssninja.com/javascript/handleevent
  1635. *
  1636. * @param {element} element
  1637. * @param {event} event
  1638. * @param {Function} fn
  1639. * @param {boolean} bubbling
  1640. */
  1641. var addEvent = function(el, evt, fn, bubble) {
  1642. if ("addEventListener" in el) {
  1643. // BBOS6 doesn't support handleEvent, catch and polyfill
  1644. try {
  1645. el.addEventListener(evt, fn, bubble);
  1646. } catch(e) {
  1647. if (typeof fn === "object" && fn.handleEvent) {
  1648. el.addEventListener(evt,
  1649. function(e) {
  1650. // Bind fn as this and set first arg as event object
  1651. fn.handleEvent.call(fn, e);
  1652. },
  1653. bubble);
  1654. } else {
  1655. throw e;
  1656. }
  1657. }
  1658. } else if ("attachEvent" in el) {
  1659. // check if the callback is an object and contains handleEvent
  1660. if (typeof fn === "object" && fn.handleEvent) {
  1661. el.attachEvent("on" + evt,
  1662. function() {
  1663. // Bind fn as this
  1664. fn.handleEvent.call(fn);
  1665. });
  1666. } else {
  1667. el.attachEvent("on" + evt, fn);
  1668. }
  1669. }
  1670. },
  1671. /**
  1672. * Remove Event
  1673. *
  1674. * @param {element} element
  1675. * @param {event} event
  1676. * @param {Function} fn
  1677. * @param {boolean} bubbling
  1678. */
  1679. removeEvent = function(el, evt, fn, bubble) {
  1680. if ("removeEventListener" in el) {
  1681. try {
  1682. el.removeEventListener(evt, fn, bubble);
  1683. } catch(e) {
  1684. if (typeof fn === "object" && fn.handleEvent) {
  1685. el.removeEventListener(evt,
  1686. function(e) {
  1687. fn.handleEvent.call(fn, e);
  1688. },
  1689. bubble);
  1690. } else {
  1691. throw e;
  1692. }
  1693. }
  1694. } else if ("detachEvent" in el) {
  1695. if (typeof fn === "object" && fn.handleEvent) {
  1696. el.detachEvent("on" + evt,
  1697. function() {
  1698. fn.handleEvent.call(fn);
  1699. });
  1700. } else {
  1701. el.detachEvent("on" + evt, fn);
  1702. }
  1703. }
  1704. },
  1705. /**
  1706. * Get the children of any element
  1707. *
  1708. * @param {element}
  1709. * @return {array} Returns matching elements in an array
  1710. */
  1711. getChildren = function(e) {
  1712. if (e.children.length < 1) {
  1713. throw new Error("The Nav container has no containing elements");
  1714. }
  1715. // Store all children in array
  1716. var children = [];
  1717. // Loop through children and store in array if child != TextNode
  1718. for (var i = 0; i < e.children.length; i++) {
  1719. if (e.children[i].nodeType === 1) {
  1720. children.push(e.children[i]);
  1721. }
  1722. }
  1723. return children;
  1724. },
  1725. /**
  1726. * Sets multiple attributes at once
  1727. *
  1728. * @param {element} element
  1729. * @param {attrs} attrs
  1730. */
  1731. setAttributes = function(el, attrs) {
  1732. for (var key in attrs) {
  1733. el.setAttribute(key, attrs[key]);
  1734. }
  1735. },
  1736. /**
  1737. * Adds a class to any element
  1738. *
  1739. * @param {element} element
  1740. * @param {string} class
  1741. */
  1742. addClass = function(el, cls) {
  1743. if (el.className.indexOf(cls) !== 0) {
  1744. el.className += " " + cls;
  1745. el.className = el.className.replace(/(^\s*)|(\s*$)/g, "");
  1746. }
  1747. },
  1748. /**
  1749. * Remove a class from any element
  1750. *
  1751. * @param {element} element
  1752. * @param {string} class
  1753. */
  1754. removeClass = function(el, cls) {
  1755. var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
  1756. el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g, "");
  1757. },
  1758. /**
  1759. * forEach method that passes back the stuff we need
  1760. *
  1761. * @param {array} array
  1762. * @param {Function} callback
  1763. * @param {scope} scope
  1764. */
  1765. forEach = function(array, callback, scope) {
  1766. for (var i = 0; i < array.length; i++) {
  1767. callback.call(scope, i, array[i]);
  1768. }
  1769. };
  1770. var nav, opts, navToggle, styleElement = document.createElement("style"),
  1771. htmlEl = document.documentElement,
  1772. hasAnimFinished,
  1773. isMobile,
  1774. navOpen;
  1775. var ResponsiveNav = function(el, options) {
  1776. var i;
  1777. /**
  1778. * Default options
  1779. * @type {Object}
  1780. */
  1781. this.options = {
  1782. animate: true,
  1783. // Boolean: Use CSS3 transitions, true or false
  1784. transition: 284,
  1785. // Integer: Speed of the transition, in milliseconds
  1786. label: "Menu",
  1787. // String: Label for the navigation toggle
  1788. insert: "before",
  1789. // String: Insert the toggle before or after the navigation
  1790. customToggle: "",
  1791. // Selector: Specify the ID of a custom toggle
  1792. closeOnNavClick: false,
  1793. // Boolean: Close the navigation when one of the links are clicked
  1794. openPos: "relative",
  1795. // String: Position of the opened nav, relative or static
  1796. navClass: "nav-collapse",
  1797. // String: Default CSS class. If changed, you need to edit the CSS too!
  1798. navActiveClass: "js-nav-active",
  1799. // String: Class that is added to <html> element when nav is active
  1800. jsClass: "js",
  1801. // String: 'JS enabled' class which is added to <html> element
  1802. init: function() {},
  1803. // Function: Init callback
  1804. open: function() {},
  1805. // Function: Open callback
  1806. close: function() {} // Function: Close callback
  1807. };
  1808. // User defined options
  1809. for (i in options) {
  1810. this.options[i] = options[i];
  1811. }
  1812. // Adds "js" class for <html>
  1813. addClass(htmlEl, this.options.jsClass);
  1814. // Wrapper
  1815. this.wrapperEl = el.replace("#", "");
  1816. // Try selecting ID first
  1817. if (document.getElementById(this.wrapperEl)) {
  1818. this.wrapper = document.getElementById(this.wrapperEl);
  1819. // If element with an ID doesn't exist, use querySelector
  1820. } else if (document.querySelector(this.wrapperEl)) {
  1821. this.wrapper = document.querySelector(this.wrapperEl);
  1822. // If element doesn't exists, stop here.
  1823. } else {
  1824. throw new Error("The nav element you are trying to select doesn't exist");
  1825. }
  1826. // Inner wrapper
  1827. this.wrapper.inner = getChildren(this.wrapper);
  1828. // For minification
  1829. opts = this.options;
  1830. nav = this.wrapper;
  1831. // Init
  1832. this._init(this);
  1833. };
  1834. ResponsiveNav.prototype = {
  1835. /**
  1836. * Unattaches events and removes any classes that were added
  1837. */
  1838. destroy: function() {
  1839. this._removeStyles();
  1840. removeClass(nav, "closed");
  1841. removeClass(nav, "opened");
  1842. removeClass(nav, opts.navClass);
  1843. removeClass(nav, opts.navClass + "-" + this.index);
  1844. removeClass(htmlEl, opts.navActiveClass);
  1845. nav.removeAttribute("style");
  1846. nav.removeAttribute("aria-hidden");
  1847. removeEvent(window, "resize", this, false);
  1848. removeEvent(window, "focus", this, false);
  1849. removeEvent(document.body, "touchmove", this, false);
  1850. removeEvent(navToggle, "touchstart", this, false);
  1851. removeEvent(navToggle, "touchend", this, false);
  1852. removeEvent(navToggle, "mouseup", this, false);
  1853. removeEvent(navToggle, "keyup", this, false);
  1854. removeEvent(navToggle, "click", this, false);
  1855. if (!opts.customToggle) {
  1856. navToggle.parentNode.removeChild(navToggle);
  1857. } else {
  1858. navToggle.removeAttribute("aria-hidden");
  1859. }
  1860. },
  1861. /**
  1862. * Toggles the navigation open/close
  1863. */
  1864. toggle: function() {
  1865. if (hasAnimFinished === true) {
  1866. if (!navOpen) {
  1867. this.open();
  1868. } else {
  1869. this.close();
  1870. }
  1871. }
  1872. },
  1873. /**
  1874. * Opens the navigation
  1875. */
  1876. open: function() {
  1877. if (!navOpen) {
  1878. removeClass(nav, "closed");
  1879. addClass(nav, "opened");
  1880. addClass(htmlEl, opts.navActiveClass);
  1881. addClass(navToggle, "active");
  1882. nav.style.position = opts.openPos;
  1883. setAttributes(nav, {
  1884. "aria-hidden": "false"
  1885. });
  1886. navOpen = true;
  1887. opts.open();
  1888. }
  1889. },
  1890. /**
  1891. * Closes the navigation
  1892. */
  1893. close: function() {
  1894. if (navOpen) {
  1895. addClass(nav, "closed");
  1896. removeClass(nav, "opened");
  1897. removeClass(htmlEl, opts.navActiveClass);
  1898. removeClass(navToggle, "active");
  1899. setAttributes(nav, {
  1900. "aria-hidden": "true"
  1901. });
  1902. // If animations are enabled, wait until they finish
  1903. if (opts.animate) {
  1904. hasAnimFinished = false;
  1905. setTimeout(function() {
  1906. nav.style.position = "absolute";
  1907. hasAnimFinished = true;
  1908. },
  1909. opts.transition + 10);
  1910. // Animations aren't enabled, we can do these immediately
  1911. } else {
  1912. nav.style.position = "absolute";
  1913. }
  1914. navOpen = false;
  1915. opts.close();
  1916. }
  1917. },
  1918. /**
  1919. * Resize is called on window resize and orientation change.
  1920. * It initializes the CSS styles and height calculations.
  1921. */
  1922. resize: function() {
  1923. // Resize watches navigation toggle's display state
  1924. if (window.getComputedStyle(navToggle, null).getPropertyValue("display") !== "none") {
  1925. isMobile = true;
  1926. setAttributes(navToggle, {
  1927. "aria-hidden": "false"
  1928. });
  1929. // If the navigation is hidden
  1930. if (nav.className.match(/(^|\s)closed(\s|$)/)) {
  1931. setAttributes(nav, {
  1932. "aria-hidden": "true"
  1933. });
  1934. nav.style.position = "absolute";
  1935. }
  1936. this._createStyles();
  1937. this._calcHeight();
  1938. } else {
  1939. isMobile = false;
  1940. setAttributes(navToggle, {
  1941. "aria-hidden": "true"
  1942. });
  1943. setAttributes(nav, {
  1944. "aria-hidden": "false"
  1945. });
  1946. nav.style.position = opts.openPos;
  1947. this._removeStyles();
  1948. }
  1949. },
  1950. /**
  1951. * Takes care of all even handling
  1952. *
  1953. * @param {event} event
  1954. * @return {type} returns the type of event that should be used
  1955. */
  1956. handleEvent: function(e) {
  1957. var evt = e || window.event;
  1958. switch (evt.type) {
  1959. case "touchstart":
  1960. this._onTouchStart(evt);
  1961. break;
  1962. case "touchmove":
  1963. this._onTouchMove(evt);
  1964. break;
  1965. case "touchend":
  1966. case "mouseup":
  1967. this._onTouchEnd(evt);
  1968. break;
  1969. case "click":
  1970. this._preventDefault(evt);
  1971. break;
  1972. case "keyup":
  1973. this._onKeyUp(evt);
  1974. break;
  1975. case "focus":
  1976. case "resize":
  1977. this.resize(evt);
  1978. break;
  1979. }
  1980. },
  1981. /**
  1982. * Initializes the widget
  1983. */
  1984. _init: function() {
  1985. this.index = index++;
  1986. addClass(nav, opts.navClass);
  1987. addClass(nav, opts.navClass + "-" + this.index);
  1988. addClass(nav, "closed");
  1989. hasAnimFinished = true;
  1990. navOpen = false;
  1991. this._closeOnNavClick();
  1992. this._createToggle();
  1993. this._transitions();
  1994. this.resize();
  1995. /**
  1996. * On IE8 the resize event triggers too early for some reason
  1997. * so it's called here again on init to make sure all the
  1998. * calculated styles are correct.
  1999. */
  2000. var self = this;
  2001. setTimeout(function() {
  2002. self.resize();
  2003. },
  2004. 20);
  2005. addEvent(window, "resize", this, false);
  2006. addEvent(window, "focus", this, false);
  2007. addEvent(document.body, "touchmove", this, false);
  2008. addEvent(navToggle, "touchstart", this, false);
  2009. addEvent(navToggle, "touchend", this, false);
  2010. addEvent(navToggle, "mouseup", this, false);
  2011. addEvent(navToggle, "keyup", this, false);
  2012. addEvent(navToggle, "click", this, false);
  2013. /**
  2014. * Init callback here
  2015. */
  2016. opts.init();
  2017. },
  2018. /**
  2019. * Creates Styles to the <head>
  2020. */
  2021. _createStyles: function() {
  2022. if (!styleElement.parentNode) {
  2023. styleElement.type = "text/css";
  2024. document.getElementsByTagName("head")[0].appendChild(styleElement);
  2025. }
  2026. },
  2027. /**
  2028. * Removes styles from the <head>
  2029. */
  2030. _removeStyles: function() {
  2031. if (styleElement.parentNode) {
  2032. styleElement.parentNode.removeChild(styleElement);
  2033. }
  2034. },
  2035. /**
  2036. * Creates Navigation Toggle
  2037. */
  2038. _createToggle: function() {
  2039. // If there's no toggle, let's create one
  2040. if (!opts.customToggle) {
  2041. var toggle = document.createElement("a");
  2042. toggle.innerHTML = opts.label;
  2043. setAttributes(toggle, {
  2044. "href": "#",
  2045. "class": "nav-toggle"
  2046. });
  2047. // Determine where to insert the toggle
  2048. if (opts.insert === "after") {
  2049. nav.parentNode.insertBefore(toggle, nav.nextSibling);
  2050. } else {
  2051. nav.parentNode.insertBefore(toggle, nav);
  2052. }
  2053. navToggle = toggle;
  2054. // There is a toggle already, let's use that one
  2055. } else {
  2056. var toggleEl = opts.customToggle.replace("#", "");
  2057. if (document.getElementById(toggleEl)) {
  2058. navToggle = document.getElementById(toggleEl);
  2059. } else if (document.querySelector(toggleEl)) {
  2060. navToggle = document.querySelector(toggleEl);
  2061. } else {
  2062. throw new Error("The custom nav toggle you are trying to select doesn't exist");
  2063. }
  2064. }
  2065. },
  2066. /**
  2067. * Closes the navigation when a link inside is clicked.
  2068. */
  2069. _closeOnNavClick: function() {
  2070. if (opts.closeOnNavClick) {
  2071. var links = nav.getElementsByTagName("a"),
  2072. self = this;
  2073. forEach(links,
  2074. function(i, el) {
  2075. addEvent(links[i], "click",
  2076. function() {
  2077. if (isMobile) {
  2078. self.toggle();
  2079. }
  2080. },
  2081. false);
  2082. });
  2083. }
  2084. },
  2085. /**
  2086. * Prevents the default functionality.
  2087. *
  2088. * @param {event} event
  2089. */
  2090. _preventDefault: function(e) {
  2091. if (e.preventDefault) {
  2092. if (e.stopImmediatePropagation) {
  2093. e.stopImmediatePropagation();
  2094. }
  2095. e.preventDefault();
  2096. e.stopPropagation();
  2097. return false;
  2098. // This is strictly for old IE
  2099. } else {
  2100. e.returnValue = false;
  2101. }
  2102. },
  2103. /**
  2104. * On touch start we get the location of the touch.
  2105. *
  2106. * @param {event} event
  2107. */
  2108. _onTouchStart: function(e) {
  2109. if (!Event.prototype.stopImmediatePropagation) {
  2110. this._preventDefault(e);
  2111. }
  2112. this.startX = e.touches[0].clientX;
  2113. this.startY = e.touches[0].clientY;
  2114. this.touchHasMoved = false;
  2115. /**
  2116. * Remove mouseup event completely here to avoid
  2117. * double triggering the event.
  2118. */
  2119. removeEvent(navToggle, "mouseup", this, false);
  2120. },
  2121. /**
  2122. * Check if the user is scrolling instead of tapping.
  2123. *
  2124. * @param {event} event
  2125. */
  2126. _onTouchMove: function(e) {
  2127. if (Math.abs(e.touches[0].clientX - this.startX) > 10 || Math.abs(e.touches[0].clientY - this.startY) > 10) {
  2128. this.touchHasMoved = true;
  2129. }
  2130. },
  2131. /**
  2132. * On touch end toggle the navigation.
  2133. *
  2134. * @param {event} event
  2135. */
  2136. _onTouchEnd: function(e) {
  2137. this._preventDefault(e);
  2138. if (!isMobile) {
  2139. return;
  2140. }
  2141. // If the user isn't scrolling
  2142. if (!this.touchHasMoved) {
  2143. // If the event type is touch
  2144. if (e.type === "touchend") {
  2145. this.toggle();
  2146. return;
  2147. // Event type was click, not touch
  2148. } else {
  2149. var evt = e || window.event;
  2150. // If it isn't a right click, do toggling
  2151. if (! (evt.which === 3 || evt.button === 2)) {
  2152. this.toggle();
  2153. }
  2154. }
  2155. }
  2156. },
  2157. /**
  2158. * For keyboard accessibility, toggle the navigation on Enter
  2159. * keypress too.
  2160. *
  2161. * @param {event} event
  2162. */
  2163. _onKeyUp: function(e) {
  2164. var evt = e || window.event;
  2165. if (evt.keyCode === 13) {
  2166. this.toggle();
  2167. }
  2168. },
  2169. /**
  2170. * Adds the needed CSS transitions if animations are enabled
  2171. */
  2172. _transitions: function() {
  2173. if (opts.animate) {
  2174. var objStyle = nav.style,
  2175. transition = "max-height " + opts.transition + "ms";
  2176. objStyle.WebkitTransition = objStyle.MozTransition = objStyle.OTransition = objStyle.transition = transition;
  2177. }
  2178. },
  2179. /**
  2180. * Calculates the height of the navigation and then creates
  2181. * styles which are later added to the page <head>
  2182. */
  2183. _calcHeight: function() {
  2184. var savedHeight = 0;
  2185. for (var i = 0; i < nav.inner.length; i++) {
  2186. savedHeight += nav.inner[i].offsetHeight;
  2187. }
  2188. 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}";
  2189. if (styleElement.styleSheet) {
  2190. styleElement.styleSheet.cssText = innerStyles;
  2191. } else {
  2192. styleElement.innerHTML = innerStyles;
  2193. }
  2194. innerStyles = "";
  2195. }
  2196. };
  2197. /**
  2198. * Return new Responsive Nav
  2199. */
  2200. return new ResponsiveNav(el, options);
  2201. };
  2202. if (typeof module !== "undefined" && module.exports) {
  2203. module.exports = responsiveNav;
  2204. } else {
  2205. window.responsiveNav = responsiveNav;
  2206. }
  2207. } (document, window, 0));
  2208. /* =======================================================================
  2209. * jQuery.placeholder.js 兼容性处理
  2210. * ======================================================================== */
  2211. !function(window, document, $) {
  2212. var isInputSupported = 'placeholder' in document.createElement('input');
  2213. var isTextareaSupported = 'placeholder' in document.createElement('textarea');
  2214. var prototype = $.fn;
  2215. var valHooks = $.valHooks;
  2216. var propHooks = $.propHooks;
  2217. var hooks;
  2218. var placeholder;
  2219. if (isInputSupported && isTextareaSupported) {
  2220. placeholder = prototype.placeholder = function() {
  2221. return this;
  2222. };
  2223. placeholder.input = placeholder.textarea = true;
  2224. } else {
  2225. placeholder = prototype.placeholder = function() {
  2226. var $this = this;
  2227. $this.filter((isInputSupported ? 'textarea': ':input') + '[placeholder]').not('.placeholder').on({
  2228. 'focus.placeholder': clearPlaceholder,
  2229. 'blur.placeholder': setPlaceholder
  2230. }).data('placeholder-enabled', true).trigger('blur.placeholder');
  2231. return $this;
  2232. };
  2233. placeholder.input = isInputSupported;
  2234. placeholder.textarea = isTextareaSupported;
  2235. hooks = {
  2236. 'get': function(element) {
  2237. var $element = $(element);
  2238. var $passwordInput = $element.data('placeholder-password');
  2239. if ($passwordInput) {
  2240. return $passwordInput[0].value;
  2241. }
  2242. return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '': element.value;
  2243. },
  2244. 'set': function(element, value) {
  2245. var $element = $(element);
  2246. var $passwordInput = $element.data('placeholder-password');
  2247. if ($passwordInput) {
  2248. return $passwordInput[0].value = value;
  2249. }
  2250. if (!$element.data('placeholder-enabled')) {
  2251. return element.value = value;
  2252. }
  2253. if (value == '') {
  2254. element.value = value;
  2255. if (element != safeActiveElement()) {
  2256. setPlaceholder.call(element);
  2257. }
  2258. } else if ($element.hasClass('placeholder')) {
  2259. clearPlaceholder.call(element, true, value) || (element.value = value);
  2260. } else {
  2261. element.value = value;
  2262. }
  2263. return $element;
  2264. }
  2265. };
  2266. if (!isInputSupported) {
  2267. valHooks.input = hooks;
  2268. propHooks.value = hooks;
  2269. }
  2270. if (!isTextareaSupported) {
  2271. valHooks.textarea = hooks;
  2272. propHooks.value = hooks;
  2273. }
  2274. $(function() {
  2275. $(document).delegate('form', 'submit.placeholder',
  2276. function() {
  2277. var $inputs = $('.placeholder', this).each(clearPlaceholder);
  2278. setTimeout(function() {
  2279. $inputs.each(setPlaceholder);
  2280. },
  2281. 10);
  2282. });
  2283. });
  2284. $(window).on('beforeunload.placeholder',
  2285. function() {
  2286. $('.placeholder').each(function() {
  2287. this.value = '';
  2288. });
  2289. });
  2290. }
  2291. function args(elem) {
  2292. var newAttrs = {};
  2293. var rinlinejQuery = /^jQuery\d+$/;
  2294. $.each(elem.attributes,
  2295. function(i, attr) {
  2296. if (attr.specified && !rinlinejQuery.test(attr.name)) {
  2297. newAttrs[attr.name] = attr.value;
  2298. }
  2299. });
  2300. return newAttrs;
  2301. }
  2302. function clearPlaceholder(event, value) {
  2303. var input = this;
  2304. var $input = $(input);
  2305. if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
  2306. if ($input.data('placeholder-password')) {
  2307. $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
  2308. if (event === true) {
  2309. return $input[0].value = value;
  2310. }
  2311. $input.focus();
  2312. } else {
  2313. input.value = '';
  2314. $input.removeClass('placeholder');
  2315. input == safeActiveElement() && input.select();
  2316. }
  2317. }
  2318. }
  2319. function setPlaceholder() {
  2320. var $replacement;
  2321. var input = this;
  2322. var $input = $(input);
  2323. var id = this.id;
  2324. if (input.value == '') {
  2325. if (input.type == 'password') {
  2326. if (!$input.data('placeholder-textinput')) {
  2327. try {
  2328. $replacement = $input.clone().prop('type', 'text');
  2329. } catch(e) {
  2330. $replacement = $('<input>').prop($.extend(args(this), {
  2331. 'type': 'text'
  2332. }));
  2333. }
  2334. $replacement.removeAttr('name').data({
  2335. 'placeholder-password': $input,
  2336. 'placeholder-id': id
  2337. }).on('focus.placeholder', clearPlaceholder);
  2338. $input.data({
  2339. 'placeholder-textinput': $replacement,
  2340. 'placeholder-id': id
  2341. }).before($replacement);
  2342. }
  2343. $input = $input.removeAttr('id').hide().prev().attr('id', id).show();
  2344. }
  2345. $input.addClass('placeholder');
  2346. $input[0].value = $input.attr('placeholder');
  2347. } else {
  2348. $input.removeClass('placeholder');
  2349. }
  2350. }
  2351. function safeActiveElement() {
  2352. try {
  2353. return document.activeElement;
  2354. } catch(exception) {}
  2355. }
  2356. } (this, document, jQuery);
  2357. /* =======================================================================
  2358. * jquery.emailsuggest.js v1.0 邮箱自动提示
  2359. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2360. * ======================================================================== */
  2361. !function($) {
  2362. var
  2363. // 插件名
  2364. plugin = 'emailsuggest',
  2365. // 默认参数配置
  2366. defaults = {
  2367. sugClass: 'emailSug',
  2368. domains: ['163.com', '126.com', 'sohu.com', '139.com', 'sina.com', 'qq.com', 'gmail.com']
  2369. };
  2370. function EmailSug(elem, options) {
  2371. this.$field = $(elem);
  2372. this.options = $.extend(true, {},
  2373. defaults, options);
  2374. this._defaults = defaults;
  2375. this._domains = this.options.domains;
  2376. // 当前选中元素下标
  2377. this.selectedIndex = 0;
  2378. this.init();
  2379. }
  2380. EmailSug.prototype = {
  2381. init: function() {
  2382. this.addEvent();
  2383. },
  2384. addEvent: function() {
  2385. var that = this,
  2386. value;
  2387. this.$field.on('keyup.ema',
  2388. function(e) {
  2389. value = $.trim(this.value);
  2390. if (value) {
  2391. that.create(this, value);
  2392. that.doSelect(e.keyCode);
  2393. } else {
  2394. that.hide();
  2395. }
  2396. }).on('blur.ema',
  2397. function() {
  2398. setTimeout(function() {
  2399. that.hide();
  2400. },
  2401. 200);
  2402. });
  2403. },
  2404. create: function(elem, value) {
  2405. var that = this,
  2406. arr, len, fragment, ul = [],
  2407. offset,
  2408. left,
  2409. top,
  2410. width,
  2411. height,
  2412. style,
  2413. // 左右边框
  2414. borderWidth = 2;
  2415. elem = $(elem);
  2416. offset = elem.offset();
  2417. width = elem.outerWidth(true) - borderWidth;
  2418. height = elem.outerHeight(true);
  2419. left = offset.left;
  2420. top = offset.top + height;
  2421. style = 'left: ' + left + 'px; top: ' + top + 'px; width: ' + width + 'px; border: 1px solid #e2e2e2; border-top: 0; display: none';
  2422. fragment = $('<div class="' + this.options.sugClass + '-wrapper" style="' + style + '" />');
  2423. ul.push('<ul class="' + this.options.sugClass + '-list">');
  2424. arr = this.filter(value, this._domains);
  2425. len = arr.length;
  2426. $.each(arr,
  2427. function(i, domain) {
  2428. var _class = that.options.sugClass + '-item';
  2429. if (that.selectedIndex > len - 1) {
  2430. if (i === 0) {
  2431. _class += ' active';
  2432. that.selectedIndex = 0;
  2433. }
  2434. } else {
  2435. if (i === that.selectedIndex) {
  2436. _class += ' active';
  2437. }
  2438. }
  2439. ul.push('<li class="' + _class + '" data-index="' + i + '">' + value.replace(/@.*/, '') + '@' + domain + '</li>');
  2440. });
  2441. ul.push('</ul>');
  2442. ul = ul.join('');
  2443. if (this.$suggest) {
  2444. this.$suggest.empty();
  2445. this.$suggest.append(ul);
  2446. } else {
  2447. fragment.append(ul);
  2448. // 显示到页面
  2449. $('body').append(fragment);
  2450. this.$suggest = fragment;
  2451. this.$suggest.on('mouseenter click', '.' + this.options.sugClass + '-item',
  2452. function(e) {
  2453. var lis, li;
  2454. li = $(this);
  2455. lis = li.parent().children();
  2456. if (e.type === 'mouseenter') {
  2457. li.addClass('active').siblings().removeClass('active');
  2458. that.selectedIndex = $.inArray(this, lis);
  2459. } else {
  2460. // 当前选中
  2461. that.$field.val(lis.eq(that.selectedIndex).text());
  2462. // 隐藏email sug
  2463. that.hide();
  2464. }
  2465. });
  2466. }
  2467. this.show();
  2468. },
  2469. doSelect: function(keyCode) {
  2470. var elems = $('.' + this.options.sugClass + '-item', this.$suggest),
  2471. min = 0,
  2472. max = elems.length - 1;
  2473. switch (keyCode) {
  2474. case 13:
  2475. // 回车选中当前已选项
  2476. $('li.active', this.$suggest).trigger('click');
  2477. // 下标重置
  2478. this.selectedIndex = 0;
  2479. break;
  2480. // 向上
  2481. case 38:
  2482. this.selectedIndex--;
  2483. if (this.selectedIndex < min) {
  2484. this.selectedIndex = max;
  2485. }
  2486. elems.removeClass('active').eq(this.selectedIndex).addClass('active');
  2487. break;
  2488. // 向下
  2489. case 40:
  2490. this.selectedIndex++;
  2491. if (this.selectedIndex > max) {
  2492. this.selectedIndex = min;
  2493. }
  2494. elems.removeClass('active').eq(this.selectedIndex).addClass('active');
  2495. break;
  2496. default:
  2497. break;
  2498. }
  2499. },
  2500. filter: function(value, arr) {
  2501. var start, suffix, r = [];
  2502. start = value.indexOf('@');
  2503. if (start > -1) {
  2504. suffix = value.substring(start + 1);
  2505. $.each(arr,
  2506. function(i, str) {
  2507. if (str.indexOf(suffix) > -1) {
  2508. r.push(str);
  2509. }
  2510. });
  2511. } else {
  2512. r = arr;
  2513. }
  2514. return r;
  2515. },
  2516. show: function() {
  2517. if (this.$suggest) {
  2518. this.$suggest.show();
  2519. }
  2520. },
  2521. hide: function() {
  2522. if (this.$suggest) {
  2523. this.$suggest.hide();
  2524. }
  2525. }
  2526. }
  2527. $.fn[plugin] = function(options) {
  2528. return this.each(function() {
  2529. if (!$.data(this, plugin)) {
  2530. $.data(this, plugin, new EmailSug(this, options));
  2531. }
  2532. });
  2533. }
  2534. } (window.jQuery);
  2535. /* =======================================================================
  2536. * jQuery.Huispinner.js v2.1.2 微调器
  2537. * http://www.h-ui.net/
  2538. * Created & Modified by guojunhui
  2539. * Date modified 2017.06.26
  2540. *
  2541. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  2542. * Licensed under MIT license.
  2543. * http://opensource.org/licenses/MIT
  2544. * ========================================================================*/
  2545. !function($) {
  2546. $.fn.Huispinner = function(options, callback) {
  2547. var defaults = {
  2548. value : 1,
  2549. minValue : 1,
  2550. maxValue : 999,
  2551. dis : 1,
  2552. }
  2553. var options = $.extend(defaults, options);
  2554. var keyCodes = {
  2555. up : 38,
  2556. down : 40
  2557. }
  2558. this.each(function() {
  2559. var that = $(this);
  2560. var str = '<div class="spinner">'
  2561. + '<a class="subtract" href="javascript:void(0)"><i>-</i></a>'
  2562. + '<input class="amount input-text" value="'
  2563. + options.value + '" autocomplete="off">'
  2564. + '<a class="add" href="javascript:void(0)"><i>+</i></a>'
  2565. + '</div>';
  2566. that.append(str);
  2567. var input = that.find(".input-text"),
  2568. subtract = that.find(".subtract"),
  2569. add = that.find(".add"),
  2570. value = parseInt(input.val());
  2571. if (value <= options.minValue) {
  2572. subtract.addClass("disabled");
  2573. add.removeClass("disabled");
  2574. }
  2575. if (value >= options.maxValue) {
  2576. subtract.removeClass("disabled");
  2577. add.addClass("disabled");
  2578. }
  2579. // 输入框失去焦点
  2580. input.on('blur', function() {
  2581. var v = $(this).val();
  2582. v = v.replace(/[^\d]/g, "");
  2583. v = v.replace(/\b(0+)/gi, "");
  2584. if (v != "") {
  2585. if (v > options.minValue && v < options.maxValue) {
  2586. input.val(v)
  2587. add.removeClass("disabled");
  2588. subtract.removeClass("disabled");
  2589. } else {
  2590. if (v <= options.minValue) {
  2591. input.val(options.minValue);
  2592. subtract.addClass("disabled");
  2593. add.removeClass("disabled");
  2594. } else {
  2595. input.val(options.maxValue);
  2596. subtract.removeClass("disabled");
  2597. add.addClass("disabled");
  2598. }
  2599. }
  2600. } else {
  2601. $(this).val(options.minValue);
  2602. subtract.addClass("disabled");
  2603. add.removeClass("disabled");
  2604. }
  2605. if (callback) {
  2606. callback(input.val());
  2607. }
  2608. });
  2609. // 上下方向键
  2610. input.on("keydown", function(e) {
  2611. var evt = e || window.event;
  2612. if (evt.keyCode === keyCodes.up) {
  2613. subtract.trigger("click");
  2614. evt.returnValue = false;
  2615. }
  2616. if (evt.keyCode === keyCodes.down) {
  2617. add.trigger("click");
  2618. evt.returnValue = false;
  2619. }
  2620. });
  2621. // 减
  2622. subtract.on('click', function() {
  2623. var goodsCount = parseInt(input.val());
  2624. input.val(goodsCount <= options.minValue
  2625. ? options.minValue
  2626. : goodsCount - options.dis);
  2627. add.removeClass("disabled");
  2628. if (input.val() <= options.minValue) {
  2629. input.val(options.minValue)
  2630. subtract.addClass("disabled");
  2631. }
  2632. if (callback) {
  2633. callback(input.val());
  2634. }
  2635. });
  2636. // 加
  2637. add.on('click', function() {
  2638. var goodsCount = parseInt(input.val());
  2639. input.val(goodsCount >= options.maxValue
  2640. ? options.maxValue
  2641. : goodsCount + options.dis);
  2642. subtract.removeClass("disabled");
  2643. if (input.val() >= options.maxValue) {
  2644. input.val(options.maxValue);
  2645. add.addClass("disabled");
  2646. }
  2647. if (callback) {
  2648. callback(input.val());
  2649. }
  2650. });
  2651. });
  2652. }
  2653. }(window.jQuery);
  2654. /* =======================================================================
  2655. * jQuery.format.js 金额格式化
  2656. * ========================================================================*/
  2657. !function($) {
  2658. $.extend({
  2659. format: function(str, step, splitor) {
  2660. str = str.toString();
  2661. var len = str.length;
  2662. if (len > step) {
  2663. var l1 = len % step,
  2664. l2 = parseInt(len / step),
  2665. arr = [],
  2666. first = str.substr(0, l1);
  2667. if (first != '') {
  2668. arr.push(first);
  2669. };
  2670. for (var i = 0; i < l2; i++) {
  2671. arr.push(str.substr(l1 + i * step, step));
  2672. };
  2673. str = arr.join(splitor);
  2674. };
  2675. return str;
  2676. }
  2677. });
  2678. } (window.jQuery);
  2679. /* =======================================================================
  2680. * jquery.togglePassword.js 隐藏显示密码
  2681. * type="password"
  2682. * ========================================================================*/
  2683. !function($) {
  2684. $.fn.togglePassword = function(options) {
  2685. var s = $.extend($.fn.togglePassword.defaults, options),
  2686. input = $(this);
  2687. $(s.el).on(s.ev,
  2688. function() {
  2689. "password" == $(input).attr("type") ? $(input).attr("type", "text") : $(input).attr("type", "password");
  2690. });
  2691. };
  2692. $.fn.togglePassword.defaults = {
  2693. ev: "click"
  2694. };
  2695. } (window.jQuery);
  2696. /* =======================================================================
  2697. * jQuery.iCheck.js v1.0.2, http://git.io/arlzeA
  2698. * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization
  2699. *
  2700. * (c) 2013 Damir Sultanov, http://fronteed.com
  2701. * MIT Licensed
  2702. * ======================================================================== */
  2703. !(function($) {
  2704. // Cached vars
  2705. var _iCheck = 'iCheck',
  2706. _iCheckHelper = _iCheck + '-helper',
  2707. _checkbox = 'checkbox',
  2708. _radio = 'radio',
  2709. _checked = 'checked',
  2710. _unchecked = 'un' + _checked,
  2711. _disabled = 'disabled',
  2712. _determinate = 'determinate',
  2713. _indeterminate = 'in' + _determinate,
  2714. _update = 'update',
  2715. _type = 'type',
  2716. _click = 'click',
  2717. _touch = 'touchbegin.i touchend.i',
  2718. _add = 'addClass',
  2719. _remove = 'removeClass',
  2720. _callback = 'trigger',
  2721. _label = 'label',
  2722. _cursor = 'cursor',
  2723. _mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
  2724. // Plugin init
  2725. $.fn[_iCheck] = function(options, fire) {
  2726. // Walker
  2727. var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
  2728. stack = $(),
  2729. walker = function(object) {
  2730. object.each(function() {
  2731. var self = $(this);
  2732. if (self.is(handle)) {
  2733. stack = stack.add(self);
  2734. } else {
  2735. stack = stack.add(self.find(handle));
  2736. }
  2737. });
  2738. };
  2739. // Check if we should operate with some method
  2740. if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
  2741. // Normalize method's name
  2742. options = options.toLowerCase();
  2743. // Find checkboxes and radio buttons
  2744. walker(this);
  2745. return stack.each(function() {
  2746. var self = $(this);
  2747. if (options == 'destroy') {
  2748. tidy(self, 'ifDestroyed');
  2749. } else {
  2750. operate(self, true, options);
  2751. }
  2752. // Fire method's callback
  2753. if ($.isFunction(fire)) {
  2754. fire();
  2755. }
  2756. });
  2757. // Customization
  2758. } else if (typeof options == 'object' || !options) {
  2759. // Check if any options were passed
  2760. var settings = $.extend({
  2761. checkedClass: _checked,
  2762. disabledClass: _disabled,
  2763. indeterminateClass: _indeterminate,
  2764. labelHover: true
  2765. },
  2766. options),
  2767. selector = settings.handle,
  2768. hoverClass = settings.hoverClass || 'hover',
  2769. focusClass = settings.focusClass || 'focus',
  2770. activeClass = settings.activeClass || 'active',
  2771. labelHover = !!settings.labelHover,
  2772. labelHoverClass = settings.labelHoverClass || 'hover',
  2773. // Setup clickable area
  2774. area = ('' + settings.increaseArea).replace('%', '') | 0;
  2775. // Selector limit
  2776. if (selector == _checkbox || selector == _radio) {
  2777. handle = 'input[type="' + selector + '"]';
  2778. }
  2779. // Clickable area limit
  2780. if (area < -50) {
  2781. area = -50;
  2782. }
  2783. // Walk around the selector
  2784. walker(this);
  2785. return stack.each(function() {
  2786. var self = $(this);
  2787. // If already customized
  2788. tidy(self);
  2789. var node = this,
  2790. id = node.id,
  2791. // Layer styles
  2792. offset = -area + '%',
  2793. size = 100 + (area * 2) + '%',
  2794. layer = {
  2795. position: 'absolute',
  2796. top: offset,
  2797. left: offset,
  2798. display: 'block',
  2799. width: size,
  2800. height: size,
  2801. margin: 0,
  2802. padding: 0,
  2803. background: '#fff',
  2804. border: 0,
  2805. opacity: 0
  2806. },
  2807. // Choose how to hide input
  2808. hide = _mobile ? {
  2809. position: 'absolute',
  2810. visibility: 'hidden'
  2811. }: area ? layer: {
  2812. position: 'absolute',
  2813. opacity: 0
  2814. },
  2815. // Get proper class
  2816. className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox: settings.radioClass || 'i' + _radio,
  2817. // Find assigned labels
  2818. label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
  2819. // Check ARIA option
  2820. aria = !!settings.aria,
  2821. // Set ARIA placeholder
  2822. ariaID = _iCheck + '-' + Math.random().toString(36).substr(2, 6),
  2823. // Parent & helper
  2824. parent = '<div class="' + className + '" ' + (aria ? 'role="' + node[_type] + '" ': ''),
  2825. helper;
  2826. // Set ARIA "labelledby"
  2827. if (aria) {
  2828. label.each(function() {
  2829. parent += 'aria-labelledby="';
  2830. if (this.id) {
  2831. parent += this.id;
  2832. } else {
  2833. this.id = ariaID;
  2834. parent += ariaID;
  2835. }
  2836. parent += '"';
  2837. });
  2838. }
  2839. // Wrap input
  2840. parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);
  2841. // Layer addition
  2842. helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);
  2843. // Finalize customization
  2844. self.data(_iCheck, {
  2845. o: settings,
  2846. s: self.attr('style')
  2847. }).css(hide); !! settings.inheritClass && parent[_add](node.className || ''); !! settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
  2848. parent.css('position') == 'static' && parent.css('position', 'relative');
  2849. operate(self, true, _update);
  2850. // Label events
  2851. if (label.length) {
  2852. label.on(_click + '.i mouseover.i mouseout.i ' + _touch,
  2853. function(event) {
  2854. var type = event[_type],
  2855. item = $(this);
  2856. // Do nothing if input is disabled
  2857. if (!node[_disabled]) {
  2858. // Click
  2859. if (type == _click) {
  2860. if ($(event.target).is('a')) {
  2861. return;
  2862. }
  2863. operate(self, false, true);
  2864. // Hover state
  2865. } else if (labelHover) {
  2866. // mouseout|touchend
  2867. if (/ut|nd/.test(type)) {
  2868. parent[_remove](hoverClass);
  2869. item[_remove](labelHoverClass);
  2870. } else {
  2871. parent[_add](hoverClass);
  2872. item[_add](labelHoverClass);
  2873. }
  2874. }
  2875. if (_mobile) {
  2876. event.stopPropagation();
  2877. } else {
  2878. return false;
  2879. }
  2880. }
  2881. });
  2882. }
  2883. // Input events
  2884. self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i',
  2885. function(event) {
  2886. var type = event[_type],
  2887. key = event.keyCode;
  2888. // Click
  2889. if (type == _click) {
  2890. return false;
  2891. // Keydown
  2892. } else if (type == 'keydown' && key == 32) {
  2893. if (! (node[_type] == _radio && node[_checked])) {
  2894. if (node[_checked]) {
  2895. off(self, _checked);
  2896. } else {
  2897. on(self, _checked);
  2898. }
  2899. }
  2900. return false;
  2901. // Keyup
  2902. } else if (type == 'keyup' && node[_type] == _radio) { ! node[_checked] && on(self, _checked);
  2903. // Focus/blur
  2904. } else if (/us|ur/.test(type)) {
  2905. parent[type == 'blur' ? _remove: _add](focusClass);
  2906. }
  2907. });
  2908. // Helper events
  2909. helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch,
  2910. function(event) {
  2911. var type = event[_type],
  2912. // mousedown|mouseup
  2913. toggle = /wn|up/.test(type) ? activeClass: hoverClass;
  2914. // Do nothing if input is disabled
  2915. if (!node[_disabled]) {
  2916. // Click
  2917. if (type == _click) {
  2918. operate(self, false, true);
  2919. // Active and hover states
  2920. } else {
  2921. // State is on
  2922. if (/wn|er|in/.test(type)) {
  2923. // mousedown|mouseover|touchbegin
  2924. parent[_add](toggle);
  2925. // State is off
  2926. } else {
  2927. parent[_remove](toggle + ' ' + activeClass);
  2928. }
  2929. // Label hover
  2930. if (label.length && labelHover && toggle == hoverClass) {
  2931. // mouseout|touchend
  2932. label[/ut|nd/.test(type) ? _remove: _add](labelHoverClass);
  2933. }
  2934. }
  2935. if (_mobile) {
  2936. event.stopPropagation();
  2937. } else {
  2938. return false;
  2939. }
  2940. }
  2941. });
  2942. });
  2943. } else {
  2944. return this;
  2945. }
  2946. };
  2947. // Do something with inputs
  2948. function operate(input, direct, method) {
  2949. var node = input[0],
  2950. state = /er/.test(method) ? _indeterminate: /bl/.test(method) ? _disabled: _checked,
  2951. active = method == _update ? {
  2952. checked: node[_checked],
  2953. disabled: node[_disabled],
  2954. indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
  2955. }: node[state];
  2956. // Check, disable or indeterminate
  2957. if (/^(ch|di|in)/.test(method) && !active) {
  2958. on(input, state);
  2959. // Uncheck, enable or determinate
  2960. } else if (/^(un|en|de)/.test(method) && active) {
  2961. off(input, state);
  2962. // Update
  2963. } else if (method == _update) {
  2964. // Handle states
  2965. for (var each in active) {
  2966. if (active[each]) {
  2967. on(input, each, true);
  2968. } else {
  2969. off(input, each, true);
  2970. }
  2971. }
  2972. } else if (!direct || method == 'toggle') {
  2973. // Helper or label was clicked
  2974. if (!direct) {
  2975. input[_callback]('ifClicked');
  2976. }
  2977. // Toggle checked state
  2978. if (active) {
  2979. if (node[_type] !== _radio) {
  2980. off(input, state);
  2981. }
  2982. } else {
  2983. on(input, state);
  2984. }
  2985. }
  2986. }
  2987. // Add checked, disabled or indeterminate state
  2988. function on(input, state, keep) {
  2989. var node = input[0],
  2990. parent = input.parent(),
  2991. checked = state == _checked,
  2992. indeterminate = state == _indeterminate,
  2993. disabled = state == _disabled,
  2994. callback = indeterminate ? _determinate: checked ? _unchecked: 'enabled',
  2995. regular = option(input, callback + capitalize(node[_type])),
  2996. specific = option(input, state + capitalize(node[_type]));
  2997. // Prevent unnecessary actions
  2998. if (node[state] !== true) {
  2999. // Toggle assigned radio buttons
  3000. if (!keep && state == _checked && node[_type] == _radio && node.name) {
  3001. var form = input.closest('form'),
  3002. inputs = 'input[name="' + node.name + '"]';
  3003. inputs = form.length ? form.find(inputs) : $(inputs);
  3004. inputs.each(function() {
  3005. if (this !== node && $(this).data(_iCheck)) {
  3006. off($(this), state);
  3007. }
  3008. });
  3009. }
  3010. // Indeterminate state
  3011. if (indeterminate) {
  3012. // Add indeterminate state
  3013. node[state] = true;
  3014. // Remove checked state
  3015. if (node[_checked]) {
  3016. off(input, _checked, 'force');
  3017. }
  3018. // Checked or disabled state
  3019. } else {
  3020. // Add checked or disabled state
  3021. if (!keep) {
  3022. node[state] = true;
  3023. }
  3024. // Remove indeterminate state
  3025. if (checked && node[_indeterminate]) {
  3026. off(input, _indeterminate, false);
  3027. }
  3028. }
  3029. // Trigger callbacks
  3030. callbacks(input, checked, state, keep);
  3031. }
  3032. // Add proper cursor
  3033. if (node[_disabled] && !!option(input, _cursor, true)) {
  3034. parent.find('.' + _iCheckHelper).css(_cursor, 'default');
  3035. }
  3036. // Add state class
  3037. parent[_add](specific || option(input, state) || '');
  3038. // Set ARIA attribute
  3039. if ( !! parent.attr('role') && !indeterminate) {
  3040. parent.attr('aria-' + (disabled ? _disabled: _checked), 'true');
  3041. }
  3042. // Remove regular state class
  3043. parent[_remove](regular || option(input, callback) || '');
  3044. }
  3045. // Remove checked, disabled or indeterminate state
  3046. function off(input, state, keep) {
  3047. var node = input[0],
  3048. parent = input.parent(),
  3049. checked = state == _checked,
  3050. indeterminate = state == _indeterminate,
  3051. disabled = state == _disabled,
  3052. callback = indeterminate ? _determinate: checked ? _unchecked: 'enabled',
  3053. regular = option(input, callback + capitalize(node[_type])),
  3054. specific = option(input, state + capitalize(node[_type]));
  3055. // Prevent unnecessary actions
  3056. if (node[state] !== false) {
  3057. // Toggle state
  3058. if (indeterminate || !keep || keep == 'force') {
  3059. node[state] = false;
  3060. }
  3061. // Trigger callbacks
  3062. callbacks(input, checked, callback, keep);
  3063. }
  3064. // Add proper cursor
  3065. if (!node[_disabled] && !!option(input, _cursor, true)) {
  3066. parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
  3067. }
  3068. // Remove state class
  3069. parent[_remove](specific || option(input, state) || '');
  3070. // Set ARIA attribute
  3071. if ( !! parent.attr('role') && !indeterminate) {
  3072. parent.attr('aria-' + (disabled ? _disabled: _checked), 'false');
  3073. }
  3074. // Add regular state class
  3075. parent[_add](regular || option(input, callback) || '');
  3076. }
  3077. // Remove all traces
  3078. function tidy(input, callback) {
  3079. if (input.data(_iCheck)) {
  3080. // Remove everything except input
  3081. input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
  3082. // Callback
  3083. if (callback) {
  3084. input[_callback](callback);
  3085. }
  3086. // Unbind events
  3087. input.off('.i').unwrap();
  3088. $(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
  3089. }
  3090. }
  3091. // Get some option
  3092. function option(input, state, regular) {
  3093. if (input.data(_iCheck)) {
  3094. return input.data(_iCheck).o[state + (regular ? '': 'Class')];
  3095. }
  3096. }
  3097. // Capitalize some string
  3098. function capitalize(string) {
  3099. return string.charAt(0).toUpperCase() + string.slice(1);
  3100. }
  3101. // Executable handlers
  3102. function callbacks(input, checked, callback, keep) {
  3103. if (!keep) {
  3104. if (checked) {
  3105. input[_callback]('ifToggled');
  3106. }
  3107. input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
  3108. }
  3109. }
  3110. })(window.jQuery || window.Zepto);
  3111. /* =======================================================================
  3112. * jQuery.raty.js v2.4.5- A Star Rating Plugin
  3113. * -------------------------------------------------------------------
  3114. * jQuery Raty is a plugin that generates a customizable star rating.
  3115. * Licensed under The MIT License
  3116. *
  3117. * @version 2.4.5
  3118. * @since 2010.06.11
  3119. * @author Washington Botelho
  3120. * @documentation wbotelhos.com/raty
  3121. * @twitter twitter.com/wbotelhos
  3122. *
  3123. * Usage:
  3124. * -------------------------------------------------------------------
  3125. * $('#star').raty();
  3126. * <div id="star"></div>
  3127. * ======================================================================== */
  3128. !(function($) {
  3129. var methods = {
  3130. init: function(settings) {
  3131. return this.each(function() {
  3132. var self = this,
  3133. $this = $(self).empty();
  3134. self.opt = $.extend(true, {},
  3135. $.fn.raty.defaults, settings);
  3136. $this.data('settings', self.opt);
  3137. self.opt.number = methods.between(self.opt.number, 0, 20);
  3138. if (self.opt.path.substring(self.opt.path.length - 1, self.opt.path.length) != '/') {
  3139. self.opt.path += '/';
  3140. }
  3141. if (typeof self.opt.score == 'function') {
  3142. self.opt.score = self.opt.score.call(self);
  3143. }
  3144. if (self.opt.score) {
  3145. self.opt.score = methods.between(self.opt.score, 0, self.opt.number);
  3146. }
  3147. for (var i = 1; i <= self.opt.number; i++) {
  3148. $('<img />', {
  3149. src: self.opt.path + ((!self.opt.score || self.opt.score < i) ? self.opt.starOff: self.opt.starOn),
  3150. alt: i,
  3151. title: (i <= self.opt.hints.length && self.opt.hints[i - 1] !== null) ? self.opt.hints[i - 1] : i
  3152. }).appendTo(self);
  3153. if (self.opt.space) {
  3154. $this.append((i < self.opt.number) ? '': '');
  3155. }
  3156. }
  3157. self.stars = $this.children('img:not(".raty-cancel")');
  3158. self.score = $('<input />', {
  3159. type: 'hidden',
  3160. name: self.opt.scoreName
  3161. }).appendTo(self);
  3162. if (self.opt.score && self.opt.score > 0) {
  3163. self.score.val(self.opt.score);
  3164. methods.roundStar.call(self, self.opt.score);
  3165. }
  3166. if (self.opt.iconRange) {
  3167. methods.fill.call(self, self.opt.score); }
  3168. methods.setTarget.call(self, self.opt.score, self.opt.targetKeep);
  3169. var space = self.opt.space ? 4 : 0,
  3170. width = self.opt.width || (self.opt.number * self.opt.size + self.opt.number * space);
  3171. if (self.opt.cancel) {
  3172. self.cancel = $('<img />', {
  3173. src: self.opt.path + self.opt.cancelOff,
  3174. alt: 'x',
  3175. title: self.opt.cancelHint,
  3176. 'class': 'raty-cancel'
  3177. });
  3178. if (self.opt.cancelPlace == 'left') {
  3179. //$this.prepend('&#160;').prepend(self.cancel);
  3180. } else {
  3181. //$this.append('&#160;').append(self.cancel);
  3182. }
  3183. width += (self.opt.size + space);
  3184. }
  3185. if (self.opt.readOnly) {
  3186. methods.fixHint.call(self);
  3187. if (self.cancel) {
  3188. self.cancel.hide();
  3189. }
  3190. } else {
  3191. $this.css('cursor', 'pointer');
  3192. methods.bindAction.call(self);
  3193. }
  3194. //$this.css('width', width);
  3195. });
  3196. },
  3197. between: function(value, min, max) {
  3198. return Math.min(Math.max(parseFloat(value), min), max);
  3199. },
  3200. bindAction: function() {
  3201. var self = this,
  3202. $this = $(self);
  3203. $this.mouseleave(function() {
  3204. var score = self.score.val() || undefined;
  3205. methods.initialize.call(self, score);
  3206. methods.setTarget.call(self, score, self.opt.targetKeep);
  3207. if (self.opt.mouseover) {
  3208. self.opt.mouseover.call(self, score);
  3209. }
  3210. });
  3211. var action = self.opt.half ? 'mousemove': 'mouseover';
  3212. if (self.opt.cancel) {
  3213. self.cancel.mouseenter(function() {
  3214. $(this).attr('src', self.opt.path + self.opt.cancelOn);
  3215. self.stars.attr('src', self.opt.path + self.opt.starOff);
  3216. methods.setTarget.call(self, null, true);
  3217. if (self.opt.mouseover) {
  3218. self.opt.mouseover.call(self, null);
  3219. }
  3220. }).mouseleave(function() {
  3221. $(this).attr('src', self.opt.path + self.opt.cancelOff);
  3222. if (self.opt.mouseover) {
  3223. self.opt.mouseover.call(self, self.score.val() || null);
  3224. }
  3225. }).click(function(evt) {
  3226. self.score.removeAttr('value');
  3227. if (self.opt.click) {
  3228. self.opt.click.call(self, null, evt);
  3229. }
  3230. });
  3231. }
  3232. self.stars.bind(action,
  3233. function(evt) {
  3234. var value = parseInt(this.alt, 10);
  3235. if (self.opt.half) {
  3236. var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size),
  3237. diff = (position > .5) ? 1 : .5;
  3238. value = parseFloat(this.alt) - 1 + diff;
  3239. methods.fill.call(self, value);
  3240. if (self.opt.precision) {
  3241. value = value - diff + position;
  3242. }
  3243. methods.showHalf.call(self, value);
  3244. } else {
  3245. methods.fill.call(self, value);
  3246. }
  3247. $this.data('score', value);
  3248. methods.setTarget.call(self, value, true);
  3249. if (self.opt.mouseover) {
  3250. self.opt.mouseover.call(self, value, evt);
  3251. }
  3252. }).click(function(evt) {
  3253. self.score.val((self.opt.half || self.opt.precision) ? $this.data('score') : this.alt);
  3254. if (self.opt.click) {
  3255. self.opt.click.call(self, self.score.val(), evt);
  3256. }
  3257. });
  3258. },
  3259. cancel: function(isClick) {
  3260. return $(this).each(function() {
  3261. var self = this,
  3262. $this = $(self);
  3263. if ($this.data('readonly') === true) {
  3264. return this;
  3265. }
  3266. if (isClick) {
  3267. methods.click.call(self, null);
  3268. } else {
  3269. methods.score.call(self, null);
  3270. }
  3271. self.score.removeAttr('value');
  3272. });
  3273. },
  3274. click: function(score) {
  3275. return $(this).each(function() {
  3276. if ($(this).data('readonly') === true) {
  3277. return this;
  3278. }
  3279. methods.initialize.call(this, score);
  3280. if (this.opt.click) {
  3281. this.opt.click.call(this, score);
  3282. } else {
  3283. methods.error.call(this, 'you must add the "click: function(score, evt) { }" callback.');
  3284. }
  3285. methods.setTarget.call(this, score, true);
  3286. });
  3287. },
  3288. error: function(message) {
  3289. $(this).html(message);
  3290. $.error(message);
  3291. },
  3292. fill: function(score) {
  3293. var self = this,
  3294. number = self.stars.length,
  3295. count = 0,
  3296. $star, star, icon;
  3297. for (var i = 1; i <= number; i++) {
  3298. $star = self.stars.eq(i - 1);
  3299. if (self.opt.iconRange && self.opt.iconRange.length > count) {
  3300. star = self.opt.iconRange[count];
  3301. if (self.opt.single) {
  3302. icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
  3303. } else {
  3304. icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
  3305. }
  3306. if (i <= star.range) {
  3307. $star.attr('src', self.opt.path + icon);
  3308. }
  3309. if (i == star.range) {
  3310. count++;
  3311. }
  3312. } else {
  3313. if (self.opt.single) {
  3314. icon = (i == score) ? self.opt.starOn: self.opt.starOff;
  3315. } else {
  3316. icon = (i <= score) ? self.opt.starOn: self.opt.starOff;
  3317. }
  3318. $star.attr('src', self.opt.path + icon);
  3319. }
  3320. }
  3321. },
  3322. fixHint: function() {
  3323. var $this = $(this),
  3324. score = parseInt(this.score.val(), 10),
  3325. hint = this.opt.noRatedMsg;
  3326. if (!isNaN(score) && score > 0) {
  3327. hint = (score <= this.opt.hints.length && this.opt.hints[score - 1] !== null) ? this.opt.hints[score - 1] : score;
  3328. }
  3329. $this.data('readonly', true).css('cursor', 'default').attr('title', hint);
  3330. this.score.attr('readonly', 'readonly');
  3331. this.stars.attr('title', hint);
  3332. },
  3333. getScore: function() {
  3334. var score = [],
  3335. value;
  3336. $(this).each(function() {
  3337. value = this.score.val();
  3338. score.push(value ? parseFloat(value) : undefined);
  3339. });
  3340. return (score.length > 1) ? score: score[0];
  3341. },
  3342. readOnly: function(isReadOnly) {
  3343. return this.each(function() {
  3344. var $this = $(this);
  3345. if ($this.data('readonly') === isReadOnly) {
  3346. return this;
  3347. }
  3348. if (this.cancel) {
  3349. if (isReadOnly) {
  3350. this.cancel.hide();
  3351. } else {
  3352. this.cancel.show();
  3353. }
  3354. }
  3355. if (isReadOnly) {
  3356. $this.unbind();
  3357. $this.children('img').unbind();
  3358. methods.fixHint.call(this);
  3359. } else {
  3360. methods.bindAction.call(this);
  3361. methods.unfixHint.call(this);
  3362. }
  3363. $this.data('readonly', isReadOnly);
  3364. });
  3365. },
  3366. reload: function() {
  3367. return methods.set.call(this, {});
  3368. },
  3369. roundStar: function(score) {
  3370. var diff = (score - Math.floor(score)).toFixed(2);
  3371. if (diff > this.opt.round.down) {
  3372. var icon = this.opt.starOn; // Full up: [x.76 .. x.99]
  3373. if (diff < this.opt.round.up && this.opt.halfShow) { // Half: [x.26 .. x.75]
  3374. icon = this.opt.starHalf;
  3375. } else if (diff < this.opt.round.full) { // Full down: [x.00 .. x.5]
  3376. icon = this.opt.starOff;
  3377. }
  3378. this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + icon);
  3379. } // Full down: [x.00 .. x.25]
  3380. },
  3381. score: function() {
  3382. return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this);
  3383. },
  3384. set: function(settings) {
  3385. this.each(function() {
  3386. var $this = $(this),
  3387. actual = $this.data('settings'),
  3388. clone = $this.clone().removeAttr('style').insertBefore($this);
  3389. $this.remove();
  3390. clone.raty($.extend(actual, settings));
  3391. });
  3392. return $(this.selector);
  3393. },
  3394. setScore: function(score) {
  3395. return $(this).each(function() {
  3396. if ($(this).data('readonly') === true) {
  3397. return this;
  3398. }
  3399. methods.initialize.call(this, score);
  3400. methods.setTarget.call(this, score, true);
  3401. });
  3402. },
  3403. setTarget: function(value, isKeep) {
  3404. if (this.opt.target) {
  3405. var $target = $(this.opt.target);
  3406. if ($target.length == 0) {
  3407. methods.error.call(this, '目标选择器无效或丢失!');
  3408. }
  3409. var score = value;
  3410. if (!isKeep || score === undefined) {
  3411. score = this.opt.targetText;
  3412. } else {
  3413. if (this.opt.targetType == 'hint') {
  3414. score = (score === null && this.opt.cancel) ? this.opt.cancelHint: this.opt.hints[Math.ceil(score - 1)];
  3415. } else {
  3416. score = this.opt.precision ? parseFloat(score).toFixed(1) : parseInt(score, 10);
  3417. }
  3418. }
  3419. if (this.opt.targetFormat.indexOf('{score}') < 0) {
  3420. methods.error.call(this, '模版 "{score}" 找不到!');
  3421. }
  3422. if (value !== null) {
  3423. score = this.opt.targetFormat.toString().replace('{score}', score);
  3424. }
  3425. if ($target.is(':input')) {
  3426. $target.val(score);
  3427. } else {
  3428. $target.html(score);
  3429. }
  3430. }
  3431. },
  3432. showHalf: function(score) {
  3433. var diff = (score - Math.floor(score)).toFixed(1);
  3434. if (diff > 0 && diff < .6) {
  3435. this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt.starHalf);
  3436. }
  3437. },
  3438. initialize: function(score) {
  3439. score = !score ? 0 : methods.between(score, 0, this.opt.number);
  3440. methods.fill.call(this, score);
  3441. if (score > 0) {
  3442. if (this.opt.halfShow) {
  3443. methods.roundStar.call(this, score);
  3444. }
  3445. this.score.val(score);
  3446. }
  3447. },
  3448. unfixHint: function() {
  3449. for (var i = 0; i < this.opt.number; i++) {
  3450. this.stars.eq(i).attr('title', (i < this.opt.hints.length && this.opt.hints[i] !== null) ? this.opt.hints[i] : i);
  3451. }
  3452. $(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title');
  3453. this.score.attr('readonly', 'readonly');
  3454. }
  3455. };
  3456. $.fn.raty = function(method) {
  3457. if (methods[method]) {
  3458. return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  3459. } else if (typeof method === 'object' || !method) {
  3460. return methods.init.apply(this, arguments);
  3461. } else {
  3462. $.error('方法 ' + method + ' 不存在!');
  3463. }
  3464. };
  3465. $.fn.raty.defaults = {
  3466. cancel: false,
  3467. cancelHint: '取消评级!',
  3468. cancelOff: 'cancel-off.png',
  3469. cancelOn: 'cancel-on.png',
  3470. cancelPlace: 'left',
  3471. click: undefined,
  3472. half: false,
  3473. halfShow: true,
  3474. hints: ['10', '20', '30', '40', '50', '60', '70', '80', '90', '100'],
  3475. iconRange: undefined,
  3476. mouseover: undefined,
  3477. noRatedMsg: '没有额定',
  3478. number: 10,
  3479. path: 'images/',
  3480. precision: false,
  3481. round: {
  3482. down: .25,
  3483. full: .6,
  3484. up: .76
  3485. },
  3486. readOnly: false,
  3487. score: undefined,
  3488. scoreName: 'score',
  3489. single: false,
  3490. size: 16,
  3491. space: true,
  3492. starHalf: 'star-half.png',
  3493. starOff: 'star-off.png',
  3494. starOn: 'star-on.png',
  3495. target: undefined,
  3496. targetFormat: '{score}',
  3497. targetKeep: false,
  3498. targetText: '',
  3499. targetType: 'hint',
  3500. width: undefined
  3501. };
  3502. })(jQuery);
  3503. /* =======================================================================
  3504. * jQuery.onePageNav.js v0.9One Page Nav Plugin
  3505. * http://github.com/davist11/jQuery-One-Page-Nav
  3506. * Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
  3507. * Dual licensed under the MIT and GPL licenses.
  3508. * Uses the same license as jQuery, see:
  3509. * http://jquery.org/license
  3510. * Example usage:
  3511. * $('#nav').onePageNav({
  3512. * currentClass: 'current',
  3513. * changeHash: false,
  3514. * scrollSpeed: 750
  3515. * });
  3516. * ========================================================================*/
  3517. !(function($) {
  3518. $.fn.onePageNav = function(options) {
  3519. var opts = $.extend({},
  3520. $.fn.onePageNav.defaults, options),
  3521. onePageNav = {};
  3522. onePageNav.sections = {};
  3523. onePageNav.bindNav = function($el, $this, o) {
  3524. var $par = $el.parent(),
  3525. newLoc = $el.attr('href'),
  3526. $win = $(window);
  3527. if (!$par.hasClass(o.currentClass)) {
  3528. if (o.begin) {
  3529. o.begin();
  3530. }
  3531. onePageNav.adjustNav($this, $par, o.currentClass);
  3532. $win.unbind('.onePageNav');
  3533. $.scrollTo(newLoc, o.scrollSpeed, {
  3534. easing: o.easing,
  3535. offset: {
  3536. top: -o.scrollOffset
  3537. },
  3538. onAfter: function() {
  3539. if (o.changeHash) {
  3540. window.location.hash = newLoc;
  3541. }
  3542. $win.bind('scroll.onePageNav',
  3543. function() {
  3544. onePageNav.scrollChange($this, o);
  3545. });
  3546. if (o.end) {
  3547. o.end();
  3548. }
  3549. }
  3550. });
  3551. }
  3552. };
  3553. onePageNav.adjustNav = function($this, $el, curClass) {
  3554. $this.find('.' + curClass).removeClass(curClass);
  3555. $el.addClass(curClass);
  3556. };
  3557. onePageNav.getPositions = function($this, o) {
  3558. var $nav = $this.find('a');
  3559. if (o.filter !== '') {
  3560. $nav = $nav.filter(o.filter);
  3561. }
  3562. $nav.each(function() {
  3563. var linkHref = $(this).attr('href'),
  3564. divPos = $(linkHref).offset(),
  3565. topPos = divPos.top;
  3566. onePageNav.sections[linkHref.substr(1)] = Math.round(topPos) - o.scrollOffset;
  3567. });
  3568. };
  3569. onePageNav.getSection = function(windowPos, o) {
  3570. var returnValue = '',
  3571. windowHeight = Math.round($(window).height() * o.scrollThreshold);
  3572. for (var section in onePageNav.sections) {
  3573. if ((onePageNav.sections[section] - windowHeight) < windowPos) {
  3574. returnValue = section;
  3575. }
  3576. }
  3577. return returnValue;
  3578. };
  3579. onePageNav.scrollChange = function($this, o) {
  3580. onePageNav.getPositions($this, o);
  3581. var windowTop = $(window).scrollTop(),
  3582. position = onePageNav.getSection(windowTop, o);
  3583. if (position !== '') {
  3584. onePageNav.adjustNav($this, $this.find('a[href=#' + position + ']').parent(), o.currentClass);
  3585. }
  3586. };
  3587. onePageNav.init = function($this, o) {
  3588. var didScroll = false,
  3589. $nav = $this.find('a');
  3590. if (o.filter !== '') {
  3591. $nav = $nav.filter(o.filter);
  3592. }
  3593. $nav.bind('click',
  3594. function(e) {
  3595. onePageNav.bindNav($(this), $this, o);
  3596. e.preventDefault();
  3597. });
  3598. onePageNav.getPositions($this, o);
  3599. $(window).bind('scroll.onePageNav',
  3600. function() {
  3601. didScroll = true;
  3602. });
  3603. setInterval(function() {
  3604. if (didScroll) {
  3605. didScroll = false;
  3606. onePageNav.scrollChange($this, o);
  3607. }
  3608. },
  3609. 250);
  3610. };
  3611. return this.each(function() {
  3612. var $this = $(this),
  3613. o = $.meta ? $.extend({},
  3614. opts, $this.data()) : opts;
  3615. onePageNav.init($this, o);
  3616. });
  3617. };
  3618. // default options
  3619. $.fn.onePageNav.defaults = {
  3620. currentClass: 'current',
  3621. changeHash: false,
  3622. easing: 'swing',
  3623. filter: '',
  3624. scrollSpeed: 750,
  3625. scrollOffset: 0,
  3626. scrollThreshold: 0.5,
  3627. begin: false,
  3628. end: false
  3629. };
  3630. })(jQuery);
  3631. /* =======================================================================
  3632. * jQuery.ColorPicker.js 颜色控件
  3633. * ========================================================================*/
  3634. (function($) {
  3635. 'use strict';
  3636. var name = 'Hui.colorPicker'; // modal name
  3637. var TEAMPLATE = '<div class="colorpicker"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown"><span class="cp-title"></span><i class="ic"></i></button><ul class="dropdown-menu clearfix"></ul></div>';
  3638. var LANG = {
  3639. zh_cn: {
  3640. errorTip: "不是有效的颜色值"
  3641. },
  3642. zh_tw: {
  3643. errorTip: "不是有效的顏色值"
  3644. },
  3645. en: {
  3646. errorTip: "Not a valid color value"
  3647. }
  3648. };
  3649. // The ColorPicker modal class
  3650. var ColorPicker = function(element, options) {
  3651. this.name = name;
  3652. this.$ = $(element);
  3653. this.getOptions(options);
  3654. this.init();
  3655. };
  3656. // default options
  3657. ColorPicker.DEFAULTS = {
  3658. colors: ['#00BCD4', '#388E3C', '#3280fc', '#3F51B5', '#9C27B0', '#795548', '#F57C00', '#F44336', '#E91E63'],
  3659. pullMenuRight: true,
  3660. wrapper: 'btn-wrapper',
  3661. tileSize: 30,
  3662. lineCount: 5,
  3663. optional: true,
  3664. tooltip: 'top',
  3665. icon: 'caret-down',
  3666. // btnTip: 'Tool tip in button'
  3667. };
  3668. ColorPicker.prototype.init = function() {
  3669. var options = this.options,
  3670. that = this;
  3671. this.$picker = $(TEAMPLATE).addClass(options.wrapper);
  3672. this.$picker.find('.cp-title').toggle(options.title !== undefined).text(options.title);
  3673. this.$menu = this.$picker.find('.dropdown-menu').toggleClass('pull-right', options.pullMenuRight);
  3674. this.$btn = this.$picker.find('.btn.dropdown-toggle');
  3675. this.$btn.find('.ic').addClass('icon-' + options.icon);
  3676. if (options.btnTip) {
  3677. this.$picker.attr('data-toggle', 'tooltip').tooltip({
  3678. title: options.btnTip,
  3679. placement: options.tooltip,
  3680. container: 'body'
  3681. });
  3682. }
  3683. this.$.attr('data-provide', null).after(this.$picker);
  3684. // init colors
  3685. this.colors = {};
  3686. $.each(this.options.colors,
  3687. function(idx, rawColor) {
  3688. if ($.zui.Color.isColor(rawColor)) {
  3689. var color = new $.zui.Color(rawColor);
  3690. that.colors[color.toCssStr()] = color;
  3691. }
  3692. });
  3693. this.updateColors();
  3694. var that = this;
  3695. this.$picker.on('click', '.cp-tile',
  3696. function() {
  3697. that.setValue($(this).data('color'));
  3698. });
  3699. var $input = this.$;
  3700. var setInputColor = function() {
  3701. var val = $input.val();
  3702. var isColor = $.zui.Color.isColor(val);
  3703. $input.parent().toggleClass('has-error', !isColor && !(options.optional && val === ''));
  3704. if (isColor) {
  3705. that.setValue(val, true);
  3706. } else {
  3707. if (options.optional && val === '') {
  3708. $input.tooltip('hide');
  3709. } else if (!$input.is(':focus')) {
  3710. $input.tooltip('show', options.errorTip);
  3711. }
  3712. }
  3713. }
  3714. if ($input.is('input:not([type=hidden])')) {
  3715. if (options.tooltip) {
  3716. $input.attr('data-toggle', 'tooltip').tooltip({
  3717. trigger: 'manual',
  3718. placement: options.tooltip,
  3719. tipClass: 'tooltip-danger',
  3720. container: 'body'
  3721. });
  3722. }
  3723. $input.on('keyup paste input change', setInputColor);
  3724. } else {
  3725. $input.appendTo(this.$picker);
  3726. }
  3727. setInputColor();
  3728. };
  3729. ColorPicker.prototype.addColor = function(color) {
  3730. var hex = color.toCssStr(),
  3731. options = this.options;
  3732. if (!this.colors[hex]) {
  3733. this.colors[hex] = color;
  3734. }
  3735. var $a = $('<a href="###" class="cp-tile"></a>', {
  3736. titile: color
  3737. }).data('color', color).css({
  3738. 'color': color.contrast().toCssStr(),
  3739. 'background': hex,
  3740. 'border-color': color.luma() > 0.43 ? '#ccc': 'transparent'
  3741. }).attr('data-color', hex);
  3742. this.$menu.append($('<li/>').css({
  3743. width: options.tileSize,
  3744. height: options.tileSize
  3745. }).append($a));
  3746. if (options.optional) {
  3747. this.$menu.find('.cp-tile.empty').parent().detach().appendTo(this.$menu);
  3748. }
  3749. };
  3750. ColorPicker.prototype.updateColors = function(colors) {
  3751. var $picker = this.$picker,
  3752. $menu = this.$menu.empty(),
  3753. options = this.options,
  3754. colors = colors || this.colors,
  3755. that = this;
  3756. var bestLineCount = 0;
  3757. $.each(colors,
  3758. function(idx, color) {
  3759. that.addColor(color);
  3760. bestLineCount++;
  3761. });
  3762. if (options.optional) {
  3763. var $li = $('<li><a class="cp-tile empty" href="###"></a></li>').css({
  3764. width: options.tileSize,
  3765. height: options.tileSize
  3766. });
  3767. this.$menu.append($li);
  3768. bestLineCount++;
  3769. }
  3770. $menu.css('width', Math.min(bestLineCount, options.lineCount) * options.tileSize + 6);
  3771. };
  3772. ColorPicker.prototype.setValue = function(color, notSetInput) {
  3773. var options = this.options;
  3774. this.$menu.find('.cp-tile.active').removeClass('active');
  3775. var hex = '';
  3776. if (color) {
  3777. var c = new $.zui.Color(color);
  3778. hex = c.toCssStr().toLowerCase();
  3779. this.$btn.css({
  3780. background: hex,
  3781. color: c.contrast().toCssStr(),
  3782. borderColor: c.luma() > 0.43 ? '#ccc': hex
  3783. });
  3784. if (!this.colors[hex]) {
  3785. this.addColor(c);
  3786. }
  3787. if (!notSetInput && this.$.val().toLowerCase() !== hex) {
  3788. this.$.val(hex).trigger('change');
  3789. }
  3790. this.$menu.find('.cp-tile[data-color=' + hex + ']').addClass('active');
  3791. this.$.tooltip('hide');
  3792. this.$.trigger('colorchange', c);
  3793. } else {
  3794. this.$btn.attr('style', null);
  3795. if (!notSetInput && this.$.val() !== '') {
  3796. this.$.val(hex).trigger('change');
  3797. }
  3798. if (options.optional) {
  3799. this.$.tooltip('hide');
  3800. }
  3801. this.$menu.find('.cp-tile.empty').addClass('active');
  3802. this.$.trigger('colorchange', null);
  3803. }
  3804. if (options.updateBorder) {
  3805. $(options.updateBorder).css('border-color', hex);
  3806. }
  3807. if (options.updateBackground) {
  3808. $(options.updateBackground).css('background-color', hex);
  3809. }
  3810. if (options.updateColor) {
  3811. $(options.updateText).css('color', hex);
  3812. }
  3813. if (options.updateText) {
  3814. $(options.updateText).text(hex);
  3815. }
  3816. };
  3817. // Get and init options
  3818. ColorPicker.prototype.getOptions = function(options) {
  3819. var thisOptions = $.extend({},
  3820. ColorPicker.DEFAULTS, this.$.data(), options);
  3821. if (typeof thisOptions.colors === 'string') thisOptions.colors = thisOptions.colors.split(',');
  3822. var lang = (thisOptions.lang || $.zui.clientLang()).toLowerCase();
  3823. if (!thisOptions.errorTip) {
  3824. thisOptions.errorTip = LANG[lang].errorTip;
  3825. }
  3826. if (!$.fn.tooltip) thisOptions.btnTip = false;
  3827. this.options = thisOptions;
  3828. };
  3829. // Extense jquery element
  3830. $.fn.colorPicker = function(option) {
  3831. return this.each(function() {
  3832. var $this = $(this);
  3833. var data = $this.data(name);
  3834. var options = typeof option == 'object' && option;
  3835. if (!data) $this.data(name, (data = new ColorPicker(this, options)));
  3836. if (typeof option == 'string') data[option]();
  3837. });
  3838. };
  3839. $.fn.colorPicker.Constructor = ColorPicker;
  3840. // Auto call colorPicker after document load complete
  3841. $(function() {
  3842. $('[data-provide="colorpicker"]').colorPicker();
  3843. });
  3844. }(jQuery));
  3845. /* =======================================================================
  3846. * jquery.HuiaddFavorite.js 添加收藏
  3847. * <a title="收藏本站" href="javascript:;" onClick="addFavoritepage('H-ui前端框架','http://www.h-ui.net/');">收藏本站</a>
  3848. * function shoucang(name,site){
  3849. $.addFavorite({
  3850. name:name,
  3851. site:site,
  3852. });
  3853. * ========================================================================*/
  3854. function HuiaddFavorite(obj) {
  3855. obj.site = obj.site || window.location.href;
  3856. obj.name = obj.name || document.title;
  3857. try {
  3858. window.external.addFavorite(obj.site, obj.name);
  3859. } catch(e) {
  3860. try {
  3861. window.sidebar.addPanel(name, site, "");
  3862. } catch(e) {
  3863. $.Huimodalalert("加入收藏失败,请使用Ctrl+D进行添加", 2000);
  3864. }
  3865. }
  3866. }
  3867. /* ========================================================================
  3868. * jQuery.Huisethome.js 设为首页
  3869. * ======================================================================== */
  3870. function Huisethome(obj){
  3871. try{
  3872. obj.style.behavior="url(#default#homepage)";
  3873. obj.setHomePage(webSite);
  3874. }
  3875. catch(e){
  3876. if(window.netscape){
  3877. try {
  3878. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  3879. }
  3880. catch(e){
  3881. $.Huimodalalert("此操作被浏览器拒绝!\n请在浏览器地址栏输入\"about:config\"并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。",2000);
  3882. }
  3883. var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
  3884. prefs.setCharPref('browser.startup.homepage',url);
  3885. }
  3886. }
  3887. }
  3888. /* =======================================================================
  3889. * jQuery.Huisidenav.js 左侧菜单-隐藏显示
  3890. * ======================================================================== */
  3891. function displaynavbar(obj){
  3892. if($(obj).hasClass("open")){
  3893. $(obj).removeClass("open");
  3894. $("body").removeClass("big-page");
  3895. } else {
  3896. $(obj).addClass("open");
  3897. $("body").addClass("big-page");
  3898. }
  3899. }
  3900. /* =======================================================================
  3901. * jQuery.Huihover.js v2.0 Huihover
  3902. * http://www.h-ui.net/
  3903. * Created & Modified by guojunhui
  3904. * Date modified 2017.05.05
  3905. *
  3906. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  3907. * Licensed under MIT license.
  3908. * http://opensource.org/licenses/MIT
  3909. * ========================================================================*/
  3910. !function($) {
  3911. $.fn.Huihover = function(options){
  3912. var defaults = {
  3913. className:"hover",
  3914. }
  3915. var options = $.extend(defaults, options);
  3916. this.each(function(){
  3917. var that = $(this);
  3918. that.hover(function() {
  3919. that.addClass(options.className);
  3920. },
  3921. function() {
  3922. that.removeClass(options.className);
  3923. });
  3924. });
  3925. }
  3926. } (window.jQuery);
  3927. /* =======================================================================
  3928. * jQuery.Huifocusblur.js v2.0 得到失去焦点
  3929. * http://www.h-ui.net/
  3930. * Created & Modified by guojunhui
  3931. * Date modified 2017.05.09
  3932. *
  3933. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  3934. * Licensed under MIT license.
  3935. * http://opensource.org/licenses/MIT
  3936. * ========================================================================*/
  3937. !function($) {
  3938. $.fn.Huifocusblur = function(options){
  3939. var defaults = {
  3940. className:"focus",
  3941. }
  3942. var options = $.extend(defaults, options);
  3943. this.each(function(){
  3944. var that = $(this);
  3945. that.focus(function() {
  3946. that.addClass(options.className).removeClass("inputError");
  3947. });
  3948. that.blur(function() {
  3949. that.removeClass(options.className);
  3950. });
  3951. });
  3952. }
  3953. } (window.jQuery);
  3954. /* =======================================================================
  3955. * jQuery.Huiselect.js 选择
  3956. * ========================================================================*/
  3957. !function($) {
  3958. $.Huiselect = function(divselectid, inputselectid) {
  3959. var inputselect = $(inputselectid);
  3960. $(divselectid + " cite").click(function() {
  3961. var ul = $(divselectid + " ul");
  3962. ul.slideToggle();
  3963. });
  3964. $(divselectid + " ul li a").click(function() {
  3965. var txt = $(this).text();
  3966. $(divselectid + " cite").html(txt);
  3967. var value = $(this).attr("selectid");
  3968. inputselect.val(value);
  3969. $(divselectid + " ul").hide();
  3970. });
  3971. $(document).click(function() {
  3972. $(divselectid + " ul").hide();
  3973. });
  3974. };
  3975. } (window.jQuery);
  3976. /* =======================================================================
  3977. * jQuery.Huitab.js v2.0 选项卡
  3978. * http://www.h-ui.net/
  3979. * Created & Modified by guojunhui
  3980. * Date modified 2017.05.05
  3981. *
  3982. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  3983. * Licensed under MIT license.
  3984. * http://opensource.org/licenses/MIT
  3985. * ========================================================================*/
  3986. !function($) {
  3987. $.fn.Huitab = function(options){
  3988. var defaults = {
  3989. tabBar:'.tabBar span',
  3990. tabCon:".tabCon",
  3991. className:"current",
  3992. tabEvent:"click",
  3993. index:0,
  3994. }
  3995. var options = $.extend(defaults, options);
  3996. this.each(function(){
  3997. var that = $(this);
  3998. that.find(options.tabBar).removeClass(options.className);
  3999. that.find(options.tabBar).eq(options.index).addClass(options.className);
  4000. that.find(options.tabCon).hide();
  4001. that.find(options.tabCon).eq(options.index).show();
  4002. that.find(options.tabBar).on(options.tabEvent,function(){
  4003. that.find(options.tabBar).removeClass(options.className);
  4004. $(this).addClass(options.className);
  4005. var index = that.find(options.tabBar).index(this);
  4006. that.find(options.tabCon).hide();
  4007. that.find(options.tabCon).eq(index).show();
  4008. });
  4009. });
  4010. }
  4011. } (window.jQuery);
  4012. /* =======================================================================
  4013. * jQuery.Huifold.js v2.0 折叠
  4014. * http://www.h-ui.net/
  4015. * Created & Modified by guojunhui
  4016. * Date modified 2017.05.05
  4017. *
  4018. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  4019. * Licensed under MIT license.
  4020. * http://opensource.org/licenses/MIT
  4021. * ========================================================================*/
  4022. !function($) {
  4023. $.fn.Huifold = function(options){
  4024. var defaults = {
  4025. titCell:'.item .Huifold-header',
  4026. mainCell:'.item .Huifold-body',
  4027. type:1,//1 只打开一个,可以全部关闭;2 必须有一个打开;3 可打开多个
  4028. trigger:'click',
  4029. className:"selected",
  4030. speed:'first',
  4031. }
  4032. var options = $.extend(defaults, options);
  4033. this.each(function(){
  4034. var that = $(this);
  4035. that.find(options.titCell).on(options.trigger,function(){
  4036. if ($(this).next().is(":visible")) {
  4037. if (options.type == 2) {
  4038. return false;
  4039. } else {
  4040. $(this).next().slideUp(options.speed).end().removeClass(options.className);
  4041. if ($(this).find("b")) {
  4042. $(this).find("b").html("+");
  4043. }
  4044. }
  4045. }else {
  4046. if (options.type == 3) {
  4047. $(this).next().slideDown(options.speed).end().addClass(options.className);
  4048. if ($(this).find("b")) {
  4049. $(this).find("b").html("-");
  4050. }
  4051. } else {
  4052. that.find(options.mainCell).slideUp(options.speed);
  4053. that.find(options.titCell).removeClass(options.className);
  4054. if (that.find(options.titCell).find("b")) {
  4055. that.find(options.titCell).find("b").html("+");
  4056. }
  4057. $(this).next().slideDown(options.speed).end().addClass(options.className);
  4058. if ($(this).find("b")) {
  4059. $(this).find("b").html("-");
  4060. }
  4061. }
  4062. }
  4063. });
  4064. });
  4065. }
  4066. } (window.jQuery);
  4067. /* =======================================================================
  4068. * jQuery.Huitags.js v2.0 标签
  4069. * http://www.h-ui.net/
  4070. * Created & Modified by guojunhui
  4071. * Date modified 2017.05.10
  4072. *
  4073. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  4074. * Licensed under MIT license.
  4075. * http://opensource.org/licenses/MIT
  4076. * ========================================================================*/
  4077. !function($) {
  4078. $.fn.Huitags = function(options) {
  4079. var defaults = {
  4080. value:'Hui前端框架,H-ui,辉哥',
  4081. maxlength : 20,
  4082. number : 5,
  4083. tagsDefault : ["Html","CSS","JS"],
  4084. }
  4085. var options = $.extend(defaults, options);
  4086. var keyCodes = {
  4087. Enter : 13,
  4088. Enter2 : 108,
  4089. Spacebar:32
  4090. }
  4091. this.each(function(){
  4092. var that = $(this);
  4093. var str =
  4094. '<div class="Huitags-wraper">'+
  4095. '<div class="Huitags-editor cl"></div>'+
  4096. '<div class="Huitags-input-wraper">'+
  4097. '<input type="text" class="input-text Huitags-input" maxlength="'+options.maxlength+'" value="">'+
  4098. '</div>'+
  4099. '<div class="Huitags-list">'+
  4100. '<div class="Huitags-notag" style="display:none">暂无常用标签</div>'+
  4101. '<div class="Huitags-has"></div>'+
  4102. '</div>'+
  4103. '<input type="hidden" class="Huitags-val" name="" value="'+options.value+'">'+
  4104. '</div>';
  4105. that.append(str);
  4106. var wraper = that.find(".Huitags-wraper");
  4107. var editor = that.find(".Huitags-editor");
  4108. var input =that.find(".Huitags-input");
  4109. var list = that.find(".Huitags-list");
  4110. var has = that.find(".Huitags-has");
  4111. var val = that.find(".Huitags-val");
  4112. if(options.tagsDefault){
  4113. var tagsDefaultLength = (options.tagsDefault).length;
  4114. for(var i = 0;i< tagsDefaultLength; i++){
  4115. has.append('<span>'+options.tagsDefault[i]+'</span>');
  4116. }
  4117. has.find("span").on('click',function(){
  4118. var taghasV = $(this).text();
  4119. taghasV=taghasV.replace(/(^\s*)|(\s*$)/g,"");
  4120. editor.append('<span class="Huitags-token">'+taghasV+'</span>');
  4121. gettagval(this);
  4122. $(this).remove();
  4123. });
  4124. }
  4125. function gettagval(obj) {
  4126. var str = "";
  4127. var token = that.find(".Huitags-token");
  4128. if (token.length < 1) {
  4129. input.val("");
  4130. return false;
  4131. }
  4132. for (var i = 0; i < token.length; i++) {
  4133. str += token.eq(i).text() + ",";
  4134. }
  4135. str = unique(str, 1);
  4136. str=str.join();
  4137. val.val(str);
  4138. }
  4139. /*将字符串逗号分割成数组并去重*/
  4140. function unique(o, type){
  4141. //去掉前后空格
  4142. o=o.replace(/(^\s*)|(\s*$)/g,"");
  4143. if(type == 1) {
  4144. //把所有的空格和中文逗号替换成英文逗号
  4145. o=o.replace(/(\s)|(,)/g, ",");
  4146. } else {
  4147. //把所有的中文逗号替换成英文逗号
  4148. o=o.replace(/(,)/g, ",");
  4149. }
  4150. //去掉前后英文逗号
  4151. o=o.replace(/^,|,$/g, "");
  4152. //去重连续的英文逗号
  4153. o=o.replace(/,+/g,',');
  4154. o=o.split(",");
  4155. var n = [o[0]]; //结果数组
  4156. for(var i = 1; i < o.length; i++){
  4157. if (o.indexOf(o[i]) == i) {
  4158. if(o[i] == "")
  4159. continue;
  4160. n.push(o[i]);
  4161. }
  4162. }
  4163. return n;
  4164. }
  4165. input.on("keydown",function(e){
  4166. var evt = e || window.event;
  4167. if (evt.keyCode == keyCodes.Enter || evt.keyCode == keyCodes.Enter2 || evt.keyCode == keyCodes.Spacebar) {
  4168. var v = input.val().replace(/\s+/g, "");
  4169. var reg = /^,|,$/gi;
  4170. v = v.replace(reg, "");
  4171. v = $.trim(v);
  4172. if (v != '') {
  4173. input.change();
  4174. }else{
  4175. return false;
  4176. }
  4177. }
  4178. });
  4179. input.on("change",function(){
  4180. var v1 = input.val();
  4181. var v2 = val.val();
  4182. var v = v2+','+v1;
  4183. if(v!=''){
  4184. var str='<i class="Huitags-icon Hui-iconfont">&#xe64b;</i>';
  4185. var result = unique(v, 1);
  4186. if(result.length>0){
  4187. for(var j=0;j<result.length;j++){
  4188. str+='<span class="Huitags-token">'+result[j]+'</span>';
  4189. }
  4190. val.val(result);
  4191. editor.html(str);
  4192. input.val("").blur();
  4193. }
  4194. }
  4195. });
  4196. $(document).on("click",".Huitags-token",function(){
  4197. $(this).remove();
  4198. var str ="";
  4199. if(that.find(".Huitags-token").length<1){
  4200. val.val("");
  4201. return false;
  4202. }else{
  4203. for(var i = 0;i< that.find(".Huitags-token").length;i++){
  4204. str += that.find(".Huitags-token").eq(i).text() + ",";
  4205. }
  4206. str = str.substring(0,str.length-1);
  4207. val.val(str);
  4208. }
  4209. });
  4210. input.change();
  4211. });
  4212. }
  4213. } (window.jQuery);
  4214. /* =======================================================================
  4215. * jQuery.Huitagsmixed.js 标签混排效果
  4216. * ========================================================================*/
  4217. !function($) {
  4218. $.Huitagsmixed = function(obj) {
  4219. $(obj).each(function() {
  4220. var x = 9;
  4221. var y = 0;
  4222. var rand = parseInt(Math.random() * (x - y + 1) + y);
  4223. $(this).addClass("tags" + rand);
  4224. });
  4225. }
  4226. } (window.jQuery);
  4227. /* =======================================================================
  4228. * jQuery.Huitextarealength.js v2.0 字数限制
  4229. * http://www.h-ui.net/
  4230. * Created & Modified by guojunhui
  4231. * Date modified 2017.05.12
  4232. *
  4233. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  4234. * Licensed under MIT license.
  4235. * http://opensource.org/licenses/MIT
  4236. * ========================================================================*/
  4237. !function($) {
  4238. $.fn.Huitextarealength = function(options){
  4239. var defaults = {
  4240. minlength:0,
  4241. maxlength:140,
  4242. errorClass:"error",
  4243. exceed:true,
  4244. }
  4245. var options = $.extend(defaults, options);
  4246. this.each(function(){
  4247. var that = $(this);
  4248. var v = that.val();
  4249. var l = v.length;
  4250. var str = '<p class="textarea-numberbar"><em class="textarea-length">'+l+'</em>/'+options.maxlength+'</p>';
  4251. that.parent().append(str);
  4252. that.on("keyup",function(){
  4253. v = that.val();
  4254. l = v.length;
  4255. if (l > options.maxlength) {
  4256. if(options.exceed){
  4257. that.addClass(options.errorClass);
  4258. }else{
  4259. v = v.substring(0, options.maxlength);
  4260. that.val(v);
  4261. that.removeClass(options.errorClass);
  4262. }
  4263. }
  4264. else if(l<options.minlength){
  4265. that.addClass(options.errorClass);
  4266. }else{
  4267. that.removeClass(options.errorClass);
  4268. }
  4269. that.parent().find(".textarea-length").text(v.length);
  4270. });
  4271. });
  4272. }
  4273. } (window.jQuery);
  4274. /* =======================================================================
  4275. * jQuery.Huipreview.js v2.0 图片预览
  4276. * http://www.h-ui.net/
  4277. * Created & Modified by guojunhui
  4278. * Date modified 2017.05.05
  4279. *
  4280. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  4281. * Licensed under MIT license.
  4282. * http://opensource.org/licenses/MIT
  4283. * ========================================================================*/
  4284. !function($) {
  4285. $.fn.Huipreview = function(options){
  4286. var defaults = {
  4287. className:"active",
  4288. bigImgWidth: 300,
  4289. }
  4290. var options = $.extend(defaults, options);
  4291. this.each(function(){
  4292. var that = $(this);
  4293. var timer;
  4294. that.hover(
  4295. function() {
  4296. clearTimeout(timer);
  4297. timer = setTimeout(function () {
  4298. $("#tooltip-preview").remove();
  4299. var smallImg = that.find("img").attr("src");
  4300. var bigImg = that.attr('data-src');
  4301. var bigImgW = that.attr('data-width');
  4302. var bigImgH = that.attr('data-height');
  4303. var winW = $(window).width();
  4304. var winW5 = winW / 2;
  4305. var imgT = that.parent().offset().top;
  4306. var imgL = that.parent().offset().left;
  4307. var imgW = that.parent().width();
  4308. var imgH = that.parent().height();
  4309. var ww = (imgL + imgW / 2);
  4310. var tooltipLeft = "auto",tooltipRight = "auto";
  4311. if (ww < winW5) {
  4312. tooltipLeft = (imgW + imgL) + "px";
  4313. } else {
  4314. tooltipRight = (winW - imgL) + "px";
  4315. }
  4316. that.addClass(options.className);
  4317. if (bigImg == '') {
  4318. return false;
  4319. } else {
  4320. var tooltip_keleyi_com =
  4321. '<div id="preview-wraper" style="position: absolute;width:'+options.bigImgWidth+'px;height:auto;top:' + imgT + 'px;right:' + tooltipRight + ';left:' + tooltipLeft + '">'+
  4322. '<img src="'+smallImg+'" width="'+options.bigImgWidth+'">'+
  4323. '</div>';
  4324. $("body").append(tooltip_keleyi_com);
  4325. /*图片预加载*/
  4326. var image = new Image();
  4327. image.src = bigImg;
  4328. /*创建一个Image对象*/
  4329. image.onload = function() {
  4330. $('#preview-wraper').find("img").attr("src",bigImg).css("width",options.bigImgWidth);
  4331. };
  4332. }
  4333. },500);
  4334. },
  4335. function() {
  4336. clearTimeout(timer);
  4337. that.removeClass(options.className);
  4338. $("#preview-wraper").remove();
  4339. }
  4340. );
  4341. });
  4342. }
  4343. } (window.jQuery);
  4344. /* =======================================================================
  4345. * jQuery.Huimodalalert.js alert
  4346. * ========================================================================*/
  4347. !function($) {
  4348. $.Huimodalalert = function(info, speed) {
  4349. if ($(".modal-alert").length > 0) {
  4350. $(".modal-alert").remove();
  4351. }
  4352. if (speed == 0 || typeof(speed) == "undefined") {
  4353. $(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>');
  4354. $("#modal-alert").fadeIn();
  4355. } else {
  4356. $(document.body).append('<div id="modal-alert" class="modal modal-alert radius">' + '<div class="modal-alert-info">' + info + '</div>' + '</div>');
  4357. $("#modal-alert").fadeIn();
  4358. setTimeout($.Huimodalalert.hide, speed);
  4359. }
  4360. }
  4361. $.Huimodalalert.hide = function() {
  4362. $("#modal-alert").fadeOut("normal",
  4363. function() {
  4364. $("#modal-alert").remove();
  4365. });
  4366. }
  4367. } (window.jQuery);
  4368. /* =======================================================================
  4369. * jQuery.Huialert.js alert
  4370. * ========================================================================*/
  4371. !function($) {
  4372. $.Huialert = function() {
  4373. $(".Huialert i").Huihover();
  4374. $(".Huialert i").on("click",function() {
  4375. var Huialert = $(this).parents(".Huialert");
  4376. Huialert.fadeOut("normal",
  4377. function() {
  4378. Huialert.remove();
  4379. });
  4380. });
  4381. }
  4382. $.Huialert();
  4383. } (window.jQuery);
  4384. /* =======================================================================
  4385. * jQuery.Huitotop.js v2.0 返回顶部
  4386. * http://www.h-ui.net/
  4387. * Created & Modified by guojunhui
  4388. * Date modified 2017.05.05
  4389. *
  4390. * Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
  4391. * Licensed under MIT license.
  4392. * http://opensource.org/licenses/MIT
  4393. * ========================================================================*/
  4394. !function($) {
  4395. //bottom 距离底部高度
  4396. $.Huitotop = function(bottom){
  4397. if(!bottom){
  4398. bottom = 60;
  4399. }
  4400. var str ='<a href="javascript:void(0)" class="tools-right toTop Hui-iconfont" title="返回顶部" alt="返回顶部" style="display:none;bottom:'+bottom+'px">&#xe684;</a>';
  4401. $(str).appendTo($('body')).click(function() {
  4402. $("html, body").animate({
  4403. scrollTop: 0
  4404. },
  4405. 120);
  4406. });
  4407. var backToTopFun = function(){
  4408. var st = $(document).scrollTop();
  4409. var winh = $(window).height();
  4410. if(st> 0){
  4411. $(".toTop").show();
  4412. }else{
  4413. $(".toTop").hide();
  4414. }
  4415. /*IE6下的定位*/
  4416. if (!window.XMLHttpRequest) {
  4417. $(".toTop").css("top", st + winh - 166);
  4418. }
  4419. }
  4420. $(window).on("scroll",backToTopFun);
  4421. }
  4422. } (window.jQuery);
  4423. /* =======================================================================
  4424. * jQuery.Huimarquee.js 滚动
  4425. * ========================================================================*/
  4426. !function($) {
  4427. $.Huimarquee = function(height, speed, delay) {
  4428. var scrollT;
  4429. var pause = false;
  4430. var ScrollBox = document.getElementById("marquee");
  4431. if (document.getElementById("holder").offsetHeight <= height) return;
  4432. var _tmp = ScrollBox.innerHTML.replace('holder', 'holder2');
  4433. ScrollBox.innerHTML += _tmp;
  4434. ScrollBox.onmouseover = function() {
  4435. pause = true;
  4436. }
  4437. ScrollBox.onmouseout = function() {
  4438. pause = false;
  4439. }
  4440. ScrollBox.scrollTop = 0;
  4441. var start = function() {
  4442. scrollT = setInterval(scrolling, speed);
  4443. if (!pause) ScrollBox.scrollTop += 2;
  4444. }
  4445. var scrolling = function() {
  4446. if (ScrollBox.scrollTop % height != 0) {
  4447. ScrollBox.scrollTop += 2;
  4448. if (ScrollBox.scrollTop >= ScrollBox.scrollHeight / 2) ScrollBox.scrollTop = 0;
  4449. } else {
  4450. clearInterval(scrollT);
  4451. setTimeout(start, delay);
  4452. }
  4453. }
  4454. setTimeout(start, delay);
  4455. }
  4456. } (window.jQuery);
  4457. $(function() {
  4458. /*全选*/
  4459. $("table thead th input:checkbox").on("click",function() {
  4460. $(this).closest("table").find("tr > td:first-child input:checkbox").prop("checked", $("table thead th input:checkbox").prop("checked"));
  4461. });
  4462. /*上传*/
  4463. $(document).on("change", ".input-file",function() {
  4464. var uploadVal = $(this).val();
  4465. $(this).parent().find(".upload-url").val(uploadVal).focus().blur();
  4466. });
  4467. });
  4468. /* ========================================================================
  4469. * Bootstrap.button.js v3.3.0
  4470. * http://getbootstrap.com/javascript/#buttons
  4471. * ========================================================================
  4472. * Copyright 2011-2014 Twitter, Inc.
  4473. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4474. * ======================================================================== */
  4475. !function($) {
  4476. 'use strict';
  4477. // BUTTON PUBLIC CLASS DEFINITION
  4478. // ==============================
  4479. var Button = function(element, options) {
  4480. this.$element = $(element);
  4481. this.options = $.extend({},Button.DEFAULTS, options);
  4482. this.isLoading = false;
  4483. }
  4484. Button.VERSION = '3.3.0'
  4485. Button.DEFAULTS = {
  4486. loadingText: 'loading...'
  4487. }
  4488. Button.prototype.setState = function(state) {
  4489. var d = 'disabled'
  4490. var $el = this.$element
  4491. var val = $el.is('input') ? 'val': 'html'
  4492. var data = $el.data();
  4493. state = state + 'Text';
  4494. if (data.resetText == null) $el.data('resetText', $el[val]());
  4495. // push to event loop to allow forms to submit
  4496. setTimeout($.proxy(function() {
  4497. $el[val](data[state] == null ? this.options[state] : data[state]);
  4498. if (state == 'loadingText') {
  4499. this.isLoading = true;
  4500. $el.addClass(d).attr(d, d);
  4501. } else if (this.isLoading) {
  4502. this.isLoading = false;
  4503. $el.removeClass(d).removeAttr(d);
  4504. }
  4505. },
  4506. this), 0)
  4507. }
  4508. Button.prototype.toggle = function() {
  4509. var changed = true;
  4510. var $parent = this.$element.closest('[data-toggle="buttons"]');
  4511. if ($parent.length) {
  4512. var $input = this.$element.find('input');
  4513. if ($input.prop('type') == 'radio') {
  4514. if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
  4515. else $parent.find('.active').removeClass('active')
  4516. }
  4517. if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
  4518. } else {
  4519. this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
  4520. }
  4521. if (changed) this.$element.toggleClass('active')
  4522. }
  4523. // BUTTON PLUGIN DEFINITION
  4524. // ========================
  4525. function Plugin(option) {
  4526. return this.each(function() {
  4527. var $this = $(this);
  4528. var data = $this.data('bs.button');
  4529. var options = typeof option == 'object' && option;
  4530. if (!data) $this.data('bs.button', (data = new Button(this, options)))
  4531. if (option == 'toggle') data.toggle()
  4532. else if (option) data.setState(option)
  4533. })
  4534. }
  4535. var old = $.fn.button;
  4536. $.fn.button = Plugin;
  4537. $.fn.button.Constructor = Button;
  4538. // BUTTON NO CONFLICT
  4539. // ==================
  4540. $.fn.button.noConflict = function() {
  4541. $.fn.button = old;
  4542. return this;
  4543. }
  4544. // BUTTON DATA-API
  4545. // ===============
  4546. $(document).on('click.bs.button.data-api', '[data-toggle^="button"]',
  4547. function(e) {
  4548. var $btn = $(e.target);
  4549. if (!$btn.hasClass('btn'));
  4550. $btn = $btn.closest('.btn');
  4551. Plugin.call($btn, 'toggle');
  4552. e.preventDefault();
  4553. }).on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]',
  4554. function(e) {
  4555. $(e.target).closest('.btn').toggleClass('focus', e.type == 'focus');
  4556. })
  4557. } (jQuery);
  4558. /* =======================================================================
  4559. * jQuery.stickUp.js v0.5.7 BETA by:LiranCohen
  4560. * https://github.com/LiranCohen/stickUp
  4561. * ======================================================================== */
  4562. jQuery(function($) {
  4563. $(document).ready(function(){
  4564. var contentButton = [];
  4565. var contentTop = [];
  4566. var content = [];
  4567. var lastScrollTop = 0;
  4568. var scrollDir = '';
  4569. var itemClass = '';
  4570. var itemHover = '';
  4571. var menuSize = null;
  4572. var stickyHeight = 0;
  4573. var stickyMarginB = 0;
  4574. var currentMarginT = 0;
  4575. var topMargin = 0;
  4576. var vartop = 0;
  4577. $(window).scroll(function(event){
  4578. var st = $(this).scrollTop();
  4579. if (st > lastScrollTop){
  4580. scrollDir = 'down';
  4581. } else {
  4582. scrollDir = 'up';
  4583. }
  4584. lastScrollTop = st;
  4585. });
  4586. $.fn.stickUp = function( options ) {
  4587. // adding a class to users div
  4588. $(this).addClass('stuckMenu');
  4589. //getting options
  4590. var objn = 0;
  4591. if(options != null) {
  4592. for(var o in options.parts) {
  4593. if (options.parts.hasOwnProperty(o)){
  4594. content[objn] = options.parts[objn];
  4595. objn++;
  4596. }
  4597. }
  4598. if(objn == 0) {
  4599. console.log('error:needs arguments');
  4600. }
  4601. itemClass = options.itemClass;
  4602. itemHover = options.itemHover;
  4603. if(options.topMargin != null) {
  4604. if(options.topMargin == 'auto') {
  4605. topMargin = parseInt($('.stuckMenu').css('margin-top'));
  4606. } else {
  4607. if(isNaN(options.topMargin) && options.topMargin.search("px") > 0){
  4608. topMargin = parseInt(options.topMargin.replace("px",""));
  4609. } else if(!isNaN(parseInt(options.topMargin))) {
  4610. topMargin = parseInt(options.topMargin);
  4611. } else {
  4612. console.log("incorrect argument, ignored.");
  4613. topMargin = 0;
  4614. }
  4615. }
  4616. } else {
  4617. topMargin = 0;
  4618. }
  4619. menuSize = $('.'+itemClass).size();
  4620. }
  4621. stickyHeight = parseInt($(this).height());
  4622. stickyMarginB = parseInt($(this).css('margin-bottom'));
  4623. currentMarginT = parseInt($(this).next().closest('div').css('margin-top'));
  4624. vartop = parseInt($(this).offset().top);
  4625. //$(this).find('*').removeClass(itemHover);
  4626. }
  4627. $(document).on('scroll', function() {
  4628. varscroll = parseInt($(document).scrollTop());
  4629. if(menuSize != null){
  4630. for(var i=0;i < menuSize;i++)
  4631. {
  4632. contentTop[i] = $('#'+content[i]+'').offset().top;
  4633. function bottomView(i) {
  4634. contentView = $('#'+content[i]+'').height()*.4;
  4635. testView = contentTop[i] - contentView;
  4636. if(varscroll > testView){
  4637. $('.'+itemClass).removeClass(itemHover);
  4638. $('.'+itemClass+':eq('+i+')').addClass(itemHover);
  4639. } else if(varscroll < 50){
  4640. $('.'+itemClass).removeClass(itemHover);
  4641. $('.'+itemClass+':eq(0)').addClass(itemHover);
  4642. }
  4643. }
  4644. if(scrollDir == 'down' && varscroll > contentTop[i]-50 && varscroll < contentTop[i]+50) {
  4645. $('.'+itemClass).removeClass(itemHover);
  4646. $('.'+itemClass+':eq('+i+')').addClass(itemHover);
  4647. }
  4648. if(scrollDir == 'up') {
  4649. bottomView(i);
  4650. }
  4651. }
  4652. }
  4653. if(vartop < varscroll + topMargin){
  4654. $('.stuckMenu').addClass('isStuck');
  4655. $('.stuckMenu').next().closest('div').css({
  4656. 'margin-top': stickyHeight + stickyMarginB + currentMarginT + 'px'
  4657. }, 10);
  4658. $('.stuckMenu').css("position","fixed");
  4659. $('.isStuck').css({
  4660. top: '0px'
  4661. }, 10, function(){
  4662. });
  4663. };
  4664. if(varscroll + topMargin < vartop){
  4665. $('.stuckMenu').removeClass('isStuck');
  4666. $('.stuckMenu').next().closest('div').css({
  4667. 'margin-top': currentMarginT + 'px'
  4668. }, 10);
  4669. $('.stuckMenu').css("position","relative");
  4670. };
  4671. });
  4672. });
  4673. });
  4674. /* =======================================================================
  4675. * Bootstrap.modal.js v3.3.0
  4676. * http://getbootstrap.com/javascript/#modals
  4677. * ========================================================================
  4678. * Copyright 2011-2014 Twitter, Inc.
  4679. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4680. * ======================================================================== */
  4681. !function($) {
  4682. 'use strict';
  4683. // MODAL CLASS DEFINITION
  4684. // ======================
  4685. var Modal = function(element, options) {
  4686. this.options = options;
  4687. this.$body = $(document.body);
  4688. this.$element = $(element);
  4689. this.$backdrop =
  4690. this.isShown = null;
  4691. this.scrollbarWidth = 0;
  4692. if (this.options.remote) {
  4693. this.$element.find('.modal-content').load(this.options.remote, $.proxy(function() {
  4694. this.$element.trigger('loaded.bs.modal');
  4695. },
  4696. this))
  4697. }
  4698. }
  4699. Modal.VERSION = '3.3.0';
  4700. Modal.TRANSITION_DURATION = 300;
  4701. Modal.BACKDROP_TRANSITION_DURATION = 150;
  4702. Modal.DEFAULTS = {
  4703. backdrop: true,
  4704. keyboard: true,
  4705. show: true,
  4706. }
  4707. Modal.prototype.toggle = function(_relatedTarget) {
  4708. return this.isShown ? this.hide() : this.show(_relatedTarget)
  4709. }
  4710. Modal.prototype.show = function(_relatedTarget) {
  4711. var that = this;
  4712. var e = $.Event('show.bs.modal', {
  4713. relatedTarget: _relatedTarget
  4714. });
  4715. this.$element.trigger(e);
  4716. if (this.isShown || e.isDefaultPrevented()) return;
  4717. this.isShown = true;
  4718. this.checkScrollbar();
  4719. this.$body.addClass('modal-open');
  4720. this.setScrollbar();
  4721. this.escape();
  4722. this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this));
  4723. this.backdrop(function() {
  4724. var transition = $.support.transition && that.$element.hasClass('fade');
  4725. if (!that.$element.parent().length) {
  4726. that.$element.appendTo(that.$body); // don't move modals dom position
  4727. }
  4728. that.$element.show().scrollTop(0);
  4729. if (transition) {
  4730. that.$element[0].offsetWidth; // force reflow
  4731. }
  4732. that.$element.addClass('in').attr('aria-hidden', false);
  4733. that.enforceFocus();
  4734. var e = $.Event('shown.bs.modal', {
  4735. relatedTarget: _relatedTarget
  4736. })
  4737. transition ? that.$element.find('.modal-dialog') // wait for modal to slide in
  4738. .one('bsTransitionEnd',
  4739. function() {
  4740. that.$element.trigger('focus').trigger(e)
  4741. }).emulateTransitionEnd(Modal.TRANSITION_DURATION) : that.$element.trigger('focus').trigger(e)
  4742. })
  4743. }
  4744. Modal.prototype.hide = function(e) {
  4745. if (e) e.preventDefault();
  4746. e = $.Event('hide.bs.modal');
  4747. this.$element.trigger(e);
  4748. if (!this.isShown || e.isDefaultPrevented()) return;
  4749. this.isShown = false;
  4750. this.escape();
  4751. $(document).off('focusin.bs.modal');
  4752. this.$element.removeClass('in').attr('aria-hidden', true).off('click.dismiss.bs.modal');
  4753. $.support.transition && this.$element.hasClass('fade') ? this.$element.one('bsTransitionEnd', $.proxy(this.hideModal, this)).emulateTransitionEnd(Modal.TRANSITION_DURATION) : this.hideModal()
  4754. }
  4755. Modal.prototype.enforceFocus = function() {
  4756. $(document).off('focusin.bs.modal') // guard against infinite focus loop
  4757. .on('focusin.bs.modal', $.proxy(function(e) {
  4758. if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
  4759. this.$element.trigger('focus')
  4760. }
  4761. },
  4762. this))
  4763. }
  4764. Modal.prototype.escape = function() {
  4765. if (this.isShown && this.options.keyboard) {
  4766. this.$element.on('keydown.dismiss.bs.modal', $.proxy(function(e) {
  4767. e.which == 27 && this.hide()
  4768. },
  4769. this))
  4770. } else if (!this.isShown) {
  4771. this.$element.off('keydown.dismiss.bs.modal')
  4772. }
  4773. }
  4774. Modal.prototype.hideModal = function() {
  4775. var that = this;
  4776. this.$element.hide();
  4777. this.backdrop(function() {
  4778. that.$body.removeClass('modal-open');
  4779. that.resetScrollbar();
  4780. that.$element.trigger('hidden.bs.modal');
  4781. })
  4782. }
  4783. Modal.prototype.removeBackdrop = function() {
  4784. this.$backdrop && this.$backdrop.remove();
  4785. this.$backdrop = null;
  4786. }
  4787. Modal.prototype.backdrop = function(callback) {
  4788. var that = this
  4789. var animate = this.$element.hasClass('fade') ? 'fade': ''
  4790. if (this.isShown && this.options.backdrop) {
  4791. var doAnimate = $.support.transition && animate
  4792. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />').prependTo(this.$element).on('click.dismiss.bs.modal', $.proxy(function(e) {
  4793. if (e.target !== e.currentTarget) return this.options.backdrop == 'static' ? this.$element[0].focus.call(this.$element[0]) : this.hide.call(this)
  4794. },
  4795. this))
  4796. if (doAnimate) this.$backdrop[0].offsetWidth; // force reflow
  4797. this.$backdrop.addClass('in');
  4798. if (!callback) return;
  4799. doAnimate ? this.$backdrop.one('bsTransitionEnd', callback).emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : callback();
  4800. } else if (!this.isShown && this.$backdrop) {
  4801. this.$backdrop.removeClass('in');
  4802. var callbackRemove = function() {
  4803. that.removeBackdrop();
  4804. callback && callback();
  4805. }
  4806. $.support.transition && this.$element.hasClass('fade') ? this.$backdrop.one('bsTransitionEnd', callbackRemove).emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : callbackRemove()
  4807. } else if (callback) {
  4808. callback();
  4809. }
  4810. }
  4811. Modal.prototype.checkScrollbar = function() {
  4812. this.scrollbarWidth = this.measureScrollbar();
  4813. }
  4814. Modal.prototype.setScrollbar = function() {
  4815. var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10);
  4816. if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth);
  4817. }
  4818. Modal.prototype.resetScrollbar = function() {
  4819. this.$body.css('padding-right', '')
  4820. }
  4821. Modal.prototype.measureScrollbar = function() { // thx walsh
  4822. if (document.body.clientWidth >= window.innerWidth) return 0
  4823. var scrollDiv = document.createElement('div');
  4824. scrollDiv.className = 'modal-scrollbar-measure';
  4825. this.$body.append(scrollDiv);
  4826. var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
  4827. this.$body[0].removeChild(scrollDiv);
  4828. return scrollbarWidth;
  4829. }
  4830. // MODAL PLUGIN DEFINITION
  4831. // =======================
  4832. function Plugin(option, _relatedTarget) {
  4833. return this.each(function() {
  4834. var $this = $(this);
  4835. var data = $this.data('bs.modal');
  4836. var options = $.extend({},Modal.DEFAULTS, $this.data(), typeof option == 'object' && option);
  4837. if (!data) $this.data('bs.modal', (data = new Modal(this, options)));
  4838. if (typeof option == 'string') data[option](_relatedTarget);
  4839. else if (options.show) data.show(_relatedTarget);
  4840. })
  4841. }
  4842. var old = $.fn.modal;
  4843. $.fn.modal = Plugin;
  4844. $.fn.modal.Constructor = Modal;
  4845. // MODAL NO CONFLICT
  4846. // =================
  4847. $.fn.modal.noConflict = function() {
  4848. $.fn.modal = old;
  4849. return this;
  4850. }
  4851. // MODAL DATA-API
  4852. // ==============
  4853. $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]',
  4854. function(e) {
  4855. var $this = $(this);
  4856. var href = $this.attr('href');
  4857. var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))); // strip for ie7
  4858. var option = $target.data('bs.modal') ? 'toggle': $.extend({remote: !/#/.test(href) && href},$target.data(), $this.data());
  4859. if ($this.is('a')) e.preventDefault();
  4860. $target.one('show.bs.modal',function(showEvent) {
  4861. if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
  4862. $target.one('hidden.bs.modal',function() {
  4863. $this.is(':visible') && $this.trigger('focus');
  4864. });
  4865. });
  4866. Plugin.call($target, option, this);
  4867. });
  4868. } (window.jQuery);
  4869. /* =======================================================================
  4870. * Bootstrap.dropdown.js v3.3.0
  4871. * http://getbootstrap.com/javascript/#dropdowns
  4872. * ========================================================================
  4873. * Copyright 2011-2014 Twitter, Inc.
  4874. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4875. * ======================================================================== */
  4876. !function($) {
  4877. 'use strict';
  4878. var backdrop = '.dropdown-backdrop';
  4879. var toggle = '[data-toggle="dropdown"]';
  4880. var Dropdown = function(element) {
  4881. $(element).on('click.bs.dropdown', this.toggle)
  4882. }
  4883. Dropdown.VERSION = '3.3.5';
  4884. function getParent($this) {
  4885. var selector = $this.attr('data-target');
  4886. if (!selector) {
  4887. selector = $this.attr('href');
  4888. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
  4889. }
  4890. var $parent = selector && $(selector);
  4891. return $parent && $parent.length ? $parent: $this.parent();
  4892. }
  4893. function clearMenus(e) {
  4894. if (e && e.which === 3) return $(backdrop).remove();
  4895. $(toggle).each(function() {
  4896. var $this = $(this);
  4897. var $parent = getParent($this);
  4898. var relatedTarget = {
  4899. relatedTarget: this
  4900. }
  4901. if (!$parent.hasClass('open')) return;
  4902. 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));
  4903. if (e.isDefaultPrevented()) return;
  4904. $this.attr('aria-expanded', 'false');
  4905. $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget);
  4906. });
  4907. }
  4908. Dropdown.prototype.toggle = function(e) {
  4909. var $this = $(this);
  4910. if ($this.is('.disabled, :disabled')) return;
  4911. var $parent = getParent($this);
  4912. var isActive = $parent.hasClass('open');
  4913. clearMenus();
  4914. if (!isActive) {
  4915. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  4916. // if mobile we use a backdrop because click events don't delegate
  4917. $(document.createElement('div')).addClass('dropdown-backdrop').insertAfter($(this)).on('click', clearMenus);
  4918. }
  4919. var relatedTarget = {
  4920. relatedTarget: this
  4921. }
  4922. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget));
  4923. if (e.isDefaultPrevented()) return $this.trigger('focus').attr('aria-expanded', 'true');
  4924. $parent.toggleClass('open').trigger('shown.bs.dropdown', relatedTarget);
  4925. }
  4926. return false;
  4927. }
  4928. Dropdown.prototype.keydown = function(e) {
  4929. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return;
  4930. var $this = $(this);
  4931. e.preventDefault();
  4932. e.stopPropagation();
  4933. if ($this.is('.disabled, :disabled')) return;
  4934. var $parent = getParent($this);
  4935. var isActive = $parent.hasClass('open');
  4936. if (!isActive && e.which != 27 || isActive && e.which == 27) {
  4937. if (e.which == 27)
  4938. $parent.find(toggle).trigger('focus');
  4939. return;
  4940. $this.trigger('click');
  4941. }
  4942. var desc = ' li:not(.disabled):visible a';
  4943. var $items = $parent.find('.dropdown-menu' + desc);
  4944. if (!$items.length) return;
  4945. var index = $items.index(e.target);
  4946. if (e.which == 38 && index > 0) index-- // up
  4947. if (e.which == 40 && index < $items.length - 1) index++; // down
  4948. if (!~index) index = 0;
  4949. $items.eq(index).trigger('focus');
  4950. }
  4951. function Plugin(option) {
  4952. return this.each(function() {
  4953. var $this = $(this);
  4954. var data = $this.data('bs.dropdown');
  4955. if (!data) {
  4956. $this.data('bs.dropdown', (data = new Dropdown(this)));
  4957. }
  4958. if (typeof option == 'string') {
  4959. data[option].call($this);
  4960. }
  4961. });
  4962. }
  4963. var old = $.fn.dropdown;
  4964. $.fn.dropdown = Plugin;
  4965. $.fn.dropdown.Constructor = Dropdown;
  4966. $.fn.dropdown.noConflict = function() {
  4967. $.fn.dropdown = old;
  4968. return this;
  4969. }
  4970. $(document).on('click.bs.dropdown.data-api', clearMenus).on('click.bs.dropdown.data-api', '.dropdown form',
  4971. function(e) {
  4972. e.stopPropagation()
  4973. }).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);
  4974. } (window.jQuery);
  4975. $(function() {
  4976. /*下拉菜单*/
  4977. $(document).on("mouseenter", ".dropDown",
  4978. function() {
  4979. $(this).addClass("hover");
  4980. });
  4981. $(document).on("mouseleave", ".dropDown",
  4982. function() {
  4983. $(this).removeClass("hover");
  4984. });
  4985. $(document).on("mouseenter", ".dropDown_hover",
  4986. function() {
  4987. $(this).addClass("open");
  4988. });
  4989. $(document).on("mouseleave", ".dropDown_hover",
  4990. function() {
  4991. $(this).removeClass("open");
  4992. });
  4993. $(document).on("click", ".dropDown-menu li a",
  4994. function() {
  4995. $(".dropDown").removeClass('open');
  4996. });
  4997. $(document).on("mouseenter", ".menu > li",
  4998. function() {
  4999. $(this).addClass("open");
  5000. });
  5001. $(document).on("mouseleave", ".menu > li",
  5002. function() {
  5003. $(this).removeClass("open");
  5004. });
  5005. });
  5006. /* =======================================================================
  5007. * Bootstrap.transition.js v3.3.0
  5008. * http://getbootstrap.com/javascript/#transitions
  5009. * ========================================================================
  5010. * Copyright 2011-2014 Twitter, Inc.
  5011. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5012. * ======================================================================== */
  5013. !function ($) {
  5014. 'use strict';
  5015. function transitionEnd() {
  5016. var el = document.createElement('bootstrap');
  5017. var transEndEventNames = {
  5018. WebkitTransition : 'webkitTransitionEnd',
  5019. MozTransition : 'transitionend',
  5020. OTransition : 'oTransitionEnd otransitionend',
  5021. transition : 'transitionend'
  5022. }
  5023. for (var name in transEndEventNames) {
  5024. if (el.style[name] !== undefined) {
  5025. return { end: transEndEventNames[name] }
  5026. }
  5027. }
  5028. return false // explicit for ie8 ( ._.)
  5029. }
  5030. // http://blog.alexmaccaw.com/css-transitions
  5031. $.fn.emulateTransitionEnd = function (duration) {
  5032. var called = false;
  5033. var $el = this;
  5034. $(this).one('bsTransitionEnd', function () { called = true })
  5035. var callback = function () {
  5036. if (!called) $($el).trigger($.support.transition.end)
  5037. }
  5038. setTimeout(callback, duration);
  5039. return this;
  5040. }
  5041. $(function () {
  5042. $.support.transition = transitionEnd();
  5043. if (!$.support.transition) return;
  5044. $.event.special.bsTransitionEnd = {
  5045. bindType: $.support.transition.end,
  5046. delegateType: $.support.transition.end,
  5047. handle: function (e) {
  5048. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments);
  5049. }
  5050. }
  5051. })
  5052. }(window.jQuery);
  5053. /* =======================================================================
  5054. * Bootstrap.tooltip.js v3.3.0
  5055. * http://getbootstrap.com/javascript/#tooltip
  5056. * Inspired by the original jQuery.tipsy by Jason Frame
  5057. * ========================================================================
  5058. * Copyright 2011-2014 Twitter, Inc.
  5059. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5060. * ======================================================================== */
  5061. !function($) {
  5062. 'use strict';
  5063. // TOOLTIP PUBLIC CLASS DEFINITION
  5064. // ===============================
  5065. var Tooltip = function(element, options) {
  5066. this.type = this.options = this.enabled = this.timeout = this.hoverState = this.$element = null;
  5067. this.init('tooltip', element, options);
  5068. }
  5069. Tooltip.VERSION = '3.3.0';
  5070. Tooltip.TRANSITION_DURATION = 150;
  5071. Tooltip.DEFAULTS = {
  5072. animation: true,
  5073. placement: 'top',
  5074. selector: false,
  5075. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  5076. trigger: 'hover focus',
  5077. title: '',
  5078. delay: 0,
  5079. html: false,
  5080. container: false,
  5081. viewport: {
  5082. selector: 'body',
  5083. padding: 0
  5084. }
  5085. }
  5086. Tooltip.prototype.init = function(type, element, options) {
  5087. this.enabled = true;
  5088. this.type = type;
  5089. this.$element = $(element);
  5090. this.options = this.getOptions(options);
  5091. this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport);
  5092. var triggers = this.options.trigger.split(' ');
  5093. for (var i = triggers.length; i--;) {
  5094. var trigger = triggers[i];
  5095. if (trigger == 'click') {
  5096. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this));
  5097. } else if (trigger != 'manual') {
  5098. var eventIn = trigger == 'hover' ? 'mouseenter': 'focusin';
  5099. var eventOut = trigger == 'hover' ? 'mouseleave': 'focusout';
  5100. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this));
  5101. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this));
  5102. }
  5103. }
  5104. this.options.selector ? (this._options = $.extend({},
  5105. this.options, {
  5106. trigger: 'manual',
  5107. selector: ''
  5108. })) : this.fixTitle()
  5109. }
  5110. Tooltip.prototype.getDefaults = function() {
  5111. return Tooltip.DEFAULTS;
  5112. }
  5113. Tooltip.prototype.getOptions = function(options) {
  5114. options = $.extend({},
  5115. this.getDefaults(), this.$element.data(), options);
  5116. if (options.delay && typeof options.delay == 'number') {
  5117. options.delay = {
  5118. show: options.delay,
  5119. hide: options.delay
  5120. }
  5121. }
  5122. return options;
  5123. }
  5124. Tooltip.prototype.getDelegateOptions = function() {
  5125. var options = {}
  5126. var defaults = this.getDefaults()
  5127. this._options && $.each(this._options,
  5128. function(key, value) {
  5129. if (defaults[key] != value) options[key] = value;
  5130. })
  5131. return options;
  5132. }
  5133. Tooltip.prototype.enter = function(obj) {
  5134. var self = obj instanceof this.constructor ?
  5135. obj: $(obj.currentTarget).data('bs.' + this.type);
  5136. if (self && self.$tip && self.$tip.is(':visible')) {
  5137. self.hoverState = 'in';
  5138. return;
  5139. }
  5140. if (!self) {
  5141. self = new this.constructor(obj.currentTarget, this.getDelegateOptions());
  5142. $(obj.currentTarget).data('bs.' + this.type, self);
  5143. }
  5144. clearTimeout(self.timeout);
  5145. self.hoverState = 'in';
  5146. if (!self.options.delay || !self.options.delay.show) return self.show()
  5147. self.timeout = setTimeout(function() {
  5148. if (self.hoverState == 'in') self.show();
  5149. },
  5150. self.options.delay.show);
  5151. }
  5152. Tooltip.prototype.leave = function(obj) {
  5153. var self = obj instanceof this.constructor ? obj: $(obj.currentTarget).data('bs.' + this.type);
  5154. if (!self) {
  5155. self = new this.constructor(obj.currentTarget, this.getDelegateOptions());
  5156. $(obj.currentTarget).data('bs.' + this.type, self);
  5157. }
  5158. clearTimeout(self.timeout);
  5159. self.hoverState = 'out';
  5160. if (!self.options.delay || !self.options.delay.hide) return self.hide();
  5161. self.timeout = setTimeout(function() {
  5162. if (self.hoverState == 'out') self.hide();
  5163. },
  5164. self.options.delay.hide);
  5165. }
  5166. Tooltip.prototype.show = function() {
  5167. var e = $.Event('show.bs.' + this.type);
  5168. if (this.hasContent() && this.enabled) {
  5169. this.$element.trigger(e);
  5170. var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]);
  5171. if (e.isDefaultPrevented() || !inDom) return;
  5172. var that = this;
  5173. var $tip = this.tip();
  5174. var tipId = this.getUID(this.type);
  5175. this.setContent();
  5176. $tip.attr('id', tipId);
  5177. this.$element.attr('aria-describedby', tipId);
  5178. if (this.options.animation) $tip.addClass('fade');
  5179. var placement = typeof this.options.placement == 'function' ? this.options.placement.call(this, $tip[0], this.$element[0]) : this.options.placement;
  5180. var autoToken = /\s?auto?\s?/i;
  5181. var autoPlace = autoToken.test(placement);
  5182. if (autoPlace) placement = placement.replace(autoToken, '') || 'top';
  5183. $tip.detach().css({
  5184. top: 0,
  5185. left: 0,
  5186. display: 'block'
  5187. }).addClass(placement).data('bs.' + this.type, this);
  5188. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element);
  5189. var pos = this.getPosition();
  5190. var actualWidth = $tip[0].offsetWidth;
  5191. var actualHeight = $tip[0].offsetHeight;
  5192. if (autoPlace) {
  5193. var orgPlacement = placement;
  5194. var $container = this.options.container ? $(this.options.container) : this.$element.parent();
  5195. var containerDim = this.getPosition($container);
  5196. 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
  5197. $tip.removeClass(orgPlacement).addClass(placement);
  5198. }
  5199. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight);
  5200. this.applyPlacement(calculatedOffset, placement);
  5201. var complete = function() {
  5202. var prevHoverState = that.hoverState;
  5203. that.$element.trigger('shown.bs.' + that.type);
  5204. that.hoverState = null;
  5205. if (prevHoverState == 'out') that.leave(that);
  5206. }
  5207. $.support.transition && this.$tip.hasClass('fade') ? $tip.one('bsTransitionEnd', complete).emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : complete()
  5208. }
  5209. }
  5210. Tooltip.prototype.applyPlacement = function(offset, placement) {
  5211. var $tip = this.tip();
  5212. var width = $tip[0].offsetWidth;
  5213. var height = $tip[0].offsetHeight;
  5214. // manually read margins because getBoundingClientRect includes difference
  5215. var marginTop = parseInt($tip.css('margin-top'), 10);
  5216. var marginLeft = parseInt($tip.css('margin-left'), 10);
  5217. // we must check for NaN for ie 8/9
  5218. if (isNaN(marginTop)) marginTop = 0;
  5219. if (isNaN(marginLeft)) marginLeft = 0;
  5220. offset.top = offset.top + marginTop;
  5221. offset.left = offset.left + marginLeft;
  5222. // $.fn.offset doesn't round pixel values
  5223. // so we use setOffset directly with our own function B-0
  5224. $.offset.setOffset($tip[0], $.extend({
  5225. using: function(props) {
  5226. $tip.css({
  5227. top: Math.round(props.top),
  5228. left: Math.round(props.left)
  5229. })
  5230. }
  5231. },
  5232. offset), 0);
  5233. $tip.addClass('in');
  5234. // check to see if placing tip in new offset caused the tip to resize itself
  5235. var actualWidth = $tip[0].offsetWidth;
  5236. var actualHeight = $tip[0].offsetHeight;
  5237. if (placement == 'top' && actualHeight != height) {
  5238. offset.top = offset.top + height - actualHeight;
  5239. }
  5240. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight);
  5241. if (delta.left) offset.left += delta.left;
  5242. else offset.top += delta.top;
  5243. var isVertical = /top|bottom/.test(placement);
  5244. var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth: delta.top * 2 - height + actualHeight;
  5245. var arrowOffsetPosition = isVertical ? 'offsetWidth': 'offsetHeight';
  5246. $tip.offset(offset);
  5247. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical);
  5248. }
  5249. Tooltip.prototype.replaceArrow = function(delta, dimension, isHorizontal) {
  5250. this.arrow().css(isHorizontal ? 'left': 'top', 50 * (1 - delta / dimension) + '%').css(isHorizontal ? 'top': 'left', '');
  5251. }
  5252. Tooltip.prototype.setContent = function() {
  5253. var $tip = this.tip();
  5254. var title = this.getTitle();
  5255. $tip.find('.tooltip-inner')[this.options.html ? 'html': 'text'](title);
  5256. $tip.removeClass('fade in top bottom left right');
  5257. }
  5258. Tooltip.prototype.hide = function(callback) {
  5259. var that = this;
  5260. var $tip = this.tip();
  5261. var e = $.Event('hide.bs.' + this.type);
  5262. function complete() {
  5263. if (that.hoverState != 'in') $tip.detach();
  5264. that.$element.removeAttr('aria-describedby').trigger('hidden.bs.' + that.type);
  5265. callback && callback();
  5266. }
  5267. this.$element.trigger(e);
  5268. if (e.isDefaultPrevented()) return;
  5269. $tip.removeClass('in');
  5270. $.support.transition && this.$tip.hasClass('fade') ? $tip.one('bsTransitionEnd', complete).emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : complete();
  5271. this.hoverState = null;
  5272. return this;
  5273. }
  5274. Tooltip.prototype.fixTitle = function() {
  5275. var $e = this.$element
  5276. if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
  5277. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  5278. }
  5279. }
  5280. Tooltip.prototype.hasContent = function() {
  5281. return this.getTitle();
  5282. }
  5283. Tooltip.prototype.getPosition = function($element) {
  5284. $element = $element || this.$element;
  5285. var el = $element[0];
  5286. var isBody = el.tagName == 'BODY';
  5287. var elRect = el.getBoundingClientRect();
  5288. if (elRect.width == null) {
  5289. // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
  5290. elRect = $.extend({},
  5291. elRect, {
  5292. width: elRect.right - elRect.left,
  5293. height: elRect.bottom - elRect.top
  5294. });
  5295. }
  5296. var elOffset = isBody ? {
  5297. top: 0,
  5298. left: 0
  5299. }: $element.offset();
  5300. var scroll = {
  5301. scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop: $element.scrollTop()
  5302. }
  5303. var outerDims = isBody ? {
  5304. width: $(window).width(),
  5305. height: $(window).height()
  5306. }: null
  5307. return $.extend({},
  5308. elRect, scroll, outerDims, elOffset)
  5309. }
  5310. Tooltip.prototype.getCalculatedOffset = function(placement, pos, actualWidth, actualHeight) {
  5311. return placement == 'bottom' ? {
  5312. top: pos.top + pos.height,
  5313. left: pos.left + pos.width / 2 - actualWidth / 2
  5314. }: placement == 'top' ? {
  5315. top: pos.top - actualHeight,
  5316. left: pos.left + pos.width / 2 - actualWidth / 2
  5317. }: placement == 'left' ? {
  5318. top: pos.top + pos.height / 2 - actualHeight / 2,
  5319. left: pos.left - actualWidth
  5320. }:
  5321. /* placement == 'right' */
  5322. {
  5323. top: pos.top + pos.height / 2 - actualHeight / 2,
  5324. left: pos.left + pos.width
  5325. }
  5326. }
  5327. Tooltip.prototype.getViewportAdjustedDelta = function(placement, pos, actualWidth, actualHeight) {
  5328. var delta = {
  5329. top: 0,
  5330. left: 0
  5331. }
  5332. if (!this.$viewport) return delta;
  5333. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0;
  5334. var viewportDimensions = this.getPosition(this.$viewport);
  5335. if (/right|left/.test(placement)) {
  5336. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll;
  5337. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight;
  5338. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  5339. delta.top = viewportDimensions.top - topEdgeOffset;
  5340. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  5341. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset;
  5342. }
  5343. } else {
  5344. var leftEdgeOffset = pos.left - viewportPadding;
  5345. var rightEdgeOffset = pos.left + viewportPadding + actualWidth;
  5346. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  5347. delta.left = viewportDimensions.left - leftEdgeOffset;
  5348. } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
  5349. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset;
  5350. }
  5351. }
  5352. return delta
  5353. }
  5354. Tooltip.prototype.getTitle = function() {
  5355. var title;
  5356. var $e = this.$element;
  5357. var o = this.options;
  5358. title = $e.attr('data-original-title') || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  5359. return title;
  5360. }
  5361. Tooltip.prototype.getUID = function(prefix) {
  5362. do prefix += ~~ (Math.random() * 1000000);
  5363. while (document.getElementById(prefix));
  5364. return prefix;
  5365. }
  5366. Tooltip.prototype.tip = function() {
  5367. return (this.$tip = this.$tip || $(this.options.template));
  5368. }
  5369. Tooltip.prototype.arrow = function() {
  5370. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'));
  5371. }
  5372. Tooltip.prototype.enable = function() {
  5373. this.enabled = true;
  5374. }
  5375. Tooltip.prototype.disable = function() {
  5376. this.enabled = false;
  5377. }
  5378. Tooltip.prototype.toggleEnabled = function() {
  5379. this.enabled = !this.enabled;
  5380. }
  5381. Tooltip.prototype.toggle = function(e) {
  5382. var self = this;
  5383. if (e) {
  5384. self = $(e.currentTarget).data('bs.' + this.type);
  5385. if (!self) {
  5386. self = new this.constructor(e.currentTarget, this.getDelegateOptions());
  5387. $(e.currentTarget).data('bs.' + this.type, self);
  5388. }
  5389. }
  5390. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  5391. }
  5392. Tooltip.prototype.destroy = function() {
  5393. var that = this;
  5394. clearTimeout(this.timeout);
  5395. this.hide(function() {
  5396. that.$element.off('.' + that.type).removeData('bs.' + that.type);
  5397. });
  5398. }
  5399. // TOOLTIP PLUGIN DEFINITION
  5400. // =========================
  5401. function Plugin(option) {
  5402. return this.each(function() {
  5403. var $this = $(this);
  5404. var data = $this.data('bs.tooltip');
  5405. var options = typeof option == 'object' && option;
  5406. var selector = options && options.selector;
  5407. if (!data && option == 'destroy') return;
  5408. if (selector) {
  5409. if (!data) $this.data('bs.tooltip', (data = {}));
  5410. if (!data[selector]) data[selector] = new Tooltip(this, options);
  5411. } else {
  5412. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)));
  5413. }
  5414. if (typeof option == 'string') data[option]()
  5415. })
  5416. }
  5417. var old = $.fn.tooltip;
  5418. $.fn.tooltip = Plugin;
  5419. $.fn.tooltip.Constructor = Tooltip;
  5420. // TOOLTIP NO CONFLICT
  5421. // ===================
  5422. $.fn.tooltip.noConflict = function() {
  5423. $.fn.tooltip = old;
  5424. return this;
  5425. }
  5426. } (window.jQuery);
  5427. $(function() {
  5428. $("[data-toggle='tooltip']").tooltip();
  5429. });
  5430. /* =======================================================================
  5431. * Bootstrap.popover.js v3.3.0
  5432. * http://getbootstrap.com/javascript/#popovers
  5433. * ========================================================================
  5434. * Copyright 2011-2014 Twitter, Inc.
  5435. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5436. * ======================================================================== */
  5437. !
  5438. function($) {
  5439. 'use strict';
  5440. // POPOVER PUBLIC CLASS DEFINITION
  5441. // ===============================
  5442. var Popover = function(element, options) {
  5443. this.init('popover', element, options)
  5444. }
  5445. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js');
  5446. Popover.VERSION = '3.3.0';
  5447. Popover.DEFAULTS = $.extend({},
  5448. $.fn.tooltip.Constructor.DEFAULTS, {
  5449. placement: 'right',
  5450. trigger: 'click',
  5451. content: '',
  5452. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  5453. })
  5454. // NOTE: POPOVER EXTENDS tooltip.js
  5455. // ================================
  5456. Popover.prototype = $.extend({},$.fn.tooltip.Constructor.prototype);
  5457. Popover.prototype.constructor = Popover;
  5458. Popover.prototype.getDefaults = function() {
  5459. return Popover.DEFAULTS;
  5460. }
  5461. Popover.prototype.setContent = function() {
  5462. var $tip = this.tip();
  5463. var title = this.getTitle();
  5464. var content = this.getContent();
  5465. $tip.find('.popover-title')[this.options.html ? 'html': 'text'](title);
  5466. $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
  5467. this.options.html ? (typeof content == 'string' ? 'html': 'append') : 'text'](content)
  5468. $tip.removeClass('fade top bottom left right in');
  5469. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  5470. // this manually by checking the contents.
  5471. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide();
  5472. }
  5473. Popover.prototype.hasContent = function() {
  5474. return this.getTitle() || this.getContent()
  5475. }
  5476. Popover.prototype.getContent = function() {
  5477. var $e = this.$element;
  5478. var o = this.options;
  5479. return $e.attr('data-content') || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
  5480. }
  5481. Popover.prototype.arrow = function() {
  5482. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  5483. }
  5484. Popover.prototype.tip = function() {
  5485. if (!this.$tip) this.$tip = $(this.options.template);
  5486. return this.$tip;
  5487. }
  5488. // POPOVER PLUGIN DEFINITION
  5489. // =========================
  5490. function Plugin(option) {
  5491. return this.each(function() {
  5492. var $this = $(this);
  5493. var data = $this.data('bs.popover');
  5494. var options = typeof option == 'object' && option;
  5495. var selector = options && options.selector;
  5496. if (!data && option == 'destroy') return;
  5497. if (selector) {
  5498. if (!data) $this.data('bs.popover', (data = {}));
  5499. if (!data[selector]) data[selector] = new Popover(this, options);
  5500. } else {
  5501. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  5502. }
  5503. if (typeof option == 'string') data[option]()
  5504. })
  5505. }
  5506. var old = $.fn.popover
  5507. $.fn.popover = Plugin;
  5508. $.fn.popover.Constructor = Popover;
  5509. // POPOVER NO CONFLICT
  5510. // ===================
  5511. $.fn.popover.noConflict = function() {
  5512. $.fn.popover = old;
  5513. return this;
  5514. }
  5515. } (window.jQuery);
  5516. $(function() {
  5517. $("[data-toggle='popover']").popover();
  5518. });
  5519. /* =======================================================================
  5520. * Bootstrap.alert.js v3.3.0
  5521. * http://getbootstrap.com/javascript/#alerts
  5522. * ========================================================================
  5523. * Copyright 2011-2014 Twitter, Inc.
  5524. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5525. * ======================================================================== */
  5526. !function($) {
  5527. 'use strict';
  5528. // ALERT CLASS DEFINITION
  5529. // ======================
  5530. var dismiss = '[data-dismiss="alert"]'
  5531. var Alert = function(el) {
  5532. $(el).on('click', dismiss, this.close)
  5533. }
  5534. Alert.VERSION = '3.3.0'
  5535. Alert.TRANSITION_DURATION = 150
  5536. Alert.prototype.close = function(e) {
  5537. var $this = $(this);
  5538. var selector = $this.attr('data-target');
  5539. if (!selector) {
  5540. selector = $this.attr('href');
  5541. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
  5542. }
  5543. var $parent = $(selector);
  5544. if (e) e.preventDefault();
  5545. if (!$parent.length) {
  5546. $parent = $this.closest('.alert');
  5547. }
  5548. $parent.trigger(e = $.Event('close.bs.alert'))
  5549. if (e.isDefaultPrevented()) return;
  5550. $parent.removeClass('in');
  5551. function removeElement() {
  5552. // detach from parent, fire event then clean up data
  5553. $parent.detach().trigger('closed.bs.alert').remove();
  5554. }
  5555. $.support.transition && $parent.hasClass('fade') ? $parent.one('bsTransitionEnd', removeElement).emulateTransitionEnd(Alert.TRANSITION_DURATION) : removeElement()
  5556. }
  5557. // ALERT PLUGIN DEFINITION
  5558. // =======================
  5559. function Plugin(option) {
  5560. return this.each(function() {
  5561. var $this = $(this);
  5562. var data = $this.data('bs.alert');
  5563. if (!data) $this.data('bs.alert', (data = new Alert(this)));
  5564. if (typeof option == 'string') data[option].call($this);
  5565. })
  5566. }
  5567. var old = $.fn.alert;
  5568. $.fn.alert = Plugin;
  5569. $.fn.alert.Constructor = Alert;
  5570. // ALERT NO CONFLICT
  5571. // =================
  5572. $.fn.alert.noConflict = function() {
  5573. $.fn.alert = old;
  5574. return this;
  5575. }
  5576. // ALERT DATA-API
  5577. // ==============
  5578. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  5579. } (window.jQuery);
  5580. /* =========================================================
  5581. * Bootstrap.slider.js v1.0.1
  5582. * Maintainers:
  5583. * Kyle Kemp
  5584. * - Twitter: @seiyria
  5585. * - Github: seiyria
  5586. * Rohit Kalkur
  5587. * - Twitter: @Rovolutionary
  5588. * - Github: rovolution
  5589. *
  5590. * =========================================================
  5591. *
  5592. * Licensed under the Apache License, Version 2.0 (the "License");
  5593. * you may not use this file except in compliance with the License.
  5594. * You may obtain a copy of the License at
  5595. *
  5596. * http://www.apache.org/licenses/LICENSE-2.0
  5597. *
  5598. * Unless required by applicable law or agreed to in writing, software
  5599. * distributed under the License is distributed on an "AS IS" BASIS,
  5600. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5601. * See the License for the specific language governing permissions and
  5602. * limitations under the License.
  5603. * Bridget makes jQuery widgets
  5604. * MIT license
  5605. * ========================================================= */
  5606. (function(root, factory) {
  5607. if (typeof define === "function" && define.amd) {
  5608. define(["jquery"], factory);
  5609. } else if (typeof module === "object" && module.exports) {
  5610. var jQuery;
  5611. try {
  5612. jQuery = require("jquery");
  5613. } catch(err) {
  5614. jQuery = null;
  5615. }
  5616. module.exports = factory(jQuery);
  5617. } else {
  5618. root.Slider = factory(root.jQuery);
  5619. }
  5620. } (this,
  5621. function($) {
  5622. // Reference to Slider constructor
  5623. var Slider; (function($) {
  5624. 'use strict';
  5625. // -------------------------- utils -------------------------- //
  5626. var slice = Array.prototype.slice;
  5627. function noop() {}
  5628. // -------------------------- definition -------------------------- //
  5629. function defineBridget($) {
  5630. // bail if no jQuery
  5631. if (!$) {
  5632. return;
  5633. }
  5634. // -------------------------- addOptionMethod -------------------------- //
  5635. /**
  5636. * adds option method -> $().plugin('option', {...})
  5637. * @param {Function} PluginClass - constructor class
  5638. */
  5639. function addOptionMethod(PluginClass) {
  5640. // don't overwrite original option method
  5641. if (PluginClass.prototype.option) {
  5642. return;
  5643. }
  5644. // option setter
  5645. PluginClass.prototype.option = function(opts) {
  5646. // bail out if not an object
  5647. if (!$.isPlainObject(opts)) {
  5648. return;
  5649. }
  5650. this.options = $.extend(true, this.options, opts);
  5651. };
  5652. }
  5653. // -------------------------- plugin bridge -------------------------- //
  5654. // helper function for logging errors
  5655. // $.error breaks jQuery chaining
  5656. var logError = typeof console === 'undefined' ? noop: function(message) {
  5657. console.error(message);
  5658. };
  5659. /**
  5660. * jQuery plugin bridge, access methods like $elem.plugin('method')
  5661. * @param {String} namespace - plugin name
  5662. * @param {Function} PluginClass - constructor class
  5663. */
  5664. function bridge(namespace, PluginClass) {
  5665. // add to jQuery fn namespace
  5666. $.fn[namespace] = function(options) {
  5667. if (typeof options === 'string') {
  5668. // call plugin method when first argument is a string
  5669. // get arguments for method
  5670. var args = slice.call(arguments, 1);
  5671. for (var i = 0,
  5672. len = this.length; i < len; i++) {
  5673. var elem = this[i];
  5674. var instance = $.data(elem, namespace);
  5675. if (!instance) {
  5676. logError("cannot call methods on " + namespace + " prior to initialization; " + "attempted to call '" + options + "'");
  5677. continue;
  5678. }
  5679. if (!$.isFunction(instance[options]) || options.charAt(0) === '_') {
  5680. logError("no such method '" + options + "' for " + namespace + " instance");
  5681. continue;
  5682. }
  5683. // trigger method with arguments
  5684. var returnValue = instance[options].apply(instance, args);
  5685. // break look and return first value if provided
  5686. if (returnValue !== undefined && returnValue !== instance) {
  5687. return returnValue;
  5688. }
  5689. }
  5690. // return this if no return value
  5691. return this;
  5692. } else {
  5693. var objects = this.map(function() {
  5694. var instance = $.data(this, namespace);
  5695. if (instance) {
  5696. // apply options & init
  5697. instance.option(options);
  5698. instance._init();
  5699. } else {
  5700. // initialize new instance
  5701. instance = new PluginClass(this, options);
  5702. $.data(this, namespace, instance);
  5703. }
  5704. return $(this);
  5705. });
  5706. if (!objects || objects.length > 1) {
  5707. return objects;
  5708. } else {
  5709. return objects[0];
  5710. }
  5711. }
  5712. };
  5713. }
  5714. // -------------------------- bridget -------------------------- //
  5715. /**
  5716. * converts a Prototypical class into a proper jQuery plugin
  5717. * the class must have a ._init method
  5718. * @param {String} namespace - plugin name, used in $().pluginName
  5719. * @param {Function} PluginClass - constructor class
  5720. */
  5721. $.bridget = function(namespace, PluginClass) {
  5722. addOptionMethod(PluginClass);
  5723. bridge(namespace, PluginClass);
  5724. };
  5725. return $.bridget;
  5726. }
  5727. // get jquery from browser global
  5728. defineBridget($);
  5729. })($);
  5730. /*************************************************
  5731. BOOTSTRAP-SLIDER SOURCE CODE
  5732. **************************************************/
  5733. (function($) {
  5734. var ErrorMsgs = {
  5735. formatInvalidInputErrorMsg: function(input) {
  5736. return "Invalid input value '" + input + "' passed in";
  5737. },
  5738. 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"
  5739. };
  5740. /*************************************************
  5741. CONSTRUCTOR
  5742. **************************************************/
  5743. Slider = function(element, options) {
  5744. createNewSlider.call(this, element, options);
  5745. return this;
  5746. };
  5747. function createNewSlider(element, options) {
  5748. /*************************************************
  5749. Create Markup
  5750. **************************************************/
  5751. if (typeof element === "string") {
  5752. this.element = document.querySelector(element);
  5753. } else if (element instanceof HTMLElement) {
  5754. this.element = element;
  5755. }
  5756. var origWidth = this.element.style.width;
  5757. var updateSlider = false;
  5758. var parent = this.element.parentNode;
  5759. var sliderTrackSelection;
  5760. var sliderMinHandle;
  5761. var sliderMaxHandle;
  5762. if (this.sliderElem) {
  5763. updateSlider = true;
  5764. } else {
  5765. /* Create elements needed for slider */
  5766. this.sliderElem = document.createElement("div");
  5767. this.sliderElem.className = "slider";
  5768. /* Create slider track elements */
  5769. var sliderTrack = document.createElement("div");
  5770. sliderTrack.className = "slider-track";
  5771. sliderTrackSelection = document.createElement("div");
  5772. sliderTrackSelection.className = "slider-selection";
  5773. sliderMinHandle = document.createElement("div");
  5774. sliderMinHandle.className = "slider-handle min-slider-handle";
  5775. sliderMaxHandle = document.createElement("div");
  5776. sliderMaxHandle.className = "slider-handle max-slider-handle";
  5777. sliderTrack.appendChild(sliderTrackSelection);
  5778. sliderTrack.appendChild(sliderMinHandle);
  5779. sliderTrack.appendChild(sliderMaxHandle);
  5780. var createAndAppendTooltipSubElements = function(tooltipElem) {
  5781. var arrow = document.createElement("div");
  5782. arrow.className = "tooltip-arrow";
  5783. var inner = document.createElement("div");
  5784. inner.className = "tooltip-inner";
  5785. tooltipElem.appendChild(arrow);
  5786. tooltipElem.appendChild(inner);
  5787. };
  5788. /* Create tooltip elements */
  5789. var sliderTooltip = document.createElement("div");
  5790. sliderTooltip.className = "tooltip tooltip-main";
  5791. createAndAppendTooltipSubElements(sliderTooltip);
  5792. var sliderTooltipMin = document.createElement("div");
  5793. sliderTooltipMin.className = "tooltip tooltip-min";
  5794. createAndAppendTooltipSubElements(sliderTooltipMin);
  5795. var sliderTooltipMax = document.createElement("div");
  5796. sliderTooltipMax.className = "tooltip tooltip-max";
  5797. createAndAppendTooltipSubElements(sliderTooltipMax);
  5798. /* Append components to sliderElem */
  5799. this.sliderElem.appendChild(sliderTrack);
  5800. this.sliderElem.appendChild(sliderTooltip);
  5801. this.sliderElem.appendChild(sliderTooltipMin);
  5802. this.sliderElem.appendChild(sliderTooltipMax);
  5803. /* Append slider element to parent container, right before the original <input> element */
  5804. parent.insertBefore(this.sliderElem, this.element);
  5805. /* Hide original <input> element */
  5806. this.element.style.display = "none";
  5807. }
  5808. /* If JQuery exists, cache JQ references */
  5809. if ($) {
  5810. this.$element = $(this.element);
  5811. this.$sliderElem = $(this.sliderElem);
  5812. }
  5813. /*************************************************
  5814. Process Options
  5815. **************************************************/
  5816. options = options ? options: {};
  5817. var optionTypes = Object.keys(this.defaultOptions);
  5818. for (var i = 0; i < optionTypes.length; i++) {
  5819. var optName = optionTypes[i];
  5820. // First check if an option was passed in via the constructor
  5821. var val = options[optName];
  5822. // If no data attrib, then check data atrributes
  5823. val = (typeof val !== 'undefined') ? val : getDataAttrib(this.element, optName);
  5824. // Finally, if nothing was specified, use the defaults
  5825. val = (val !== null) ? val : this.defaultOptions[optName];
  5826. // Set all options on the instance of the Slider
  5827. if (!this.options) {
  5828. this.options = {};
  5829. }
  5830. this.options[optName] = val;
  5831. }
  5832. function getDataAttrib(element, optName) {
  5833. var dataName = "data-slider-" + optName;
  5834. var dataValString = element.getAttribute(dataName);
  5835. try {
  5836. return JSON.parse(dataValString);
  5837. } catch(err) {
  5838. return dataValString;
  5839. }
  5840. }
  5841. /*************************************************
  5842. Setup
  5843. **************************************************/
  5844. this.eventToCallbackMap = {};
  5845. this.sliderElem.id = this.options.id;
  5846. this.touchCapable = 'ontouchstart' in window || (window.DocumentTouch && document instanceof window.DocumentTouch);
  5847. this.tooltip = this.sliderElem.querySelector('.tooltip-main');
  5848. this.tooltipInner = this.tooltip.querySelector('.tooltip-inner');
  5849. this.tooltip_min = this.sliderElem.querySelector('.tooltip-min');
  5850. this.tooltipInner_min = this.tooltip_min.querySelector('.tooltip-inner');
  5851. this.tooltip_max = this.sliderElem.querySelector('.tooltip-max');
  5852. this.tooltipInner_max = this.tooltip_max.querySelector('.tooltip-inner');
  5853. if (updateSlider === true) {
  5854. // Reset classes
  5855. this._removeClass(this.sliderElem, 'slider-horizontal');
  5856. this._removeClass(this.sliderElem, 'slider-vertical');
  5857. this._removeClass(this.tooltip, 'hide');
  5858. this._removeClass(this.tooltip_min, 'hide');
  5859. this._removeClass(this.tooltip_max, 'hide');
  5860. // Undo existing inline styles for track
  5861. ["left", "top", "width", "height"].forEach(function(prop) {
  5862. this._removeProperty(this.trackSelection, prop);
  5863. },
  5864. this);
  5865. // Undo inline styles on handles
  5866. [this.handle1, this.handle2].forEach(function(handle) {
  5867. this._removeProperty(handle, 'left');
  5868. this._removeProperty(handle, 'top');
  5869. },
  5870. this);
  5871. // Undo inline styles and classes on tooltips
  5872. [this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function(tooltip) {
  5873. this._removeProperty(tooltip, 'left');
  5874. this._removeProperty(tooltip, 'top');
  5875. this._removeProperty(tooltip, 'margin-left');
  5876. this._removeProperty(tooltip, 'margin-top');
  5877. this._removeClass(tooltip, 'right');
  5878. this._removeClass(tooltip, 'top');
  5879. },
  5880. this);
  5881. }
  5882. if (this.options.orientation === 'vertical') {
  5883. this._addClass(this.sliderElem, 'slider-vertical');
  5884. this.stylePos = 'top';
  5885. this.mousePos = 'pageY';
  5886. this.sizePos = 'offsetHeight';
  5887. this._addClass(this.tooltip, 'right');
  5888. this.tooltip.style.left = '100%';
  5889. this._addClass(this.tooltip_min, 'right');
  5890. this.tooltip_min.style.left = '100%';
  5891. this._addClass(this.tooltip_max, 'right');
  5892. this.tooltip_max.style.left = '100%';
  5893. } else {
  5894. this._addClass(this.sliderElem, 'slider-horizontal');
  5895. this.sliderElem.style.width = origWidth;
  5896. this.options.orientation = 'horizontal';
  5897. this.stylePos = 'left';
  5898. this.mousePos = 'pageX';
  5899. this.sizePos = 'offsetWidth';
  5900. this._addClass(this.tooltip, 'top');
  5901. this.tooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';
  5902. this._addClass(this.tooltip_min, 'top');
  5903. this.tooltip_min.style.top = -this.tooltip_min.outerHeight - 14 + 'px';
  5904. this._addClass(this.tooltip_max, 'top');
  5905. this.tooltip_max.style.top = -this.tooltip_max.outerHeight - 14 + 'px';
  5906. }
  5907. if (this.options.value instanceof Array) {
  5908. this.options.range = true;
  5909. } else if (this.options.range) {
  5910. // User wants a range, but value is not an array
  5911. this.options.value = [this.options.value, this.options.max];
  5912. }
  5913. this.trackSelection = sliderTrackSelection || this.trackSelection;
  5914. if (this.options.selection === 'none') {
  5915. this._addClass(this.trackSelection, 'hide');
  5916. }
  5917. this.handle1 = sliderMinHandle || this.handle1;
  5918. this.handle2 = sliderMaxHandle || this.handle2;
  5919. if (updateSlider === true) {
  5920. // Reset classes
  5921. this._removeClass(this.handle1, 'round triangle');
  5922. this._removeClass(this.handle2, 'round triangle hide');
  5923. }
  5924. var availableHandleModifiers = ['round', 'triangle', 'custom'];
  5925. var isValidHandleType = availableHandleModifiers.indexOf(this.options.handle) !== -1;
  5926. if (isValidHandleType) {
  5927. this._addClass(this.handle1, this.options.handle);
  5928. this._addClass(this.handle2, this.options.handle);
  5929. }
  5930. this.offset = this._offset(this.sliderElem);
  5931. this.size = this.sliderElem[this.sizePos];
  5932. this.setValue(this.options.value);
  5933. /******************************************
  5934. Bind Event Listeners
  5935. ******************************************/
  5936. // Bind keyboard handlers
  5937. this.handle1Keydown = this._keydown.bind(this, 0);
  5938. this.handle1.addEventListener("keydown", this.handle1Keydown, false);
  5939. this.handle2Keydown = this._keydown.bind(this, 1);
  5940. this.handle2.addEventListener("keydown", this.handle2Keydown, false);
  5941. if (this.touchCapable) {
  5942. // Bind touch handlers
  5943. this.mousedown = this._mousedown.bind(this);
  5944. this.sliderElem.addEventListener("touchstart", this.mousedown, false);
  5945. } else {
  5946. // Bind mouse handlers
  5947. this.mousedown = this._mousedown.bind(this);
  5948. this.sliderElem.addEventListener("mousedown", this.mousedown, false);
  5949. }
  5950. // Bind tooltip-related handlers
  5951. if (this.options.tooltip === 'hide') {
  5952. this._addClass(this.tooltip, 'hide');
  5953. this._addClass(this.tooltip_min, 'hide');
  5954. this._addClass(this.tooltip_max, 'hide');
  5955. } else if (this.options.tooltip === 'always') {
  5956. this._showTooltip();
  5957. this._alwaysShowTooltip = true;
  5958. } else {
  5959. this.showTooltip = this._showTooltip.bind(this);
  5960. this.hideTooltip = this._hideTooltip.bind(this);
  5961. this.sliderElem.addEventListener("mouseenter", this.showTooltip, false);
  5962. this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false);
  5963. this.handle1.addEventListener("focus", this.showTooltip, false);
  5964. this.handle1.addEventListener("blur", this.hideTooltip, false);
  5965. this.handle2.addEventListener("focus", this.showTooltip, false);
  5966. this.handle2.addEventListener("blur", this.hideTooltip, false);
  5967. }
  5968. if (this.options.enabled) {
  5969. this.enable();
  5970. } else {
  5971. this.disable();
  5972. }
  5973. }
  5974. /*************************************************
  5975. INSTANCE PROPERTIES/METHODS
  5976. - Any methods bound to the prototype are considered
  5977. part of the plugin's `public` interface
  5978. **************************************************/
  5979. Slider.prototype = {
  5980. _init: function() {},
  5981. // NOTE: Must exist to support bridget
  5982. constructor: Slider,
  5983. defaultOptions: {
  5984. id: "",
  5985. min: 0,
  5986. max: 10,
  5987. step: 1,
  5988. precision: 0,
  5989. orientation: 'horizontal',
  5990. value: 5,
  5991. range: false,
  5992. selection: 'before',
  5993. tooltip: 'show',
  5994. tooltip_split: false,
  5995. handle: 'round',
  5996. reversed: false,
  5997. enabled: true,
  5998. formatter: function(val) {
  5999. if (val instanceof Array) {
  6000. return val[0] + " : " + val[1];
  6001. } else {
  6002. return val;
  6003. }
  6004. },
  6005. natural_arrow_keys: false
  6006. },
  6007. over: false,
  6008. inDrag: false,
  6009. getValue: function() {
  6010. if (this.options.range) {
  6011. return this.options.value;
  6012. }
  6013. return this.options.value[0];
  6014. },
  6015. setValue: function(val, triggerSlideEvent) {
  6016. if (!val) {
  6017. val = 0;
  6018. }
  6019. var oldValue = this.getValue();
  6020. this.options.value = this._validateInputValue(val);
  6021. var applyPrecision = this._applyPrecision.bind(this);
  6022. if (this.options.range) {
  6023. this.options.value[0] = applyPrecision(this.options.value[0]);
  6024. this.options.value[1] = applyPrecision(this.options.value[1]);
  6025. this.options.value[0] = Math.max(this.options.min, Math.min(this.options.max, this.options.value[0]));
  6026. this.options.value[1] = Math.max(this.options.min, Math.min(this.options.max, this.options.value[1]));
  6027. } else {
  6028. this.options.value = applyPrecision(this.options.value);
  6029. this.options.value = [Math.max(this.options.min, Math.min(this.options.max, this.options.value))];
  6030. this._addClass(this.handle2, 'hide');
  6031. if (this.options.selection === 'after') {
  6032. this.options.value[1] = this.options.max;
  6033. } else {
  6034. this.options.value[1] = this.options.min;
  6035. }
  6036. }
  6037. this.diff = this.options.max - this.options.min;
  6038. if (this.diff > 0) {
  6039. this.percentage = [
  6040. (this.options.value[0] - this.options.min) * 100 / this.diff,
  6041. (this.options.value[1] - this.options.min) * 100 / this.diff,
  6042. this.options.step * 100 / this.diff];
  6043. } else {
  6044. this.percentage = [0, 0, 100];
  6045. }
  6046. this._layout();
  6047. var newValue = this.options.range ? this.options.value : this.options.value[0];
  6048. if (triggerSlideEvent === true) {
  6049. this._trigger('slide', newValue);
  6050. }
  6051. if (oldValue !== newValue) {
  6052. this._trigger('change', {
  6053. oldValue: oldValue,
  6054. newValue: newValue
  6055. });
  6056. }
  6057. this._setDataVal(newValue);
  6058. return this;
  6059. },
  6060. destroy: function() {
  6061. // Remove event handlers on slider elements
  6062. this._removeSliderEventHandlers();
  6063. // Remove the slider from the DOM
  6064. this.sliderElem.parentNode.removeChild(this.sliderElem);
  6065. /* Show original <input> element */
  6066. this.element.style.display = "";
  6067. // Clear out custom event bindings
  6068. this._cleanUpEventCallbacksMap();
  6069. // Remove data values
  6070. this.element.removeAttribute("data");
  6071. // Remove JQuery handlers/data
  6072. if ($) {
  6073. this._unbindJQueryEventHandlers();
  6074. this.$element.removeData('slider');
  6075. }
  6076. },
  6077. disable: function() {
  6078. this.options.enabled = false;
  6079. this.handle1.removeAttribute("tabindex");
  6080. this.handle2.removeAttribute("tabindex");
  6081. this._addClass(this.sliderElem, 'slider-disabled');
  6082. this._trigger('slideDisabled');
  6083. return this;
  6084. },
  6085. enable: function() {
  6086. this.options.enabled = true;
  6087. this.handle1.setAttribute("tabindex", 0);
  6088. this.handle2.setAttribute("tabindex", 0);
  6089. this._removeClass(this.sliderElem, 'slider-disabled');
  6090. this._trigger('slideEnabled');
  6091. return this;
  6092. },
  6093. toggle: function() {
  6094. if (this.options.enabled) {
  6095. this.disable();
  6096. } else {
  6097. this.enable();
  6098. }
  6099. return this;
  6100. },
  6101. isEnabled: function() {
  6102. return this.options.enabled;
  6103. },
  6104. on: function(evt, callback) {
  6105. if ($) {
  6106. this.$element.on(evt, callback);
  6107. this.$sliderElem.on(evt, callback);
  6108. } else {
  6109. this._bindNonQueryEventHandler(evt, callback);
  6110. }
  6111. return this;
  6112. },
  6113. getAttribute: function(attribute) {
  6114. if (attribute) {
  6115. return this.options[attribute];
  6116. } else {
  6117. return this.options;
  6118. }
  6119. },
  6120. setAttribute: function(attribute, value) {
  6121. this.options[attribute] = value;
  6122. return this;
  6123. },
  6124. refresh: function() {
  6125. this._removeSliderEventHandlers();
  6126. createNewSlider.call(this, this.element, this.options);
  6127. if ($) {
  6128. // Bind new instance of slider to the element
  6129. $.data(this.element, 'slider', this);
  6130. }
  6131. return this;
  6132. },
  6133. relayout: function() {
  6134. this._layout();
  6135. return this;
  6136. },
  6137. /******************************+
  6138. HELPERS
  6139. - Any method that is not part of the public interface.
  6140. - Place it underneath this comment block and write its signature like so:
  6141. _fnName : function() {...}
  6142. ********************************/
  6143. _removeSliderEventHandlers: function() {
  6144. // Remove event listeners from handle1
  6145. this.handle1.removeEventListener("keydown", this.handle1Keydown, false);
  6146. this.handle1.removeEventListener("focus", this.showTooltip, false);
  6147. this.handle1.removeEventListener("blur", this.hideTooltip, false);
  6148. // Remove event listeners from handle2
  6149. this.handle2.removeEventListener("keydown", this.handle2Keydown, false);
  6150. this.handle2.removeEventListener("focus", this.handle2Keydown, false);
  6151. this.handle2.removeEventListener("blur", this.handle2Keydown, false);
  6152. // Remove event listeners from sliderElem
  6153. this.sliderElem.removeEventListener("mouseenter", this.showTooltip, false);
  6154. this.sliderElem.removeEventListener("mouseleave", this.hideTooltip, false);
  6155. this.sliderElem.removeEventListener("touchstart", this.mousedown, false);
  6156. this.sliderElem.removeEventListener("mousedown", this.mousedown, false);
  6157. },
  6158. _bindNonQueryEventHandler: function(evt, callback) {
  6159. if (this.eventToCallbackMap[evt] === undefined) {
  6160. this.eventToCallbackMap[evt] = [];
  6161. }
  6162. this.eventToCallbackMap[evt].push(callback);
  6163. },
  6164. _cleanUpEventCallbacksMap: function() {
  6165. var eventNames = Object.keys(this.eventToCallbackMap);
  6166. for (var i = 0; i < eventNames.length; i++) {
  6167. var eventName = eventNames[i];
  6168. this.eventToCallbackMap[eventName] = null;
  6169. }
  6170. },
  6171. _showTooltip: function() {
  6172. if (this.options.tooltip_split === false) {
  6173. this._addClass(this.tooltip, 'in');
  6174. } else {
  6175. this._addClass(this.tooltip_min, 'in');
  6176. this._addClass(this.tooltip_max, 'in');
  6177. }
  6178. this.over = true;
  6179. },
  6180. _hideTooltip: function() {
  6181. if (this.inDrag === false && this.alwaysShowTooltip !== true) {
  6182. this._removeClass(this.tooltip, 'in');
  6183. this._removeClass(this.tooltip_min, 'in');
  6184. this._removeClass(this.tooltip_max, 'in');
  6185. }
  6186. this.over = false;
  6187. },
  6188. _layout: function() {
  6189. var positionPercentages;
  6190. if (this.options.reversed) {
  6191. positionPercentages = [100 - this.percentage[0], this.percentage[1]];
  6192. } else {
  6193. positionPercentages = [this.percentage[0], this.percentage[1]];
  6194. }
  6195. this.handle1.style[this.stylePos] = positionPercentages[0] + '%';
  6196. this.handle2.style[this.stylePos] = positionPercentages[1] + '%';
  6197. if (this.options.orientation === 'vertical') {
  6198. this.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
  6199. this.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
  6200. } else {
  6201. this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + '%';
  6202. this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';
  6203. var offset_min = this.tooltip_min.getBoundingClientRect();
  6204. var offset_max = this.tooltip_max.getBoundingClientRect();
  6205. if (offset_min.right > offset_max.left) {
  6206. this._removeClass(this.tooltip_max, 'top');
  6207. this._addClass(this.tooltip_max, 'bottom');
  6208. this.tooltip_max.style.top = 18 + 'px';
  6209. } else {
  6210. this._removeClass(this.tooltip_max, 'bottom');
  6211. this._addClass(this.tooltip_max, 'top');
  6212. this.tooltip_max.style.top = this.tooltip_min.style.top;
  6213. }
  6214. }
  6215. var formattedTooltipVal;
  6216. if (this.options.range) {
  6217. formattedTooltipVal = this.options.formatter(this.options.value);
  6218. this._setText(this.tooltipInner, formattedTooltipVal);
  6219. this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + '%';
  6220. if (this.options.orientation === 'vertical') {
  6221. this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
  6222. } else {
  6223. this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
  6224. }
  6225. if (this.options.orientation === 'vertical') {
  6226. this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
  6227. } else {
  6228. this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
  6229. }
  6230. var innerTooltipMinText = this.options.formatter(this.options.value[0]);
  6231. this._setText(this.tooltipInner_min, innerTooltipMinText);
  6232. var innerTooltipMaxText = this.options.formatter(this.options.value[1]);
  6233. this._setText(this.tooltipInner_max, innerTooltipMaxText);
  6234. this.tooltip_min.style[this.stylePos] = positionPercentages[0] + '%';
  6235. if (this.options.orientation === 'vertical') {
  6236. this._css(this.tooltip_min, 'margin-top', -this.tooltip_min.offsetHeight / 2 + 'px');
  6237. } else {
  6238. this._css(this.tooltip_min, 'margin-left', -this.tooltip_min.offsetWidth / 2 + 'px');
  6239. }
  6240. this.tooltip_max.style[this.stylePos] = positionPercentages[1] + '%';
  6241. if (this.options.orientation === 'vertical') {
  6242. this._css(this.tooltip_max, 'margin-top', -this.tooltip_max.offsetHeight / 2 + 'px');
  6243. } else {
  6244. this._css(this.tooltip_max, 'margin-left', -this.tooltip_max.offsetWidth / 2 + 'px');
  6245. }
  6246. } else {
  6247. formattedTooltipVal = this.options.formatter(this.options.value[0]);
  6248. this._setText(this.tooltipInner, formattedTooltipVal);
  6249. this.tooltip.style[this.stylePos] = positionPercentages[0] + '%';
  6250. if (this.options.orientation === 'vertical') {
  6251. this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');
  6252. } else {
  6253. this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');
  6254. }
  6255. }
  6256. },
  6257. _removeProperty: function(element, prop) {
  6258. if (element.style.removeProperty) {
  6259. element.style.removeProperty(prop);
  6260. } else {
  6261. element.style.removeAttribute(prop);
  6262. }
  6263. },
  6264. _mousedown: function(ev) {
  6265. if (!this.options.enabled) {
  6266. return false;
  6267. }
  6268. this._triggerFocusOnHandle();
  6269. this.offset = this._offset(this.sliderElem);
  6270. this.size = this.sliderElem[this.sizePos];
  6271. var percentage = this._getPercentage(ev);
  6272. if (this.options.range) {
  6273. var diff1 = Math.abs(this.percentage[0] - percentage);
  6274. var diff2 = Math.abs(this.percentage[1] - percentage);
  6275. this.dragged = (diff1 < diff2) ? 0 : 1;
  6276. } else {
  6277. this.dragged = 0;
  6278. }
  6279. this.percentage[this.dragged] = this.options.reversed ? 100 - percentage: percentage;
  6280. this._layout();
  6281. if (this.touchCapable) {
  6282. document.removeEventListener("touchmove", this.mousemove, false);
  6283. document.removeEventListener("touchend", this.mouseup, false);
  6284. }
  6285. if (this.mousemove) {
  6286. document.removeEventListener("mousemove", this.mousemove, false);
  6287. }
  6288. if (this.mouseup) {
  6289. document.removeEventListener("mouseup", this.mouseup, false);
  6290. }
  6291. this.mousemove = this._mousemove.bind(this);
  6292. this.mouseup = this._mouseup.bind(this);
  6293. if (this.touchCapable) {
  6294. // Touch: Bind touch events:
  6295. document.addEventListener("touchmove", this.mousemove, false);
  6296. document.addEventListener("touchend", this.mouseup, false);
  6297. }
  6298. // Bind mouse events:
  6299. document.addEventListener("mousemove", this.mousemove, false);
  6300. document.addEventListener("mouseup", this.mouseup, false);
  6301. this.inDrag = true;
  6302. var newValue = this._calculateValue();
  6303. this._trigger('slideStart', newValue);
  6304. this._setDataVal(newValue);
  6305. this.setValue(newValue);
  6306. this._pauseEvent(ev);
  6307. return true;
  6308. },
  6309. _triggerFocusOnHandle: function(handleIdx) {
  6310. if (handleIdx === 0) {
  6311. this.handle1.focus();
  6312. }
  6313. if (handleIdx === 1) {
  6314. this.handle2.focus();
  6315. }
  6316. },
  6317. _keydown: function(handleIdx, ev) {
  6318. if (!this.options.enabled) {
  6319. return false;
  6320. }
  6321. var dir;
  6322. switch (ev.keyCode) {
  6323. case 37:
  6324. // left
  6325. case 40:
  6326. // down
  6327. dir = -1;
  6328. break;
  6329. case 39:
  6330. // right
  6331. case 38:
  6332. // up
  6333. dir = 1;
  6334. break;
  6335. }
  6336. if (!dir) {
  6337. return;
  6338. }
  6339. // use natural arrow keys instead of from min to max
  6340. if (this.options.natural_arrow_keys) {
  6341. var ifVerticalAndNotReversed = (this.options.orientation === 'vertical' && !this.options.reversed);
  6342. var ifHorizontalAndReversed = (this.options.orientation === 'horizontal' && this.options.reversed);
  6343. if (ifVerticalAndNotReversed || ifHorizontalAndReversed) {
  6344. dir = dir * -1;
  6345. }
  6346. }
  6347. var oneStepValuePercentageChange = dir * this.percentage[2];
  6348. var percentage = this.percentage[handleIdx] + oneStepValuePercentageChange;
  6349. if (percentage > 100) {
  6350. percentage = 100;
  6351. } else if (percentage < 0) {
  6352. percentage = 0;
  6353. }
  6354. this.dragged = handleIdx;
  6355. this._adjustPercentageForRangeSliders(percentage);
  6356. this.percentage[this.dragged] = percentage;
  6357. this._layout();
  6358. var val = this._calculateValue();
  6359. this._trigger('slideStart', val);
  6360. this._setDataVal(val);
  6361. this.setValue(val, true);
  6362. this._trigger('slideStop', val);
  6363. this._setDataVal(val);
  6364. this._pauseEvent(ev);
  6365. return false;
  6366. },
  6367. _pauseEvent: function(ev) {
  6368. if (ev.stopPropagation) {
  6369. ev.stopPropagation();
  6370. }
  6371. if (ev.preventDefault) {
  6372. ev.preventDefault();
  6373. }
  6374. ev.cancelBubble = true;
  6375. ev.returnValue = false;
  6376. },
  6377. _mousemove: function(ev) {
  6378. if (!this.options.enabled) {
  6379. return false;
  6380. }
  6381. var percentage = this._getPercentage(ev);
  6382. this._adjustPercentageForRangeSliders(percentage);
  6383. this.percentage[this.dragged] = this.options.reversed ? 100 - percentage: percentage;
  6384. this._layout();
  6385. var val = this._calculateValue();
  6386. this.setValue(val, true);
  6387. return false;
  6388. },
  6389. _adjustPercentageForRangeSliders: function(percentage) {
  6390. if (this.options.range) {
  6391. if (this.dragged === 0 && this.percentage[1] < percentage) {
  6392. this.percentage[0] = this.percentage[1];
  6393. this.dragged = 1;
  6394. } else if (this.dragged === 1 && this.percentage[0] > percentage) {
  6395. this.percentage[1] = this.percentage[0];
  6396. this.dragged = 0;
  6397. }
  6398. }
  6399. },
  6400. _mouseup: function() {
  6401. if (!this.options.enabled) {
  6402. return false;
  6403. }
  6404. if (this.touchCapable) {
  6405. // Touch: Unbind touch event handlers:
  6406. document.removeEventListener("touchmove", this.mousemove, false);
  6407. document.removeEventListener("touchend", this.mouseup, false);
  6408. }
  6409. // Unbind mouse event handlers:
  6410. document.removeEventListener("mousemove", this.mousemove, false);
  6411. document.removeEventListener("mouseup", this.mouseup, false);
  6412. this.inDrag = false;
  6413. if (this.over === false) {
  6414. this._hideTooltip();
  6415. }
  6416. var val = this._calculateValue();
  6417. this._layout();
  6418. this._trigger('slideStop', val);
  6419. this._setDataVal(val);
  6420. return false;
  6421. },
  6422. _calculateValue: function() {
  6423. var val;
  6424. if (this.options.range) {
  6425. val = [this.options.min, this.options.max];
  6426. if (this.percentage[0] !== 0) {
  6427. val[0] = (Math.max(this.options.min, this.options.min + Math.round((this.diff * this.percentage[0] / 100) / this.options.step) * this.options.step));
  6428. val[0] = this._applyPrecision(val[0]);
  6429. }
  6430. if (this.percentage[1] !== 100) {
  6431. val[1] = (Math.min(this.options.max, this.options.min + Math.round((this.diff * this.percentage[1] / 100) / this.options.step) * this.options.step));
  6432. val[1] = this._applyPrecision(val[1]);
  6433. }
  6434. } else {
  6435. val = (this.options.min + Math.round((this.diff * this.percentage[0] / 100) / this.options.step) * this.options.step);
  6436. if (val < this.options.min) {
  6437. val = this.options.min;
  6438. } else if (val > this.options.max) {
  6439. val = this.options.max;
  6440. }
  6441. val = parseFloat(val);
  6442. val = this._applyPrecision(val);
  6443. }
  6444. return val;
  6445. },
  6446. _applyPrecision: function(val) {
  6447. var precision = this.options.precision || this._getNumDigitsAfterDecimalPlace(this.options.step);
  6448. return this._applyToFixedAndParseFloat(val, precision);
  6449. },
  6450. _getNumDigitsAfterDecimalPlace: function(num) {
  6451. var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  6452. if (!match) {
  6453. return 0;
  6454. }
  6455. return Math.max(0, (match[1] ? match[1].length: 0) - (match[2] ? +match[2] : 0));
  6456. },
  6457. _applyToFixedAndParseFloat: function(num, toFixedInput) {
  6458. var truncatedNum = num.toFixed(toFixedInput);
  6459. return parseFloat(truncatedNum);
  6460. },
  6461. /*
  6462. Credits to Mike Samuel for the following method!
  6463. Source: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
  6464. */
  6465. _getPercentage: function(ev) {
  6466. if (this.touchCapable && (ev.type === 'touchstart' || ev.type === 'touchmove')) {
  6467. ev = ev.touches[0];
  6468. }
  6469. var percentage = (ev[this.mousePos] - this.offset[this.stylePos]) * 100 / this.size;
  6470. percentage = Math.round(percentage / this.percentage[2]) * this.percentage[2];
  6471. return Math.max(0, Math.min(100, percentage));
  6472. },
  6473. _validateInputValue: function(val) {
  6474. if (typeof val === 'number') {
  6475. return val;
  6476. } else if (val instanceof Array) {
  6477. this._validateArray(val);
  6478. return val;
  6479. } else {
  6480. throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(val));
  6481. }
  6482. },
  6483. _validateArray: function(val) {
  6484. for (var i = 0; i < val.length; i++) {
  6485. var input = val[i];
  6486. if (typeof input !== 'number') {
  6487. throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(input));
  6488. }
  6489. }
  6490. },
  6491. _setDataVal: function(val) {
  6492. var value = "value: '" + val + "'";
  6493. this.element.setAttribute('data', value);
  6494. this.element.setAttribute('value', val);
  6495. },
  6496. _trigger: function(evt, val) {
  6497. val = (val || val === 0) ? val: undefined;
  6498. var callbackFnArray = this.eventToCallbackMap[evt];
  6499. if (callbackFnArray && callbackFnArray.length) {
  6500. for (var i = 0; i < callbackFnArray.length; i++) {
  6501. var callbackFn = callbackFnArray[i];
  6502. callbackFn(val);
  6503. }
  6504. }
  6505. /* If JQuery exists, trigger JQuery events */
  6506. if ($) {
  6507. this._triggerJQueryEvent(evt, val);
  6508. }
  6509. },
  6510. _triggerJQueryEvent: function(evt, val) {
  6511. var eventData = {
  6512. type: evt,
  6513. value: val
  6514. };
  6515. this.$element.trigger(eventData);
  6516. this.$sliderElem.trigger(eventData);
  6517. },
  6518. _unbindJQueryEventHandlers: function() {
  6519. this.$element.off();
  6520. this.$sliderElem.off();
  6521. },
  6522. _setText: function(element, text) {
  6523. if (typeof element.innerText !== "undefined") {
  6524. element.innerText = text;
  6525. } else if (typeof element.textContent !== "undefined") {
  6526. element.textContent = text;
  6527. }
  6528. },
  6529. _removeClass: function(element, classString) {
  6530. var classes = classString.split(" ");
  6531. var newClasses = element.className;
  6532. for (var i = 0; i < classes.length; i++) {
  6533. var classTag = classes[i];
  6534. var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
  6535. newClasses = newClasses.replace(regex, " ");
  6536. }
  6537. element.className = newClasses.trim();
  6538. },
  6539. _addClass: function(element, classString) {
  6540. var classes = classString.split(" ");
  6541. var newClasses = element.className;
  6542. for (var i = 0; i < classes.length; i++) {
  6543. var classTag = classes[i];
  6544. var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
  6545. var ifClassExists = regex.test(newClasses);
  6546. if (!ifClassExists) {
  6547. newClasses += " " + classTag;
  6548. }
  6549. }
  6550. element.className = newClasses.trim();
  6551. },
  6552. _offset: function(obj) {
  6553. var ol = 0;
  6554. var ot = 0;
  6555. if (obj.offsetParent) {
  6556. do {
  6557. ol += obj.offsetLeft;
  6558. ot += obj.offsetTop;
  6559. } while ( obj = obj . offsetParent );
  6560. }
  6561. return {
  6562. left: ol,
  6563. top: ot
  6564. };
  6565. },
  6566. _css: function(elementRef, styleName, value) {
  6567. if ($) {
  6568. $.style(elementRef, styleName, value);
  6569. } else {
  6570. var style = styleName.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi,
  6571. function(all, letter) {
  6572. return letter.toUpperCase();
  6573. });
  6574. elementRef.style[style] = value;
  6575. }
  6576. }
  6577. };
  6578. /*********************************
  6579. Attach to global namespace
  6580. *********************************/
  6581. if ($) {
  6582. var namespace = $.fn.slider ? 'bootstrapSlider': 'slider';
  6583. $.bridget(namespace, Slider);
  6584. }
  6585. })($);
  6586. return Slider;
  6587. }));
  6588. /* =========================================================
  6589. * Bootstrap.datetimepicker.js
  6590. * =========================================================
  6591. * Copyright 2012 Stefan Petre
  6592. *
  6593. * Improvements by Andrew Rowls
  6594. * Improvements by Sébastien Malot
  6595. * Improvements by Yun Lai
  6596. * Improvements by Kenneth Henderick
  6597. * Improvements by CuGBabyBeaR
  6598. * Improvements by Christian Vaas <auspex@auspex.eu>
  6599. *
  6600. * Project URL : http://www.malot.fr/bootstrap-datetimepicker
  6601. *
  6602. * Licensed under the Apache License, Version 2.0 (the "License");
  6603. * you may not use this file except in compliance with the License.
  6604. * You may obtain a copy of the License at
  6605. *
  6606. * http://www.apache.org/licenses/LICENSE-2.0
  6607. *
  6608. * Unless required by applicable law or agreed to in writing, software
  6609. * distributed under the License is distributed on an "AS IS" BASIS,
  6610. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6611. * See the License for the specific language governing permissions and
  6612. * limitations under the License.
  6613. * ========================================================= */
  6614. ! (function(factory) {
  6615. if (typeof define === 'function' && define.amd) define(['jquery'], factory);
  6616. else if (typeof exports === 'object') factory(require('jquery'));
  6617. else factory(jQuery);
  6618. } (function($, undefined) {
  6619. // Add ECMA262-5 Array methods if not supported natively (IE8)
  6620. if (! ('indexOf' in Array.prototype)) {
  6621. Array.prototype.indexOf = function(find, i) {
  6622. if (i === undefined) i = 0;
  6623. if (i < 0) i += this.length;
  6624. if (i < 0) i = 0;
  6625. for (var n = this.length; i < n; i++) {
  6626. if (i in this && this[i] === find) {
  6627. return i;
  6628. }
  6629. }
  6630. return - 1;
  6631. }
  6632. }
  6633. function elementOrParentIsFixed(element) {
  6634. var $element = $(element);
  6635. var $checkElements = $element.add($element.parents());
  6636. var isFixed = false;
  6637. $checkElements.each(function() {
  6638. if ($(this).css('position') === 'fixed') {
  6639. isFixed = true;
  6640. return false;
  6641. }
  6642. });
  6643. return isFixed;
  6644. }
  6645. function UTCDate() {
  6646. return new Date(Date.UTC.apply(Date, arguments));
  6647. }
  6648. function UTCToday() {
  6649. var today = new Date();
  6650. return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), today.getUTCHours(), today.getUTCMinutes(), today.getUTCSeconds(), 0);
  6651. }
  6652. // Picker object
  6653. var Datetimepicker = function(element, options) {
  6654. var that = this;
  6655. this.element = $(element);
  6656. // add container for single page application
  6657. // when page switch the datetimepicker div will be removed also.
  6658. this.container = options.container || 'body';
  6659. this.language = options.language || this.element.data('date-language') || 'en';
  6660. this.language = this.language in dates ? this.language: this.language.split('-')[0]; // fr-CA fallback to fr
  6661. this.language = this.language in dates ? this.language: 'en';
  6662. this.isRTL = dates[this.language].rtl || false;
  6663. this.formatType = options.formatType || this.element.data('format-type') || 'standard';
  6664. this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || dates[this.language].format || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
  6665. this.isInline = false;
  6666. this.isVisible = false;
  6667. this.isInput = this.element.is('input');
  6668. this.fontAwesome = options.fontAwesome || this.element.data('font-awesome') || false;
  6669. this.bootcssVer = options.bootcssVer || (this.isInput ? (this.element.is('.form-control') ? 3 : 2) : (this.bootcssVer = this.element.is('.input-group') ? 3 : 2));
  6670. 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;
  6671. 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;
  6672. this.hasInput = this.component && this.element.find('input').length;
  6673. if (this.component && this.component.length === 0) {
  6674. this.component = false;
  6675. }
  6676. this.linkField = options.linkField || this.element.data('link-field') || false;
  6677. this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
  6678. this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
  6679. this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
  6680. this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
  6681. this.initialDate = options.initialDate || new Date();
  6682. this.zIndex = options.zIndex || this.element.data('z-index') || undefined;
  6683. this.title = typeof options.title === 'undefined' ? false: options.title;
  6684. this.defaultTimeZone = (new Date).toString().split('(')[1].slice(0, -1);
  6685. this.timezone = options.timezone || this.defaultTimeZone;
  6686. this.icons = {
  6687. leftArrow: this.fontAwesome ? 'fa-arrow-left': (this.bootcssVer === 3 ? 'glyphicon-arrow-left': 'icon-arrow-left'),
  6688. rightArrow: this.fontAwesome ? 'fa-arrow-right': (this.bootcssVer === 3 ? 'glyphicon-arrow-right': 'icon-arrow-right')
  6689. }
  6690. this.icontype = this.fontAwesome ? 'fa': 'glyphicon';
  6691. this._attachEvents();
  6692. this.clickedOutside = function(e) {
  6693. // Clicked outside the datetimepicker, hide it
  6694. if ($(e.target).closest('.datetimepicker').length === 0) {
  6695. that.hide();
  6696. }
  6697. }
  6698. this.formatViewType = 'datetime';
  6699. if ('formatViewType' in options) {
  6700. this.formatViewType = options.formatViewType;
  6701. } else if ('formatViewType' in this.element.data()) {
  6702. this.formatViewType = this.element.data('formatViewType');
  6703. }
  6704. this.minView = 0;
  6705. if ('minView' in options) {
  6706. this.minView = options.minView;
  6707. } else if ('minView' in this.element.data()) {
  6708. this.minView = this.element.data('min-view');
  6709. }
  6710. this.minView = DPGlobal.convertViewMode(this.minView);
  6711. this.maxView = DPGlobal.modes.length - 1;
  6712. if ('maxView' in options) {
  6713. this.maxView = options.maxView;
  6714. } else if ('maxView' in this.element.data()) {
  6715. this.maxView = this.element.data('max-view');
  6716. }
  6717. this.maxView = DPGlobal.convertViewMode(this.maxView);
  6718. this.wheelViewModeNavigation = false;
  6719. if ('wheelViewModeNavigation' in options) {
  6720. this.wheelViewModeNavigation = options.wheelViewModeNavigation;
  6721. } else if ('wheelViewModeNavigation' in this.element.data()) {
  6722. this.wheelViewModeNavigation = this.element.data('view-mode-wheel-navigation');
  6723. }
  6724. this.wheelViewModeNavigationInverseDirection = false;
  6725. if ('wheelViewModeNavigationInverseDirection' in options) {
  6726. this.wheelViewModeNavigationInverseDirection = options.wheelViewModeNavigationInverseDirection;
  6727. } else if ('wheelViewModeNavigationInverseDirection' in this.element.data()) {
  6728. this.wheelViewModeNavigationInverseDirection = this.element.data('view-mode-wheel-navigation-inverse-dir');
  6729. }
  6730. this.wheelViewModeNavigationDelay = 100;
  6731. if ('wheelViewModeNavigationDelay' in options) {
  6732. this.wheelViewModeNavigationDelay = options.wheelViewModeNavigationDelay;
  6733. } else if ('wheelViewModeNavigationDelay' in this.element.data()) {
  6734. this.wheelViewModeNavigationDelay = this.element.data('view-mode-wheel-navigation-delay');
  6735. }
  6736. this.startViewMode = 2;
  6737. if ('startView' in options) {
  6738. this.startViewMode = options.startView;
  6739. } else if ('startView' in this.element.data()) {
  6740. this.startViewMode = this.element.data('start-view');
  6741. }
  6742. this.startViewMode = DPGlobal.convertViewMode(this.startViewMode);
  6743. this.viewMode = this.startViewMode;
  6744. this.viewSelect = this.minView;
  6745. if ('viewSelect' in options) {
  6746. this.viewSelect = options.viewSelect;
  6747. } else if ('viewSelect' in this.element.data()) {
  6748. this.viewSelect = this.element.data('view-select');
  6749. }
  6750. this.viewSelect = DPGlobal.convertViewMode(this.viewSelect);
  6751. this.forceParse = true;
  6752. if ('forceParse' in options) {
  6753. this.forceParse = options.forceParse;
  6754. } else if ('dateForceParse' in this.element.data()) {
  6755. this.forceParse = this.element.data('date-force-parse');
  6756. }
  6757. var template = this.bootcssVer === 3 ? DPGlobal.templateV3: DPGlobal.template;
  6758. while (template.indexOf('{iconType}') !== -1) {
  6759. template = template.replace('{iconType}', this.icontype);
  6760. }
  6761. while (template.indexOf('{leftArrow}') !== -1) {
  6762. template = template.replace('{leftArrow}', this.icons.leftArrow);
  6763. }
  6764. while (template.indexOf('{rightArrow}') !== -1) {
  6765. template = template.replace('{rightArrow}', this.icons.rightArrow);
  6766. }
  6767. this.picker = $(template).appendTo(this.isInline ? this.element: this.container) // 'body')
  6768. .on({
  6769. click: $.proxy(this.click, this),
  6770. mousedown: $.proxy(this.mousedown, this)
  6771. });
  6772. if (this.wheelViewModeNavigation) {
  6773. if ($.fn.mousewheel) {
  6774. this.picker.on({
  6775. mousewheel: $.proxy(this.mousewheel, this)
  6776. });
  6777. } else {
  6778. console.log('Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option');
  6779. }
  6780. }
  6781. if (this.isInline) {
  6782. this.picker.addClass('datetimepicker-inline');
  6783. } else {
  6784. this.picker.addClass('datetimepicker-dropdown-' + this.pickerPosition + ' dropdown-menu');
  6785. }
  6786. if (this.isRTL) {
  6787. this.picker.addClass('datetimepicker-rtl');
  6788. var selector = this.bootcssVer === 3 ? '.prev span, .next span': '.prev i, .next i';
  6789. this.picker.find(selector).toggleClass(this.icons.leftArrow + ' ' + this.icons.rightArrow);
  6790. }
  6791. $(document).on('mousedown', this.clickedOutside);
  6792. this.autoclose = false;
  6793. if ('autoclose' in options) {
  6794. this.autoclose = options.autoclose;
  6795. } else if ('dateAutoclose' in this.element.data()) {
  6796. this.autoclose = this.element.data('date-autoclose');
  6797. }
  6798. this.keyboardNavigation = true;
  6799. if ('keyboardNavigation' in options) {
  6800. this.keyboardNavigation = options.keyboardNavigation;
  6801. } else if ('dateKeyboardNavigation' in this.element.data()) {
  6802. this.keyboardNavigation = this.element.data('date-keyboard-navigation');
  6803. }
  6804. this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
  6805. this.clearBtn = (options.clearBtn || this.element.data('date-clear-btn') || false);
  6806. this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
  6807. this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
  6808. this.weekEnd = ((this.weekStart + 6) % 7);
  6809. this.startDate = -Infinity;
  6810. this.endDate = Infinity;
  6811. this.datesDisabled = [];
  6812. this.daysOfWeekDisabled = [];
  6813. this.setStartDate(options.startDate || this.element.data('date-startdate'));
  6814. this.setEndDate(options.endDate || this.element.data('date-enddate'));
  6815. this.setDatesDisabled(options.datesDisabled || this.element.data('date-dates-disabled'));
  6816. this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
  6817. this.setMinutesDisabled(options.minutesDisabled || this.element.data('date-minute-disabled'));
  6818. this.setHoursDisabled(options.hoursDisabled || this.element.data('date-hour-disabled'));
  6819. this.fillDow();
  6820. this.fillMonths();
  6821. this.update();
  6822. this.showMode();
  6823. if (this.isInline) {
  6824. this.show();
  6825. }
  6826. };
  6827. Datetimepicker.prototype = {
  6828. constructor: Datetimepicker,
  6829. _events: [],
  6830. _attachEvents: function() {
  6831. this._detachEvents();
  6832. if (this.isInput) { // single input
  6833. this._events = [[this.element, {
  6834. focus: $.proxy(this.show, this),
  6835. keyup: $.proxy(this.update, this),
  6836. keydown: $.proxy(this.keydown, this)
  6837. }]];
  6838. } else if (this.component && this.hasInput) { // component: input + button
  6839. this._events = [
  6840. // For components that are not readonly, allow keyboard nav
  6841. [this.element.find('input'), {
  6842. focus: $.proxy(this.show, this),
  6843. keyup: $.proxy(this.update, this),
  6844. keydown: $.proxy(this.keydown, this)
  6845. }], [this.component, {
  6846. click: $.proxy(this.show, this)
  6847. }]];
  6848. if (this.componentReset) {
  6849. this._events.push([this.componentReset, {
  6850. click: $.proxy(this.reset, this)
  6851. }]);
  6852. }
  6853. } else if (this.element.is('div')) { // inline datetimepicker
  6854. this.isInline = true;
  6855. } else {
  6856. this._events = [[this.element, {
  6857. click: $.proxy(this.show, this)
  6858. }]];
  6859. }
  6860. for (var i = 0,
  6861. el, ev; i < this._events.length; i++) {
  6862. el = this._events[i][0];
  6863. ev = this._events[i][1];
  6864. el.on(ev);
  6865. }
  6866. },
  6867. _detachEvents: function() {
  6868. for (var i = 0,
  6869. el, ev; i < this._events.length; i++) {
  6870. el = this._events[i][0];
  6871. ev = this._events[i][1];
  6872. el.off(ev);
  6873. }
  6874. this._events = [];
  6875. },
  6876. show: function(e) {
  6877. this.picker.show();
  6878. this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
  6879. if (this.forceParse) {
  6880. this.update();
  6881. }
  6882. this.place();
  6883. $(window).on('resize', $.proxy(this.place, this));
  6884. if (e) {
  6885. e.stopPropagation();
  6886. e.preventDefault();
  6887. }
  6888. this.isVisible = true;
  6889. this.element.trigger({
  6890. type: 'show',
  6891. date: this.date
  6892. });
  6893. },
  6894. hide: function(e) {
  6895. if (!this.isVisible) return;
  6896. if (this.isInline) return;
  6897. this.picker.hide();
  6898. $(window).off('resize', this.place);
  6899. this.viewMode = this.startViewMode;
  6900. this.showMode();
  6901. if (!this.isInput) {
  6902. $(document).off('mousedown', this.hide);
  6903. }
  6904. if (this.forceParse && (this.isInput && this.element.val() || this.hasInput && this.element.find('input').val())) this.setValue();
  6905. this.isVisible = false;
  6906. this.element.trigger({
  6907. type: 'hide',
  6908. date: this.date
  6909. });
  6910. },
  6911. remove: function() {
  6912. this._detachEvents();
  6913. $(document).off('mousedown', this.clickedOutside);
  6914. this.picker.remove();
  6915. delete this.picker;
  6916. delete this.element.data().datetimepicker;
  6917. },
  6918. getDate: function() {
  6919. var d = this.getUTCDate();
  6920. return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
  6921. },
  6922. getUTCDate: function() {
  6923. return this.date;
  6924. },
  6925. getInitialDate: function() {
  6926. return this.initialDate
  6927. },
  6928. setInitialDate: function(initialDate) {
  6929. this.initialDate = initialDate;
  6930. },
  6931. setDate: function(d) {
  6932. this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset() * 60000)));
  6933. },
  6934. setUTCDate: function(d) {
  6935. if (d >= this.startDate && d <= this.endDate) {
  6936. this.date = d;
  6937. this.setValue();
  6938. this.viewDate = this.date;
  6939. this.fill();
  6940. } else {
  6941. this.element.trigger({
  6942. type: 'outOfRange',
  6943. date: d,
  6944. startDate: this.startDate,
  6945. endDate: this.endDate
  6946. });
  6947. }
  6948. },
  6949. setFormat: function(format) {
  6950. this.format = DPGlobal.parseFormat(format, this.formatType);
  6951. var element;
  6952. if (this.isInput) {
  6953. element = this.element;
  6954. } else if (this.component) {
  6955. element = this.element.find('input');
  6956. }
  6957. if (element && element.val()) {
  6958. this.setValue();
  6959. }
  6960. },
  6961. setValue: function() {
  6962. var formatted = this.getFormattedDate();
  6963. if (!this.isInput) {
  6964. if (this.component) {
  6965. this.element.find('input').val(formatted);
  6966. }
  6967. this.element.data('date', formatted);
  6968. } else {
  6969. this.element.val(formatted);
  6970. }
  6971. if (this.linkField) {
  6972. $('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
  6973. }
  6974. },
  6975. getFormattedDate: function(format) {
  6976. if (format == undefined) format = this.format;
  6977. return DPGlobal.formatDate(this.date, format, this.language, this.formatType, this.timezone);
  6978. },
  6979. setStartDate: function(startDate) {
  6980. this.startDate = startDate || -Infinity;
  6981. if (this.startDate !== -Infinity) {
  6982. this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language, this.formatType, this.timezone);
  6983. }
  6984. this.update();
  6985. this.updateNavArrows();
  6986. },
  6987. setEndDate: function(endDate) {
  6988. this.endDate = endDate || Infinity;
  6989. if (this.endDate !== Infinity) {
  6990. this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language, this.formatType, this.timezone);
  6991. }
  6992. this.update();
  6993. this.updateNavArrows();
  6994. },
  6995. setDatesDisabled: function(datesDisabled) {
  6996. this.datesDisabled = datesDisabled || [];
  6997. if (!$.isArray(this.datesDisabled)) {
  6998. this.datesDisabled = this.datesDisabled.split(/,\s*/);
  6999. }
  7000. this.datesDisabled = $.map(this.datesDisabled,
  7001. function(d) {
  7002. return DPGlobal.parseDate(d, this.format, this.language, this.formatType, this.timezone).toDateString();
  7003. });
  7004. this.update();
  7005. this.updateNavArrows();
  7006. },
  7007. setTitle: function(selector, value) {
  7008. return this.picker.find(selector).find('th:eq(1)').text(this.title === false ? value: this.title);
  7009. },
  7010. setDaysOfWeekDisabled: function(daysOfWeekDisabled) {
  7011. this.daysOfWeekDisabled = daysOfWeekDisabled || [];
  7012. if (!$.isArray(this.daysOfWeekDisabled)) {
  7013. this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
  7014. }
  7015. this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled,
  7016. function(d) {
  7017. return parseInt(d, 10);
  7018. });
  7019. this.update();
  7020. this.updateNavArrows();
  7021. },
  7022. setMinutesDisabled: function(minutesDisabled) {
  7023. this.minutesDisabled = minutesDisabled || [];
  7024. if (!$.isArray(this.minutesDisabled)) {
  7025. this.minutesDisabled = this.minutesDisabled.split(/,\s*/);
  7026. }
  7027. this.minutesDisabled = $.map(this.minutesDisabled,
  7028. function(d) {
  7029. return parseInt(d, 10);
  7030. });
  7031. this.update();
  7032. this.updateNavArrows();
  7033. },
  7034. setHoursDisabled: function(hoursDisabled) {
  7035. this.hoursDisabled = hoursDisabled || [];
  7036. if (!$.isArray(this.hoursDisabled)) {
  7037. this.hoursDisabled = this.hoursDisabled.split(/,\s*/);
  7038. }
  7039. this.hoursDisabled = $.map(this.hoursDisabled,
  7040. function(d) {
  7041. return parseInt(d, 10);
  7042. });
  7043. this.update();
  7044. this.updateNavArrows();
  7045. },
  7046. place: function() {
  7047. if (this.isInline) return;
  7048. if (!this.zIndex) {
  7049. var index_highest = 0;
  7050. $('div').each(function() {
  7051. var index_current = parseInt($(this).css('zIndex'), 10);
  7052. if (index_current > index_highest) {
  7053. index_highest = index_current;
  7054. }
  7055. });
  7056. this.zIndex = index_highest + 10;
  7057. }
  7058. var offset, top, left, containerOffset;
  7059. if (this.container instanceof $) {
  7060. containerOffset = this.container.offset();
  7061. } else {
  7062. containerOffset = $(this.container).offset();
  7063. }
  7064. if (this.component) {
  7065. offset = this.component.offset();
  7066. left = offset.left;
  7067. if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {
  7068. left += this.component.outerWidth() - this.picker.outerWidth();
  7069. }
  7070. } else {
  7071. offset = this.element.offset();
  7072. left = offset.left;
  7073. if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {
  7074. left += this.element.outerWidth() - this.picker.outerWidth();
  7075. }
  7076. }
  7077. var bodyWidth = document.body.clientWidth || window.innerWidth;
  7078. if (left + 220 > bodyWidth) {
  7079. left = bodyWidth - 220;
  7080. }
  7081. if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {
  7082. top = offset.top - this.picker.outerHeight();
  7083. } else {
  7084. top = offset.top + this.height;
  7085. }
  7086. top = top - containerOffset.top;
  7087. left = left - containerOffset.left;
  7088. this.picker.css({
  7089. top: top,
  7090. left: left,
  7091. zIndex: this.zIndex
  7092. });
  7093. },
  7094. update: function() {
  7095. var date, fromArgs = false;
  7096. if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
  7097. date = arguments[0];
  7098. fromArgs = true;
  7099. } else {
  7100. date = (this.isInput ? this.element.val() : this.element.find('input').val()) || this.element.data('date') || this.initialDate;
  7101. if (typeof date == 'string' || date instanceof String) {
  7102. date = date.replace(/^\s+|\s+$/g, '');
  7103. }
  7104. }
  7105. if (!date) {
  7106. date = new Date();
  7107. fromArgs = false;
  7108. }
  7109. this.date = DPGlobal.parseDate(date, this.format, this.language, this.formatType, this.timezone);
  7110. if (fromArgs) this.setValue();
  7111. if (this.date < this.startDate) {
  7112. this.viewDate = new Date(this.startDate);
  7113. } else if (this.date > this.endDate) {
  7114. this.viewDate = new Date(this.endDate);
  7115. } else {
  7116. this.viewDate = new Date(this.date);
  7117. }
  7118. this.fill();
  7119. },
  7120. fillDow: function() {
  7121. var dowCnt = this.weekStart,
  7122. html = '<tr>';
  7123. while (dowCnt < this.weekStart + 7) {
  7124. html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>';
  7125. }
  7126. html += '</tr>';
  7127. this.picker.find('.datetimepicker-days thead').append(html);
  7128. },
  7129. fillMonths: function() {
  7130. var html = '',
  7131. i = 0;
  7132. while (i < 12) {
  7133. html += '<span class="month">' + dates[this.language].monthsShort[i++] + '</span>';
  7134. }
  7135. this.picker.find('.datetimepicker-months td').html(html);
  7136. },
  7137. fill: function() {
  7138. if (this.date == null || this.viewDate == null) {
  7139. return;
  7140. }
  7141. var d = new Date(this.viewDate),
  7142. year = d.getUTCFullYear(),
  7143. month = d.getUTCMonth(),
  7144. dayMonth = d.getUTCDate(),
  7145. hours = d.getUTCHours(),
  7146. minutes = d.getUTCMinutes(),
  7147. startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
  7148. startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
  7149. endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
  7150. endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() + 1 : Infinity,
  7151. currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
  7152. today = new Date();
  7153. this.setTitle('.datetimepicker-days', dates[this.language].months[month] + ' ' + year);
  7154. if (this.formatViewType == 'time') {
  7155. var formatted = this.getFormattedDate();
  7156. this.setTitle('.datetimepicker-hours', formatted);
  7157. this.setTitle('.datetimepicker-minutes', formatted);
  7158. } else {
  7159. this.setTitle('.datetimepicker-hours', dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
  7160. this.setTitle('.datetimepicker-minutes', dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
  7161. }
  7162. this.picker.find('tfoot th.today').text(dates[this.language].today || dates['en'].today).toggle(this.todayBtn !== false);
  7163. this.picker.find('tfoot th.clear').text(dates[this.language].clear || dates['en'].clear).toggle(this.clearBtn !== false);
  7164. this.updateNavArrows();
  7165. this.fillMonths();
  7166. /*var prevMonth = UTCDate(year, month, 0,0,0,0,0);
  7167. prevMonth.setUTCDate(prevMonth.getDate() - (prevMonth.getUTCDay() - this.weekStart + 7)%7);*/
  7168. var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
  7169. day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
  7170. prevMonth.setUTCDate(day);
  7171. prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
  7172. var nextMonth = new Date(prevMonth);
  7173. nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
  7174. nextMonth = nextMonth.valueOf();
  7175. var html = [];
  7176. var clsName;
  7177. while (prevMonth.valueOf() < nextMonth) {
  7178. if (prevMonth.getUTCDay() == this.weekStart) {
  7179. html.push('<tr>');
  7180. }
  7181. clsName = '';
  7182. if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
  7183. clsName += ' old';
  7184. } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
  7185. clsName += ' new';
  7186. }
  7187. // Compare internal UTC date with local today, not UTC today
  7188. if (this.todayHighlight && prevMonth.getUTCFullYear() == today.getFullYear() && prevMonth.getUTCMonth() == today.getMonth() && prevMonth.getUTCDate() == today.getDate()) {
  7189. clsName += ' today';
  7190. }
  7191. if (prevMonth.valueOf() == currentDate) {
  7192. clsName += ' active';
  7193. }
  7194. if ((prevMonth.valueOf() + 86400000) <= this.startDate || prevMonth.valueOf() > this.endDate || $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1 || $.inArray(prevMonth.toDateString(), this.datesDisabled) !== -1) {
  7195. clsName += ' disabled';
  7196. }
  7197. html.push('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + '</td>');
  7198. if (prevMonth.getUTCDay() == this.weekEnd) {
  7199. html.push('</tr>');
  7200. }
  7201. prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
  7202. }
  7203. this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
  7204. html = [];
  7205. var txt = '',
  7206. meridian = '',
  7207. meridianOld = '';
  7208. var hoursDisabled = this.hoursDisabled || [];
  7209. for (var i = 0; i < 24; i++) {
  7210. if (hoursDisabled.indexOf(i) !== -1) continue;
  7211. var actual = UTCDate(year, month, dayMonth, i);
  7212. clsName = '';
  7213. // We want the previous hour for the startDate
  7214. if ((actual.valueOf() + 3600000) <= this.startDate || actual.valueOf() > this.endDate) {
  7215. clsName += ' disabled';
  7216. } else if (hours == i) {
  7217. clsName += ' active';
  7218. }
  7219. if (this.showMeridian && dates[this.language].meridiem.length == 2) {
  7220. meridian = (i < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
  7221. if (meridian != meridianOld) {
  7222. if (meridianOld != '') {
  7223. html.push('</fieldset>');
  7224. }
  7225. html.push('<fieldset class="hour"><legend>' + meridian.toUpperCase() + '</legend>');
  7226. }
  7227. meridianOld = meridian;
  7228. txt = (i % 12 ? i % 12 : 12);
  7229. html.push('<span class="hour' + clsName + ' hour_' + (i < 12 ? 'am': 'pm') + '">' + txt + '</span>');
  7230. if (i == 23) {
  7231. html.push('</fieldset>');
  7232. }
  7233. } else {
  7234. txt = i + ':00';
  7235. html.push('<span class="hour' + clsName + '">' + txt + '</span>');
  7236. }
  7237. }
  7238. this.picker.find('.datetimepicker-hours td').html(html.join(''));
  7239. html = [];
  7240. txt = '',
  7241. meridian = '',
  7242. meridianOld = '';
  7243. var minutesDisabled = this.minutesDisabled || [];
  7244. for (var i = 0; i < 60; i += this.minuteStep) {
  7245. if (minutesDisabled.indexOf(i) !== -1) continue;
  7246. var actual = UTCDate(year, month, dayMonth, hours, i, 0);
  7247. clsName = '';
  7248. if (actual.valueOf() < this.startDate || actual.valueOf() > this.endDate) {
  7249. clsName += ' disabled';
  7250. } else if (Math.floor(minutes / this.minuteStep) == Math.floor(i / this.minuteStep)) {
  7251. clsName += ' active';
  7252. }
  7253. if (this.showMeridian && dates[this.language].meridiem.length == 2) {
  7254. meridian = (hours < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
  7255. if (meridian != meridianOld) {
  7256. if (meridianOld != '') {
  7257. html.push('</fieldset>');
  7258. }
  7259. html.push('<fieldset class="minute"><legend>' + meridian.toUpperCase() + '</legend>');
  7260. }
  7261. meridianOld = meridian;
  7262. txt = (hours % 12 ? hours % 12 : 12);
  7263. //html.push('<span class="minute'+clsName+' minute_'+(hours<12?'am':'pm')+'">'+txt+'</span>');
  7264. html.push('<span class="minute' + clsName + '">' + txt + ':' + (i < 10 ? '0' + i: i) + '</span>');
  7265. if (i == 59) {
  7266. html.push('</fieldset>');
  7267. }
  7268. } else {
  7269. txt = i + ':00';
  7270. //html.push('<span class="hour'+clsName+'">'+txt+'</span>');
  7271. html.push('<span class="minute' + clsName + '">' + hours + ':' + (i < 10 ? '0' + i: i) + '</span>');
  7272. }
  7273. }
  7274. this.picker.find('.datetimepicker-minutes td').html(html.join(''));
  7275. var currentYear = this.date.getUTCFullYear();
  7276. var months = this.setTitle('.datetimepicker-months', year).end().find('span').removeClass('active');
  7277. if (currentYear == year) {
  7278. // getUTCMonths() returns 0 based, and we need to select the next one
  7279. // To cater bootstrap 2 we don't need to select the next one
  7280. var offset = months.length - 12;
  7281. months.eq(this.date.getUTCMonth() + offset).addClass('active');
  7282. }
  7283. if (year < startYear || year > endYear) {
  7284. months.addClass('disabled');
  7285. }
  7286. if (year == startYear) {
  7287. months.slice(0, startMonth).addClass('disabled');
  7288. }
  7289. if (year == endYear) {
  7290. months.slice(endMonth).addClass('disabled');
  7291. }
  7292. html = '';
  7293. year = parseInt(year / 10, 10) * 10;
  7294. var yearCont = this.setTitle('.datetimepicker-years', year + '-' + (year + 9)).end().find('td');
  7295. year -= 1;
  7296. for (var i = -1; i < 11; i++) {
  7297. html += '<span class="year' + (i == -1 || i == 10 ? ' old': '') + (currentYear == year ? ' active': '') + (year < startYear || year > endYear ? ' disabled': '') + '">' + year + '</span>';
  7298. year += 1;
  7299. }
  7300. yearCont.html(html);
  7301. this.place();
  7302. },
  7303. updateNavArrows: function() {
  7304. var d = new Date(this.viewDate),
  7305. year = d.getUTCFullYear(),
  7306. month = d.getUTCMonth(),
  7307. day = d.getUTCDate(),
  7308. hour = d.getUTCHours();
  7309. switch (this.viewMode) {
  7310. case 0:
  7311. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth() && day <= this.startDate.getUTCDate() && hour <= this.startDate.getUTCHours()) {
  7312. this.picker.find('.prev').css({
  7313. visibility: 'hidden'
  7314. });
  7315. } else {
  7316. this.picker.find('.prev').css({
  7317. visibility: 'visible'
  7318. });
  7319. }
  7320. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth() && day >= this.endDate.getUTCDate() && hour >= this.endDate.getUTCHours()) {
  7321. this.picker.find('.next').css({
  7322. visibility: 'hidden'
  7323. });
  7324. } else {
  7325. this.picker.find('.next').css({
  7326. visibility: 'visible'
  7327. });
  7328. }
  7329. break;
  7330. case 1:
  7331. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth() && day <= this.startDate.getUTCDate()) {
  7332. this.picker.find('.prev').css({
  7333. visibility: 'hidden'
  7334. });
  7335. } else {
  7336. this.picker.find('.prev').css({
  7337. visibility: 'visible'
  7338. });
  7339. }
  7340. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth() && day >= this.endDate.getUTCDate()) {
  7341. this.picker.find('.next').css({
  7342. visibility: 'hidden'
  7343. });
  7344. } else {
  7345. this.picker.find('.next').css({
  7346. visibility: 'visible'
  7347. });
  7348. }
  7349. break;
  7350. case 2:
  7351. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
  7352. this.picker.find('.prev').css({
  7353. visibility: 'hidden'
  7354. });
  7355. } else {
  7356. this.picker.find('.prev').css({
  7357. visibility: 'visible'
  7358. });
  7359. }
  7360. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
  7361. this.picker.find('.next').css({
  7362. visibility: 'hidden'
  7363. });
  7364. } else {
  7365. this.picker.find('.next').css({
  7366. visibility: 'visible'
  7367. });
  7368. }
  7369. break;
  7370. case 3:
  7371. case 4:
  7372. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
  7373. this.picker.find('.prev').css({
  7374. visibility: 'hidden'
  7375. });
  7376. } else {
  7377. this.picker.find('.prev').css({
  7378. visibility: 'visible'
  7379. });
  7380. }
  7381. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
  7382. this.picker.find('.next').css({
  7383. visibility: 'hidden'
  7384. });
  7385. } else {
  7386. this.picker.find('.next').css({
  7387. visibility: 'visible'
  7388. });
  7389. }
  7390. break;
  7391. }
  7392. },
  7393. mousewheel: function(e) {
  7394. e.preventDefault();
  7395. e.stopPropagation();
  7396. if (this.wheelPause) {
  7397. return;
  7398. }
  7399. this.wheelPause = true;
  7400. var originalEvent = e.originalEvent;
  7401. var delta = originalEvent.wheelDelta;
  7402. var mode = delta > 0 ? 1 : (delta === 0) ? 0 : -1;
  7403. if (this.wheelViewModeNavigationInverseDirection) {
  7404. mode = -mode;
  7405. }
  7406. this.showMode(mode);
  7407. setTimeout($.proxy(function() {
  7408. this.wheelPause = false
  7409. },
  7410. this), this.wheelViewModeNavigationDelay);
  7411. },
  7412. click: function(e) {
  7413. e.stopPropagation();
  7414. e.preventDefault();
  7415. var target = $(e.target).closest('span, td, th, legend');
  7416. if (target.is('.' + this.icontype)) {
  7417. target = $(target).parent().closest('span, td, th, legend');
  7418. }
  7419. if (target.length == 1) {
  7420. if (target.is('.disabled')) {
  7421. this.element.trigger({
  7422. type: 'outOfRange',
  7423. date: this.viewDate,
  7424. startDate: this.startDate,
  7425. endDate: this.endDate
  7426. });
  7427. return;
  7428. }
  7429. switch (target[0].nodeName.toLowerCase()) {
  7430. case 'th':
  7431. switch (target[0].className) {
  7432. case 'switch':
  7433. this.showMode(1);
  7434. break;
  7435. case 'prev':
  7436. case 'next':
  7437. var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
  7438. switch (this.viewMode) {
  7439. case 0:
  7440. this.viewDate = this.moveHour(this.viewDate, dir);
  7441. break;
  7442. case 1:
  7443. this.viewDate = this.moveDate(this.viewDate, dir);
  7444. break;
  7445. case 2:
  7446. this.viewDate = this.moveMonth(this.viewDate, dir);
  7447. break;
  7448. case 3:
  7449. case 4:
  7450. this.viewDate = this.moveYear(this.viewDate, dir);
  7451. break;
  7452. }
  7453. this.fill();
  7454. this.element.trigger({
  7455. type: target[0].className + ':' + this.convertViewModeText(this.viewMode),
  7456. date: this.viewDate,
  7457. startDate: this.startDate,
  7458. endDate: this.endDate
  7459. });
  7460. break;
  7461. case 'clear':
  7462. this.reset();
  7463. if (this.autoclose) {
  7464. this.hide();
  7465. }
  7466. break;
  7467. case 'today':
  7468. var date = new Date();
  7469. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
  7470. // Respect startDate and endDate.
  7471. if (date < this.startDate) date = this.startDate;
  7472. else if (date > this.endDate) date = this.endDate;
  7473. this.viewMode = this.startViewMode;
  7474. this.showMode(0);
  7475. this._setDate(date);
  7476. this.fill();
  7477. if (this.autoclose) {
  7478. this.hide();
  7479. }
  7480. break;
  7481. }
  7482. break;
  7483. case 'span':
  7484. if (!target.is('.disabled')) {
  7485. var year = this.viewDate.getUTCFullYear(),
  7486. month = this.viewDate.getUTCMonth(),
  7487. day = this.viewDate.getUTCDate(),
  7488. hours = this.viewDate.getUTCHours(),
  7489. minutes = this.viewDate.getUTCMinutes(),
  7490. seconds = this.viewDate.getUTCSeconds();
  7491. if (target.is('.month')) {
  7492. this.viewDate.setUTCDate(1);
  7493. month = target.parent().find('span').index(target);
  7494. day = this.viewDate.getUTCDate();
  7495. this.viewDate.setUTCMonth(month);
  7496. this.element.trigger({
  7497. type: 'changeMonth',
  7498. date: this.viewDate
  7499. });
  7500. if (this.viewSelect >= 3) {
  7501. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7502. }
  7503. } else if (target.is('.year')) {
  7504. this.viewDate.setUTCDate(1);
  7505. year = parseInt(target.text(), 10) || 0;
  7506. this.viewDate.setUTCFullYear(year);
  7507. this.element.trigger({
  7508. type: 'changeYear',
  7509. date: this.viewDate
  7510. });
  7511. if (this.viewSelect >= 4) {
  7512. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7513. }
  7514. } else if (target.is('.hour')) {
  7515. hours = parseInt(target.text(), 10) || 0;
  7516. if (target.hasClass('hour_am') || target.hasClass('hour_pm')) {
  7517. if (hours == 12 && target.hasClass('hour_am')) {
  7518. hours = 0;
  7519. } else if (hours != 12 && target.hasClass('hour_pm')) {
  7520. hours += 12;
  7521. }
  7522. }
  7523. this.viewDate.setUTCHours(hours);
  7524. this.element.trigger({
  7525. type: 'changeHour',
  7526. date: this.viewDate
  7527. });
  7528. if (this.viewSelect >= 1) {
  7529. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7530. }
  7531. } else if (target.is('.minute')) {
  7532. minutes = parseInt(target.text().substr(target.text().indexOf(':') + 1), 10) || 0;
  7533. this.viewDate.setUTCMinutes(minutes);
  7534. this.element.trigger({
  7535. type: 'changeMinute',
  7536. date: this.viewDate
  7537. });
  7538. if (this.viewSelect >= 0) {
  7539. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7540. }
  7541. }
  7542. if (this.viewMode != 0) {
  7543. var oldViewMode = this.viewMode;
  7544. this.showMode( - 1);
  7545. this.fill();
  7546. if (oldViewMode == this.viewMode && this.autoclose) {
  7547. this.hide();
  7548. }
  7549. } else {
  7550. this.fill();
  7551. if (this.autoclose) {
  7552. this.hide();
  7553. }
  7554. }
  7555. }
  7556. break;
  7557. case 'td':
  7558. if (target.is('.day') && !target.is('.disabled')) {
  7559. var day = parseInt(target.text(), 10) || 1;
  7560. var year = this.viewDate.getUTCFullYear(),
  7561. month = this.viewDate.getUTCMonth(),
  7562. hours = this.viewDate.getUTCHours(),
  7563. minutes = this.viewDate.getUTCMinutes(),
  7564. seconds = this.viewDate.getUTCSeconds();
  7565. if (target.is('.old')) {
  7566. if (month === 0) {
  7567. month = 11;
  7568. year -= 1;
  7569. } else {
  7570. month -= 1;
  7571. }
  7572. } else if (target.is('.new')) {
  7573. if (month == 11) {
  7574. month = 0;
  7575. year += 1;
  7576. } else {
  7577. month += 1;
  7578. }
  7579. }
  7580. this.viewDate.setUTCFullYear(year);
  7581. this.viewDate.setUTCMonth(month, day);
  7582. this.element.trigger({
  7583. type: 'changeDay',
  7584. date: this.viewDate
  7585. });
  7586. if (this.viewSelect >= 2) {
  7587. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  7588. }
  7589. }
  7590. var oldViewMode = this.viewMode;
  7591. this.showMode( - 1);
  7592. this.fill();
  7593. if (oldViewMode == this.viewMode && this.autoclose) {
  7594. this.hide();
  7595. }
  7596. break;
  7597. }
  7598. }
  7599. },
  7600. _setDate: function(date, which) {
  7601. if (!which || which == 'date') this.date = date;
  7602. if (!which || which == 'view') this.viewDate = date;
  7603. this.fill();
  7604. this.setValue();
  7605. var element;
  7606. if (this.isInput) {
  7607. element = this.element;
  7608. } else if (this.component) {
  7609. element = this.element.find('input');
  7610. }
  7611. if (element) {
  7612. element.change();
  7613. if (this.autoclose && (!which || which == 'date')) {
  7614. //this.hide();
  7615. }
  7616. }
  7617. this.element.trigger({
  7618. type: 'changeDate',
  7619. date: this.getDate()
  7620. });
  7621. if (date == null) this.date = this.viewDate;
  7622. },
  7623. moveMinute: function(date, dir) {
  7624. if (!dir) return date;
  7625. var new_date = new Date(date.valueOf());
  7626. //dir = dir > 0 ? 1 : -1;
  7627. new_date.setUTCMinutes(new_date.getUTCMinutes() + (dir * this.minuteStep));
  7628. return new_date;
  7629. },
  7630. moveHour: function(date, dir) {
  7631. if (!dir) return date;
  7632. var new_date = new Date(date.valueOf());
  7633. //dir = dir > 0 ? 1 : -1;
  7634. new_date.setUTCHours(new_date.getUTCHours() + dir);
  7635. return new_date;
  7636. },
  7637. moveDate: function(date, dir) {
  7638. if (!dir) return date;
  7639. var new_date = new Date(date.valueOf());
  7640. //dir = dir > 0 ? 1 : -1;
  7641. new_date.setUTCDate(new_date.getUTCDate() + dir);
  7642. return new_date;
  7643. },
  7644. moveMonth: function(date, dir) {
  7645. if (!dir) return date;
  7646. var new_date = new Date(date.valueOf()),
  7647. day = new_date.getUTCDate(),
  7648. month = new_date.getUTCMonth(),
  7649. mag = Math.abs(dir),
  7650. new_month,
  7651. test;
  7652. dir = dir > 0 ? 1 : -1;
  7653. if (mag == 1) {
  7654. test = dir == -1
  7655. // If going back one month, make sure month is not current month
  7656. // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
  7657. ?
  7658. function() {
  7659. return new_date.getUTCMonth() == month;
  7660. }
  7661. // If going forward one month, make sure month is as expected
  7662. // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
  7663. : function() {
  7664. return new_date.getUTCMonth() != new_month;
  7665. };
  7666. new_month = month + dir;
  7667. new_date.setUTCMonth(new_month);
  7668. // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
  7669. if (new_month < 0 || new_month > 11) new_month = (new_month + 12) % 12;
  7670. } else {
  7671. // For magnitudes >1, move one month at a time...
  7672. for (var i = 0; i < mag; i++)
  7673. // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
  7674. new_date = this.moveMonth(new_date, dir);
  7675. // ...then reset the day, keeping it in the new month
  7676. new_month = new_date.getUTCMonth();
  7677. new_date.setUTCDate(day);
  7678. test = function() {
  7679. return new_month != new_date.getUTCMonth();
  7680. };
  7681. }
  7682. // Common date-resetting loop -- if date is beyond end of month, make it
  7683. // end of month
  7684. while (test()) {
  7685. new_date.setUTCDate(--day);
  7686. new_date.setUTCMonth(new_month);
  7687. }
  7688. return new_date;
  7689. },
  7690. moveYear: function(date, dir) {
  7691. return this.moveMonth(date, dir * 12);
  7692. },
  7693. dateWithinRange: function(date) {
  7694. return date >= this.startDate && date <= this.endDate;
  7695. },
  7696. keydown: function(e) {
  7697. if (this.picker.is(':not(:visible)')) {
  7698. if (e.keyCode == 27) // allow escape to hide and re-show picker
  7699. this.show();
  7700. return;
  7701. }
  7702. var dateChanged = false,
  7703. dir, day, month, newDate, newViewDate;
  7704. switch (e.keyCode) {
  7705. case 27:
  7706. // escape
  7707. this.hide();
  7708. e.preventDefault();
  7709. break;
  7710. case 37:
  7711. // left
  7712. case 39:
  7713. // right
  7714. if (!this.keyboardNavigation) break;
  7715. dir = e.keyCode == 37 ? -1 : 1;
  7716. viewMode = this.viewMode;
  7717. if (e.ctrlKey) {
  7718. viewMode += 2;
  7719. } else if (e.shiftKey) {
  7720. viewMode += 1;
  7721. }
  7722. if (viewMode == 4) {
  7723. newDate = this.moveYear(this.date, dir);
  7724. newViewDate = this.moveYear(this.viewDate, dir);
  7725. } else if (viewMode == 3) {
  7726. newDate = this.moveMonth(this.date, dir);
  7727. newViewDate = this.moveMonth(this.viewDate, dir);
  7728. } else if (viewMode == 2) {
  7729. newDate = this.moveDate(this.date, dir);
  7730. newViewDate = this.moveDate(this.viewDate, dir);
  7731. } else if (viewMode == 1) {
  7732. newDate = this.moveHour(this.date, dir);
  7733. newViewDate = this.moveHour(this.viewDate, dir);
  7734. } else if (viewMode == 0) {
  7735. newDate = this.moveMinute(this.date, dir);
  7736. newViewDate = this.moveMinute(this.viewDate, dir);
  7737. }
  7738. if (this.dateWithinRange(newDate)) {
  7739. this.date = newDate;
  7740. this.viewDate = newViewDate;
  7741. this.setValue();
  7742. this.update();
  7743. e.preventDefault();
  7744. dateChanged = true;
  7745. }
  7746. break;
  7747. case 38:
  7748. // up
  7749. case 40:
  7750. // down
  7751. if (!this.keyboardNavigation) break;
  7752. dir = e.keyCode == 38 ? -1 : 1;
  7753. viewMode = this.viewMode;
  7754. if (e.ctrlKey) {
  7755. viewMode += 2;
  7756. } else if (e.shiftKey) {
  7757. viewMode += 1;
  7758. }
  7759. if (viewMode == 4) {
  7760. newDate = this.moveYear(this.date, dir);
  7761. newViewDate = this.moveYear(this.viewDate, dir);
  7762. } else if (viewMode == 3) {
  7763. newDate = this.moveMonth(this.date, dir);
  7764. newViewDate = this.moveMonth(this.viewDate, dir);
  7765. } else if (viewMode == 2) {
  7766. newDate = this.moveDate(this.date, dir * 7);
  7767. newViewDate = this.moveDate(this.viewDate, dir * 7);
  7768. } else if (viewMode == 1) {
  7769. if (this.showMeridian) {
  7770. newDate = this.moveHour(this.date, dir * 6);
  7771. newViewDate = this.moveHour(this.viewDate, dir * 6);
  7772. } else {
  7773. newDate = this.moveHour(this.date, dir * 4);
  7774. newViewDate = this.moveHour(this.viewDate, dir * 4);
  7775. }
  7776. } else if (viewMode == 0) {
  7777. newDate = this.moveMinute(this.date, dir * 4);
  7778. newViewDate = this.moveMinute(this.viewDate, dir * 4);
  7779. }
  7780. if (this.dateWithinRange(newDate)) {
  7781. this.date = newDate;
  7782. this.viewDate = newViewDate;
  7783. this.setValue();
  7784. this.update();
  7785. e.preventDefault();
  7786. dateChanged = true;
  7787. }
  7788. break;
  7789. case 13:
  7790. // enter
  7791. if (this.viewMode != 0) {
  7792. var oldViewMode = this.viewMode;
  7793. this.showMode( - 1);
  7794. this.fill();
  7795. if (oldViewMode == this.viewMode && this.autoclose) {
  7796. this.hide();
  7797. }
  7798. } else {
  7799. this.fill();
  7800. if (this.autoclose) {
  7801. this.hide();
  7802. }
  7803. }
  7804. e.preventDefault();
  7805. break;
  7806. case 9:
  7807. // tab
  7808. this.hide();
  7809. break;
  7810. }
  7811. if (dateChanged) {
  7812. var element;
  7813. if (this.isInput) {
  7814. element = this.element;
  7815. } else if (this.component) {
  7816. element = this.element.find('input');
  7817. }
  7818. if (element) {
  7819. element.change();
  7820. }
  7821. this.element.trigger({
  7822. type: 'changeDate',
  7823. date: this.getDate()
  7824. });
  7825. }
  7826. },
  7827. showMode: function(dir) {
  7828. if (dir) {
  7829. var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
  7830. if (newViewMode >= this.minView && newViewMode <= this.maxView) {
  7831. this.element.trigger({
  7832. type: 'changeMode',
  7833. date: this.viewDate,
  7834. oldViewMode: this.viewMode,
  7835. newViewMode: newViewMode
  7836. });
  7837. this.viewMode = newViewMode;
  7838. }
  7839. }
  7840. /*
  7841. vitalets: fixing bug of very special conditions:
  7842. jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
  7843. Method show() does not set display css correctly and datetimepicker is not shown.
  7844. Changed to .css('display', 'block') solve the problem.
  7845. See https://github.com/vitalets/x-editable/issues/37
  7846. In jquery 1.7.2+ everything works fine.
  7847. */
  7848. //this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
  7849. this.picker.find('>div').hide().filter('.datetimepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
  7850. this.updateNavArrows();
  7851. },
  7852. reset: function(e) {
  7853. this._setDate(null, 'date');
  7854. },
  7855. convertViewModeText: function(viewMode) {
  7856. switch (viewMode) {
  7857. case 4:
  7858. return 'decade';
  7859. case 3:
  7860. return 'year';
  7861. case 2:
  7862. return 'month';
  7863. case 1:
  7864. return 'day';
  7865. case 0:
  7866. return 'hour';
  7867. }
  7868. }
  7869. };
  7870. var old = $.fn.datetimepicker;
  7871. $.fn.datetimepicker = function(option) {
  7872. var args = Array.apply(null, arguments);
  7873. args.shift();
  7874. var internal_return;
  7875. this.each(function() {
  7876. var $this = $(this),
  7877. data = $this.data('datetimepicker'),
  7878. options = typeof option == 'object' && option;
  7879. if (!data) {
  7880. $this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({},
  7881. $.fn.datetimepicker.defaults, options))));
  7882. }
  7883. if (typeof option == 'string' && typeof data[option] == 'function') {
  7884. internal_return = data[option].apply(data, args);
  7885. if (internal_return !== undefined) {
  7886. return false;
  7887. }
  7888. }
  7889. });
  7890. if (internal_return !== undefined) return internal_return;
  7891. else return this;
  7892. };
  7893. $.fn.datetimepicker.defaults = {};
  7894. $.fn.datetimepicker.Constructor = Datetimepicker;
  7895. var dates = $.fn.datetimepicker.dates = {
  7896. en: {
  7897. days: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'],
  7898. daysShort: ['日', '一', '二', '三', '四', '五', '六', '日'],
  7899. daysMin: ['日', '一', '二', '三', '四', '五', '六', '日'],
  7900. months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
  7901. monthsShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  7902. meridiem: ['上午', '下午'],
  7903. suffix: ['st', 'nd', 'rd', 'th'],
  7904. today: '今天',
  7905. clear: '清空'
  7906. }
  7907. };
  7908. var DPGlobal = {
  7909. modes: [{
  7910. clsName: 'minutes',
  7911. navFnc: 'Hours',
  7912. navStep: 1
  7913. },
  7914. {
  7915. clsName: 'hours',
  7916. navFnc: 'Date',
  7917. navStep: 1
  7918. },
  7919. {
  7920. clsName: 'days',
  7921. navFnc: 'Month',
  7922. navStep: 1
  7923. },
  7924. {
  7925. clsName: 'months',
  7926. navFnc: 'FullYear',
  7927. navStep: 1
  7928. },
  7929. {
  7930. clsName: 'years',
  7931. navFnc: 'FullYear',
  7932. navStep: 10
  7933. }],
  7934. isLeapYear: function(year) {
  7935. return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
  7936. },
  7937. getDaysInMonth: function(year, month) {
  7938. return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
  7939. },
  7940. getDefaultFormat: function(type, field) {
  7941. if (type == 'standard') {
  7942. if (field == 'input') return 'yyyy-mm-dd hh:ii';
  7943. else return 'yyyy-mm-dd hh:ii:ss';
  7944. } else if (type == 'php') {
  7945. if (field == 'input') return 'Y-m-d H:i';
  7946. else return 'Y-m-d H:i:s';
  7947. } else {
  7948. throw new Error('Invalid format type.');
  7949. }
  7950. },
  7951. validParts: function(type) {
  7952. if (type == 'standard') {
  7953. return /t|hh?|HH?|p|P|z|Z|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
  7954. } else if (type == 'php') {
  7955. return /[dDjlNwzFmMnStyYaABgGhHis]/g;
  7956. } else {
  7957. throw new Error('Invalid format type.');
  7958. }
  7959. },
  7960. nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
  7961. parseFormat: function(format, type) {
  7962. // IE treats \0 as a string end in inputs (truncating the value),
  7963. // so it's a bad format delimiter, anyway
  7964. var separators = format.replace(this.validParts(type), '\0').split('\0'),
  7965. parts = format.match(this.validParts(type));
  7966. if (!separators || !separators.length || !parts || parts.length == 0) {
  7967. throw new Error('Invalid date format.');
  7968. }
  7969. return {
  7970. separators: separators,
  7971. parts: parts
  7972. };
  7973. },
  7974. parseDate: function(date, format, language, type, timezone) {
  7975. if (date instanceof Date) {
  7976. var dateUTC = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
  7977. dateUTC.setMilliseconds(0);
  7978. return dateUTC;
  7979. }
  7980. if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
  7981. format = this.parseFormat('yyyy-mm-dd', type);
  7982. }
  7983. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
  7984. format = this.parseFormat('yyyy-mm-dd hh:ii', type);
  7985. }
  7986. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
  7987. format = this.parseFormat('yyyy-mm-dd hh:ii:ss', type);
  7988. }
  7989. if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
  7990. var part_re = /([-+]\d+)([dmwy])/,
  7991. parts = date.match(/([-+]\d+)([dmwy])/g),
  7992. part,
  7993. dir;
  7994. date = new Date();
  7995. for (var i = 0; i < parts.length; i++) {
  7996. part = part_re.exec(parts[i]);
  7997. dir = parseInt(part[1]);
  7998. switch (part[2]) {
  7999. case 'd':
  8000. date.setUTCDate(date.getUTCDate() + dir);
  8001. break;
  8002. case 'm':
  8003. date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
  8004. break;
  8005. case 'w':
  8006. date.setUTCDate(date.getUTCDate() + dir * 7);
  8007. break;
  8008. case 'y':
  8009. date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
  8010. break;
  8011. }
  8012. }
  8013. return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), 0);
  8014. }
  8015. var parts = date && date.toString().match(this.nonpunctuation) || [],
  8016. date = new Date(0, 0, 0, 0, 0, 0, 0),
  8017. parsed = {},
  8018. setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'D', 'DD', 'd', 'dd', 'H', 'HH', 'p', 'P', 'z', 'Z'],
  8019. setters_map = {
  8020. hh: function(d, v) {
  8021. return d.setUTCHours(v);
  8022. },
  8023. h: function(d, v) {
  8024. return d.setUTCHours(v);
  8025. },
  8026. HH: function(d, v) {
  8027. return d.setUTCHours(v == 12 ? 0 : v);
  8028. },
  8029. H: function(d, v) {
  8030. return d.setUTCHours(v == 12 ? 0 : v);
  8031. },
  8032. ii: function(d, v) {
  8033. return d.setUTCMinutes(v);
  8034. },
  8035. i: function(d, v) {
  8036. return d.setUTCMinutes(v);
  8037. },
  8038. ss: function(d, v) {
  8039. return d.setUTCSeconds(v);
  8040. },
  8041. s: function(d, v) {
  8042. return d.setUTCSeconds(v);
  8043. },
  8044. yyyy: function(d, v) {
  8045. return d.setUTCFullYear(v);
  8046. },
  8047. yy: function(d, v) {
  8048. return d.setUTCFullYear(2000 + v);
  8049. },
  8050. m: function(d, v) {
  8051. v -= 1;
  8052. while (v < 0) v += 12;
  8053. v %= 12;
  8054. d.setUTCMonth(v);
  8055. while (d.getUTCMonth() != v) if (isNaN(d.getUTCMonth())) return d;
  8056. else d.setUTCDate(d.getUTCDate() - 1);
  8057. return d;
  8058. },
  8059. d: function(d, v) {
  8060. return d.setUTCDate(v);
  8061. },
  8062. p: function(d, v) {
  8063. return d.setUTCHours(v == 1 ? d.getUTCHours() + 12 : d.getUTCHours());
  8064. },
  8065. z: function() {
  8066. return timezone
  8067. }
  8068. },
  8069. val,
  8070. filtered,
  8071. part;
  8072. setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
  8073. setters_map['dd'] = setters_map['d'];
  8074. setters_map['P'] = setters_map['p'];
  8075. setters_map['Z'] = setters_map['z'];
  8076. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
  8077. if (parts.length == format.parts.length) {
  8078. for (var i = 0,
  8079. cnt = format.parts.length; i < cnt; i++) {
  8080. val = parseInt(parts[i], 10);
  8081. part = format.parts[i];
  8082. if (isNaN(val)) {
  8083. switch (part) {
  8084. case 'MM':
  8085. filtered = $(dates[language].months).filter(function() {
  8086. var m = this.slice(0, parts[i].length),
  8087. p = parts[i].slice(0, m.length);
  8088. return m == p;
  8089. });
  8090. val = $.inArray(filtered[0], dates[language].months) + 1;
  8091. break;
  8092. case 'M':
  8093. filtered = $(dates[language].monthsShort).filter(function() {
  8094. var m = this.slice(0, parts[i].length),
  8095. p = parts[i].slice(0, m.length);
  8096. return m.toLowerCase() == p.toLowerCase();
  8097. });
  8098. val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
  8099. break;
  8100. case 'p':
  8101. case 'P':
  8102. val = $.inArray(parts[i].toLowerCase(), dates[language].meridiem);
  8103. break;
  8104. case 'z':
  8105. case 'Z':
  8106. timezone;
  8107. break;
  8108. }
  8109. }
  8110. parsed[part] = val;
  8111. }
  8112. for (var i = 0,
  8113. s; i < setters_order.length; i++) {
  8114. s = setters_order[i];
  8115. if (s in parsed && !isNaN(parsed[s])) setters_map[s](date, parsed[s])
  8116. }
  8117. }
  8118. return date;
  8119. },
  8120. formatDate: function(date, format, language, type, timezone) {
  8121. if (date == null) {
  8122. return '';
  8123. }
  8124. var val;
  8125. if (type == 'standard') {
  8126. val = {
  8127. t: date.getTime(),
  8128. // year
  8129. yy: date.getUTCFullYear().toString().substring(2),
  8130. yyyy: date.getUTCFullYear(),
  8131. // month
  8132. m: date.getUTCMonth() + 1,
  8133. M: dates[language].monthsShort[date.getUTCMonth()],
  8134. MM: dates[language].months[date.getUTCMonth()],
  8135. // day
  8136. d: date.getUTCDate(),
  8137. D: dates[language].daysShort[date.getUTCDay()],
  8138. DD: dates[language].days[date.getUTCDay()],
  8139. p: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
  8140. // hour
  8141. h: date.getUTCHours(),
  8142. // minute
  8143. i: date.getUTCMinutes(),
  8144. // second
  8145. s: date.getUTCSeconds(),
  8146. // timezone
  8147. z: timezone
  8148. };
  8149. if (dates[language].meridiem.length == 2) {
  8150. val.H = (val.h % 12 == 0 ? 12 : val.h % 12);
  8151. } else {
  8152. val.H = val.h;
  8153. }
  8154. val.HH = (val.H < 10 ? '0': '') + val.H;
  8155. val.P = val.p.toUpperCase();
  8156. val.Z = val.z;
  8157. val.hh = (val.h < 10 ? '0': '') + val.h;
  8158. val.ii = (val.i < 10 ? '0': '') + val.i;
  8159. val.ss = (val.s < 10 ? '0': '') + val.s;
  8160. val.dd = (val.d < 10 ? '0': '') + val.d;
  8161. val.mm = (val.m < 10 ? '0': '') + val.m;
  8162. } else if (type == 'php') {
  8163. // php format
  8164. val = {
  8165. // year
  8166. y: date.getUTCFullYear().toString().substring(2),
  8167. Y: date.getUTCFullYear(),
  8168. // month
  8169. F: dates[language].months[date.getUTCMonth()],
  8170. M: dates[language].monthsShort[date.getUTCMonth()],
  8171. n: date.getUTCMonth() + 1,
  8172. t: DPGlobal.getDaysInMonth(date.getUTCFullYear(), date.getUTCMonth()),
  8173. // day
  8174. j: date.getUTCDate(),
  8175. l: dates[language].days[date.getUTCDay()],
  8176. D: dates[language].daysShort[date.getUTCDay()],
  8177. w: date.getUTCDay(),
  8178. // 0 -> 6
  8179. N: (date.getUTCDay() == 0 ? 7 : date.getUTCDay()),
  8180. // 1 -> 7
  8181. S: (date.getUTCDate() % 10 <= dates[language].suffix.length ? dates[language].suffix[date.getUTCDate() % 10 - 1] : ''),
  8182. // hour
  8183. a: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
  8184. g: (date.getUTCHours() % 12 == 0 ? 12 : date.getUTCHours() % 12),
  8185. G: date.getUTCHours(),
  8186. // minute
  8187. i: date.getUTCMinutes(),
  8188. // second
  8189. s: date.getUTCSeconds()
  8190. };
  8191. val.m = (val.n < 10 ? '0': '') + val.n;
  8192. val.d = (val.j < 10 ? '0': '') + val.j;
  8193. val.A = val.a.toString().toUpperCase();
  8194. val.h = (val.g < 10 ? '0': '') + val.g;
  8195. val.H = (val.G < 10 ? '0': '') + val.G;
  8196. val.i = (val.i < 10 ? '0': '') + val.i;
  8197. val.s = (val.s < 10 ? '0': '') + val.s;
  8198. } else {
  8199. throw new Error('Invalid format type.');
  8200. }
  8201. var date = [],
  8202. seps = $.extend([], format.separators);
  8203. for (var i = 0,
  8204. cnt = format.parts.length; i < cnt; i++) {
  8205. if (seps.length) {
  8206. date.push(seps.shift());
  8207. }
  8208. date.push(val[format.parts[i]]);
  8209. }
  8210. if (seps.length) {
  8211. date.push(seps.shift());
  8212. }
  8213. return date.join('');
  8214. },
  8215. convertViewMode: function(viewMode) {
  8216. switch (viewMode) {
  8217. case 4:
  8218. case 'decade':
  8219. viewMode = 4;
  8220. break;
  8221. case 3:
  8222. case 'year':
  8223. viewMode = 3;
  8224. break;
  8225. case 2:
  8226. case 'month':
  8227. viewMode = 2;
  8228. break;
  8229. case 1:
  8230. case 'day':
  8231. viewMode = 1;
  8232. break;
  8233. case 0:
  8234. case 'hour':
  8235. viewMode = 0;
  8236. break;
  8237. }
  8238. return viewMode;
  8239. },
  8240. 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>',
  8241. 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>',
  8242. contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
  8243. footTemplate: '<tfoot>' + '<tr><th colspan="7" class="today"></th></tr>' + '<tr><th colspan="7" class="clear"></th></tr>' + '</tfoot>'
  8244. };
  8245. 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>';
  8246. 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>';
  8247. $.fn.datetimepicker.DPGlobal = DPGlobal;
  8248. /* DATETIMEPICKER NO CONFLICT
  8249. * =================== */
  8250. $.fn.datetimepicker.noConflict = function() {
  8251. $.fn.datetimepicker = old;
  8252. return this;
  8253. };
  8254. /* DATETIMEPICKER DATA-API
  8255. * ================== */
  8256. $(document).on('focus.datetimepicker.data-api click.datetimepicker.data-api', '[data-provide="datetimepicker"]',
  8257. function(e) {
  8258. var $this = $(this);
  8259. if ($this.data('datetimepicker')) return;
  8260. e.preventDefault();
  8261. // component click requires us to explicitly show it
  8262. $this.datetimepicker('show');
  8263. });
  8264. $(function() {
  8265. $('[data-provide="datetimepicker-inline"]').datetimepicker();
  8266. });
  8267. }));
  8268. /* ============================================================
  8269. * Bootstrap.Switch v1.3 by Larentis Mattia @spiritualGuru
  8270. * http://www.larentis.eu/switch/
  8271. * ============================================================
  8272. * Licensed under the Apache License, Version 2.0
  8273. * http://www.apache.org/licenses/LICENSE-2.0
  8274. * ============================================================ */
  8275. !function($) {
  8276. "use strict";
  8277. $.fn['bootstrapSwitch'] = function(method) {
  8278. var methods = {
  8279. init: function() {
  8280. return this.each(function() {
  8281. var $element = $(this),
  8282. $div,
  8283. $switchLeft,
  8284. $switchRight,
  8285. $label,
  8286. myClasses = "",
  8287. classes = $element.attr('class'),
  8288. color,
  8289. moving,
  8290. onLabel = "ON",
  8291. offLabel = "OFF",
  8292. icon = false;
  8293. $.each(['size-MINI', 'size-S', 'size-L'],
  8294. function(i, el) {
  8295. if (classes.indexOf(el) >= 0) myClasses = el;
  8296. });
  8297. $element.addClass('has-switch');
  8298. if ($element.data('on') !== undefined) color = "switch-" + $element.data('on');
  8299. if ($element.data('on-label') !== undefined) onLabel = $element.data('on-label');
  8300. if ($element.data('off-label') !== undefined) offLabel = $element.data('off-label');
  8301. if ($element.data('icon') !== undefined) icon = $element.data('icon');
  8302. $switchLeft = $('<span>').addClass("switch-left").addClass(myClasses).addClass(color).html(onLabel);
  8303. color = '';
  8304. if ($element.data('off') !== undefined) color = "switch-" + $element.data('off');
  8305. $switchRight = $('<span>').addClass("switch-right").addClass(myClasses).addClass(color).html(offLabel);
  8306. $label = $('<label>').html("&nbsp;").addClass(myClasses).attr('for', $element.find('input').attr('id'));
  8307. if (icon) {
  8308. $label.html('<i class="icon icon-' + icon + '"></i>');
  8309. }
  8310. $div = $element.find(':checkbox').wrap($('<div>')).parent().data('animated', false);
  8311. if ($element.data('animated') !== false) $div.addClass('switch-animate').data('animated', true);
  8312. $div.append($switchLeft).append($label).append($switchRight);
  8313. $element.find('>div').addClass($element.find('input').is(':checked') ? 'switch-on': 'switch-off');
  8314. if ($element.find('input').is(':disabled')) $(this).addClass('deactivate');
  8315. var changeStatus = function($this) {
  8316. $this.siblings('label').trigger('mousedown').trigger('mouseup').trigger('click');
  8317. };
  8318. $element.on('keydown',
  8319. function(e) {
  8320. if (e.keyCode === 32) {
  8321. e.stopImmediatePropagation();
  8322. e.preventDefault();
  8323. changeStatus($(e.target).find('span:first'));
  8324. }
  8325. });
  8326. $switchLeft.on('click',
  8327. function(e) {
  8328. changeStatus($(this));
  8329. });
  8330. $switchRight.on('click',
  8331. function(e) {
  8332. changeStatus($(this));
  8333. });
  8334. $element.find('input').on('change',
  8335. function(e) {
  8336. var $this = $(this),
  8337. $element = $this.parent(),
  8338. thisState = $this.is(':checked'),
  8339. state = $element.is('.switch-off');
  8340. e.preventDefault();
  8341. $element.css('left', '');
  8342. if (state === thisState) {
  8343. if (thisState) $element.removeClass('switch-off').addClass('switch-on');
  8344. else $element.removeClass('switch-on').addClass('switch-off');
  8345. if ($element.data('animated') !== false) $element.addClass("switch-animate");
  8346. $element.parent().trigger('switch-change', {
  8347. 'el': $this,
  8348. 'value': thisState
  8349. })
  8350. }
  8351. });
  8352. $element.find('label').on('mousedown touchstart',
  8353. function(e) {
  8354. var $this = $(this);
  8355. moving = false;
  8356. e.preventDefault();
  8357. e.stopImmediatePropagation();
  8358. $this.closest('div').removeClass('switch-animate');
  8359. if ($this.closest('.has-switch').is('.deactivate')) $this.unbind('click');
  8360. else {
  8361. $this.on('mousemove touchmove',
  8362. function(e) {
  8363. var $element = $(this).closest('.switch'),
  8364. relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $element.offset().left,
  8365. percent = (relativeX / $element.width()) * 100,
  8366. left = 25,
  8367. right = 75;
  8368. moving = true;
  8369. if (percent < left) percent = left;
  8370. else if (percent > right) percent = right;
  8371. $element.find('>div').css('left', (percent - right) + "%")
  8372. });
  8373. $this.on('click touchend',
  8374. function(e) {
  8375. var $this = $(this),
  8376. $target = $(e.target),
  8377. $myCheckBox = $target.siblings('input');
  8378. e.stopImmediatePropagation();
  8379. e.preventDefault();
  8380. $this.unbind('mouseleave');
  8381. if (moving) $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
  8382. else $myCheckBox.prop("checked", !$myCheckBox.is(":checked"));
  8383. moving = false;
  8384. $myCheckBox.trigger('change');
  8385. });
  8386. $this.on('mouseleave',
  8387. function(e) {
  8388. var $this = $(this),
  8389. $myCheckBox = $this.siblings('input');
  8390. e.preventDefault();
  8391. e.stopImmediatePropagation();
  8392. $this.unbind('mouseleave');
  8393. $this.trigger('mouseup');
  8394. $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
  8395. });
  8396. $this.on('mouseup',
  8397. function(e) {
  8398. e.stopImmediatePropagation();
  8399. e.preventDefault();
  8400. $(this).unbind('mousemove');
  8401. });
  8402. }
  8403. });
  8404. });
  8405. },
  8406. toggleActivation: function() {
  8407. $(this).toggleClass('deactivate');
  8408. },
  8409. isActive: function() {
  8410. return ! $(this).hasClass('deactivate');
  8411. },
  8412. setActive: function(active) {
  8413. if (active) $(this).removeClass('deactivate');
  8414. else $(this).addClass('deactivate');
  8415. },
  8416. toggleState: function(skipOnChange) {
  8417. var $input = $(this).find('input:checkbox');
  8418. $input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
  8419. },
  8420. setState: function(value, skipOnChange) {
  8421. $(this).find('input:checkbox').prop('checked', value).trigger('change', skipOnChange);
  8422. },
  8423. status: function() {
  8424. return $(this).find('input:checkbox').is(':checked');
  8425. },
  8426. destroy: function() {
  8427. var $div = $(this).find('div'),
  8428. $checkbox;
  8429. $div.find(':not(input:checkbox)').remove();
  8430. $checkbox = $div.children();
  8431. $checkbox.unwrap().unwrap();
  8432. $checkbox.unbind('change');
  8433. return $checkbox;
  8434. }
  8435. };
  8436. if (methods[method]) return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  8437. else if (typeof method === 'object' || !method) return methods.init.apply(this, arguments);
  8438. else $.error('Method ' + method + ' does not exist!');
  8439. };
  8440. } (jQuery);
  8441. $(function() {
  8442. $('.switch')['bootstrapSwitch']();
  8443. });