mootools.js 195 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456
  1. /*
  2. ---
  3. MooTools: the javascript framework
  4. web build:
  5. - http://mootools.net/core/76bf47062d6c1983d66ce47ad66aa0e0
  6. packager build:
  7. - packager build Core/Core Core/Array Core/String Core/Number Core/Function Core/Object Core/Event Core/Browser Core/Class Core/Class.Extras Core/Slick.Parser Core/Slick.Finder Core/Element Core/Element.Style Core/Element.Event Core/Element.Delegation Core/Element.Dimensions Core/Fx Core/Fx.CSS Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request Core/Request.HTML Core/Request.JSON Core/Cookie Core/JSON Core/DOMReady Core/Swiff
  8. ...
  9. */
  10. /*
  11. ---
  12. name: Core
  13. description: The heart of MooTools.
  14. license: MIT-style license.
  15. copyright: Copyright (c) 2006-2012 [Valerio Proietti](http://mad4milk.net/).
  16. authors: The MooTools production team (http://mootools.net/developers/)
  17. inspiration:
  18. - Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)
  19. - Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)
  20. provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
  21. ...
  22. */
  23. (function () {
  24. this.MooTools = {
  25. version: '1.4.5',
  26. build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0'
  27. };
  28. // typeOf, instanceOf
  29. var typeOf = this.typeOf = function (item) {
  30. if (item == null) return 'null';
  31. if (item.$family != null) return item.$family();
  32. if (item.nodeName) {
  33. if (item.nodeType == 1) return 'element';
  34. if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
  35. } else if (typeof item.length == 'number') {
  36. if (item.callee) return 'arguments';
  37. if ('item' in item) return 'collection';
  38. }
  39. return typeof item;
  40. };
  41. var instanceOf = this.instanceOf = function (item, object) {
  42. if (item == null) return false;
  43. var constructor = item.$constructor || item.constructor;
  44. while (constructor) {
  45. if (constructor === object) return true;
  46. constructor = constructor.parent;
  47. }
  48. /*<ltIE8>*/
  49. if (!item.hasOwnProperty) return false;
  50. /*</ltIE8>*/
  51. return item instanceof object;
  52. };
  53. // Function overloading
  54. var Function = this.Function;
  55. var enumerables = true;
  56. for (var i in { toString: 1 }) enumerables = null;
  57. if (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];
  58. Function.prototype.overloadSetter = function (usePlural) {
  59. var self = this;
  60. return function (a, b) {
  61. if (a == null) return this;
  62. if (usePlural || typeof a != 'string') {
  63. for (var k in a) self.call(this, k, a[k]);
  64. if (enumerables) for (var i = enumerables.length; i--;) {
  65. k = enumerables[i];
  66. if (a.hasOwnProperty(k)) self.call(this, k, a[k]);
  67. }
  68. } else {
  69. self.call(this, a, b);
  70. }
  71. return this;
  72. };
  73. };
  74. Function.prototype.overloadGetter = function (usePlural) {
  75. var self = this;
  76. return function (a) {
  77. var args, result;
  78. if (typeof a != 'string') args = a;
  79. else if (arguments.length > 1) args = arguments;
  80. else if (usePlural) args = [a];
  81. if (args) {
  82. result = {};
  83. for (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]);
  84. } else {
  85. result = self.call(this, a);
  86. }
  87. return result;
  88. };
  89. };
  90. Function.prototype.extend = function (key, value) {
  91. this[key] = value;
  92. }.overloadSetter();
  93. Function.prototype.implement = function (key, value) {
  94. this.prototype[key] = value;
  95. }.overloadSetter();
  96. // From
  97. var slice = Array.prototype.slice;
  98. Function.from = function (item) {
  99. return (typeOf(item) == 'function') ? item : function () {
  100. return item;
  101. };
  102. };
  103. Array.from = function (item) {
  104. if (item == null) return [];
  105. return (Type.isEnumerable(item) && typeof item != 'string') ? (typeOf(item) == 'array') ? item : slice.call(item) : [item];
  106. };
  107. Number.from = function (item) {
  108. var number = parseFloat(item);
  109. return isFinite(number) ? number : null;
  110. };
  111. String.from = function (item) {
  112. return item + '';
  113. };
  114. // hide, protect
  115. Function.implement({
  116. hide: function () {
  117. this.$hidden = true;
  118. return this;
  119. },
  120. protect: function () {
  121. this.$protected = true;
  122. return this;
  123. }
  124. });
  125. // Type
  126. var Type = this.Type = function (name, object) {
  127. if (name) {
  128. var lower = name.toLowerCase();
  129. var typeCheck = function (item) {
  130. return (typeOf(item) == lower);
  131. };
  132. Type['is' + name] = typeCheck;
  133. if (object != null) {
  134. object.prototype.$family = (function () {
  135. return lower;
  136. }).hide();
  137. //<1.2compat>
  138. object.type = typeCheck;
  139. //</1.2compat>
  140. }
  141. }
  142. if (object == null) return null;
  143. object.extend(this);
  144. object.$constructor = Type;
  145. object.prototype.$constructor = object;
  146. return object;
  147. };
  148. var toString = Object.prototype.toString;
  149. Type.isEnumerable = function (item) {
  150. return (item != null && typeof item.length == 'number' && toString.call(item) != '[object Function]');
  151. };
  152. var hooks = {};
  153. var hooksOf = function (object) {
  154. var type = typeOf(object.prototype);
  155. return hooks[type] || (hooks[type] = []);
  156. };
  157. var implement = function (name, method) {
  158. if (method && method.$hidden) return;
  159. var hooks = hooksOf(this);
  160. for (var i = 0; i < hooks.length; i++) {
  161. var hook = hooks[i];
  162. if (typeOf(hook) == 'type') implement.call(hook, name, method);
  163. else hook.call(this, name, method);
  164. }
  165. var previous = this.prototype[name];
  166. if (previous == null || !previous.$protected) this.prototype[name] = method;
  167. if (this[name] == null && typeOf(method) == 'function') extend.call(this, name, function (item) {
  168. return method.apply(item, slice.call(arguments, 1));
  169. });
  170. };
  171. var extend = function (name, method) {
  172. if (method && method.$hidden) return;
  173. var previous = this[name];
  174. if (previous == null || !previous.$protected) this[name] = method;
  175. };
  176. Type.implement({
  177. implement: implement.overloadSetter(),
  178. extend: extend.overloadSetter(),
  179. alias: function (name, existing) {
  180. implement.call(this, name, this.prototype[existing]);
  181. }.overloadSetter(),
  182. mirror: function (hook) {
  183. hooksOf(this).push(hook);
  184. return this;
  185. }
  186. });
  187. new Type('Type', Type);
  188. // Default Types
  189. var force = function (name, object, methods) {
  190. var isType = (object != Object),
  191. prototype = object.prototype;
  192. if (isType) object = new Type(name, object);
  193. for (var i = 0, l = methods.length; i < l; i++) {
  194. var key = methods[i],
  195. generic = object[key],
  196. proto = prototype[key];
  197. if (generic) generic.protect();
  198. if (isType && proto) object.implement(key, proto.protect());
  199. }
  200. if (isType) {
  201. var methodsEnumerable = prototype.propertyIsEnumerable(methods[0]);
  202. object.forEachMethod = function (fn) {
  203. if (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++) {
  204. fn.call(prototype, prototype[methods[i]], methods[i]);
  205. }
  206. for (var key in prototype) fn.call(prototype, prototype[key], key)
  207. };
  208. }
  209. return force;
  210. };
  211. force('String', String, [
  212. 'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
  213. 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
  214. ])('Array', Array, [
  215. 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
  216. 'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'
  217. ])('Number', Number, [
  218. 'toExponential', 'toFixed', 'toLocaleString', 'toPrecision'
  219. ])('Function', Function, [
  220. 'apply', 'call', 'bind'
  221. ])('RegExp', RegExp, [
  222. 'exec', 'test'
  223. ])('Object', Object, [
  224. 'create', 'defineProperty', 'defineProperties', 'keys',
  225. 'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames',
  226. 'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen'
  227. ])('Date', Date, ['now']);
  228. Object.extend = extend.overloadSetter();
  229. Date.extend('now', function () {
  230. return +(new Date);
  231. });
  232. new Type('Boolean', Boolean);
  233. // fixes NaN returning as Number
  234. Number.prototype.$family = function () {
  235. return isFinite(this) ? 'number' : 'null';
  236. }.hide();
  237. // Number.random
  238. Number.extend('random', function (min, max) {
  239. return Math.floor(Math.random() * (max - min + 1) + min);
  240. });
  241. // forEach, each
  242. var hasOwnProperty = Object.prototype.hasOwnProperty;
  243. Object.extend('forEach', function (object, fn, bind) {
  244. for (var key in object) {
  245. if (hasOwnProperty.call(object, key)) fn.call(bind, object[key], key, object);
  246. }
  247. });
  248. Object.each = Object.forEach;
  249. Array.implement({
  250. forEach: function (fn, bind) {
  251. for (var i = 0, l = this.length; i < l; i++) {
  252. if (i in this) fn.call(bind, this[i], i, this);
  253. }
  254. },
  255. each: function (fn, bind) {
  256. Array.forEach(this, fn, bind);
  257. return this;
  258. }
  259. });
  260. // Array & Object cloning, Object merging and appending
  261. var cloneOf = function (item) {
  262. switch (typeOf(item)) {
  263. case 'array': return item.clone();
  264. case 'object': return Object.clone(item);
  265. default: return item;
  266. }
  267. };
  268. Array.implement('clone', function () {
  269. var i = this.length, clone = new Array(i);
  270. while (i--) clone[i] = cloneOf(this[i]);
  271. return clone;
  272. });
  273. var mergeOne = function (source, key, current) {
  274. switch (typeOf(current)) {
  275. case 'object':
  276. if (typeOf(source[key]) == 'object') Object.merge(source[key], current);
  277. else source[key] = Object.clone(current);
  278. break;
  279. case 'array': source[key] = current.clone(); break;
  280. default: source[key] = current;
  281. }
  282. return source;
  283. };
  284. Object.extend({
  285. merge: function (source, k, v) {
  286. if (typeOf(k) == 'string') return mergeOne(source, k, v);
  287. for (var i = 1, l = arguments.length; i < l; i++) {
  288. var object = arguments[i];
  289. for (var key in object) mergeOne(source, key, object[key]);
  290. }
  291. return source;
  292. },
  293. clone: function (object) {
  294. var clone = {};
  295. for (var key in object) clone[key] = cloneOf(object[key]);
  296. return clone;
  297. },
  298. append: function (original) {
  299. for (var i = 1, l = arguments.length; i < l; i++) {
  300. var extended = arguments[i] || {};
  301. for (var key in extended) original[key] = extended[key];
  302. }
  303. return original;
  304. }
  305. });
  306. // Object-less types
  307. ['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function (name) {
  308. new Type(name);
  309. });
  310. // Unique ID
  311. var UID = Date.now();
  312. String.extend('uniqueID', function () {
  313. return (UID++).toString(36);
  314. });
  315. //<1.2compat>
  316. var Hash = this.Hash = new Type('Hash', function (object) {
  317. if (typeOf(object) == 'hash') object = Object.clone(object.getClean());
  318. for (var key in object) this[key] = object[key];
  319. return this;
  320. });
  321. Hash.implement({
  322. forEach: function (fn, bind) {
  323. Object.forEach(this, fn, bind);
  324. },
  325. getClean: function () {
  326. var clean = {};
  327. for (var key in this) {
  328. if (this.hasOwnProperty(key)) clean[key] = this[key];
  329. }
  330. return clean;
  331. },
  332. getLength: function () {
  333. var length = 0;
  334. for (var key in this) {
  335. if (this.hasOwnProperty(key)) length++;
  336. }
  337. return length;
  338. }
  339. });
  340. Hash.alias('each', 'forEach');
  341. Object.type = Type.isObject;
  342. var Native = this.Native = function (properties) {
  343. return new Type(properties.name, properties.initialize);
  344. };
  345. Native.type = Type.type;
  346. Native.implement = function (objects, methods) {
  347. for (var i = 0; i < objects.length; i++) objects[i].implement(methods);
  348. return Native;
  349. };
  350. var arrayType = Array.type;
  351. Array.type = function (item) {
  352. return instanceOf(item, Array) || arrayType(item);
  353. };
  354. this.$A = function (item) {
  355. return Array.from(item).slice();
  356. };
  357. this.$arguments = function (i) {
  358. return function () {
  359. return arguments[i];
  360. };
  361. };
  362. this.$chk = function (obj) {
  363. return !!(obj || obj === 0);
  364. };
  365. this.$clear = function (timer) {
  366. clearTimeout(timer);
  367. clearInterval(timer);
  368. return null;
  369. };
  370. this.$defined = function (obj) {
  371. return (obj != null);
  372. };
  373. this.$each = function (iterable, fn, bind) {
  374. var type = typeOf(iterable);
  375. ((type == 'arguments' || type == 'collection' || type == 'array' || type == 'elements') ? Array : Object).each(iterable, fn, bind);
  376. };
  377. this.$empty = function () { };
  378. this.$extend = function (original, extended) {
  379. return Object.append(original, extended);
  380. };
  381. this.$H = function (object) {
  382. return new Hash(object);
  383. };
  384. this.$merge = function () {
  385. var args = Array.slice(arguments);
  386. args.unshift({});
  387. return Object.merge.apply(null, args);
  388. };
  389. this.$lambda = Function.from;
  390. this.$mixin = Object.merge;
  391. this.$random = Number.random;
  392. this.$splat = Array.from;
  393. this.$time = Date.now;
  394. this.$type = function (object) {
  395. var type = typeOf(object);
  396. if (type == 'elements') return 'array';
  397. return (type == 'null') ? false : type;
  398. };
  399. this.$unlink = function (object) {
  400. switch (typeOf(object)) {
  401. case 'object': return Object.clone(object);
  402. case 'array': return Array.clone(object);
  403. case 'hash': return new Hash(object);
  404. default: return object;
  405. }
  406. };
  407. //</1.2compat>
  408. })();
  409. /*
  410. ---
  411. name: Array
  412. description: Contains Array Prototypes like each, contains, and erase.
  413. license: MIT-style license.
  414. requires: Type
  415. provides: Array
  416. ...
  417. */
  418. Array.implement({
  419. /*<!ES5>*/
  420. every: function (fn, bind) {
  421. for (var i = 0, l = this.length >>> 0; i < l; i++) {
  422. if ((i in this) && !fn.call(bind, this[i], i, this)) return false;
  423. }
  424. return true;
  425. },
  426. filter: function (fn, bind) {
  427. var results = [];
  428. for (var value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this) {
  429. value = this[i];
  430. if (fn.call(bind, value, i, this)) results.push(value);
  431. }
  432. return results;
  433. },
  434. indexOf: function (item, from) {
  435. var length = this.length >>> 0;
  436. for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) {
  437. if (this[i] === item) return i;
  438. }
  439. return -1;
  440. },
  441. map: function (fn, bind) {
  442. var length = this.length >>> 0, results = Array(length);
  443. for (var i = 0; i < length; i++) {
  444. if (i in this) results[i] = fn.call(bind, this[i], i, this);
  445. }
  446. return results;
  447. },
  448. some: function (fn, bind) {
  449. for (var i = 0, l = this.length >>> 0; i < l; i++) {
  450. if ((i in this) && fn.call(bind, this[i], i, this)) return true;
  451. }
  452. return false;
  453. },
  454. /*</!ES5>*/
  455. clean: function () {
  456. return this.filter(function (item) {
  457. return item != null;
  458. });
  459. },
  460. invoke: function (methodName) {
  461. var args = Array.slice(arguments, 1);
  462. return this.map(function (item) {
  463. return item[methodName].apply(item, args);
  464. });
  465. },
  466. associate: function (keys) {
  467. var obj = {}, length = Math.min(this.length, keys.length);
  468. for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
  469. return obj;
  470. },
  471. link: function (object) {
  472. var result = {};
  473. for (var i = 0, l = this.length; i < l; i++) {
  474. for (var key in object) {
  475. if (object[key](this[i])) {
  476. result[key] = this[i];
  477. delete object[key];
  478. break;
  479. }
  480. }
  481. }
  482. return result;
  483. },
  484. contains: function (item, from) {
  485. return this.indexOf(item, from) != -1;
  486. },
  487. append: function (array) {
  488. this.push.apply(this, array);
  489. return this;
  490. },
  491. getLast: function () {
  492. return (this.length) ? this[this.length - 1] : null;
  493. },
  494. getRandom: function () {
  495. return (this.length) ? this[Number.random(0, this.length - 1)] : null;
  496. },
  497. include: function (item) {
  498. if (!this.contains(item)) this.push(item);
  499. return this;
  500. },
  501. combine: function (array) {
  502. for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
  503. return this;
  504. },
  505. erase: function (item) {
  506. for (var i = this.length; i--;) {
  507. if (this[i] === item) this.splice(i, 1);
  508. }
  509. return this;
  510. },
  511. empty: function () {
  512. this.length = 0;
  513. return this;
  514. },
  515. flatten: function () {
  516. var array = [];
  517. for (var i = 0, l = this.length; i < l; i++) {
  518. var type = typeOf(this[i]);
  519. if (type == 'null') continue;
  520. array = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceOf(this[i], Array)) ? Array.flatten(this[i]) : this[i]);
  521. }
  522. return array;
  523. },
  524. pick: function () {
  525. for (var i = 0, l = this.length; i < l; i++) {
  526. if (this[i] != null) return this[i];
  527. }
  528. return null;
  529. },
  530. hexToRgb: function (array) {
  531. if (this.length != 3) return null;
  532. var rgb = this.map(function (value) {
  533. if (value.length == 1) value += value;
  534. return value.toInt(16);
  535. });
  536. return (array) ? rgb : 'rgb(' + rgb + ')';
  537. },
  538. rgbToHex: function (array) {
  539. if (this.length < 3) return null;
  540. if (this.length == 4 && this[3] == 0 && !array) return 'transparent';
  541. var hex = [];
  542. for (var i = 0; i < 3; i++) {
  543. var bit = (this[i] - 0).toString(16);
  544. hex.push((bit.length == 1) ? '0' + bit : bit);
  545. }
  546. return (array) ? hex : '#' + hex.join('');
  547. }
  548. });
  549. //<1.2compat>
  550. Array.alias('extend', 'append');
  551. var $pick = function () {
  552. return Array.from(arguments).pick();
  553. };
  554. //</1.2compat>
  555. /*
  556. ---
  557. name: String
  558. description: Contains String Prototypes like camelCase, capitalize, test, and toInt.
  559. license: MIT-style license.
  560. requires: Type
  561. provides: String
  562. ...
  563. */
  564. String.implement({
  565. test: function (regex, params) {
  566. return ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this);
  567. },
  568. contains: function (string, separator) {
  569. return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
  570. },
  571. trim: function () {
  572. return String(this).replace(/^\s+|\s+$/g, '');
  573. },
  574. clean: function () {
  575. return String(this).replace(/\s+/g, ' ').trim();
  576. },
  577. camelCase: function () {
  578. return String(this).replace(/-\D/g, function (match) {
  579. return match.charAt(1).toUpperCase();
  580. });
  581. },
  582. hyphenate: function () {
  583. return String(this).replace(/[A-Z]/g, function (match) {
  584. return ('-' + match.charAt(0).toLowerCase());
  585. });
  586. },
  587. capitalize: function () {
  588. return String(this).replace(/\b[a-z]/g, function (match) {
  589. return match.toUpperCase();
  590. });
  591. },
  592. escapeRegExp: function () {
  593. return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
  594. },
  595. toInt: function (base) {
  596. return parseInt(this, base || 10);
  597. },
  598. toFloat: function () {
  599. return parseFloat(this);
  600. },
  601. hexToRgb: function (array) {
  602. var hex = String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
  603. return (hex) ? hex.slice(1).hexToRgb(array) : null;
  604. },
  605. rgbToHex: function (array) {
  606. var rgb = String(this).match(/\d{1,3}/g);
  607. return (rgb) ? rgb.rgbToHex(array) : null;
  608. },
  609. substitute: function (object, regexp) {
  610. return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function (match, name) {
  611. if (match.charAt(0) == '\\') return match.slice(1);
  612. return (object[name] != null) ? object[name] : '';
  613. });
  614. }
  615. });
  616. /*
  617. ---
  618. name: Number
  619. description: Contains Number Prototypes like limit, round, times, and ceil.
  620. license: MIT-style license.
  621. requires: Type
  622. provides: Number
  623. ...
  624. */
  625. Number.implement({
  626. limit: function (min, max) {
  627. return Math.min(max, Math.max(min, this));
  628. },
  629. round: function (precision) {
  630. precision = Math.pow(10, precision || 0).toFixed(precision < 0 ? -precision : 0);
  631. return Math.round(this * precision) / precision;
  632. },
  633. times: function (fn, bind) {
  634. for (var i = 0; i < this; i++) fn.call(bind, i, this);
  635. },
  636. toFloat: function () {
  637. return parseFloat(this);
  638. },
  639. toInt: function (base) {
  640. return parseInt(this, base || 10);
  641. }
  642. });
  643. Number.alias('each', 'times');
  644. (function (math) {
  645. var methods = {};
  646. math.each(function (name) {
  647. if (!Number[name]) methods[name] = function () {
  648. return Math[name].apply(null, [this].concat(Array.from(arguments)));
  649. };
  650. });
  651. Number.implement(methods);
  652. })(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
  653. /*
  654. ---
  655. name: Function
  656. description: Contains Function Prototypes like create, bind, pass, and delay.
  657. license: MIT-style license.
  658. requires: Type
  659. provides: Function
  660. ...
  661. */
  662. Function.extend({
  663. attempt: function () {
  664. for (var i = 0, l = arguments.length; i < l; i++) {
  665. try {
  666. return arguments[i]();
  667. } catch (e) { }
  668. }
  669. return null;
  670. }
  671. });
  672. Function.implement({
  673. attempt: function (args, bind) {
  674. try {
  675. return this.apply(bind, Array.from(args));
  676. } catch (e) { }
  677. return null;
  678. },
  679. /*<!ES5-bind>*/
  680. bind: function (that) {
  681. var self = this,
  682. args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
  683. F = function () { };
  684. var bound = function () {
  685. var context = that, length = arguments.length;
  686. if (this instanceof bound) {
  687. F.prototype = self.prototype;
  688. context = new F;
  689. }
  690. var result = (!args && !length)
  691. ? self.call(context)
  692. : self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
  693. return context == that ? result : context;
  694. };
  695. return bound;
  696. },
  697. /*</!ES5-bind>*/
  698. pass: function (args, bind) {
  699. var self = this;
  700. if (args != null) args = Array.from(args);
  701. return function () {
  702. return self.apply(bind, args || arguments);
  703. };
  704. },
  705. delay: function (delay, bind, args) {
  706. return setTimeout(this.pass((args == null ? [] : args), bind), delay);
  707. },
  708. periodical: function (periodical, bind, args) {
  709. return setInterval(this.pass((args == null ? [] : args), bind), periodical);
  710. }
  711. });
  712. //<1.2compat>
  713. delete Function.prototype.bind;
  714. Function.implement({
  715. create: function (options) {
  716. var self = this;
  717. options = options || {};
  718. return function (event) {
  719. var args = options.arguments;
  720. args = (args != null) ? Array.from(args) : Array.slice(arguments, (options.event) ? 1 : 0);
  721. if (options.event) args = [event || window.event].extend(args);
  722. var returns = function () {
  723. return self.apply(options.bind || null, args);
  724. };
  725. if (options.delay) return setTimeout(returns, options.delay);
  726. if (options.periodical) return setInterval(returns, options.periodical);
  727. if (options.attempt) return Function.attempt(returns);
  728. return returns();
  729. };
  730. },
  731. bind: function (bind, args) {
  732. var self = this;
  733. if (args != null) args = Array.from(args);
  734. return function () {
  735. return self.apply(bind, args || arguments);
  736. };
  737. },
  738. bindWithEvent: function (bind, args) {
  739. var self = this;
  740. if (args != null) args = Array.from(args);
  741. return function (event) {
  742. return self.apply(bind, (args == null) ? arguments : [event].concat(args));
  743. };
  744. },
  745. run: function (args, bind) {
  746. return this.apply(bind, Array.from(args));
  747. }
  748. });
  749. if (Object.create == Function.prototype.create) Object.create = null;
  750. var $try = Function.attempt;
  751. //</1.2compat>
  752. /*
  753. ---
  754. name: Object
  755. description: Object generic methods
  756. license: MIT-style license.
  757. requires: Type
  758. provides: [Object, Hash]
  759. ...
  760. */
  761. (function () {
  762. var hasOwnProperty = Object.prototype.hasOwnProperty;
  763. Object.extend({
  764. subset: function (object, keys) {
  765. var results = {};
  766. for (var i = 0, l = keys.length; i < l; i++) {
  767. var k = keys[i];
  768. if (k in object) results[k] = object[k];
  769. }
  770. return results;
  771. },
  772. map: function (object, fn, bind) {
  773. var results = {};
  774. for (var key in object) {
  775. if (hasOwnProperty.call(object, key)) results[key] = fn.call(bind, object[key], key, object);
  776. }
  777. return results;
  778. },
  779. filter: function (object, fn, bind) {
  780. var results = {};
  781. for (var key in object) {
  782. var value = object[key];
  783. if (hasOwnProperty.call(object, key) && fn.call(bind, value, key, object)) results[key] = value;
  784. }
  785. return results;
  786. },
  787. every: function (object, fn, bind) {
  788. for (var key in object) {
  789. if (hasOwnProperty.call(object, key) && !fn.call(bind, object[key], key)) return false;
  790. }
  791. return true;
  792. },
  793. some: function (object, fn, bind) {
  794. for (var key in object) {
  795. if (hasOwnProperty.call(object, key) && fn.call(bind, object[key], key)) return true;
  796. }
  797. return false;
  798. },
  799. keys: function (object) {
  800. var keys = [];
  801. for (var key in object) {
  802. if (hasOwnProperty.call(object, key)) keys.push(key);
  803. }
  804. return keys;
  805. },
  806. values: function (object) {
  807. var values = [];
  808. for (var key in object) {
  809. if (hasOwnProperty.call(object, key)) values.push(object[key]);
  810. }
  811. return values;
  812. },
  813. getLength: function (object) {
  814. return Object.keys(object).length;
  815. },
  816. keyOf: function (object, value) {
  817. for (var key in object) {
  818. if (hasOwnProperty.call(object, key) && object[key] === value) return key;
  819. }
  820. return null;
  821. },
  822. contains: function (object, value) {
  823. return Object.keyOf(object, value) != null;
  824. },
  825. toQueryString: function (object, base) {
  826. var queryString = [];
  827. Object.each(object, function (value, key) {
  828. if (base) key = base + '[' + key + ']';
  829. var result;
  830. switch (typeOf(value)) {
  831. case 'object': result = Object.toQueryString(value, key); break;
  832. case 'array':
  833. var qs = {};
  834. value.each(function (val, i) {
  835. qs[i] = val;
  836. });
  837. result = Object.toQueryString(qs, key);
  838. break;
  839. default: result = key + '=' + encodeURIComponent(value);
  840. }
  841. if (value != null) queryString.push(result);
  842. });
  843. return queryString.join('&');
  844. }
  845. });
  846. })();
  847. //<1.2compat>
  848. Hash.implement({
  849. has: Object.prototype.hasOwnProperty,
  850. keyOf: function (value) {
  851. return Object.keyOf(this, value);
  852. },
  853. hasValue: function (value) {
  854. return Object.contains(this, value);
  855. },
  856. extend: function (properties) {
  857. Hash.each(properties || {}, function (value, key) {
  858. Hash.set(this, key, value);
  859. }, this);
  860. return this;
  861. },
  862. combine: function (properties) {
  863. Hash.each(properties || {}, function (value, key) {
  864. Hash.include(this, key, value);
  865. }, this);
  866. return this;
  867. },
  868. erase: function (key) {
  869. if (this.hasOwnProperty(key)) delete this[key];
  870. return this;
  871. },
  872. get: function (key) {
  873. return (this.hasOwnProperty(key)) ? this[key] : null;
  874. },
  875. set: function (key, value) {
  876. if (!this[key] || this.hasOwnProperty(key)) this[key] = value;
  877. return this;
  878. },
  879. empty: function () {
  880. Hash.each(this, function (value, key) {
  881. delete this[key];
  882. }, this);
  883. return this;
  884. },
  885. include: function (key, value) {
  886. if (this[key] == null) this[key] = value;
  887. return this;
  888. },
  889. map: function (fn, bind) {
  890. return new Hash(Object.map(this, fn, bind));
  891. },
  892. filter: function (fn, bind) {
  893. return new Hash(Object.filter(this, fn, bind));
  894. },
  895. every: function (fn, bind) {
  896. return Object.every(this, fn, bind);
  897. },
  898. some: function (fn, bind) {
  899. return Object.some(this, fn, bind);
  900. },
  901. getKeys: function () {
  902. return Object.keys(this);
  903. },
  904. getValues: function () {
  905. return Object.values(this);
  906. },
  907. toQueryString: function (base) {
  908. return Object.toQueryString(this, base);
  909. }
  910. });
  911. Hash.extend = Object.append;
  912. Hash.alias({ indexOf: 'keyOf', contains: 'hasValue' });
  913. //</1.2compat>
  914. /*
  915. ---
  916. name: Browser
  917. description: The Browser Object. Contains Browser initialization, Window and Document, and the Browser Hash.
  918. license: MIT-style license.
  919. requires: [Array, Function, Number, String]
  920. provides: [Browser, Window, Document]
  921. ...
  922. */
  923. (function () {
  924. var document = this.document;
  925. var window = document.window = this;
  926. var ua = navigator.userAgent.toLowerCase(),
  927. platform = navigator.platform.toLowerCase(),
  928. UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0],
  929. mode = UA[1] == 'ie' && document.documentMode;
  930. var Browser = this.Browser = {
  931. extend: Function.prototype.extend,
  932. name: (UA[1] == 'version') ? UA[3] : UA[1],
  933. version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
  934. Platform: {
  935. name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
  936. },
  937. Features: {
  938. xpath: !!(document.evaluate),
  939. air: !!(window.runtime),
  940. query: !!(document.querySelector),
  941. json: !!(window.JSON)
  942. },
  943. Plugins: {}
  944. };
  945. Browser[Browser.name] = true;
  946. Browser[Browser.name + parseInt(Browser.version, 10)] = true;
  947. Browser.Platform[Browser.Platform.name] = true;
  948. // Request
  949. Browser.Request = (function () {
  950. var XMLHTTP = function () {
  951. return new XMLHttpRequest();
  952. };
  953. var MSXML2 = function () {
  954. return new ActiveXObject('MSXML2.XMLHTTP');
  955. };
  956. var MSXML = function () {
  957. return new ActiveXObject('Microsoft.XMLHTTP');
  958. };
  959. return Function.attempt(function () {
  960. XMLHTTP();
  961. return XMLHTTP;
  962. }, function () {
  963. MSXML2();
  964. return MSXML2;
  965. }, function () {
  966. MSXML();
  967. return MSXML;
  968. });
  969. })();
  970. Browser.Features.xhr = !!(Browser.Request);
  971. // Flash detection
  972. var version = (Function.attempt(function () {
  973. return navigator.plugins['Shockwave Flash'].description;
  974. }, function () {
  975. return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
  976. }) || '0 r0').match(/\d+/g);
  977. Browser.Plugins.Flash = {
  978. version: Number(version[0] || '0.' + version[1]) || 0,
  979. build: Number(version[2]) || 0
  980. };
  981. // String scripts
  982. Browser.exec = function (text) {
  983. if (!text) return text;
  984. if (window.execScript) {
  985. window.execScript(text);
  986. } else {
  987. var script = document.createElement('script');
  988. script.setAttribute('type', 'text/javascript');
  989. script.text = text;
  990. document.head.appendChild(script);
  991. document.head.removeChild(script);
  992. }
  993. return text;
  994. };
  995. String.implement('stripScripts', function (exec) {
  996. var scripts = '';
  997. var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function (all, code) {
  998. scripts += code + '\n';
  999. return '';
  1000. });
  1001. if (exec === true) Browser.exec(scripts);
  1002. else if (typeOf(exec) == 'function') exec(scripts, text);
  1003. return text;
  1004. });
  1005. // Window, Document
  1006. Browser.extend({
  1007. Document: this.Document,
  1008. Window: this.Window,
  1009. Element: this.Element,
  1010. Event: this.Event
  1011. });
  1012. this.Window = this.$constructor = new Type('Window', function () { });
  1013. this.$family = Function.from('window').hide();
  1014. Window.mirror(function (name, method) {
  1015. window[name] = method;
  1016. });
  1017. this.Document = document.$constructor = new Type('Document', function () { });
  1018. document.$family = Function.from('document').hide();
  1019. Document.mirror(function (name, method) {
  1020. document[name] = method;
  1021. });
  1022. document.html = document.documentElement;
  1023. if (!document.head) document.head = document.getElementsByTagName('head')[0];
  1024. if (document.execCommand) try {
  1025. document.execCommand("BackgroundImageCache", false, true);
  1026. } catch (e) { }
  1027. /*<ltIE9>*/
  1028. if (this.attachEvent && !this.addEventListener) {
  1029. var unloadEvent = function () {
  1030. this.detachEvent('onunload', unloadEvent);
  1031. document.head = document.html = document.window = null;
  1032. };
  1033. this.attachEvent('onunload', unloadEvent);
  1034. }
  1035. // IE fails on collections and <select>.options (refers to <select>)
  1036. var arrayFrom = Array.from;
  1037. try {
  1038. arrayFrom(document.html.childNodes);
  1039. } catch (e) {
  1040. Array.from = function (item) {
  1041. if (typeof item != 'string' && Type.isEnumerable(item) && typeOf(item) != 'array') {
  1042. var i = item.length, array = new Array(i);
  1043. while (i--) array[i] = item[i];
  1044. return array;
  1045. }
  1046. return arrayFrom(item);
  1047. };
  1048. var prototype = Array.prototype,
  1049. slice = prototype.slice;
  1050. ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice'].each(function (name) {
  1051. var method = prototype[name];
  1052. Array[name] = function (item) {
  1053. return method.apply(Array.from(item), slice.call(arguments, 1));
  1054. };
  1055. });
  1056. }
  1057. /*</ltIE9>*/
  1058. //<1.2compat>
  1059. if (Browser.Platform.ios) Browser.Platform.ipod = true;
  1060. Browser.Engine = {};
  1061. var setEngine = function (name, version) {
  1062. Browser.Engine.name = name;
  1063. Browser.Engine[name + version] = true;
  1064. Browser.Engine.version = version;
  1065. };
  1066. if (Browser.ie) {
  1067. Browser.Engine.trident = true;
  1068. switch (Browser.version) {
  1069. case 6: setEngine('trident', 4); break;
  1070. case 7: setEngine('trident', 5); break;
  1071. case 8: setEngine('trident', 6);
  1072. }
  1073. }
  1074. if (Browser.firefox) {
  1075. Browser.Engine.gecko = true;
  1076. if (Browser.version >= 3) setEngine('gecko', 19);
  1077. else setEngine('gecko', 18);
  1078. }
  1079. if (Browser.safari || Browser.chrome) {
  1080. Browser.Engine.webkit = true;
  1081. switch (Browser.version) {
  1082. case 2: setEngine('webkit', 419); break;
  1083. case 3: setEngine('webkit', 420); break;
  1084. case 4: setEngine('webkit', 525);
  1085. }
  1086. }
  1087. if (Browser.opera) {
  1088. Browser.Engine.presto = true;
  1089. if (Browser.version >= 9.6) setEngine('presto', 960);
  1090. else if (Browser.version >= 9.5) setEngine('presto', 950);
  1091. else setEngine('presto', 925);
  1092. }
  1093. if (Browser.name == 'unknown') {
  1094. switch ((ua.match(/(?:webkit|khtml|gecko)/) || [])[0]) {
  1095. case 'webkit':
  1096. case 'khtml':
  1097. Browser.Engine.webkit = true;
  1098. break;
  1099. case 'gecko':
  1100. Browser.Engine.gecko = true;
  1101. }
  1102. }
  1103. this.$exec = Browser.exec;
  1104. //</1.2compat>
  1105. })();
  1106. /*
  1107. ---
  1108. name: Event
  1109. description: Contains the Event Type, to make the event object cross-browser.
  1110. license: MIT-style license.
  1111. requires: [Window, Document, Array, Function, String, Object]
  1112. provides: Event
  1113. ...
  1114. */
  1115. (function () {
  1116. var _keys = {};
  1117. var DOMEvent = this.DOMEvent = new Type('DOMEvent', function (event, win) {
  1118. if (!win) win = window;
  1119. event = event || win.event;
  1120. if (event.$extended) return event;
  1121. this.event = event;
  1122. this.$extended = true;
  1123. this.shift = event.shiftKey;
  1124. this.control = event.ctrlKey;
  1125. this.alt = event.altKey;
  1126. this.meta = event.metaKey;
  1127. var type = this.type = event.type;
  1128. var target = event.target || event.srcElement;
  1129. while (target && target.nodeType == 3) target = target.parentNode;
  1130. this.target = document.id(target);
  1131. if (type.indexOf('key') == 0) {
  1132. var code = this.code = (event.which || event.keyCode);
  1133. this.key = _keys[code]/*<1.3compat>*/ || Object.keyOf(Event.Keys, code)/*</1.3compat>*/;
  1134. if (type == 'keydown') {
  1135. if (code > 111 && code < 124) this.key = 'f' + (code - 111);
  1136. else if (code > 95 && code < 106) this.key = code - 96;
  1137. }
  1138. if (this.key == null) this.key = String.fromCharCode(code).toLowerCase();
  1139. } else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'DOMMouseScroll' || type.indexOf('mouse') == 0) {
  1140. var doc = win.document;
  1141. doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
  1142. this.page = {
  1143. x: (event.pageX != null) ? event.pageX : event.clientX + doc.scrollLeft,
  1144. y: (event.pageY != null) ? event.pageY : event.clientY + doc.scrollTop
  1145. };
  1146. this.client = {
  1147. x: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX,
  1148. y: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY
  1149. };
  1150. if (type == 'DOMMouseScroll' || type == 'mousewheel')
  1151. this.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
  1152. this.rightClick = (event.which == 3 || event.button == 2);
  1153. if (type == 'mouseover' || type == 'mouseout') {
  1154. var related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];
  1155. while (related && related.nodeType == 3) related = related.parentNode;
  1156. this.relatedTarget = document.id(related);
  1157. }
  1158. } else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0) {
  1159. this.rotation = event.rotation;
  1160. this.scale = event.scale;
  1161. this.targetTouches = event.targetTouches;
  1162. this.changedTouches = event.changedTouches;
  1163. var touches = this.touches = event.touches;
  1164. if (touches && touches[0]) {
  1165. var touch = touches[0];
  1166. this.page = { x: touch.pageX, y: touch.pageY };
  1167. this.client = { x: touch.clientX, y: touch.clientY };
  1168. }
  1169. }
  1170. if (!this.client) this.client = {};
  1171. if (!this.page) this.page = {};
  1172. });
  1173. DOMEvent.implement({
  1174. stop: function () {
  1175. return this.preventDefault().stopPropagation();
  1176. },
  1177. stopPropagation: function () {
  1178. if (this.event.stopPropagation) this.event.stopPropagation();
  1179. else this.event.cancelBubble = true;
  1180. return this;
  1181. },
  1182. preventDefault: function () {
  1183. if (this.event.preventDefault) this.event.preventDefault();
  1184. else this.event.returnValue = false;
  1185. return this;
  1186. }
  1187. });
  1188. DOMEvent.defineKey = function (code, key) {
  1189. _keys[code] = key;
  1190. return this;
  1191. };
  1192. DOMEvent.defineKeys = DOMEvent.defineKey.overloadSetter(true);
  1193. DOMEvent.defineKeys({
  1194. '38': 'up', '40': 'down', '37': 'left', '39': 'right',
  1195. '27': 'esc', '32': 'space', '8': 'backspace', '9': 'tab',
  1196. '46': 'delete', '13': 'enter'
  1197. });
  1198. })();
  1199. /*<1.3compat>*/
  1200. var Event = DOMEvent;
  1201. Event.Keys = {};
  1202. /*</1.3compat>*/
  1203. /*<1.2compat>*/
  1204. Event.Keys = new Hash(Event.Keys);
  1205. /*</1.2compat>*/
  1206. /*
  1207. ---
  1208. name: Class
  1209. description: Contains the Class Function for easily creating, extending, and implementing reusable Classes.
  1210. license: MIT-style license.
  1211. requires: [Array, String, Function, Number]
  1212. provides: Class
  1213. ...
  1214. */
  1215. (function () {
  1216. var Class = this.Class = new Type('Class', function (params) {
  1217. if (instanceOf(params, Function)) params = { initialize: params };
  1218. var newClass = function () {
  1219. reset(this);
  1220. if (newClass.$prototyping) return this;
  1221. this.$caller = null;
  1222. var value = (this.initialize) ? this.initialize.apply(this, arguments) : this;
  1223. this.$caller = this.caller = null;
  1224. return value;
  1225. }.extend(this).implement(params);
  1226. newClass.$constructor = Class;
  1227. newClass.prototype.$constructor = newClass;
  1228. newClass.prototype.parent = parent;
  1229. return newClass;
  1230. });
  1231. var parent = function () {
  1232. if (!this.$caller) throw new Error('The method "parent" cannot be called.');
  1233. var name = this.$caller.$name,
  1234. parent = this.$caller.$owner.parent,
  1235. previous = (parent) ? parent.prototype[name] : null;
  1236. if (!previous) throw new Error('The method "' + name + '" has no parent.');
  1237. return previous.apply(this, arguments);
  1238. };
  1239. var reset = function (object) {
  1240. for (var key in object) {
  1241. var value = object[key];
  1242. switch (typeOf(value)) {
  1243. case 'object':
  1244. var F = function () { };
  1245. F.prototype = value;
  1246. object[key] = reset(new F);
  1247. break;
  1248. case 'array': object[key] = value.clone(); break;
  1249. }
  1250. }
  1251. return object;
  1252. };
  1253. var wrap = function (self, key, method) {
  1254. if (method.$origin) method = method.$origin;
  1255. var wrapper = function () {
  1256. if (method.$protected && this.$caller == null) throw new Error('The method "' + key + '" cannot be called.');
  1257. var caller = this.caller, current = this.$caller;
  1258. this.caller = current; this.$caller = wrapper;
  1259. var result = method.apply(this, arguments);
  1260. this.$caller = current; this.caller = caller;
  1261. return result;
  1262. }.extend({ $owner: self, $origin: method, $name: key });
  1263. return wrapper;
  1264. };
  1265. var implement = function (key, value, retain) {
  1266. if (Class.Mutators.hasOwnProperty(key)) {
  1267. value = Class.Mutators[key].call(this, value);
  1268. if (value == null) return this;
  1269. }
  1270. if (typeOf(value) == 'function') {
  1271. if (value.$hidden) return this;
  1272. this.prototype[key] = (retain) ? value : wrap(this, key, value);
  1273. } else {
  1274. Object.merge(this.prototype, key, value);
  1275. }
  1276. return this;
  1277. };
  1278. var getInstance = function (klass) {
  1279. klass.$prototyping = true;
  1280. var proto = new klass;
  1281. delete klass.$prototyping;
  1282. return proto;
  1283. };
  1284. Class.implement('implement', implement.overloadSetter());
  1285. Class.Mutators = {
  1286. Extends: function (parent) {
  1287. this.parent = parent;
  1288. this.prototype = getInstance(parent);
  1289. },
  1290. Implements: function (items) {
  1291. Array.from(items).each(function (item) {
  1292. var instance = new item;
  1293. for (var key in instance) implement.call(this, key, instance[key], true);
  1294. }, this);
  1295. }
  1296. };
  1297. })();
  1298. /*
  1299. ---
  1300. name: Class.Extras
  1301. description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.
  1302. license: MIT-style license.
  1303. requires: Class
  1304. provides: [Class.Extras, Chain, Events, Options]
  1305. ...
  1306. */
  1307. (function () {
  1308. this.Chain = new Class({
  1309. $chain: [],
  1310. chain: function () {
  1311. this.$chain.append(Array.flatten(arguments));
  1312. return this;
  1313. },
  1314. callChain: function () {
  1315. return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;
  1316. },
  1317. clearChain: function () {
  1318. this.$chain.empty();
  1319. return this;
  1320. }
  1321. });
  1322. var removeOn = function (string) {
  1323. return string.replace(/^on([A-Z])/, function (full, first) {
  1324. return first.toLowerCase();
  1325. });
  1326. };
  1327. this.Events = new Class({
  1328. $events: {},
  1329. addEvent: function (type, fn, internal) {
  1330. type = removeOn(type);
  1331. /*<1.2compat>*/
  1332. if (fn == $empty) return this;
  1333. /*</1.2compat>*/
  1334. this.$events[type] = (this.$events[type] || []).include(fn);
  1335. if (internal) fn.internal = true;
  1336. return this;
  1337. },
  1338. addEvents: function (events) {
  1339. for (var type in events) this.addEvent(type, events[type]);
  1340. return this;
  1341. },
  1342. fireEvent: function (type, args, delay) {
  1343. type = removeOn(type);
  1344. var events = this.$events[type];
  1345. if (!events) return this;
  1346. args = Array.from(args);
  1347. events.each(function (fn) {
  1348. if (delay) fn.delay(delay, this, args);
  1349. else fn.apply(this, args);
  1350. }, this);
  1351. return this;
  1352. },
  1353. removeEvent: function (type, fn) {
  1354. type = removeOn(type);
  1355. var events = this.$events[type];
  1356. if (events && !fn.internal) {
  1357. var index = events.indexOf(fn);
  1358. if (index != -1) delete events[index];
  1359. }
  1360. return this;
  1361. },
  1362. removeEvents: function (events) {
  1363. var type;
  1364. if (typeOf(events) == 'object') {
  1365. for (type in events) this.removeEvent(type, events[type]);
  1366. return this;
  1367. }
  1368. if (events) events = removeOn(events);
  1369. for (type in this.$events) {
  1370. if (events && events != type) continue;
  1371. var fns = this.$events[type];
  1372. for (var i = fns.length; i--;) if (i in fns) {
  1373. this.removeEvent(type, fns[i]);
  1374. }
  1375. }
  1376. return this;
  1377. }
  1378. });
  1379. this.Options = new Class({
  1380. setOptions: function () {
  1381. var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));
  1382. if (this.addEvent) for (var option in options) {
  1383. if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
  1384. this.addEvent(option, options[option]);
  1385. delete options[option];
  1386. }
  1387. return this;
  1388. }
  1389. });
  1390. })();
  1391. /*
  1392. ---
  1393. name: Slick.Parser
  1394. description: Standalone CSS3 Selector parser
  1395. provides: Slick.Parser
  1396. ...
  1397. */
  1398. ; (function () {
  1399. var parsed,
  1400. separatorIndex,
  1401. combinatorIndex,
  1402. reversed,
  1403. cache = {},
  1404. reverseCache = {},
  1405. reUnescape = /\\/g;
  1406. var parse = function (expression, isReversed) {
  1407. if (expression == null) return null;
  1408. if (expression.Slick === true) return expression;
  1409. expression = ('' + expression).replace(/^\s+|\s+$/g, '');
  1410. reversed = !!isReversed;
  1411. var currentCache = (reversed) ? reverseCache : cache;
  1412. if (currentCache[expression]) return currentCache[expression];
  1413. parsed = {
  1414. Slick: true,
  1415. expressions: [],
  1416. raw: expression,
  1417. reverse: function () {
  1418. return parse(this.raw, true);
  1419. }
  1420. };
  1421. separatorIndex = -1;
  1422. while (expression != (expression = expression.replace(regexp, parser)));
  1423. parsed.length = parsed.expressions.length;
  1424. return currentCache[parsed.raw] = (reversed) ? reverse(parsed) : parsed;
  1425. };
  1426. var reverseCombinator = function (combinator) {
  1427. if (combinator === '!') return ' ';
  1428. else if (combinator === ' ') return '!';
  1429. else if ((/^!/).test(combinator)) return combinator.replace(/^!/, '');
  1430. else return '!' + combinator;
  1431. };
  1432. var reverse = function (expression) {
  1433. var expressions = expression.expressions;
  1434. for (var i = 0; i < expressions.length; i++) {
  1435. var exp = expressions[i];
  1436. var last = { parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator) };
  1437. for (var j = 0; j < exp.length; j++) {
  1438. var cexp = exp[j];
  1439. if (!cexp.reverseCombinator) cexp.reverseCombinator = ' ';
  1440. cexp.combinator = cexp.reverseCombinator;
  1441. delete cexp.reverseCombinator;
  1442. }
  1443. exp.reverse().push(last);
  1444. }
  1445. return expression;
  1446. };
  1447. var escapeRegExp = function (string) {// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License
  1448. return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, function (match) {
  1449. return '\\' + match;
  1450. });
  1451. };
  1452. var regexp = new RegExp(
  1453. /*
  1454. #!/usr/bin/env ruby
  1455. puts "\t\t" + DATA.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'')
  1456. __END__
  1457. "(?x)^(?:\
  1458. \\s* ( , ) \\s* # Separator \n\
  1459. | \\s* ( <combinator>+ ) \\s* # Combinator \n\
  1460. | ( \\s+ ) # CombinatorChildren \n\
  1461. | ( <unicode>+ | \\* ) # Tag \n\
  1462. | \\# ( <unicode>+ ) # ID \n\
  1463. | \\. ( <unicode>+ ) # ClassName \n\
  1464. | # Attribute \n\
  1465. \\[ \
  1466. \\s* (<unicode1>+) (?: \
  1467. \\s* ([*^$!~|]?=) (?: \
  1468. \\s* (?:\
  1469. ([\"']?)(.*?)\\9 \
  1470. )\
  1471. ) \
  1472. )? \\s* \
  1473. \\](?!\\]) \n\
  1474. | :+ ( <unicode>+ )(?:\
  1475. \\( (?:\
  1476. (?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\
  1477. ) \\)\
  1478. )?\
  1479. )"
  1480. */
  1481. "^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)"
  1482. .replace(/<combinator>/, '[' + escapeRegExp(">+~`!@$%^&={}\\;</") + ']')
  1483. .replace(/<unicode>/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
  1484. .replace(/<unicode1>/g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
  1485. );
  1486. function parser(
  1487. rawMatch,
  1488. separator,
  1489. combinator,
  1490. combinatorChildren,
  1491. tagName,
  1492. id,
  1493. className,
  1494. attributeKey,
  1495. attributeOperator,
  1496. attributeQuote,
  1497. attributeValue,
  1498. pseudoMarker,
  1499. pseudoClass,
  1500. pseudoQuote,
  1501. pseudoClassQuotedValue,
  1502. pseudoClassValue
  1503. ) {
  1504. if (separator || separatorIndex === -1) {
  1505. parsed.expressions[++separatorIndex] = [];
  1506. combinatorIndex = -1;
  1507. if (separator) return '';
  1508. }
  1509. if (combinator || combinatorChildren || combinatorIndex === -1) {
  1510. combinator = combinator || ' ';
  1511. var currentSeparator = parsed.expressions[separatorIndex];
  1512. if (reversed && currentSeparator[combinatorIndex])
  1513. currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator);
  1514. currentSeparator[++combinatorIndex] = { combinator: combinator, tag: '*' };
  1515. }
  1516. var currentParsed = parsed.expressions[separatorIndex][combinatorIndex];
  1517. if (tagName) {
  1518. currentParsed.tag = tagName.replace(reUnescape, '');
  1519. } else if (id) {
  1520. currentParsed.id = id.replace(reUnescape, '');
  1521. } else if (className) {
  1522. className = className.replace(reUnescape, '');
  1523. if (!currentParsed.classList) currentParsed.classList = [];
  1524. if (!currentParsed.classes) currentParsed.classes = [];
  1525. currentParsed.classList.push(className);
  1526. currentParsed.classes.push({
  1527. value: className,
  1528. regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)')
  1529. });
  1530. } else if (pseudoClass) {
  1531. pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue;
  1532. pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null;
  1533. if (!currentParsed.pseudos) currentParsed.pseudos = [];
  1534. currentParsed.pseudos.push({
  1535. key: pseudoClass.replace(reUnescape, ''),
  1536. value: pseudoClassValue,
  1537. type: pseudoMarker.length == 1 ? 'class' : 'element'
  1538. });
  1539. } else if (attributeKey) {
  1540. attributeKey = attributeKey.replace(reUnescape, '');
  1541. attributeValue = (attributeValue || '').replace(reUnescape, '');
  1542. var test, regexp;
  1543. switch (attributeOperator) {
  1544. case '^=': regexp = new RegExp('^' + escapeRegExp(attributeValue)); break;
  1545. case '$=': regexp = new RegExp(escapeRegExp(attributeValue) + '$'); break;
  1546. case '~=': regexp = new RegExp('(^|\\s)' + escapeRegExp(attributeValue) + '(\\s|$)'); break;
  1547. case '|=': regexp = new RegExp('^' + escapeRegExp(attributeValue) + '(-|$)'); break;
  1548. case '=': test = function (value) {
  1549. return attributeValue == value;
  1550. }; break;
  1551. case '*=': test = function (value) {
  1552. return value && value.indexOf(attributeValue) > -1;
  1553. }; break;
  1554. case '!=': test = function (value) {
  1555. return attributeValue != value;
  1556. }; break;
  1557. default: test = function (value) {
  1558. return !!value;
  1559. };
  1560. }
  1561. if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function () {
  1562. return false;
  1563. };
  1564. if (!test) test = function (value) {
  1565. return value && regexp.test(value);
  1566. };
  1567. if (!currentParsed.attributes) currentParsed.attributes = [];
  1568. currentParsed.attributes.push({
  1569. key: attributeKey,
  1570. operator: attributeOperator,
  1571. value: attributeValue,
  1572. test: test
  1573. });
  1574. }
  1575. return '';
  1576. };
  1577. // Slick NS
  1578. var Slick = (this.Slick || {});
  1579. Slick.parse = function (expression) {
  1580. return parse(expression);
  1581. };
  1582. Slick.escapeRegExp = escapeRegExp;
  1583. if (!this.Slick) this.Slick = Slick;
  1584. }).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);
  1585. /*
  1586. ---
  1587. name: Slick.Finder
  1588. description: The new, superfast css selector engine.
  1589. provides: Slick.Finder
  1590. requires: Slick.Parser
  1591. ...
  1592. */
  1593. ; (function () {
  1594. var local = {},
  1595. featuresCache = {},
  1596. toString = Object.prototype.toString;
  1597. // Feature / Bug detection
  1598. local.isNativeCode = function (fn) {
  1599. return (/\{\s*\[native code\]\s*\}/).test('' + fn);
  1600. };
  1601. local.isXML = function (document) {
  1602. return (!!document.xmlVersion) || (!!document.xml) || (toString.call(document) == '[object XMLDocument]') ||
  1603. (document.nodeType == 9 && document.documentElement.nodeName != 'HTML');
  1604. };
  1605. local.setDocument = function (document) {
  1606. // convert elements / window arguments to document. if document cannot be extrapolated, the function returns.
  1607. var nodeType = document.nodeType;
  1608. if (nodeType == 9); // document
  1609. else if (nodeType) document = document.ownerDocument; // node
  1610. else if (document.navigator) document = document.document; // window
  1611. else return;
  1612. // check if it's the old document
  1613. if (this.document === document) return;
  1614. this.document = document;
  1615. // check if we have done feature detection on this document before
  1616. var root = document.documentElement,
  1617. rootUid = this.getUIDXML(root),
  1618. features = featuresCache[rootUid],
  1619. feature;
  1620. if (features) {
  1621. for (feature in features) {
  1622. this[feature] = features[feature];
  1623. }
  1624. return;
  1625. }
  1626. features = featuresCache[rootUid] = {};
  1627. features.root = root;
  1628. features.isXMLDocument = this.isXML(document);
  1629. features.brokenStarGEBTN
  1630. = features.starSelectsClosedQSA
  1631. = features.idGetsName
  1632. = features.brokenMixedCaseQSA
  1633. = features.brokenGEBCN
  1634. = features.brokenCheckedQSA
  1635. = features.brokenEmptyAttributeQSA
  1636. = features.isHTMLDocument
  1637. = features.nativeMatchesSelector
  1638. = false;
  1639. var starSelectsClosed, starSelectsComments,
  1640. brokenSecondClassNameGEBCN, cachedGetElementsByClassName,
  1641. brokenFormAttributeGetter;
  1642. var selected, id = 'slick_uniqueid';
  1643. var testNode = document.createElement('div');
  1644. var testRoot = document.body || document.getElementsByTagName('body')[0] || root;
  1645. testRoot.appendChild(testNode);
  1646. // on non-HTML documents innerHTML and getElementsById doesnt work properly
  1647. try {
  1648. testNode.innerHTML = '<a id="' + id + '"></a>';
  1649. features.isHTMLDocument = !!document.getElementById(id);
  1650. } catch (e) { };
  1651. if (features.isHTMLDocument) {
  1652. testNode.style.display = 'none';
  1653. // IE returns comment nodes for getElementsByTagName('*') for some documents
  1654. testNode.appendChild(document.createComment(''));
  1655. starSelectsComments = (testNode.getElementsByTagName('*').length > 1);
  1656. // IE returns closed nodes (EG:"</foo>") for getElementsByTagName('*') for some documents
  1657. try {
  1658. testNode.innerHTML = 'foo</foo>';
  1659. selected = testNode.getElementsByTagName('*');
  1660. starSelectsClosed = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');
  1661. } catch (e) { };
  1662. features.brokenStarGEBTN = starSelectsComments || starSelectsClosed;
  1663. // IE returns elements with the name instead of just id for getElementsById for some documents
  1664. try {
  1665. testNode.innerHTML = '<a name="' + id + '"></a><b id="' + id + '"></b>';
  1666. features.idGetsName = document.getElementById(id) === testNode.firstChild;
  1667. } catch (e) { };
  1668. if (testNode.getElementsByClassName) {
  1669. // Safari 3.2 getElementsByClassName caches results
  1670. try {
  1671. testNode.innerHTML = '<a class="f"></a><a class="b"></a>';
  1672. testNode.getElementsByClassName('b').length;
  1673. testNode.firstChild.className = 'b';
  1674. cachedGetElementsByClassName = (testNode.getElementsByClassName('b').length != 2);
  1675. } catch (e) { };
  1676. // Opera 9.6 getElementsByClassName doesnt detects the class if its not the first one
  1677. try {
  1678. testNode.innerHTML = '<a class="a"></a><a class="f b a"></a>';
  1679. brokenSecondClassNameGEBCN = (testNode.getElementsByClassName('a').length != 2);
  1680. } catch (e) { };
  1681. features.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;
  1682. }
  1683. if (testNode.querySelectorAll) {
  1684. // IE 8 returns closed nodes (EG:"</foo>") for querySelectorAll('*') for some documents
  1685. try {
  1686. testNode.innerHTML = 'foo</foo>';
  1687. selected = testNode.querySelectorAll('*');
  1688. features.starSelectsClosedQSA = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');
  1689. } catch (e) { };
  1690. // Safari 3.2 querySelectorAll doesnt work with mixedcase on quirksmode
  1691. try {
  1692. testNode.innerHTML = '<a class="MiX"></a>';
  1693. features.brokenMixedCaseQSA = !testNode.querySelectorAll('.MiX').length;
  1694. } catch (e) { };
  1695. // Webkit and Opera dont return selected options on querySelectorAll
  1696. try {
  1697. testNode.innerHTML = '<select><option selected="selected">a</option></select>';
  1698. features.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0);
  1699. } catch (e) { };
  1700. // IE returns incorrect results for attr[*^$]="" selectors on querySelectorAll
  1701. try {
  1702. testNode.innerHTML = '<a class=""></a>';
  1703. features.brokenEmptyAttributeQSA = (testNode.querySelectorAll('[class*=""]').length != 0);
  1704. } catch (e) { };
  1705. }
  1706. // IE6-7, if a form has an input of id x, form.getAttribute(x) returns a reference to the input
  1707. try {
  1708. testNode.innerHTML = '<form action="s"><input id="action"/></form>';
  1709. brokenFormAttributeGetter = (testNode.firstChild.getAttribute('action') != 's');
  1710. } catch (e) { };
  1711. // native matchesSelector function
  1712. features.nativeMatchesSelector = root.matchesSelector || /*root.msMatchesSelector ||*/ root.mozMatchesSelector || root.webkitMatchesSelector;
  1713. if (features.nativeMatchesSelector) try {
  1714. // if matchesSelector trows errors on incorrect sintaxes we can use it
  1715. features.nativeMatchesSelector.call(root, ':slick');
  1716. features.nativeMatchesSelector = null;
  1717. } catch (e) { };
  1718. }
  1719. try {
  1720. root.slick_expando = 1;
  1721. delete root.slick_expando;
  1722. features.getUID = this.getUIDHTML;
  1723. } catch (e) {
  1724. features.getUID = this.getUIDXML;
  1725. }
  1726. testRoot.removeChild(testNode);
  1727. testNode = selected = testRoot = null;
  1728. // getAttribute
  1729. features.getAttribute = (features.isHTMLDocument && brokenFormAttributeGetter) ? function (node, name) {
  1730. var method = this.attributeGetters[name];
  1731. if (method) return method.call(node);
  1732. var attributeNode = node.getAttributeNode(name);
  1733. return (attributeNode) ? attributeNode.nodeValue : null;
  1734. } : function (node, name) {
  1735. var method = this.attributeGetters[name];
  1736. return (method) ? method.call(node) : node.getAttribute(name);
  1737. };
  1738. // hasAttribute
  1739. features.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function (node, attribute) {
  1740. return node.hasAttribute(attribute);
  1741. } : function (node, attribute) {
  1742. node = node.getAttributeNode(attribute);
  1743. return !!(node && (node.specified || node.nodeValue));
  1744. };
  1745. // contains
  1746. // FIXME: Add specs: local.contains should be different for xml and html documents?
  1747. var nativeRootContains = root && this.isNativeCode(root.contains),
  1748. nativeDocumentContains = document && this.isNativeCode(document.contains);
  1749. features.contains = (nativeRootContains && nativeDocumentContains) ? function (context, node) {
  1750. return context.contains(node);
  1751. } : (nativeRootContains && !nativeDocumentContains) ? function (context, node) {
  1752. // IE8 does not have .contains on document.
  1753. return context === node || ((context === document) ? document.documentElement : context).contains(node);
  1754. } : (root && root.compareDocumentPosition) ? function (context, node) {
  1755. return context === node || !!(context.compareDocumentPosition(node) & 16);
  1756. } : function (context, node) {
  1757. if (node) do {
  1758. if (node === context) return true;
  1759. } while ((node = node.parentNode));
  1760. return false;
  1761. };
  1762. // document order sorting
  1763. // credits to Sizzle (http://sizzlejs.com/)
  1764. features.documentSorter = (root.compareDocumentPosition) ? function (a, b) {
  1765. if (!a.compareDocumentPosition || !b.compareDocumentPosition) return 0;
  1766. return a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
  1767. } : ('sourceIndex' in root) ? function (a, b) {
  1768. if (!a.sourceIndex || !b.sourceIndex) return 0;
  1769. return a.sourceIndex - b.sourceIndex;
  1770. } : (document.createRange) ? function (a, b) {
  1771. if (!a.ownerDocument || !b.ownerDocument) return 0;
  1772. var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
  1773. aRange.setStart(a, 0);
  1774. aRange.setEnd(a, 0);
  1775. bRange.setStart(b, 0);
  1776. bRange.setEnd(b, 0);
  1777. return aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
  1778. } : null;
  1779. root = null;
  1780. for (feature in features) {
  1781. this[feature] = features[feature];
  1782. }
  1783. };
  1784. // Main Method
  1785. var reSimpleSelector = /^([#.]?)((?:[\w-]+|\*))$/,
  1786. reEmptyAttribute = /\[.+[*$^]=(?:""|'')?\]/,
  1787. qsaFailExpCache = {};
  1788. local.search = function (context, expression, append, first) {
  1789. var found = this.found = (first) ? null : (append || []);
  1790. if (!context) return found;
  1791. else if (context.navigator) context = context.document; // Convert the node from a window to a document
  1792. else if (!context.nodeType) return found;
  1793. // setup
  1794. var parsed, i,
  1795. uniques = this.uniques = {},
  1796. hasOthers = !!(append && append.length),
  1797. contextIsDocument = (context.nodeType == 9);
  1798. if (this.document !== (contextIsDocument ? context : context.ownerDocument)) this.setDocument(context);
  1799. // avoid duplicating items already in the append array
  1800. if (hasOthers) for (i = found.length; i--;) uniques[this.getUID(found[i])] = true;
  1801. // expression checks
  1802. if (typeof expression == 'string') { // expression is a string
  1803. /*<simple-selectors-override>*/
  1804. var simpleSelector = expression.match(reSimpleSelector);
  1805. simpleSelectors: if (simpleSelector) {
  1806. var symbol = simpleSelector[1],
  1807. name = simpleSelector[2],
  1808. node, nodes;
  1809. if (!symbol) {
  1810. if (name == '*' && this.brokenStarGEBTN) break simpleSelectors;
  1811. nodes = context.getElementsByTagName(name);
  1812. if (first) return nodes[0] || null;
  1813. for (i = 0; node = nodes[i++];) {
  1814. if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
  1815. }
  1816. } else if (symbol == '#') {
  1817. if (!this.isHTMLDocument || !contextIsDocument) break simpleSelectors;
  1818. node = context.getElementById(name);
  1819. if (!node) return found;
  1820. if (this.idGetsName && node.getAttributeNode('id').nodeValue != name) break simpleSelectors;
  1821. if (first) return node || null;
  1822. if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
  1823. } else if (symbol == '.') {
  1824. if (!this.isHTMLDocument || ((!context.getElementsByClassName || this.brokenGEBCN) && context.querySelectorAll)) break simpleSelectors;
  1825. if (context.getElementsByClassName && !this.brokenGEBCN) {
  1826. nodes = context.getElementsByClassName(name);
  1827. if (first) return nodes[0] || null;
  1828. for (i = 0; node = nodes[i++];) {
  1829. if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
  1830. }
  1831. } else {
  1832. var matchClass = new RegExp('(^|\\s)' + Slick.escapeRegExp(name) + '(\\s|$)');
  1833. nodes = context.getElementsByTagName('*');
  1834. for (i = 0; node = nodes[i++];) {
  1835. className = node.className;
  1836. if (!(className && matchClass.test(className))) continue;
  1837. if (first) return node;
  1838. if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
  1839. }
  1840. }
  1841. }
  1842. if (hasOthers) this.sort(found);
  1843. return (first) ? null : found;
  1844. }
  1845. /*</simple-selectors-override>*/
  1846. /*<query-selector-override>*/
  1847. querySelector: if (context.querySelectorAll) {
  1848. if (!this.isHTMLDocument
  1849. || qsaFailExpCache[expression]
  1850. //TODO: only skip when expression is actually mixed case
  1851. || this.brokenMixedCaseQSA
  1852. || (this.brokenCheckedQSA && expression.indexOf(':checked') > -1)
  1853. || (this.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression))
  1854. || (!contextIsDocument //Abort when !contextIsDocument and...
  1855. // there are multiple expressions in the selector
  1856. // since we currently only fix non-document rooted QSA for single expression selectors
  1857. && expression.indexOf(',') > -1
  1858. )
  1859. || Slick.disableQSA
  1860. ) break querySelector;
  1861. var _expression = expression, _context = context;
  1862. if (!contextIsDocument) {
  1863. // non-document rooted QSA
  1864. // credits to Andrew Dupont
  1865. var currentId = _context.getAttribute('id'), slickid = 'slickid__';
  1866. _context.setAttribute('id', slickid);
  1867. _expression = '#' + slickid + ' ' + _expression;
  1868. context = _context.parentNode;
  1869. }
  1870. try {
  1871. if (first) return context.querySelector(_expression) || null;
  1872. else nodes = context.querySelectorAll(_expression);
  1873. } catch (e) {
  1874. qsaFailExpCache[expression] = 1;
  1875. break querySelector;
  1876. } finally {
  1877. if (!contextIsDocument) {
  1878. if (currentId) _context.setAttribute('id', currentId);
  1879. else _context.removeAttribute('id');
  1880. context = _context;
  1881. }
  1882. }
  1883. if (this.starSelectsClosedQSA) for (i = 0; node = nodes[i++];) {
  1884. if (node.nodeName > '@' && !(hasOthers && uniques[this.getUID(node)])) found.push(node);
  1885. } else for (i = 0; node = nodes[i++];) {
  1886. if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
  1887. }
  1888. if (hasOthers) this.sort(found);
  1889. return found;
  1890. }
  1891. /*</query-selector-override>*/
  1892. parsed = this.Slick.parse(expression);
  1893. if (!parsed.length) return found;
  1894. } else if (expression == null) { // there is no expression
  1895. return found;
  1896. } else if (expression.Slick) { // expression is a parsed Slick object
  1897. parsed = expression;
  1898. } else if (this.contains(context.documentElement || context, expression)) { // expression is a node
  1899. (found) ? found.push(expression) : found = expression;
  1900. return found;
  1901. } else { // other junk
  1902. return found;
  1903. }
  1904. /*<pseudo-selectors>*//*<nth-pseudo-selectors>*/
  1905. // cache elements for the nth selectors
  1906. this.posNTH = {};
  1907. this.posNTHLast = {};
  1908. this.posNTHType = {};
  1909. this.posNTHTypeLast = {};
  1910. /*</nth-pseudo-selectors>*//*</pseudo-selectors>*/
  1911. // if append is null and there is only a single selector with one expression use pushArray, else use pushUID
  1912. this.push = (!hasOthers && (first || (parsed.length == 1 && parsed.expressions[0].length == 1))) ? this.pushArray : this.pushUID;
  1913. if (found == null) found = [];
  1914. // default engine
  1915. var j, m, n;
  1916. var combinator, tag, id, classList, classes, attributes, pseudos;
  1917. var currentItems, currentExpression, currentBit, lastBit, expressions = parsed.expressions;
  1918. search: for (i = 0; (currentExpression = expressions[i]) ; i++) for (j = 0; (currentBit = currentExpression[j]) ; j++) {
  1919. combinator = 'combinator:' + currentBit.combinator;
  1920. if (!this[combinator]) continue search;
  1921. tag = (this.isXMLDocument) ? currentBit.tag : currentBit.tag.toUpperCase();
  1922. id = currentBit.id;
  1923. classList = currentBit.classList;
  1924. classes = currentBit.classes;
  1925. attributes = currentBit.attributes;
  1926. pseudos = currentBit.pseudos;
  1927. lastBit = (j === (currentExpression.length - 1));
  1928. this.bitUniques = {};
  1929. if (lastBit) {
  1930. this.uniques = uniques;
  1931. this.found = found;
  1932. } else {
  1933. this.uniques = {};
  1934. this.found = [];
  1935. }
  1936. if (j === 0) {
  1937. this[combinator](context, tag, id, classes, attributes, pseudos, classList);
  1938. if (first && lastBit && found.length) break search;
  1939. } else {
  1940. if (first && lastBit) for (m = 0, n = currentItems.length; m < n; m++) {
  1941. this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList);
  1942. if (found.length) break search;
  1943. } else for (m = 0, n = currentItems.length; m < n; m++) this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList);
  1944. }
  1945. currentItems = this.found;
  1946. }
  1947. // should sort if there are nodes in append and if you pass multiple expressions.
  1948. if (hasOthers || (parsed.expressions.length > 1)) this.sort(found);
  1949. return (first) ? (found[0] || null) : found;
  1950. };
  1951. // Utils
  1952. local.uidx = 1;
  1953. local.uidk = 'slick-uniqueid';
  1954. local.getUIDXML = function (node) {
  1955. var uid = node.getAttribute(this.uidk);
  1956. if (!uid) {
  1957. uid = this.uidx++;
  1958. node.setAttribute(this.uidk, uid);
  1959. }
  1960. return uid;
  1961. };
  1962. local.getUIDHTML = function (node) {
  1963. return node.uniqueNumber || (node.uniqueNumber = this.uidx++);
  1964. };
  1965. // sort based on the setDocument documentSorter method.
  1966. local.sort = function (results) {
  1967. if (!this.documentSorter) return results;
  1968. results.sort(this.documentSorter);
  1969. return results;
  1970. };
  1971. /*<pseudo-selectors>*//*<nth-pseudo-selectors>*/
  1972. local.cacheNTH = {};
  1973. local.matchNTH = /^([+-]?\d*)?([a-z]+)?([+-]\d+)?$/;
  1974. local.parseNTHArgument = function (argument) {
  1975. var parsed = argument.match(this.matchNTH);
  1976. if (!parsed) return false;
  1977. var special = parsed[2] || false;
  1978. var a = parsed[1] || 1;
  1979. if (a == '-') a = -1;
  1980. var b = +parsed[3] || 0;
  1981. parsed =
  1982. (special == 'n') ? { a: a, b: b } :
  1983. (special == 'odd') ? { a: 2, b: 1 } :
  1984. (special == 'even') ? { a: 2, b: 0 } : { a: 0, b: a };
  1985. return (this.cacheNTH[argument] = parsed);
  1986. };
  1987. local.createNTHPseudo = function (child, sibling, positions, ofType) {
  1988. return function (node, argument) {
  1989. var uid = this.getUID(node);
  1990. if (!this[positions][uid]) {
  1991. var parent = node.parentNode;
  1992. if (!parent) return false;
  1993. var el = parent[child], count = 1;
  1994. if (ofType) {
  1995. var nodeName = node.nodeName;
  1996. do {
  1997. if (el.nodeName != nodeName) continue;
  1998. this[positions][this.getUID(el)] = count++;
  1999. } while ((el = el[sibling]));
  2000. } else {
  2001. do {
  2002. if (el.nodeType != 1) continue;
  2003. this[positions][this.getUID(el)] = count++;
  2004. } while ((el = el[sibling]));
  2005. }
  2006. }
  2007. argument = argument || 'n';
  2008. var parsed = this.cacheNTH[argument] || this.parseNTHArgument(argument);
  2009. if (!parsed) return false;
  2010. var a = parsed.a, b = parsed.b, pos = this[positions][uid];
  2011. if (a == 0) return b == pos;
  2012. if (a > 0) {
  2013. if (pos < b) return false;
  2014. } else {
  2015. if (b < pos) return false;
  2016. }
  2017. return ((pos - b) % a) == 0;
  2018. };
  2019. };
  2020. /*</nth-pseudo-selectors>*//*</pseudo-selectors>*/
  2021. local.pushArray = function (node, tag, id, classes, attributes, pseudos) {
  2022. if (this.matchSelector(node, tag, id, classes, attributes, pseudos)) this.found.push(node);
  2023. };
  2024. local.pushUID = function (node, tag, id, classes, attributes, pseudos) {
  2025. var uid = this.getUID(node);
  2026. if (!this.uniques[uid] && this.matchSelector(node, tag, id, classes, attributes, pseudos)) {
  2027. this.uniques[uid] = true;
  2028. this.found.push(node);
  2029. }
  2030. };
  2031. local.matchNode = function (node, selector) {
  2032. if (this.isHTMLDocument && this.nativeMatchesSelector) {
  2033. try {
  2034. return this.nativeMatchesSelector.call(node, selector.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g, '[$1="$2"]'));
  2035. } catch (matchError) { }
  2036. }
  2037. var parsed = this.Slick.parse(selector);
  2038. if (!parsed) return true;
  2039. // simple (single) selectors
  2040. var expressions = parsed.expressions, simpleExpCounter = 0, i;
  2041. for (i = 0; (currentExpression = expressions[i]) ; i++) {
  2042. if (currentExpression.length == 1) {
  2043. var exp = currentExpression[0];
  2044. if (this.matchSelector(node, (this.isXMLDocument) ? exp.tag : exp.tag.toUpperCase(), exp.id, exp.classes, exp.attributes, exp.pseudos)) return true;
  2045. simpleExpCounter++;
  2046. }
  2047. }
  2048. if (simpleExpCounter == parsed.length) return false;
  2049. var nodes = this.search(this.document, parsed), item;
  2050. for (i = 0; item = nodes[i++];) {
  2051. if (item === node) return true;
  2052. }
  2053. return false;
  2054. };
  2055. local.matchPseudo = function (node, name, argument) {
  2056. var pseudoName = 'pseudo:' + name;
  2057. if (this[pseudoName]) return this[pseudoName](node, argument);
  2058. var attribute = this.getAttribute(node, name);
  2059. return (argument) ? argument == attribute : !!attribute;
  2060. };
  2061. local.matchSelector = function (node, tag, id, classes, attributes, pseudos) {
  2062. if (tag) {
  2063. var nodeName = (this.isXMLDocument) ? node.nodeName : node.nodeName.toUpperCase();
  2064. if (tag == '*') {
  2065. if (nodeName < '@') return false; // Fix for comment nodes and closed nodes
  2066. } else {
  2067. if (nodeName != tag) return false;
  2068. }
  2069. }
  2070. if (id && node.getAttribute('id') != id) return false;
  2071. var i, part, cls;
  2072. if (classes) for (i = classes.length; i--;) {
  2073. cls = this.getAttribute(node, 'class');
  2074. if (!(cls && classes[i].regexp.test(cls))) return false;
  2075. }
  2076. if (attributes) for (i = attributes.length; i--;) {
  2077. part = attributes[i];
  2078. if (part.operator ? !part.test(this.getAttribute(node, part.key)) : !this.hasAttribute(node, part.key)) return false;
  2079. }
  2080. if (pseudos) for (i = pseudos.length; i--;) {
  2081. part = pseudos[i];
  2082. if (!this.matchPseudo(node, part.key, part.value)) return false;
  2083. }
  2084. return true;
  2085. };
  2086. var combinators = {
  2087. ' ': function (node, tag, id, classes, attributes, pseudos, classList) { // all child nodes, any level
  2088. var i, item, children;
  2089. if (this.isHTMLDocument) {
  2090. getById: if (id) {
  2091. item = this.document.getElementById(id);
  2092. if ((!item && node.all) || (this.idGetsName && item && item.getAttributeNode('id').nodeValue != id)) {
  2093. // all[id] returns all the elements with that name or id inside node
  2094. // if theres just one it will return the element, else it will be a collection
  2095. children = node.all[id];
  2096. if (!children) return;
  2097. if (!children[0]) children = [children];
  2098. for (i = 0; item = children[i++];) {
  2099. var idNode = item.getAttributeNode('id');
  2100. if (idNode && idNode.nodeValue == id) {
  2101. this.push(item, tag, null, classes, attributes, pseudos);
  2102. break;
  2103. }
  2104. }
  2105. return;
  2106. }
  2107. if (!item) {
  2108. // if the context is in the dom we return, else we will try GEBTN, breaking the getById label
  2109. if (this.contains(this.root, node)) return;
  2110. else break getById;
  2111. } else if (this.document !== node && !this.contains(node, item)) return;
  2112. this.push(item, tag, null, classes, attributes, pseudos);
  2113. return;
  2114. }
  2115. getByClass: if (classes && node.getElementsByClassName && !this.brokenGEBCN) {
  2116. children = node.getElementsByClassName(classList.join(' '));
  2117. if (!(children && children.length)) break getByClass;
  2118. for (i = 0; item = children[i++];) this.push(item, tag, id, null, attributes, pseudos);
  2119. return;
  2120. }
  2121. }
  2122. getByTag: {
  2123. children = node.getElementsByTagName(tag);
  2124. if (!(children && children.length)) break getByTag;
  2125. if (!this.brokenStarGEBTN) tag = null;
  2126. for (i = 0; item = children[i++];) this.push(item, tag, id, classes, attributes, pseudos);
  2127. }
  2128. },
  2129. '>': function (node, tag, id, classes, attributes, pseudos) { // direct children
  2130. if ((node = node.firstChild)) do {
  2131. if (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);
  2132. } while ((node = node.nextSibling));
  2133. },
  2134. '+': function (node, tag, id, classes, attributes, pseudos) { // next sibling
  2135. while ((node = node.nextSibling)) if (node.nodeType == 1) {
  2136. this.push(node, tag, id, classes, attributes, pseudos);
  2137. break;
  2138. }
  2139. },
  2140. '^': function (node, tag, id, classes, attributes, pseudos) { // first child
  2141. node = node.firstChild;
  2142. if (node) {
  2143. if (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);
  2144. else this['combinator:+'](node, tag, id, classes, attributes, pseudos);
  2145. }
  2146. },
  2147. '~': function (node, tag, id, classes, attributes, pseudos) { // next siblings
  2148. while ((node = node.nextSibling)) {
  2149. if (node.nodeType != 1) continue;
  2150. var uid = this.getUID(node);
  2151. if (this.bitUniques[uid]) break;
  2152. this.bitUniques[uid] = true;
  2153. this.push(node, tag, id, classes, attributes, pseudos);
  2154. }
  2155. },
  2156. '++': function (node, tag, id, classes, attributes, pseudos) { // next sibling and previous sibling
  2157. this['combinator:+'](node, tag, id, classes, attributes, pseudos);
  2158. this['combinator:!+'](node, tag, id, classes, attributes, pseudos);
  2159. },
  2160. '~~': function (node, tag, id, classes, attributes, pseudos) { // next siblings and previous siblings
  2161. this['combinator:~'](node, tag, id, classes, attributes, pseudos);
  2162. this['combinator:!~'](node, tag, id, classes, attributes, pseudos);
  2163. },
  2164. '!': function (node, tag, id, classes, attributes, pseudos) { // all parent nodes up to document
  2165. while ((node = node.parentNode)) if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos);
  2166. },
  2167. '!>': function (node, tag, id, classes, attributes, pseudos) { // direct parent (one level)
  2168. node = node.parentNode;
  2169. if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos);
  2170. },
  2171. '!+': function (node, tag, id, classes, attributes, pseudos) { // previous sibling
  2172. while ((node = node.previousSibling)) if (node.nodeType == 1) {
  2173. this.push(node, tag, id, classes, attributes, pseudos);
  2174. break;
  2175. }
  2176. },
  2177. '!^': function (node, tag, id, classes, attributes, pseudos) { // last child
  2178. node = node.lastChild;
  2179. if (node) {
  2180. if (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);
  2181. else this['combinator:!+'](node, tag, id, classes, attributes, pseudos);
  2182. }
  2183. },
  2184. '!~': function (node, tag, id, classes, attributes, pseudos) { // previous siblings
  2185. while ((node = node.previousSibling)) {
  2186. if (node.nodeType != 1) continue;
  2187. var uid = this.getUID(node);
  2188. if (this.bitUniques[uid]) break;
  2189. this.bitUniques[uid] = true;
  2190. this.push(node, tag, id, classes, attributes, pseudos);
  2191. }
  2192. }
  2193. };
  2194. for (var c in combinators) local['combinator:' + c] = combinators[c];
  2195. var pseudos = {
  2196. /*<pseudo-selectors>*/
  2197. 'empty': function (node) {
  2198. var child = node.firstChild;
  2199. return !(child && child.nodeType == 1) && !(node.innerText || node.textContent || '').length;
  2200. },
  2201. 'not': function (node, expression) {
  2202. return !this.matchNode(node, expression);
  2203. },
  2204. 'contains': function (node, text) {
  2205. return (node.innerText || node.textContent || '').indexOf(text) > -1;
  2206. },
  2207. 'first-child': function (node) {
  2208. while ((node = node.previousSibling)) if (node.nodeType == 1) return false;
  2209. return true;
  2210. },
  2211. 'last-child': function (node) {
  2212. while ((node = node.nextSibling)) if (node.nodeType == 1) return false;
  2213. return true;
  2214. },
  2215. 'only-child': function (node) {
  2216. var prev = node;
  2217. while ((prev = prev.previousSibling)) if (prev.nodeType == 1) return false;
  2218. var next = node;
  2219. while ((next = next.nextSibling)) if (next.nodeType == 1) return false;
  2220. return true;
  2221. },
  2222. /*<nth-pseudo-selectors>*/
  2223. 'nth-child': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTH'),
  2224. 'nth-last-child': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHLast'),
  2225. 'nth-of-type': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTHType', true),
  2226. 'nth-last-of-type': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHTypeLast', true),
  2227. 'index': function (node, index) {
  2228. return this['pseudo:nth-child'](node, '' + (index + 1));
  2229. },
  2230. 'even': function (node) {
  2231. return this['pseudo:nth-child'](node, '2n');
  2232. },
  2233. 'odd': function (node) {
  2234. return this['pseudo:nth-child'](node, '2n+1');
  2235. },
  2236. /*</nth-pseudo-selectors>*/
  2237. /*<of-type-pseudo-selectors>*/
  2238. 'first-of-type': function (node) {
  2239. var nodeName = node.nodeName;
  2240. while ((node = node.previousSibling)) if (node.nodeName == nodeName) return false;
  2241. return true;
  2242. },
  2243. 'last-of-type': function (node) {
  2244. var nodeName = node.nodeName;
  2245. while ((node = node.nextSibling)) if (node.nodeName == nodeName) return false;
  2246. return true;
  2247. },
  2248. 'only-of-type': function (node) {
  2249. var prev = node, nodeName = node.nodeName;
  2250. while ((prev = prev.previousSibling)) if (prev.nodeName == nodeName) return false;
  2251. var next = node;
  2252. while ((next = next.nextSibling)) if (next.nodeName == nodeName) return false;
  2253. return true;
  2254. },
  2255. /*</of-type-pseudo-selectors>*/
  2256. // custom pseudos
  2257. 'enabled': function (node) {
  2258. return !node.disabled;
  2259. },
  2260. 'disabled': function (node) {
  2261. return node.disabled;
  2262. },
  2263. 'checked': function (node) {
  2264. return node.checked || node.selected;
  2265. },
  2266. 'focus': function (node) {
  2267. return this.isHTMLDocument && this.document.activeElement === node && (node.href || node.type || this.hasAttribute(node, 'tabindex'));
  2268. },
  2269. 'root': function (node) {
  2270. return (node === this.root);
  2271. },
  2272. 'selected': function (node) {
  2273. return node.selected;
  2274. }
  2275. /*</pseudo-selectors>*/
  2276. };
  2277. for (var p in pseudos) local['pseudo:' + p] = pseudos[p];
  2278. // attributes methods
  2279. var attributeGetters = local.attributeGetters = {
  2280. 'for': function () {
  2281. return ('htmlFor' in this) ? this.htmlFor : this.getAttribute('for');
  2282. },
  2283. 'href': function () {
  2284. return ('href' in this) ? this.getAttribute('href', 2) : this.getAttribute('href');
  2285. },
  2286. 'style': function () {
  2287. return (this.style) ? this.style.cssText : this.getAttribute('style');
  2288. },
  2289. 'tabindex': function () {
  2290. var attributeNode = this.getAttributeNode('tabindex');
  2291. return (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;
  2292. },
  2293. 'type': function () {
  2294. return this.getAttribute('type');
  2295. },
  2296. 'maxlength': function () {
  2297. var attributeNode = this.getAttributeNode('maxLength');
  2298. return (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;
  2299. }
  2300. };
  2301. attributeGetters.MAXLENGTH = attributeGetters.maxLength = attributeGetters.maxlength;
  2302. // Slick
  2303. var Slick = local.Slick = (this.Slick || {});
  2304. Slick.version = '1.1.7';
  2305. // Slick finder
  2306. Slick.search = function (context, expression, append) {
  2307. return local.search(context, expression, append);
  2308. };
  2309. Slick.find = function (context, expression) {
  2310. return local.search(context, expression, null, true);
  2311. };
  2312. // Slick containment checker
  2313. Slick.contains = function (container, node) {
  2314. local.setDocument(container);
  2315. return local.contains(container, node);
  2316. };
  2317. // Slick attribute getter
  2318. Slick.getAttribute = function (node, name) {
  2319. local.setDocument(node);
  2320. return local.getAttribute(node, name);
  2321. };
  2322. Slick.hasAttribute = function (node, name) {
  2323. local.setDocument(node);
  2324. return local.hasAttribute(node, name);
  2325. };
  2326. // Slick matcher
  2327. Slick.match = function (node, selector) {
  2328. if (!(node && selector)) return false;
  2329. if (!selector || selector === node) return true;
  2330. local.setDocument(node);
  2331. return local.matchNode(node, selector);
  2332. };
  2333. // Slick attribute accessor
  2334. Slick.defineAttributeGetter = function (name, fn) {
  2335. local.attributeGetters[name] = fn;
  2336. return this;
  2337. };
  2338. Slick.lookupAttributeGetter = function (name) {
  2339. return local.attributeGetters[name];
  2340. };
  2341. // Slick pseudo accessor
  2342. Slick.definePseudo = function (name, fn) {
  2343. local['pseudo:' + name] = function (node, argument) {
  2344. return fn.call(node, argument);
  2345. };
  2346. return this;
  2347. };
  2348. Slick.lookupPseudo = function (name) {
  2349. var pseudo = local['pseudo:' + name];
  2350. if (pseudo) return function (argument) {
  2351. return pseudo.call(this, argument);
  2352. };
  2353. return null;
  2354. };
  2355. // Slick overrides accessor
  2356. Slick.override = function (regexp, fn) {
  2357. local.override(regexp, fn);
  2358. return this;
  2359. };
  2360. Slick.isXML = local.isXML;
  2361. Slick.uidOf = function (node) {
  2362. return local.getUIDHTML(node);
  2363. };
  2364. if (!this.Slick) this.Slick = Slick;
  2365. }).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);
  2366. /*
  2367. ---
  2368. name: Element
  2369. description: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements.
  2370. license: MIT-style license.
  2371. requires: [Window, Document, Array, String, Function, Object, Number, Slick.Parser, Slick.Finder]
  2372. provides: [Element, Elements, $, $$, Iframe, Selectors]
  2373. ...
  2374. */
  2375. var Element = function (tag, props) {
  2376. var konstructor = Element.Constructors[tag];
  2377. if (konstructor) return konstructor(props);
  2378. if (typeof tag != 'string') return document.id(tag).set(props);
  2379. if (!props) props = {};
  2380. if (!(/^[\w-]+$/).test(tag)) {
  2381. var parsed = Slick.parse(tag).expressions[0][0];
  2382. tag = (parsed.tag == '*') ? 'div' : parsed.tag;
  2383. if (parsed.id && props.id == null) props.id = parsed.id;
  2384. var attributes = parsed.attributes;
  2385. if (attributes) for (var attr, i = 0, l = attributes.length; i < l; i++) {
  2386. attr = attributes[i];
  2387. if (props[attr.key] != null) continue;
  2388. if (attr.value != null && attr.operator == '=') props[attr.key] = attr.value;
  2389. else if (!attr.value && !attr.operator) props[attr.key] = true;
  2390. }
  2391. if (parsed.classList && props['class'] == null) props['class'] = parsed.classList.join(' ');
  2392. }
  2393. return document.newElement(tag, props);
  2394. };
  2395. if (Browser.Element) {
  2396. Element.prototype = Browser.Element.prototype;
  2397. // IE8 and IE9 require the wrapping.
  2398. Element.prototype._fireEvent = (function (fireEvent) {
  2399. return function (type, event) {
  2400. return fireEvent.call(this, type, event);
  2401. };
  2402. })(Element.prototype.fireEvent);
  2403. }
  2404. new Type('Element', Element).mirror(function (name) {
  2405. if (Array.prototype[name]) return;
  2406. var obj = {};
  2407. obj[name] = function () {
  2408. var results = [], args = arguments, elements = true;
  2409. for (var i = 0, l = this.length; i < l; i++) {
  2410. var element = this[i], result = results[i] = element[name].apply(element, args);
  2411. elements = (elements && typeOf(result) == 'element');
  2412. }
  2413. return (elements) ? new Elements(results) : results;
  2414. };
  2415. Elements.implement(obj);
  2416. });
  2417. if (!Browser.Element) {
  2418. Element.parent = Object;
  2419. Element.Prototype = {
  2420. '$constructor': Element,
  2421. '$family': Function.from('element').hide()
  2422. };
  2423. Element.mirror(function (name, method) {
  2424. Element.Prototype[name] = method;
  2425. });
  2426. }
  2427. Element.Constructors = {};
  2428. //<1.2compat>
  2429. Element.Constructors = new Hash;
  2430. //</1.2compat>
  2431. var IFrame = new Type('IFrame', function () {
  2432. var params = Array.link(arguments, {
  2433. properties: Type.isObject,
  2434. iframe: function (obj) {
  2435. return (obj != null);
  2436. }
  2437. });
  2438. var props = params.properties || {}, iframe;
  2439. if (params.iframe) iframe = document.id(params.iframe);
  2440. var onload = props.onload || function () { };
  2441. delete props.onload;
  2442. props.id = props.name = [props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + String.uniqueID()].pick();
  2443. iframe = new Element(iframe || 'iframe', props);
  2444. var onLoad = function () {
  2445. onload.call(iframe.contentWindow);
  2446. };
  2447. if (window.frames[props.id]) onLoad();
  2448. else iframe.addListener('load', onLoad);
  2449. return iframe;
  2450. });
  2451. var Elements = this.Elements = function (nodes) {
  2452. if (nodes && nodes.length) {
  2453. var uniques = {}, node;
  2454. for (var i = 0; node = nodes[i++];) {
  2455. var uid = Slick.uidOf(node);
  2456. if (!uniques[uid]) {
  2457. uniques[uid] = true;
  2458. this.push(node);
  2459. }
  2460. }
  2461. }
  2462. };
  2463. Elements.prototype = { length: 0 };
  2464. Elements.parent = Array;
  2465. new Type('Elements', Elements).implement({
  2466. filter: function (filter, bind) {
  2467. if (!filter) return this;
  2468. return new Elements(Array.filter(this, (typeOf(filter) == 'string') ? function (item) {
  2469. return item.match(filter);
  2470. } : filter, bind));
  2471. }.protect(),
  2472. push: function () {
  2473. var length = this.length;
  2474. for (var i = 0, l = arguments.length; i < l; i++) {
  2475. var item = document.id(arguments[i]);
  2476. if (item) this[length++] = item;
  2477. }
  2478. return (this.length = length);
  2479. }.protect(),
  2480. unshift: function () {
  2481. var items = [];
  2482. for (var i = 0, l = arguments.length; i < l; i++) {
  2483. var item = document.id(arguments[i]);
  2484. if (item) items.push(item);
  2485. }
  2486. return Array.prototype.unshift.apply(this, items);
  2487. }.protect(),
  2488. concat: function () {
  2489. var newElements = new Elements(this);
  2490. for (var i = 0, l = arguments.length; i < l; i++) {
  2491. var item = arguments[i];
  2492. if (Type.isEnumerable(item)) newElements.append(item);
  2493. else newElements.push(item);
  2494. }
  2495. return newElements;
  2496. }.protect(),
  2497. append: function (collection) {
  2498. for (var i = 0, l = collection.length; i < l; i++) this.push(collection[i]);
  2499. return this;
  2500. }.protect(),
  2501. empty: function () {
  2502. while (this.length) delete this[--this.length];
  2503. return this;
  2504. }.protect()
  2505. });
  2506. //<1.2compat>
  2507. Elements.alias('extend', 'append');
  2508. //</1.2compat>
  2509. (function () {
  2510. // FF, IE
  2511. var splice = Array.prototype.splice, object = { '0': 0, '1': 1, length: 2 };
  2512. splice.call(object, 1, 1);
  2513. if (object[1] == 1) Elements.implement('splice', function () {
  2514. var length = this.length;
  2515. var result = splice.apply(this, arguments);
  2516. while (length >= this.length) delete this[length--];
  2517. return result;
  2518. }.protect());
  2519. Array.forEachMethod(function (method, name) {
  2520. Elements.implement(name, method);
  2521. });
  2522. Array.mirror(Elements);
  2523. /*<ltIE8>*/
  2524. var createElementAcceptsHTML;
  2525. try {
  2526. createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');
  2527. } catch (e) { }
  2528. var escapeQuotes = function (html) {
  2529. return ('' + html).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  2530. };
  2531. /*</ltIE8>*/
  2532. Document.implement({
  2533. newElement: function (tag, props) {
  2534. if (props && props.checked != null) props.defaultChecked = props.checked;
  2535. /*<ltIE8>*/// Fix for readonly name and type properties in IE < 8
  2536. if (createElementAcceptsHTML && props) {
  2537. tag = '<' + tag;
  2538. if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"';
  2539. if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"';
  2540. tag += '>';
  2541. delete props.name;
  2542. delete props.type;
  2543. }
  2544. /*</ltIE8>*/
  2545. return this.id(this.createElement(tag)).set(props);
  2546. }
  2547. });
  2548. })();
  2549. (function () {
  2550. Slick.uidOf(window);
  2551. Slick.uidOf(document);
  2552. Document.implement({
  2553. newTextNode: function (text) {
  2554. return this.createTextNode(text);
  2555. },
  2556. getDocument: function () {
  2557. return this;
  2558. },
  2559. getWindow: function () {
  2560. return this.window;
  2561. },
  2562. id: (function () {
  2563. var types = {
  2564. string: function (id, nocash, doc) {
  2565. id = Slick.find(doc, '#' + id.replace(/(\W)/g, '\\$1'));
  2566. return (id) ? types.element(id, nocash) : null;
  2567. },
  2568. element: function (el, nocash) {
  2569. Slick.uidOf(el);
  2570. if (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagName)) {
  2571. var fireEvent = el.fireEvent;
  2572. // wrapping needed in IE7, or else crash
  2573. el._fireEvent = function (type, event) {
  2574. return fireEvent(type, event);
  2575. };
  2576. Object.append(el, Element.Prototype);
  2577. }
  2578. return el;
  2579. },
  2580. object: function (obj, nocash, doc) {
  2581. if (obj.toElement) return types.element(obj.toElement(doc), nocash);
  2582. return null;
  2583. }
  2584. };
  2585. types.textnode = types.whitespace = types.window = types.document = function (zero) {
  2586. return zero;
  2587. };
  2588. return function (el, nocash, doc) {
  2589. if (el && el.$family && el.uniqueNumber) return el;
  2590. var type = typeOf(el);
  2591. return (types[type]) ? types[type](el, nocash, doc || document) : null;
  2592. };
  2593. })()
  2594. });
  2595. if (window.$ == null) Window.implement('$', function (el, nc) {
  2596. return document.id(el, nc, this.document);
  2597. });
  2598. Window.implement({
  2599. getDocument: function () {
  2600. return this.document;
  2601. },
  2602. getWindow: function () {
  2603. return this;
  2604. }
  2605. });
  2606. [Document, Element].invoke('implement', {
  2607. getElements: function (expression) {
  2608. return Slick.search(this, expression, new Elements);
  2609. },
  2610. getElement: function (expression) {
  2611. return document.id(Slick.find(this, expression));
  2612. }
  2613. });
  2614. var contains = {
  2615. contains: function (element) {
  2616. return Slick.contains(this, element);
  2617. }
  2618. };
  2619. if (!document.contains) Document.implement(contains);
  2620. if (!document.createElement('div').contains) Element.implement(contains);
  2621. //<1.2compat>
  2622. Element.implement('hasChild', function (element) {
  2623. return this !== element && this.contains(element);
  2624. });
  2625. (function (search, find, match) {
  2626. this.Selectors = {};
  2627. var pseudos = this.Selectors.Pseudo = new Hash();
  2628. var addSlickPseudos = function () {
  2629. for (var name in pseudos) if (pseudos.hasOwnProperty(name)) {
  2630. Slick.definePseudo(name, pseudos[name]);
  2631. delete pseudos[name];
  2632. }
  2633. };
  2634. Slick.search = function (context, expression, append) {
  2635. addSlickPseudos();
  2636. return search.call(this, context, expression, append);
  2637. };
  2638. Slick.find = function (context, expression) {
  2639. addSlickPseudos();
  2640. return find.call(this, context, expression);
  2641. };
  2642. Slick.match = function (node, selector) {
  2643. addSlickPseudos();
  2644. return match.call(this, node, selector);
  2645. };
  2646. })(Slick.search, Slick.find, Slick.match);
  2647. //</1.2compat>
  2648. // tree walking
  2649. var injectCombinator = function (expression, combinator) {
  2650. if (!expression) return combinator;
  2651. expression = Object.clone(Slick.parse(expression));
  2652. var expressions = expression.expressions;
  2653. for (var i = expressions.length; i--;)
  2654. expressions[i][0].combinator = combinator;
  2655. return expression;
  2656. };
  2657. Object.forEach({
  2658. getNext: '~',
  2659. getPrevious: '!~',
  2660. getParent: '!'
  2661. }, function (combinator, method) {
  2662. Element.implement(method, function (expression) {
  2663. return this.getElement(injectCombinator(expression, combinator));
  2664. });
  2665. });
  2666. Object.forEach({
  2667. getAllNext: '~',
  2668. getAllPrevious: '!~',
  2669. getSiblings: '~~',
  2670. getChildren: '>',
  2671. getParents: '!'
  2672. }, function (combinator, method) {
  2673. Element.implement(method, function (expression) {
  2674. return this.getElements(injectCombinator(expression, combinator));
  2675. });
  2676. });
  2677. Element.implement({
  2678. getFirst: function (expression) {
  2679. return document.id(Slick.search(this, injectCombinator(expression, '>'))[0]);
  2680. },
  2681. getLast: function (expression) {
  2682. return document.id(Slick.search(this, injectCombinator(expression, '>')).getLast());
  2683. },
  2684. getWindow: function () {
  2685. return this.ownerDocument.window;
  2686. },
  2687. getDocument: function () {
  2688. return this.ownerDocument;
  2689. },
  2690. getElementById: function (id) {
  2691. return document.id(Slick.find(this, '#' + ('' + id).replace(/(\W)/g, '\\$1')));
  2692. },
  2693. match: function (expression) {
  2694. return !expression || Slick.match(this, expression);
  2695. }
  2696. });
  2697. //<1.2compat>
  2698. if (window.$$ == null) Window.implement('$$', function (selector) {
  2699. var elements = new Elements;
  2700. if (arguments.length == 1 && typeof selector == 'string') return Slick.search(this.document, selector, elements);
  2701. var args = Array.flatten(arguments);
  2702. for (var i = 0, l = args.length; i < l; i++) {
  2703. var item = args[i];
  2704. switch (typeOf(item)) {
  2705. case 'element': elements.push(item); break;
  2706. case 'string': Slick.search(this.document, item, elements);
  2707. }
  2708. }
  2709. return elements;
  2710. });
  2711. //</1.2compat>
  2712. if (window.$$ == null) Window.implement('$$', function (selector) {
  2713. if (arguments.length == 1) {
  2714. if (typeof selector == 'string') return Slick.search(this.document, selector, new Elements);
  2715. else if (Type.isEnumerable(selector)) return new Elements(selector);
  2716. }
  2717. return new Elements(arguments);
  2718. });
  2719. // Inserters
  2720. var inserters = {
  2721. before: function (context, element) {
  2722. var parent = element.parentNode;
  2723. if (parent) parent.insertBefore(context, element);
  2724. },
  2725. after: function (context, element) {
  2726. var parent = element.parentNode;
  2727. if (parent) parent.insertBefore(context, element.nextSibling);
  2728. },
  2729. bottom: function (context, element) {
  2730. element.appendChild(context);
  2731. },
  2732. top: function (context, element) {
  2733. element.insertBefore(context, element.firstChild);
  2734. }
  2735. };
  2736. inserters.inside = inserters.bottom;
  2737. //<1.2compat>
  2738. Object.each(inserters, function (inserter, where) {
  2739. where = where.capitalize();
  2740. var methods = {};
  2741. methods['inject' + where] = function (el) {
  2742. inserter(this, document.id(el, true));
  2743. return this;
  2744. };
  2745. methods['grab' + where] = function (el) {
  2746. inserter(document.id(el, true), this);
  2747. return this;
  2748. };
  2749. Element.implement(methods);
  2750. });
  2751. //</1.2compat>
  2752. // getProperty / setProperty
  2753. var propertyGetters = {}, propertySetters = {};
  2754. // properties
  2755. var properties = {};
  2756. Array.forEach([
  2757. 'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
  2758. 'frameBorder', 'rowSpan', 'tabIndex', 'useMap'
  2759. ], function (property) {
  2760. properties[property.toLowerCase()] = property;
  2761. });
  2762. properties.html = 'innerHTML';
  2763. properties.text = (document.createElement('div').textContent == null) ? 'innerText' : 'textContent';
  2764. Object.forEach(properties, function (real, key) {
  2765. propertySetters[key] = function (node, value) {
  2766. node[real] = value;
  2767. };
  2768. propertyGetters[key] = function (node) {
  2769. return node[real];
  2770. };
  2771. });
  2772. // Booleans
  2773. var bools = [
  2774. 'compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked',
  2775. 'disabled', 'readOnly', 'multiple', 'selected', 'noresize',
  2776. 'defer', 'defaultChecked', 'autofocus', 'controls', 'autoplay',
  2777. 'loop'
  2778. ];
  2779. var booleans = {};
  2780. Array.forEach(bools, function (bool) {
  2781. var lower = bool.toLowerCase();
  2782. booleans[lower] = bool;
  2783. propertySetters[lower] = function (node, value) {
  2784. node[bool] = !!value;
  2785. };
  2786. propertyGetters[lower] = function (node) {
  2787. return !!node[bool];
  2788. };
  2789. });
  2790. // Special cases
  2791. Object.append(propertySetters, {
  2792. 'class': function (node, value) {
  2793. ('className' in node) ? node.className = (value || '') : node.setAttribute('class', value);
  2794. },
  2795. 'for': function (node, value) {
  2796. ('htmlFor' in node) ? node.htmlFor = value : node.setAttribute('for', value);
  2797. },
  2798. 'style': function (node, value) {
  2799. (node.style) ? node.style.cssText = value : node.setAttribute('style', value);
  2800. },
  2801. 'value': function (node, value) {
  2802. node.value = (value != null) ? value : '';
  2803. }
  2804. });
  2805. propertyGetters['class'] = function (node) {
  2806. return ('className' in node) ? node.className || null : node.getAttribute('class');
  2807. };
  2808. /* <webkit> */
  2809. var el = document.createElement('button');
  2810. // IE sets type as readonly and throws
  2811. try { el.type = 'button'; } catch (e) { }
  2812. if (el.type != 'button') propertySetters.type = function (node, value) {
  2813. node.setAttribute('type', value);
  2814. };
  2815. el = null;
  2816. /* </webkit> */
  2817. /*<IE>*/
  2818. var input = document.createElement('input');
  2819. input.value = 't';
  2820. input.type = 'submit';
  2821. if (input.value != 't') propertySetters.type = function (node, type) {
  2822. var value = node.value;
  2823. node.type = type;
  2824. node.value = value;
  2825. };
  2826. input = null;
  2827. /*</IE>*/
  2828. /* getProperty, setProperty */
  2829. /* <ltIE9> */
  2830. var pollutesGetAttribute = (function (div) {
  2831. div.random = 'attribute';
  2832. return (div.getAttribute('random') == 'attribute');
  2833. })(document.createElement('div'));
  2834. /* <ltIE9> */
  2835. Element.implement({
  2836. setProperty: function (name, value) {
  2837. var setter = propertySetters[name.toLowerCase()];
  2838. if (setter) {
  2839. setter(this, value);
  2840. } else {
  2841. /* <ltIE9> */
  2842. if (pollutesGetAttribute) var attributeWhiteList = this.retrieve('$attributeWhiteList', {});
  2843. /* </ltIE9> */
  2844. if (value == null) {
  2845. this.removeAttribute(name);
  2846. /* <ltIE9> */
  2847. if (pollutesGetAttribute) delete attributeWhiteList[name];
  2848. /* </ltIE9> */
  2849. } else {
  2850. this.setAttribute(name, '' + value);
  2851. /* <ltIE9> */
  2852. if (pollutesGetAttribute) attributeWhiteList[name] = true;
  2853. /* </ltIE9> */
  2854. }
  2855. }
  2856. return this;
  2857. },
  2858. setProperties: function (attributes) {
  2859. for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);
  2860. return this;
  2861. },
  2862. getProperty: function (name) {
  2863. var getter = propertyGetters[name.toLowerCase()];
  2864. if (getter) return getter(this);
  2865. /* <ltIE9> */
  2866. if (pollutesGetAttribute) {
  2867. var attr = this.getAttributeNode(name), attributeWhiteList = this.retrieve('$attributeWhiteList', {});
  2868. if (!attr) return null;
  2869. if (attr.expando && !attributeWhiteList[name]) {
  2870. var outer = this.outerHTML;
  2871. // segment by the opening tag and find mention of attribute name
  2872. if (outer.substr(0, outer.search(/\/?['"]?>(?![^<]*<['"])/)).indexOf(name) < 0) return null;
  2873. attributeWhiteList[name] = true;
  2874. }
  2875. }
  2876. /* </ltIE9> */
  2877. var result = Slick.getAttribute(this, name);
  2878. return (!result && !Slick.hasAttribute(this, name)) ? null : result;
  2879. },
  2880. getProperties: function () {
  2881. var args = Array.from(arguments);
  2882. return args.map(this.getProperty, this).associate(args);
  2883. },
  2884. removeProperty: function (name) {
  2885. return this.setProperty(name, null);
  2886. },
  2887. removeProperties: function () {
  2888. Array.each(arguments, this.removeProperty, this);
  2889. return this;
  2890. },
  2891. set: function (prop, value) {
  2892. var property = Element.Properties[prop];
  2893. (property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value);
  2894. }.overloadSetter(),
  2895. get: function (prop) {
  2896. var property = Element.Properties[prop];
  2897. return (property && property.get) ? property.get.apply(this) : this.getProperty(prop);
  2898. }.overloadGetter(),
  2899. erase: function (prop) {
  2900. var property = Element.Properties[prop];
  2901. (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
  2902. return this;
  2903. },
  2904. hasClass: function (className) {
  2905. return this.className.clean().contains(className, ' ');
  2906. },
  2907. addClass: function (className) {
  2908. if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
  2909. return this;
  2910. },
  2911. removeClass: function (className) {
  2912. this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
  2913. return this;
  2914. },
  2915. toggleClass: function (className, force) {
  2916. if (force == null) force = !this.hasClass(className);
  2917. return (force) ? this.addClass(className) : this.removeClass(className);
  2918. },
  2919. adopt: function () {
  2920. var parent = this, fragment, elements = Array.flatten(arguments), length = elements.length;
  2921. if (length > 1) parent = fragment = document.createDocumentFragment();
  2922. for (var i = 0; i < length; i++) {
  2923. var element = document.id(elements[i], true);
  2924. if (element) parent.appendChild(element);
  2925. }
  2926. if (fragment) this.appendChild(fragment);
  2927. return this;
  2928. },
  2929. appendText: function (text, where) {
  2930. return this.grab(this.getDocument().newTextNode(text), where);
  2931. },
  2932. grab: function (el, where) {
  2933. inserters[where || 'bottom'](document.id(el, true), this);
  2934. return this;
  2935. },
  2936. inject: function (el, where) {
  2937. inserters[where || 'bottom'](this, document.id(el, true));
  2938. return this;
  2939. },
  2940. replaces: function (el) {
  2941. el = document.id(el, true);
  2942. el.parentNode.replaceChild(this, el);
  2943. return this;
  2944. },
  2945. wraps: function (el, where) {
  2946. el = document.id(el, true);
  2947. return this.replaces(el).grab(el, where);
  2948. },
  2949. getSelected: function () {
  2950. this.selectedIndex; // Safari 3.2.1
  2951. return new Elements(Array.from(this.options).filter(function (option) {
  2952. return option.selected;
  2953. }));
  2954. },
  2955. toQueryString: function () {
  2956. var queryString = [];
  2957. this.getElements('input, select, textarea').each(function (el) {
  2958. var type = el.type;
  2959. if (!el.name || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return;
  2960. var value = (el.get('tag') == 'select') ? el.getSelected().map(function (opt) {
  2961. // IE
  2962. return document.id(opt).get('value');
  2963. }) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value');
  2964. Array.from(value).each(function (val) {
  2965. if (typeof val != 'undefined') queryString.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(val));
  2966. });
  2967. });
  2968. return queryString.join('&');
  2969. }
  2970. });
  2971. var collected = {}, storage = {};
  2972. var get = function (uid) {
  2973. return (storage[uid] || (storage[uid] = {}));
  2974. };
  2975. var clean = function (item) {
  2976. var uid = item.uniqueNumber;
  2977. if (item.removeEvents) item.removeEvents();
  2978. if (item.clearAttributes) item.clearAttributes();
  2979. if (uid != null) {
  2980. delete collected[uid];
  2981. delete storage[uid];
  2982. }
  2983. return item;
  2984. };
  2985. var formProps = { input: 'checked', option: 'selected', textarea: 'value' };
  2986. Element.implement({
  2987. destroy: function () {
  2988. var children = clean(this).getElementsByTagName('*');
  2989. Array.each(children, clean);
  2990. Element.dispose(this);
  2991. return null;
  2992. },
  2993. empty: function () {
  2994. Array.from(this.childNodes).each(Element.dispose);
  2995. return this;
  2996. },
  2997. dispose: function () {
  2998. return (this.parentNode) ? this.parentNode.removeChild(this) : this;
  2999. },
  3000. clone: function (contents, keepid) {
  3001. contents = contents !== false;
  3002. var clone = this.cloneNode(contents), ce = [clone], te = [this], i;
  3003. if (contents) {
  3004. ce.append(Array.from(clone.getElementsByTagName('*')));
  3005. te.append(Array.from(this.getElementsByTagName('*')));
  3006. }
  3007. for (i = ce.length; i--;) {
  3008. var node = ce[i], element = te[i];
  3009. if (!keepid) node.removeAttribute('id');
  3010. /*<ltIE9>*/
  3011. if (node.clearAttributes) {
  3012. node.clearAttributes();
  3013. node.mergeAttributes(element);
  3014. node.removeAttribute('uniqueNumber');
  3015. if (node.options) {
  3016. var no = node.options, eo = element.options;
  3017. for (var j = no.length; j--;) no[j].selected = eo[j].selected;
  3018. }
  3019. }
  3020. /*</ltIE9>*/
  3021. var prop = formProps[element.tagName.toLowerCase()];
  3022. if (prop && element[prop]) node[prop] = element[prop];
  3023. }
  3024. /*<ltIE9>*/
  3025. if (Browser.ie) {
  3026. var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');
  3027. for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;
  3028. }
  3029. /*</ltIE9>*/
  3030. return document.id(clone);
  3031. }
  3032. });
  3033. [Element, Window, Document].invoke('implement', {
  3034. addListener: function (type, fn) {
  3035. if (type == 'unload') {
  3036. var old = fn, self = this;
  3037. fn = function () {
  3038. self.removeListener('unload', fn);
  3039. old();
  3040. };
  3041. } else {
  3042. collected[Slick.uidOf(this)] = this;
  3043. }
  3044. if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);
  3045. else this.attachEvent('on' + type, fn);
  3046. return this;
  3047. },
  3048. removeListener: function (type, fn) {
  3049. if (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]);
  3050. else this.detachEvent('on' + type, fn);
  3051. return this;
  3052. },
  3053. retrieve: function (property, dflt) {
  3054. var storage = get(Slick.uidOf(this)), prop = storage[property];
  3055. if (dflt != null && prop == null) prop = storage[property] = dflt;
  3056. return prop != null ? prop : null;
  3057. },
  3058. store: function (property, value) {
  3059. var storage = get(Slick.uidOf(this));
  3060. storage[property] = value;
  3061. return this;
  3062. },
  3063. eliminate: function (property) {
  3064. var storage = get(Slick.uidOf(this));
  3065. delete storage[property];
  3066. return this;
  3067. }
  3068. });
  3069. /*<ltIE9>*/
  3070. if (window.attachEvent && !window.addEventListener) window.addListener('unload', function () {
  3071. Object.each(collected, clean);
  3072. if (window.CollectGarbage) CollectGarbage();
  3073. });
  3074. /*</ltIE9>*/
  3075. Element.Properties = {};
  3076. //<1.2compat>
  3077. Element.Properties = new Hash;
  3078. //</1.2compat>
  3079. Element.Properties.style = {
  3080. set: function (style) {
  3081. this.style.cssText = style;
  3082. },
  3083. get: function () {
  3084. return this.style.cssText;
  3085. },
  3086. erase: function () {
  3087. this.style.cssText = '';
  3088. }
  3089. };
  3090. Element.Properties.tag = {
  3091. get: function () {
  3092. return this.tagName.toLowerCase();
  3093. }
  3094. };
  3095. Element.Properties.html = {
  3096. set: function (html) {
  3097. if (html == null) html = '';
  3098. else if (typeOf(html) == 'array') html = html.join('');
  3099. this.innerHTML = html;
  3100. },
  3101. erase: function () {
  3102. this.innerHTML = '';
  3103. }
  3104. };
  3105. /*<ltIE9>*/
  3106. // technique by jdbarlett - http://jdbartlett.com/innershiv/
  3107. var div = document.createElement('div');
  3108. div.innerHTML = '<nav></nav>';
  3109. var supportsHTML5Elements = (div.childNodes.length == 1);
  3110. if (!supportsHTML5Elements) {
  3111. var tags = 'abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' '),
  3112. fragment = document.createDocumentFragment(), l = tags.length;
  3113. while (l--) fragment.createElement(tags[l]);
  3114. }
  3115. div = null;
  3116. /*</ltIE9>*/
  3117. /*<IE>*/
  3118. var supportsTableInnerHTML = Function.attempt(function () {
  3119. var table = document.createElement('table');
  3120. table.innerHTML = '<tr><td></td></tr>';
  3121. return true;
  3122. });
  3123. /*<ltFF4>*/
  3124. var tr = document.createElement('tr'), html = '<td></td>';
  3125. tr.innerHTML = html;
  3126. var supportsTRInnerHTML = (tr.innerHTML == html);
  3127. tr = null;
  3128. /*</ltFF4>*/
  3129. if (!supportsTableInnerHTML || !supportsTRInnerHTML || !supportsHTML5Elements) {
  3130. Element.Properties.html.set = (function (set) {
  3131. var translations = {
  3132. table: [1, '<table>', '</table>'],
  3133. select: [1, '<select>', '</select>'],
  3134. tbody: [2, '<table><tbody>', '</tbody></table>'],
  3135. tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']
  3136. };
  3137. translations.thead = translations.tfoot = translations.tbody;
  3138. return function (html) {
  3139. var wrap = translations[this.get('tag')];
  3140. if (!wrap && !supportsHTML5Elements) wrap = [0, '', ''];
  3141. if (!wrap) return set.call(this, html);
  3142. var level = wrap[0], wrapper = document.createElement('div'), target = wrapper;
  3143. if (!supportsHTML5Elements) fragment.appendChild(wrapper);
  3144. wrapper.innerHTML = [wrap[1], html, wrap[2]].flatten().join('');
  3145. while (level--) target = target.firstChild;
  3146. this.empty().adopt(target.childNodes);
  3147. if (!supportsHTML5Elements) fragment.removeChild(wrapper);
  3148. wrapper = null;
  3149. };
  3150. })(Element.Properties.html.set);
  3151. }
  3152. /*</IE>*/
  3153. /*<ltIE9>*/
  3154. var testForm = document.createElement('form');
  3155. testForm.innerHTML = '<select><option>s</option></select>';
  3156. if (testForm.firstChild.value != 's') Element.Properties.value = {
  3157. set: function (value) {
  3158. var tag = this.get('tag');
  3159. if (tag != 'select') return this.setProperty('value', value);
  3160. var options = this.getElements('option');
  3161. for (var i = 0; i < options.length; i++) {
  3162. var option = options[i],
  3163. attr = option.getAttributeNode('value'),
  3164. optionValue = (attr && attr.specified) ? option.value : option.get('text');
  3165. if (optionValue == value) return option.selected = true;
  3166. }
  3167. },
  3168. get: function () {
  3169. var option = this, tag = option.get('tag');
  3170. if (tag != 'select' && tag != 'option') return this.getProperty('value');
  3171. if (tag == 'select' && !(option = option.getSelected()[0])) return '';
  3172. var attr = option.getAttributeNode('value');
  3173. return (attr && attr.specified) ? option.value : option.get('text');
  3174. }
  3175. };
  3176. testForm = null;
  3177. /*</ltIE9>*/
  3178. /*<IE>*/
  3179. if (document.createElement('div').getAttributeNode('id')) Element.Properties.id = {
  3180. set: function (id) {
  3181. this.id = this.getAttributeNode('id').value = id;
  3182. },
  3183. get: function () {
  3184. return this.id || null;
  3185. },
  3186. erase: function () {
  3187. this.id = this.getAttributeNode('id').value = '';
  3188. }
  3189. };
  3190. /*</IE>*/
  3191. })();
  3192. /*
  3193. ---
  3194. name: Element.Style
  3195. description: Contains methods for interacting with the styles of Elements in a fashionable way.
  3196. license: MIT-style license.
  3197. requires: Element
  3198. provides: Element.Style
  3199. ...
  3200. */
  3201. (function () {
  3202. var html = document.html;
  3203. //<ltIE9>
  3204. // Check for oldIE, which does not remove styles when they're set to null
  3205. var el = document.createElement('div');
  3206. el.style.color = 'red';
  3207. el.style.color = null;
  3208. var doesNotRemoveStyles = el.style.color == 'red';
  3209. el = null;
  3210. //</ltIE9>
  3211. Element.Properties.styles = {
  3212. set: function (styles) {
  3213. this.setStyles(styles);
  3214. }
  3215. };
  3216. var hasOpacity = (html.style.opacity != null),
  3217. hasFilter = (html.style.filter != null),
  3218. reAlpha = /alpha\(opacity=([\d.]+)\)/i;
  3219. var setVisibility = function (element, opacity) {
  3220. element.store('$opacity', opacity);
  3221. element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';
  3222. };
  3223. var setOpacity = (hasOpacity ? function (element, opacity) {
  3224. element.style.opacity = opacity;
  3225. } : (hasFilter ? function (element, opacity) {
  3226. var style = element.style;
  3227. if (!element.currentStyle || !element.currentStyle.hasLayout) style.zoom = 1;
  3228. if (opacity == null || opacity == 1) opacity = '';
  3229. else opacity = 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')';
  3230. var filter = style.filter || element.getComputedStyle('filter') || '';
  3231. style.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity;
  3232. if (!style.filter) style.removeAttribute('filter');
  3233. } : setVisibility));
  3234. var getOpacity = (hasOpacity ? function (element) {
  3235. var opacity = element.style.opacity || element.getComputedStyle('opacity');
  3236. return (opacity == '') ? 1 : opacity.toFloat();
  3237. } : (hasFilter ? function (element) {
  3238. var filter = (element.style.filter || element.getComputedStyle('filter')),
  3239. opacity;
  3240. if (filter) opacity = filter.match(reAlpha);
  3241. return (opacity == null || filter == null) ? 1 : (opacity[1] / 100);
  3242. } : function (element) {
  3243. var opacity = element.retrieve('$opacity');
  3244. if (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1);
  3245. return opacity;
  3246. }));
  3247. var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat';
  3248. Element.implement({
  3249. getComputedStyle: function (property) {
  3250. if (this.currentStyle) return this.currentStyle[property.camelCase()];
  3251. var defaultView = Element.getDocument(this).defaultView,
  3252. computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
  3253. return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;
  3254. },
  3255. setStyle: function (property, value) {
  3256. if (property == 'opacity') {
  3257. if (value != null) value = parseFloat(value);
  3258. setOpacity(this, value);
  3259. return this;
  3260. }
  3261. property = (property == 'float' ? floatName : property).camelCase();
  3262. if (typeOf(value) != 'string') {
  3263. var map = (Element.Styles[property] || '@').split(' ');
  3264. value = Array.from(value).map(function (val, i) {
  3265. if (!map[i]) return '';
  3266. return (typeOf(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;
  3267. }).join(' ');
  3268. } else if (value == String(Number(value))) {
  3269. value = Math.round(value);
  3270. }
  3271. this.style[property] = value;
  3272. //<ltIE9>
  3273. if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute) {
  3274. this.style.removeAttribute(property);
  3275. }
  3276. //</ltIE9>
  3277. return this;
  3278. },
  3279. getStyle: function (property) {
  3280. if (property == 'opacity') return getOpacity(this);
  3281. property = (property == 'float' ? floatName : property).camelCase();
  3282. var result = this.style[property];
  3283. if (!result || property == 'zIndex') {
  3284. result = [];
  3285. for (var style in Element.ShortStyles) {
  3286. if (property != style) continue;
  3287. for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));
  3288. return result.join(' ');
  3289. }
  3290. result = this.getComputedStyle(property);
  3291. }
  3292. if (result) {
  3293. result = String(result);
  3294. var color = result.match(/rgba?\([\d\s,]+\)/);
  3295. if (color) result = result.replace(color[0], color[0].rgbToHex());
  3296. }
  3297. if (Browser.opera || Browser.ie) {
  3298. if ((/^(height|width)$/).test(property) && !(/px$/.test(result))) {
  3299. var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
  3300. values.each(function (value) {
  3301. size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
  3302. }, this);
  3303. return this['offset' + property.capitalize()] - size + 'px';
  3304. }
  3305. if (Browser.ie && (/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))) {
  3306. return '0px';
  3307. }
  3308. }
  3309. return result;
  3310. },
  3311. setStyles: function (styles) {
  3312. for (var style in styles) this.setStyle(style, styles[style]);
  3313. return this;
  3314. },
  3315. getStyles: function () {
  3316. var result = {};
  3317. Array.flatten(arguments).each(function (key) {
  3318. result[key] = this.getStyle(key);
  3319. }, this);
  3320. return result;
  3321. }
  3322. });
  3323. Element.Styles = {
  3324. left: '@px', top: '@px', bottom: '@px', right: '@px',
  3325. width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
  3326. backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',
  3327. fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',
  3328. margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',
  3329. borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',
  3330. zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
  3331. };
  3332. //<1.3compat>
  3333. Element.implement({
  3334. setOpacity: function (value) {
  3335. setOpacity(this, value);
  3336. return this;
  3337. },
  3338. getOpacity: function () {
  3339. return getOpacity(this);
  3340. }
  3341. });
  3342. Element.Properties.opacity = {
  3343. set: function (opacity) {
  3344. setOpacity(this, opacity);
  3345. setVisibility(this, opacity);
  3346. },
  3347. get: function () {
  3348. return getOpacity(this);
  3349. }
  3350. };
  3351. //</1.3compat>
  3352. //<1.2compat>
  3353. Element.Styles = new Hash(Element.Styles);
  3354. //</1.2compat>
  3355. Element.ShortStyles = { margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {} };
  3356. ['Top', 'Right', 'Bottom', 'Left'].each(function (direction) {
  3357. var Short = Element.ShortStyles;
  3358. var All = Element.Styles;
  3359. ['margin', 'padding'].each(function (style) {
  3360. var sd = style + direction;
  3361. Short[style][sd] = All[sd] = '@px';
  3362. });
  3363. var bd = 'border' + direction;
  3364. Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';
  3365. var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';
  3366. Short[bd] = {};
  3367. Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';
  3368. Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
  3369. Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
  3370. });
  3371. })();
  3372. /*
  3373. ---
  3374. name: Element.Event
  3375. description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events, if necessary.
  3376. license: MIT-style license.
  3377. requires: [Element, Event]
  3378. provides: Element.Event
  3379. ...
  3380. */
  3381. (function () {
  3382. Element.Properties.events = {
  3383. set: function (events) {
  3384. this.addEvents(events);
  3385. }
  3386. };
  3387. [Element, Window, Document].invoke('implement', {
  3388. addEvent: function (type, fn) {
  3389. var events = this.retrieve('events', {});
  3390. if (!events[type]) events[type] = { keys: [], values: [] };
  3391. if (events[type].keys.contains(fn)) return this;
  3392. events[type].keys.push(fn);
  3393. var realType = type,
  3394. custom = Element.Events[type],
  3395. condition = fn,
  3396. self = this;
  3397. if (custom) {
  3398. if (custom.onAdd) custom.onAdd.call(this, fn, type);
  3399. if (custom.condition) {
  3400. condition = function (event) {
  3401. if (custom.condition.call(this, event, type)) return fn.call(this, event);
  3402. return true;
  3403. };
  3404. }
  3405. if (custom.base) realType = Function.from(custom.base).call(this, type);
  3406. }
  3407. var defn = function () {
  3408. return fn.call(self);
  3409. };
  3410. var nativeEvent = Element.NativeEvents[realType];
  3411. if (nativeEvent) {
  3412. if (nativeEvent == 2) {
  3413. defn = function (event) {
  3414. event = new DOMEvent(event, self.getWindow());
  3415. if (condition.call(self, event) === false) event.stop();
  3416. };
  3417. }
  3418. this.addListener(realType, defn, arguments[2]);
  3419. }
  3420. events[type].values.push(defn);
  3421. return this;
  3422. },
  3423. removeEvent: function (type, fn) {
  3424. var events = this.retrieve('events');
  3425. if (!events || !events[type]) return this;
  3426. var list = events[type];
  3427. var index = list.keys.indexOf(fn);
  3428. if (index == -1) return this;
  3429. var value = list.values[index];
  3430. delete list.keys[index];
  3431. delete list.values[index];
  3432. var custom = Element.Events[type];
  3433. if (custom) {
  3434. if (custom.onRemove) custom.onRemove.call(this, fn, type);
  3435. if (custom.base) type = Function.from(custom.base).call(this, type);
  3436. }
  3437. return (Element.NativeEvents[type]) ? this.removeListener(type, value, arguments[2]) : this;
  3438. },
  3439. addEvents: function (events) {
  3440. for (var event in events) this.addEvent(event, events[event]);
  3441. return this;
  3442. },
  3443. removeEvents: function (events) {
  3444. var type;
  3445. if (typeOf(events) == 'object') {
  3446. for (type in events) this.removeEvent(type, events[type]);
  3447. return this;
  3448. }
  3449. var attached = this.retrieve('events');
  3450. if (!attached) return this;
  3451. if (!events) {
  3452. for (type in attached) this.removeEvents(type);
  3453. this.eliminate('events');
  3454. } else if (attached[events]) {
  3455. attached[events].keys.each(function (fn) {
  3456. this.removeEvent(events, fn);
  3457. }, this);
  3458. delete attached[events];
  3459. }
  3460. return this;
  3461. },
  3462. fireEvent: function (type, args, delay) {
  3463. var events = this.retrieve('events');
  3464. if (!events || !events[type]) return this;
  3465. args = Array.from(args);
  3466. events[type].keys.each(function (fn) {
  3467. if (delay) fn.delay(delay, this, args);
  3468. else fn.apply(this, args);
  3469. }, this);
  3470. return this;
  3471. },
  3472. cloneEvents: function (from, type) {
  3473. from = document.id(from);
  3474. var events = from.retrieve('events');
  3475. if (!events) return this;
  3476. if (!type) {
  3477. for (var eventType in events) this.cloneEvents(from, eventType);
  3478. } else if (events[type]) {
  3479. events[type].keys.each(function (fn) {
  3480. this.addEvent(type, fn);
  3481. }, this);
  3482. }
  3483. return this;
  3484. }
  3485. });
  3486. Element.NativeEvents = {
  3487. click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons
  3488. mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
  3489. mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement
  3490. keydown: 2, keypress: 2, keyup: 2, //keyboard
  3491. orientationchange: 2, // mobile
  3492. touchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch
  3493. gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture
  3494. focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, paste: 2, input: 2, //form elements
  3495. load: 2, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window
  3496. error: 1, abort: 1, scroll: 1 //misc
  3497. };
  3498. Element.Events = {
  3499. mousewheel: {
  3500. base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'
  3501. }
  3502. };
  3503. if ('onmouseenter' in document.documentElement) {
  3504. Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;
  3505. } else {
  3506. var check = function (event) {
  3507. var related = event.relatedTarget;
  3508. if (related == null) return true;
  3509. if (!related) return false;
  3510. return (related != this && related.prefix != 'xul' && typeOf(this) != 'document' && !this.contains(related));
  3511. };
  3512. Element.Events.mouseenter = {
  3513. base: 'mouseover',
  3514. condition: check
  3515. };
  3516. Element.Events.mouseleave = {
  3517. base: 'mouseout',
  3518. condition: check
  3519. };
  3520. }
  3521. /*<ltIE9>*/
  3522. if (!window.addEventListener) {
  3523. Element.NativeEvents.propertychange = 2;
  3524. Element.Events.change = {
  3525. base: function () {
  3526. var type = this.type;
  3527. return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change'
  3528. },
  3529. condition: function (event) {
  3530. return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);
  3531. }
  3532. }
  3533. }
  3534. /*</ltIE9>*/
  3535. //<1.2compat>
  3536. Element.Events = new Hash(Element.Events);
  3537. //</1.2compat>
  3538. })();
  3539. /*
  3540. ---
  3541. name: Element.Delegation
  3542. description: Extends the Element native object to include the delegate method for more efficient event management.
  3543. license: MIT-style license.
  3544. requires: [Element.Event]
  3545. provides: [Element.Delegation]
  3546. ...
  3547. */
  3548. (function () {
  3549. var eventListenerSupport = !!window.addEventListener;
  3550. Element.NativeEvents.focusin = Element.NativeEvents.focusout = 2;
  3551. var bubbleUp = function (self, match, fn, event, target) {
  3552. while (target && target != self) {
  3553. if (match(target, event)) return fn.call(target, event, target);
  3554. target = document.id(target.parentNode);
  3555. }
  3556. };
  3557. var map = {
  3558. mouseenter: {
  3559. base: 'mouseover'
  3560. },
  3561. mouseleave: {
  3562. base: 'mouseout'
  3563. },
  3564. focus: {
  3565. base: 'focus' + (eventListenerSupport ? '' : 'in'),
  3566. capture: true
  3567. },
  3568. blur: {
  3569. base: eventListenerSupport ? 'blur' : 'focusout',
  3570. capture: true
  3571. }
  3572. };
  3573. /*<ltIE9>*/
  3574. var _key = '$delegation:';
  3575. var formObserver = function (type) {
  3576. return {
  3577. base: 'focusin',
  3578. remove: function (self, uid) {
  3579. var list = self.retrieve(_key + type + 'listeners', {})[uid];
  3580. if (list && list.forms) for (var i = list.forms.length; i--;) {
  3581. list.forms[i].removeEvent(type, list.fns[i]);
  3582. }
  3583. },
  3584. listen: function (self, match, fn, event, target, uid) {
  3585. var form = (target.get('tag') == 'form') ? target : event.target.getParent('form');
  3586. if (!form) return;
  3587. var listeners = self.retrieve(_key + type + 'listeners', {}),
  3588. listener = listeners[uid] || { forms: [], fns: [] },
  3589. forms = listener.forms, fns = listener.fns;
  3590. if (forms.indexOf(form) != -1) return;
  3591. forms.push(form);
  3592. var _fn = function (event) {
  3593. bubbleUp(self, match, fn, event, target);
  3594. };
  3595. form.addEvent(type, _fn);
  3596. fns.push(_fn);
  3597. listeners[uid] = listener;
  3598. self.store(_key + type + 'listeners', listeners);
  3599. }
  3600. };
  3601. };
  3602. var inputObserver = function (type) {
  3603. return {
  3604. base: 'focusin',
  3605. listen: function (self, match, fn, event, target) {
  3606. var events = {
  3607. blur: function () {
  3608. this.removeEvents(events);
  3609. }
  3610. };
  3611. events[type] = function (event) {
  3612. bubbleUp(self, match, fn, event, target);
  3613. };
  3614. event.target.addEvents(events);
  3615. }
  3616. };
  3617. };
  3618. if (!eventListenerSupport) Object.append(map, {
  3619. submit: formObserver('submit'),
  3620. reset: formObserver('reset'),
  3621. change: inputObserver('change'),
  3622. select: inputObserver('select')
  3623. });
  3624. /*</ltIE9>*/
  3625. var proto = Element.prototype,
  3626. addEvent = proto.addEvent,
  3627. removeEvent = proto.removeEvent;
  3628. var relay = function (old, method) {
  3629. return function (type, fn, useCapture) {
  3630. if (type.indexOf(':relay') == -1) return old.call(this, type, fn, useCapture);
  3631. var parsed = Slick.parse(type).expressions[0][0];
  3632. if (parsed.pseudos[0].key != 'relay') return old.call(this, type, fn, useCapture);
  3633. var newType = parsed.tag;
  3634. parsed.pseudos.slice(1).each(function (pseudo) {
  3635. newType += ':' + pseudo.key + (pseudo.value ? '(' + pseudo.value + ')' : '');
  3636. });
  3637. old.call(this, type, fn);
  3638. return method.call(this, newType, parsed.pseudos[0].value, fn);
  3639. };
  3640. };
  3641. var delegation = {
  3642. addEvent: function (type, match, fn) {
  3643. var storage = this.retrieve('$delegates', {}), stored = storage[type];
  3644. if (stored) for (var _uid in stored) {
  3645. if (stored[_uid].fn == fn && stored[_uid].match == match) return this;
  3646. }
  3647. var _type = type, _match = match, _fn = fn, _map = map[type] || {};
  3648. type = _map.base || _type;
  3649. match = function (target) {
  3650. return Slick.match(target, _match);
  3651. };
  3652. var elementEvent = Element.Events[_type];
  3653. if (elementEvent && elementEvent.condition) {
  3654. var __match = match, condition = elementEvent.condition;
  3655. match = function (target, event) {
  3656. return __match(target, event) && condition.call(target, event, type);
  3657. };
  3658. }
  3659. var self = this, uid = String.uniqueID();
  3660. var delegator = _map.listen ? function (event, target) {
  3661. if (!target && event && event.target) target = event.target;
  3662. if (target) _map.listen(self, match, fn, event, target, uid);
  3663. } : function (event, target) {
  3664. if (!target && event && event.target) target = event.target;
  3665. if (target) bubbleUp(self, match, fn, event, target);
  3666. };
  3667. if (!stored) stored = {};
  3668. stored[uid] = {
  3669. match: _match,
  3670. fn: _fn,
  3671. delegator: delegator
  3672. };
  3673. storage[_type] = stored;
  3674. return addEvent.call(this, type, delegator, _map.capture);
  3675. },
  3676. removeEvent: function (type, match, fn, _uid) {
  3677. var storage = this.retrieve('$delegates', {}), stored = storage[type];
  3678. if (!stored) return this;
  3679. if (_uid) {
  3680. var _type = type, delegator = stored[_uid].delegator, _map = map[type] || {};
  3681. type = _map.base || _type;
  3682. if (_map.remove) _map.remove(this, _uid);
  3683. delete stored[_uid];
  3684. storage[_type] = stored;
  3685. return removeEvent.call(this, type, delegator);
  3686. }
  3687. var __uid, s;
  3688. if (fn) for (__uid in stored) {
  3689. s = stored[__uid];
  3690. if (s.match == match && s.fn == fn) return delegation.removeEvent.call(this, type, match, fn, __uid);
  3691. } else for (__uid in stored) {
  3692. s = stored[__uid];
  3693. if (s.match == match) delegation.removeEvent.call(this, type, match, s.fn, __uid);
  3694. }
  3695. return this;
  3696. }
  3697. };
  3698. [Element, Window, Document].invoke('implement', {
  3699. addEvent: relay(addEvent, delegation.addEvent),
  3700. removeEvent: relay(removeEvent, delegation.removeEvent)
  3701. });
  3702. })();
  3703. /*
  3704. ---
  3705. name: Element.Dimensions
  3706. description: Contains methods to work with size, scroll, or positioning of Elements and the window object.
  3707. license: MIT-style license.
  3708. credits:
  3709. - Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html).
  3710. - Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html).
  3711. requires: [Element, Element.Style]
  3712. provides: [Element.Dimensions]
  3713. ...
  3714. */
  3715. (function () {
  3716. var element = document.createElement('div'),
  3717. child = document.createElement('div');
  3718. element.style.height = '0';
  3719. element.appendChild(child);
  3720. var brokenOffsetParent = (child.offsetParent === element);
  3721. element = child = null;
  3722. var isOffset = function (el) {
  3723. return styleString(el, 'position') != 'static' || isBody(el);
  3724. };
  3725. var isOffsetStatic = function (el) {
  3726. return isOffset(el) || (/^(?:table|td|th)$/i).test(el.tagName);
  3727. };
  3728. Element.implement({
  3729. scrollTo: function (x, y) {
  3730. if (isBody(this)) {
  3731. this.getWindow().scrollTo(x, y);
  3732. } else {
  3733. this.scrollLeft = x;
  3734. this.scrollTop = y;
  3735. }
  3736. return this;
  3737. },
  3738. getSize: function () {
  3739. if (isBody(this)) return this.getWindow().getSize();
  3740. return { x: this.offsetWidth, y: this.offsetHeight };
  3741. },
  3742. getScrollSize: function () {
  3743. if (isBody(this)) return this.getWindow().getScrollSize();
  3744. return { x: this.scrollWidth, y: this.scrollHeight };
  3745. },
  3746. getScroll: function () {
  3747. if (isBody(this)) return this.getWindow().getScroll();
  3748. return { x: this.scrollLeft, y: this.scrollTop };
  3749. },
  3750. getScrolls: function () {
  3751. var element = this.parentNode, position = { x: 0, y: 0 };
  3752. while (element && !isBody(element)) {
  3753. position.x += element.scrollLeft;
  3754. position.y += element.scrollTop;
  3755. element = element.parentNode;
  3756. }
  3757. return position;
  3758. },
  3759. getOffsetParent: brokenOffsetParent ? function () {
  3760. var element = this;
  3761. if (isBody(element) || styleString(element, 'position') == 'fixed') return null;
  3762. var isOffsetCheck = (styleString(element, 'position') == 'static') ? isOffsetStatic : isOffset;
  3763. while ((element = element.parentNode)) {
  3764. if (isOffsetCheck(element)) return element;
  3765. }
  3766. return null;
  3767. } : function () {
  3768. var element = this;
  3769. if (isBody(element) || styleString(element, 'position') == 'fixed') return null;
  3770. try {
  3771. return element.offsetParent;
  3772. } catch (e) { }
  3773. return null;
  3774. },
  3775. getOffsets: function () {
  3776. if (this.getBoundingClientRect && !Browser.Platform.ios) {
  3777. var bound = this.getBoundingClientRect(),
  3778. html = document.id(this.getDocument().documentElement),
  3779. htmlScroll = html.getScroll(),
  3780. elemScrolls = this.getScrolls(),
  3781. isFixed = (styleString(this, 'position') == 'fixed');
  3782. return {
  3783. x: bound.left.toInt() + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
  3784. y: bound.top.toInt() + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
  3785. };
  3786. }
  3787. var element = this, position = { x: 0, y: 0 };
  3788. if (isBody(this)) return position;
  3789. while (element && !isBody(element)) {
  3790. position.x += element.offsetLeft;
  3791. position.y += element.offsetTop;
  3792. if (Browser.firefox) {
  3793. if (!borderBox(element)) {
  3794. position.x += leftBorder(element);
  3795. position.y += topBorder(element);
  3796. }
  3797. var parent = element.parentNode;
  3798. if (parent && styleString(parent, 'overflow') != 'visible') {
  3799. position.x += leftBorder(parent);
  3800. position.y += topBorder(parent);
  3801. }
  3802. } else if (element != this && Browser.safari) {
  3803. position.x += leftBorder(element);
  3804. position.y += topBorder(element);
  3805. }
  3806. element = element.offsetParent;
  3807. }
  3808. if (Browser.firefox && !borderBox(this)) {
  3809. position.x -= leftBorder(this);
  3810. position.y -= topBorder(this);
  3811. }
  3812. return position;
  3813. },
  3814. getPosition: function (relative) {
  3815. var offset = this.getOffsets(),
  3816. scroll = this.getScrolls();
  3817. var position = {
  3818. x: offset.x - scroll.x,
  3819. y: offset.y - scroll.y
  3820. };
  3821. if (relative && (relative = document.id(relative))) {
  3822. var relativePosition = relative.getPosition();
  3823. return { x: position.x - relativePosition.x - leftBorder(relative), y: position.y - relativePosition.y - topBorder(relative) };
  3824. }
  3825. return position;
  3826. },
  3827. getCoordinates: function (element) {
  3828. if (isBody(this)) return this.getWindow().getCoordinates();
  3829. var position = this.getPosition(element),
  3830. size = this.getSize();
  3831. var obj = {
  3832. left: position.x,
  3833. top: position.y,
  3834. width: size.x,
  3835. height: size.y
  3836. };
  3837. obj.right = obj.left + obj.width;
  3838. obj.bottom = obj.top + obj.height;
  3839. return obj;
  3840. },
  3841. computePosition: function (obj) {
  3842. return {
  3843. left: obj.x - styleNumber(this, 'margin-left'),
  3844. top: obj.y - styleNumber(this, 'margin-top')
  3845. };
  3846. },
  3847. setPosition: function (obj) {
  3848. return this.setStyles(this.computePosition(obj));
  3849. }
  3850. });
  3851. [Document, Window].invoke('implement', {
  3852. getSize: function () {
  3853. var doc = getCompatElement(this);
  3854. return { x: doc.clientWidth, y: doc.clientHeight };
  3855. },
  3856. getScroll: function () {
  3857. var win = this.getWindow(), doc = getCompatElement(this);
  3858. return { x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop };
  3859. },
  3860. getScrollSize: function () {
  3861. var doc = getCompatElement(this),
  3862. min = this.getSize(),
  3863. body = this.getDocument().body;
  3864. return { x: Math.max(doc.scrollWidth, body.scrollWidth, min.x), y: Math.max(doc.scrollHeight, body.scrollHeight, min.y) };
  3865. },
  3866. getPosition: function () {
  3867. return { x: 0, y: 0 };
  3868. },
  3869. getCoordinates: function () {
  3870. var size = this.getSize();
  3871. return { top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x };
  3872. }
  3873. });
  3874. // private methods
  3875. var styleString = Element.getComputedStyle;
  3876. function styleNumber(element, style) {
  3877. return styleString(element, style).toInt() || 0;
  3878. }
  3879. function borderBox(element) {
  3880. return styleString(element, '-moz-box-sizing') == 'border-box';
  3881. }
  3882. function topBorder(element) {
  3883. return styleNumber(element, 'border-top-width');
  3884. }
  3885. function leftBorder(element) {
  3886. return styleNumber(element, 'border-left-width');
  3887. }
  3888. function isBody(element) {
  3889. return (/^(?:body|html)$/i).test(element.tagName);
  3890. }
  3891. function getCompatElement(element) {
  3892. var doc = element.getDocument();
  3893. return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
  3894. }
  3895. })();
  3896. //aliases
  3897. Element.alias({ position: 'setPosition' }); //compatability
  3898. [Window, Document, Element].invoke('implement', {
  3899. getHeight: function () {
  3900. return this.getSize().y;
  3901. },
  3902. getWidth: function () {
  3903. return this.getSize().x;
  3904. },
  3905. getScrollTop: function () {
  3906. return this.getScroll().y;
  3907. },
  3908. getScrollLeft: function () {
  3909. return this.getScroll().x;
  3910. },
  3911. getScrollHeight: function () {
  3912. return this.getScrollSize().y;
  3913. },
  3914. getScrollWidth: function () {
  3915. return this.getScrollSize().x;
  3916. },
  3917. getTop: function () {
  3918. return this.getPosition().y;
  3919. },
  3920. getLeft: function () {
  3921. return this.getPosition().x;
  3922. }
  3923. });
  3924. /*
  3925. ---
  3926. name: Fx
  3927. description: Contains the basic animation logic to be extended by all other Fx Classes.
  3928. license: MIT-style license.
  3929. requires: [Chain, Events, Options]
  3930. provides: Fx
  3931. ...
  3932. */
  3933. (function () {
  3934. var Fx = this.Fx = new Class({
  3935. Implements: [Chain, Events, Options],
  3936. options: {
  3937. /*
  3938. onStart: nil,
  3939. onCancel: nil,
  3940. onComplete: nil,
  3941. */
  3942. fps: 60,
  3943. unit: false,
  3944. duration: 500,
  3945. frames: null,
  3946. frameSkip: true,
  3947. link: 'ignore'
  3948. },
  3949. initialize: function (options) {
  3950. this.subject = this.subject || this;
  3951. this.setOptions(options);
  3952. },
  3953. getTransition: function () {
  3954. return function (p) {
  3955. return -(Math.cos(Math.PI * p) - 1) / 2;
  3956. };
  3957. },
  3958. step: function (now) {
  3959. if (this.options.frameSkip) {
  3960. var diff = (this.time != null) ? (now - this.time) : 0, frames = diff / this.frameInterval;
  3961. this.time = now;
  3962. this.frame += frames;
  3963. } else {
  3964. this.frame++;
  3965. }
  3966. if (this.frame < this.frames) {
  3967. var delta = this.transition(this.frame / this.frames);
  3968. this.set(this.compute(this.from, this.to, delta));
  3969. } else {
  3970. this.frame = this.frames;
  3971. this.set(this.compute(this.from, this.to, 1));
  3972. this.stop();
  3973. }
  3974. },
  3975. set: function (now) {
  3976. return now;
  3977. },
  3978. compute: function (from, to, delta) {
  3979. return Fx.compute(from, to, delta);
  3980. },
  3981. check: function () {
  3982. if (!this.isRunning()) return true;
  3983. switch (this.options.link) {
  3984. case 'cancel': this.cancel(); return true;
  3985. case 'chain': this.chain(this.caller.pass(arguments, this)); return false;
  3986. }
  3987. return false;
  3988. },
  3989. start: function (from, to) {
  3990. if (!this.check(from, to)) return this;
  3991. this.from = from;
  3992. this.to = to;
  3993. this.frame = (this.options.frameSkip) ? 0 : -1;
  3994. this.time = null;
  3995. this.transition = this.getTransition();
  3996. var frames = this.options.frames, fps = this.options.fps, duration = this.options.duration;
  3997. this.duration = Fx.Durations[duration] || duration.toInt();
  3998. this.frameInterval = 1000 / fps;
  3999. this.frames = frames || Math.round(this.duration / this.frameInterval);
  4000. this.fireEvent('start', this.subject);
  4001. pushInstance.call(this, fps);
  4002. return this;
  4003. },
  4004. stop: function () {
  4005. if (this.isRunning()) {
  4006. this.time = null;
  4007. pullInstance.call(this, this.options.fps);
  4008. if (this.frames == this.frame) {
  4009. this.fireEvent('complete', this.subject);
  4010. if (!this.callChain()) this.fireEvent('chainComplete', this.subject);
  4011. } else {
  4012. this.fireEvent('stop', this.subject);
  4013. }
  4014. }
  4015. return this;
  4016. },
  4017. cancel: function () {
  4018. if (this.isRunning()) {
  4019. this.time = null;
  4020. pullInstance.call(this, this.options.fps);
  4021. this.frame = this.frames;
  4022. this.fireEvent('cancel', this.subject).clearChain();
  4023. }
  4024. return this;
  4025. },
  4026. pause: function () {
  4027. if (this.isRunning()) {
  4028. this.time = null;
  4029. pullInstance.call(this, this.options.fps);
  4030. }
  4031. return this;
  4032. },
  4033. resume: function () {
  4034. if ((this.frame < this.frames) && !this.isRunning()) pushInstance.call(this, this.options.fps);
  4035. return this;
  4036. },
  4037. isRunning: function () {
  4038. var list = instances[this.options.fps];
  4039. return list && list.contains(this);
  4040. }
  4041. });
  4042. Fx.compute = function (from, to, delta) {
  4043. return (to - from) * delta + from;
  4044. };
  4045. Fx.Durations = { 'short': 250, 'normal': 500, 'long': 1000 };
  4046. // global timers
  4047. var instances = {}, timers = {};
  4048. var loop = function () {
  4049. var now = Date.now();
  4050. for (var i = this.length; i--;) {
  4051. var instance = this[i];
  4052. if (instance) instance.step(now);
  4053. }
  4054. };
  4055. var pushInstance = function (fps) {
  4056. var list = instances[fps] || (instances[fps] = []);
  4057. list.push(this);
  4058. if (!timers[fps]) timers[fps] = loop.periodical(Math.round(1000 / fps), list);
  4059. };
  4060. var pullInstance = function (fps) {
  4061. var list = instances[fps];
  4062. if (list) {
  4063. list.erase(this);
  4064. if (!list.length && timers[fps]) {
  4065. delete instances[fps];
  4066. timers[fps] = clearInterval(timers[fps]);
  4067. }
  4068. }
  4069. };
  4070. })();
  4071. /*
  4072. ---
  4073. name: Fx.CSS
  4074. description: Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements.
  4075. license: MIT-style license.
  4076. requires: [Fx, Element.Style]
  4077. provides: Fx.CSS
  4078. ...
  4079. */
  4080. Fx.CSS = new Class({
  4081. Extends: Fx,
  4082. //prepares the base from/to object
  4083. prepare: function (element, property, values) {
  4084. values = Array.from(values);
  4085. var from = values[0], to = values[1];
  4086. if (to == null) {
  4087. to = from;
  4088. from = element.getStyle(property);
  4089. var unit = this.options.unit;
  4090. // adapted from: https://github.com/ryanmorr/fx/blob/master/fx.js#L299
  4091. if (unit && from.slice(-unit.length) != unit && parseFloat(from) != 0) {
  4092. element.setStyle(property, to + unit);
  4093. var value = element.getComputedStyle(property);
  4094. // IE and Opera support pixelLeft or pixelWidth
  4095. if (!(/px$/.test(value))) {
  4096. value = element.style[('pixel-' + property).camelCase()];
  4097. if (value == null) {
  4098. // adapted from Dean Edwards' http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  4099. var left = element.style.left;
  4100. element.style.left = to + unit;
  4101. value = element.style.pixelLeft;
  4102. element.style.left = left;
  4103. }
  4104. }
  4105. from = (to || 1) / (parseFloat(value) || 1) * (parseFloat(from) || 0);
  4106. element.setStyle(property, from + unit);
  4107. }
  4108. }
  4109. return { from: this.parse(from), to: this.parse(to) };
  4110. },
  4111. //parses a value into an array
  4112. parse: function (value) {
  4113. value = Function.from(value)();
  4114. value = (typeof value == 'string') ? value.split(' ') : Array.from(value);
  4115. return value.map(function (val) {
  4116. val = String(val);
  4117. var found = false;
  4118. Object.each(Fx.CSS.Parsers, function (parser, key) {
  4119. if (found) return;
  4120. var parsed = parser.parse(val);
  4121. if (parsed || parsed === 0) found = { value: parsed, parser: parser };
  4122. });
  4123. found = found || { value: val, parser: Fx.CSS.Parsers.String };
  4124. return found;
  4125. });
  4126. },
  4127. //computes by a from and to prepared objects, using their parsers.
  4128. compute: function (from, to, delta) {
  4129. var computed = [];
  4130. (Math.min(from.length, to.length)).times(function (i) {
  4131. computed.push({ value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser });
  4132. });
  4133. computed.$family = Function.from('fx:css:value');
  4134. return computed;
  4135. },
  4136. //serves the value as settable
  4137. serve: function (value, unit) {
  4138. if (typeOf(value) != 'fx:css:value') value = this.parse(value);
  4139. var returned = [];
  4140. value.each(function (bit) {
  4141. returned = returned.concat(bit.parser.serve(bit.value, unit));
  4142. });
  4143. return returned;
  4144. },
  4145. //renders the change to an element
  4146. render: function (element, property, value, unit) {
  4147. element.setStyle(property, this.serve(value, unit));
  4148. },
  4149. //searches inside the page css to find the values for a selector
  4150. search: function (selector) {
  4151. if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];
  4152. var to = {}, selectorTest = new RegExp('^' + selector.escapeRegExp() + '$');
  4153. Array.each(document.styleSheets, function (sheet, j) {
  4154. var href = sheet.href;
  4155. if (href && href.contains('://') && !href.contains(document.domain)) return;
  4156. var rules = sheet.rules || sheet.cssRules;
  4157. Array.each(rules, function (rule, i) {
  4158. if (!rule.style) return;
  4159. var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function (m) {
  4160. return m.toLowerCase();
  4161. }) : null;
  4162. if (!selectorText || !selectorTest.test(selectorText)) return;
  4163. Object.each(Element.Styles, function (value, style) {
  4164. if (!rule.style[style] || Element.ShortStyles[style]) return;
  4165. value = String(rule.style[style]);
  4166. to[style] = ((/^rgb/).test(value)) ? value.rgbToHex() : value;
  4167. });
  4168. });
  4169. });
  4170. return Fx.CSS.Cache[selector] = to;
  4171. }
  4172. });
  4173. Fx.CSS.Cache = {};
  4174. Fx.CSS.Parsers = {
  4175. Color: {
  4176. parse: function (value) {
  4177. if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true);
  4178. return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false;
  4179. },
  4180. compute: function (from, to, delta) {
  4181. return from.map(function (value, i) {
  4182. return Math.round(Fx.compute(from[i], to[i], delta));
  4183. });
  4184. },
  4185. serve: function (value) {
  4186. return value.map(Number);
  4187. }
  4188. },
  4189. Number: {
  4190. parse: parseFloat,
  4191. compute: Fx.compute,
  4192. serve: function (value, unit) {
  4193. return (unit) ? value + unit : value;
  4194. }
  4195. },
  4196. String: {
  4197. parse: Function.from(false),
  4198. compute: function (zero, one) {
  4199. return one;
  4200. },
  4201. serve: function (zero) {
  4202. return zero;
  4203. }
  4204. }
  4205. };
  4206. //<1.2compat>
  4207. Fx.CSS.Parsers = new Hash(Fx.CSS.Parsers);
  4208. //</1.2compat>
  4209. /*
  4210. ---
  4211. name: Fx.Tween
  4212. description: Formerly Fx.Style, effect to transition any CSS property for an element.
  4213. license: MIT-style license.
  4214. requires: Fx.CSS
  4215. provides: [Fx.Tween, Element.fade, Element.highlight]
  4216. ...
  4217. */
  4218. Fx.Tween = new Class({
  4219. Extends: Fx.CSS,
  4220. initialize: function (element, options) {
  4221. this.element = this.subject = document.id(element);
  4222. this.parent(options);
  4223. },
  4224. set: function (property, now) {
  4225. if (arguments.length == 1) {
  4226. now = property;
  4227. property = this.property || this.options.property;
  4228. }
  4229. this.render(this.element, property, now, this.options.unit);
  4230. return this;
  4231. },
  4232. start: function (property, from, to) {
  4233. if (!this.check(property, from, to)) return this;
  4234. var args = Array.flatten(arguments);
  4235. this.property = this.options.property || args.shift();
  4236. var parsed = this.prepare(this.element, this.property, args);
  4237. return this.parent(parsed.from, parsed.to);
  4238. }
  4239. });
  4240. Element.Properties.tween = {
  4241. set: function (options) {
  4242. this.get('tween').cancel().setOptions(options);
  4243. return this;
  4244. },
  4245. get: function () {
  4246. var tween = this.retrieve('tween');
  4247. if (!tween) {
  4248. tween = new Fx.Tween(this, { link: 'cancel' });
  4249. this.store('tween', tween);
  4250. }
  4251. return tween;
  4252. }
  4253. };
  4254. Element.implement({
  4255. tween: function (property, from, to) {
  4256. this.get('tween').start(property, from, to);
  4257. return this;
  4258. },
  4259. fade: function (how) {
  4260. var fade = this.get('tween'), method, args = ['opacity'].append(arguments), toggle;
  4261. if (args[1] == null) args[1] = 'toggle';
  4262. switch (args[1]) {
  4263. case 'in': method = 'start'; args[1] = 1; break;
  4264. case 'out': method = 'start'; args[1] = 0; break;
  4265. case 'show': method = 'set'; args[1] = 1; break;
  4266. case 'hide': method = 'set'; args[1] = 0; break;
  4267. case 'toggle':
  4268. var flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);
  4269. method = 'start';
  4270. args[1] = flag ? 0 : 1;
  4271. this.store('fade:flag', !flag);
  4272. toggle = true;
  4273. break;
  4274. default: method = 'start';
  4275. }
  4276. if (!toggle) this.eliminate('fade:flag');
  4277. fade[method].apply(fade, args);
  4278. var to = args[args.length - 1];
  4279. if (method == 'set' || to != 0) this.setStyle('visibility', to == 0 ? 'hidden' : 'visible');
  4280. else fade.chain(function () {
  4281. this.element.setStyle('visibility', 'hidden');
  4282. this.callChain();
  4283. });
  4284. return this;
  4285. },
  4286. highlight: function (start, end) {
  4287. if (!end) {
  4288. end = this.retrieve('highlight:original', this.getStyle('background-color'));
  4289. end = (end == 'transparent') ? '#fff' : end;
  4290. }
  4291. var tween = this.get('tween');
  4292. tween.start('background-color', start || '#ffff88', end).chain(function () {
  4293. this.setStyle('background-color', this.retrieve('highlight:original'));
  4294. tween.callChain();
  4295. }.bind(this));
  4296. return this;
  4297. }
  4298. });
  4299. /*
  4300. ---
  4301. name: Fx.Morph
  4302. description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.
  4303. license: MIT-style license.
  4304. requires: Fx.CSS
  4305. provides: Fx.Morph
  4306. ...
  4307. */
  4308. Fx.Morph = new Class({
  4309. Extends: Fx.CSS,
  4310. initialize: function (element, options) {
  4311. this.element = this.subject = document.id(element);
  4312. this.parent(options);
  4313. },
  4314. set: function (now) {
  4315. if (typeof now == 'string') now = this.search(now);
  4316. for (var p in now) this.render(this.element, p, now[p], this.options.unit);
  4317. return this;
  4318. },
  4319. compute: function (from, to, delta) {
  4320. var now = {};
  4321. for (var p in from) now[p] = this.parent(from[p], to[p], delta);
  4322. return now;
  4323. },
  4324. start: function (properties) {
  4325. if (!this.check(properties)) return this;
  4326. if (typeof properties == 'string') properties = this.search(properties);
  4327. var from = {}, to = {};
  4328. for (var p in properties) {
  4329. var parsed = this.prepare(this.element, p, properties[p]);
  4330. from[p] = parsed.from;
  4331. to[p] = parsed.to;
  4332. }
  4333. return this.parent(from, to);
  4334. }
  4335. });
  4336. Element.Properties.morph = {
  4337. set: function (options) {
  4338. this.get('morph').cancel().setOptions(options);
  4339. return this;
  4340. },
  4341. get: function () {
  4342. var morph = this.retrieve('morph');
  4343. if (!morph) {
  4344. morph = new Fx.Morph(this, { link: 'cancel' });
  4345. this.store('morph', morph);
  4346. }
  4347. return morph;
  4348. }
  4349. };
  4350. Element.implement({
  4351. morph: function (props) {
  4352. this.get('morph').start(props);
  4353. return this;
  4354. }
  4355. });
  4356. /*
  4357. ---
  4358. name: Fx.Transitions
  4359. description: Contains a set of advanced transitions to be used with any of the Fx Classes.
  4360. license: MIT-style license.
  4361. credits:
  4362. - Easing Equations by Robert Penner, <http://www.robertpenner.com/easing/>, modified and optimized to be used with MooTools.
  4363. requires: Fx
  4364. provides: Fx.Transitions
  4365. ...
  4366. */
  4367. Fx.implement({
  4368. getTransition: function () {
  4369. var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
  4370. if (typeof trans == 'string') {
  4371. var data = trans.split(':');
  4372. trans = Fx.Transitions;
  4373. trans = trans[data[0]] || trans[data[0].capitalize()];
  4374. if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
  4375. }
  4376. return trans;
  4377. }
  4378. });
  4379. Fx.Transition = function (transition, params) {
  4380. params = Array.from(params);
  4381. var easeIn = function (pos) {
  4382. return transition(pos, params);
  4383. };
  4384. return Object.append(easeIn, {
  4385. easeIn: easeIn,
  4386. easeOut: function (pos) {
  4387. return 1 - transition(1 - pos, params);
  4388. },
  4389. easeInOut: function (pos) {
  4390. return (pos <= 0.5 ? transition(2 * pos, params) : (2 - transition(2 * (1 - pos), params))) / 2;
  4391. }
  4392. });
  4393. };
  4394. Fx.Transitions = {
  4395. linear: function (zero) {
  4396. return zero;
  4397. }
  4398. };
  4399. //<1.2compat>
  4400. Fx.Transitions = new Hash(Fx.Transitions);
  4401. //</1.2compat>
  4402. Fx.Transitions.extend = function (transitions) {
  4403. for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
  4404. };
  4405. Fx.Transitions.extend({
  4406. Pow: function (p, x) {
  4407. return Math.pow(p, x && x[0] || 6);
  4408. },
  4409. Expo: function (p) {
  4410. return Math.pow(2, 8 * (p - 1));
  4411. },
  4412. Circ: function (p) {
  4413. return 1 - Math.sin(Math.acos(p));
  4414. },
  4415. Sine: function (p) {
  4416. return 1 - Math.cos(p * Math.PI / 2);
  4417. },
  4418. Back: function (p, x) {
  4419. x = x && x[0] || 1.618;
  4420. return Math.pow(p, 2) * ((x + 1) * p - x);
  4421. },
  4422. Bounce: function (p) {
  4423. var value;
  4424. for (var a = 0, b = 1; 1; a += b, b /= 2) {
  4425. if (p >= (7 - 4 * a) / 11) {
  4426. value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
  4427. break;
  4428. }
  4429. }
  4430. return value;
  4431. },
  4432. Elastic: function (p, x) {
  4433. return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x && x[0] || 1) / 3);
  4434. }
  4435. });
  4436. ['Quad', 'Cubic', 'Quart', 'Quint'].each(function (transition, i) {
  4437. Fx.Transitions[transition] = new Fx.Transition(function (p) {
  4438. return Math.pow(p, i + 2);
  4439. });
  4440. });
  4441. /*
  4442. ---
  4443. name: Request
  4444. description: Powerful all purpose Request Class. Uses XMLHTTPRequest.
  4445. license: MIT-style license.
  4446. requires: [Object, Element, Chain, Events, Options, Browser]
  4447. provides: Request
  4448. ...
  4449. */
  4450. (function () {
  4451. var empty = function () { },
  4452. progressSupport = ('onprogress' in new Browser.Request);
  4453. var Request = this.Request = new Class({
  4454. Implements: [Chain, Events, Options],
  4455. options: {/*
  4456. onRequest: function(){},
  4457. onLoadstart: function(event, xhr){},
  4458. onProgress: function(event, xhr){},
  4459. onComplete: function(){},
  4460. onCancel: function(){},
  4461. onSuccess: function(responseText, responseXML){},
  4462. onFailure: function(xhr){},
  4463. onException: function(headerName, value){},
  4464. onTimeout: function(){},
  4465. user: '',
  4466. password: '',*/
  4467. url: '',
  4468. data: '',
  4469. headers: {
  4470. 'X-Requested-With': 'XMLHttpRequest',
  4471. 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
  4472. },
  4473. async: true,
  4474. format: false,
  4475. method: 'post',
  4476. link: 'ignore',
  4477. isSuccess: null,
  4478. emulation: true,
  4479. urlEncoded: true,
  4480. encoding: 'utf-8',
  4481. evalScripts: false,
  4482. evalResponse: false,
  4483. timeout: 0,
  4484. noCache: false
  4485. },
  4486. initialize: function (options) {
  4487. this.xhr = new Browser.Request();
  4488. this.setOptions(options);
  4489. this.headers = this.options.headers;
  4490. },
  4491. onStateChange: function () {
  4492. var xhr = this.xhr;
  4493. if (xhr.readyState != 4 || !this.running) return;
  4494. this.running = false;
  4495. this.status = 0;
  4496. Function.attempt(function () {
  4497. var status = xhr.status;
  4498. this.status = (status == 1223) ? 204 : status;
  4499. }.bind(this));
  4500. xhr.onreadystatechange = empty;
  4501. if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
  4502. clearTimeout(this.timer);
  4503. this.response = { text: this.xhr.responseText || '', xml: this.xhr.responseXML };
  4504. if (this.options.isSuccess.call(this, this.status))
  4505. this.success(this.response.text, this.response.xml);
  4506. else
  4507. this.failure();
  4508. },
  4509. isSuccess: function () {
  4510. var status = this.status;
  4511. return (status >= 200 && status < 300);
  4512. },
  4513. isRunning: function () {
  4514. return !!this.running;
  4515. },
  4516. processScripts: function (text) {
  4517. if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return Browser.exec(text);
  4518. return text.stripScripts(this.options.evalScripts);
  4519. },
  4520. success: function (text, xml) {
  4521. this.onSuccess(this.processScripts(text), xml);
  4522. },
  4523. onSuccess: function () {
  4524. this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain();
  4525. },
  4526. failure: function () {
  4527. this.onFailure();
  4528. },
  4529. onFailure: function () {
  4530. this.fireEvent('complete').fireEvent('failure', this.xhr);
  4531. },
  4532. loadstart: function (event) {
  4533. this.fireEvent('loadstart', [event, this.xhr]);
  4534. },
  4535. progress: function (event) {
  4536. this.fireEvent('progress', [event, this.xhr]);
  4537. },
  4538. timeout: function () {
  4539. this.fireEvent('timeout', this.xhr);
  4540. },
  4541. setHeader: function (name, value) {
  4542. this.headers[name] = value;
  4543. return this;
  4544. },
  4545. getHeader: function (name) {
  4546. return Function.attempt(function () {
  4547. return this.xhr.getResponseHeader(name);
  4548. }.bind(this));
  4549. },
  4550. check: function () {
  4551. if (!this.running) return true;
  4552. switch (this.options.link) {
  4553. case 'cancel': this.cancel(); return true;
  4554. case 'chain': this.chain(this.caller.pass(arguments, this)); return false;
  4555. }
  4556. return false;
  4557. },
  4558. send: function (options) {
  4559. if (!this.check(options)) return this;
  4560. this.options.isSuccess = this.options.isSuccess || this.isSuccess;
  4561. this.running = true;
  4562. var type = typeOf(options);
  4563. if (type == 'string' || type == 'element') options = { data: options };
  4564. var old = this.options;
  4565. options = Object.append({ data: old.data, url: old.url, method: old.method }, options);
  4566. var data = options.data, url = String(options.url), method = options.method.toLowerCase();
  4567. switch (typeOf(data)) {
  4568. case 'element': data = document.id(data).toQueryString(); break;
  4569. case 'object': case 'hash': data = Object.toQueryString(data);
  4570. }
  4571. if (this.options.format) {
  4572. var format = 'format=' + this.options.format;
  4573. data = (data) ? format + '&' + data : format;
  4574. }
  4575. if (this.options.emulation && !['get', 'post'].contains(method)) {
  4576. var _method = '_method=' + method;
  4577. data = (data) ? _method + '&' + data : _method;
  4578. method = 'post';
  4579. }
  4580. if (this.options.urlEncoded && ['post', 'put'].contains(method)) {
  4581. var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
  4582. this.headers['Content-type'] = 'application/x-www-form-urlencoded' + encoding;
  4583. }
  4584. if (!url) url = document.location.pathname;
  4585. var trimPosition = url.lastIndexOf('/');
  4586. if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
  4587. if (this.options.noCache)
  4588. url += (url.contains('?') ? '&' : '?') + String.uniqueID();
  4589. if (data && method == 'get') {
  4590. url += (url.contains('?') ? '&' : '?') + data;
  4591. data = null;
  4592. }
  4593. var xhr = this.xhr;
  4594. if (progressSupport) {
  4595. xhr.onloadstart = this.loadstart.bind(this);
  4596. xhr.onprogress = this.progress.bind(this);
  4597. }
  4598. xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password);
  4599. if (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true;
  4600. xhr.onreadystatechange = this.onStateChange.bind(this);
  4601. Object.each(this.headers, function (value, key) {
  4602. try {
  4603. xhr.setRequestHeader(key, value);
  4604. } catch (e) {
  4605. this.fireEvent('exception', [key, value]);
  4606. }
  4607. }, this);
  4608. this.fireEvent('request');
  4609. xhr.send(data);
  4610. if (!this.options.async) this.onStateChange();
  4611. else if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
  4612. return this;
  4613. },
  4614. cancel: function () {
  4615. if (!this.running) return this;
  4616. this.running = false;
  4617. var xhr = this.xhr;
  4618. xhr.abort();
  4619. clearTimeout(this.timer);
  4620. xhr.onreadystatechange = empty;
  4621. if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
  4622. this.xhr = new Browser.Request();
  4623. this.fireEvent('cancel');
  4624. return this;
  4625. }
  4626. });
  4627. var methods = {};
  4628. ['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function (method) {
  4629. methods[method] = function (data) {
  4630. var object = {
  4631. method: method
  4632. };
  4633. if (data != null) object.data = data;
  4634. return this.send(object);
  4635. };
  4636. });
  4637. Request.implement(methods);
  4638. Element.Properties.send = {
  4639. set: function (options) {
  4640. var send = this.get('send').cancel();
  4641. send.setOptions(options);
  4642. return this;
  4643. },
  4644. get: function () {
  4645. var send = this.retrieve('send');
  4646. if (!send) {
  4647. send = new Request({
  4648. data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')
  4649. });
  4650. this.store('send', send);
  4651. }
  4652. return send;
  4653. }
  4654. };
  4655. Element.implement({
  4656. send: function (url) {
  4657. var sender = this.get('send');
  4658. sender.send({ data: this, url: url || sender.options.url });
  4659. return this;
  4660. }
  4661. });
  4662. })();
  4663. /*
  4664. ---
  4665. name: Request.HTML
  4666. description: Extends the basic Request Class with additional methods for interacting with HTML responses.
  4667. license: MIT-style license.
  4668. requires: [Element, Request]
  4669. provides: Request.HTML
  4670. ...
  4671. */
  4672. Request.HTML = new Class({
  4673. Extends: Request,
  4674. options: {
  4675. update: false,
  4676. append: false,
  4677. evalScripts: true,
  4678. filter: false,
  4679. headers: {
  4680. Accept: 'text/html, application/xml, text/xml, */*'
  4681. }
  4682. },
  4683. success: function (text) {
  4684. var options = this.options, response = this.response;
  4685. response.html = text.stripScripts(function (script) {
  4686. response.javascript = script;
  4687. });
  4688. var match = response.html.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
  4689. if (match) response.html = match[1];
  4690. var temp = new Element('div').set('html', response.html);
  4691. response.tree = temp.childNodes;
  4692. response.elements = temp.getElements(options.filter || '*');
  4693. if (options.filter) response.tree = response.elements;
  4694. if (options.update) {
  4695. var update = document.id(options.update).empty();
  4696. if (options.filter) update.adopt(response.elements);
  4697. else update.set('html', response.html);
  4698. } else if (options.append) {
  4699. var append = document.id(options.append);
  4700. if (options.filter) response.elements.reverse().inject(append);
  4701. else append.adopt(temp.getChildren());
  4702. }
  4703. if (options.evalScripts) Browser.exec(response.javascript);
  4704. this.onSuccess(response.tree, response.elements, response.html, response.javascript);
  4705. }
  4706. });
  4707. Element.Properties.load = {
  4708. set: function (options) {
  4709. var load = this.get('load').cancel();
  4710. load.setOptions(options);
  4711. return this;
  4712. },
  4713. get: function () {
  4714. var load = this.retrieve('load');
  4715. if (!load) {
  4716. load = new Request.HTML({ data: this, link: 'cancel', update: this, method: 'get' });
  4717. this.store('load', load);
  4718. }
  4719. return load;
  4720. }
  4721. };
  4722. Element.implement({
  4723. load: function () {
  4724. this.get('load').send(Array.link(arguments, { data: Type.isObject, url: Type.isString }));
  4725. return this;
  4726. }
  4727. });
  4728. /*
  4729. ---
  4730. name: JSON
  4731. description: JSON encoder and decoder.
  4732. license: MIT-style license.
  4733. SeeAlso: <http://www.json.org/>
  4734. requires: [Array, String, Number, Function]
  4735. provides: JSON
  4736. ...
  4737. */
  4738. if (typeof JSON == 'undefined') this.JSON = {};
  4739. //<1.2compat>
  4740. JSON = new Hash({
  4741. stringify: JSON.stringify,
  4742. parse: JSON.parse
  4743. });
  4744. //</1.2compat>
  4745. (function () {
  4746. var special = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' };
  4747. var escape = function (chr) {
  4748. return special[chr] || '\\u' + ('0000' + chr.charCodeAt(0).toString(16)).slice(-4);
  4749. };
  4750. JSON.validate = function (string) {
  4751. string = string.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
  4752. replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
  4753. replace(/(?:^|:|,)(?:\s*\[)+/g, '');
  4754. return (/^[\],:{}\s]*$/).test(string);
  4755. };
  4756. JSON.encode = JSON.stringify ? function (obj) {
  4757. return JSON.stringify(obj);
  4758. } : function (obj) {
  4759. if (obj && obj.toJSON) obj = obj.toJSON();
  4760. switch (typeOf(obj)) {
  4761. case 'string':
  4762. return '"' + obj.replace(/[\x00-\x1f\\"]/g, escape) + '"';
  4763. case 'array':
  4764. return '[' + obj.map(JSON.encode).clean() + ']';
  4765. case 'object': case 'hash':
  4766. var string = [];
  4767. Object.each(obj, function (value, key) {
  4768. var json = JSON.encode(value);
  4769. if (json) string.push(JSON.encode(key) + ':' + json);
  4770. });
  4771. return '{' + string + '}';
  4772. case 'number': case 'boolean': return '' + obj;
  4773. case 'null': return 'null';
  4774. }
  4775. return null;
  4776. };
  4777. JSON.decode = function (string, secure) {
  4778. if (!string || typeOf(string) != 'string') return null;
  4779. if (secure || JSON.secure) {
  4780. if (JSON.parse) return JSON.parse(string);
  4781. if (!JSON.validate(string)) throw new Error('JSON could not decode the input; security is enabled and the value is not secure.');
  4782. }
  4783. return eval('(' + string + ')');
  4784. };
  4785. })();
  4786. /*
  4787. ---
  4788. name: Request.JSON
  4789. description: Extends the basic Request Class with additional methods for sending and receiving JSON data.
  4790. license: MIT-style license.
  4791. requires: [Request, JSON]
  4792. provides: Request.JSON
  4793. ...
  4794. */
  4795. Request.JSON = new Class({
  4796. Extends: Request,
  4797. options: {
  4798. /*onError: function(text, error){},*/
  4799. secure: true
  4800. },
  4801. initialize: function (options) {
  4802. this.parent(options);
  4803. Object.append(this.headers, {
  4804. 'Accept': 'application/json',
  4805. 'X-Request': 'JSON'
  4806. });
  4807. },
  4808. success: function (text) {
  4809. var json;
  4810. try {
  4811. json = this.response.json = JSON.decode(text, this.options.secure);
  4812. } catch (error) {
  4813. this.fireEvent('error', [text, error]);
  4814. return;
  4815. }
  4816. if (json == null) this.onFailure();
  4817. else this.onSuccess(json, text);
  4818. }
  4819. });
  4820. /*
  4821. ---
  4822. name: Cookie
  4823. description: Class for creating, reading, and deleting browser Cookies.
  4824. license: MIT-style license.
  4825. credits:
  4826. - Based on the functions by Peter-Paul Koch (http://quirksmode.org).
  4827. requires: [Options, Browser]
  4828. provides: Cookie
  4829. ...
  4830. */
  4831. var Cookie = new Class({
  4832. Implements: Options,
  4833. options: {
  4834. path: '/',
  4835. domain: false,
  4836. duration: false,
  4837. secure: false,
  4838. document: document,
  4839. encode: true
  4840. },
  4841. initialize: function (key, options) {
  4842. this.key = key;
  4843. this.setOptions(options);
  4844. },
  4845. write: function (value) {
  4846. if (this.options.encode) value = encodeURIComponent(value);
  4847. if (this.options.domain) value += '; domain=' + this.options.domain;
  4848. if (this.options.path) value += '; path=' + this.options.path;
  4849. if (this.options.duration) {
  4850. var date = new Date();
  4851. date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000);
  4852. value += '; expires=' + date.toGMTString();
  4853. }
  4854. if (this.options.secure) value += '; secure';
  4855. this.options.document.cookie = this.key + '=' + value;
  4856. return this;
  4857. },
  4858. read: function () {
  4859. var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)');
  4860. return (value) ? decodeURIComponent(value[1]) : null;
  4861. },
  4862. dispose: function () {
  4863. new Cookie(this.key, Object.merge({}, this.options, { duration: -1 })).write('');
  4864. return this;
  4865. }
  4866. });
  4867. Cookie.write = function (key, value, options) {
  4868. return new Cookie(key, options).write(value);
  4869. };
  4870. Cookie.read = function (key) {
  4871. return new Cookie(key).read();
  4872. };
  4873. Cookie.dispose = function (key, options) {
  4874. return new Cookie(key, options).dispose();
  4875. };
  4876. /*
  4877. ---
  4878. name: DOMReady
  4879. description: Contains the custom event domready.
  4880. license: MIT-style license.
  4881. requires: [Browser, Element, Element.Event]
  4882. provides: [DOMReady, DomReady]
  4883. ...
  4884. */
  4885. (function (window, document) {
  4886. var ready,
  4887. loaded,
  4888. checks = [],
  4889. shouldPoll,
  4890. timer,
  4891. testElement = document.createElement('div');
  4892. var domready = function () {
  4893. clearTimeout(timer);
  4894. if (ready) return;
  4895. Browser.loaded = ready = true;
  4896. document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check);
  4897. document.fireEvent('domready');
  4898. window.fireEvent('domready');
  4899. };
  4900. var check = function () {
  4901. for (var i = checks.length; i--;) if (checks[i]()) {
  4902. domready();
  4903. return true;
  4904. }
  4905. return false;
  4906. };
  4907. var poll = function () {
  4908. clearTimeout(timer);
  4909. if (!check()) timer = setTimeout(poll, 10);
  4910. };
  4911. document.addListener('DOMContentLoaded', domready);
  4912. /*<ltIE8>*/
  4913. // doScroll technique by Diego Perini http://javascript.nwbox.com/IEContentLoaded/
  4914. // testElement.doScroll() throws when the DOM is not ready, only in the top window
  4915. var doScrollWorks = function () {
  4916. try {
  4917. testElement.doScroll();
  4918. return true;
  4919. } catch (e) { }
  4920. return false;
  4921. };
  4922. // If doScroll works already, it can't be used to determine domready
  4923. // e.g. in an iframe
  4924. if (testElement.doScroll && !doScrollWorks()) {
  4925. checks.push(doScrollWorks);
  4926. shouldPoll = true;
  4927. }
  4928. /*</ltIE8>*/
  4929. if (document.readyState) checks.push(function () {
  4930. var state = document.readyState;
  4931. return (state == 'loaded' || state == 'complete');
  4932. });
  4933. if ('onreadystatechange' in document) document.addListener('readystatechange', check);
  4934. else shouldPoll = true;
  4935. if (shouldPoll) poll();
  4936. Element.Events.domready = {
  4937. onAdd: function (fn) {
  4938. if (ready) fn.call(this);
  4939. }
  4940. };
  4941. // Make sure that domready fires before load
  4942. Element.Events.load = {
  4943. base: 'load',
  4944. onAdd: function (fn) {
  4945. if (loaded && this == window) fn.call(this);
  4946. },
  4947. condition: function () {
  4948. if (this == window) {
  4949. domready();
  4950. delete Element.Events.load;
  4951. }
  4952. return true;
  4953. }
  4954. };
  4955. // This is based on the custom load event
  4956. window.addEvent('load', function () {
  4957. loaded = true;
  4958. });
  4959. })(window, document);
  4960. /*
  4961. ---
  4962. name: Swiff
  4963. description: Wrapper for embedding SWF movies. Supports External Interface Communication.
  4964. license: MIT-style license.
  4965. credits:
  4966. - Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.
  4967. requires: [Options, Object, Element]
  4968. provides: Swiff
  4969. ...
  4970. */
  4971. (function () {
  4972. var Swiff = this.Swiff = new Class({
  4973. Implements: Options,
  4974. options: {
  4975. id: null,
  4976. height: 1,
  4977. width: 1,
  4978. container: null,
  4979. properties: {},
  4980. params: {
  4981. quality: 'high',
  4982. allowScriptAccess: 'always',
  4983. wMode: 'window',
  4984. swLiveConnect: true
  4985. },
  4986. callBacks: {},
  4987. vars: {}
  4988. },
  4989. toElement: function () {
  4990. return this.object;
  4991. },
  4992. initialize: function (path, options) {
  4993. this.instance = 'Swiff_' + String.uniqueID();
  4994. this.setOptions(options);
  4995. options = this.options;
  4996. var id = this.id = options.id || this.instance;
  4997. var container = document.id(options.container);
  4998. Swiff.CallBacks[this.instance] = {};
  4999. var params = options.params, vars = options.vars, callBacks = options.callBacks;
  5000. var properties = Object.append({ height: options.height, width: options.width }, options.properties);
  5001. var self = this;
  5002. for (var callBack in callBacks) {
  5003. Swiff.CallBacks[this.instance][callBack] = (function (option) {
  5004. return function () {
  5005. return option.apply(self.object, arguments);
  5006. };
  5007. })(callBacks[callBack]);
  5008. vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;
  5009. }
  5010. params.flashVars = Object.toQueryString(vars);
  5011. if (Browser.ie) {
  5012. properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
  5013. params.movie = path;
  5014. } else {
  5015. properties.type = 'application/x-shockwave-flash';
  5016. }
  5017. properties.data = path;
  5018. var build = '<object id="' + id + '"';
  5019. for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';
  5020. build += '>';
  5021. for (var param in params) {
  5022. if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';
  5023. }
  5024. build += '</object>';
  5025. this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;
  5026. },
  5027. replaces: function (element) {
  5028. element = document.id(element, true);
  5029. element.parentNode.replaceChild(this.toElement(), element);
  5030. return this;
  5031. },
  5032. inject: function (element) {
  5033. document.id(element, true).appendChild(this.toElement());
  5034. return this;
  5035. },
  5036. remote: function () {
  5037. return Swiff.remote.apply(Swiff, [this.toElement()].append(arguments));
  5038. }
  5039. });
  5040. Swiff.CallBacks = {};
  5041. Swiff.remote = function (obj, fn) {
  5042. var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');
  5043. return eval(rs);
  5044. };
  5045. })();