mootools.js 142 KB

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