MyInfusion.js 772 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151
  1. /*
  2. * Licensed to Jasig under one or more contributor license
  3. * agreements. See the NOTICE file distributed with this work
  4. * for additional information regarding copyright ownership.
  5. * Jasig licenses this file to you under the Apache License,
  6. * Version 2.0 (the "License"); you may not use this file
  7. * except in compliance with the License. You may obtain a
  8. * copy of the License at the following location:
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. (function (window, undefined) {
  20. var document = window.document,
  21. navigator = window.navigator,
  22. location = window.location;
  23. var jQuery = (function () {
  24. var jQuery = function (selector, context) {
  25. return new jQuery.fn.init(selector, context, rootjQuery)
  26. },
  27. _jQuery = window.jQuery,
  28. _$ = window.$,
  29. rootjQuery,
  30. quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
  31. rnotwhite = /\S/,
  32. trimLeft = /^\s+/,
  33. trimRight = /\s+$/,
  34. rdigit = /\d/,
  35. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  36. rvalidchars = /^[\],:{}\s]*$/,
  37. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  38. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  39. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  40. rwebkit = /(webkit)[ \/]([\w.]+)/,
  41. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  42. rmsie = /(msie) ([\w.]+)/,
  43. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  44. userAgent = navigator.userAgent,
  45. browserMatch,
  46. readyList,
  47. DOMContentLoaded,
  48. toString = Object.prototype.toString,
  49. hasOwn = Object.prototype.hasOwnProperty,
  50. push = Array.prototype.push,
  51. slice = Array.prototype.slice,
  52. trim = String.prototype.trim,
  53. indexOf = Array.prototype.indexOf,
  54. class2type = {};
  55. jQuery.fn = jQuery.prototype = {
  56. constructor : jQuery,
  57. init : function (selector, context, rootjQuery) {
  58. var match,
  59. elem,
  60. ret,
  61. doc;
  62. if (!selector) {
  63. return this
  64. }
  65. if (selector.nodeType) {
  66. this.context = this[0] = selector;
  67. this.length = 1;
  68. return this
  69. }
  70. if (selector === "body" && !context && document.body) {
  71. this.context = document;
  72. this[0] = document.body;
  73. this.selector = selector;
  74. this.length = 1;
  75. return this
  76. }
  77. if (typeof selector === "string") {
  78. if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
  79. match = [null, selector, null]
  80. } else {
  81. match = quickExpr.exec(selector)
  82. }
  83. if (match && (match[1] || !context)) {
  84. if (match[1]) {
  85. context = context instanceof jQuery ? context[0] : context;
  86. doc = (context ? context.ownerDocument || context : document);
  87. ret = rsingleTag.exec(selector);
  88. if (ret) {
  89. if (jQuery.isPlainObject(context)) {
  90. selector = [document.createElement(ret[1])];
  91. jQuery.fn.attr.call(selector, context, true)
  92. } else {
  93. selector = [doc.createElement(ret[1])]
  94. }
  95. } else {
  96. ret = jQuery.buildFragment([match[1]], [doc]);
  97. selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes
  98. }
  99. return jQuery.merge(this, selector)
  100. } else {
  101. elem = document.getElementById(match[2]);
  102. if (elem && elem.parentNode) {
  103. if (elem.id !== match[2]) {
  104. return rootjQuery.find(selector)
  105. }
  106. this.length = 1;
  107. this[0] = elem
  108. }
  109. this.context = document;
  110. this.selector = selector;
  111. return this
  112. }
  113. } else {
  114. if (!context || context.jquery) {
  115. return (context || rootjQuery).find(selector)
  116. } else {
  117. return this.constructor(context).find(selector)
  118. }
  119. }
  120. } else {
  121. if (jQuery.isFunction(selector)) {
  122. return rootjQuery.ready(selector)
  123. }
  124. }
  125. if (selector.selector !== undefined) {
  126. this.selector = selector.selector;
  127. this.context = selector.context
  128. }
  129. return jQuery.makeArray(selector, this)
  130. },
  131. selector : "",
  132. jquery : "1.6.1",
  133. length : 0,
  134. size : function () {
  135. return this.length
  136. },
  137. toArray : function () {
  138. return slice.call(this, 0)
  139. },
  140. get : function (num) {
  141. return num == null ? this.toArray() : (num < 0 ? this[this.length + num] : this[num])
  142. },
  143. pushStack : function (elems, name, selector) {
  144. var ret = this.constructor();
  145. if (jQuery.isArray(elems)) {
  146. push.apply(ret, elems)
  147. } else {
  148. jQuery.merge(ret, elems)
  149. }
  150. ret.prevObject = this;
  151. ret.context = this.context;
  152. if (name === "find") {
  153. ret.selector = this.selector + (this.selector ? " " : "") + selector
  154. } else {
  155. if (name) {
  156. ret.selector = this.selector + "." + name + "(" + selector + ")"
  157. }
  158. }
  159. return ret
  160. },
  161. each : function (callback, args) {
  162. return jQuery.each(this, callback, args)
  163. },
  164. ready : function (fn) {
  165. jQuery.bindReady();
  166. readyList.done(fn);
  167. return this
  168. },
  169. eq : function (i) {
  170. return i === -1 ? this.slice(i) : this.slice(i, +i + 1)
  171. },
  172. first : function () {
  173. return this.eq(0)
  174. },
  175. last : function () {
  176. return this.eq(-1)
  177. },
  178. slice : function () {
  179. return this.pushStack(slice.apply(this, arguments), "slice", slice.call(arguments).join(","))
  180. },
  181. map : function (callback) {
  182. return this.pushStack(jQuery.map(this, function (elem, i) {
  183. return callback.call(elem, i, elem)
  184. }))
  185. },
  186. end : function () {
  187. return this.prevObject || this.constructor(null)
  188. },
  189. push : push,
  190. sort : [].sort,
  191. splice : [].splice
  192. };
  193. jQuery.fn.init.prototype = jQuery.fn;
  194. jQuery.extend = jQuery.fn.extend = function () {
  195. var options,
  196. name,
  197. src,
  198. copy,
  199. copyIsArray,
  200. clone,
  201. target = arguments[0] || {},
  202. i = 1,
  203. length = arguments.length,
  204. deep = false;
  205. if (typeof target === "boolean") {
  206. deep = target;
  207. target = arguments[1] || {};
  208. i = 2
  209. }
  210. if (typeof target !== "object" && !jQuery.isFunction(target)) {
  211. target = {}
  212. }
  213. if (length === i) {
  214. target = this;
  215. --i
  216. }
  217. for (; i < length; i++) {
  218. if ((options = arguments[i]) != null) {
  219. for (name in options) {
  220. src = target[name];
  221. copy = options[name];
  222. if (target === copy) {
  223. continue
  224. }
  225. if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) {
  226. if (copyIsArray) {
  227. copyIsArray = false;
  228. clone = src && jQuery.isArray(src) ? src : []
  229. } else {
  230. clone = src && jQuery.isPlainObject(src) ? src : {}
  231. }
  232. target[name] = jQuery.extend(deep, clone, copy)
  233. } else {
  234. if (copy !== undefined) {
  235. target[name] = copy
  236. }
  237. }
  238. }
  239. }
  240. }
  241. return target
  242. };
  243. jQuery.extend({
  244. noConflict : function (deep) {
  245. if (window.$ === jQuery) {
  246. window.$ = _$
  247. }
  248. if (deep && window.jQuery === jQuery) {
  249. window.jQuery = _jQuery
  250. }
  251. return jQuery
  252. },
  253. isReady : false,
  254. readyWait : 1,
  255. holdReady : function (hold) {
  256. if (hold) {
  257. jQuery.readyWait++
  258. } else {
  259. jQuery.ready(true)
  260. }
  261. },
  262. ready : function (wait) {
  263. if ((wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady)) {
  264. if (!document.body) {
  265. return setTimeout(jQuery.ready, 1)
  266. }
  267. jQuery.isReady = true;
  268. if (wait !== true && --jQuery.readyWait > 0) {
  269. return
  270. }
  271. readyList.resolveWith(document, [jQuery]);
  272. if (jQuery.fn.trigger) {
  273. jQuery(document).trigger("ready").unbind("ready")
  274. }
  275. }
  276. },
  277. bindReady : function () {
  278. if (readyList) {
  279. return
  280. }
  281. readyList = jQuery._Deferred();
  282. if (document.readyState === "complete") {
  283. return setTimeout(jQuery.ready, 1)
  284. }
  285. if (document.addEventListener) {
  286. document.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
  287. window.addEventListener("load", jQuery.ready, false)
  288. } else {
  289. if (document.attachEvent) {
  290. document.attachEvent("onreadystatechange", DOMContentLoaded);
  291. window.attachEvent("onload", jQuery.ready);
  292. var toplevel = false;
  293. try {
  294. toplevel = window.frameElement == null
  295. } catch (e) {}
  296. if (document.documentElement.doScroll && toplevel) {
  297. doScrollCheck()
  298. }
  299. }
  300. }
  301. },
  302. isFunction : function (obj) {
  303. return jQuery.type(obj) === "function"
  304. },
  305. isArray : Array.isArray || function (obj) {
  306. return jQuery.type(obj) === "array"
  307. },
  308. isWindow : function (obj) {
  309. return obj && typeof obj === "object" && "setInterval" in obj
  310. },
  311. isNaN : function (obj) {
  312. return obj == null || !rdigit.test(obj) || isNaN(obj)
  313. },
  314. type : function (obj) {
  315. return obj == null ? String(obj) : class2type[toString.call(obj)] || "object"
  316. },
  317. isPlainObject : function (obj) {
  318. if (!obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) {
  319. return false
  320. }
  321. if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
  322. return false
  323. }
  324. var key;
  325. for (key in obj) {}
  326. return key === undefined || hasOwn.call(obj, key)
  327. },
  328. isEmptyObject : function (obj) {
  329. for (var name in obj) {
  330. return false
  331. }
  332. return true
  333. },
  334. error : function (msg) {
  335. throw msg
  336. },
  337. parseJSON : function (data) {
  338. if (typeof data !== "string" || !data) {
  339. return null
  340. }
  341. data = jQuery.trim(data);
  342. if (window.JSON && window.JSON.parse) {
  343. return window.JSON.parse(data)
  344. }
  345. if (rvalidchars.test(data.replace(rvalidescape, "@").replace(rvalidtokens, "]").replace(rvalidbraces, ""))) {
  346. return (new Function("return " + data))()
  347. }
  348. jQuery.error("Invalid JSON: " + data)
  349. },
  350. parseXML : function (data, xml, tmp) {
  351. if (window.DOMParser) {
  352. tmp = new DOMParser();
  353. xml = tmp.parseFromString(data, "text/xml")
  354. } else {
  355. xml = new ActiveXObject("Microsoft.XMLDOM");
  356. xml.async = "false";
  357. xml.loadXML(data)
  358. }
  359. tmp = xml.documentElement;
  360. if (!tmp || !tmp.nodeName || tmp.nodeName === "parsererror") {
  361. jQuery.error("Invalid XML: " + data)
  362. }
  363. return xml
  364. },
  365. noop : function () {},
  366. globalEval : function (data) {
  367. if (data && rnotwhite.test(data)) {
  368. (window.execScript || function (data) {
  369. window.eval.call(window, data)
  370. })(data)
  371. }
  372. },
  373. nodeName : function (elem, name) {
  374. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase()
  375. },
  376. each : function (object, callback, args) {
  377. var name,
  378. i = 0,
  379. length = object.length,
  380. isObj = length === undefined || jQuery.isFunction(object);
  381. if (args) {
  382. if (isObj) {
  383. for (name in object) {
  384. if (callback.apply(object[name], args) === false) {
  385. break
  386. }
  387. }
  388. } else {
  389. for (; i < length; ) {
  390. if (callback.apply(object[i++], args) === false) {
  391. break
  392. }
  393. }
  394. }
  395. } else {
  396. if (isObj) {
  397. for (name in object) {
  398. if (callback.call(object[name], name, object[name]) === false) {
  399. break
  400. }
  401. }
  402. } else {
  403. for (; i < length; ) {
  404. if (callback.call(object[i], i, object[i++]) === false) {
  405. break
  406. }
  407. }
  408. }
  409. }
  410. return object
  411. },
  412. trim : trim ? function (text) {
  413. return text == null ? "" : trim.call(text)
  414. }
  415. : function (text) {
  416. return text == null ? "" : text.toString().replace(trimLeft, "").replace(trimRight, "")
  417. },
  418. makeArray : function (array, results) {
  419. var ret = results || [];
  420. if (array != null) {
  421. var type = jQuery.type(array);
  422. if (array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow(array)) {
  423. push.call(ret, array)
  424. } else {
  425. jQuery.merge(ret, array)
  426. }
  427. }
  428. return ret
  429. },
  430. inArray : function (elem, array) {
  431. if (indexOf) {
  432. return indexOf.call(array, elem)
  433. }
  434. for (var i = 0, length = array.length; i < length; i++) {
  435. if (array[i] === elem) {
  436. return i
  437. }
  438. }
  439. return -1
  440. },
  441. merge : function (first, second) {
  442. var i = first.length,
  443. j = 0;
  444. if (typeof second.length === "number") {
  445. for (var l = second.length; j < l; j++) {
  446. first[i++] = second[j]
  447. }
  448. } else {
  449. while (second[j] !== undefined) {
  450. first[i++] = second[j++]
  451. }
  452. }
  453. first.length = i;
  454. return first
  455. },
  456. grep : function (elems, callback, inv) {
  457. var ret = [],
  458. retVal;
  459. inv = !!inv;
  460. for (var i = 0, length = elems.length; i < length; i++) {
  461. retVal = !!callback(elems[i], i);
  462. if (inv !== retVal) {
  463. ret.push(elems[i])
  464. }
  465. }
  466. return ret
  467. },
  468. map : function (elems, callback, arg) {
  469. var value,
  470. key,
  471. ret = [],
  472. i = 0,
  473. length = elems.length,
  474. isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ((length > 0 && elems[0] && elems[length - 1]) || length === 0 || jQuery.isArray(elems));
  475. if (isArray) {
  476. for (; i < length; i++) {
  477. value = callback(elems[i], i, arg);
  478. if (value != null) {
  479. ret[ret.length] = value
  480. }
  481. }
  482. } else {
  483. for (key in elems) {
  484. value = callback(elems[key], key, arg);
  485. if (value != null) {
  486. ret[ret.length] = value
  487. }
  488. }
  489. }
  490. return ret.concat.apply([], ret)
  491. },
  492. guid : 1,
  493. proxy : function (fn, context) {
  494. if (typeof context === "string") {
  495. var tmp = fn[context];
  496. context = fn;
  497. fn = tmp
  498. }
  499. if (!jQuery.isFunction(fn)) {
  500. return undefined
  501. }
  502. var args = slice.call(arguments, 2),
  503. proxy = function () {
  504. return fn.apply(context, args.concat(slice.call(arguments)))
  505. };
  506. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  507. return proxy
  508. },
  509. access : function (elems, key, value, exec, fn, pass) {
  510. var length = elems.length;
  511. if (typeof key === "object") {
  512. for (var k in key) {
  513. jQuery.access(elems, k, key[k], exec, fn, value)
  514. }
  515. return elems
  516. }
  517. if (value !== undefined) {
  518. exec = !pass && exec && jQuery.isFunction(value);
  519. for (var i = 0; i < length; i++) {
  520. fn(elems[i], key, exec ? value.call(elems[i], i, fn(elems[i], key)) : value, pass)
  521. }
  522. return elems
  523. }
  524. return length ? fn(elems[0], key) : undefined
  525. },
  526. now : function () {
  527. return (new Date()).getTime()
  528. },
  529. uaMatch : function (ua) {
  530. ua = ua.toLowerCase();
  531. var match = rwebkit.exec(ua) || ropera.exec(ua) || rmsie.exec(ua) || ua.indexOf("compatible") < 0 && rmozilla.exec(ua) || [];
  532. return {
  533. browser : match[1] || "",
  534. version : match[2] || "0"
  535. }
  536. },
  537. sub : function () {
  538. function jQuerySub(selector, context) {
  539. return new jQuerySub.fn.init(selector, context)
  540. }
  541. jQuery.extend(true, jQuerySub, this);
  542. jQuerySub.superclass = this;
  543. jQuerySub.fn = jQuerySub.prototype = this();
  544. jQuerySub.fn.constructor = jQuerySub;
  545. jQuerySub.sub = this.sub;
  546. jQuerySub.fn.init = function init(selector, context) {
  547. if (context && context instanceof jQuery && !(context instanceof jQuerySub)) {
  548. context = jQuerySub(context)
  549. }
  550. return jQuery.fn.init.call(this, selector, context, rootjQuerySub)
  551. };
  552. jQuerySub.fn.init.prototype = jQuerySub.fn;
  553. var rootjQuerySub = jQuerySub(document);
  554. return jQuerySub
  555. },
  556. browser : {}
  557. });
  558. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function (i, name) {
  559. class2type["[object " + name + "]"] = name.toLowerCase()
  560. });
  561. browserMatch = jQuery.uaMatch(userAgent);
  562. if (browserMatch.browser) {
  563. jQuery.browser[browserMatch.browser] = true;
  564. jQuery.browser.version = browserMatch.version
  565. }
  566. if (jQuery.browser.webkit) {
  567. jQuery.browser.safari = true
  568. }
  569. if (rnotwhite.test("\xA0")) {
  570. trimLeft = /^[\s\xA0]+/;
  571. trimRight = /[\s\xA0]+$/
  572. }
  573. rootjQuery = jQuery(document);
  574. if (document.addEventListener) {
  575. DOMContentLoaded = function () {
  576. document.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
  577. jQuery.ready()
  578. }
  579. } else {
  580. if (document.attachEvent) {
  581. DOMContentLoaded = function () {
  582. if (document.readyState === "complete") {
  583. document.detachEvent("onreadystatechange", DOMContentLoaded);
  584. jQuery.ready()
  585. }
  586. }
  587. }
  588. }
  589. function doScrollCheck() {
  590. if (jQuery.isReady) {
  591. return
  592. }
  593. try {
  594. document.documentElement.doScroll("left")
  595. } catch (e) {
  596. setTimeout(doScrollCheck, 1);
  597. return
  598. }
  599. jQuery.ready()
  600. }
  601. return jQuery
  602. })();
  603. var promiseMethods = "done fail isResolved isRejected promise then always pipe".split(" "),
  604. sliceDeferred = [].slice;
  605. jQuery.extend({
  606. _Deferred : function () {
  607. var callbacks = [],
  608. fired,
  609. firing,
  610. cancelled,
  611. deferred = {
  612. done : function () {
  613. if (!cancelled) {
  614. var args = arguments,
  615. i,
  616. length,
  617. elem,
  618. type,
  619. _fired;
  620. if (fired) {
  621. _fired = fired;
  622. fired = 0
  623. }
  624. for (i = 0, length = args.length; i < length; i++) {
  625. elem = args[i];
  626. type = jQuery.type(elem);
  627. if (type === "array") {
  628. deferred.done.apply(deferred, elem)
  629. } else {
  630. if (type === "function") {
  631. callbacks.push(elem)
  632. }
  633. }
  634. }
  635. if (_fired) {
  636. deferred.resolveWith(_fired[0], _fired[1])
  637. }
  638. }
  639. return this
  640. },
  641. resolveWith : function (context, args) {
  642. if (!cancelled && !fired && !firing) {
  643. args = args || [];
  644. firing = 1;
  645. try {
  646. while (callbacks[0]) {
  647. callbacks.shift().apply(context, args)
  648. }
  649. }
  650. finally {
  651. fired = [context, args];
  652. firing = 0
  653. }
  654. }
  655. return this
  656. },
  657. resolve : function () {
  658. deferred.resolveWith(this, arguments);
  659. return this
  660. },
  661. isResolved : function () {
  662. return !!(firing || fired)
  663. },
  664. cancel : function () {
  665. cancelled = 1;
  666. callbacks = [];
  667. return this
  668. }
  669. };
  670. return deferred
  671. },
  672. Deferred : function (func) {
  673. var deferred = jQuery._Deferred(),
  674. failDeferred = jQuery._Deferred(),
  675. promise;
  676. jQuery.extend(deferred, {
  677. then : function (doneCallbacks, failCallbacks) {
  678. deferred.done(doneCallbacks).fail(failCallbacks);
  679. return this
  680. },
  681. always : function () {
  682. return deferred.done.apply(deferred, arguments).fail.apply(this, arguments)
  683. },
  684. fail : failDeferred.done,
  685. rejectWith : failDeferred.resolveWith,
  686. reject : failDeferred.resolve,
  687. isRejected : failDeferred.isResolved,
  688. pipe : function (fnDone, fnFail) {
  689. return jQuery.Deferred(function (newDefer) {
  690. jQuery.each({
  691. done : [fnDone, "resolve"],
  692. fail : [fnFail, "reject"]
  693. }, function (handler, data) {
  694. var fn = data[0],
  695. action = data[1],
  696. returned;
  697. if (jQuery.isFunction(fn)) {
  698. deferred[handler](function () {
  699. returned = fn.apply(this, arguments);
  700. if (returned && jQuery.isFunction(returned.promise)) {
  701. returned.promise().then(newDefer.resolve, newDefer.reject)
  702. } else {
  703. newDefer[action](returned)
  704. }
  705. })
  706. } else {
  707. deferred[handler](newDefer[action])
  708. }
  709. })
  710. }).promise()
  711. },
  712. promise : function (obj) {
  713. if (obj == null) {
  714. if (promise) {
  715. return promise
  716. }
  717. promise = obj = {}
  718. }
  719. var i = promiseMethods.length;
  720. while (i--) {
  721. obj[promiseMethods[i]] = deferred[promiseMethods[i]]
  722. }
  723. return obj
  724. }
  725. });
  726. deferred.done(failDeferred.cancel).fail(deferred.cancel);
  727. delete deferred.cancel;
  728. if (func) {
  729. func.call(deferred, deferred)
  730. }
  731. return deferred
  732. },
  733. when : function (firstParam) {
  734. var args = arguments,
  735. i = 0,
  736. length = args.length,
  737. count = length,
  738. deferred = length <= 1 && firstParam && jQuery.isFunction(firstParam.promise) ? firstParam : jQuery.Deferred();
  739. function resolveFunc(i) {
  740. return function (value) {
  741. args[i] = arguments.length > 1 ? sliceDeferred.call(arguments, 0) : value;
  742. if (!(--count)) {
  743. deferred.resolveWith(deferred, sliceDeferred.call(args, 0))
  744. }
  745. }
  746. }
  747. if (length > 1) {
  748. for (; i < length; i++) {
  749. if (args[i] && jQuery.isFunction(args[i].promise)) {
  750. args[i].promise().then(resolveFunc(i), deferred.reject)
  751. } else {
  752. --count
  753. }
  754. }
  755. if (!count) {
  756. deferred.resolveWith(deferred, args)
  757. }
  758. } else {
  759. if (deferred !== firstParam) {
  760. deferred.resolveWith(deferred, length ? [firstParam] : [])
  761. }
  762. }
  763. return deferred.promise()
  764. }
  765. });
  766. jQuery.support = (function () {
  767. var div = document.createElement("div"),
  768. documentElement = document.documentElement,
  769. all,
  770. a,
  771. select,
  772. opt,
  773. input,
  774. marginDiv,
  775. support,
  776. fragment,
  777. body,
  778. bodyStyle,
  779. tds,
  780. events,
  781. eventName,
  782. i,
  783. isSupported;
  784. div.setAttribute("className", "t");
  785. div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  786. all = div.getElementsByTagName("*");
  787. a = div.getElementsByTagName("a")[0];
  788. if (!all || !all.length || !a) {
  789. return {}
  790. }
  791. select = document.createElement("select");
  792. opt = select.appendChild(document.createElement("option"));
  793. input = div.getElementsByTagName("input")[0];
  794. support = {
  795. leadingWhitespace : (div.firstChild.nodeType === 3),
  796. tbody : !div.getElementsByTagName("tbody").length,
  797. htmlSerialize : !!div.getElementsByTagName("link").length,
  798. style : /top/.test(a.getAttribute("style")),
  799. hrefNormalized : (a.getAttribute("href") === "/a"),
  800. opacity : /^0.55$/.test(a.style.opacity),
  801. cssFloat : !!a.style.cssFloat,
  802. checkOn : (input.value === "on"),
  803. optSelected : opt.selected,
  804. getSetAttribute : div.className !== "t",
  805. submitBubbles : true,
  806. changeBubbles : true,
  807. focusinBubbles : false,
  808. deleteExpando : true,
  809. noCloneEvent : true,
  810. inlineBlockNeedsLayout : false,
  811. shrinkWrapBlocks : false,
  812. reliableMarginRight : true
  813. };
  814. input.checked = true;
  815. support.noCloneChecked = input.cloneNode(true).checked;
  816. select.disabled = true;
  817. support.optDisabled = !opt.disabled;
  818. try {
  819. delete div.test
  820. } catch (e) {
  821. support.deleteExpando = false
  822. }
  823. if (!div.addEventListener && div.attachEvent && div.fireEvent) {
  824. div.attachEvent("onclick", function click() {
  825. support.noCloneEvent = false;
  826. div.detachEvent("onclick", click)
  827. });
  828. div.cloneNode(true).fireEvent("onclick")
  829. }
  830. input = document.createElement("input");
  831. input.value = "t";
  832. input.setAttribute("type", "radio");
  833. support.radioValue = input.value === "t";
  834. input.setAttribute("checked", "checked");
  835. div.appendChild(input);
  836. fragment = document.createDocumentFragment();
  837. fragment.appendChild(div.firstChild);
  838. support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
  839. div.innerHTML = "";
  840. div.style.width = div.style.paddingLeft = "1px";
  841. body = document.createElement("body");
  842. bodyStyle = {
  843. visibility : "hidden",
  844. width : 0,
  845. height : 0,
  846. border : 0,
  847. margin : 0,
  848. background : "none"
  849. };
  850. for (i in bodyStyle) {
  851. body.style[i] = bodyStyle[i]
  852. }
  853. body.appendChild(div);
  854. documentElement.insertBefore(body, documentElement.firstChild);
  855. support.appendChecked = input.checked;
  856. support.boxModel = div.offsetWidth === 2;
  857. if ("zoom" in div.style) {
  858. div.style.display = "inline";
  859. div.style.zoom = 1;
  860. support.inlineBlockNeedsLayout = (div.offsetWidth === 2);
  861. div.style.display = "";
  862. div.innerHTML = "<div style='width:4px;'></div>";
  863. support.shrinkWrapBlocks = (div.offsetWidth !== 2)
  864. }
  865. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  866. tds = div.getElementsByTagName("td");
  867. isSupported = (tds[0].offsetHeight === 0);
  868. tds[0].style.display = "";
  869. tds[1].style.display = "none";
  870. support.reliableHiddenOffsets = isSupported && (tds[0].offsetHeight === 0);
  871. div.innerHTML = "";
  872. if (document.defaultView && document.defaultView.getComputedStyle) {
  873. marginDiv = document.createElement("div");
  874. marginDiv.style.width = "0";
  875. marginDiv.style.marginRight = "0";
  876. div.appendChild(marginDiv);
  877. support.reliableMarginRight = (parseInt((document.defaultView.getComputedStyle(marginDiv, null) || {
  878. marginRight : 0
  879. }).marginRight, 10) || 0) === 0
  880. }
  881. body.innerHTML = "";
  882. documentElement.removeChild(body);
  883. if (div.attachEvent) {
  884. for (i in {
  885. submit : 1,
  886. change : 1,
  887. focusin : 1
  888. }) {
  889. eventName = "on" + i;
  890. isSupported = (eventName in div);
  891. if (!isSupported) {
  892. div.setAttribute(eventName, "return;");
  893. isSupported = (typeof div[eventName] === "function")
  894. }
  895. support[i + "Bubbles"] = isSupported
  896. }
  897. }
  898. return support
  899. })();
  900. jQuery.boxModel = jQuery.support.boxModel;
  901. var rbrace = /^(?:\{.*\}|\[.*\])$/,
  902. rmultiDash = /([a-z])([A-Z])/g;
  903. jQuery.extend({
  904. cache : {},
  905. uuid : 0,
  906. expando : "jQuery" + (jQuery.fn.jquery + Math.random()).replace(/\D/g, ""),
  907. noData : {
  908. embed : true,
  909. object : "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  910. applet : true
  911. },
  912. hasData : function (elem) {
  913. elem = elem.nodeType ? jQuery.cache[elem[jQuery.expando]] : elem[jQuery.expando];
  914. return !!elem && !isEmptyDataObject(elem)
  915. },
  916. data : function (elem, name, data, pvt) {
  917. if (!jQuery.acceptData(elem)) {
  918. return
  919. }
  920. var internalKey = jQuery.expando,
  921. getByName = typeof name === "string",
  922. thisCache,
  923. isNode = elem.nodeType,
  924. cache = isNode ? jQuery.cache : elem,
  925. id = isNode ? elem[jQuery.expando] : elem[jQuery.expando] && jQuery.expando;
  926. if ((!id || (pvt && id && !cache[id][internalKey])) && getByName && data === undefined) {
  927. return
  928. }
  929. if (!id) {
  930. if (isNode) {
  931. elem[jQuery.expando] = id = ++jQuery.uuid
  932. } else {
  933. id = jQuery.expando
  934. }
  935. }
  936. if (!cache[id]) {
  937. cache[id] = {};
  938. if (!isNode) {
  939. cache[id].toJSON = jQuery.noop
  940. }
  941. }
  942. if (typeof name === "object" || typeof name === "function") {
  943. if (pvt) {
  944. cache[id][internalKey] = jQuery.extend(cache[id][internalKey], name)
  945. } else {
  946. cache[id] = jQuery.extend(cache[id], name)
  947. }
  948. }
  949. thisCache = cache[id];
  950. if (pvt) {
  951. if (!thisCache[internalKey]) {
  952. thisCache[internalKey] = {}
  953. }
  954. thisCache = thisCache[internalKey]
  955. }
  956. if (data !== undefined) {
  957. thisCache[jQuery.camelCase(name)] = data
  958. }
  959. if (name === "events" && !thisCache[name]) {
  960. return thisCache[internalKey] && thisCache[internalKey].events
  961. }
  962. return getByName ? thisCache[jQuery.camelCase(name)] : thisCache
  963. },
  964. removeData : function (elem, name, pvt) {
  965. if (!jQuery.acceptData(elem)) {
  966. return
  967. }
  968. var internalKey = jQuery.expando,
  969. isNode = elem.nodeType,
  970. cache = isNode ? jQuery.cache : elem,
  971. id = isNode ? elem[jQuery.expando] : jQuery.expando;
  972. if (!cache[id]) {
  973. return
  974. }
  975. if (name) {
  976. var thisCache = pvt ? cache[id][internalKey] : cache[id];
  977. if (thisCache) {
  978. delete thisCache[name];
  979. if (!isEmptyDataObject(thisCache)) {
  980. return
  981. }
  982. }
  983. }
  984. if (pvt) {
  985. delete cache[id][internalKey];
  986. if (!isEmptyDataObject(cache[id])) {
  987. return
  988. }
  989. }
  990. var internalCache = cache[id][internalKey];
  991. if (jQuery.support.deleteExpando || cache != window) {
  992. delete cache[id]
  993. } else {
  994. cache[id] = null
  995. }
  996. if (internalCache) {
  997. cache[id] = {};
  998. if (!isNode) {
  999. cache[id].toJSON = jQuery.noop
  1000. }
  1001. cache[id][internalKey] = internalCache
  1002. } else {
  1003. if (isNode) {
  1004. if (jQuery.support.deleteExpando) {
  1005. delete elem[jQuery.expando]
  1006. } else {
  1007. if (elem.removeAttribute) {
  1008. elem.removeAttribute(jQuery.expando)
  1009. } else {
  1010. elem[jQuery.expando] = null
  1011. }
  1012. }
  1013. }
  1014. }
  1015. },
  1016. _data : function (elem, name, data) {
  1017. return jQuery.data(elem, name, data, true)
  1018. },
  1019. acceptData : function (elem) {
  1020. if (elem.nodeName) {
  1021. var match = jQuery.noData[elem.nodeName.toLowerCase()];
  1022. if (match) {
  1023. return !(match === true || elem.getAttribute("classid") !== match)
  1024. }
  1025. }
  1026. return true
  1027. }
  1028. });
  1029. jQuery.fn.extend({
  1030. data : function (key, value) {
  1031. var data = null;
  1032. if (typeof key === "undefined") {
  1033. if (this.length) {
  1034. data = jQuery.data(this[0]);
  1035. if (this[0].nodeType === 1) {
  1036. var attr = this[0].attributes,
  1037. name;
  1038. for (var i = 0, l = attr.length; i < l; i++) {
  1039. name = attr[i].name;
  1040. if (name.indexOf("data-") === 0) {
  1041. name = jQuery.camelCase(name.substring(5));
  1042. dataAttr(this[0], name, data[name])
  1043. }
  1044. }
  1045. }
  1046. }
  1047. return data
  1048. } else {
  1049. if (typeof key === "object") {
  1050. return this.each(function () {
  1051. jQuery.data(this, key)
  1052. })
  1053. }
  1054. }
  1055. var parts = key.split(".");
  1056. parts[1] = parts[1] ? "." + parts[1] : "";
  1057. if (value === undefined) {
  1058. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1059. if (data === undefined && this.length) {
  1060. data = jQuery.data(this[0], key);
  1061. data = dataAttr(this[0], key, data)
  1062. }
  1063. return data === undefined && parts[1] ? this.data(parts[0]) : data
  1064. } else {
  1065. return this.each(function () {
  1066. var $this = jQuery(this),
  1067. args = [parts[0], value];
  1068. $this.triggerHandler("setData" + parts[1] + "!", args);
  1069. jQuery.data(this, key, value);
  1070. $this.triggerHandler("changeData" + parts[1] + "!", args)
  1071. })
  1072. }
  1073. },
  1074. removeData : function (key) {
  1075. return this.each(function () {
  1076. jQuery.removeData(this, key)
  1077. })
  1078. }
  1079. });
  1080. function dataAttr(elem, key, data) {
  1081. if (data === undefined && elem.nodeType === 1) {
  1082. var name = "data-" + key.replace(rmultiDash, "$1-$2").toLowerCase();
  1083. data = elem.getAttribute(name);
  1084. if (typeof data === "string") {
  1085. try {
  1086. data = data === "true" ? true : data === "false" ? false : data === "null" ? null : !jQuery.isNaN(data) ? parseFloat(data) : rbrace.test(data) ? jQuery.parseJSON(data) : data
  1087. } catch (e) {}
  1088. jQuery.data(elem, key, data)
  1089. } else {
  1090. data = undefined
  1091. }
  1092. }
  1093. return data
  1094. }
  1095. function isEmptyDataObject(obj) {
  1096. for (var name in obj) {
  1097. if (name !== "toJSON") {
  1098. return false
  1099. }
  1100. }
  1101. return true
  1102. }
  1103. function handleQueueMarkDefer(elem, type, src) {
  1104. var deferDataKey = type + "defer",
  1105. queueDataKey = type + "queue",
  1106. markDataKey = type + "mark",
  1107. defer = jQuery.data(elem, deferDataKey, undefined, true);
  1108. if (defer && (src === "queue" || !jQuery.data(elem, queueDataKey, undefined, true)) && (src === "mark" || !jQuery.data(elem, markDataKey, undefined, true))) {
  1109. setTimeout(function () {
  1110. if (!jQuery.data(elem, queueDataKey, undefined, true) && !jQuery.data(elem, markDataKey, undefined, true)) {
  1111. jQuery.removeData(elem, deferDataKey, true);
  1112. defer.resolve()
  1113. }
  1114. }, 0)
  1115. }
  1116. }
  1117. jQuery.extend({
  1118. _mark : function (elem, type) {
  1119. if (elem) {
  1120. type = (type || "fx") + "mark";
  1121. jQuery.data(elem, type, (jQuery.data(elem, type, undefined, true) || 0) + 1, true)
  1122. }
  1123. },
  1124. _unmark : function (force, elem, type) {
  1125. if (force !== true) {
  1126. type = elem;
  1127. elem = force;
  1128. force = false
  1129. }
  1130. if (elem) {
  1131. type = type || "fx";
  1132. var key = type + "mark",
  1133. count = force ? 0 : ((jQuery.data(elem, key, undefined, true) || 1) - 1);
  1134. if (count) {
  1135. jQuery.data(elem, key, count, true)
  1136. } else {
  1137. jQuery.removeData(elem, key, true);
  1138. handleQueueMarkDefer(elem, type, "mark")
  1139. }
  1140. }
  1141. },
  1142. queue : function (elem, type, data) {
  1143. if (elem) {
  1144. type = (type || "fx") + "queue";
  1145. var q = jQuery.data(elem, type, undefined, true);
  1146. if (data) {
  1147. if (!q || jQuery.isArray(data)) {
  1148. q = jQuery.data(elem, type, jQuery.makeArray(data), true)
  1149. } else {
  1150. q.push(data)
  1151. }
  1152. }
  1153. return q || []
  1154. }
  1155. },
  1156. dequeue : function (elem, type) {
  1157. type = type || "fx";
  1158. var queue = jQuery.queue(elem, type),
  1159. fn = queue.shift(),
  1160. defer;
  1161. if (fn === "inprogress") {
  1162. fn = queue.shift()
  1163. }
  1164. if (fn) {
  1165. if (type === "fx") {
  1166. queue.unshift("inprogress")
  1167. }
  1168. fn.call(elem, function () {
  1169. jQuery.dequeue(elem, type)
  1170. })
  1171. }
  1172. if (!queue.length) {
  1173. jQuery.removeData(elem, type + "queue", true);
  1174. handleQueueMarkDefer(elem, type, "queue")
  1175. }
  1176. }
  1177. });
  1178. jQuery.fn.extend({
  1179. queue : function (type, data) {
  1180. if (typeof type !== "string") {
  1181. data = type;
  1182. type = "fx"
  1183. }
  1184. if (data === undefined) {
  1185. return jQuery.queue(this[0], type)
  1186. }
  1187. return this.each(function () {
  1188. var queue = jQuery.queue(this, type, data);
  1189. if (type === "fx" && queue[0] !== "inprogress") {
  1190. jQuery.dequeue(this, type)
  1191. }
  1192. })
  1193. },
  1194. dequeue : function (type) {
  1195. return this.each(function () {
  1196. jQuery.dequeue(this, type)
  1197. })
  1198. },
  1199. delay : function (time, type) {
  1200. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1201. type = type || "fx";
  1202. return this.queue(type, function () {
  1203. var elem = this;
  1204. setTimeout(function () {
  1205. jQuery.dequeue(elem, type)
  1206. }, time)
  1207. })
  1208. },
  1209. clearQueue : function (type) {
  1210. return this.queue(type || "fx", [])
  1211. },
  1212. promise : function (type, object) {
  1213. if (typeof type !== "string") {
  1214. object = type;
  1215. type = undefined
  1216. }
  1217. type = type || "fx";
  1218. var defer = jQuery.Deferred(),
  1219. elements = this,
  1220. i = elements.length,
  1221. count = 1,
  1222. deferDataKey = type + "defer",
  1223. queueDataKey = type + "queue",
  1224. markDataKey = type + "mark",
  1225. tmp;
  1226. function resolve() {
  1227. if (!(--count)) {
  1228. defer.resolveWith(elements, [elements])
  1229. }
  1230. }
  1231. while (i--) {
  1232. if ((tmp = jQuery.data(elements[i], deferDataKey, undefined, true) || (jQuery.data(elements[i], queueDataKey, undefined, true) || jQuery.data(elements[i], markDataKey, undefined, true)) && jQuery.data(elements[i], deferDataKey, jQuery._Deferred(), true))) {
  1233. count++;
  1234. tmp.done(resolve)
  1235. }
  1236. }
  1237. resolve();
  1238. return defer.promise()
  1239. }
  1240. });
  1241. var rclass = /[\n\t\r]/g,
  1242. rspace = /\s+/,
  1243. rreturn = /\r/g,
  1244. rtype = /^(?:button|input)$/i,
  1245. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1246. rclickable = /^a(?:rea)?$/i,
  1247. rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
  1248. rinvalidChar = /\:/,
  1249. formHook,
  1250. boolHook;
  1251. jQuery.fn.extend({
  1252. attr : function (name, value) {
  1253. return jQuery.access(this, name, value, true, jQuery.attr)
  1254. },
  1255. removeAttr : function (name) {
  1256. return this.each(function () {
  1257. jQuery.removeAttr(this, name)
  1258. })
  1259. },
  1260. prop : function (name, value) {
  1261. return jQuery.access(this, name, value, true, jQuery.prop)
  1262. },
  1263. removeProp : function (name) {
  1264. name = jQuery.propFix[name] || name;
  1265. return this.each(function () {
  1266. try {
  1267. this[name] = undefined;
  1268. delete this[name]
  1269. } catch (e) {}
  1270. })
  1271. },
  1272. addClass : function (value) {
  1273. if (jQuery.isFunction(value)) {
  1274. return this.each(function (i) {
  1275. var self = jQuery(this);
  1276. self.addClass(value.call(this, i, self.attr("class") || ""))
  1277. })
  1278. }
  1279. if (value && typeof value === "string") {
  1280. var classNames = (value || "").split(rspace);
  1281. for (var i = 0, l = this.length; i < l; i++) {
  1282. var elem = this[i];
  1283. if (elem.nodeType === 1) {
  1284. if (!elem.className) {
  1285. elem.className = value
  1286. } else {
  1287. var className = " " + elem.className + " ",
  1288. setClass = elem.className;
  1289. for (var c = 0, cl = classNames.length; c < cl; c++) {
  1290. if (className.indexOf(" " + classNames[c] + " ") < 0) {
  1291. setClass += " " + classNames[c]
  1292. }
  1293. }
  1294. elem.className = jQuery.trim(setClass)
  1295. }
  1296. }
  1297. }
  1298. }
  1299. return this
  1300. },
  1301. removeClass : function (value) {
  1302. if (jQuery.isFunction(value)) {
  1303. return this.each(function (i) {
  1304. var self = jQuery(this);
  1305. self.removeClass(value.call(this, i, self.attr("class")))
  1306. })
  1307. }
  1308. if ((value && typeof value === "string") || value === undefined) {
  1309. var classNames = (value || "").split(rspace);
  1310. for (var i = 0, l = this.length; i < l; i++) {
  1311. var elem = this[i];
  1312. if (elem.nodeType === 1 && elem.className) {
  1313. if (value) {
  1314. var className = (" " + elem.className + " ").replace(rclass, " ");
  1315. for (var c = 0, cl = classNames.length; c < cl; c++) {
  1316. className = className.replace(" " + classNames[c] + " ", " ")
  1317. }
  1318. elem.className = jQuery.trim(className)
  1319. } else {
  1320. elem.className = ""
  1321. }
  1322. }
  1323. }
  1324. }
  1325. return this
  1326. },
  1327. toggleClass : function (value, stateVal) {
  1328. var type = typeof value,
  1329. isBool = typeof stateVal === "boolean";
  1330. if (jQuery.isFunction(value)) {
  1331. return this.each(function (i) {
  1332. var self = jQuery(this);
  1333. self.toggleClass(value.call(this, i, self.attr("class"), stateVal), stateVal)
  1334. })
  1335. }
  1336. return this.each(function () {
  1337. if (type === "string") {
  1338. var className,
  1339. i = 0,
  1340. self = jQuery(this),
  1341. state = stateVal,
  1342. classNames = value.split(rspace);
  1343. while ((className = classNames[i++])) {
  1344. state = isBool ? state : !self.hasClass(className);
  1345. self[state ? "addClass" : "removeClass"](className)
  1346. }
  1347. } else {
  1348. if (type === "undefined" || type === "boolean") {
  1349. if (this.className) {
  1350. jQuery._data(this, "__className__", this.className)
  1351. }
  1352. this.className = this.className || value === false ? "" : jQuery._data(this, "__className__") || ""
  1353. }
  1354. }
  1355. })
  1356. },
  1357. hasClass : function (selector) {
  1358. var className = " " + selector + " ";
  1359. for (var i = 0, l = this.length; i < l; i++) {
  1360. if ((" " + this[i].className + " ").replace(rclass, " ").indexOf(className) > -1) {
  1361. return true
  1362. }
  1363. }
  1364. return false
  1365. },
  1366. val : function (value) {
  1367. var hooks,
  1368. ret,
  1369. elem = this[0];
  1370. if (!arguments.length) {
  1371. if (elem) {
  1372. hooks = jQuery.valHooks[elem.nodeName.toLowerCase()] || jQuery.valHooks[elem.type];
  1373. if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) {
  1374. return ret
  1375. }
  1376. return (elem.value || "").replace(rreturn, "")
  1377. }
  1378. return undefined
  1379. }
  1380. var isFunction = jQuery.isFunction(value);
  1381. return this.each(function (i) {
  1382. var self = jQuery(this),
  1383. val;
  1384. if (this.nodeType !== 1) {
  1385. return
  1386. }
  1387. if (isFunction) {
  1388. val = value.call(this, i, self.val())
  1389. } else {
  1390. val = value
  1391. }
  1392. if (val == null) {
  1393. val = ""
  1394. } else {
  1395. if (typeof val === "number") {
  1396. val += ""
  1397. } else {
  1398. if (jQuery.isArray(val)) {
  1399. val = jQuery.map(val, function (value) {
  1400. return value == null ? "" : value + ""
  1401. })
  1402. }
  1403. }
  1404. }
  1405. hooks = jQuery.valHooks[this.nodeName.toLowerCase()] || jQuery.valHooks[this.type];
  1406. if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {
  1407. this.value = val
  1408. }
  1409. })
  1410. }
  1411. });
  1412. jQuery.extend({
  1413. valHooks : {
  1414. option : {
  1415. get : function (elem) {
  1416. var val = elem.attributes.value;
  1417. return !val || val.specified ? elem.value : elem.text
  1418. }
  1419. },
  1420. select : {
  1421. get : function (elem) {
  1422. var value,
  1423. index = elem.selectedIndex,
  1424. values = [],
  1425. options = elem.options,
  1426. one = elem.type === "select-one";
  1427. if (index < 0) {
  1428. return null
  1429. }
  1430. for (var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++) {
  1431. var option = options[i];
  1432. if (option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && (!option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup"))) {
  1433. value = jQuery(option).val();
  1434. if (one) {
  1435. return value
  1436. }
  1437. values.push(value)
  1438. }
  1439. }
  1440. if (one && !values.length && options.length) {
  1441. return jQuery(options[index]).val()
  1442. }
  1443. return values
  1444. },
  1445. set : function (elem, value) {
  1446. var values = jQuery.makeArray(value);
  1447. jQuery(elem).find("option").each(function () {
  1448. this.selected = jQuery.inArray(jQuery(this).val(), values) >= 0
  1449. });
  1450. if (!values.length) {
  1451. elem.selectedIndex = -1
  1452. }
  1453. return values
  1454. }
  1455. }
  1456. },
  1457. attrFn : {
  1458. val : true,
  1459. css : true,
  1460. html : true,
  1461. text : true,
  1462. data : true,
  1463. width : true,
  1464. height : true,
  1465. offset : true
  1466. },
  1467. attrFix : {
  1468. tabindex : "tabIndex"
  1469. },
  1470. attr : function (elem, name, value, pass) {
  1471. var nType = elem.nodeType;
  1472. if (!elem || nType === 3 || nType === 8 || nType === 2) {
  1473. return undefined
  1474. }
  1475. if (pass && name in jQuery.attrFn) {
  1476. return jQuery(elem)[name](value)
  1477. }
  1478. if (!("getAttribute" in elem)) {
  1479. return jQuery.prop(elem, name, value)
  1480. }
  1481. var ret,
  1482. hooks,
  1483. notxml = nType !== 1 || !jQuery.isXMLDoc(elem);
  1484. name = notxml && jQuery.attrFix[name] || name;
  1485. hooks = jQuery.attrHooks[name];
  1486. if (!hooks) {
  1487. if (rboolean.test(name) && (typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase())) {
  1488. hooks = boolHook
  1489. } else {
  1490. if (formHook && (jQuery.nodeName(elem, "form") || rinvalidChar.test(name))) {
  1491. hooks = formHook
  1492. }
  1493. }
  1494. }
  1495. if (value !== undefined) {
  1496. if (value === null) {
  1497. jQuery.removeAttr(elem, name);
  1498. return undefined
  1499. } else {
  1500. if (hooks && "set" in hooks && notxml && (ret = hooks.set(elem, value, name)) !== undefined) {
  1501. return ret
  1502. } else {
  1503. elem.setAttribute(name, "" + value);
  1504. return value
  1505. }
  1506. }
  1507. } else {
  1508. if (hooks && "get" in hooks && notxml) {
  1509. return hooks.get(elem, name)
  1510. } else {
  1511. ret = elem.getAttribute(name);
  1512. return ret === null ? undefined : ret
  1513. }
  1514. }
  1515. },
  1516. removeAttr : function (elem, name) {
  1517. var propName;
  1518. if (elem.nodeType === 1) {
  1519. name = jQuery.attrFix[name] || name;
  1520. if (jQuery.support.getSetAttribute) {
  1521. elem.removeAttribute(name)
  1522. } else {
  1523. jQuery.attr(elem, name, "");
  1524. elem.removeAttributeNode(elem.getAttributeNode(name))
  1525. }
  1526. if (rboolean.test(name) && (propName = jQuery.propFix[name] || name)in elem) {
  1527. elem[propName] = false
  1528. }
  1529. }
  1530. },
  1531. attrHooks : {
  1532. type : {
  1533. set : function (elem, value) {
  1534. if (rtype.test(elem.nodeName) && elem.parentNode) {
  1535. jQuery.error("type property can't be changed")
  1536. } else {
  1537. if (!jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input")) {
  1538. var val = elem.value;
  1539. elem.setAttribute("type", value);
  1540. if (val) {
  1541. elem.value = val
  1542. }
  1543. return value
  1544. }
  1545. }
  1546. }
  1547. },
  1548. tabIndex : {
  1549. get : function (elem) {
  1550. var attributeNode = elem.getAttributeNode("tabIndex");
  1551. return attributeNode && attributeNode.specified ? parseInt(attributeNode.value, 10) : rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href ? 0 : undefined
  1552. }
  1553. }
  1554. },
  1555. propFix : {
  1556. tabindex : "tabIndex",
  1557. readonly : "readOnly",
  1558. "for" : "htmlFor",
  1559. "class" : "className",
  1560. maxlength : "maxLength",
  1561. cellspacing : "cellSpacing",
  1562. cellpadding : "cellPadding",
  1563. rowspan : "rowSpan",
  1564. colspan : "colSpan",
  1565. usemap : "useMap",
  1566. frameborder : "frameBorder",
  1567. contenteditable : "contentEditable"
  1568. },
  1569. prop : function (elem, name, value) {
  1570. var nType = elem.nodeType;
  1571. if (!elem || nType === 3 || nType === 8 || nType === 2) {
  1572. return undefined
  1573. }
  1574. var ret,
  1575. hooks,
  1576. notxml = nType !== 1 || !jQuery.isXMLDoc(elem);
  1577. name = notxml && jQuery.propFix[name] || name;
  1578. hooks = jQuery.propHooks[name];
  1579. if (value !== undefined) {
  1580. if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) {
  1581. return ret
  1582. } else {
  1583. return (elem[name] = value)
  1584. }
  1585. } else {
  1586. if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== undefined) {
  1587. return ret
  1588. } else {
  1589. return elem[name]
  1590. }
  1591. }
  1592. },
  1593. propHooks : {}
  1594. });
  1595. boolHook = {
  1596. get : function (elem, name) {
  1597. return elem[jQuery.propFix[name] || name] ? name.toLowerCase() : undefined
  1598. },
  1599. set : function (elem, value, name) {
  1600. var propName;
  1601. if (value === false) {
  1602. jQuery.removeAttr(elem, name)
  1603. } else {
  1604. propName = jQuery.propFix[name] || name;
  1605. if (propName in elem) {
  1606. elem[propName] = value
  1607. }
  1608. elem.setAttribute(name, name.toLowerCase())
  1609. }
  1610. return name
  1611. }
  1612. };
  1613. jQuery.attrHooks.value = {
  1614. get : function (elem, name) {
  1615. if (formHook && jQuery.nodeName(elem, "button")) {
  1616. return formHook.get(elem, name)
  1617. }
  1618. return elem.value
  1619. },
  1620. set : function (elem, value, name) {
  1621. if (formHook && jQuery.nodeName(elem, "button")) {
  1622. return formHook.set(elem, value, name)
  1623. }
  1624. elem.value = value
  1625. }
  1626. };
  1627. if (!jQuery.support.getSetAttribute) {
  1628. jQuery.attrFix = jQuery.propFix;
  1629. formHook = jQuery.attrHooks.name = jQuery.valHooks.button = {
  1630. get : function (elem, name) {
  1631. var ret;
  1632. ret = elem.getAttributeNode(name);
  1633. return ret && ret.nodeValue !== "" ? ret.nodeValue : undefined
  1634. },
  1635. set : function (elem, value, name) {
  1636. var ret = elem.getAttributeNode(name);
  1637. if (ret) {
  1638. ret.nodeValue = value;
  1639. return value
  1640. }
  1641. }
  1642. };
  1643. jQuery.each(["width", "height"], function (i, name) {
  1644. jQuery.attrHooks[name] = jQuery.extend(jQuery.attrHooks[name], {
  1645. set : function (elem, value) {
  1646. if (value === "") {
  1647. elem.setAttribute(name, "auto");
  1648. return value
  1649. }
  1650. }
  1651. })
  1652. })
  1653. }
  1654. if (!jQuery.support.hrefNormalized) {
  1655. jQuery.each(["href", "src", "width", "height"], function (i, name) {
  1656. jQuery.attrHooks[name] = jQuery.extend(jQuery.attrHooks[name], {
  1657. get : function (elem) {
  1658. var ret = elem.getAttribute(name, 2);
  1659. return ret === null ? undefined : ret
  1660. }
  1661. })
  1662. })
  1663. }
  1664. if (!jQuery.support.style) {
  1665. jQuery.attrHooks.style = {
  1666. get : function (elem) {
  1667. return elem.style.cssText.toLowerCase() || undefined
  1668. },
  1669. set : function (elem, value) {
  1670. return (elem.style.cssText = "" + value)
  1671. }
  1672. }
  1673. }
  1674. if (!jQuery.support.optSelected) {
  1675. jQuery.propHooks.selected = jQuery.extend(jQuery.propHooks.selected, {
  1676. get : function (elem) {
  1677. var parent = elem.parentNode;
  1678. if (parent) {
  1679. parent.selectedIndex;
  1680. if (parent.parentNode) {
  1681. parent.parentNode.selectedIndex
  1682. }
  1683. }
  1684. }
  1685. })
  1686. }
  1687. if (!jQuery.support.checkOn) {
  1688. jQuery.each(["radio", "checkbox"], function () {
  1689. jQuery.valHooks[this] = {
  1690. get : function (elem) {
  1691. return elem.getAttribute("value") === null ? "on" : elem.value
  1692. }
  1693. }
  1694. })
  1695. }
  1696. jQuery.each(["radio", "checkbox"], function () {
  1697. jQuery.valHooks[this] = jQuery.extend(jQuery.valHooks[this], {
  1698. set : function (elem, value) {
  1699. if (jQuery.isArray(value)) {
  1700. return (elem.checked = jQuery.inArray(jQuery(elem).val(), value) >= 0)
  1701. }
  1702. }
  1703. })
  1704. });
  1705. var hasOwn = Object.prototype.hasOwnProperty,
  1706. rnamespaces = /\.(.*)$/,
  1707. rformElems = /^(?:textarea|input|select)$/i,
  1708. rperiod = /\./g,
  1709. rspaces = / /g,
  1710. rescape = /[^\w\s.|`]/g,
  1711. fcleanup = function (nm) {
  1712. return nm.replace(rescape, "\\$&")
  1713. };
  1714. jQuery.event = {
  1715. add : function (elem, types, handler, data) {
  1716. if (elem.nodeType === 3 || elem.nodeType === 8) {
  1717. return
  1718. }
  1719. if (handler === false) {
  1720. handler = returnFalse
  1721. } else {
  1722. if (!handler) {
  1723. return
  1724. }
  1725. }
  1726. var handleObjIn,
  1727. handleObj;
  1728. if (handler.handler) {
  1729. handleObjIn = handler;
  1730. handler = handleObjIn.handler
  1731. }
  1732. if (!handler.guid) {
  1733. handler.guid = jQuery.guid++
  1734. }
  1735. var elemData = jQuery._data(elem);
  1736. if (!elemData) {
  1737. return
  1738. }
  1739. var events = elemData.events,
  1740. eventHandle = elemData.handle;
  1741. if (!events) {
  1742. elemData.events = events = {}
  1743. }
  1744. if (!eventHandle) {
  1745. elemData.handle = eventHandle = function (e) {
  1746. return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.handle.apply(eventHandle.elem, arguments) : undefined
  1747. }
  1748. }
  1749. eventHandle.elem = elem;
  1750. types = types.split(" ");
  1751. var type,
  1752. i = 0,
  1753. namespaces;
  1754. while ((type = types[i++])) {
  1755. handleObj = handleObjIn ? jQuery.extend({}, handleObjIn) : {
  1756. handler : handler,
  1757. data : data
  1758. };
  1759. if (type.indexOf(".") > -1) {
  1760. namespaces = type.split(".");
  1761. type = namespaces.shift();
  1762. handleObj.namespace = namespaces.slice(0).sort().join(".")
  1763. } else {
  1764. namespaces = [];
  1765. handleObj.namespace = ""
  1766. }
  1767. handleObj.type = type;
  1768. if (!handleObj.guid) {
  1769. handleObj.guid = handler.guid
  1770. }
  1771. var handlers = events[type],
  1772. special = jQuery.event.special[type] || {};
  1773. if (!handlers) {
  1774. handlers = events[type] = [];
  1775. if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
  1776. if (elem.addEventListener) {
  1777. elem.addEventListener(type, eventHandle, false)
  1778. } else {
  1779. if (elem.attachEvent) {
  1780. elem.attachEvent("on" + type, eventHandle)
  1781. }
  1782. }
  1783. }
  1784. }
  1785. if (special.add) {
  1786. special.add.call(elem, handleObj);
  1787. if (!handleObj.handler.guid) {
  1788. handleObj.handler.guid = handler.guid
  1789. }
  1790. }
  1791. handlers.push(handleObj);
  1792. jQuery.event.global[type] = true
  1793. }
  1794. elem = null
  1795. },
  1796. global : {},
  1797. remove : function (elem, types, handler, pos) {
  1798. if (elem.nodeType === 3 || elem.nodeType === 8) {
  1799. return
  1800. }
  1801. if (handler === false) {
  1802. handler = returnFalse
  1803. }
  1804. var ret,
  1805. type,
  1806. fn,
  1807. j,
  1808. i = 0,
  1809. all,
  1810. namespaces,
  1811. namespace,
  1812. special,
  1813. eventType,
  1814. handleObj,
  1815. origType,
  1816. elemData = jQuery.hasData(elem) && jQuery._data(elem),
  1817. events = elemData && elemData.events;
  1818. if (!elemData || !events) {
  1819. return
  1820. }
  1821. if (types && types.type) {
  1822. handler = types.handler;
  1823. types = types.type
  1824. }
  1825. if (!types || typeof types === "string" && types.charAt(0) === ".") {
  1826. types = types || "";
  1827. for (type in events) {
  1828. jQuery.event.remove(elem, type + types)
  1829. }
  1830. return
  1831. }
  1832. types = types.split(" ");
  1833. while ((type = types[i++])) {
  1834. origType = type;
  1835. handleObj = null;
  1836. all = type.indexOf(".") < 0;
  1837. namespaces = [];
  1838. if (!all) {
  1839. namespaces = type.split(".");
  1840. type = namespaces.shift();
  1841. namespace = new RegExp("(^|\\.)" + jQuery.map(namespaces.slice(0).sort(), fcleanup).join("\\.(?:.*\\.)?") + "(\\.|$)")
  1842. }
  1843. eventType = events[type];
  1844. if (!eventType) {
  1845. continue
  1846. }
  1847. if (!handler) {
  1848. for (j = 0; j < eventType.length; j++) {
  1849. handleObj = eventType[j];
  1850. if (all || namespace.test(handleObj.namespace)) {
  1851. jQuery.event.remove(elem, origType, handleObj.handler, j);
  1852. eventType.splice(j--, 1)
  1853. }
  1854. }
  1855. continue
  1856. }
  1857. special = jQuery.event.special[type] || {};
  1858. for (j = pos || 0; j < eventType.length; j++) {
  1859. handleObj = eventType[j];
  1860. if (handler.guid === handleObj.guid) {
  1861. if (all || namespace.test(handleObj.namespace)) {
  1862. if (pos == null) {
  1863. eventType.splice(j--, 1)
  1864. }
  1865. if (special.remove) {
  1866. special.remove.call(elem, handleObj)
  1867. }
  1868. }
  1869. if (pos != null) {
  1870. break
  1871. }
  1872. }
  1873. }
  1874. if (eventType.length === 0 || pos != null && eventType.length === 1) {
  1875. if (!special.teardown || special.teardown.call(elem, namespaces) === false) {
  1876. jQuery.removeEvent(elem, type, elemData.handle)
  1877. }
  1878. ret = null;
  1879. delete events[type]
  1880. }
  1881. }
  1882. if (jQuery.isEmptyObject(events)) {
  1883. var handle = elemData.handle;
  1884. if (handle) {
  1885. handle.elem = null
  1886. }
  1887. delete elemData.events;
  1888. delete elemData.handle;
  1889. if (jQuery.isEmptyObject(elemData)) {
  1890. jQuery.removeData(elem, undefined, true)
  1891. }
  1892. }
  1893. },
  1894. customEvent : {
  1895. getData : true,
  1896. setData : true,
  1897. changeData : true
  1898. },
  1899. trigger : function (event, data, elem, onlyHandlers) {
  1900. var type = event.type || event,
  1901. namespaces = [],
  1902. exclusive;
  1903. if (type.indexOf("!") >= 0) {
  1904. type = type.slice(0, -1);
  1905. exclusive = true
  1906. }
  1907. if (type.indexOf(".") >= 0) {
  1908. namespaces = type.split(".");
  1909. type = namespaces.shift();
  1910. namespaces.sort()
  1911. }
  1912. if ((!elem || jQuery.event.customEvent[type]) && !jQuery.event.global[type]) {
  1913. return
  1914. }
  1915. event = typeof event === "object" ? event[jQuery.expando] ? event : new jQuery.Event(type, event) : new jQuery.Event(type);
  1916. event.type = type;
  1917. event.exclusive = exclusive;
  1918. event.namespace = namespaces.join(".");
  1919. event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
  1920. if (onlyHandlers || !elem) {
  1921. event.preventDefault();
  1922. event.stopPropagation()
  1923. }
  1924. if (!elem) {
  1925. jQuery.each(jQuery.cache, function () {
  1926. var internalKey = jQuery.expando,
  1927. internalCache = this[internalKey];
  1928. if (internalCache && internalCache.events && internalCache.events[type]) {
  1929. jQuery.event.trigger(event, data, internalCache.handle.elem)
  1930. }
  1931. });
  1932. return
  1933. }
  1934. if (elem.nodeType === 3 || elem.nodeType === 8) {
  1935. return
  1936. }
  1937. event.result = undefined;
  1938. event.target = elem;
  1939. data = data ? jQuery.makeArray(data) : [];
  1940. data.unshift(event);
  1941. var cur = elem,
  1942. ontype = type.indexOf(":") < 0 ? "on" + type : "";
  1943. do {
  1944. var handle = jQuery._data(cur, "handle");
  1945. event.currentTarget = cur;
  1946. if (handle) {
  1947. handle.apply(cur, data)
  1948. }
  1949. if (ontype && jQuery.acceptData(cur) && cur[ontype] && cur[ontype].apply(cur, data) === false) {
  1950. event.result = false;
  1951. event.preventDefault()
  1952. }
  1953. cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window
  1954. } while (cur && !event.isPropagationStopped());
  1955. if (!event.isDefaultPrevented()) {
  1956. var old,
  1957. special = jQuery.event.special[type] || {};
  1958. if ((!special._default || special._default.call(elem.ownerDocument, event) === false) && !(type === "click" && jQuery.nodeName(elem, "a")) && jQuery.acceptData(elem)) {
  1959. try {
  1960. if (ontype && elem[type]) {
  1961. old = elem[ontype];
  1962. if (old) {
  1963. elem[ontype] = null
  1964. }
  1965. jQuery.event.triggered = type;
  1966. elem[type]()
  1967. }
  1968. } catch (ieError) {}
  1969. if (old) {
  1970. elem[ontype] = old
  1971. }
  1972. jQuery.event.triggered = undefined
  1973. }
  1974. }
  1975. return event.result
  1976. },
  1977. handle : function (event) {
  1978. event = jQuery.event.fix(event || window.event);
  1979. var handlers = ((jQuery._data(this, "events") || {})[event.type] || []).slice(0),
  1980. run_all = !event.exclusive && !event.namespace,
  1981. args = Array.prototype.slice.call(arguments, 0);
  1982. args[0] = event;
  1983. event.currentTarget = this;
  1984. for (var j = 0, l = handlers.length; j < l; j++) {
  1985. var handleObj = handlers[j];
  1986. if (run_all || event.namespace_re.test(handleObj.namespace)) {
  1987. event.handler = handleObj.handler;
  1988. event.data = handleObj.data;
  1989. event.handleObj = handleObj;
  1990. var ret = handleObj.handler.apply(this, args);
  1991. if (ret !== undefined) {
  1992. event.result = ret;
  1993. if (ret === false) {
  1994. event.preventDefault();
  1995. event.stopPropagation()
  1996. }
  1997. }
  1998. if (event.isImmediatePropagationStopped()) {
  1999. break
  2000. }
  2001. }
  2002. }
  2003. return event.result
  2004. },
  2005. props : "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
  2006. fix : function (event) {
  2007. if (event[jQuery.expando]) {
  2008. return event
  2009. }
  2010. var originalEvent = event;
  2011. event = jQuery.Event(originalEvent);
  2012. for (var i = this.props.length, prop; i; ) {
  2013. prop = this.props[--i];
  2014. event[prop] = originalEvent[prop]
  2015. }
  2016. if (!event.target) {
  2017. event.target = event.srcElement || document
  2018. }
  2019. if (event.target.nodeType === 3) {
  2020. event.target = event.target.parentNode
  2021. }
  2022. if (!event.relatedTarget && event.fromElement) {
  2023. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement
  2024. }
  2025. if (event.pageX == null && event.clientX != null) {
  2026. var eventDocument = event.target.ownerDocument || document,
  2027. doc = eventDocument.documentElement,
  2028. body = eventDocument.body;
  2029. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  2030. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0)
  2031. }
  2032. if (event.which == null && (event.charCode != null || event.keyCode != null)) {
  2033. event.which = event.charCode != null ? event.charCode : event.keyCode
  2034. }
  2035. if (!event.metaKey && event.ctrlKey) {
  2036. event.metaKey = event.ctrlKey
  2037. }
  2038. if (!event.which && event.button !== undefined) {
  2039. event.which = (event.button & 1 ? 1 : (event.button & 2 ? 3 : (event.button & 4 ? 2 : 0)))
  2040. }
  2041. return event
  2042. },
  2043. guid : 100000000,
  2044. proxy : jQuery.proxy,
  2045. special : {
  2046. ready : {
  2047. setup : jQuery.bindReady,
  2048. teardown : jQuery.noop
  2049. },
  2050. live : {
  2051. add : function (handleObj) {
  2052. jQuery.event.add(this, liveConvert(handleObj.origType, handleObj.selector), jQuery.extend({}, handleObj, {
  2053. handler : liveHandler,
  2054. guid : handleObj.handler.guid
  2055. }))
  2056. },
  2057. remove : function (handleObj) {
  2058. jQuery.event.remove(this, liveConvert(handleObj.origType, handleObj.selector), handleObj)
  2059. }
  2060. },
  2061. beforeunload : {
  2062. setup : function (data, namespaces, eventHandle) {
  2063. if (jQuery.isWindow(this)) {
  2064. this.onbeforeunload = eventHandle
  2065. }
  2066. },
  2067. teardown : function (namespaces, eventHandle) {
  2068. if (this.onbeforeunload === eventHandle) {
  2069. this.onbeforeunload = null
  2070. }
  2071. }
  2072. }
  2073. }
  2074. };
  2075. jQuery.removeEvent = document.removeEventListener ? function (elem, type, handle) {
  2076. if (elem.removeEventListener) {
  2077. elem.removeEventListener(type, handle, false)
  2078. }
  2079. }
  2080. : function (elem, type, handle) {
  2081. if (elem.detachEvent) {
  2082. elem.detachEvent("on" + type, handle)
  2083. }
  2084. };
  2085. jQuery.Event = function (src, props) {
  2086. if (!this.preventDefault) {
  2087. return new jQuery.Event(src, props)
  2088. }
  2089. if (src && src.type) {
  2090. this.originalEvent = src;
  2091. this.type = src.type;
  2092. this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse
  2093. } else {
  2094. this.type = src
  2095. }
  2096. if (props) {
  2097. jQuery.extend(this, props)
  2098. }
  2099. this.timeStamp = jQuery.now();
  2100. this[jQuery.expando] = true
  2101. };
  2102. function returnFalse() {
  2103. return false
  2104. }
  2105. function returnTrue() {
  2106. return true
  2107. }
  2108. jQuery.Event.prototype = {
  2109. preventDefault : function () {
  2110. this.isDefaultPrevented = returnTrue;
  2111. var e = this.originalEvent;
  2112. if (!e) {
  2113. return
  2114. }
  2115. if (e.preventDefault) {
  2116. e.preventDefault()
  2117. } else {
  2118. e.returnValue = false
  2119. }
  2120. },
  2121. stopPropagation : function () {
  2122. this.isPropagationStopped = returnTrue;
  2123. var e = this.originalEvent;
  2124. if (!e) {
  2125. return
  2126. }
  2127. if (e.stopPropagation) {
  2128. e.stopPropagation()
  2129. }
  2130. e.cancelBubble = true
  2131. },
  2132. stopImmediatePropagation : function () {
  2133. this.isImmediatePropagationStopped = returnTrue;
  2134. this.stopPropagation()
  2135. },
  2136. isDefaultPrevented : returnFalse,
  2137. isPropagationStopped : returnFalse,
  2138. isImmediatePropagationStopped : returnFalse
  2139. };
  2140. var withinElement = function (event) {
  2141. var parent = event.relatedTarget;
  2142. event.type = event.data;
  2143. try {
  2144. if (parent && parent !== document && !parent.parentNode) {
  2145. return
  2146. }
  2147. while (parent && parent !== this) {
  2148. parent = parent.parentNode
  2149. }
  2150. if (parent !== this) {
  2151. jQuery.event.handle.apply(this, arguments)
  2152. }
  2153. } catch (e) {}
  2154. },
  2155. delegate = function (event) {
  2156. event.type = event.data;
  2157. jQuery.event.handle.apply(this, arguments)
  2158. };
  2159. jQuery.each({
  2160. mouseenter : "mouseover",
  2161. mouseleave : "mouseout"
  2162. }, function (orig, fix) {
  2163. jQuery.event.special[orig] = {
  2164. setup : function (data) {
  2165. jQuery.event.add(this, fix, data && data.selector ? delegate : withinElement, orig)
  2166. },
  2167. teardown : function (data) {
  2168. jQuery.event.remove(this, fix, data && data.selector ? delegate : withinElement)
  2169. }
  2170. }
  2171. });
  2172. if (!jQuery.support.submitBubbles) {
  2173. jQuery.event.special.submit = {
  2174. setup : function (data, namespaces) {
  2175. if (!jQuery.nodeName(this, "form")) {
  2176. jQuery.event.add(this, "click.specialSubmit", function (e) {
  2177. var elem = e.target,
  2178. type = elem.type;
  2179. if ((type === "submit" || type === "image") && jQuery(elem).closest("form").length) {
  2180. trigger("submit", this, arguments)
  2181. }
  2182. });
  2183. jQuery.event.add(this, "keypress.specialSubmit", function (e) {
  2184. var elem = e.target,
  2185. type = elem.type;
  2186. if ((type === "text" || type === "password") && jQuery(elem).closest("form").length && e.keyCode === 13) {
  2187. trigger("submit", this, arguments)
  2188. }
  2189. })
  2190. } else {
  2191. return false
  2192. }
  2193. },
  2194. teardown : function (namespaces) {
  2195. jQuery.event.remove(this, ".specialSubmit")
  2196. }
  2197. }
  2198. }
  2199. if (!jQuery.support.changeBubbles) {
  2200. var changeFilters,
  2201. getVal = function (elem) {
  2202. var type = elem.type,
  2203. val = elem.value;
  2204. if (type === "radio" || type === "checkbox") {
  2205. val = elem.checked
  2206. } else {
  2207. if (type === "select-multiple") {
  2208. val = elem.selectedIndex > -1 ? jQuery.map(elem.options, function (elem) {
  2209. return elem.selected
  2210. }).join("-") : ""
  2211. } else {
  2212. if (jQuery.nodeName(elem, "select")) {
  2213. val = elem.selectedIndex
  2214. }
  2215. }
  2216. }
  2217. return val
  2218. },
  2219. testChange = function testChange(e) {
  2220. var elem = e.target,
  2221. data,
  2222. val;
  2223. if (!rformElems.test(elem.nodeName) || elem.readOnly) {
  2224. return
  2225. }
  2226. data = jQuery._data(elem, "_change_data");
  2227. val = getVal(elem);
  2228. if (e.type !== "focusout" || elem.type !== "radio") {
  2229. jQuery._data(elem, "_change_data", val)
  2230. }
  2231. if (data === undefined || val === data) {
  2232. return
  2233. }
  2234. if (data != null || val) {
  2235. e.type = "change";
  2236. e.liveFired = undefined;
  2237. jQuery.event.trigger(e, arguments[1], elem)
  2238. }
  2239. };
  2240. jQuery.event.special.change = {
  2241. filters : {
  2242. focusout : testChange,
  2243. beforedeactivate : testChange,
  2244. click : function (e) {
  2245. var elem = e.target,
  2246. type = jQuery.nodeName(elem, "input") ? elem.type : "";
  2247. if (type === "radio" || type === "checkbox" || jQuery.nodeName(elem, "select")) {
  2248. testChange.call(this, e)
  2249. }
  2250. },
  2251. keydown : function (e) {
  2252. var elem = e.target,
  2253. type = jQuery.nodeName(elem, "input") ? elem.type : "";
  2254. if ((e.keyCode === 13 && !jQuery.nodeName(elem, "textarea")) || (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || type === "select-multiple") {
  2255. testChange.call(this, e)
  2256. }
  2257. },
  2258. beforeactivate : function (e) {
  2259. var elem = e.target;
  2260. jQuery._data(elem, "_change_data", getVal(elem))
  2261. }
  2262. },
  2263. setup : function (data, namespaces) {
  2264. if (this.type === "file") {
  2265. return false
  2266. }
  2267. for (var type in changeFilters) {
  2268. jQuery.event.add(this, type + ".specialChange", changeFilters[type])
  2269. }
  2270. return rformElems.test(this.nodeName)
  2271. },
  2272. teardown : function (namespaces) {
  2273. jQuery.event.remove(this, ".specialChange");
  2274. return rformElems.test(this.nodeName)
  2275. }
  2276. };
  2277. changeFilters = jQuery.event.special.change.filters;
  2278. changeFilters.focus = changeFilters.beforeactivate
  2279. }
  2280. function trigger(type, elem, args) {
  2281. var event = jQuery.extend({}, args[0]);
  2282. event.type = type;
  2283. event.originalEvent = {};
  2284. event.liveFired = undefined;
  2285. jQuery.event.handle.call(elem, event);
  2286. if (event.isDefaultPrevented()) {
  2287. args[0].preventDefault()
  2288. }
  2289. }
  2290. if (!jQuery.support.focusinBubbles) {
  2291. jQuery.each({
  2292. focus : "focusin",
  2293. blur : "focusout"
  2294. }, function (orig, fix) {
  2295. var attaches = 0;
  2296. jQuery.event.special[fix] = {
  2297. setup : function () {
  2298. if (attaches++ === 0) {
  2299. document.addEventListener(orig, handler, true)
  2300. }
  2301. },
  2302. teardown : function () {
  2303. if (--attaches === 0) {
  2304. document.removeEventListener(orig, handler, true)
  2305. }
  2306. }
  2307. };
  2308. function handler(donor) {
  2309. var e = jQuery.event.fix(donor);
  2310. e.type = fix;
  2311. e.originalEvent = {};
  2312. jQuery.event.trigger(e, null, e.target);
  2313. if (e.isDefaultPrevented()) {
  2314. donor.preventDefault()
  2315. }
  2316. }
  2317. })
  2318. }
  2319. jQuery.each(["bind", "one"], function (i, name) {
  2320. jQuery.fn[name] = function (type, data, fn) {
  2321. var handler;
  2322. if (typeof type === "object") {
  2323. for (var key in type) {
  2324. this[name](key, data, type[key], fn)
  2325. }
  2326. return this
  2327. }
  2328. if (arguments.length === 2 || data === false) {
  2329. fn = data;
  2330. data = undefined
  2331. }
  2332. if (name === "one") {
  2333. handler = function (event) {
  2334. jQuery(this).unbind(event, handler);
  2335. return fn.apply(this, arguments)
  2336. };
  2337. handler.guid = fn.guid || jQuery.guid++
  2338. } else {
  2339. handler = fn
  2340. }
  2341. if (type === "unload" && name !== "one") {
  2342. this.one(type, data, fn)
  2343. } else {
  2344. for (var i = 0, l = this.length; i < l; i++) {
  2345. jQuery.event.add(this[i], type, handler, data)
  2346. }
  2347. }
  2348. return this
  2349. }
  2350. });
  2351. jQuery.fn.extend({
  2352. unbind : function (type, fn) {
  2353. if (typeof type === "object" && !type.preventDefault) {
  2354. for (var key in type) {
  2355. this.unbind(key, type[key])
  2356. }
  2357. } else {
  2358. for (var i = 0, l = this.length; i < l; i++) {
  2359. jQuery.event.remove(this[i], type, fn)
  2360. }
  2361. }
  2362. return this
  2363. },
  2364. delegate : function (selector, types, data, fn) {
  2365. return this.live(types, data, fn, selector)
  2366. },
  2367. undelegate : function (selector, types, fn) {
  2368. if (arguments.length === 0) {
  2369. return this.unbind("live")
  2370. } else {
  2371. return this.die(types, null, fn, selector)
  2372. }
  2373. },
  2374. trigger : function (type, data) {
  2375. return this.each(function () {
  2376. jQuery.event.trigger(type, data, this)
  2377. })
  2378. },
  2379. triggerHandler : function (type, data) {
  2380. if (this[0]) {
  2381. return jQuery.event.trigger(type, data, this[0], true)
  2382. }
  2383. },
  2384. toggle : function (fn) {
  2385. var args = arguments,
  2386. guid = fn.guid || jQuery.guid++,
  2387. i = 0,
  2388. toggler = function (event) {
  2389. var lastToggle = (jQuery.data(this, "lastToggle" + fn.guid) || 0) % i;
  2390. jQuery.data(this, "lastToggle" + fn.guid, lastToggle + 1);
  2391. event.preventDefault();
  2392. return args[lastToggle].apply(this, arguments) || false
  2393. };
  2394. toggler.guid = guid;
  2395. while (i < args.length) {
  2396. args[i++].guid = guid
  2397. }
  2398. return this.click(toggler)
  2399. },
  2400. hover : function (fnOver, fnOut) {
  2401. return this.mouseenter(fnOver).mouseleave(fnOut || fnOver)
  2402. }
  2403. });
  2404. var liveMap = {
  2405. focus : "focusin",
  2406. blur : "focusout",
  2407. mouseenter : "mouseover",
  2408. mouseleave : "mouseout"
  2409. };
  2410. jQuery.each(["live", "die"], function (i, name) {
  2411. jQuery.fn[name] = function (types, data, fn, origSelector) {
  2412. var type,
  2413. i = 0,
  2414. match,
  2415. namespaces,
  2416. preType,
  2417. selector = origSelector || this.selector,
  2418. context = origSelector ? this : jQuery(this.context);
  2419. if (typeof types === "object" && !types.preventDefault) {
  2420. for (var key in types) {
  2421. context[name](key, data, types[key], selector)
  2422. }
  2423. return this
  2424. }
  2425. if (name === "die" && !types && origSelector && origSelector.charAt(0) === ".") {
  2426. context.unbind(origSelector);
  2427. return this
  2428. }
  2429. if (data === false || jQuery.isFunction(data)) {
  2430. fn = data || returnFalse;
  2431. data = undefined
  2432. }
  2433. types = (types || "").split(" ");
  2434. while ((type = types[i++]) != null) {
  2435. match = rnamespaces.exec(type);
  2436. namespaces = "";
  2437. if (match) {
  2438. namespaces = match[0];
  2439. type = type.replace(rnamespaces, "")
  2440. }
  2441. if (type === "hover") {
  2442. types.push("mouseenter" + namespaces, "mouseleave" + namespaces);
  2443. continue
  2444. }
  2445. preType = type;
  2446. if (liveMap[type]) {
  2447. types.push(liveMap[type] + namespaces);
  2448. type = type + namespaces
  2449. } else {
  2450. type = (liveMap[type] || type) + namespaces
  2451. }
  2452. if (name === "live") {
  2453. for (var j = 0, l = context.length; j < l; j++) {
  2454. jQuery.event.add(context[j], "live." + liveConvert(type, selector), {
  2455. data : data,
  2456. selector : selector,
  2457. handler : fn,
  2458. origType : type,
  2459. origHandler : fn,
  2460. preType : preType
  2461. })
  2462. }
  2463. } else {
  2464. context.unbind("live." + liveConvert(type, selector), fn)
  2465. }
  2466. }
  2467. return this
  2468. }
  2469. });
  2470. function liveHandler(event) {
  2471. var stop,
  2472. maxLevel,
  2473. related,
  2474. match,
  2475. handleObj,
  2476. elem,
  2477. j,
  2478. i,
  2479. l,
  2480. data,
  2481. close,
  2482. namespace,
  2483. ret,
  2484. elems = [],
  2485. selectors = [],
  2486. events = jQuery._data(this, "events");
  2487. if (event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click") {
  2488. return
  2489. }
  2490. if (event.namespace) {
  2491. namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)")
  2492. }
  2493. event.liveFired = this;
  2494. var live = events.live.slice(0);
  2495. for (j = 0; j < live.length; j++) {
  2496. handleObj = live[j];
  2497. if (handleObj.origType.replace(rnamespaces, "") === event.type) {
  2498. selectors.push(handleObj.selector)
  2499. } else {
  2500. live.splice(j--, 1)
  2501. }
  2502. }
  2503. match = jQuery(event.target).closest(selectors, event.currentTarget);
  2504. for (i = 0, l = match.length; i < l; i++) {
  2505. close = match[i];
  2506. for (j = 0; j < live.length; j++) {
  2507. handleObj = live[j];
  2508. if (close.selector === handleObj.selector && (!namespace || namespace.test(handleObj.namespace)) && !close.elem.disabled) {
  2509. elem = close.elem;
  2510. related = null;
  2511. if (handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave") {
  2512. event.type = handleObj.preType;
  2513. related = jQuery(event.relatedTarget).closest(handleObj.selector)[0];
  2514. if (related && jQuery.contains(elem, related)) {
  2515. related = elem
  2516. }
  2517. }
  2518. if (!related || related !== elem) {
  2519. elems.push({
  2520. elem : elem,
  2521. handleObj : handleObj,
  2522. level : close.level
  2523. })
  2524. }
  2525. }
  2526. }
  2527. }
  2528. for (i = 0, l = elems.length; i < l; i++) {
  2529. match = elems[i];
  2530. if (maxLevel && match.level > maxLevel) {
  2531. break
  2532. }
  2533. event.currentTarget = match.elem;
  2534. event.data = match.handleObj.data;
  2535. event.handleObj = match.handleObj;
  2536. ret = match.handleObj.origHandler.apply(match.elem, arguments);
  2537. if (ret === false || event.isPropagationStopped()) {
  2538. maxLevel = match.level;
  2539. if (ret === false) {
  2540. stop = false
  2541. }
  2542. if (event.isImmediatePropagationStopped()) {
  2543. break
  2544. }
  2545. }
  2546. }
  2547. return stop
  2548. }
  2549. function liveConvert(type, selector) {
  2550. return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&")
  2551. }
  2552. jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error").split(" "), function (i, name) {
  2553. jQuery.fn[name] = function (data, fn) {
  2554. if (fn == null) {
  2555. fn = data;
  2556. data = null
  2557. }
  2558. return arguments.length > 0 ? this.bind(name, data, fn) : this.trigger(name)
  2559. };
  2560. if (jQuery.attrFn) {
  2561. jQuery.attrFn[name] = true
  2562. }
  2563. });
  2564. /*
  2565. * Sizzle CSS Selector Engine
  2566. * Copyright 2011, The Dojo Foundation
  2567. * Released under the MIT, BSD, and GPL Licenses.
  2568. * More information: http://sizzlejs.com/
  2569. */
  2570. (function () {
  2571. var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
  2572. done = 0,
  2573. toString = Object.prototype.toString,
  2574. hasDuplicate = false,
  2575. baseHasDuplicate = true,
  2576. rBackslash = /\\/g,
  2577. rNonWord = /\W/;
  2578. [0, 0].sort(function () {
  2579. baseHasDuplicate = false;
  2580. return 0
  2581. });
  2582. var Sizzle = function (selector, context, results, seed) {
  2583. results = results || [];
  2584. context = context || document;
  2585. var origContext = context;
  2586. if (context.nodeType !== 1 && context.nodeType !== 9) {
  2587. return []
  2588. }
  2589. if (!selector || typeof selector !== "string") {
  2590. return results
  2591. }
  2592. var m,
  2593. set,
  2594. checkSet,
  2595. extra,
  2596. ret,
  2597. cur,
  2598. pop,
  2599. i,
  2600. prune = true,
  2601. contextXML = Sizzle.isXML(context),
  2602. parts = [],
  2603. soFar = selector;
  2604. do {
  2605. chunker.exec("");
  2606. m = chunker.exec(soFar);
  2607. if (m) {
  2608. soFar = m[3];
  2609. parts.push(m[1]);
  2610. if (m[2]) {
  2611. extra = m[3];
  2612. break
  2613. }
  2614. }
  2615. } while (m);
  2616. if (parts.length > 1 && origPOS.exec(selector)) {
  2617. if (parts.length === 2 && Expr.relative[parts[0]]) {
  2618. set = posProcess(parts[0] + parts[1], context)
  2619. } else {
  2620. set = Expr.relative[parts[0]] ? [context] : Sizzle(parts.shift(), context);
  2621. while (parts.length) {
  2622. selector = parts.shift();
  2623. if (Expr.relative[selector]) {
  2624. selector += parts.shift()
  2625. }
  2626. set = posProcess(selector, set)
  2627. }
  2628. }
  2629. } else {
  2630. if (!seed && parts.length > 1 && context.nodeType === 9 && !contextXML && Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1])) {
  2631. ret = Sizzle.find(parts.shift(), context, contextXML);
  2632. context = ret.expr ? Sizzle.filter(ret.expr, ret.set)[0] : ret.set[0]
  2633. }
  2634. if (context) {
  2635. ret = seed ? {
  2636. expr : parts.pop(),
  2637. set : makeArray(seed)
  2638. }
  2639. : Sizzle.find(parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML);
  2640. set = ret.expr ? Sizzle.filter(ret.expr, ret.set) : ret.set;
  2641. if (parts.length > 0) {
  2642. checkSet = makeArray(set)
  2643. } else {
  2644. prune = false
  2645. }
  2646. while (parts.length) {
  2647. cur = parts.pop();
  2648. pop = cur;
  2649. if (!Expr.relative[cur]) {
  2650. cur = ""
  2651. } else {
  2652. pop = parts.pop()
  2653. }
  2654. if (pop == null) {
  2655. pop = context
  2656. }
  2657. Expr.relative[cur](checkSet, pop, contextXML)
  2658. }
  2659. } else {
  2660. checkSet = parts = []
  2661. }
  2662. }
  2663. if (!checkSet) {
  2664. checkSet = set
  2665. }
  2666. if (!checkSet) {
  2667. Sizzle.error(cur || selector)
  2668. }
  2669. if (toString.call(checkSet) === "[object Array]") {
  2670. if (!prune) {
  2671. results.push.apply(results, checkSet)
  2672. } else {
  2673. if (context && context.nodeType === 1) {
  2674. for (i = 0; checkSet[i] != null; i++) {
  2675. if (checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i]))) {
  2676. results.push(set[i])
  2677. }
  2678. }
  2679. } else {
  2680. for (i = 0; checkSet[i] != null; i++) {
  2681. if (checkSet[i] && checkSet[i].nodeType === 1) {
  2682. results.push(set[i])
  2683. }
  2684. }
  2685. }
  2686. }
  2687. } else {
  2688. makeArray(checkSet, results)
  2689. }
  2690. if (extra) {
  2691. Sizzle(extra, origContext, results, seed);
  2692. Sizzle.uniqueSort(results)
  2693. }
  2694. return results
  2695. };
  2696. Sizzle.uniqueSort = function (results) {
  2697. if (sortOrder) {
  2698. hasDuplicate = baseHasDuplicate;
  2699. results.sort(sortOrder);
  2700. if (hasDuplicate) {
  2701. for (var i = 1; i < results.length; i++) {
  2702. if (results[i] === results[i - 1]) {
  2703. results.splice(i--, 1)
  2704. }
  2705. }
  2706. }
  2707. }
  2708. return results
  2709. };
  2710. Sizzle.matches = function (expr, set) {
  2711. return Sizzle(expr, null, null, set)
  2712. };
  2713. Sizzle.matchesSelector = function (node, expr) {
  2714. return Sizzle(expr, null, null, [node]).length > 0
  2715. };
  2716. Sizzle.find = function (expr, context, isXML) {
  2717. var set;
  2718. if (!expr) {
  2719. return []
  2720. }
  2721. for (var i = 0, l = Expr.order.length; i < l; i++) {
  2722. var match,
  2723. type = Expr.order[i];
  2724. if ((match = Expr.leftMatch[type].exec(expr))) {
  2725. var left = match[1];
  2726. match.splice(1, 1);
  2727. if (left.substr(left.length - 1) !== "\\") {
  2728. match[1] = (match[1] || "").replace(rBackslash, "");
  2729. set = Expr.find[type](match, context, isXML);
  2730. if (set != null) {
  2731. expr = expr.replace(Expr.match[type], "");
  2732. break
  2733. }
  2734. }
  2735. }
  2736. }
  2737. if (!set) {
  2738. set = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName("*") : []
  2739. }
  2740. return {
  2741. set : set,
  2742. expr : expr
  2743. }
  2744. };
  2745. Sizzle.filter = function (expr, set, inplace, not) {
  2746. var match,
  2747. anyFound,
  2748. old = expr,
  2749. result = [],
  2750. curLoop = set,
  2751. isXMLFilter = set && set[0] && Sizzle.isXML(set[0]);
  2752. while (expr && set.length) {
  2753. for (var type in Expr.filter) {
  2754. if ((match = Expr.leftMatch[type].exec(expr)) != null && match[2]) {
  2755. var found,
  2756. item,
  2757. filter = Expr.filter[type],
  2758. left = match[1];
  2759. anyFound = false;
  2760. match.splice(1, 1);
  2761. if (left.substr(left.length - 1) === "\\") {
  2762. continue
  2763. }
  2764. if (curLoop === result) {
  2765. result = []
  2766. }
  2767. if (Expr.preFilter[type]) {
  2768. match = Expr.preFilter[type](match, curLoop, inplace, result, not, isXMLFilter);
  2769. if (!match) {
  2770. anyFound = found = true
  2771. } else {
  2772. if (match === true) {
  2773. continue
  2774. }
  2775. }
  2776. }
  2777. if (match) {
  2778. for (var i = 0; (item = curLoop[i]) != null; i++) {
  2779. if (item) {
  2780. found = filter(item, match, i, curLoop);
  2781. var pass = not^!!found;
  2782. if (inplace && found != null) {
  2783. if (pass) {
  2784. anyFound = true
  2785. } else {
  2786. curLoop[i] = false
  2787. }
  2788. } else {
  2789. if (pass) {
  2790. result.push(item);
  2791. anyFound = true
  2792. }
  2793. }
  2794. }
  2795. }
  2796. }
  2797. if (found !== undefined) {
  2798. if (!inplace) {
  2799. curLoop = result
  2800. }
  2801. expr = expr.replace(Expr.match[type], "");
  2802. if (!anyFound) {
  2803. return []
  2804. }
  2805. break
  2806. }
  2807. }
  2808. }
  2809. if (expr === old) {
  2810. if (anyFound == null) {
  2811. Sizzle.error(expr)
  2812. } else {
  2813. break
  2814. }
  2815. }
  2816. old = expr
  2817. }
  2818. return curLoop
  2819. };
  2820. Sizzle.error = function (msg) {
  2821. throw "Syntax error, unrecognized expression: " + msg
  2822. };
  2823. var Expr = Sizzle.selectors = {
  2824. order : ["ID", "NAME", "TAG"],
  2825. match : {
  2826. ID : /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  2827. CLASS : /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  2828. NAME : /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
  2829. ATTR : /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
  2830. TAG : /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
  2831. CHILD : /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
  2832. POS : /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
  2833. PSEUDO : /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
  2834. },
  2835. leftMatch : {},
  2836. attrMap : {
  2837. "class" : "className",
  2838. "for" : "htmlFor"
  2839. },
  2840. attrHandle : {
  2841. href : function (elem) {
  2842. return elem.getAttribute("href")
  2843. },
  2844. type : function (elem) {
  2845. return elem.getAttribute("type")
  2846. }
  2847. },
  2848. relative : {
  2849. "+" : function (checkSet, part) {
  2850. var isPartStr = typeof part === "string",
  2851. isTag = isPartStr && !rNonWord.test(part),
  2852. isPartStrNotTag = isPartStr && !isTag;
  2853. if (isTag) {
  2854. part = part.toLowerCase()
  2855. }
  2856. for (var i = 0, l = checkSet.length, elem; i < l; i++) {
  2857. if ((elem = checkSet[i])) {
  2858. while ((elem = elem.previousSibling) && elem.nodeType !== 1) {}
  2859. checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? elem || false : elem === part
  2860. }
  2861. }
  2862. if (isPartStrNotTag) {
  2863. Sizzle.filter(part, checkSet, true)
  2864. }
  2865. },
  2866. ">" : function (checkSet, part) {
  2867. var elem,
  2868. isPartStr = typeof part === "string",
  2869. i = 0,
  2870. l = checkSet.length;
  2871. if (isPartStr && !rNonWord.test(part)) {
  2872. part = part.toLowerCase();
  2873. for (; i < l; i++) {
  2874. elem = checkSet[i];
  2875. if (elem) {
  2876. var parent = elem.parentNode;
  2877. checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false
  2878. }
  2879. }
  2880. } else {
  2881. for (; i < l; i++) {
  2882. elem = checkSet[i];
  2883. if (elem) {
  2884. checkSet[i] = isPartStr ? elem.parentNode : elem.parentNode === part
  2885. }
  2886. }
  2887. if (isPartStr) {
  2888. Sizzle.filter(part, checkSet, true)
  2889. }
  2890. }
  2891. },
  2892. "" : function (checkSet, part, isXML) {
  2893. var nodeCheck,
  2894. doneName = done++,
  2895. checkFn = dirCheck;
  2896. if (typeof part === "string" && !rNonWord.test(part)) {
  2897. part = part.toLowerCase();
  2898. nodeCheck = part;
  2899. checkFn = dirNodeCheck
  2900. }
  2901. checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML)
  2902. },
  2903. "~" : function (checkSet, part, isXML) {
  2904. var nodeCheck,
  2905. doneName = done++,
  2906. checkFn = dirCheck;
  2907. if (typeof part === "string" && !rNonWord.test(part)) {
  2908. part = part.toLowerCase();
  2909. nodeCheck = part;
  2910. checkFn = dirNodeCheck
  2911. }
  2912. checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML)
  2913. }
  2914. },
  2915. find : {
  2916. ID : function (match, context, isXML) {
  2917. if (typeof context.getElementById !== "undefined" && !isXML) {
  2918. var m = context.getElementById(match[1]);
  2919. return m && m.parentNode ? [m] : []
  2920. }
  2921. },
  2922. NAME : function (match, context) {
  2923. if (typeof context.getElementsByName !== "undefined") {
  2924. var ret = [],
  2925. results = context.getElementsByName(match[1]);
  2926. for (var i = 0, l = results.length; i < l; i++) {
  2927. if (results[i].getAttribute("name") === match[1]) {
  2928. ret.push(results[i])
  2929. }
  2930. }
  2931. return ret.length === 0 ? null : ret
  2932. }
  2933. },
  2934. TAG : function (match, context) {
  2935. if (typeof context.getElementsByTagName !== "undefined") {
  2936. return context.getElementsByTagName(match[1])
  2937. }
  2938. }
  2939. },
  2940. preFilter : {
  2941. CLASS : function (match, curLoop, inplace, result, not, isXML) {
  2942. match = " " + match[1].replace(rBackslash, "") + " ";
  2943. if (isXML) {
  2944. return match
  2945. }
  2946. for (var i = 0, elem; (elem = curLoop[i]) != null; i++) {
  2947. if (elem) {
  2948. if (not^(elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0)) {
  2949. if (!inplace) {
  2950. result.push(elem)
  2951. }
  2952. } else {
  2953. if (inplace) {
  2954. curLoop[i] = false
  2955. }
  2956. }
  2957. }
  2958. }
  2959. return false
  2960. },
  2961. ID : function (match) {
  2962. return match[1].replace(rBackslash, "")
  2963. },
  2964. TAG : function (match, curLoop) {
  2965. return match[1].replace(rBackslash, "").toLowerCase()
  2966. },
  2967. CHILD : function (match) {
  2968. if (match[1] === "nth") {
  2969. if (!match[2]) {
  2970. Sizzle.error(match[0])
  2971. }
  2972. match[2] = match[2].replace(/^\+|\s*/g, "");
  2973. var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || !/\D/.test(match[2]) && "0n+" + match[2] || match[2]);
  2974. match[2] = (test[1] + (test[2] || 1)) - 0;
  2975. match[3] = test[3] - 0
  2976. } else {
  2977. if (match[2]) {
  2978. Sizzle.error(match[0])
  2979. }
  2980. }
  2981. match[0] = done++;
  2982. return match
  2983. },
  2984. ATTR : function (match, curLoop, inplace, result, not, isXML) {
  2985. var name = match[1] = match[1].replace(rBackslash, "");
  2986. if (!isXML && Expr.attrMap[name]) {
  2987. match[1] = Expr.attrMap[name]
  2988. }
  2989. match[4] = (match[4] || match[5] || "").replace(rBackslash, "");
  2990. if (match[2] === "~=") {
  2991. match[4] = " " + match[4] + " "
  2992. }
  2993. return match
  2994. },
  2995. PSEUDO : function (match, curLoop, inplace, result, not) {
  2996. if (match[1] === "not") {
  2997. if ((chunker.exec(match[3]) || "").length > 1 || /^\w/.test(match[3])) {
  2998. match[3] = Sizzle(match[3], null, null, curLoop)
  2999. } else {
  3000. var ret = Sizzle.filter(match[3], curLoop, inplace, true^not);
  3001. if (!inplace) {
  3002. result.push.apply(result, ret)
  3003. }
  3004. return false
  3005. }
  3006. } else {
  3007. if (Expr.match.POS.test(match[0]) || Expr.match.CHILD.test(match[0])) {
  3008. return true
  3009. }
  3010. }
  3011. return match
  3012. },
  3013. POS : function (match) {
  3014. match.unshift(true);
  3015. return match
  3016. }
  3017. },
  3018. filters : {
  3019. enabled : function (elem) {
  3020. return elem.disabled === false && elem.type !== "hidden"
  3021. },
  3022. disabled : function (elem) {
  3023. return elem.disabled === true
  3024. },
  3025. checked : function (elem) {
  3026. return elem.checked === true
  3027. },
  3028. selected : function (elem) {
  3029. if (elem.parentNode) {
  3030. elem.parentNode.selectedIndex
  3031. }
  3032. return elem.selected === true
  3033. },
  3034. parent : function (elem) {
  3035. return !!elem.firstChild
  3036. },
  3037. empty : function (elem) {
  3038. return !elem.firstChild
  3039. },
  3040. has : function (elem, i, match) {
  3041. return !!Sizzle(match[3], elem).length
  3042. },
  3043. header : function (elem) {
  3044. return (/h\d/i).test(elem.nodeName)
  3045. },
  3046. text : function (elem) {
  3047. var attr = elem.getAttribute("type"),
  3048. type = elem.type;
  3049. return elem.nodeName.toLowerCase() === "input" && "text" === type && (attr === type || attr === null)
  3050. },
  3051. radio : function (elem) {
  3052. return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type
  3053. },
  3054. checkbox : function (elem) {
  3055. return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type
  3056. },
  3057. file : function (elem) {
  3058. return elem.nodeName.toLowerCase() === "input" && "file" === elem.type
  3059. },
  3060. password : function (elem) {
  3061. return elem.nodeName.toLowerCase() === "input" && "password" === elem.type
  3062. },
  3063. submit : function (elem) {
  3064. var name = elem.nodeName.toLowerCase();
  3065. return (name === "input" || name === "button") && "submit" === elem.type
  3066. },
  3067. image : function (elem) {
  3068. return elem.nodeName.toLowerCase() === "input" && "image" === elem.type
  3069. },
  3070. reset : function (elem) {
  3071. var name = elem.nodeName.toLowerCase();
  3072. return (name === "input" || name === "button") && "reset" === elem.type
  3073. },
  3074. button : function (elem) {
  3075. var name = elem.nodeName.toLowerCase();
  3076. return name === "input" && "button" === elem.type || name === "button"
  3077. },
  3078. input : function (elem) {
  3079. return (/input|select|textarea|button/i).test(elem.nodeName)
  3080. },
  3081. focus : function (elem) {
  3082. return elem === elem.ownerDocument.activeElement
  3083. }
  3084. },
  3085. setFilters : {
  3086. first : function (elem, i) {
  3087. return i === 0
  3088. },
  3089. last : function (elem, i, match, array) {
  3090. return i === array.length - 1
  3091. },
  3092. even : function (elem, i) {
  3093. return i % 2 === 0
  3094. },
  3095. odd : function (elem, i) {
  3096. return i % 2 === 1
  3097. },
  3098. lt : function (elem, i, match) {
  3099. return i < match[3] - 0
  3100. },
  3101. gt : function (elem, i, match) {
  3102. return i > match[3] - 0
  3103. },
  3104. nth : function (elem, i, match) {
  3105. return match[3] - 0 === i
  3106. },
  3107. eq : function (elem, i, match) {
  3108. return match[3] - 0 === i
  3109. }
  3110. },
  3111. filter : {
  3112. PSEUDO : function (elem, match, i, array) {
  3113. var name = match[1],
  3114. filter = Expr.filters[name];
  3115. if (filter) {
  3116. return filter(elem, i, match, array)
  3117. } else {
  3118. if (name === "contains") {
  3119. return (elem.textContent || elem.innerText || Sizzle.getText([elem]) || "").indexOf(match[3]) >= 0
  3120. } else {
  3121. if (name === "not") {
  3122. var not = match[3];
  3123. for (var j = 0, l = not.length; j < l; j++) {
  3124. if (not[j] === elem) {
  3125. return false
  3126. }
  3127. }
  3128. return true
  3129. } else {
  3130. Sizzle.error(name)
  3131. }
  3132. }
  3133. }
  3134. },
  3135. CHILD : function (elem, match) {
  3136. var type = match[1],
  3137. node = elem;
  3138. switch (type) {
  3139. case "only":
  3140. case "first":
  3141. while ((node = node.previousSibling)) {
  3142. if (node.nodeType === 1) {
  3143. return false
  3144. }
  3145. }
  3146. if (type === "first") {
  3147. return true
  3148. }
  3149. node = elem;
  3150. case "last":
  3151. while ((node = node.nextSibling)) {
  3152. if (node.nodeType === 1) {
  3153. return false
  3154. }
  3155. }
  3156. return true;
  3157. case "nth":
  3158. var first = match[2],
  3159. last = match[3];
  3160. if (first === 1 && last === 0) {
  3161. return true
  3162. }
  3163. var doneName = match[0],
  3164. parent = elem.parentNode;
  3165. if (parent && (parent.sizcache !== doneName || !elem.nodeIndex)) {
  3166. var count = 0;
  3167. for (node = parent.firstChild; node; node = node.nextSibling) {
  3168. if (node.nodeType === 1) {
  3169. node.nodeIndex = ++count
  3170. }
  3171. }
  3172. parent.sizcache = doneName
  3173. }
  3174. var diff = elem.nodeIndex - last;
  3175. if (first === 0) {
  3176. return diff === 0
  3177. } else {
  3178. return (diff % first === 0 && diff / first >= 0)
  3179. }
  3180. }
  3181. },
  3182. ID : function (elem, match) {
  3183. return elem.nodeType === 1 && elem.getAttribute("id") === match
  3184. },
  3185. TAG : function (elem, match) {
  3186. return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match
  3187. },
  3188. CLASS : function (elem, match) {
  3189. return (" " + (elem.className || elem.getAttribute("class")) + " ").indexOf(match) > -1
  3190. },
  3191. ATTR : function (elem, match) {
  3192. var name = match[1],
  3193. result = Expr.attrHandle[name] ? Expr.attrHandle[name](elem) : elem[name] != null ? elem[name] : elem.getAttribute(name),
  3194. value = result + "",
  3195. type = match[2],
  3196. check = match[4];
  3197. return result == null ? type === "!=" : type === "=" ? value === check : type === "*=" ? value.indexOf(check) >= 0 : type === "~=" ? (" " + value + " ").indexOf(check) >= 0 : !check ? value && result !== false : type === "!=" ? value !== check : type === "^=" ? value.indexOf(check) === 0 : type === "$=" ? value.substr(value.length - check.length) === check : type === "|=" ? value === check || value.substr(0, check.length + 1) === check + "-" : false
  3198. },
  3199. POS : function (elem, match, i, array) {
  3200. var name = match[2],
  3201. filter = Expr.setFilters[name];
  3202. if (filter) {
  3203. return filter(elem, i, match, array)
  3204. }
  3205. }
  3206. }
  3207. };
  3208. var origPOS = Expr.match.POS,
  3209. fescape = function (all, num) {
  3210. return "\\" + (num - 0 + 1)
  3211. };
  3212. for (var type in Expr.match) {
  3213. Expr.match[type] = new RegExp(Expr.match[type].source + (/(?![^\[]*\])(?![^\(]*\))/.source));
  3214. Expr.leftMatch[type] = new RegExp(/(^(?:.|\r|\n)*?)/.source + Expr.match[type].source.replace(/\\(\d+)/g, fescape))
  3215. }
  3216. var makeArray = function (array, results) {
  3217. array = Array.prototype.slice.call(array, 0);
  3218. if (results) {
  3219. results.push.apply(results, array);
  3220. return results
  3221. }
  3222. return array
  3223. };
  3224. try {
  3225. Array.prototype.slice.call(document.documentElement.childNodes, 0)[0].nodeType
  3226. } catch (e) {
  3227. makeArray = function (array, results) {
  3228. var i = 0,
  3229. ret = results || [];
  3230. if (toString.call(array) === "[object Array]") {
  3231. Array.prototype.push.apply(ret, array)
  3232. } else {
  3233. if (typeof array.length === "number") {
  3234. for (var l = array.length; i < l; i++) {
  3235. ret.push(array[i])
  3236. }
  3237. } else {
  3238. for (; array[i]; i++) {
  3239. ret.push(array[i])
  3240. }
  3241. }
  3242. }
  3243. return ret
  3244. }
  3245. }
  3246. var sortOrder,
  3247. siblingCheck;
  3248. if (document.documentElement.compareDocumentPosition) {
  3249. sortOrder = function (a, b) {
  3250. if (a === b) {
  3251. hasDuplicate = true;
  3252. return 0
  3253. }
  3254. if (!a.compareDocumentPosition || !b.compareDocumentPosition) {
  3255. return a.compareDocumentPosition ? -1 : 1
  3256. }
  3257. return a.compareDocumentPosition(b) & 4 ? -1 : 1
  3258. }
  3259. } else {
  3260. sortOrder = function (a, b) {
  3261. if (a === b) {
  3262. hasDuplicate = true;
  3263. return 0
  3264. } else {
  3265. if (a.sourceIndex && b.sourceIndex) {
  3266. return a.sourceIndex - b.sourceIndex
  3267. }
  3268. }
  3269. var al,
  3270. bl,
  3271. ap = [],
  3272. bp = [],
  3273. aup = a.parentNode,
  3274. bup = b.parentNode,
  3275. cur = aup;
  3276. if (aup === bup) {
  3277. return siblingCheck(a, b)
  3278. } else {
  3279. if (!aup) {
  3280. return -1
  3281. } else {
  3282. if (!bup) {
  3283. return 1
  3284. }
  3285. }
  3286. }
  3287. while (cur) {
  3288. ap.unshift(cur);
  3289. cur = cur.parentNode
  3290. }
  3291. cur = bup;
  3292. while (cur) {
  3293. bp.unshift(cur);
  3294. cur = cur.parentNode
  3295. }
  3296. al = ap.length;
  3297. bl = bp.length;
  3298. for (var i = 0; i < al && i < bl; i++) {
  3299. if (ap[i] !== bp[i]) {
  3300. return siblingCheck(ap[i], bp[i])
  3301. }
  3302. }
  3303. return i === al ? siblingCheck(a, bp[i], -1) : siblingCheck(ap[i], b, 1)
  3304. };
  3305. siblingCheck = function (a, b, ret) {
  3306. if (a === b) {
  3307. return ret
  3308. }
  3309. var cur = a.nextSibling;
  3310. while (cur) {
  3311. if (cur === b) {
  3312. return -1
  3313. }
  3314. cur = cur.nextSibling
  3315. }
  3316. return 1
  3317. }
  3318. }
  3319. Sizzle.getText = function (elems) {
  3320. var ret = "",
  3321. elem;
  3322. for (var i = 0; elems[i]; i++) {
  3323. elem = elems[i];
  3324. if (elem.nodeType === 3 || elem.nodeType === 4) {
  3325. ret += elem.nodeValue
  3326. } else {
  3327. if (elem.nodeType !== 8) {
  3328. ret += Sizzle.getText(elem.childNodes)
  3329. }
  3330. }
  3331. }
  3332. return ret
  3333. };
  3334. (function () {
  3335. var form = document.createElement("div"),
  3336. id = "script" + (new Date()).getTime(),
  3337. root = document.documentElement;
  3338. form.innerHTML = "<a name='" + id + "'/>";
  3339. root.insertBefore(form, root.firstChild);
  3340. if (document.getElementById(id)) {
  3341. Expr.find.ID = function (match, context, isXML) {
  3342. if (typeof context.getElementById !== "undefined" && !isXML) {
  3343. var m = context.getElementById(match[1]);
  3344. return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []
  3345. }
  3346. };
  3347. Expr.filter.ID = function (elem, match) {
  3348. var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
  3349. return elem.nodeType === 1 && node && node.nodeValue === match
  3350. }
  3351. }
  3352. root.removeChild(form);
  3353. root = form = null
  3354. })();
  3355. (function () {
  3356. var div = document.createElement("div");
  3357. div.appendChild(document.createComment(""));
  3358. if (div.getElementsByTagName("*").length > 0) {
  3359. Expr.find.TAG = function (match, context) {
  3360. var results = context.getElementsByTagName(match[1]);
  3361. if (match[1] === "*") {
  3362. var tmp = [];
  3363. for (var i = 0; results[i]; i++) {
  3364. if (results[i].nodeType === 1) {
  3365. tmp.push(results[i])
  3366. }
  3367. }
  3368. results = tmp
  3369. }
  3370. return results
  3371. }
  3372. }
  3373. div.innerHTML = "<a href='#'></a>";
  3374. if (div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && div.firstChild.getAttribute("href") !== "#") {
  3375. Expr.attrHandle.href = function (elem) {
  3376. return elem.getAttribute("href", 2)
  3377. }
  3378. }
  3379. div = null
  3380. })();
  3381. if (document.querySelectorAll) {
  3382. (function () {
  3383. var oldSizzle = Sizzle,
  3384. div = document.createElement("div"),
  3385. id = "__sizzle__";
  3386. div.innerHTML = "<p class='TEST'></p>";
  3387. if (div.querySelectorAll && div.querySelectorAll(".TEST").length === 0) {
  3388. return
  3389. }
  3390. Sizzle = function (query, context, extra, seed) {
  3391. context = context || document;
  3392. if (!seed && !Sizzle.isXML(context)) {
  3393. var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(query);
  3394. if (match && (context.nodeType === 1 || context.nodeType === 9)) {
  3395. if (match[1]) {
  3396. return makeArray(context.getElementsByTagName(query), extra)
  3397. } else {
  3398. if (match[2] && Expr.find.CLASS && context.getElementsByClassName) {
  3399. return makeArray(context.getElementsByClassName(match[2]), extra)
  3400. }
  3401. }
  3402. }
  3403. if (context.nodeType === 9) {
  3404. if (query === "body" && context.body) {
  3405. return makeArray([context.body], extra)
  3406. } else {
  3407. if (match && match[3]) {
  3408. var elem = context.getElementById(match[3]);
  3409. if (elem && elem.parentNode) {
  3410. if (elem.id === match[3]) {
  3411. return makeArray([elem], extra)
  3412. }
  3413. } else {
  3414. return makeArray([], extra)
  3415. }
  3416. }
  3417. }
  3418. try {
  3419. return makeArray(context.querySelectorAll(query), extra)
  3420. } catch (qsaError) {}
  3421. } else {
  3422. if (context.nodeType === 1 && context.nodeName.toLowerCase() !== "object") {
  3423. var oldContext = context,
  3424. old = context.getAttribute("id"),
  3425. nid = old || id,
  3426. hasParent = context.parentNode,
  3427. relativeHierarchySelector = /^\s*[+~]/.test(query);
  3428. if (!old) {
  3429. context.setAttribute("id", nid)
  3430. } else {
  3431. nid = nid.replace(/'/g, "\\$&")
  3432. }
  3433. if (relativeHierarchySelector && hasParent) {
  3434. context = context.parentNode
  3435. }
  3436. try {
  3437. if (!relativeHierarchySelector || hasParent) {
  3438. return makeArray(context.querySelectorAll("[id='" + nid + "'] " + query), extra)
  3439. }
  3440. } catch (pseudoError) {}
  3441. finally {
  3442. if (!old) {
  3443. oldContext.removeAttribute("id")
  3444. }
  3445. }
  3446. }
  3447. }
  3448. }
  3449. return oldSizzle(query, context, extra, seed)
  3450. };
  3451. for (var prop in oldSizzle) {
  3452. Sizzle[prop] = oldSizzle[prop]
  3453. }
  3454. div = null
  3455. })()
  3456. }
  3457. (function () {
  3458. var html = document.documentElement,
  3459. matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
  3460. if (matches) {
  3461. var disconnectedMatch = !matches.call(document.createElement("div"), "div"),
  3462. pseudoWorks = false;
  3463. try {
  3464. matches.call(document.documentElement, "[test!='']:sizzle")
  3465. } catch (pseudoError) {
  3466. pseudoWorks = true
  3467. }
  3468. Sizzle.matchesSelector = function (node, expr) {
  3469. expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
  3470. if (!Sizzle.isXML(node)) {
  3471. try {
  3472. if (pseudoWorks || !Expr.match.PSEUDO.test(expr) && !/!=/.test(expr)) {
  3473. var ret = matches.call(node, expr);
  3474. if (ret || !disconnectedMatch || node.document && node.document.nodeType !== 11) {
  3475. return ret
  3476. }
  3477. }
  3478. } catch (e) {}
  3479. }
  3480. return Sizzle(expr, null, null, [node]).length > 0
  3481. }
  3482. }
  3483. })();
  3484. (function () {
  3485. var div = document.createElement("div");
  3486. div.innerHTML = "<div class='test e'></div><div class='test'></div>";
  3487. if (!div.getElementsByClassName || div.getElementsByClassName("e").length === 0) {
  3488. return
  3489. }
  3490. div.lastChild.className = "e";
  3491. if (div.getElementsByClassName("e").length === 1) {
  3492. return
  3493. }
  3494. Expr.order.splice(1, 0, "CLASS");
  3495. Expr.find.CLASS = function (match, context, isXML) {
  3496. if (typeof context.getElementsByClassName !== "undefined" && !isXML) {
  3497. return context.getElementsByClassName(match[1])
  3498. }
  3499. };
  3500. div = null
  3501. })();
  3502. function dirNodeCheck(dir, cur, doneName, checkSet, nodeCheck, isXML) {
  3503. for (var i = 0, l = checkSet.length; i < l; i++) {
  3504. var elem = checkSet[i];
  3505. if (elem) {
  3506. var match = false;
  3507. elem = elem[dir];
  3508. while (elem) {
  3509. if (elem.sizcache === doneName) {
  3510. match = checkSet[elem.sizset];
  3511. break
  3512. }
  3513. if (elem.nodeType === 1 && !isXML) {
  3514. elem.sizcache = doneName;
  3515. elem.sizset = i
  3516. }
  3517. if (elem.nodeName.toLowerCase() === cur) {
  3518. match = elem;
  3519. break
  3520. }
  3521. elem = elem[dir]
  3522. }
  3523. checkSet[i] = match
  3524. }
  3525. }
  3526. }
  3527. function dirCheck(dir, cur, doneName, checkSet, nodeCheck, isXML) {
  3528. for (var i = 0, l = checkSet.length; i < l; i++) {
  3529. var elem = checkSet[i];
  3530. if (elem) {
  3531. var match = false;
  3532. elem = elem[dir];
  3533. while (elem) {
  3534. if (elem.sizcache === doneName) {
  3535. match = checkSet[elem.sizset];
  3536. break
  3537. }
  3538. if (elem.nodeType === 1) {
  3539. if (!isXML) {
  3540. elem.sizcache = doneName;
  3541. elem.sizset = i
  3542. }
  3543. if (typeof cur !== "string") {
  3544. if (elem === cur) {
  3545. match = true;
  3546. break
  3547. }
  3548. } else {
  3549. if (Sizzle.filter(cur, [elem]).length > 0) {
  3550. match = elem;
  3551. break
  3552. }
  3553. }
  3554. }
  3555. elem = elem[dir]
  3556. }
  3557. checkSet[i] = match
  3558. }
  3559. }
  3560. }
  3561. if (document.documentElement.contains) {
  3562. Sizzle.contains = function (a, b) {
  3563. return a !== b && (a.contains ? a.contains(b) : true)
  3564. }
  3565. } else {
  3566. if (document.documentElement.compareDocumentPosition) {
  3567. Sizzle.contains = function (a, b) {
  3568. return !!(a.compareDocumentPosition(b) & 16)
  3569. }
  3570. } else {
  3571. Sizzle.contains = function () {
  3572. return false
  3573. }
  3574. }
  3575. }
  3576. Sizzle.isXML = function (elem) {
  3577. var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
  3578. return documentElement ? documentElement.nodeName !== "HTML" : false
  3579. };
  3580. var posProcess = function (selector, context) {
  3581. var match,
  3582. tmpSet = [],
  3583. later = "",
  3584. root = context.nodeType ? [context] : context;
  3585. while ((match = Expr.match.PSEUDO.exec(selector))) {
  3586. later += match[0];
  3587. selector = selector.replace(Expr.match.PSEUDO, "")
  3588. }
  3589. selector = Expr.relative[selector] ? selector + "*" : selector;
  3590. for (var i = 0, l = root.length; i < l; i++) {
  3591. Sizzle(selector, root[i], tmpSet)
  3592. }
  3593. return Sizzle.filter(later, tmpSet)
  3594. };
  3595. jQuery.find = Sizzle;
  3596. jQuery.expr = Sizzle.selectors;
  3597. jQuery.expr[":"] = jQuery.expr.filters;
  3598. jQuery.unique = Sizzle.uniqueSort;
  3599. jQuery.text = Sizzle.getText;
  3600. jQuery.isXMLDoc = Sizzle.isXML;
  3601. jQuery.contains = Sizzle.contains
  3602. })();
  3603. var runtil = /Until$/,
  3604. rparentsprev = /^(?:parents|prevUntil|prevAll)/,
  3605. rmultiselector = /,/,
  3606. isSimple = /^.[^:#\[\.,]*$/,
  3607. slice = Array.prototype.slice,
  3608. POS = jQuery.expr.match.POS,
  3609. guaranteedUnique = {
  3610. children : true,
  3611. contents : true,
  3612. next : true,
  3613. prev : true
  3614. };
  3615. jQuery.fn.extend({
  3616. find : function (selector) {
  3617. var self = this,
  3618. i,
  3619. l;
  3620. if (typeof selector !== "string") {
  3621. return jQuery(selector).filter(function () {
  3622. for (i = 0, l = self.length; i < l; i++) {
  3623. if (jQuery.contains(self[i], this)) {
  3624. return true
  3625. }
  3626. }
  3627. })
  3628. }
  3629. var ret = this.pushStack("", "find", selector),
  3630. length,
  3631. n,
  3632. r;
  3633. for (i = 0, l = this.length; i < l; i++) {
  3634. length = ret.length;
  3635. jQuery.find(selector, this[i], ret);
  3636. if (i > 0) {
  3637. for (n = length; n < ret.length; n++) {
  3638. for (r = 0; r < length; r++) {
  3639. if (ret[r] === ret[n]) {
  3640. ret.splice(n--, 1);
  3641. break
  3642. }
  3643. }
  3644. }
  3645. }
  3646. }
  3647. return ret
  3648. },
  3649. has : function (target) {
  3650. var targets = jQuery(target);
  3651. return this.filter(function () {
  3652. for (var i = 0, l = targets.length; i < l; i++) {
  3653. if (jQuery.contains(this, targets[i])) {
  3654. return true
  3655. }
  3656. }
  3657. })
  3658. },
  3659. not : function (selector) {
  3660. return this.pushStack(winnow(this, selector, false), "not", selector)
  3661. },
  3662. filter : function (selector) {
  3663. return this.pushStack(winnow(this, selector, true), "filter", selector)
  3664. },
  3665. is : function (selector) {
  3666. return !!selector && (typeof selector === "string" ? jQuery.filter(selector, this).length > 0 : this.filter(selector).length > 0)
  3667. },
  3668. closest : function (selectors, context) {
  3669. var ret = [],
  3670. i,
  3671. l,
  3672. cur = this[0];
  3673. if (jQuery.isArray(selectors)) {
  3674. var match,
  3675. selector,
  3676. matches = {},
  3677. level = 1;
  3678. if (cur && selectors.length) {
  3679. for (i = 0, l = selectors.length; i < l; i++) {
  3680. selector = selectors[i];
  3681. if (!matches[selector]) {
  3682. matches[selector] = POS.test(selector) ? jQuery(selector, context || this.context) : selector
  3683. }
  3684. }
  3685. while (cur && cur.ownerDocument && cur !== context) {
  3686. for (selector in matches) {
  3687. match = matches[selector];
  3688. if (match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match)) {
  3689. ret.push({
  3690. selector : selector,
  3691. elem : cur,
  3692. level : level
  3693. })
  3694. }
  3695. }
  3696. cur = cur.parentNode;
  3697. level++
  3698. }
  3699. }
  3700. return ret
  3701. }
  3702. var pos = POS.test(selectors) || typeof selectors !== "string" ? jQuery(selectors, context || this.context) : 0;
  3703. for (i = 0, l = this.length; i < l; i++) {
  3704. cur = this[i];
  3705. while (cur) {
  3706. if (pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors)) {
  3707. ret.push(cur);
  3708. break
  3709. } else {
  3710. cur = cur.parentNode;
  3711. if (!cur || !cur.ownerDocument || cur === context || cur.nodeType === 11) {
  3712. break
  3713. }
  3714. }
  3715. }
  3716. }
  3717. ret = ret.length > 1 ? jQuery.unique(ret) : ret;
  3718. return this.pushStack(ret, "closest", selectors)
  3719. },
  3720. index : function (elem) {
  3721. if (!elem || typeof elem === "string") {
  3722. return jQuery.inArray(this[0], elem ? jQuery(elem) : this.parent().children())
  3723. }
  3724. return jQuery.inArray(elem.jquery ? elem[0] : elem, this)
  3725. },
  3726. add : function (selector, context) {
  3727. var set = typeof selector === "string" ? jQuery(selector, context) : jQuery.makeArray(selector && selector.nodeType ? [selector] : selector),
  3728. all = jQuery.merge(this.get(), set);
  3729. return this.pushStack(isDisconnected(set[0]) || isDisconnected(all[0]) ? all : jQuery.unique(all))
  3730. },
  3731. andSelf : function () {
  3732. return this.add(this.prevObject)
  3733. }
  3734. });
  3735. function isDisconnected(node) {
  3736. return !node || !node.parentNode || node.parentNode.nodeType === 11
  3737. }
  3738. jQuery.each({
  3739. parent : function (elem) {
  3740. var parent = elem.parentNode;
  3741. return parent && parent.nodeType !== 11 ? parent : null
  3742. },
  3743. parents : function (elem) {
  3744. return jQuery.dir(elem, "parentNode")
  3745. },
  3746. parentsUntil : function (elem, i, until) {
  3747. return jQuery.dir(elem, "parentNode", until)
  3748. },
  3749. next : function (elem) {
  3750. return jQuery.nth(elem, 2, "nextSibling")
  3751. },
  3752. prev : function (elem) {
  3753. return jQuery.nth(elem, 2, "previousSibling")
  3754. },
  3755. nextAll : function (elem) {
  3756. return jQuery.dir(elem, "nextSibling")
  3757. },
  3758. prevAll : function (elem) {
  3759. return jQuery.dir(elem, "previousSibling")
  3760. },
  3761. nextUntil : function (elem, i, until) {
  3762. return jQuery.dir(elem, "nextSibling", until)
  3763. },
  3764. prevUntil : function (elem, i, until) {
  3765. return jQuery.dir(elem, "previousSibling", until)
  3766. },
  3767. siblings : function (elem) {
  3768. return jQuery.sibling(elem.parentNode.firstChild, elem)
  3769. },
  3770. children : function (elem) {
  3771. return jQuery.sibling(elem.firstChild)
  3772. },
  3773. contents : function (elem) {
  3774. return jQuery.nodeName(elem, "iframe") ? elem.contentDocument || elem.contentWindow.document : jQuery.makeArray(elem.childNodes)
  3775. }
  3776. }, function (name, fn) {
  3777. jQuery.fn[name] = function (until, selector) {
  3778. var ret = jQuery.map(this, fn, until),
  3779. args = slice.call(arguments);
  3780. if (!runtil.test(name)) {
  3781. selector = until
  3782. }
  3783. if (selector && typeof selector === "string") {
  3784. ret = jQuery.filter(selector, ret)
  3785. }
  3786. ret = this.length > 1 && !guaranteedUnique[name] ? jQuery.unique(ret) : ret;
  3787. if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) {
  3788. ret = ret.reverse()
  3789. }
  3790. return this.pushStack(ret, name, args.join(","))
  3791. }
  3792. });
  3793. jQuery.extend({
  3794. filter : function (expr, elems, not) {
  3795. if (not) {
  3796. expr = ":not(" + expr + ")"
  3797. }
  3798. return elems.length === 1 ? jQuery.find.matchesSelector(elems[0], expr) ? [elems[0]] : [] : jQuery.find.matches(expr, elems)
  3799. },
  3800. dir : function (elem, dir, until) {
  3801. var matched = [],
  3802. cur = elem[dir];
  3803. while (cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery(cur).is(until))) {
  3804. if (cur.nodeType === 1) {
  3805. matched.push(cur)
  3806. }
  3807. cur = cur[dir]
  3808. }
  3809. return matched
  3810. },
  3811. nth : function (cur, result, dir, elem) {
  3812. result = result || 1;
  3813. var num = 0;
  3814. for (; cur; cur = cur[dir]) {
  3815. if (cur.nodeType === 1 && ++num === result) {
  3816. break
  3817. }
  3818. }
  3819. return cur
  3820. },
  3821. sibling : function (n, elem) {
  3822. var r = [];
  3823. for (; n; n = n.nextSibling) {
  3824. if (n.nodeType === 1 && n !== elem) {
  3825. r.push(n)
  3826. }
  3827. }
  3828. return r
  3829. }
  3830. });
  3831. function winnow(elements, qualifier, keep) {
  3832. qualifier = qualifier || 0;
  3833. if (jQuery.isFunction(qualifier)) {
  3834. return jQuery.grep(elements, function (elem, i) {
  3835. var retVal = !!qualifier.call(elem, i, elem);
  3836. return retVal === keep
  3837. })
  3838. } else {
  3839. if (qualifier.nodeType) {
  3840. return jQuery.grep(elements, function (elem, i) {
  3841. return (elem === qualifier) === keep
  3842. })
  3843. } else {
  3844. if (typeof qualifier === "string") {
  3845. var filtered = jQuery.grep(elements, function (elem) {
  3846. return elem.nodeType === 1
  3847. });
  3848. if (isSimple.test(qualifier)) {
  3849. return jQuery.filter(qualifier, filtered, !keep)
  3850. } else {
  3851. qualifier = jQuery.filter(qualifier, filtered)
  3852. }
  3853. }
  3854. }
  3855. }
  3856. return jQuery.grep(elements, function (elem, i) {
  3857. return (jQuery.inArray(elem, qualifier) >= 0) === keep
  3858. })
  3859. }
  3860. var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
  3861. rleadingWhitespace = /^\s+/,
  3862. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
  3863. rtagName = /<([\w:]+)/,
  3864. rtbody = /<tbody/i,
  3865. rhtml = /<|&#?\w+;/,
  3866. rnocache = /<(?:script|object|embed|option|style)/i,
  3867. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  3868. rscriptType = /\/(java|ecma)script/i,
  3869. rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
  3870. wrapMap = {
  3871. option : [1, "<select multiple='multiple'>", "</select>"],
  3872. legend : [1, "<fieldset>", "</fieldset>"],
  3873. thead : [1, "<table>", "</table>"],
  3874. tr : [2, "<table><tbody>", "</tbody></table>"],
  3875. td : [3, "<table><tbody><tr>", "</tr></tbody></table>"],
  3876. col : [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"],
  3877. area : [1, "<map>", "</map>"],
  3878. _default : [0, "", ""]
  3879. };
  3880. wrapMap.optgroup = wrapMap.option;
  3881. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  3882. wrapMap.th = wrapMap.td;
  3883. if (!jQuery.support.htmlSerialize) {
  3884. wrapMap._default = [1, "div<div>", "</div>"]
  3885. }
  3886. jQuery.fn.extend({
  3887. text : function (text) {
  3888. if (jQuery.isFunction(text)) {
  3889. return this.each(function (i) {
  3890. var self = jQuery(this);
  3891. self.text(text.call(this, i, self.text()))
  3892. })
  3893. }
  3894. if (typeof text !== "object" && text !== undefined) {
  3895. return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(text))
  3896. }
  3897. return jQuery.text(this)
  3898. },
  3899. wrapAll : function (html) {
  3900. if (jQuery.isFunction(html)) {
  3901. return this.each(function (i) {
  3902. jQuery(this).wrapAll(html.call(this, i))
  3903. })
  3904. }
  3905. if (this[0]) {
  3906. var wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
  3907. if (this[0].parentNode) {
  3908. wrap.insertBefore(this[0])
  3909. }
  3910. wrap.map(function () {
  3911. var elem = this;
  3912. while (elem.firstChild && elem.firstChild.nodeType === 1) {
  3913. elem = elem.firstChild
  3914. }
  3915. return elem
  3916. }).append(this)
  3917. }
  3918. return this
  3919. },
  3920. wrapInner : function (html) {
  3921. if (jQuery.isFunction(html)) {
  3922. return this.each(function (i) {
  3923. jQuery(this).wrapInner(html.call(this, i))
  3924. })
  3925. }
  3926. return this.each(function () {
  3927. var self = jQuery(this),
  3928. contents = self.contents();
  3929. if (contents.length) {
  3930. contents.wrapAll(html)
  3931. } else {
  3932. self.append(html)
  3933. }
  3934. })
  3935. },
  3936. wrap : function (html) {
  3937. return this.each(function () {
  3938. jQuery(this).wrapAll(html)
  3939. })
  3940. },
  3941. unwrap : function () {
  3942. return this.parent().each(function () {
  3943. if (!jQuery.nodeName(this, "body")) {
  3944. jQuery(this).replaceWith(this.childNodes)
  3945. }
  3946. }).end()
  3947. },
  3948. append : function () {
  3949. return this.domManip(arguments, true, function (elem) {
  3950. if (this.nodeType === 1) {
  3951. this.appendChild(elem)
  3952. }
  3953. })
  3954. },
  3955. prepend : function () {
  3956. return this.domManip(arguments, true, function (elem) {
  3957. if (this.nodeType === 1) {
  3958. this.insertBefore(elem, this.firstChild)
  3959. }
  3960. })
  3961. },
  3962. before : function () {
  3963. if (this[0] && this[0].parentNode) {
  3964. return this.domManip(arguments, false, function (elem) {
  3965. this.parentNode.insertBefore(elem, this)
  3966. })
  3967. } else {
  3968. if (arguments.length) {
  3969. var set = jQuery(arguments[0]);
  3970. set.push.apply(set, this.toArray());
  3971. return this.pushStack(set, "before", arguments)
  3972. }
  3973. }
  3974. },
  3975. after : function () {
  3976. if (this[0] && this[0].parentNode) {
  3977. return this.domManip(arguments, false, function (elem) {
  3978. this.parentNode.insertBefore(elem, this.nextSibling)
  3979. })
  3980. } else {
  3981. if (arguments.length) {
  3982. var set = this.pushStack(this, "after", arguments);
  3983. set.push.apply(set, jQuery(arguments[0]).toArray());
  3984. return set
  3985. }
  3986. }
  3987. },
  3988. remove : function (selector, keepData) {
  3989. for (var i = 0, elem; (elem = this[i]) != null; i++) {
  3990. if (!selector || jQuery.filter(selector, [elem]).length) {
  3991. if (!keepData && elem.nodeType === 1) {
  3992. jQuery.cleanData(elem.getElementsByTagName("*"));
  3993. jQuery.cleanData([elem])
  3994. }
  3995. if (elem.parentNode) {
  3996. elem.parentNode.removeChild(elem)
  3997. }
  3998. }
  3999. }
  4000. return this
  4001. },
  4002. empty : function () {
  4003. for (var i = 0, elem; (elem = this[i]) != null; i++) {
  4004. if (elem.nodeType === 1) {
  4005. jQuery.cleanData(elem.getElementsByTagName("*"))
  4006. }
  4007. while (elem.firstChild) {
  4008. elem.removeChild(elem.firstChild)
  4009. }
  4010. }
  4011. return this
  4012. },
  4013. clone : function (dataAndEvents, deepDataAndEvents) {
  4014. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4015. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4016. return this.map(function () {
  4017. return jQuery.clone(this, dataAndEvents, deepDataAndEvents)
  4018. })
  4019. },
  4020. html : function (value) {
  4021. if (value === undefined) {
  4022. return this[0] && this[0].nodeType === 1 ? this[0].innerHTML.replace(rinlinejQuery, "") : null
  4023. } else {
  4024. if (typeof value === "string" && !rnocache.test(value) && (jQuery.support.leadingWhitespace || !rleadingWhitespace.test(value)) && !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) {
  4025. value = value.replace(rxhtmlTag, "<$1></$2>");
  4026. try {
  4027. for (var i = 0, l = this.length; i < l; i++) {
  4028. if (this[i].nodeType === 1) {
  4029. jQuery.cleanData(this[i].getElementsByTagName("*"));
  4030. this[i].innerHTML = value
  4031. }
  4032. }
  4033. } catch (e) {
  4034. this.empty().append(value)
  4035. }
  4036. } else {
  4037. if (jQuery.isFunction(value)) {
  4038. this.each(function (i) {
  4039. var self = jQuery(this);
  4040. self.html(value.call(this, i, self.html()))
  4041. })
  4042. } else {
  4043. this.empty().append(value)
  4044. }
  4045. }
  4046. }
  4047. return this
  4048. },
  4049. replaceWith : function (value) {
  4050. if (this[0] && this[0].parentNode) {
  4051. if (jQuery.isFunction(value)) {
  4052. return this.each(function (i) {
  4053. var self = jQuery(this),
  4054. old = self.html();
  4055. self.replaceWith(value.call(this, i, old))
  4056. })
  4057. }
  4058. if (typeof value !== "string") {
  4059. value = jQuery(value).detach()
  4060. }
  4061. return this.each(function () {
  4062. var next = this.nextSibling,
  4063. parent = this.parentNode;
  4064. jQuery(this).remove();
  4065. if (next) {
  4066. jQuery(next).before(value)
  4067. } else {
  4068. jQuery(parent).append(value)
  4069. }
  4070. })
  4071. } else {
  4072. return this.length ? this.pushStack(jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value) : this
  4073. }
  4074. },
  4075. detach : function (selector) {
  4076. return this.remove(selector, true)
  4077. },
  4078. domManip : function (args, table, callback) {
  4079. var results,
  4080. first,
  4081. fragment,
  4082. parent,
  4083. value = args[0],
  4084. scripts = [];
  4085. if (!jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test(value)) {
  4086. return this.each(function () {
  4087. jQuery(this).domManip(args, table, callback, true)
  4088. })
  4089. }
  4090. if (jQuery.isFunction(value)) {
  4091. return this.each(function (i) {
  4092. var self = jQuery(this);
  4093. args[0] = value.call(this, i, table ? self.html() : undefined);
  4094. self.domManip(args, table, callback)
  4095. })
  4096. }
  4097. if (this[0]) {
  4098. parent = value && value.parentNode;
  4099. if (jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length) {
  4100. results = {
  4101. fragment : parent
  4102. }
  4103. } else {
  4104. results = jQuery.buildFragment(args, this, scripts)
  4105. }
  4106. fragment = results.fragment;
  4107. if (fragment.childNodes.length === 1) {
  4108. first = fragment = fragment.firstChild
  4109. } else {
  4110. first = fragment.firstChild
  4111. }
  4112. if (first) {
  4113. table = table && jQuery.nodeName(first, "tr");
  4114. for (var i = 0, l = this.length, lastIndex = l - 1; i < l; i++) {
  4115. callback.call(table ? root(this[i], first) : this[i], results.cacheable || (l > 1 && i < lastIndex) ? jQuery.clone(fragment, true, true) : fragment)
  4116. }
  4117. }
  4118. if (scripts.length) {
  4119. jQuery.each(scripts, evalScript)
  4120. }
  4121. }
  4122. return this
  4123. }
  4124. });
  4125. function root(elem, cur) {
  4126. return jQuery.nodeName(elem, "table") ? (elem.getElementsByTagName("tbody")[0] || elem.appendChild(elem.ownerDocument.createElement("tbody"))) : elem
  4127. }
  4128. function cloneCopyEvent(src, dest) {
  4129. if (dest.nodeType !== 1 || !jQuery.hasData(src)) {
  4130. return
  4131. }
  4132. var internalKey = jQuery.expando,
  4133. oldData = jQuery.data(src),
  4134. curData = jQuery.data(dest, oldData);
  4135. if ((oldData = oldData[internalKey])) {
  4136. var events = oldData.events;
  4137. curData = curData[internalKey] = jQuery.extend({}, oldData);
  4138. if (events) {
  4139. delete curData.handle;
  4140. curData.events = {};
  4141. for (var type in events) {
  4142. for (var i = 0, l = events[type].length; i < l; i++) {
  4143. jQuery.event.add(dest, type + (events[type][i].namespace ? "." : "") + events[type][i].namespace, events[type][i], events[type][i].data)
  4144. }
  4145. }
  4146. }
  4147. }
  4148. }
  4149. function cloneFixAttributes(src, dest) {
  4150. var nodeName;
  4151. if (dest.nodeType !== 1) {
  4152. return
  4153. }
  4154. if (dest.clearAttributes) {
  4155. dest.clearAttributes()
  4156. }
  4157. if (dest.mergeAttributes) {
  4158. dest.mergeAttributes(src)
  4159. }
  4160. nodeName = dest.nodeName.toLowerCase();
  4161. if (nodeName === "object") {
  4162. dest.outerHTML = src.outerHTML
  4163. } else {
  4164. if (nodeName === "input" && (src.type === "checkbox" || src.type === "radio")) {
  4165. if (src.checked) {
  4166. dest.defaultChecked = dest.checked = src.checked
  4167. }
  4168. if (dest.value !== src.value) {
  4169. dest.value = src.value
  4170. }
  4171. } else {
  4172. if (nodeName === "option") {
  4173. dest.selected = src.defaultSelected
  4174. } else {
  4175. if (nodeName === "input" || nodeName === "textarea") {
  4176. dest.defaultValue = src.defaultValue
  4177. }
  4178. }
  4179. }
  4180. }
  4181. dest.removeAttribute(jQuery.expando)
  4182. }
  4183. jQuery.buildFragment = function (args, nodes, scripts) {
  4184. var fragment,
  4185. cacheable,
  4186. cacheresults,
  4187. doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
  4188. if (args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document && args[0].charAt(0) === "<" && !rnocache.test(args[0]) && (jQuery.support.checkClone || !rchecked.test(args[0]))) {
  4189. cacheable = true;
  4190. cacheresults = jQuery.fragments[args[0]];
  4191. if (cacheresults && cacheresults !== 1) {
  4192. fragment = cacheresults
  4193. }
  4194. }
  4195. if (!fragment) {
  4196. fragment = doc.createDocumentFragment();
  4197. jQuery.clean(args, doc, fragment, scripts)
  4198. }
  4199. if (cacheable) {
  4200. jQuery.fragments[args[0]] = cacheresults ? fragment : 1
  4201. }
  4202. return {
  4203. fragment : fragment,
  4204. cacheable : cacheable
  4205. }
  4206. };
  4207. jQuery.fragments = {};
  4208. jQuery.each({
  4209. appendTo : "append",
  4210. prependTo : "prepend",
  4211. insertBefore : "before",
  4212. insertAfter : "after",
  4213. replaceAll : "replaceWith"
  4214. }, function (name, original) {
  4215. jQuery.fn[name] = function (selector) {
  4216. var ret = [],
  4217. insert = jQuery(selector),
  4218. parent = this.length === 1 && this[0].parentNode;
  4219. if (parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1) {
  4220. insert[original](this[0]);
  4221. return this
  4222. } else {
  4223. for (var i = 0, l = insert.length; i < l; i++) {
  4224. var elems = (i > 0 ? this.clone(true) : this).get();
  4225. jQuery(insert[i])[original](elems);
  4226. ret = ret.concat(elems)
  4227. }
  4228. return this.pushStack(ret, name, insert.selector)
  4229. }
  4230. }
  4231. });
  4232. function getAll(elem) {
  4233. if ("getElementsByTagName" in elem) {
  4234. return elem.getElementsByTagName("*")
  4235. } else {
  4236. if ("querySelectorAll" in elem) {
  4237. return elem.querySelectorAll("*")
  4238. } else {
  4239. return []
  4240. }
  4241. }
  4242. }
  4243. function fixDefaultChecked(elem) {
  4244. if (elem.type === "checkbox" || elem.type === "radio") {
  4245. elem.defaultChecked = elem.checked
  4246. }
  4247. }
  4248. function findInputs(elem) {
  4249. if (jQuery.nodeName(elem, "input")) {
  4250. fixDefaultChecked(elem)
  4251. } else {
  4252. if (elem.getElementsByTagName) {
  4253. jQuery.grep(elem.getElementsByTagName("input"), fixDefaultChecked)
  4254. }
  4255. }
  4256. }
  4257. jQuery.extend({
  4258. clone : function (elem, dataAndEvents, deepDataAndEvents) {
  4259. var clone = elem.cloneNode(true),
  4260. srcElements,
  4261. destElements,
  4262. i;
  4263. if ((!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) {
  4264. cloneFixAttributes(elem, clone);
  4265. srcElements = getAll(elem);
  4266. destElements = getAll(clone);
  4267. for (i = 0; srcElements[i]; ++i) {
  4268. cloneFixAttributes(srcElements[i], destElements[i])
  4269. }
  4270. }
  4271. if (dataAndEvents) {
  4272. cloneCopyEvent(elem, clone);
  4273. if (deepDataAndEvents) {
  4274. srcElements = getAll(elem);
  4275. destElements = getAll(clone);
  4276. for (i = 0; srcElements[i]; ++i) {
  4277. cloneCopyEvent(srcElements[i], destElements[i])
  4278. }
  4279. }
  4280. }
  4281. return clone
  4282. },
  4283. clean : function (elems, context, fragment, scripts) {
  4284. var checkScriptType;
  4285. context = context || document;
  4286. if (typeof context.createElement === "undefined") {
  4287. context = context.ownerDocument || context[0] && context[0].ownerDocument || document
  4288. }
  4289. var ret = [],
  4290. j;
  4291. for (var i = 0, elem; (elem = elems[i]) != null; i++) {
  4292. if (typeof elem === "number") {
  4293. elem += ""
  4294. }
  4295. if (!elem) {
  4296. continue
  4297. }
  4298. if (typeof elem === "string") {
  4299. if (!rhtml.test(elem)) {
  4300. elem = context.createTextNode(elem)
  4301. } else {
  4302. elem = elem.replace(rxhtmlTag, "<$1></$2>");
  4303. var tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(),
  4304. wrap = wrapMap[tag] || wrapMap._default,
  4305. depth = wrap[0],
  4306. div = context.createElement("div");
  4307. div.innerHTML = wrap[1] + elem + wrap[2];
  4308. while (depth--) {
  4309. div = div.lastChild
  4310. }
  4311. if (!jQuery.support.tbody) {
  4312. var hasBody = rtbody.test(elem),
  4313. tbody = tag === "table" && !hasBody ? div.firstChild && div.firstChild.childNodes : wrap[1] === "<table>" && !hasBody ? div.childNodes : [];
  4314. for (j = tbody.length - 1; j >= 0; --j) {
  4315. if (jQuery.nodeName(tbody[j], "tbody") && !tbody[j].childNodes.length) {
  4316. tbody[j].parentNode.removeChild(tbody[j])
  4317. }
  4318. }
  4319. }
  4320. if (!jQuery.support.leadingWhitespace && rleadingWhitespace.test(elem)) {
  4321. div.insertBefore(context.createTextNode(rleadingWhitespace.exec(elem)[0]), div.firstChild)
  4322. }
  4323. elem = div.childNodes
  4324. }
  4325. }
  4326. var len;
  4327. if (!jQuery.support.appendChecked) {
  4328. if (elem[0] && typeof(len = elem.length) === "number") {
  4329. for (j = 0; j < len; j++) {
  4330. findInputs(elem[j])
  4331. }
  4332. } else {
  4333. findInputs(elem)
  4334. }
  4335. }
  4336. if (elem.nodeType) {
  4337. ret.push(elem)
  4338. } else {
  4339. ret = jQuery.merge(ret, elem)
  4340. }
  4341. }
  4342. if (fragment) {
  4343. checkScriptType = function (elem) {
  4344. return !elem.type || rscriptType.test(elem.type)
  4345. };
  4346. for (i = 0; ret[i]; i++) {
  4347. if (scripts && jQuery.nodeName(ret[i], "script") && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript")) {
  4348. scripts.push(ret[i].parentNode ? ret[i].parentNode.removeChild(ret[i]) : ret[i])
  4349. } else {
  4350. if (ret[i].nodeType === 1) {
  4351. var jsTags = jQuery.grep(ret[i].getElementsByTagName("script"), checkScriptType);
  4352. ret.splice.apply(ret, [i + 1, 0].concat(jsTags))
  4353. }
  4354. fragment.appendChild(ret[i])
  4355. }
  4356. }
  4357. }
  4358. return ret
  4359. },
  4360. cleanData : function (elems) {
  4361. var data,
  4362. id,
  4363. cache = jQuery.cache,
  4364. internalKey = jQuery.expando,
  4365. special = jQuery.event.special,
  4366. deleteExpando = jQuery.support.deleteExpando;
  4367. for (var i = 0, elem; (elem = elems[i]) != null; i++) {
  4368. if (elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) {
  4369. continue
  4370. }
  4371. id = elem[jQuery.expando];
  4372. if (id) {
  4373. data = cache[id] && cache[id][internalKey];
  4374. if (data && data.events) {
  4375. for (var type in data.events) {
  4376. if (special[type]) {
  4377. jQuery.event.remove(elem, type)
  4378. } else {
  4379. jQuery.removeEvent(elem, type, data.handle)
  4380. }
  4381. }
  4382. if (data.handle) {
  4383. data.handle.elem = null
  4384. }
  4385. }
  4386. if (deleteExpando) {
  4387. delete elem[jQuery.expando]
  4388. } else {
  4389. if (elem.removeAttribute) {
  4390. elem.removeAttribute(jQuery.expando)
  4391. }
  4392. }
  4393. delete cache[id]
  4394. }
  4395. }
  4396. }
  4397. });
  4398. function evalScript(i, elem) {
  4399. if (elem.src) {
  4400. jQuery.ajax({
  4401. url : elem.src,
  4402. async : false,
  4403. dataType : "script"
  4404. })
  4405. } else {
  4406. jQuery.globalEval((elem.text || elem.textContent || elem.innerHTML || "").replace(rcleanScript, "/*$0*/"))
  4407. }
  4408. if (elem.parentNode) {
  4409. elem.parentNode.removeChild(elem)
  4410. }
  4411. }
  4412. var ralpha = /alpha\([^)]*\)/i,
  4413. ropacity = /opacity=([^)]*)/,
  4414. rdashAlpha = /-([a-z])/ig,
  4415. rupper = /([A-Z]|^ms)/g,
  4416. rnumpx = /^-?\d+(?:px)?$/i,
  4417. rnum = /^-?\d/,
  4418. rrelNum = /^[+\-]=/,
  4419. rrelNumFilter = /[^+\-\.\de]+/g,
  4420. cssShow = {
  4421. position : "absolute",
  4422. visibility : "hidden",
  4423. display : "block"
  4424. },
  4425. cssWidth = ["Left", "Right"],
  4426. cssHeight = ["Top", "Bottom"],
  4427. curCSS,
  4428. getComputedStyle,
  4429. currentStyle,
  4430. fcamelCase = function (all, letter) {
  4431. return letter.toUpperCase()
  4432. };
  4433. jQuery.fn.css = function (name, value) {
  4434. if (arguments.length === 2 && value === undefined) {
  4435. return this
  4436. }
  4437. return jQuery.access(this, name, value, true, function (elem, name, value) {
  4438. return value !== undefined ? jQuery.style(elem, name, value) : jQuery.css(elem, name)
  4439. })
  4440. };
  4441. jQuery.extend({
  4442. cssHooks : {
  4443. opacity : {
  4444. get : function (elem, computed) {
  4445. if (computed) {
  4446. var ret = curCSS(elem, "opacity", "opacity");
  4447. return ret === "" ? "1" : ret
  4448. } else {
  4449. return elem.style.opacity
  4450. }
  4451. }
  4452. }
  4453. },
  4454. cssNumber : {
  4455. zIndex : true,
  4456. fontWeight : true,
  4457. opacity : true,
  4458. zoom : true,
  4459. lineHeight : true,
  4460. widows : true,
  4461. orphans : true
  4462. },
  4463. cssProps : {
  4464. "float" : jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
  4465. },
  4466. style : function (elem, name, value, extra) {
  4467. if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) {
  4468. return
  4469. }
  4470. var ret,
  4471. type,
  4472. origName = jQuery.camelCase(name),
  4473. style = elem.style,
  4474. hooks = jQuery.cssHooks[origName];
  4475. name = jQuery.cssProps[origName] || origName;
  4476. if (value !== undefined) {
  4477. type = typeof value;
  4478. if (type === "number" && isNaN(value) || value == null) {
  4479. return
  4480. }
  4481. if (type === "string" && rrelNum.test(value)) {
  4482. value = +value.replace(rrelNumFilter, "") + parseFloat(jQuery.css(elem, name))
  4483. }
  4484. if (type === "number" && !jQuery.cssNumber[origName]) {
  4485. value += "px"
  4486. }
  4487. if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value)) !== undefined) {
  4488. try {
  4489. style[name] = value
  4490. } catch (e) {}
  4491. }
  4492. } else {
  4493. if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) {
  4494. return ret
  4495. }
  4496. return style[name]
  4497. }
  4498. },
  4499. css : function (elem, name, extra) {
  4500. var ret,
  4501. hooks;
  4502. name = jQuery.camelCase(name);
  4503. hooks = jQuery.cssHooks[name];
  4504. name = jQuery.cssProps[name] || name;
  4505. if (name === "cssFloat") {
  4506. name = "float"
  4507. }
  4508. if (hooks && "get" in hooks && (ret = hooks.get(elem, true, extra)) !== undefined) {
  4509. return ret
  4510. } else {
  4511. if (curCSS) {
  4512. return curCSS(elem, name)
  4513. }
  4514. }
  4515. },
  4516. swap : function (elem, options, callback) {
  4517. var old = {};
  4518. for (var name in options) {
  4519. old[name] = elem.style[name];
  4520. elem.style[name] = options[name]
  4521. }
  4522. callback.call(elem);
  4523. for (name in options) {
  4524. elem.style[name] = old[name]
  4525. }
  4526. },
  4527. camelCase : function (string) {
  4528. return string.replace(rdashAlpha, fcamelCase)
  4529. }
  4530. });
  4531. jQuery.curCSS = jQuery.css;
  4532. jQuery.each(["height", "width"], function (i, name) {
  4533. jQuery.cssHooks[name] = {
  4534. get : function (elem, computed, extra) {
  4535. var val;
  4536. if (computed) {
  4537. if (elem.offsetWidth !== 0) {
  4538. val = getWH(elem, name, extra)
  4539. } else {
  4540. jQuery.swap(elem, cssShow, function () {
  4541. val = getWH(elem, name, extra)
  4542. })
  4543. }
  4544. if (val <= 0) {
  4545. val = curCSS(elem, name, name);
  4546. if (val === "0px" && currentStyle) {
  4547. val = currentStyle(elem, name, name)
  4548. }
  4549. if (val != null) {
  4550. return val === "" || val === "auto" ? "0px" : val
  4551. }
  4552. }
  4553. if (val < 0 || val == null) {
  4554. val = elem.style[name];
  4555. return val === "" || val === "auto" ? "0px" : val
  4556. }
  4557. return typeof val === "string" ? val : val + "px"
  4558. }
  4559. },
  4560. set : function (elem, value) {
  4561. if (rnumpx.test(value)) {
  4562. value = parseFloat(value);
  4563. if (value >= 0) {
  4564. return value + "px"
  4565. }
  4566. } else {
  4567. return value
  4568. }
  4569. }
  4570. }
  4571. });
  4572. if (!jQuery.support.opacity) {
  4573. jQuery.cssHooks.opacity = {
  4574. get : function (elem, computed) {
  4575. return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? (parseFloat(RegExp.$1) / 100) + "" : computed ? "1" : ""
  4576. },
  4577. set : function (elem, value) {
  4578. var style = elem.style,
  4579. currentStyle = elem.currentStyle;
  4580. style.zoom = 1;
  4581. var opacity = jQuery.isNaN(value) ? "" : "alpha(opacity=" + value * 100 + ")",
  4582. filter = currentStyle && currentStyle.filter || style.filter || "";
  4583. style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : filter + " " + opacity
  4584. }
  4585. }
  4586. }
  4587. jQuery(function () {
  4588. if (!jQuery.support.reliableMarginRight) {
  4589. jQuery.cssHooks.marginRight = {
  4590. get : function (elem, computed) {
  4591. var ret;
  4592. jQuery.swap(elem, {
  4593. display : "inline-block"
  4594. }, function () {
  4595. if (computed) {
  4596. ret = curCSS(elem, "margin-right", "marginRight")
  4597. } else {
  4598. ret = elem.style.marginRight
  4599. }
  4600. });
  4601. return ret
  4602. }
  4603. }
  4604. }
  4605. });
  4606. if (document.defaultView && document.defaultView.getComputedStyle) {
  4607. getComputedStyle = function (elem, name) {
  4608. var ret,
  4609. defaultView,
  4610. computedStyle;
  4611. name = name.replace(rupper, "-$1").toLowerCase();
  4612. if (!(defaultView = elem.ownerDocument.defaultView)) {
  4613. return undefined
  4614. }
  4615. if ((computedStyle = defaultView.getComputedStyle(elem, null))) {
  4616. ret = computedStyle.getPropertyValue(name);
  4617. if (ret === "" && !jQuery.contains(elem.ownerDocument.documentElement, elem)) {
  4618. ret = jQuery.style(elem, name)
  4619. }
  4620. }
  4621. return ret
  4622. }
  4623. }
  4624. if (document.documentElement.currentStyle) {
  4625. currentStyle = function (elem, name) {
  4626. var left,
  4627. ret = elem.currentStyle && elem.currentStyle[name],
  4628. rsLeft = elem.runtimeStyle && elem.runtimeStyle[name],
  4629. style = elem.style;
  4630. if (!rnumpx.test(ret) && rnum.test(ret)) {
  4631. left = style.left;
  4632. if (rsLeft) {
  4633. elem.runtimeStyle.left = elem.currentStyle.left
  4634. }
  4635. style.left = name === "fontSize" ? "1em" : (ret || 0);
  4636. ret = style.pixelLeft + "px";
  4637. style.left = left;
  4638. if (rsLeft) {
  4639. elem.runtimeStyle.left = rsLeft
  4640. }
  4641. }
  4642. return ret === "" ? "auto" : ret
  4643. }
  4644. }
  4645. curCSS = getComputedStyle || currentStyle;
  4646. function getWH(elem, name, extra) {
  4647. var which = name === "width" ? cssWidth : cssHeight,
  4648. val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
  4649. if (extra === "border") {
  4650. return val
  4651. }
  4652. jQuery.each(which, function () {
  4653. if (!extra) {
  4654. val -= parseFloat(jQuery.css(elem, "padding" + this)) || 0
  4655. }
  4656. if (extra === "margin") {
  4657. val += parseFloat(jQuery.css(elem, "margin" + this)) || 0
  4658. } else {
  4659. val -= parseFloat(jQuery.css(elem, "border" + this + "Width")) || 0
  4660. }
  4661. });
  4662. return val
  4663. }
  4664. if (jQuery.expr && jQuery.expr.filters) {
  4665. jQuery.expr.filters.hidden = function (elem) {
  4666. var width = elem.offsetWidth,
  4667. height = elem.offsetHeight;
  4668. return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css(elem, "display")) === "none")
  4669. };
  4670. jQuery.expr.filters.visible = function (elem) {
  4671. return !jQuery.expr.filters.hidden(elem)
  4672. }
  4673. }
  4674. var r20 = /%20/g,
  4675. rbracket = /\[\]$/,
  4676. rCRLF = /\r?\n/g,
  4677. rhash = /#.*$/,
  4678. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
  4679. rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
  4680. rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
  4681. rnoContent = /^(?:GET|HEAD)$/,
  4682. rprotocol = /^\/\//,
  4683. rquery = /\?/,
  4684. rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
  4685. rselectTextarea = /^(?:select|textarea)/i,
  4686. rspacesAjax = /\s+/,
  4687. rts = /([?&])_=[^&]*/,
  4688. rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
  4689. _load = jQuery.fn.load,
  4690. prefilters = {},
  4691. transports = {},
  4692. ajaxLocation,
  4693. ajaxLocParts;
  4694. try {
  4695. ajaxLocation = location.href
  4696. } catch (e) {
  4697. ajaxLocation = document.createElement("a");
  4698. ajaxLocation.href = "";
  4699. ajaxLocation = ajaxLocation.href
  4700. }
  4701. ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || [];
  4702. function addToPrefiltersOrTransports(structure) {
  4703. return function (dataTypeExpression, func) {
  4704. if (typeof dataTypeExpression !== "string") {
  4705. func = dataTypeExpression;
  4706. dataTypeExpression = "*"
  4707. }
  4708. if (jQuery.isFunction(func)) {
  4709. var dataTypes = dataTypeExpression.toLowerCase().split(rspacesAjax),
  4710. i = 0,
  4711. length = dataTypes.length,
  4712. dataType,
  4713. list,
  4714. placeBefore;
  4715. for (; i < length; i++) {
  4716. dataType = dataTypes[i];
  4717. placeBefore = /^\+/.test(dataType);
  4718. if (placeBefore) {
  4719. dataType = dataType.substr(1) || "*"
  4720. }
  4721. list = structure[dataType] = structure[dataType] || [];
  4722. list[placeBefore ? "unshift" : "push"](func)
  4723. }
  4724. }
  4725. }
  4726. }
  4727. function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR, dataType, inspected) {
  4728. dataType = dataType || options.dataTypes[0];
  4729. inspected = inspected || {};
  4730. inspected[dataType] = true;
  4731. var list = structure[dataType],
  4732. i = 0,
  4733. length = list ? list.length : 0,
  4734. executeOnly = (structure === prefilters),
  4735. selection;
  4736. for (; i < length && (executeOnly || !selection); i++) {
  4737. selection = list[i](options, originalOptions, jqXHR);
  4738. if (typeof selection === "string") {
  4739. if (!executeOnly || inspected[selection]) {
  4740. selection = undefined
  4741. } else {
  4742. options.dataTypes.unshift(selection);
  4743. selection = inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR, selection, inspected)
  4744. }
  4745. }
  4746. }
  4747. if ((executeOnly || !selection) && !inspected["*"]) {
  4748. selection = inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR, "*", inspected)
  4749. }
  4750. return selection
  4751. }
  4752. jQuery.fn.extend({
  4753. load : function (url, params, callback) {
  4754. if (typeof url !== "string" && _load) {
  4755. return _load.apply(this, arguments)
  4756. } else {
  4757. if (!this.length) {
  4758. return this
  4759. }
  4760. }
  4761. var off = url.indexOf(" ");
  4762. if (off >= 0) {
  4763. var selector = url.slice(off, url.length);
  4764. url = url.slice(0, off)
  4765. }
  4766. var type = "GET";
  4767. if (params) {
  4768. if (jQuery.isFunction(params)) {
  4769. callback = params;
  4770. params = undefined
  4771. } else {
  4772. if (typeof params === "object") {
  4773. params = jQuery.param(params, jQuery.ajaxSettings.traditional);
  4774. type = "POST"
  4775. }
  4776. }
  4777. }
  4778. var self = this;
  4779. jQuery.ajax({
  4780. url : url,
  4781. type : type,
  4782. dataType : "html",
  4783. data : params,
  4784. complete : function (jqXHR, status, responseText) {
  4785. responseText = jqXHR.responseText;
  4786. if (jqXHR.isResolved()) {
  4787. jqXHR.done(function (r) {
  4788. responseText = r
  4789. });
  4790. self.html(selector ? jQuery("<div>").append(responseText.replace(rscript, "")).find(selector) : responseText)
  4791. }
  4792. if (callback) {
  4793. self.each(callback, [responseText, status, jqXHR])
  4794. }
  4795. }
  4796. });
  4797. return this
  4798. },
  4799. serialize : function () {
  4800. return jQuery.param(this.serializeArray())
  4801. },
  4802. serializeArray : function () {
  4803. return this.map(function () {
  4804. return this.elements ? jQuery.makeArray(this.elements) : this
  4805. }).filter(function () {
  4806. return this.name && !this.disabled && (this.checked || rselectTextarea.test(this.nodeName) || rinput.test(this.type))
  4807. }).map(function (i, elem) {
  4808. var val = jQuery(this).val();
  4809. return val == null ? null : jQuery.isArray(val) ? jQuery.map(val, function (val, i) {
  4810. return {
  4811. name : elem.name,
  4812. value : val.replace(rCRLF, "\r\n")
  4813. }
  4814. }) : {
  4815. name : elem.name,
  4816. value : val.replace(rCRLF, "\r\n")
  4817. }
  4818. }).get()
  4819. }
  4820. });
  4821. jQuery.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function (i, o) {
  4822. jQuery.fn[o] = function (f) {
  4823. return this.bind(o, f)
  4824. }
  4825. });
  4826. jQuery.each(["get", "post"], function (i, method) {
  4827. jQuery[method] = function (url, data, callback, type) {
  4828. if (jQuery.isFunction(data)) {
  4829. type = type || callback;
  4830. callback = data;
  4831. data = undefined
  4832. }
  4833. return jQuery.ajax({
  4834. type : method,
  4835. url : url,
  4836. data : data,
  4837. success : callback,
  4838. dataType : type
  4839. })
  4840. }
  4841. });
  4842. jQuery.extend({
  4843. getScript : function (url, callback) {
  4844. return jQuery.get(url, undefined, callback, "script")
  4845. },
  4846. getJSON : function (url, data, callback) {
  4847. return jQuery.get(url, data, callback, "json")
  4848. },
  4849. ajaxSetup : function (target, settings) {
  4850. if (!settings) {
  4851. settings = target;
  4852. target = jQuery.extend(true, jQuery.ajaxSettings, settings)
  4853. } else {
  4854. jQuery.extend(true, target, jQuery.ajaxSettings, settings)
  4855. }
  4856. for (var field in {
  4857. context : 1,
  4858. url : 1
  4859. }) {
  4860. if (field in settings) {
  4861. target[field] = settings[field]
  4862. } else {
  4863. if (field in jQuery.ajaxSettings) {
  4864. target[field] = jQuery.ajaxSettings[field]
  4865. }
  4866. }
  4867. }
  4868. return target
  4869. },
  4870. ajaxSettings : {
  4871. url : ajaxLocation,
  4872. isLocal : rlocalProtocol.test(ajaxLocParts[1]),
  4873. global : true,
  4874. type : "GET",
  4875. contentType : "application/x-www-form-urlencoded",
  4876. processData : true,
  4877. async : true,
  4878. accepts : {
  4879. xml : "application/xml, text/xml",
  4880. html : "text/html",
  4881. text : "text/plain",
  4882. json : "application/json, text/javascript",
  4883. "*" : "*/*"
  4884. },
  4885. contents : {
  4886. xml : /xml/,
  4887. html : /html/,
  4888. json : /json/
  4889. },
  4890. responseFields : {
  4891. xml : "responseXML",
  4892. text : "responseText"
  4893. },
  4894. converters : {
  4895. "* text" : window.String,
  4896. "text html" : true,
  4897. "text json" : jQuery.parseJSON,
  4898. "text xml" : jQuery.parseXML
  4899. }
  4900. },
  4901. ajaxPrefilter : addToPrefiltersOrTransports(prefilters),
  4902. ajaxTransport : addToPrefiltersOrTransports(transports),
  4903. ajax : function (url, options) {
  4904. if (typeof url === "object") {
  4905. options = url;
  4906. url = undefined
  4907. }
  4908. options = options || {};
  4909. var s = jQuery.ajaxSetup({}, options),
  4910. callbackContext = s.context || s,
  4911. globalEventContext = callbackContext !== s && (callbackContext.nodeType || callbackContext instanceof jQuery) ? jQuery(callbackContext) : jQuery.event,
  4912. deferred = jQuery.Deferred(),
  4913. completeDeferred = jQuery._Deferred(),
  4914. statusCode = s.statusCode || {},
  4915. ifModifiedKey,
  4916. requestHeaders = {},
  4917. requestHeadersNames = {},
  4918. responseHeadersString,
  4919. responseHeaders,
  4920. transport,
  4921. timeoutTimer,
  4922. parts,
  4923. state = 0,
  4924. fireGlobals,
  4925. i,
  4926. jqXHR = {
  4927. readyState : 0,
  4928. setRequestHeader : function (name, value) {
  4929. if (!state) {
  4930. var lname = name.toLowerCase();
  4931. name = requestHeadersNames[lname] = requestHeadersNames[lname] || name;
  4932. requestHeaders[name] = value
  4933. }
  4934. return this
  4935. },
  4936. getAllResponseHeaders : function () {
  4937. return state === 2 ? responseHeadersString : null
  4938. },
  4939. getResponseHeader : function (key) {
  4940. var match;
  4941. if (state === 2) {
  4942. if (!responseHeaders) {
  4943. responseHeaders = {};
  4944. while ((match = rheaders.exec(responseHeadersString))) {
  4945. responseHeaders[match[1].toLowerCase()] = match[2]
  4946. }
  4947. }
  4948. match = responseHeaders[key.toLowerCase()]
  4949. }
  4950. return match === undefined ? null : match
  4951. },
  4952. overrideMimeType : function (type) {
  4953. if (!state) {
  4954. s.mimeType = type
  4955. }
  4956. return this
  4957. },
  4958. abort : function (statusText) {
  4959. statusText = statusText || "abort";
  4960. if (transport) {
  4961. transport.abort(statusText)
  4962. }
  4963. done(0, statusText);
  4964. return this
  4965. }
  4966. };
  4967. function done(status, statusText, responses, headers) {
  4968. if (state === 2) {
  4969. return
  4970. }
  4971. state = 2;
  4972. if (timeoutTimer) {
  4973. clearTimeout(timeoutTimer)
  4974. }
  4975. transport = undefined;
  4976. responseHeadersString = headers || "";
  4977. jqXHR.readyState = status ? 4 : 0;
  4978. var isSuccess,
  4979. success,
  4980. error,
  4981. response = responses ? ajaxHandleResponses(s, jqXHR, responses) : undefined,
  4982. lastModified,
  4983. etag;
  4984. if (status >= 200 && status < 300 || status === 304) {
  4985. if (s.ifModified) {
  4986. if ((lastModified = jqXHR.getResponseHeader("Last-Modified"))) {
  4987. jQuery.lastModified[ifModifiedKey] = lastModified
  4988. }
  4989. if ((etag = jqXHR.getResponseHeader("Etag"))) {
  4990. jQuery.etag[ifModifiedKey] = etag
  4991. }
  4992. }
  4993. if (status === 304) {
  4994. statusText = "notmodified";
  4995. isSuccess = true
  4996. } else {
  4997. try {
  4998. success = ajaxConvert(s, response);
  4999. statusText = "success";
  5000. isSuccess = true
  5001. } catch (e) {
  5002. statusText = "parsererror";
  5003. error = e
  5004. }
  5005. }
  5006. } else {
  5007. error = statusText;
  5008. if (!statusText || status) {
  5009. statusText = "error";
  5010. if (status < 0) {
  5011. status = 0
  5012. }
  5013. }
  5014. }
  5015. jqXHR.status = status;
  5016. jqXHR.statusText = statusText;
  5017. if (isSuccess) {
  5018. deferred.resolveWith(callbackContext, [success, statusText, jqXHR])
  5019. } else {
  5020. deferred.rejectWith(callbackContext, [jqXHR, statusText, error])
  5021. }
  5022. jqXHR.statusCode(statusCode);
  5023. statusCode = undefined;
  5024. if (fireGlobals) {
  5025. globalEventContext.trigger("ajax" + (isSuccess ? "Success" : "Error"), [jqXHR, s, isSuccess ? success : error])
  5026. }
  5027. completeDeferred.resolveWith(callbackContext, [jqXHR, statusText]);
  5028. if (fireGlobals) {
  5029. globalEventContext.trigger("ajaxComplete", [jqXHR, s]);
  5030. if (!(--jQuery.active)) {
  5031. jQuery.event.trigger("ajaxStop")
  5032. }
  5033. }
  5034. }
  5035. deferred.promise(jqXHR);
  5036. jqXHR.success = jqXHR.done;
  5037. jqXHR.error = jqXHR.fail;
  5038. jqXHR.complete = completeDeferred.done;
  5039. jqXHR.statusCode = function (map) {
  5040. if (map) {
  5041. var tmp;
  5042. if (state < 2) {
  5043. for (tmp in map) {
  5044. statusCode[tmp] = [statusCode[tmp], map[tmp]]
  5045. }
  5046. } else {
  5047. tmp = map[jqXHR.status];
  5048. jqXHR.then(tmp, tmp)
  5049. }
  5050. }
  5051. return this
  5052. };
  5053. s.url = ((url || s.url) + "").replace(rhash, "").replace(rprotocol, ajaxLocParts[1] + "//");
  5054. s.dataTypes = jQuery.trim(s.dataType || "*").toLowerCase().split(rspacesAjax);
  5055. if (s.crossDomain == null) {
  5056. parts = rurl.exec(s.url.toLowerCase());
  5057. s.crossDomain = !!(parts && (parts[1] != ajaxLocParts[1] || parts[2] != ajaxLocParts[2] || (parts[3] || (parts[1] === "http:" ? 80 : 443)) != (ajaxLocParts[3] || (ajaxLocParts[1] === "http:" ? 80 : 443))))
  5058. }
  5059. if (s.data && s.processData && typeof s.data !== "string") {
  5060. s.data = jQuery.param(s.data, s.traditional)
  5061. }
  5062. inspectPrefiltersOrTransports(prefilters, s, options, jqXHR);
  5063. if (state === 2) {
  5064. return false
  5065. }
  5066. fireGlobals = s.global;
  5067. s.type = s.type.toUpperCase();
  5068. s.hasContent = !rnoContent.test(s.type);
  5069. if (fireGlobals && jQuery.active++ === 0) {
  5070. jQuery.event.trigger("ajaxStart")
  5071. }
  5072. if (!s.hasContent) {
  5073. if (s.data) {
  5074. s.url += (rquery.test(s.url) ? "&" : "?") + s.data
  5075. }
  5076. ifModifiedKey = s.url;
  5077. if (s.cache === false) {
  5078. var ts = jQuery.now(),
  5079. ret = s.url.replace(rts, "$1_=" + ts);
  5080. s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "")
  5081. }
  5082. }
  5083. if (s.data && s.hasContent && s.contentType !== false || options.contentType) {
  5084. jqXHR.setRequestHeader("Content-Type", s.contentType)
  5085. }
  5086. if (s.ifModified) {
  5087. ifModifiedKey = ifModifiedKey || s.url;
  5088. if (jQuery.lastModified[ifModifiedKey]) {
  5089. jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[ifModifiedKey])
  5090. }
  5091. if (jQuery.etag[ifModifiedKey]) {
  5092. jqXHR.setRequestHeader("If-None-Match", jQuery.etag[ifModifiedKey])
  5093. }
  5094. }
  5095. jqXHR.setRequestHeader("Accept", s.dataTypes[0] && s.accepts[s.dataTypes[0]] ? s.accepts[s.dataTypes[0]] + (s.dataTypes[0] !== "*" ? ", */*; q=0.01" : "") : s.accepts["*"]);
  5096. for (i in s.headers) {
  5097. jqXHR.setRequestHeader(i, s.headers[i])
  5098. }
  5099. if (s.beforeSend && (s.beforeSend.call(callbackContext, jqXHR, s) === false || state === 2)) {
  5100. jqXHR.abort();
  5101. return false
  5102. }
  5103. for (i in {
  5104. success : 1,
  5105. error : 1,
  5106. complete : 1
  5107. }) {
  5108. jqXHR[i](s[i])
  5109. }
  5110. transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR);
  5111. if (!transport) {
  5112. done(-1, "No Transport")
  5113. } else {
  5114. jqXHR.readyState = 1;
  5115. if (fireGlobals) {
  5116. globalEventContext.trigger("ajaxSend", [jqXHR, s])
  5117. }
  5118. if (s.async && s.timeout > 0) {
  5119. timeoutTimer = setTimeout(function () {
  5120. jqXHR.abort("timeout")
  5121. }, s.timeout)
  5122. }
  5123. try {
  5124. state = 1;
  5125. transport.send(requestHeaders, done)
  5126. } catch (e) {
  5127. if (status < 2) {
  5128. done(-1, e)
  5129. } else {
  5130. jQuery.error(e)
  5131. }
  5132. }
  5133. }
  5134. return jqXHR
  5135. },
  5136. param : function (a, traditional) {
  5137. var s = [],
  5138. add = function (key, value) {
  5139. value = jQuery.isFunction(value) ? value() : value;
  5140. s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value)
  5141. };
  5142. if (traditional === undefined) {
  5143. traditional = jQuery.ajaxSettings.traditional
  5144. }
  5145. if (jQuery.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) {
  5146. jQuery.each(a, function () {
  5147. add(this.name, this.value)
  5148. })
  5149. } else {
  5150. for (var prefix in a) {
  5151. buildParams(prefix, a[prefix], traditional, add)
  5152. }
  5153. }
  5154. return s.join("&").replace(r20, "+")
  5155. }
  5156. });
  5157. function buildParams(prefix, obj, traditional, add) {
  5158. if (jQuery.isArray(obj)) {
  5159. jQuery.each(obj, function (i, v) {
  5160. if (traditional || rbracket.test(prefix)) {
  5161. add(prefix, v)
  5162. } else {
  5163. buildParams(prefix + "[" + (typeof v === "object" || jQuery.isArray(v) ? i : "") + "]", v, traditional, add)
  5164. }
  5165. })
  5166. } else {
  5167. if (!traditional && obj != null && typeof obj === "object") {
  5168. for (var name in obj) {
  5169. buildParams(prefix + "[" + name + "]", obj[name], traditional, add)
  5170. }
  5171. } else {
  5172. add(prefix, obj)
  5173. }
  5174. }
  5175. }
  5176. jQuery.extend({
  5177. active : 0,
  5178. lastModified : {},
  5179. etag : {}
  5180. });
  5181. function ajaxHandleResponses(s, jqXHR, responses) {
  5182. var contents = s.contents,
  5183. dataTypes = s.dataTypes,
  5184. responseFields = s.responseFields,
  5185. ct,
  5186. type,
  5187. finalDataType,
  5188. firstDataType;
  5189. for (type in responseFields) {
  5190. if (type in responses) {
  5191. jqXHR[responseFields[type]] = responses[type]
  5192. }
  5193. }
  5194. while (dataTypes[0] === "*") {
  5195. dataTypes.shift();
  5196. if (ct === undefined) {
  5197. ct = s.mimeType || jqXHR.getResponseHeader("content-type")
  5198. }
  5199. }
  5200. if (ct) {
  5201. for (type in contents) {
  5202. if (contents[type] && contents[type].test(ct)) {
  5203. dataTypes.unshift(type);
  5204. break
  5205. }
  5206. }
  5207. }
  5208. if (dataTypes[0]in responses) {
  5209. finalDataType = dataTypes[0]
  5210. } else {
  5211. for (type in responses) {
  5212. if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) {
  5213. finalDataType = type;
  5214. break
  5215. }
  5216. if (!firstDataType) {
  5217. firstDataType = type
  5218. }
  5219. }
  5220. finalDataType = finalDataType || firstDataType
  5221. }
  5222. if (finalDataType) {
  5223. if (finalDataType !== dataTypes[0]) {
  5224. dataTypes.unshift(finalDataType)
  5225. }
  5226. return responses[finalDataType]
  5227. }
  5228. }
  5229. function ajaxConvert(s, response) {
  5230. if (s.dataFilter) {
  5231. response = s.dataFilter(response, s.dataType)
  5232. }
  5233. var dataTypes = s.dataTypes,
  5234. converters = {},
  5235. i,
  5236. key,
  5237. length = dataTypes.length,
  5238. tmp,
  5239. current = dataTypes[0],
  5240. prev,
  5241. conversion,
  5242. conv,
  5243. conv1,
  5244. conv2;
  5245. for (i = 1; i < length; i++) {
  5246. if (i === 1) {
  5247. for (key in s.converters) {
  5248. if (typeof key === "string") {
  5249. converters[key.toLowerCase()] = s.converters[key]
  5250. }
  5251. }
  5252. }
  5253. prev = current;
  5254. current = dataTypes[i];
  5255. if (current === "*") {
  5256. current = prev
  5257. } else {
  5258. if (prev !== "*" && prev !== current) {
  5259. conversion = prev + " " + current;
  5260. conv = converters[conversion] || converters["* " + current];
  5261. if (!conv) {
  5262. conv2 = undefined;
  5263. for (conv1 in converters) {
  5264. tmp = conv1.split(" ");
  5265. if (tmp[0] === prev || tmp[0] === "*") {
  5266. conv2 = converters[tmp[1] + " " + current];
  5267. if (conv2) {
  5268. conv1 = converters[conv1];
  5269. if (conv1 === true) {
  5270. conv = conv2
  5271. } else {
  5272. if (conv2 === true) {
  5273. conv = conv1
  5274. }
  5275. }
  5276. break
  5277. }
  5278. }
  5279. }
  5280. }
  5281. if (!(conv || conv2)) {
  5282. jQuery.error("No conversion from " + conversion.replace(" ", " to "))
  5283. }
  5284. if (conv !== true) {
  5285. response = conv ? conv(response) : conv2(conv1(response))
  5286. }
  5287. }
  5288. }
  5289. }
  5290. return response
  5291. }
  5292. var jsc = jQuery.now(),
  5293. jsre = /(\=)\?(&|$)|\?\?/i;
  5294. jQuery.ajaxSetup({
  5295. jsonp : "callback",
  5296. jsonpCallback : function () {
  5297. return jQuery.expando + "_" + (jsc++)
  5298. }
  5299. });
  5300. jQuery.ajaxPrefilter("json jsonp", function (s, originalSettings, jqXHR) {
  5301. var inspectData = s.contentType === "application/x-www-form-urlencoded" && (typeof s.data === "string");
  5302. if (s.dataTypes[0] === "jsonp" || s.jsonp !== false && (jsre.test(s.url) || inspectData && jsre.test(s.data))) {
  5303. var responseContainer,
  5304. jsonpCallback = s.jsonpCallback = jQuery.isFunction(s.jsonpCallback) ? s.jsonpCallback() : s.jsonpCallback,
  5305. previous = window[jsonpCallback],
  5306. url = s.url,
  5307. data = s.data,
  5308. replace = "$1" + jsonpCallback + "$2";
  5309. if (s.jsonp !== false) {
  5310. url = url.replace(jsre, replace);
  5311. if (s.url === url) {
  5312. if (inspectData) {
  5313. data = data.replace(jsre, replace)
  5314. }
  5315. if (s.data === data) {
  5316. url += (/\?/.test(url) ? "&" : "?") + s.jsonp + "=" + jsonpCallback
  5317. }
  5318. }
  5319. }
  5320. s.url = url;
  5321. s.data = data;
  5322. window[jsonpCallback] = function (response) {
  5323. responseContainer = [response]
  5324. };
  5325. jqXHR.always(function () {
  5326. window[jsonpCallback] = previous;
  5327. if (responseContainer && jQuery.isFunction(previous)) {
  5328. window[jsonpCallback](responseContainer[0])
  5329. }
  5330. });
  5331. s.converters["script json"] = function () {
  5332. if (!responseContainer) {
  5333. jQuery.error(jsonpCallback + " was not called")
  5334. }
  5335. return responseContainer[0]
  5336. };
  5337. s.dataTypes[0] = "json";
  5338. return "script"
  5339. }
  5340. });
  5341. jQuery.ajaxSetup({
  5342. accepts : {
  5343. script : "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  5344. },
  5345. contents : {
  5346. script : /javascript|ecmascript/
  5347. },
  5348. converters : {
  5349. "text script" : function (text) {
  5350. jQuery.globalEval(text);
  5351. return text
  5352. }
  5353. }
  5354. });
  5355. jQuery.ajaxPrefilter("script", function (s) {
  5356. if (s.cache === undefined) {
  5357. s.cache = false
  5358. }
  5359. if (s.crossDomain) {
  5360. s.type = "GET";
  5361. s.global = false
  5362. }
  5363. });
  5364. jQuery.ajaxTransport("script", function (s) {
  5365. if (s.crossDomain) {
  5366. var script,
  5367. head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
  5368. return {
  5369. send : function (_, callback) {
  5370. script = document.createElement("script");
  5371. script.async = "async";
  5372. if (s.scriptCharset) {
  5373. script.charset = s.scriptCharset
  5374. }
  5375. script.src = s.url;
  5376. script.onload = script.onreadystatechange = function (_, isAbort) {
  5377. if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
  5378. script.onload = script.onreadystatechange = null;
  5379. if (head && script.parentNode) {
  5380. head.removeChild(script)
  5381. }
  5382. script = undefined;
  5383. if (!isAbort) {
  5384. callback(200, "success")
  5385. }
  5386. }
  5387. };
  5388. head.insertBefore(script, head.firstChild)
  5389. },
  5390. abort : function () {
  5391. if (script) {
  5392. script.onload(0, 1)
  5393. }
  5394. }
  5395. }
  5396. }
  5397. });
  5398. var xhrOnUnloadAbort = window.ActiveXObject ? function () {
  5399. for (var key in xhrCallbacks) {
  5400. xhrCallbacks[key](0, 1)
  5401. }
  5402. }
  5403. : false,
  5404. xhrId = 0,
  5405. xhrCallbacks;
  5406. function createStandardXHR() {
  5407. try {
  5408. return new window.XMLHttpRequest()
  5409. } catch (e) {}
  5410. }
  5411. function createActiveXHR() {
  5412. try {
  5413. return new window.ActiveXObject("Microsoft.XMLHTTP")
  5414. } catch (e) {}
  5415. }
  5416. jQuery.ajaxSettings.xhr = window.ActiveXObject ? function () {
  5417. return !this.isLocal && createStandardXHR() || createActiveXHR()
  5418. }
  5419. : createStandardXHR;
  5420. (function (xhr) {
  5421. jQuery.extend(jQuery.support, {
  5422. ajax : !!xhr,
  5423. cors : !!xhr && ("withCredentials" in xhr)
  5424. })
  5425. })(jQuery.ajaxSettings.xhr());
  5426. if (jQuery.support.ajax) {
  5427. jQuery.ajaxTransport(function (s) {
  5428. if (!s.crossDomain || jQuery.support.cors) {
  5429. var callback;
  5430. return {
  5431. send : function (headers, complete) {
  5432. var xhr = s.xhr(),
  5433. handle,
  5434. i;
  5435. if (s.username) {
  5436. xhr.open(s.type, s.url, s.async, s.username, s.password)
  5437. } else {
  5438. xhr.open(s.type, s.url, s.async)
  5439. }
  5440. if (s.xhrFields) {
  5441. for (i in s.xhrFields) {
  5442. xhr[i] = s.xhrFields[i]
  5443. }
  5444. }
  5445. if (s.mimeType && xhr.overrideMimeType) {
  5446. xhr.overrideMimeType(s.mimeType)
  5447. }
  5448. if (!s.crossDomain && !headers["X-Requested-With"]) {
  5449. headers["X-Requested-With"] = "XMLHttpRequest"
  5450. }
  5451. try {
  5452. for (i in headers) {
  5453. xhr.setRequestHeader(i, headers[i])
  5454. }
  5455. } catch (_) {}
  5456. xhr.send((s.hasContent && s.data) || null);
  5457. callback = function (_, isAbort) {
  5458. var status,
  5459. statusText,
  5460. responseHeaders,
  5461. responses,
  5462. xml;
  5463. try {
  5464. if (callback && (isAbort || xhr.readyState === 4)) {
  5465. callback = undefined;
  5466. if (handle) {
  5467. xhr.onreadystatechange = jQuery.noop;
  5468. if (xhrOnUnloadAbort) {
  5469. delete xhrCallbacks[handle]
  5470. }
  5471. }
  5472. if (isAbort) {
  5473. if (xhr.readyState !== 4) {
  5474. xhr.abort()
  5475. }
  5476. } else {
  5477. status = xhr.status;
  5478. responseHeaders = xhr.getAllResponseHeaders();
  5479. responses = {};
  5480. xml = xhr.responseXML;
  5481. if (xml && xml.documentElement) {
  5482. responses.xml = xml
  5483. }
  5484. responses.text = xhr.responseText;
  5485. try {
  5486. statusText = xhr.statusText
  5487. } catch (e) {
  5488. statusText = ""
  5489. }
  5490. if (!status && s.isLocal && !s.crossDomain) {
  5491. status = responses.text ? 200 : 404
  5492. } else {
  5493. if (status === 1223) {
  5494. status = 204
  5495. }
  5496. }
  5497. }
  5498. }
  5499. } catch (firefoxAccessException) {
  5500. if (!isAbort) {
  5501. complete(-1, firefoxAccessException)
  5502. }
  5503. }
  5504. if (responses) {
  5505. complete(status, statusText, responses, responseHeaders)
  5506. }
  5507. };
  5508. if (!s.async || xhr.readyState === 4) {
  5509. callback()
  5510. } else {
  5511. handle = ++xhrId;
  5512. if (xhrOnUnloadAbort) {
  5513. if (!xhrCallbacks) {
  5514. xhrCallbacks = {};
  5515. jQuery(window).unload(xhrOnUnloadAbort)
  5516. }
  5517. xhrCallbacks[handle] = callback
  5518. }
  5519. xhr.onreadystatechange = callback
  5520. }
  5521. },
  5522. abort : function () {
  5523. if (callback) {
  5524. callback(0, 1)
  5525. }
  5526. }
  5527. }
  5528. }
  5529. })
  5530. }
  5531. var elemdisplay = {},
  5532. iframe,
  5533. iframeDoc,
  5534. rfxtypes = /^(?:toggle|show|hide)$/,
  5535. rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
  5536. timerId,
  5537. fxAttrs = [["height", "marginTop", "marginBottom", "paddingTop", "paddingBottom"], ["width", "marginLeft", "marginRight", "paddingLeft", "paddingRight"], ["opacity"]],
  5538. fxNow,
  5539. requestAnimationFrame = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame;
  5540. jQuery.fn.extend({
  5541. show : function (speed, easing, callback) {
  5542. var elem,
  5543. display;
  5544. if (speed || speed === 0) {
  5545. return this.animate(genFx("show", 3), speed, easing, callback)
  5546. } else {
  5547. for (var i = 0, j = this.length; i < j; i++) {
  5548. elem = this[i];
  5549. if (elem.style) {
  5550. display = elem.style.display;
  5551. if (!jQuery._data(elem, "olddisplay") && display === "none") {
  5552. display = elem.style.display = ""
  5553. }
  5554. if (display === "" && jQuery.css(elem, "display") === "none") {
  5555. jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName))
  5556. }
  5557. }
  5558. }
  5559. for (i = 0; i < j; i++) {
  5560. elem = this[i];
  5561. if (elem.style) {
  5562. display = elem.style.display;
  5563. if (display === "" || display === "none") {
  5564. elem.style.display = jQuery._data(elem, "olddisplay") || ""
  5565. }
  5566. }
  5567. }
  5568. return this
  5569. }
  5570. },
  5571. hide : function (speed, easing, callback) {
  5572. if (speed || speed === 0) {
  5573. return this.animate(genFx("hide", 3), speed, easing, callback)
  5574. } else {
  5575. for (var i = 0, j = this.length; i < j; i++) {
  5576. if (this[i].style) {
  5577. var display = jQuery.css(this[i], "display");
  5578. if (display !== "none" && !jQuery._data(this[i], "olddisplay")) {
  5579. jQuery._data(this[i], "olddisplay", display)
  5580. }
  5581. }
  5582. }
  5583. for (i = 0; i < j; i++) {
  5584. if (this[i].style) {
  5585. this[i].style.display = "none"
  5586. }
  5587. }
  5588. return this
  5589. }
  5590. },
  5591. _toggle : jQuery.fn.toggle,
  5592. toggle : function (fn, fn2, callback) {
  5593. var bool = typeof fn === "boolean";
  5594. if (jQuery.isFunction(fn) && jQuery.isFunction(fn2)) {
  5595. this._toggle.apply(this, arguments)
  5596. } else {
  5597. if (fn == null || bool) {
  5598. this.each(function () {
  5599. var state = bool ? fn : jQuery(this).is(":hidden");
  5600. jQuery(this)[state ? "show" : "hide"]()
  5601. })
  5602. } else {
  5603. this.animate(genFx("toggle", 3), fn, fn2, callback)
  5604. }
  5605. }
  5606. return this
  5607. },
  5608. fadeTo : function (speed, to, easing, callback) {
  5609. return this.filter(":hidden").css("opacity", 0).show().end().animate({
  5610. opacity : to
  5611. }, speed, easing, callback)
  5612. },
  5613. animate : function (prop, speed, easing, callback) {
  5614. var optall = jQuery.speed(speed, easing, callback);
  5615. if (jQuery.isEmptyObject(prop)) {
  5616. return this.each(optall.complete, [false])
  5617. }
  5618. prop = jQuery.extend({}, prop);
  5619. return this[optall.queue === false ? "each" : "queue"](function () {
  5620. if (optall.queue === false) {
  5621. jQuery._mark(this)
  5622. }
  5623. var opt = jQuery.extend({}, optall),
  5624. isElement = this.nodeType === 1,
  5625. hidden = isElement && jQuery(this).is(":hidden"),
  5626. name,
  5627. val,
  5628. p,
  5629. display,
  5630. e,
  5631. parts,
  5632. start,
  5633. end,
  5634. unit;
  5635. opt.animatedProperties = {};
  5636. for (p in prop) {
  5637. name = jQuery.camelCase(p);
  5638. if (p !== name) {
  5639. prop[name] = prop[p];
  5640. delete prop[p]
  5641. }
  5642. val = prop[name];
  5643. if (jQuery.isArray(val)) {
  5644. opt.animatedProperties[name] = val[1];
  5645. val = prop[name] = val[0]
  5646. } else {
  5647. opt.animatedProperties[name] = opt.specialEasing && opt.specialEasing[name] || opt.easing || "swing"
  5648. }
  5649. if (val === "hide" && hidden || val === "show" && !hidden) {
  5650. return opt.complete.call(this)
  5651. }
  5652. if (isElement && (name === "height" || name === "width")) {
  5653. opt.overflow = [this.style.overflow, this.style.overflowX, this.style.overflowY];
  5654. if (jQuery.css(this, "display") === "inline" && jQuery.css(this, "float") === "none") {
  5655. if (!jQuery.support.inlineBlockNeedsLayout) {
  5656. this.style.display = "inline-block"
  5657. } else {
  5658. display = defaultDisplay(this.nodeName);
  5659. if (display === "inline") {
  5660. this.style.display = "inline-block"
  5661. } else {
  5662. this.style.display = "inline";
  5663. this.style.zoom = 1
  5664. }
  5665. }
  5666. }
  5667. }
  5668. }
  5669. if (opt.overflow != null) {
  5670. this.style.overflow = "hidden"
  5671. }
  5672. for (p in prop) {
  5673. e = new jQuery.fx(this, opt, p);
  5674. val = prop[p];
  5675. if (rfxtypes.test(val)) {
  5676. e[val === "toggle" ? hidden ? "show" : "hide" : val]()
  5677. } else {
  5678. parts = rfxnum.exec(val);
  5679. start = e.cur();
  5680. if (parts) {
  5681. end = parseFloat(parts[2]);
  5682. unit = parts[3] || (jQuery.cssNumber[p] ? "" : "px");
  5683. if (unit !== "px") {
  5684. jQuery.style(this, p, (end || 1) + unit);
  5685. start = ((end || 1) / e.cur()) * start;
  5686. jQuery.style(this, p, start + unit)
  5687. }
  5688. if (parts[1]) {
  5689. end = ((parts[1] === "-=" ? -1 : 1) * end) + start
  5690. }
  5691. e.custom(start, end, unit)
  5692. } else {
  5693. e.custom(start, val, "")
  5694. }
  5695. }
  5696. }
  5697. return true
  5698. })
  5699. },
  5700. stop : function (clearQueue, gotoEnd) {
  5701. if (clearQueue) {
  5702. this.queue([])
  5703. }
  5704. this.each(function () {
  5705. var timers = jQuery.timers,
  5706. i = timers.length;
  5707. if (!gotoEnd) {
  5708. jQuery._unmark(true, this)
  5709. }
  5710. while (i--) {
  5711. if (timers[i].elem === this) {
  5712. if (gotoEnd) {
  5713. timers[i](true)
  5714. }
  5715. timers.splice(i, 1)
  5716. }
  5717. }
  5718. });
  5719. if (!gotoEnd) {
  5720. this.dequeue()
  5721. }
  5722. return this
  5723. }
  5724. });
  5725. function createFxNow() {
  5726. setTimeout(clearFxNow, 0);
  5727. return (fxNow = jQuery.now())
  5728. }
  5729. function clearFxNow() {
  5730. fxNow = undefined
  5731. }
  5732. function genFx(type, num) {
  5733. var obj = {};
  5734. jQuery.each(fxAttrs.concat.apply([], fxAttrs.slice(0, num)), function () {
  5735. obj[this] = type
  5736. });
  5737. return obj
  5738. }
  5739. jQuery.each({
  5740. slideDown : genFx("show", 1),
  5741. slideUp : genFx("hide", 1),
  5742. slideToggle : genFx("toggle", 1),
  5743. fadeIn : {
  5744. opacity : "show"
  5745. },
  5746. fadeOut : {
  5747. opacity : "hide"
  5748. },
  5749. fadeToggle : {
  5750. opacity : "toggle"
  5751. }
  5752. }, function (name, props) {
  5753. jQuery.fn[name] = function (speed, easing, callback) {
  5754. return this.animate(props, speed, easing, callback)
  5755. }
  5756. });
  5757. jQuery.extend({
  5758. speed : function (speed, easing, fn) {
  5759. var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
  5760. complete : fn || !fn && easing || jQuery.isFunction(speed) && speed,
  5761. duration : speed,
  5762. easing : fn && easing || easing && !jQuery.isFunction(easing) && easing
  5763. };
  5764. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
  5765. opt.old = opt.complete;
  5766. opt.complete = function (noUnmark) {
  5767. if (opt.queue !== false) {
  5768. jQuery.dequeue(this)
  5769. } else {
  5770. if (noUnmark !== false) {
  5771. jQuery._unmark(this)
  5772. }
  5773. }
  5774. if (jQuery.isFunction(opt.old)) {
  5775. opt.old.call(this)
  5776. }
  5777. };
  5778. return opt
  5779. },
  5780. easing : {
  5781. linear : function (p, n, firstNum, diff) {
  5782. return firstNum + diff * p
  5783. },
  5784. swing : function (p, n, firstNum, diff) {
  5785. return ((-Math.cos(p * Math.PI) / 2) + 0.5) * diff + firstNum
  5786. }
  5787. },
  5788. timers : [],
  5789. fx : function (elem, options, prop) {
  5790. this.options = options;
  5791. this.elem = elem;
  5792. this.prop = prop;
  5793. options.orig = options.orig || {}
  5794. }
  5795. });
  5796. jQuery.fx.prototype = {
  5797. update : function () {
  5798. if (this.options.step) {
  5799. this.options.step.call(this.elem, this.now, this)
  5800. }
  5801. (jQuery.fx.step[this.prop] || jQuery.fx.step._default)(this)
  5802. },
  5803. cur : function () {
  5804. if (this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null)) {
  5805. return this.elem[this.prop]
  5806. }
  5807. var parsed,
  5808. r = jQuery.css(this.elem, this.prop);
  5809. return isNaN(parsed = parseFloat(r)) ? !r || r === "auto" ? 0 : r : parsed
  5810. },
  5811. custom : function (from, to, unit) {
  5812. var self = this,
  5813. fx = jQuery.fx,
  5814. raf;
  5815. this.startTime = fxNow || createFxNow();
  5816. this.start = from;
  5817. this.end = to;
  5818. this.unit = unit || this.unit || (jQuery.cssNumber[this.prop] ? "" : "px");
  5819. this.now = this.start;
  5820. this.pos = this.state = 0;
  5821. function t(gotoEnd) {
  5822. return self.step(gotoEnd)
  5823. }
  5824. t.elem = this.elem;
  5825. if (t() && jQuery.timers.push(t) && !timerId) {
  5826. if (requestAnimationFrame) {
  5827. timerId = 1;
  5828. raf = function () {
  5829. if (timerId) {
  5830. requestAnimationFrame(raf);
  5831. fx.tick()
  5832. }
  5833. };
  5834. requestAnimationFrame(raf)
  5835. } else {
  5836. timerId = setInterval(fx.tick, fx.interval)
  5837. }
  5838. }
  5839. },
  5840. show : function () {
  5841. this.options.orig[this.prop] = jQuery.style(this.elem, this.prop);
  5842. this.options.show = true;
  5843. this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
  5844. jQuery(this.elem).show()
  5845. },
  5846. hide : function () {
  5847. this.options.orig[this.prop] = jQuery.style(this.elem, this.prop);
  5848. this.options.hide = true;
  5849. this.custom(this.cur(), 0)
  5850. },
  5851. step : function (gotoEnd) {
  5852. var t = fxNow || createFxNow(),
  5853. done = true,
  5854. elem = this.elem,
  5855. options = this.options,
  5856. i,
  5857. n;
  5858. if (gotoEnd || t >= options.duration + this.startTime) {
  5859. this.now = this.end;
  5860. this.pos = this.state = 1;
  5861. this.update();
  5862. options.animatedProperties[this.prop] = true;
  5863. for (i in options.animatedProperties) {
  5864. if (options.animatedProperties[i] !== true) {
  5865. done = false
  5866. }
  5867. }
  5868. if (done) {
  5869. if (options.overflow != null && !jQuery.support.shrinkWrapBlocks) {
  5870. jQuery.each(["", "X", "Y"], function (index, value) {
  5871. elem.style["overflow" + value] = options.overflow[index]
  5872. })
  5873. }
  5874. if (options.hide) {
  5875. jQuery(elem).hide()
  5876. }
  5877. if (options.hide || options.show) {
  5878. for (var p in options.animatedProperties) {
  5879. jQuery.style(elem, p, options.orig[p])
  5880. }
  5881. }
  5882. options.complete.call(elem)
  5883. }
  5884. return false
  5885. } else {
  5886. if (options.duration == Infinity) {
  5887. this.now = t
  5888. } else {
  5889. n = t - this.startTime;
  5890. this.state = n / options.duration;
  5891. this.pos = jQuery.easing[options.animatedProperties[this.prop]](this.state, n, 0, 1, options.duration);
  5892. this.now = this.start + ((this.end - this.start) * this.pos)
  5893. }
  5894. this.update()
  5895. }
  5896. return true
  5897. }
  5898. };
  5899. jQuery.extend(jQuery.fx, {
  5900. tick : function () {
  5901. for (var timers = jQuery.timers, i = 0; i < timers.length; ++i) {
  5902. if (!timers[i]()) {
  5903. timers.splice(i--, 1)
  5904. }
  5905. }
  5906. if (!timers.length) {
  5907. jQuery.fx.stop()
  5908. }
  5909. },
  5910. interval : 13,
  5911. stop : function () {
  5912. clearInterval(timerId);
  5913. timerId = null
  5914. },
  5915. speeds : {
  5916. slow : 600,
  5917. fast : 200,
  5918. _default : 400
  5919. },
  5920. step : {
  5921. opacity : function (fx) {
  5922. jQuery.style(fx.elem, "opacity", fx.now)
  5923. },
  5924. _default : function (fx) {
  5925. if (fx.elem.style && fx.elem.style[fx.prop] != null) {
  5926. fx.elem.style[fx.prop] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit
  5927. } else {
  5928. fx.elem[fx.prop] = fx.now
  5929. }
  5930. }
  5931. }
  5932. });
  5933. if (jQuery.expr && jQuery.expr.filters) {
  5934. jQuery.expr.filters.animated = function (elem) {
  5935. return jQuery.grep(jQuery.timers, function (fn) {
  5936. return elem === fn.elem
  5937. }).length
  5938. }
  5939. }
  5940. function defaultDisplay(nodeName) {
  5941. if (!elemdisplay[nodeName]) {
  5942. var elem = jQuery("<" + nodeName + ">").appendTo("body"),
  5943. display = elem.css("display");
  5944. elem.remove();
  5945. if (display === "none" || display === "") {
  5946. if (!iframe) {
  5947. iframe = document.createElement("iframe");
  5948. iframe.frameBorder = iframe.width = iframe.height = 0
  5949. }
  5950. document.body.appendChild(iframe);
  5951. if (!iframeDoc || !iframe.createElement) {
  5952. iframeDoc = (iframe.contentWindow || iframe.contentDocument).document;
  5953. iframeDoc.write("<!doctype><html><body></body></html>")
  5954. }
  5955. elem = iframeDoc.createElement(nodeName);
  5956. iframeDoc.body.appendChild(elem);
  5957. display = jQuery.css(elem, "display");
  5958. document.body.removeChild(iframe)
  5959. }
  5960. elemdisplay[nodeName] = display
  5961. }
  5962. return elemdisplay[nodeName]
  5963. }
  5964. var rtable = /^t(?:able|d|h)$/i,
  5965. rroot = /^(?:body|html)$/i;
  5966. if ("getBoundingClientRect" in document.documentElement) {
  5967. jQuery.fn.offset = function (options) {
  5968. var elem = this[0],
  5969. box;
  5970. if (options) {
  5971. return this.each(function (i) {
  5972. jQuery.offset.setOffset(this, options, i)
  5973. })
  5974. }
  5975. if (!elem || !elem.ownerDocument) {
  5976. return null
  5977. }
  5978. if (elem === elem.ownerDocument.body) {
  5979. return jQuery.offset.bodyOffset(elem)
  5980. }
  5981. try {
  5982. box = elem.getBoundingClientRect()
  5983. } catch (e) {}
  5984. var doc = elem.ownerDocument,
  5985. docElem = doc.documentElement;
  5986. if (!box || !jQuery.contains(docElem, elem)) {
  5987. return box ? {
  5988. top : box.top,
  5989. left : box.left
  5990. }
  5991. : {
  5992. top : 0,
  5993. left : 0
  5994. }
  5995. }
  5996. var body = doc.body,
  5997. win = getWindow(doc),
  5998. clientTop = docElem.clientTop || body.clientTop || 0,
  5999. clientLeft = docElem.clientLeft || body.clientLeft || 0,
  6000. scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
  6001. scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
  6002. top = box.top + scrollTop - clientTop,
  6003. left = box.left + scrollLeft - clientLeft;
  6004. return {
  6005. top : top,
  6006. left : left
  6007. }
  6008. }
  6009. } else {
  6010. jQuery.fn.offset = function (options) {
  6011. var elem = this[0];
  6012. if (options) {
  6013. return this.each(function (i) {
  6014. jQuery.offset.setOffset(this, options, i)
  6015. })
  6016. }
  6017. if (!elem || !elem.ownerDocument) {
  6018. return null
  6019. }
  6020. if (elem === elem.ownerDocument.body) {
  6021. return jQuery.offset.bodyOffset(elem)
  6022. }
  6023. jQuery.offset.initialize();
  6024. var computedStyle,
  6025. offsetParent = elem.offsetParent,
  6026. prevOffsetParent = elem,
  6027. doc = elem.ownerDocument,
  6028. docElem = doc.documentElement,
  6029. body = doc.body,
  6030. defaultView = doc.defaultView,
  6031. prevComputedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle,
  6032. top = elem.offsetTop,
  6033. left = elem.offsetLeft;
  6034. while ((elem = elem.parentNode) && elem !== body && elem !== docElem) {
  6035. if (jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed") {
  6036. break
  6037. }
  6038. computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
  6039. top -= elem.scrollTop;
  6040. left -= elem.scrollLeft;
  6041. if (elem === offsetParent) {
  6042. top += elem.offsetTop;
  6043. left += elem.offsetLeft;
  6044. if (jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName))) {
  6045. top += parseFloat(computedStyle.borderTopWidth) || 0;
  6046. left += parseFloat(computedStyle.borderLeftWidth) || 0
  6047. }
  6048. prevOffsetParent = offsetParent;
  6049. offsetParent = elem.offsetParent
  6050. }
  6051. if (jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible") {
  6052. top += parseFloat(computedStyle.borderTopWidth) || 0;
  6053. left += parseFloat(computedStyle.borderLeftWidth) || 0
  6054. }
  6055. prevComputedStyle = computedStyle
  6056. }
  6057. if (prevComputedStyle.position === "relative" || prevComputedStyle.position === "static") {
  6058. top += body.offsetTop;
  6059. left += body.offsetLeft
  6060. }
  6061. if (jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed") {
  6062. top += Math.max(docElem.scrollTop, body.scrollTop);
  6063. left += Math.max(docElem.scrollLeft, body.scrollLeft)
  6064. }
  6065. return {
  6066. top : top,
  6067. left : left
  6068. }
  6069. }
  6070. }
  6071. jQuery.offset = {
  6072. initialize : function () {
  6073. var body = document.body,
  6074. container = document.createElement("div"),
  6075. innerDiv,
  6076. checkDiv,
  6077. table,
  6078. td,
  6079. bodyMarginTop = parseFloat(jQuery.css(body, "marginTop")) || 0,
  6080. html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
  6081. jQuery.extend(container.style, {
  6082. position : "absolute",
  6083. top : 0,
  6084. left : 0,
  6085. margin : 0,
  6086. border : 0,
  6087. width : "1px",
  6088. height : "1px",
  6089. visibility : "hidden"
  6090. });
  6091. container.innerHTML = html;
  6092. body.insertBefore(container, body.firstChild);
  6093. innerDiv = container.firstChild;
  6094. checkDiv = innerDiv.firstChild;
  6095. td = innerDiv.nextSibling.firstChild.firstChild;
  6096. this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
  6097. this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
  6098. checkDiv.style.position = "fixed";
  6099. checkDiv.style.top = "20px";
  6100. this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
  6101. checkDiv.style.position = checkDiv.style.top = "";
  6102. innerDiv.style.overflow = "hidden";
  6103. innerDiv.style.position = "relative";
  6104. this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
  6105. this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
  6106. body.removeChild(container);
  6107. jQuery.offset.initialize = jQuery.noop
  6108. },
  6109. bodyOffset : function (body) {
  6110. var top = body.offsetTop,
  6111. left = body.offsetLeft;
  6112. jQuery.offset.initialize();
  6113. if (jQuery.offset.doesNotIncludeMarginInBodyOffset) {
  6114. top += parseFloat(jQuery.css(body, "marginTop")) || 0;
  6115. left += parseFloat(jQuery.css(body, "marginLeft")) || 0
  6116. }
  6117. return {
  6118. top : top,
  6119. left : left
  6120. }
  6121. },
  6122. setOffset : function (elem, options, i) {
  6123. var position = jQuery.css(elem, "position");
  6124. if (position === "static") {
  6125. elem.style.position = "relative"
  6126. }
  6127. var curElem = jQuery(elem),
  6128. curOffset = curElem.offset(),
  6129. curCSSTop = jQuery.css(elem, "top"),
  6130. curCSSLeft = jQuery.css(elem, "left"),
  6131. calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
  6132. props = {},
  6133. curPosition = {},
  6134. curTop,
  6135. curLeft;
  6136. if (calculatePosition) {
  6137. curPosition = curElem.position();
  6138. curTop = curPosition.top;
  6139. curLeft = curPosition.left
  6140. } else {
  6141. curTop = parseFloat(curCSSTop) || 0;
  6142. curLeft = parseFloat(curCSSLeft) || 0
  6143. }
  6144. if (jQuery.isFunction(options)) {
  6145. options = options.call(elem, i, curOffset)
  6146. }
  6147. if (options.top != null) {
  6148. props.top = (options.top - curOffset.top) + curTop
  6149. }
  6150. if (options.left != null) {
  6151. props.left = (options.left - curOffset.left) + curLeft
  6152. }
  6153. if ("using" in options) {
  6154. options.using.call(elem, props)
  6155. } else {
  6156. curElem.css(props)
  6157. }
  6158. }
  6159. };
  6160. jQuery.fn.extend({
  6161. position : function () {
  6162. if (!this[0]) {
  6163. return null
  6164. }
  6165. var elem = this[0],
  6166. offsetParent = this.offsetParent(),
  6167. offset = this.offset(),
  6168. parentOffset = rroot.test(offsetParent[0].nodeName) ? {
  6169. top : 0,
  6170. left : 0
  6171. }
  6172. : offsetParent.offset();
  6173. offset.top -= parseFloat(jQuery.css(elem, "marginTop")) || 0;
  6174. offset.left -= parseFloat(jQuery.css(elem, "marginLeft")) || 0;
  6175. parentOffset.top += parseFloat(jQuery.css(offsetParent[0], "borderTopWidth")) || 0;
  6176. parentOffset.left += parseFloat(jQuery.css(offsetParent[0], "borderLeftWidth")) || 0;
  6177. return {
  6178. top : offset.top - parentOffset.top,
  6179. left : offset.left - parentOffset.left
  6180. }
  6181. },
  6182. offsetParent : function () {
  6183. return this.map(function () {
  6184. var offsetParent = this.offsetParent || document.body;
  6185. while (offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static")) {
  6186. offsetParent = offsetParent.offsetParent
  6187. }
  6188. return offsetParent
  6189. })
  6190. }
  6191. });
  6192. jQuery.each(["Left", "Top"], function (i, name) {
  6193. var method = "scroll" + name;
  6194. jQuery.fn[method] = function (val) {
  6195. var elem,
  6196. win;
  6197. if (val === undefined) {
  6198. elem = this[0];
  6199. if (!elem) {
  6200. return null
  6201. }
  6202. win = getWindow(elem);
  6203. return win ? ("pageXOffset" in win) ? win[i ? "pageYOffset" : "pageXOffset"] : jQuery.support.boxModel && win.document.documentElement[method] || win.document.body[method] : elem[method]
  6204. }
  6205. return this.each(function () {
  6206. win = getWindow(this);
  6207. if (win) {
  6208. win.scrollTo(!i ? val : jQuery(win).scrollLeft(), i ? val : jQuery(win).scrollTop())
  6209. } else {
  6210. this[method] = val
  6211. }
  6212. })
  6213. }
  6214. });
  6215. function getWindow(elem) {
  6216. return jQuery.isWindow(elem) ? elem : elem.nodeType === 9 ? elem.defaultView || elem.parentWindow : false
  6217. }
  6218. jQuery.each(["Height", "Width"], function (i, name) {
  6219. var type = name.toLowerCase();
  6220. jQuery.fn["inner" + name] = function () {
  6221. return this[0] ? parseFloat(jQuery.css(this[0], type, "padding")) : null
  6222. };
  6223. jQuery.fn["outer" + name] = function (margin) {
  6224. return this[0] ? parseFloat(jQuery.css(this[0], type, margin ? "margin" : "border")) : null
  6225. };
  6226. jQuery.fn[type] = function (size) {
  6227. var elem = this[0];
  6228. if (!elem) {
  6229. return size == null ? null : this
  6230. }
  6231. if (jQuery.isFunction(size)) {
  6232. return this.each(function (i) {
  6233. var self = jQuery(this);
  6234. self[type](size.call(this, i, self[type]()))
  6235. })
  6236. }
  6237. if (jQuery.isWindow(elem)) {
  6238. var docElemProp = elem.document.documentElement["client" + name];
  6239. return elem.document.compatMode === "CSS1Compat" && docElemProp || elem.document.body["client" + name] || docElemProp
  6240. } else {
  6241. if (elem.nodeType === 9) {
  6242. return Math.max(elem.documentElement["client" + name], elem.body["scroll" + name], elem.documentElement["scroll" + name], elem.body["offset" + name], elem.documentElement["offset" + name])
  6243. } else {
  6244. if (size === undefined) {
  6245. var orig = jQuery.css(elem, type),
  6246. ret = parseFloat(orig);
  6247. return jQuery.isNaN(ret) ? orig : ret
  6248. } else {
  6249. return this.css(type, typeof size === "string" ? size : size + "px")
  6250. }
  6251. }
  6252. }
  6253. }
  6254. });
  6255. window.jQuery = window.$ = jQuery
  6256. })(window);
  6257. /*
  6258. * jQuery UI 1.8.12
  6259. *
  6260. * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
  6261. * Dual licensed under the MIT or GPL Version 2 licenses.
  6262. * http://jquery.org/license
  6263. *
  6264. * http://docs.jquery.com/UI
  6265. */
  6266. (function ($, undefined) {
  6267. $.ui = $.ui || {};
  6268. if ($.ui.version) {
  6269. return
  6270. }
  6271. $.extend($.ui, {
  6272. version : "1.8.12",
  6273. keyCode : {
  6274. ALT : 18,
  6275. BACKSPACE : 8,
  6276. CAPS_LOCK : 20,
  6277. COMMA : 188,
  6278. COMMAND : 91,
  6279. COMMAND_LEFT : 91,
  6280. COMMAND_RIGHT : 93,
  6281. CONTROL : 17,
  6282. DELETE : 46,
  6283. DOWN : 40,
  6284. END : 35,
  6285. ENTER : 13,
  6286. ESCAPE : 27,
  6287. HOME : 36,
  6288. INSERT : 45,
  6289. LEFT : 37,
  6290. MENU : 93,
  6291. NUMPAD_ADD : 107,
  6292. NUMPAD_DECIMAL : 110,
  6293. NUMPAD_DIVIDE : 111,
  6294. NUMPAD_ENTER : 108,
  6295. NUMPAD_MULTIPLY : 106,
  6296. NUMPAD_SUBTRACT : 109,
  6297. PAGE_DOWN : 34,
  6298. PAGE_UP : 33,
  6299. PERIOD : 190,
  6300. RIGHT : 39,
  6301. SHIFT : 16,
  6302. SPACE : 32,
  6303. TAB : 9,
  6304. UP : 38,
  6305. WINDOWS : 91
  6306. }
  6307. });
  6308. $.fn.extend({
  6309. _focus : $.fn.focus,
  6310. focus : function (delay, fn) {
  6311. return typeof delay === "number" ? this.each(function () {
  6312. var elem = this;
  6313. setTimeout(function () {
  6314. $(elem).focus();
  6315. if (fn) {
  6316. fn.call(elem)
  6317. }
  6318. }, delay)
  6319. }) : this._focus.apply(this, arguments)
  6320. },
  6321. scrollParent : function () {
  6322. var scrollParent;
  6323. if (($.browser.msie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  6324. scrollParent = this.parents().filter(function () {
  6325. return (/(relative|absolute|fixed)/).test($.curCSS(this, "position", 1)) && (/(auto|scroll)/).test($.curCSS(this, "overflow", 1) + $.curCSS(this, "overflow-y", 1) + $.curCSS(this, "overflow-x", 1))
  6326. }).eq(0)
  6327. } else {
  6328. scrollParent = this.parents().filter(function () {
  6329. return (/(auto|scroll)/).test($.curCSS(this, "overflow", 1) + $.curCSS(this, "overflow-y", 1) + $.curCSS(this, "overflow-x", 1))
  6330. }).eq(0)
  6331. }
  6332. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent
  6333. },
  6334. zIndex : function (zIndex) {
  6335. if (zIndex !== undefined) {
  6336. return this.css("zIndex", zIndex)
  6337. }
  6338. if (this.length) {
  6339. var elem = $(this[0]),
  6340. position,
  6341. value;
  6342. while (elem.length && elem[0] !== document) {
  6343. position = elem.css("position");
  6344. if (position === "absolute" || position === "relative" || position === "fixed") {
  6345. value = parseInt(elem.css("zIndex"), 10);
  6346. if (!isNaN(value) && value !== 0) {
  6347. return value
  6348. }
  6349. }
  6350. elem = elem.parent()
  6351. }
  6352. }
  6353. return 0
  6354. },
  6355. disableSelection : function () {
  6356. return this.bind(($.support.selectstart ? "selectstart" : "mousedown") + ".ui-disableSelection", function (event) {
  6357. event.preventDefault()
  6358. })
  6359. },
  6360. enableSelection : function () {
  6361. return this.unbind(".ui-disableSelection")
  6362. }
  6363. });
  6364. $.each(["Width", "Height"], function (i, name) {
  6365. var side = name === "Width" ? ["Left", "Right"] : ["Top", "Bottom"],
  6366. type = name.toLowerCase(),
  6367. orig = {
  6368. innerWidth : $.fn.innerWidth,
  6369. innerHeight : $.fn.innerHeight,
  6370. outerWidth : $.fn.outerWidth,
  6371. outerHeight : $.fn.outerHeight
  6372. };
  6373. function reduce(elem, size, border, margin) {
  6374. $.each(side, function () {
  6375. size -= parseFloat($.curCSS(elem, "padding" + this, true)) || 0;
  6376. if (border) {
  6377. size -= parseFloat($.curCSS(elem, "border" + this + "Width", true)) || 0
  6378. }
  6379. if (margin) {
  6380. size -= parseFloat($.curCSS(elem, "margin" + this, true)) || 0
  6381. }
  6382. });
  6383. return size
  6384. }
  6385. $.fn["inner" + name] = function (size) {
  6386. if (size === undefined) {
  6387. return orig["inner" + name].call(this)
  6388. }
  6389. return this.each(function () {
  6390. $(this).css(type, reduce(this, size) + "px")
  6391. })
  6392. };
  6393. $.fn["outer" + name] = function (size, margin) {
  6394. if (typeof size !== "number") {
  6395. return orig["outer" + name].call(this, size)
  6396. }
  6397. return this.each(function () {
  6398. $(this).css(type, reduce(this, size, true, margin) + "px")
  6399. })
  6400. }
  6401. });
  6402. function visible(element) {
  6403. return !$(element).parents().andSelf().filter(function () {
  6404. return $.curCSS(this, "visibility") === "hidden" || $.expr.filters.hidden(this)
  6405. }).length
  6406. }
  6407. $.extend($.expr[":"], {
  6408. data : function (elem, i, match) {
  6409. return !!$.data(elem, match[3])
  6410. },
  6411. focusable : function (element) {
  6412. var nodeName = element.nodeName.toLowerCase(),
  6413. tabIndex = $.attr(element, "tabindex");
  6414. if ("area" === nodeName) {
  6415. var map = element.parentNode,
  6416. mapName = map.name,
  6417. img;
  6418. if (!element.href || !mapName || map.nodeName.toLowerCase() !== "map") {
  6419. return false
  6420. }
  6421. img = $("img[usemap=#" + mapName + "]")[0];
  6422. return !!img && visible(img)
  6423. }
  6424. return (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled : "a" == nodeName ? element.href || !isNaN(tabIndex) : !isNaN(tabIndex)) && visible(element)
  6425. },
  6426. tabbable : function (element) {
  6427. var tabIndex = $.attr(element, "tabindex");
  6428. return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(":focusable")
  6429. }
  6430. });
  6431. $(function () {
  6432. var body = document.body,
  6433. div = body.appendChild(div = document.createElement("div"));
  6434. $.extend(div.style, {
  6435. minHeight : "100px",
  6436. height : "auto",
  6437. padding : 0,
  6438. borderWidth : 0
  6439. });
  6440. $.support.minHeight = div.offsetHeight === 100;
  6441. $.support.selectstart = "onselectstart" in div;
  6442. body.removeChild(div).style.display = "none"
  6443. });
  6444. $.extend($.ui, {
  6445. plugin : {
  6446. add : function (module, option, set) {
  6447. var proto = $.ui[module].prototype;
  6448. for (var i in set) {
  6449. proto.plugins[i] = proto.plugins[i] || [];
  6450. proto.plugins[i].push([option, set[i]])
  6451. }
  6452. },
  6453. call : function (instance, name, args) {
  6454. var set = instance.plugins[name];
  6455. if (!set || !instance.element[0].parentNode) {
  6456. return
  6457. }
  6458. for (var i = 0; i < set.length; i++) {
  6459. if (instance.options[set[i][0]]) {
  6460. set[i][1].apply(instance.element, args)
  6461. }
  6462. }
  6463. }
  6464. },
  6465. contains : function (a, b) {
  6466. return document.compareDocumentPosition ? a.compareDocumentPosition(b) & 16 : a !== b && a.contains(b)
  6467. },
  6468. hasScroll : function (el, a) {
  6469. if ($(el).css("overflow") === "hidden") {
  6470. return false
  6471. }
  6472. var scroll = (a && a === "left") ? "scrollLeft" : "scrollTop",
  6473. has = false;
  6474. if (el[scroll] > 0) {
  6475. return true
  6476. }
  6477. el[scroll] = 1;
  6478. has = (el[scroll] > 0);
  6479. el[scroll] = 0;
  6480. return has
  6481. },
  6482. isOverAxis : function (x, reference, size) {
  6483. return (x > reference) && (x < (reference + size))
  6484. },
  6485. isOver : function (y, x, top, left, height, width) {
  6486. return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width)
  6487. }
  6488. })
  6489. })(jQuery);
  6490. /*
  6491. * jQuery UI Widget 1.8.12
  6492. *
  6493. * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
  6494. * Dual licensed under the MIT or GPL Version 2 licenses.
  6495. * http://jquery.org/license
  6496. *
  6497. * http://docs.jquery.com/UI/Widget
  6498. */
  6499. (function ($, undefined) {
  6500. if ($.cleanData) {
  6501. var _cleanData = $.cleanData;
  6502. $.cleanData = function (elems) {
  6503. for (var i = 0, elem; (elem = elems[i]) != null; i++) {
  6504. $(elem).triggerHandler("remove")
  6505. }
  6506. _cleanData(elems)
  6507. }
  6508. } else {
  6509. var _remove = $.fn.remove;
  6510. $.fn.remove = function (selector, keepData) {
  6511. return this.each(function () {
  6512. if (!keepData) {
  6513. if (!selector || $.filter(selector, [this]).length) {
  6514. $("*", this).add([this]).each(function () {
  6515. $(this).triggerHandler("remove")
  6516. })
  6517. }
  6518. }
  6519. return _remove.call($(this), selector, keepData)
  6520. })
  6521. }
  6522. }
  6523. $.widget = function (name, base, prototype) {
  6524. var namespace = name.split(".")[0],
  6525. fullName;
  6526. name = name.split(".")[1];
  6527. fullName = namespace + "-" + name;
  6528. if (!prototype) {
  6529. prototype = base;
  6530. base = $.Widget
  6531. }
  6532. $.expr[":"][fullName] = function (elem) {
  6533. return !!$.data(elem, name)
  6534. };
  6535. $[namespace] = $[namespace] || {};
  6536. $[namespace][name] = function (options, element) {
  6537. if (arguments.length) {
  6538. this._createWidget(options, element)
  6539. }
  6540. };
  6541. var basePrototype = new base();
  6542. basePrototype.options = $.extend(true, {}, basePrototype.options);
  6543. $[namespace][name].prototype = $.extend(true, basePrototype, {
  6544. namespace : namespace,
  6545. widgetName : name,
  6546. widgetEventPrefix : $[namespace][name].prototype.widgetEventPrefix || name,
  6547. widgetBaseClass : fullName
  6548. }, prototype);
  6549. $.widget.bridge(name, $[namespace][name])
  6550. };
  6551. $.widget.bridge = function (name, object) {
  6552. $.fn[name] = function (options) {
  6553. var isMethodCall = typeof options === "string",
  6554. args = Array.prototype.slice.call(arguments, 1),
  6555. returnValue = this;
  6556. options = !isMethodCall && args.length ? $.extend.apply(null, [true, options].concat(args)) : options;
  6557. if (isMethodCall && options.charAt(0) === "_") {
  6558. return returnValue
  6559. }
  6560. if (isMethodCall) {
  6561. this.each(function () {
  6562. var instance = $.data(this, name),
  6563. methodValue = instance && $.isFunction(instance[options]) ? instance[options].apply(instance, args) : instance;
  6564. if (methodValue !== instance && methodValue !== undefined) {
  6565. returnValue = methodValue;
  6566. return false
  6567. }
  6568. })
  6569. } else {
  6570. this.each(function () {
  6571. var instance = $.data(this, name);
  6572. if (instance) {
  6573. instance.option(options || {})._init()
  6574. } else {
  6575. $.data(this, name, new object(options, this))
  6576. }
  6577. })
  6578. }
  6579. return returnValue
  6580. }
  6581. };
  6582. $.Widget = function (options, element) {
  6583. if (arguments.length) {
  6584. this._createWidget(options, element)
  6585. }
  6586. };
  6587. $.Widget.prototype = {
  6588. widgetName : "widget",
  6589. widgetEventPrefix : "",
  6590. options : {
  6591. disabled : false
  6592. },
  6593. _createWidget : function (options, element) {
  6594. $.data(element, this.widgetName, this);
  6595. this.element = $(element);
  6596. this.options = $.extend(true, {}, this.options, this._getCreateOptions(), options);
  6597. var self = this;
  6598. this.element.bind("remove." + this.widgetName, function () {
  6599. self.destroy()
  6600. });
  6601. this._create();
  6602. this._trigger("create");
  6603. this._init()
  6604. },
  6605. _getCreateOptions : function () {
  6606. return $.metadata && $.metadata.get(this.element[0])[this.widgetName]
  6607. },
  6608. _create : function () {},
  6609. _init : function () {},
  6610. destroy : function () {
  6611. this.element.unbind("." + this.widgetName).removeData(this.widgetName);
  6612. this.widget().unbind("." + this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass + "-disabled ui-state-disabled")
  6613. },
  6614. widget : function () {
  6615. return this.element
  6616. },
  6617. option : function (key, value) {
  6618. var options = key;
  6619. if (arguments.length === 0) {
  6620. return $.extend({}, this.options)
  6621. }
  6622. if (typeof key === "string") {
  6623. if (value === undefined) {
  6624. return this.options[key]
  6625. }
  6626. options = {};
  6627. options[key] = value
  6628. }
  6629. this._setOptions(options);
  6630. return this
  6631. },
  6632. _setOptions : function (options) {
  6633. var self = this;
  6634. $.each(options, function (key, value) {
  6635. self._setOption(key, value)
  6636. });
  6637. return this
  6638. },
  6639. _setOption : function (key, value) {
  6640. this.options[key] = value;
  6641. if (key === "disabled") {
  6642. this.widget()[value ? "addClass" : "removeClass"](this.widgetBaseClass + "-disabled ui-state-disabled").attr("aria-disabled", value)
  6643. }
  6644. return this
  6645. },
  6646. enable : function () {
  6647. return this._setOption("disabled", false)
  6648. },
  6649. disable : function () {
  6650. return this._setOption("disabled", true)
  6651. },
  6652. _trigger : function (type, event, data) {
  6653. var callback = this.options[type];
  6654. event = $.Event(event);
  6655. event.type = (type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type).toLowerCase();
  6656. data = data || {};
  6657. if (event.originalEvent) {
  6658. for (var i = $.event.props.length, prop; i; ) {
  6659. prop = $.event.props[--i];
  6660. event[prop] = event.originalEvent[prop]
  6661. }
  6662. }
  6663. this.element.trigger(event, data);
  6664. return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false || event.isDefaultPrevented())
  6665. }
  6666. }
  6667. })(jQuery);
  6668. /*
  6669. * jQuery UI Mouse 1.8.12
  6670. *
  6671. * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
  6672. * Dual licensed under the MIT or GPL Version 2 licenses.
  6673. * http://jquery.org/license
  6674. *
  6675. * http://docs.jquery.com/UI/Mouse
  6676. *
  6677. * Depends:
  6678. * jquery.ui.widget.js
  6679. */
  6680. (function ($, undefined) {
  6681. $.widget("ui.mouse", {
  6682. options : {
  6683. cancel : ":input,option",
  6684. distance : 1,
  6685. delay : 0
  6686. },
  6687. _mouseInit : function () {
  6688. var self = this;
  6689. this.element.bind("mousedown." + this.widgetName, function (event) {
  6690. return self._mouseDown(event)
  6691. }).bind("click." + this.widgetName, function (event) {
  6692. if (true === $.data(event.target, self.widgetName + ".preventClickEvent")) {
  6693. $.removeData(event.target, self.widgetName + ".preventClickEvent");
  6694. event.stopImmediatePropagation();
  6695. return false
  6696. }
  6697. });
  6698. this.started = false
  6699. },
  6700. _mouseDestroy : function () {
  6701. this.element.unbind("." + this.widgetName)
  6702. },
  6703. _mouseDown : function (event) {
  6704. event.originalEvent = event.originalEvent || {};
  6705. if (event.originalEvent.mouseHandled) {
  6706. return
  6707. }
  6708. (this._mouseStarted && this._mouseUp(event));
  6709. this._mouseDownEvent = event;
  6710. var self = this,
  6711. btnIsLeft = (event.which == 1),
  6712. elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
  6713. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  6714. return true
  6715. }
  6716. this.mouseDelayMet = !this.options.delay;
  6717. if (!this.mouseDelayMet) {
  6718. this._mouseDelayTimer = setTimeout(function () {
  6719. self.mouseDelayMet = true
  6720. }, this.options.delay)
  6721. }
  6722. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  6723. this._mouseStarted = (this._mouseStart(event) !== false);
  6724. if (!this._mouseStarted) {
  6725. event.preventDefault();
  6726. return true
  6727. }
  6728. }
  6729. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  6730. $.removeData(event.target, this.widgetName + ".preventClickEvent")
  6731. }
  6732. this._mouseMoveDelegate = function (event) {
  6733. return self._mouseMove(event)
  6734. };
  6735. this._mouseUpDelegate = function (event) {
  6736. return self._mouseUp(event)
  6737. };
  6738. $(document).bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate);
  6739. event.preventDefault();
  6740. event.originalEvent.mouseHandled = true;
  6741. return true
  6742. },
  6743. _mouseMove : function (event) {
  6744. if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
  6745. return this._mouseUp(event)
  6746. }
  6747. if (this._mouseStarted) {
  6748. this._mouseDrag(event);
  6749. return event.preventDefault()
  6750. }
  6751. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  6752. this._mouseStarted = (this._mouseStart(this._mouseDownEvent, event) !== false);
  6753. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event))
  6754. }
  6755. return !this._mouseStarted
  6756. },
  6757. _mouseUp : function (event) {
  6758. $(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  6759. if (this._mouseStarted) {
  6760. this._mouseStarted = false;
  6761. if (event.target == this._mouseDownEvent.target) {
  6762. $.data(event.target, this.widgetName + ".preventClickEvent", true)
  6763. }
  6764. this._mouseStop(event)
  6765. }
  6766. return false
  6767. },
  6768. _mouseDistanceMet : function (event) {
  6769. return (Math.max(Math.abs(this._mouseDownEvent.pageX - event.pageX), Math.abs(this._mouseDownEvent.pageY - event.pageY)) >= this.options.distance)
  6770. },
  6771. _mouseDelayMet : function (event) {
  6772. return this.mouseDelayMet
  6773. },
  6774. _mouseStart : function (event) {},
  6775. _mouseDrag : function (event) {},
  6776. _mouseStop : function (event) {},
  6777. _mouseCapture : function (event) {
  6778. return true
  6779. }
  6780. })
  6781. })(jQuery);
  6782. (function ($, undefined) {
  6783. $.ui = $.ui || {};
  6784. var horizontalPositions = /left|center|right/,
  6785. verticalPositions = /top|center|bottom/,
  6786. center = "center",
  6787. _position = $.fn.position,
  6788. _offset = $.fn.offset;
  6789. $.fn.position = function (options) {
  6790. if (!options || !options.of) {
  6791. return _position.apply(this, arguments)
  6792. }
  6793. options = $.extend({}, options);
  6794. var target = $(options.of),
  6795. targetElem = target[0],
  6796. collision = (options.collision || "flip").split(" "),
  6797. offset = options.offset ? options.offset.split(" ") : [0, 0],
  6798. targetWidth,
  6799. targetHeight,
  6800. basePosition;
  6801. if (targetElem.nodeType === 9) {
  6802. targetWidth = target.width();
  6803. targetHeight = target.height();
  6804. basePosition = {
  6805. top : 0,
  6806. left : 0
  6807. }
  6808. } else {
  6809. if (targetElem.setTimeout) {
  6810. targetWidth = target.width();
  6811. targetHeight = target.height();
  6812. basePosition = {
  6813. top : target.scrollTop(),
  6814. left : target.scrollLeft()
  6815. }
  6816. } else {
  6817. if (targetElem.preventDefault) {
  6818. options.at = "left top";
  6819. targetWidth = targetHeight = 0;
  6820. basePosition = {
  6821. top : options.of.pageY,
  6822. left : options.of.pageX
  6823. }
  6824. } else {
  6825. targetWidth = target.outerWidth();
  6826. targetHeight = target.outerHeight();
  6827. basePosition = target.offset()
  6828. }
  6829. }
  6830. }
  6831. $.each(["my", "at"], function () {
  6832. var pos = (options[this] || "").split(" ");
  6833. if (pos.length === 1) {
  6834. pos = horizontalPositions.test(pos[0]) ? pos.concat([center]) : verticalPositions.test(pos[0]) ? [center].concat(pos) : [center, center]
  6835. }
  6836. pos[0] = horizontalPositions.test(pos[0]) ? pos[0] : center;
  6837. pos[1] = verticalPositions.test(pos[1]) ? pos[1] : center;
  6838. options[this] = pos
  6839. });
  6840. if (collision.length === 1) {
  6841. collision[1] = collision[0]
  6842. }
  6843. offset[0] = parseInt(offset[0], 10) || 0;
  6844. if (offset.length === 1) {
  6845. offset[1] = offset[0]
  6846. }
  6847. offset[1] = parseInt(offset[1], 10) || 0;
  6848. if (options.at[0] === "right") {
  6849. basePosition.left += targetWidth
  6850. } else {
  6851. if (options.at[0] === center) {
  6852. basePosition.left += targetWidth / 2
  6853. }
  6854. }
  6855. if (options.at[1] === "bottom") {
  6856. basePosition.top += targetHeight
  6857. } else {
  6858. if (options.at[1] === center) {
  6859. basePosition.top += targetHeight / 2
  6860. }
  6861. }
  6862. basePosition.left += offset[0];
  6863. basePosition.top += offset[1];
  6864. return this.each(function () {
  6865. var elem = $(this),
  6866. elemWidth = elem.outerWidth(),
  6867. elemHeight = elem.outerHeight(),
  6868. marginLeft = parseInt($.curCSS(this, "marginLeft", true)) || 0,
  6869. marginTop = parseInt($.curCSS(this, "marginTop", true)) || 0,
  6870. collisionWidth = elemWidth + marginLeft + (parseInt($.curCSS(this, "marginRight", true)) || 0),
  6871. collisionHeight = elemHeight + marginTop + (parseInt($.curCSS(this, "marginBottom", true)) || 0),
  6872. position = $.extend({}, basePosition),
  6873. collisionPosition;
  6874. if (options.my[0] === "right") {
  6875. position.left -= elemWidth
  6876. } else {
  6877. if (options.my[0] === center) {
  6878. position.left -= elemWidth / 2
  6879. }
  6880. }
  6881. if (options.my[1] === "bottom") {
  6882. position.top -= elemHeight
  6883. } else {
  6884. if (options.my[1] === center) {
  6885. position.top -= elemHeight / 2
  6886. }
  6887. }
  6888. position.left = Math.round(position.left);
  6889. position.top = Math.round(position.top);
  6890. collisionPosition = {
  6891. left : position.left - marginLeft,
  6892. top : position.top - marginTop
  6893. };
  6894. $.each(["left", "top"], function (i, dir) {
  6895. if ($.ui.position[collision[i]]) {
  6896. $.ui.position[collision[i]][dir](position, {
  6897. targetWidth : targetWidth,
  6898. targetHeight : targetHeight,
  6899. elemWidth : elemWidth,
  6900. elemHeight : elemHeight,
  6901. collisionPosition : collisionPosition,
  6902. collisionWidth : collisionWidth,
  6903. collisionHeight : collisionHeight,
  6904. offset : offset,
  6905. my : options.my,
  6906. at : options.at
  6907. })
  6908. }
  6909. });
  6910. if ($.fn.bgiframe) {
  6911. elem.bgiframe()
  6912. }
  6913. elem.offset($.extend(position, {
  6914. using : options.using
  6915. }))
  6916. })
  6917. };
  6918. $.ui.position = {
  6919. fit : {
  6920. left : function (position, data) {
  6921. var win = $(window),
  6922. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
  6923. position.left = over > 0 ? position.left - over : Math.max(position.left - data.collisionPosition.left, position.left)
  6924. },
  6925. top : function (position, data) {
  6926. var win = $(window),
  6927. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
  6928. position.top = over > 0 ? position.top - over : Math.max(position.top - data.collisionPosition.top, position.top)
  6929. }
  6930. },
  6931. flip : {
  6932. left : function (position, data) {
  6933. if (data.at[0] === center) {
  6934. return
  6935. }
  6936. var win = $(window),
  6937. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
  6938. myOffset = data.my[0] === "left" ? -data.elemWidth : data.my[0] === "right" ? data.elemWidth : 0,
  6939. atOffset = data.at[0] === "left" ? data.targetWidth : -data.targetWidth,
  6940. offset = -2 * data.offset[0];
  6941. position.left += data.collisionPosition.left < 0 ? myOffset + atOffset + offset : over > 0 ? myOffset + atOffset + offset : 0
  6942. },
  6943. top : function (position, data) {
  6944. if (data.at[1] === center) {
  6945. return
  6946. }
  6947. var win = $(window),
  6948. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
  6949. myOffset = data.my[1] === "top" ? -data.elemHeight : data.my[1] === "bottom" ? data.elemHeight : 0,
  6950. atOffset = data.at[1] === "top" ? data.targetHeight : -data.targetHeight,
  6951. offset = -2 * data.offset[1];
  6952. position.top += data.collisionPosition.top < 0 ? myOffset + atOffset + offset : over > 0 ? myOffset + atOffset + offset : 0
  6953. }
  6954. }
  6955. };
  6956. if (!$.offset.setOffset) {
  6957. $.offset.setOffset = function (elem, options) {
  6958. if (/static/.test($.curCSS(elem, "position"))) {
  6959. elem.style.position = "relative"
  6960. }
  6961. var curElem = $(elem),
  6962. curOffset = curElem.offset(),
  6963. curTop = parseInt($.curCSS(elem, "top", true), 10) || 0,
  6964. curLeft = parseInt($.curCSS(elem, "left", true), 10) || 0,
  6965. props = {
  6966. top : (options.top - curOffset.top) + curTop,
  6967. left : (options.left - curOffset.left) + curLeft
  6968. };
  6969. if ("using" in options) {
  6970. options.using.call(elem, props)
  6971. } else {
  6972. curElem.css(props)
  6973. }
  6974. };
  6975. $.fn.offset = function (options) {
  6976. var elem = this[0];
  6977. if (!elem || !elem.ownerDocument) {
  6978. return null
  6979. }
  6980. if (options) {
  6981. return this.each(function () {
  6982. $.offset.setOffset(this, options)
  6983. })
  6984. }
  6985. return _offset.call(this)
  6986. }
  6987. }
  6988. }
  6989. (jQuery));
  6990. /*
  6991. * Fluid Infusion v1.4
  6992. *
  6993. * Infusion is distributed under the Educational Community License 2.0 and new BSD licenses:
  6994. * http://wiki.fluidproject.org/display/fluid/Fluid+Licensing
  6995. *
  6996. * For information on copyright, see the individual Infusion source code files:
  6997. * https://github.com/fluid-project/infusion/
  6998. */
  6999. var fluid_1_4 = fluid_1_4 || {};
  7000. var fluid = fluid || fluid_1_4;
  7001. (function ($, fluid) {
  7002. fluid.version = "Infusion 1.4";
  7003. fluid.environment = {
  7004. fluid : fluid
  7005. };
  7006. var globalObject = window || {};
  7007. var softFailure = [true];
  7008. fluid.describeActivity = function () {
  7009. return []
  7010. };
  7011. fluid.fail = function (message) {
  7012. fluid.setLogging(true);
  7013. fluid.log.apply(null, ["ASSERTION FAILED: "].concat(fluid.makeArray(arguments)).concat(fluid.describeActivity()));
  7014. if (softFailure[0]) {
  7015. throw new Error(message)
  7016. } else {
  7017. message.fail()
  7018. }
  7019. };
  7020. fluid.pushSoftFailure = function (condition) {
  7021. if (typeof(condition) === "boolean") {
  7022. softFailure.unshift(condition)
  7023. } else {
  7024. if (condition === -1) {
  7025. softFailure.shift()
  7026. }
  7027. }
  7028. };
  7029. fluid.notrycatch = false;
  7030. fluid.tryCatch = function (tryfun, catchfun, finallyfun) {
  7031. finallyfun = finallyfun || fluid.identity;
  7032. if (fluid.notrycatch) {
  7033. var togo = tryfun();
  7034. finallyfun();
  7035. return togo
  7036. } else {
  7037. try {
  7038. return tryfun()
  7039. } catch (e) {
  7040. if (catchfun) {
  7041. catchfun(e)
  7042. } else {
  7043. throw(e)
  7044. }
  7045. }
  7046. finally {
  7047. finallyfun()
  7048. }
  7049. }
  7050. };
  7051. fluid.expect = function (name, members, target) {
  7052. fluid.transform(fluid.makeArray(members), function (key) {
  7053. if (typeof target[key] === "undefined") {
  7054. fluid.fail(name + " missing required parameter " + key)
  7055. }
  7056. })
  7057. };
  7058. var logging;
  7059. fluid.isLogging = function () {
  7060. return logging
  7061. };
  7062. fluid.setLogging = function (enabled) {
  7063. if (typeof enabled === "boolean") {
  7064. logging = enabled
  7065. } else {
  7066. logging = false
  7067. }
  7068. };
  7069. fluid.applyHostFunction = function (obj, func, args) {
  7070. if (func.apply) {
  7071. func.apply(obj, args)
  7072. } else {
  7073. var applier = Function.prototype.bind.call(func, obj);
  7074. applier.apply(obj, args)
  7075. }
  7076. };
  7077. fluid.log = function (message) {
  7078. if (logging) {
  7079. var arg0 = fluid.renderTimestamp(new Date()) + ": ";
  7080. var args = [arg0].concat(fluid.makeArray(arguments));
  7081. var str = args.join("");
  7082. if (typeof(console) !== "undefined") {
  7083. if (console.debug) {
  7084. fluid.applyHostFunction(console, console.debug, args)
  7085. } else {
  7086. if (typeof(console.log) === "function") {
  7087. fluid.applyHostFunction(console, console.log, args)
  7088. } else {
  7089. console.log(str)
  7090. }
  7091. }
  7092. } else {
  7093. if (typeof(YAHOO) !== "undefined") {
  7094. YAHOO.log(str)
  7095. } else {
  7096. if (typeof(opera) !== "undefined") {
  7097. opera.postError(str)
  7098. }
  7099. }
  7100. }
  7101. }
  7102. };
  7103. fluid.wrap = function (obj) {
  7104. return ((!obj || obj.jquery) ? obj : $(obj))
  7105. };
  7106. fluid.unwrap = function (obj) {
  7107. return obj && obj.jquery && obj.length === 1 ? obj[0] : obj
  7108. };
  7109. fluid.identity = function (arg) {
  7110. return arg
  7111. };
  7112. fluid.isValue = function (value) {
  7113. return value !== undefined && value !== null
  7114. };
  7115. fluid.isPrimitive = function (value) {
  7116. var valueType = typeof(value);
  7117. return !value || valueType === "string" || valueType === "boolean" || valueType === "number" || valueType === "function"
  7118. };
  7119. fluid.isDOMNode = function (obj) {
  7120. return obj && typeof(obj.nodeType) === "number"
  7121. };
  7122. fluid.isArrayable = function (totest) {
  7123. return totest && !fluid.isPrimitive(totest) && typeof(totest.length) === "number"
  7124. };
  7125. fluid.freshContainer = function (tocopy) {
  7126. return fluid.isArrayable(tocopy) ? [] : {}
  7127. };
  7128. fluid.copy = function (tocopy) {
  7129. if (fluid.isPrimitive(tocopy)) {
  7130. return tocopy
  7131. }
  7132. return $.extend(true, fluid.freshContainer(tocopy), tocopy)
  7133. };
  7134. fluid.makeArray = function (arg) {
  7135. if (arg === null || arg === undefined) {
  7136. return []
  7137. } else {
  7138. return $.makeArray(arg)
  7139. }
  7140. };
  7141. function transformInternal(source, togo, key, args) {
  7142. var transit = source[key];
  7143. for (var j = 0; j < args.length - 1; ++j) {
  7144. transit = args[j + 1](transit, key)
  7145. }
  7146. togo[key] = transit
  7147. }
  7148. fluid.transform = function (source) {
  7149. var togo = fluid.freshContainer(source);
  7150. if (fluid.isArrayable(source)) {
  7151. for (var i = 0; i < source.length; ++i) {
  7152. transformInternal(source, togo, i, arguments)
  7153. }
  7154. } else {
  7155. for (var key in source) {
  7156. transformInternal(source, togo, key, arguments)
  7157. }
  7158. }
  7159. return togo
  7160. };
  7161. fluid.each = function (source, func) {
  7162. if (fluid.isArrayable(source)) {
  7163. for (var i = 0; i < source.length; ++i) {
  7164. func(source[i], i)
  7165. }
  7166. } else {
  7167. for (var key in source) {
  7168. func(source[key], key)
  7169. }
  7170. }
  7171. };
  7172. fluid.find = function (source, func, deflt) {
  7173. var disp;
  7174. if (fluid.isArrayable(source)) {
  7175. for (var i = 0; i < source.length; ++i) {
  7176. disp = func(source[i], i);
  7177. if (disp !== undefined) {
  7178. return disp
  7179. }
  7180. }
  7181. } else {
  7182. for (var key in source) {
  7183. disp = func(source[key], key);
  7184. if (disp !== undefined) {
  7185. return disp
  7186. }
  7187. }
  7188. }
  7189. return deflt
  7190. };
  7191. fluid.accumulate = function (list, fn, arg) {
  7192. for (var i = 0; i < list.length; ++i) {
  7193. arg = fn(list[i], arg, i)
  7194. }
  7195. return arg
  7196. };
  7197. fluid.remove_if = function (source, fn) {
  7198. if (fluid.isArrayable(source)) {
  7199. for (var i = 0; i < source.length; ++i) {
  7200. if (fn(source[i], i)) {
  7201. source.splice(i, 1);
  7202. --i
  7203. }
  7204. }
  7205. } else {
  7206. for (var key in source) {
  7207. if (fn(source[key], key)) {
  7208. delete source[key]
  7209. }
  7210. }
  7211. }
  7212. return source
  7213. };
  7214. fluid.filterKeys = function (toFilter, keys, exclude) {
  7215. return fluid.remove_if($.extend({}, toFilter), function (value, key) {
  7216. return exclude^($.inArray(key, keys) === -1)
  7217. })
  7218. };
  7219. fluid.censorKeys = function (toCensor, keys) {
  7220. return fluid.filterKeys(toCensor, keys, true)
  7221. };
  7222. fluid.keys = function (obj) {
  7223. var togo = [];
  7224. fluid.each(obj, function (value, key) {
  7225. togo.push(key)
  7226. });
  7227. return togo
  7228. };
  7229. fluid.contains = function (obj, value) {
  7230. return obj ? fluid.find(obj, function (thisValue, key) {
  7231. if (value === thisValue) {
  7232. return true
  7233. }
  7234. }) : undefined
  7235. };
  7236. fluid.keyForValue = function (obj, value) {
  7237. return fluid.find(obj, function (thisValue, key) {
  7238. if (value === thisValue) {
  7239. return key
  7240. }
  7241. })
  7242. };
  7243. fluid.findKeyInObject = fluid.keyForValue;
  7244. fluid.arrayToHash = function (array) {
  7245. var togo = {};
  7246. fluid.each(array, function (el) {
  7247. togo[el] = true
  7248. });
  7249. return togo
  7250. };
  7251. fluid.clear = function (target) {
  7252. if (fluid.isArrayable(target)) {
  7253. target.length = 0
  7254. } else {
  7255. for (var i in target) {
  7256. delete target[i]
  7257. }
  7258. }
  7259. };
  7260. fluid.model = {};
  7261. fluid.VALUE = {
  7262. type : "fluid.marker",
  7263. value : "VALUE"
  7264. };
  7265. fluid.NO_VALUE = {
  7266. type : "fluid.marker",
  7267. value : "NO_VALUE"
  7268. };
  7269. fluid.EXPAND = {
  7270. type : "fluid.marker",
  7271. value : "EXPAND"
  7272. };
  7273. fluid.EXPAND_NOW = {
  7274. type : "fluid.marker",
  7275. value : "EXPAND_NOW"
  7276. };
  7277. fluid.isMarker = function (totest, type) {
  7278. if (!totest || typeof(totest) !== "object" || totest.type !== "fluid.marker") {
  7279. return false
  7280. }
  7281. if (!type) {
  7282. return true
  7283. }
  7284. return totest === type
  7285. };
  7286. fluid.model.copyModel = function (target, source) {
  7287. fluid.clear(target);
  7288. $.extend(true, target, source)
  7289. };
  7290. fluid.model.parseEL = function (EL) {
  7291. return EL === "" ? [] : String(EL).split(".")
  7292. };
  7293. fluid.model.composePath = function (prefix, suffix) {
  7294. return prefix === "" ? suffix : (suffix === "" ? prefix : prefix + "." + suffix)
  7295. };
  7296. fluid.model.composeSegments = function () {
  7297. return $.makeArray(arguments).join(".")
  7298. };
  7299. fluid.path = fluid.model.composeSegments;
  7300. fluid.composePath = fluid.model.composePath;
  7301. fluid.model.environmentStrategy = function (initEnvironment) {
  7302. return {
  7303. init : function () {
  7304. var environment = initEnvironment;
  7305. return function (root, segment, index) {
  7306. var togo;
  7307. if (environment && environment[segment]) {
  7308. togo = environment[segment]
  7309. }
  7310. environment = null;
  7311. return togo
  7312. }
  7313. }
  7314. }
  7315. };
  7316. fluid.model.defaultCreatorStrategy = function (root, segment) {
  7317. if (root[segment] === undefined) {
  7318. root[segment] = {};
  7319. return root[segment]
  7320. }
  7321. };
  7322. fluid.model.defaultFetchStrategy = function (root, segment) {
  7323. return segment === "" ? root : root[segment]
  7324. };
  7325. fluid.model.funcResolverStrategy = function (root, segment) {
  7326. if (root.resolvePathSegment) {
  7327. return root.resolvePathSegment(segment)
  7328. }
  7329. };
  7330. fluid.model.applyStrategy = function (strategy, root, segment, index) {
  7331. if (typeof(strategy) === "function") {
  7332. return strategy(root, segment, index)
  7333. } else {
  7334. if (strategy && strategy.next) {
  7335. return strategy.next(root, segment, index)
  7336. }
  7337. }
  7338. };
  7339. fluid.model.initStrategy = function (baseStrategy, index, oldStrategies) {
  7340. return baseStrategy.init ? baseStrategy.init(oldStrategies ? oldStrategies[index] : undefined) : baseStrategy
  7341. };
  7342. fluid.model.makeTrundler = function (root, config, oldStrategies) {
  7343. var that = {
  7344. root : root,
  7345. strategies : fluid.isArrayable(config) ? config : fluid.transform(config.strategies, function (strategy, index) {
  7346. return fluid.model.initStrategy(strategy, index, oldStrategies)
  7347. })
  7348. };
  7349. that.trundle = function (EL, uncess) {
  7350. uncess = uncess || 0;
  7351. var newThat = fluid.model.makeTrundler(that.root, config, that.strategies);
  7352. newThat.segs = fluid.model.parseEL(EL);
  7353. newThat.index = 0;
  7354. newThat.step(newThat.segs.length - uncess);
  7355. return newThat
  7356. };
  7357. that.next = function () {
  7358. if (!that.root) {
  7359. return
  7360. }
  7361. var accepted;
  7362. for (var i = 0; i < that.strategies.length; ++i) {
  7363. var value = fluid.model.applyStrategy(that.strategies[i], that.root, that.segs[that.index], that.index);
  7364. if (accepted === undefined) {
  7365. accepted = value
  7366. }
  7367. }
  7368. if (accepted === fluid.NO_VALUE) {
  7369. accepted = undefined
  7370. }
  7371. that.root = accepted;
  7372. ++that.index
  7373. };
  7374. that.step = function (limit) {
  7375. for (var i = 0; i < limit; ++i) {
  7376. that.next()
  7377. }
  7378. that.last = that.segs[that.index]
  7379. };
  7380. return that
  7381. };
  7382. fluid.model.defaultSetConfig = {
  7383. strategies : [fluid.model.funcResolverStrategy, fluid.model.defaultFetchStrategy, fluid.model.defaultCreatorStrategy]
  7384. };
  7385. fluid.model.trundleImpl = function (trundler, EL, config, uncess) {
  7386. if (typeof(EL) === "string") {
  7387. trundler = trundler.trundle(EL, uncess)
  7388. } else {
  7389. var key = EL.type || "default";
  7390. var resolver = config.resolvers[key];
  7391. if (!resolver) {
  7392. fluid.fail("Unable to find resolver of type " + key)
  7393. }
  7394. trundler = resolver(EL, trundler) || {};
  7395. if (EL.path && trundler.trundle && trundler.root !== undefined) {
  7396. trundler = fluid.model.trundleImpl(trundler, EL.path, config, uncess)
  7397. }
  7398. }
  7399. return trundler
  7400. };
  7401. fluid.model.trundle = function (root, EL, config, uncess) {
  7402. EL = EL || "";
  7403. config = config || fluid.model.defaultGetConfig;
  7404. var trundler = fluid.model.makeTrundler(root, config);
  7405. return fluid.model.trundleImpl(trundler, EL, config, uncess)
  7406. };
  7407. fluid.model.getPenultimate = function (root, EL, config) {
  7408. return fluid.model.trundle(root, EL, config, 1)
  7409. };
  7410. fluid.set = function (root, EL, newValue, config) {
  7411. config = config || fluid.model.defaultSetConfig;
  7412. var trundler = fluid.model.getPenultimate(root, EL, config);
  7413. trundler.root[trundler.last] = newValue
  7414. };
  7415. fluid.model.defaultGetConfig = {
  7416. strategies : [fluid.model.funcResolverStrategy, fluid.model.defaultFetchStrategy]
  7417. };
  7418. fluid.get = function (root, EL, config) {
  7419. return fluid.model.trundle(root, EL, config).root
  7420. };
  7421. fluid.model.setBeanValue = fluid.set;
  7422. fluid.model.getBeanValue = fluid.get;
  7423. fluid.getGlobalValue = function (path, env) {
  7424. if (path) {
  7425. env = env || fluid.environment;
  7426. var envFetcher = fluid.model.environmentStrategy(env);
  7427. return fluid.get(globalObject, path, {
  7428. strategies : [envFetcher].concat(fluid.model.defaultGetConfig.strategies)
  7429. })
  7430. }
  7431. };
  7432. fluid.invokeGlobalFunction = function (functionPath, args, environment) {
  7433. var func = fluid.getGlobalValue(functionPath, environment);
  7434. if (!func) {
  7435. fluid.fail("Error invoking global function: " + functionPath + " could not be located")
  7436. } else {
  7437. return func.apply(null, args)
  7438. }
  7439. };
  7440. fluid.registerGlobalFunction = function (functionPath, func, env) {
  7441. env = env || fluid.environment;
  7442. var envFetcher = fluid.model.environmentStrategy(env);
  7443. fluid.set(globalObject, functionPath, func, {
  7444. strategies : [envFetcher].concat(fluid.model.defaultSetConfig.strategies)
  7445. })
  7446. };
  7447. fluid.setGlobalValue = fluid.registerGlobalFunction;
  7448. fluid.registerNamespace = function (naimspace, env) {
  7449. env = env || fluid.environment;
  7450. var existing = fluid.getGlobalValue(naimspace, env);
  7451. if (!existing) {
  7452. existing = {};
  7453. fluid.setGlobalValue(naimspace, existing, env)
  7454. }
  7455. return existing
  7456. };
  7457. fluid.dumpEl = fluid.identity;
  7458. fluid.renderTimestamp = fluid.identity;
  7459. fluid.registerNamespace("fluid.event");
  7460. fluid.generateUniquePrefix = function () {
  7461. return (Math.floor(Math.random() * 1000000000000)).toString(36) + "-"
  7462. };
  7463. var fluid_prefix = fluid.generateUniquePrefix();
  7464. var fluid_guid = 1;
  7465. fluid.allocateGuid = function () {
  7466. return fluid_prefix + (fluid_guid++)
  7467. };
  7468. fluid.event.identifyListener = function (listener) {
  7469. if (typeof(listener) === "string") {
  7470. return listener
  7471. }
  7472. if (!listener.$$guid) {
  7473. listener.$$guid = fluid.allocateGuid()
  7474. }
  7475. return listener.$$guid
  7476. };
  7477. fluid.event.mapPriority = function (priority, count) {
  7478. return (priority === null || priority === undefined ? -count : (priority === "last" ? -Number.MAX_VALUE : (priority === "first" ? Number.MAX_VALUE : priority)))
  7479. };
  7480. fluid.event.listenerComparator = function (recA, recB) {
  7481. return recB.priority - recA.priority
  7482. };
  7483. fluid.event.sortListeners = function (listeners) {
  7484. var togo = [];
  7485. fluid.each(listeners, function (listener) {
  7486. togo.push(listener)
  7487. });
  7488. return togo.sort(fluid.event.listenerComparator)
  7489. };
  7490. fluid.event.getEventFirer = function (unicast, preventable) {
  7491. var listeners = {};
  7492. var sortedListeners = [];
  7493. function fireToListeners(listeners, args, wrapper) {
  7494. for (var i in listeners) {
  7495. var lisrec = listeners[i];
  7496. var listener = lisrec.listener;
  7497. if (typeof(listener) === "string") {
  7498. var listenerFunc = fluid.getGlobalValue(listener);
  7499. if (!listenerFunc) {
  7500. fluid.fail("Unable to look up name " + listener + " as a global function")
  7501. } else {
  7502. listener = lisrec.listener = listenerFunc
  7503. }
  7504. }
  7505. if (lisrec.predicate && !lisrec.predicate(listener, args)) {
  7506. continue
  7507. }
  7508. var value = fluid.tryCatch(function () {
  7509. var ret = (wrapper ? wrapper(listener) : listener).apply(null, args);
  7510. if (preventable && ret === false) {
  7511. return false
  7512. }
  7513. if (unicast) {
  7514. return ret
  7515. }
  7516. }, function (e) {
  7517. fluid.log("FireEvent received exception " + e.message + " e " + e + " firing to listener " + i);
  7518. throw(e)
  7519. });
  7520. if (value !== undefined) {
  7521. return value
  7522. }
  7523. }
  7524. }
  7525. return {
  7526. addListener : function (listener, namespace, predicate, priority) {
  7527. if (!listener) {
  7528. return
  7529. }
  7530. if (unicast) {
  7531. namespace = "unicast"
  7532. }
  7533. if (!namespace) {
  7534. namespace = fluid.event.identifyListener(listener)
  7535. }
  7536. listeners[namespace] = {
  7537. listener : listener,
  7538. predicate : predicate,
  7539. priority : fluid.event.mapPriority(priority, sortedListeners.length)
  7540. };
  7541. sortedListeners = fluid.event.sortListeners(listeners)
  7542. },
  7543. removeListener : function (listener) {
  7544. if (typeof(listener) === "string") {
  7545. delete listeners[listener]
  7546. } else {
  7547. if (listener.$$guid) {
  7548. delete listeners[listener.$$guid]
  7549. }
  7550. }
  7551. sortedListeners = fluid.event.sortListeners(listeners)
  7552. },
  7553. fireToListeners : function (listeners, args, wrapper) {
  7554. return fireToListeners(listeners, args, wrapper)
  7555. },
  7556. fire : function () {
  7557. return fireToListeners(sortedListeners, arguments)
  7558. }
  7559. }
  7560. };
  7561. fluid.event.addListenerToFirer = function (firer, value, namespace) {
  7562. if (fluid.isArrayable(value)) {
  7563. for (var i = 0; i < value.length; ++i) {
  7564. fluid.event.addListenerToFirer(firer, value[i], namespace)
  7565. }
  7566. } else {
  7567. if (typeof(value) === "function" || typeof(value) === "string") {
  7568. firer.addListener(value, namespace)
  7569. } else {
  7570. if (value && typeof(value) === "object") {
  7571. firer.addListener(value.listener, namespace || value.namespace, value.predicate, value.priority)
  7572. }
  7573. }
  7574. }
  7575. };
  7576. fluid.mergeListeners = function (that, events, listeners) {
  7577. fluid.each(listeners, function (value, key) {
  7578. var firer,
  7579. namespace;
  7580. if (key.charAt(0) === "{") {
  7581. if (!fluid.expandOptions) {
  7582. fluid.fail("fluid.expandOptions could not be loaded - please include FluidIoC.js in order to operate IoC-driven event with descriptor " + key)
  7583. }
  7584. firer = fluid.expandOptions(key, that)
  7585. } else {
  7586. var keydot = key.indexOf(".");
  7587. if (keydot !== -1) {
  7588. namespace = key.substring(keydot + 1);
  7589. key = key.substring(0, keydot)
  7590. }
  7591. if (!events[key]) {
  7592. fluid.fail("Listener registered for event " + key + " which is not defined for this component");
  7593. events[key] = fluid.event.getEventFirer()
  7594. }
  7595. firer = events[key]
  7596. }
  7597. fluid.event.addListenerToFirer(firer, value, namespace)
  7598. })
  7599. };
  7600. function initEvents(that, events, pass) {
  7601. fluid.each(events, function (eventSpec, eventKey) {
  7602. var isIoCEvent = eventSpec && (typeof(eventSpec) !== "string" || eventSpec.charAt(0) === "{");
  7603. var event;
  7604. if (isIoCEvent && pass === "IoC") {
  7605. if (!fluid.event.resolveEvent) {
  7606. fluid.fail("fluid.event.resolveEvent could not be loaded - please include FluidIoC.js in order to operate IoC-driven event with descriptor ", eventSpec)
  7607. } else {
  7608. event = fluid.event.resolveEvent(that, eventKey, eventSpec)
  7609. }
  7610. } else {
  7611. if (pass === "flat") {
  7612. event = fluid.event.getEventFirer(eventSpec === "unicast", eventSpec === "preventable")
  7613. }
  7614. }
  7615. if (event) {
  7616. that.events[eventKey] = event
  7617. }
  7618. })
  7619. }
  7620. fluid.instantiateFirers = function (that, options) {
  7621. that.events = {};
  7622. initEvents(that, options.events, "flat");
  7623. initEvents(that, options.events, "IoC");
  7624. var listeners = fluid.expandOptions ? fluid.expandOptions(options.listeners, that) : options.listeners;
  7625. fluid.mergeListeners(that, that.events, listeners)
  7626. };
  7627. fluid.mergeListenersPolicy = function (target, source) {
  7628. var togo = target || {};
  7629. fluid.each(source, function (listeners, key) {
  7630. togo[key] = fluid.makeArray(source[key]).concat(fluid.makeArray(listeners))
  7631. });
  7632. return togo
  7633. };
  7634. var defaultsStore = {};
  7635. var resolveGradesImpl = function (gs, gradeNames) {
  7636. gradeNames = fluid.makeArray(gradeNames);
  7637. fluid.each(gradeNames, function (gradeName) {
  7638. var options = fluid.rawDefaults(gradeName) || {};
  7639. gs.gradeHash[gradeName] = true;
  7640. gs.gradeChain.push(gradeName);
  7641. gs.optionsChain.push(options);
  7642. fluid.each(options.gradeNames, function (parent) {
  7643. if (!gs.gradeHash[parent]) {
  7644. resolveGradesImpl(gs, parent)
  7645. }
  7646. })
  7647. });
  7648. return gs
  7649. };
  7650. fluid.resolveGradeStructure = function (gradeNames) {
  7651. var gradeStruct = {
  7652. gradeChain : [],
  7653. gradeHash : {},
  7654. optionsChain : []
  7655. };
  7656. return resolveGradesImpl(gradeStruct, gradeNames)
  7657. };
  7658. fluid.lifecycleFunctions = {
  7659. preInitFunction : true,
  7660. postInitFunction : true,
  7661. finalInitFunction : true
  7662. };
  7663. fluid.mergeLifecycleFunction = function (target, source) {
  7664. fluid.event.addListenerToFirer(target, source);
  7665. return target
  7666. };
  7667. fluid.rootMergePolicy = fluid.transform(fluid.lifecycleFunctions, function () {
  7668. return fluid.mergeLifecycleFunction
  7669. });
  7670. fluid.makeLifecycleFirers = function () {
  7671. return fluid.transform(fluid.lifecycleFunctions, function () {
  7672. return fluid.event.getEventFirer()
  7673. })
  7674. };
  7675. fluid.resolveGrade = function (defaults, gradeNames) {
  7676. var mergeArgs = [defaults];
  7677. if (gradeNames) {
  7678. var gradeStruct = fluid.resolveGradeStructure(gradeNames);
  7679. mergeArgs = gradeStruct.optionsChain.reverse().concat(mergeArgs).concat({
  7680. gradeNames : gradeStruct.gradeChain
  7681. })
  7682. }
  7683. mergeArgs = [fluid.rootMergePolicy, fluid.makeLifecycleFirers()].concat(mergeArgs);
  7684. var mergedDefaults = fluid.merge.apply(null, mergeArgs);
  7685. return mergedDefaults
  7686. };
  7687. fluid.resolveGradedOptions = function (componentName) {
  7688. var defaults = fluid.rawDefaults(componentName);
  7689. if (!defaults) {
  7690. return defaults
  7691. } else {
  7692. return fluid.resolveGrade(defaults, defaults.gradeNames)
  7693. }
  7694. };
  7695. fluid.rawDefaults = function (componentName, options) {
  7696. if (options === undefined) {
  7697. return defaultsStore[componentName]
  7698. } else {
  7699. defaultsStore[componentName] = options
  7700. }
  7701. };
  7702. fluid.hasGrade = function (options, gradeName) {
  7703. return !options || !options.gradeNames ? false : fluid.contains(options.gradeNames, gradeName)
  7704. };
  7705. fluid.defaults = function () {
  7706. var offset = 0;
  7707. if (typeof arguments[0] === "boolean") {
  7708. offset = 1
  7709. }
  7710. var componentName = (offset === 0 ? "" : "*.global-") + arguments[offset];
  7711. var options = arguments[offset + 1];
  7712. if (options === undefined) {
  7713. return fluid.resolveGradedOptions(componentName)
  7714. } else {
  7715. if (options && options.options) {
  7716. fluid.fail('Probable error in options structure with option named "options" - perhaps you meant to write these options at top level in fluid.defaults?')
  7717. }
  7718. fluid.rawDefaults(componentName, options);
  7719. if (fluid.hasGrade(options, "autoInit")) {
  7720. fluid.makeComponent(componentName, fluid.resolveGradedOptions(componentName))
  7721. }
  7722. }
  7723. };
  7724. fluid.makeComponent = function (componentName, options) {
  7725. if (!options.initFunction || !options.gradeNames) {
  7726. fluid.fail("Cannot autoInit component " + componentName + " which does not have an initFunction and gradeName defined")
  7727. }
  7728. var creator = function () {
  7729. return fluid.initComponent(componentName, arguments)
  7730. };
  7731. var existing = fluid.getGlobalValue(componentName);
  7732. if (existing) {
  7733. $.extend(creator, existing)
  7734. }
  7735. fluid.setGlobalValue(componentName, creator)
  7736. };
  7737. fluid.makeComponents = function (components, env) {
  7738. fluid.each(components, function (value, key) {
  7739. var options = {
  7740. gradeNames : fluid.makeArray(value).concat(["autoInit"])
  7741. };
  7742. fluid.defaults(key, options)
  7743. })
  7744. };
  7745. fluid.defaults("fluid.littleComponent", {
  7746. initFunction : "fluid.initLittleComponent",
  7747. argumentMap : {
  7748. options : 0
  7749. }
  7750. });
  7751. fluid.defaults("fluid.eventedComponent", {
  7752. gradeNames : ["fluid.littleComponent"],
  7753. mergePolicy : {
  7754. listeners : "fluid.mergeListenersPolicy"
  7755. }
  7756. });
  7757. fluid.preInitModelComponent = function (that) {
  7758. that.model = that.options.model || {};
  7759. that.applier = that.options.applier || fluid.makeChangeApplier(that.model, that.options.changeApplierOptions)
  7760. };
  7761. fluid.defaults("fluid.modelComponent", {
  7762. gradeNames : ["fluid.littleComponent"],
  7763. preInitFunction : {
  7764. namespace : "preInitModelComponent",
  7765. listener : "fluid.preInitModelComponent"
  7766. },
  7767. mergePolicy : {
  7768. model : "preserve",
  7769. applier : "nomerge"
  7770. }
  7771. });
  7772. fluid.defaults("fluid.viewComponent", {
  7773. gradeNames : ["fluid.littleComponent", "fluid.modelComponent", "fluid.eventedComponent"],
  7774. initFunction : "fluid.initView",
  7775. argumentMap : {
  7776. container : 0,
  7777. options : 1
  7778. }
  7779. });
  7780. fluid.guardCircularity = function (seenIds, source, message1, message2) {
  7781. if (source && source.id) {
  7782. if (!seenIds[source.id]) {
  7783. seenIds[source.id] = source
  7784. } else {
  7785. if (seenIds[source.id] === source) {
  7786. fluid.fail("Circularity in options " + message1 + " - component with typename " + source.typeName + " and id " + source.id + " has already been seen" + message2)
  7787. }
  7788. }
  7789. }
  7790. };
  7791. fluid.mergePolicyIs = function (policy, test) {
  7792. return typeof(policy) === "string" && $.inArray(test, policy.split(/\s*,\s*/)) !== -1
  7793. };
  7794. function mergeImpl(policy, basePath, target, source, thisPolicy, rec) {
  7795. if (typeof(thisPolicy) === "function") {
  7796. thisPolicy.call(null, target, source);
  7797. return target
  7798. }
  7799. if (fluid.mergePolicyIs(thisPolicy, "replace")) {
  7800. fluid.clear(target)
  7801. }
  7802. fluid.guardCircularity(rec.seenIds, source, "merging", " when evaluating path " + basePath + ' - please protect components from merging using the "nomerge" merge policy');
  7803. for (var name in source) {
  7804. var path = (basePath ? basePath + "." : "") + name;
  7805. var newPolicy = policy && typeof(policy) !== "string" ? policy[path] : policy;
  7806. var thisTarget = target[name];
  7807. var thisSource = source[name];
  7808. var primitiveTarget = fluid.isPrimitive(thisTarget);
  7809. if (thisSource !== undefined) {
  7810. if (thisSource !== null && typeof(thisSource) === "object" && !fluid.isDOMNode(thisSource) && !thisSource.jquery && thisSource !== fluid.VALUE && !fluid.mergePolicyIs(newPolicy, "preserve") && !fluid.mergePolicyIs(newPolicy, "nomerge") && !fluid.mergePolicyIs(newPolicy, "noexpand")) {
  7811. if (primitiveTarget) {
  7812. target[name] = thisTarget = fluid.freshContainer(thisSource)
  7813. }
  7814. mergeImpl(policy, path, thisTarget, thisSource, newPolicy, rec)
  7815. } else {
  7816. if (typeof(newPolicy) === "function") {
  7817. target[name] = newPolicy.call(null, thisTarget, thisSource, name)
  7818. } else {
  7819. if (!fluid.isValue(thisTarget) || !fluid.mergePolicyIs(newPolicy, "reverse")) {
  7820. target[name] = fluid.isValue(thisTarget) && fluid.mergePolicyIs(newPolicy, "preserve") ? fluid.model.mergeModel(thisTarget, thisSource) : thisSource
  7821. }
  7822. }
  7823. }
  7824. }
  7825. }
  7826. return target
  7827. }
  7828. fluid.merge = function (policy, target) {
  7829. var path = "";
  7830. for (var i = 2; i < arguments.length; ++i) {
  7831. var source = arguments[i];
  7832. if (source !== null && source !== undefined) {
  7833. mergeImpl(policy, path, target, source, policy ? policy[""] : null, {
  7834. seenIds : {}
  7835. })
  7836. }
  7837. }
  7838. if (policy && typeof(policy) !== "string") {
  7839. for (var key in policy) {
  7840. var elrh = policy[key];
  7841. if (typeof(elrh) === "string" && elrh !== "replace" && elrh !== "preserve") {
  7842. var oldValue = fluid.get(target, key);
  7843. if (oldValue === null || oldValue === undefined) {
  7844. var value = fluid.get(target, elrh);
  7845. fluid.set(target, key, value)
  7846. }
  7847. }
  7848. }
  7849. }
  7850. return target
  7851. };
  7852. fluid.transformOptions = function (mergeArgs, transRec) {
  7853. fluid.expect("Options transformation record", ["transformer", "config"], transRec);
  7854. var transFunc = fluid.getGlobalValue(transRec.transformer);
  7855. var togo = fluid.transform(mergeArgs, function (value, key) {
  7856. return key === 0 ? value : transFunc.call(null, value, transRec.config)
  7857. });
  7858. return togo
  7859. };
  7860. fluid.lastTransformationRecord = function (extraArgs) {
  7861. for (var i = extraArgs.length - 1; i >= 0; --i) {
  7862. if (extraArgs[i] && extraArgs[i].transformOptions) {
  7863. return extraArgs[i].transformOptions
  7864. }
  7865. }
  7866. };
  7867. fluid.mergeComponentOptions = function (that, componentName, userOptions, localOptions) {
  7868. var defaults = fluid.defaults(componentName);
  7869. var mergePolicy = $.extend({}, fluid.rootMergePolicy, defaults ? defaults.mergePolicy : {});
  7870. var defaultGrades = defaults && defaults.gradeNames;
  7871. var mergeArgs;
  7872. if (!defaultGrades) {
  7873. defaults = fluid.censorKeys(defaults, fluid.keys(fluid.lifecycleFunctions));
  7874. mergeArgs = [mergePolicy, localOptions]
  7875. } else {
  7876. mergeArgs = [mergePolicy]
  7877. }
  7878. var extraArgs;
  7879. if (fluid.expandComponentOptions) {
  7880. extraArgs = fluid.expandComponentOptions(defaults, userOptions, that)
  7881. } else {
  7882. extraArgs = [defaults, userOptions]
  7883. }
  7884. var transRec = fluid.lastTransformationRecord(extraArgs);
  7885. if (transRec) {
  7886. extraArgs = fluid.transformOptions(extraArgs, transRec)
  7887. }
  7888. mergeArgs = mergeArgs.concat(extraArgs);
  7889. that.options = fluid.merge.apply(null, mergeArgs)
  7890. };
  7891. fluid.COMPONENT_OPTIONS = {
  7892. type : "fluid.marker",
  7893. value : "COMPONENT_OPTIONS"
  7894. };
  7895. fluid.emptySubcomponent = function (options) {
  7896. var that = {};
  7897. options = $.makeArray(options);
  7898. var empty = function () {};
  7899. for (var i = 0; i < options.length; ++i) {
  7900. that[options[i]] = empty
  7901. }
  7902. return that
  7903. };
  7904. fluid.computeNickName = function (typeName) {
  7905. var segs = fluid.model.parseEL(typeName);
  7906. return segs[segs.length - 1]
  7907. };
  7908. fluid.typeTag = function (name) {
  7909. return name ? {
  7910. typeName : name,
  7911. id : fluid.allocateGuid()
  7912. }
  7913. : null
  7914. };
  7915. fluid.typeFount = function (options) {
  7916. var that = fluid.initLittleComponent("fluid.typeFount", options);
  7917. return fluid.typeTag(that.options.targetTypeName)
  7918. };
  7919. fluid.initLittleComponent = function (name, options, localOptions) {
  7920. var that = fluid.typeTag(name);
  7921. that.nickName = options && options.nickName ? options.nickName : fluid.computeNickName(that.typeName);
  7922. localOptions = localOptions || {
  7923. gradeNames : "fluid.littleComponent"
  7924. };
  7925. localOptions = fluid.resolveGrade({}, localOptions.gradeNames);
  7926. fluid.mergeComponentOptions(that, name, options, localOptions);
  7927. that.options.preInitFunction.fire(that);
  7928. if (fluid.hasGrade(that.options, "fluid.eventedComponent")) {
  7929. fluid.instantiateFirers(that, that.options)
  7930. }
  7931. if (!fluid.hasGrade(that.options, "autoInit")) {
  7932. fluid.clearLifecycleFunctions(that.options)
  7933. }
  7934. return that
  7935. };
  7936. fluid.clearLifecycleFunctions = function (options) {
  7937. fluid.each(fluid.lifecycleFunctions, function (value, key) {
  7938. delete options[key]
  7939. });
  7940. delete options.initFunction
  7941. };
  7942. fluid.diagnoseFailedView = function (componentName, that, options, args) {
  7943. if (!that && fluid.hasGrade(options, "fluid.viewComponent")) {
  7944. var container = fluid.wrap(args[1]);
  7945. var message1 = "Instantiation of autoInit component with type " + componentName + " failed, since ";
  7946. if (container.length === 0) {
  7947. fluid.fail(message1 + 'selector "', args[1], '" did not match any markup in the document')
  7948. } else {
  7949. fluid.fail(message1 + " component creator function did not return a value")
  7950. }
  7951. }
  7952. };
  7953. fluid.initComponent = function (componentName, initArgs) {
  7954. var options = fluid.defaults(componentName);
  7955. if (!options.gradeNames) {
  7956. fluid.fail("Cannot initialise component " + componentName + " which has no gradeName registered")
  7957. }
  7958. var args = [componentName].concat(fluid.makeArray(initArgs));
  7959. var that = fluid.invokeGlobalFunction(options.initFunction, args);
  7960. fluid.diagnoseFailedView(componentName, that, options, args);
  7961. that.options.postInitFunction.fire(that);
  7962. if (fluid.initDependents) {
  7963. fluid.initDependents(that)
  7964. }
  7965. that.options.finalInitFunction.fire(that);
  7966. fluid.clearLifecycleFunctions(that.options);
  7967. return that.options.returnedPath ? fluid.get(that, that.options.returnedPath) : that
  7968. };
  7969. fluid.initSubcomponentImpl = function (that, entry, args) {
  7970. var togo;
  7971. if (typeof(entry) !== "function") {
  7972. var entryType = typeof(entry) === "string" ? entry : entry.type;
  7973. var globDef = fluid.defaults(true, entryType);
  7974. fluid.merge("reverse", that.options, globDef);
  7975. togo = entryType === "fluid.emptySubcomponent" ? fluid.emptySubcomponent(entry.options) : fluid.invokeGlobalFunction(entryType, args)
  7976. } else {
  7977. togo = entry.apply(null, args)
  7978. }
  7979. var returnedOptions = togo ? togo.returnedOptions : null;
  7980. if (returnedOptions) {
  7981. fluid.merge(that.options.mergePolicy, that.options, returnedOptions);
  7982. if (returnedOptions.listeners) {
  7983. fluid.mergeListeners(that, that.events, returnedOptions.listeners)
  7984. }
  7985. }
  7986. return togo
  7987. };
  7988. fluid.initSubcomponents = function (that, className, args) {
  7989. var entry = that.options[className];
  7990. if (!entry) {
  7991. return
  7992. }
  7993. var entries = $.makeArray(entry);
  7994. var optindex = -1;
  7995. var togo = [];
  7996. args = $.makeArray(args);
  7997. for (var i = 0; i < args.length; ++i) {
  7998. if (args[i] === fluid.COMPONENT_OPTIONS) {
  7999. optindex = i
  8000. }
  8001. }
  8002. for (i = 0; i < entries.length; ++i) {
  8003. entry = entries[i];
  8004. if (optindex !== -1) {
  8005. args[optindex] = entry.options
  8006. }
  8007. togo[i] = fluid.initSubcomponentImpl(that, entry, args)
  8008. }
  8009. return togo
  8010. };
  8011. fluid.initSubcomponent = function (that, className, args) {
  8012. return fluid.initSubcomponents(that, className, args)[0]
  8013. };
  8014. fluid.checkTryCatchParameter = function () {
  8015. var location = window.location || {
  8016. search : "",
  8017. protocol : "file:"
  8018. };
  8019. var GETParams = location.search.slice(1).split("&");
  8020. return fluid.contains(GETParams, "notrycatch")
  8021. };
  8022. fluid.notrycatch = fluid.checkTryCatchParameter();
  8023. fluid.container = function (containerSpec, fallible) {
  8024. var container = fluid.wrap(containerSpec);
  8025. if (fallible && (!container || container.length === 0)) {
  8026. return null
  8027. }
  8028. if (!container || !container.jquery || container.length !== 1) {
  8029. if (typeof(containerSpec) !== "string") {
  8030. containerSpec = container.selector
  8031. }
  8032. var count = container.length !== undefined ? container.length : 0;
  8033. fluid.fail((count > 1 ? "More than one (" + count + ") container elements were" : "No container element was") + " found for selector " + containerSpec)
  8034. }
  8035. if (!fluid.isDOMNode(container[0])) {
  8036. fluid.fail("fluid.container was supplied a non-jQueryable element")
  8037. }
  8038. return container
  8039. };
  8040. fluid.createDomBinder = function (container, selectors) {
  8041. var cache = {},
  8042. that = {};
  8043. function cacheKey(name, thisContainer) {
  8044. return fluid.allocateSimpleId(thisContainer) + "-" + name
  8045. }
  8046. function record(name, thisContainer, result) {
  8047. cache[cacheKey(name, thisContainer)] = result
  8048. }
  8049. that.locate = function (name, localContainer) {
  8050. var selector,
  8051. thisContainer,
  8052. togo;
  8053. selector = selectors[name];
  8054. thisContainer = localContainer ? localContainer : container;
  8055. if (!thisContainer) {
  8056. fluid.fail("DOM binder invoked for selector " + name + " without container")
  8057. }
  8058. if (!selector) {
  8059. return thisContainer
  8060. }
  8061. if (typeof(selector) === "function") {
  8062. togo = $(selector.call(null, fluid.unwrap(thisContainer)))
  8063. } else {
  8064. togo = $(selector, thisContainer)
  8065. }
  8066. if (togo.get(0) === document) {
  8067. togo = []
  8068. }
  8069. if (!togo.selector) {
  8070. togo.selector = selector;
  8071. togo.context = thisContainer
  8072. }
  8073. togo.selectorName = name;
  8074. record(name, thisContainer, togo);
  8075. return togo
  8076. };
  8077. that.fastLocate = function (name, localContainer) {
  8078. var thisContainer = localContainer ? localContainer : container;
  8079. var key = cacheKey(name, thisContainer);
  8080. var togo = cache[key];
  8081. return togo ? togo : that.locate(name, localContainer)
  8082. };
  8083. that.clear = function () {
  8084. cache = {}
  8085. };
  8086. that.refresh = function (names, localContainer) {
  8087. var thisContainer = localContainer ? localContainer : container;
  8088. if (typeof names === "string") {
  8089. names = [names]
  8090. }
  8091. if (thisContainer.length === undefined) {
  8092. thisContainer = [thisContainer]
  8093. }
  8094. for (var i = 0; i < names.length; ++i) {
  8095. for (var j = 0; j < thisContainer.length; ++j) {
  8096. that.locate(names[i], thisContainer[j])
  8097. }
  8098. }
  8099. };
  8100. that.resolvePathSegment = that.locate;
  8101. return that
  8102. };
  8103. fluid.expectFilledSelector = function (result, message) {
  8104. if (result && result.length === 0 && result.jquery) {
  8105. fluid.fail(message + ': selector "' + result.selector + '" with name ' + result.selectorName + " returned no results in context " + fluid.dumpEl(result.context))
  8106. }
  8107. };
  8108. fluid.initView = function (componentName, container, userOptions, localOptions) {
  8109. fluid.expectFilledSelector(container, 'Error instantiating component with name "' + componentName);
  8110. container = fluid.container(container, true);
  8111. if (!container) {
  8112. return null
  8113. }
  8114. var that = fluid.initLittleComponent(componentName, userOptions, localOptions || {
  8115. gradeNames : ["fluid.viewComponent"]
  8116. });
  8117. that.container = container;
  8118. fluid.initDomBinder(that);
  8119. return that
  8120. };
  8121. fluid.initDomBinder = function (that) {
  8122. that.dom = fluid.createDomBinder(that.container, that.options.selectors);
  8123. that.locate = that.dom.locate
  8124. };
  8125. fluid.findAncestor = function (element, test) {
  8126. element = fluid.unwrap(element);
  8127. while (element) {
  8128. if (test(element)) {
  8129. return element
  8130. }
  8131. element = element.parentNode
  8132. }
  8133. };
  8134. fluid.jById = function (id, dokkument) {
  8135. dokkument = dokkument && dokkument.nodeType === 9 ? dokkument : document;
  8136. var element = fluid.byId(id, dokkument);
  8137. var togo = element ? $(element) : [];
  8138. togo.selector = "#" + id;
  8139. togo.context = dokkument;
  8140. return togo
  8141. };
  8142. fluid.byId = function (id, dokkument) {
  8143. dokkument = dokkument && dokkument.nodeType === 9 ? dokkument : document;
  8144. var el = dokkument.getElementById(id);
  8145. if (el) {
  8146. if (el.id !== id) {
  8147. fluid.fail("Problem in document structure - picked up element " + fluid.dumpEl(el) + " for id " + id + " without this id - most likely the element has a name which conflicts with this id")
  8148. }
  8149. return el
  8150. } else {
  8151. return null
  8152. }
  8153. };
  8154. fluid.getId = function (element) {
  8155. return fluid.unwrap(element).id
  8156. };
  8157. fluid.allocateSimpleId = function (element) {
  8158. var simpleId = "fluid-id-" + fluid.allocateGuid();
  8159. if (!element) {
  8160. return simpleId
  8161. }
  8162. element = fluid.unwrap(element);
  8163. if (!element.id) {
  8164. element.id = simpleId
  8165. }
  8166. return element.id
  8167. };
  8168. fluid.stringToRegExp = function (str, flags) {
  8169. return new RegExp(str.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"), flags)
  8170. };
  8171. fluid.stringTemplate = function (template, values) {
  8172. var newString = template;
  8173. for (var key in values) {
  8174. var re = fluid.stringToRegExp("%" + key, "g");
  8175. newString = newString.replace(re, values[key])
  8176. }
  8177. return newString
  8178. };
  8179. fluid.messageResolver = function (options) {
  8180. var that = fluid.initLittleComponent("fluid.messageResolver", options);
  8181. that.messageBase = that.options.parseFunc(that.options.messageBase);
  8182. that.lookup = function (messagecodes) {
  8183. var resolved = fluid.messageResolver.resolveOne(that.messageBase, messagecodes);
  8184. if (resolved === undefined) {
  8185. return fluid.find(that.options.parents, function (parent) {
  8186. return parent.lookup(messagecodes)
  8187. })
  8188. } else {
  8189. return {
  8190. template : resolved,
  8191. resolveFunc : that.options.resolveFunc
  8192. }
  8193. }
  8194. };
  8195. that.resolve = function (messagecodes, args) {
  8196. if (!messagecodes) {
  8197. return "[No messagecodes provided]"
  8198. }
  8199. messagecodes = fluid.makeArray(messagecodes);
  8200. var looked = that.lookup(messagecodes);
  8201. return looked ? looked.resolveFunc(looked.template, args) : "[Message string for key " + messagecodes[0] + " not found]"
  8202. };
  8203. return that
  8204. };
  8205. fluid.defaults("fluid.messageResolver", {
  8206. mergePolicy : {
  8207. messageBase : "preserve"
  8208. },
  8209. resolveFunc : fluid.stringTemplate,
  8210. parseFunc : fluid.identity,
  8211. messageBase : {},
  8212. parents : []
  8213. });
  8214. fluid.messageResolver.resolveOne = function (messageBase, messagecodes) {
  8215. for (var i = 0; i < messagecodes.length; ++i) {
  8216. var code = messagecodes[i];
  8217. var message = messageBase[code];
  8218. if (message !== undefined) {
  8219. return message
  8220. }
  8221. }
  8222. };
  8223. fluid.messageLocator = function (messageBase, resolveFunc) {
  8224. var resolver = fluid.messageResolver({
  8225. messageBase : messageBase,
  8226. resolveFunc : resolveFunc
  8227. });
  8228. return function (messagecodes, args) {
  8229. return resolver.resolve(messagecodes, args)
  8230. }
  8231. }
  8232. })(jQuery, fluid_1_4);
  8233. var fluid_1_4 = fluid_1_4 || {};
  8234. (function ($, fluid) {
  8235. var NAMESPACE_KEY = "fluid-scoped-data";
  8236. fluid.getScopedData = function (target, key) {
  8237. var data = $(target).data(NAMESPACE_KEY);
  8238. return data ? data[key] : undefined
  8239. };
  8240. fluid.setScopedData = function (target, key, value) {
  8241. $(target).each(function () {
  8242. var data = $.data(this, NAMESPACE_KEY) || {};
  8243. data[key] = value;
  8244. $.data(this, NAMESPACE_KEY, data)
  8245. })
  8246. };
  8247. var lastFocusedElement = null;
  8248. $(document).bind("focusin", function (event) {
  8249. lastFocusedElement = event.target
  8250. });
  8251. fluid.getLastFocusedElement = function () {
  8252. return lastFocusedElement
  8253. };
  8254. var ENABLEMENT_KEY = "enablement";
  8255. fluid.enabled = function (target, state) {
  8256. target = $(target);
  8257. if (state === undefined) {
  8258. return fluid.getScopedData(target, ENABLEMENT_KEY) !== false
  8259. } else {
  8260. $("*", target).add(target).each(function () {
  8261. if (fluid.getScopedData(this, ENABLEMENT_KEY) !== undefined) {
  8262. fluid.setScopedData(this, ENABLEMENT_KEY, state)
  8263. } else {
  8264. if (/select|textarea|input/i.test(this.nodeName)) {
  8265. $(this).prop("disabled", !state)
  8266. }
  8267. }
  8268. });
  8269. fluid.setScopedData(target, ENABLEMENT_KEY, state)
  8270. }
  8271. };
  8272. fluid.initEnablement = function (target) {
  8273. fluid.setScopedData(target, ENABLEMENT_KEY, true)
  8274. };
  8275. function applyOp(node, func) {
  8276. node = $(node);
  8277. node.trigger("fluid-" + func);
  8278. node[func]()
  8279. }
  8280. $.each(["focus", "blur"], function (i, name) {
  8281. fluid[name] = function (elem) {
  8282. applyOp(elem, name)
  8283. }
  8284. })
  8285. })(jQuery, fluid_1_4);
  8286. var fluid_1_4 = fluid_1_4 || {};
  8287. (function ($, fluid) {
  8288. fluid.dom = fluid.dom || {};
  8289. var getNextNode = function (iterator) {
  8290. if (iterator.node.firstChild) {
  8291. iterator.node = iterator.node.firstChild;
  8292. iterator.depth += 1;
  8293. return iterator
  8294. }
  8295. while (iterator.node) {
  8296. if (iterator.node.nextSibling) {
  8297. iterator.node = iterator.node.nextSibling;
  8298. return iterator
  8299. }
  8300. iterator.node = iterator.node.parentNode;
  8301. iterator.depth -= 1
  8302. }
  8303. return iterator
  8304. };
  8305. fluid.dom.iterateDom = function (node, acceptor, allNodes) {
  8306. var currentNode = {
  8307. node : node,
  8308. depth : 0
  8309. };
  8310. var prevNode = node;
  8311. var condition;
  8312. while (currentNode.node !== null && currentNode.depth >= 0 && currentNode.depth < fluid.dom.iterateDom.DOM_BAIL_DEPTH) {
  8313. condition = null;
  8314. if (currentNode.node.nodeType === 1 || allNodes) {
  8315. condition = acceptor(currentNode.node, currentNode.depth)
  8316. }
  8317. if (condition) {
  8318. if (condition === "delete") {
  8319. currentNode.node.parentNode.removeChild(currentNode.node);
  8320. currentNode.node = prevNode
  8321. } else {
  8322. if (condition === "stop") {
  8323. return currentNode.node
  8324. }
  8325. }
  8326. }
  8327. prevNode = currentNode.node;
  8328. currentNode = getNextNode(currentNode)
  8329. }
  8330. };
  8331. fluid.dom.iterateDom.DOM_BAIL_DEPTH = 256;
  8332. fluid.dom.isContainer = function (container, containee) {
  8333. for (; containee; containee = containee.parentNode) {
  8334. if (container === containee) {
  8335. return true
  8336. }
  8337. }
  8338. return false
  8339. };
  8340. fluid.dom.getElementText = function (element) {
  8341. var nodes = element.childNodes;
  8342. var text = "";
  8343. for (var i = 0; i < nodes.length; ++i) {
  8344. var child = nodes[i];
  8345. if (child.nodeType === 3) {
  8346. text = text + child.nodeValue
  8347. }
  8348. }
  8349. return text
  8350. }
  8351. })(jQuery, fluid_1_4);
  8352. fluid_1_4 = fluid_1_4 || {};
  8353. (function ($, fluid) {
  8354. var unUnicode = /(\\u[\dabcdef]{4}|\\x[\dabcdef]{2})/g;
  8355. fluid.unescapeProperties = function (string) {
  8356. string = string.replace(unUnicode, function (match) {
  8357. var code = match.substring(2);
  8358. var parsed = parseInt(code, 16);
  8359. return String.fromCharCode(parsed)
  8360. });
  8361. var pos = 0;
  8362. while (true) {
  8363. var backpos = string.indexOf("\\", pos);
  8364. if (backpos === -1) {
  8365. break
  8366. }
  8367. if (backpos === string.length - 1) {
  8368. return [string.substring(0, string.length - 1), true]
  8369. }
  8370. var replace = string.charAt(backpos + 1);
  8371. if (replace === "n") {
  8372. replace = "\n"
  8373. }
  8374. if (replace === "r") {
  8375. replace = "\r"
  8376. }
  8377. if (replace === "t") {
  8378. replace = "\t"
  8379. }
  8380. string = string.substring(0, backpos) + replace + string.substring(backpos + 2);
  8381. pos = backpos + 1
  8382. }
  8383. return [string, false]
  8384. };
  8385. var breakPos = /[^\\][\s:=]/;
  8386. fluid.parseJavaProperties = function (text) {
  8387. var togo = {};
  8388. text = text.replace(/\r\n/g, "\n");
  8389. text = text.replace(/\r/g, "\n");
  8390. lines = text.split("\n");
  8391. var contin,
  8392. key,
  8393. valueComp,
  8394. valueRaw,
  8395. valueEsc;
  8396. for (var i = 0; i < lines.length; ++i) {
  8397. var line = $.trim(lines[i]);
  8398. if (!line || line.charAt(0) === "#" || line.charAt(0) === "!") {
  8399. continue
  8400. }
  8401. if (!contin) {
  8402. valueComp = "";
  8403. var breakpos = line.search(breakPos);
  8404. if (breakpos === -1) {
  8405. key = line;
  8406. valueRaw = ""
  8407. } else {
  8408. key = $.trim(line.substring(0, breakpos + 1));
  8409. valueRaw = $.trim(line.substring(breakpos + 2));
  8410. if (valueRaw.charAt(0) === ":" || valueRaw.charAt(0) === "=") {
  8411. valueRaw = $.trim(valueRaw.substring(1))
  8412. }
  8413. }
  8414. key = fluid.unescapeProperties(key)[0];
  8415. valueEsc = fluid.unescapeProperties(valueRaw)
  8416. } else {
  8417. valueEsc = fluid.unescapeProperties(line)
  8418. }
  8419. contin = valueEsc[1];
  8420. if (!valueEsc[1]) {
  8421. togo[key] = valueComp + valueEsc[0]
  8422. } else {
  8423. valueComp += valueEsc[0]
  8424. }
  8425. }
  8426. return togo
  8427. };
  8428. fluid.formatMessage = function (messageString, args) {
  8429. if (!args) {
  8430. return messageString
  8431. }
  8432. if (typeof(args) === "string") {
  8433. args = [args]
  8434. }
  8435. for (var i = 0; i < args.length; ++i) {
  8436. messageString = messageString.replace("{" + i + "}", args[i])
  8437. }
  8438. return messageString
  8439. }
  8440. })(jQuery, fluid_1_4);
  8441. var fluid_1_4 = fluid_1_4 || {};
  8442. var fluid = fluid || fluid_1_4;
  8443. (function ($, fluid) {
  8444. fluid.renderTimestamp = function (date) {
  8445. var zeropad = function (num, width) {
  8446. if (!width) {
  8447. width = 2
  8448. }
  8449. var numstr = (num == undefined ? "" : num.toString());
  8450. return "00000".substring(5 - width + numstr.length) + numstr
  8451. };
  8452. return zeropad(date.getHours()) + ":" + zeropad(date.getMinutes()) + ":" + zeropad(date.getSeconds()) + "." + zeropad(date.getMilliseconds(), 3)
  8453. };
  8454. fluid.detectStackStyle = function (e) {
  8455. var style = "other";
  8456. var stackStyle = {
  8457. offset : 0
  8458. };
  8459. if (e.arguments) {
  8460. style = "chrome"
  8461. } else {
  8462. if (typeof window !== "undefined" && window.opera && e.stacktrace) {
  8463. style = "opera10"
  8464. } else {
  8465. if (e.stack) {
  8466. style = "firefox";
  8467. stackStyle.offset = e.stack.indexOf("Trace exception") === -1 ? 1 : 0
  8468. } else {
  8469. if (typeof window !== "undefined" && window.opera && !("stacktrace" in e)) {
  8470. style = "opera"
  8471. }
  8472. }
  8473. }
  8474. }
  8475. stackStyle.style = style;
  8476. return stackStyle
  8477. };
  8478. fluid.obtainException = function () {
  8479. try {
  8480. throw new Error("Trace exception")
  8481. } catch (e) {
  8482. return e
  8483. }
  8484. };
  8485. var stackStyle = fluid.detectStackStyle(fluid.obtainException());
  8486. fluid.registerNamespace("fluid.exceptionDecoders");
  8487. fluid.decodeStack = function () {
  8488. if (stackStyle.style !== "firefox") {
  8489. return null
  8490. }
  8491. var e = fluid.obtainException();
  8492. return fluid.exceptionDecoders[stackStyle.style](e)
  8493. };
  8494. fluid.exceptionDecoders.firefox = function (e) {
  8495. var lines = e.stack.replace(/(?:\n@:0)?\s+$/m, "").replace(/^\(/gm, "{anonymous}(").split("\n");
  8496. return fluid.transform(lines, function (line) {
  8497. var atind = line.indexOf("@");
  8498. return atind === -1 ? [line] : [line.substring(atind + 1), line.substring(0, atind)]
  8499. })
  8500. };
  8501. fluid.getCallerInfo = function (atDepth) {
  8502. atDepth = (atDepth || 3) - stackStyle.offset;
  8503. var stack = fluid.decodeStack();
  8504. return stack ? stack[atDepth][0] : null
  8505. };
  8506. function generate(c, count) {
  8507. var togo = "";
  8508. for (var i = 0; i < count; ++i) {
  8509. togo += c
  8510. }
  8511. return togo
  8512. }
  8513. function printImpl(obj, small, options) {
  8514. var big = small + options.indentChars;
  8515. if (obj === null) {
  8516. return "null"
  8517. } else {
  8518. if (fluid.isPrimitive(obj)) {
  8519. return JSON.stringify(obj)
  8520. } else {
  8521. var j = [];
  8522. if (fluid.isArrayable(obj)) {
  8523. if (obj.length === 0) {
  8524. return "[]"
  8525. }
  8526. for (var i = 0; i < obj.length; ++i) {
  8527. j[i] = printImpl(obj[i], big, options)
  8528. }
  8529. return "[\n" + big + j.join(",\n" + big) + "\n" + small + "]"
  8530. } else {
  8531. var i = 0;
  8532. fluid.each(obj, function (value, key) {
  8533. j[i++] = JSON.stringify(key) + ": " + printImpl(value, big, options)
  8534. });
  8535. return "{\n" + big + j.join(",\n" + big) + "\n" + small + "}"
  8536. }
  8537. }
  8538. }
  8539. }
  8540. fluid.prettyPrintJSON = function (obj, options) {
  8541. options = $.extend({
  8542. indent : 4
  8543. }, options);
  8544. options.indentChars = generate(" ", options.indent);
  8545. return printImpl(obj, "", options)
  8546. };
  8547. fluid.dumpEl = function (element) {
  8548. var togo;
  8549. if (!element) {
  8550. return "null"
  8551. }
  8552. if (element.nodeType === 3 || element.nodeType === 8) {
  8553. return "[data: " + element.data + "]"
  8554. }
  8555. if (element.nodeType === 9) {
  8556. return "[document: location " + element.location + "]"
  8557. }
  8558. if (!element.nodeType && fluid.isArrayable(element)) {
  8559. togo = "[";
  8560. for (var i = 0; i < element.length; ++i) {
  8561. togo += fluid.dumpEl(element[i]);
  8562. if (i < element.length - 1) {
  8563. togo += ", "
  8564. }
  8565. }
  8566. return togo + "]"
  8567. }
  8568. element = $(element);
  8569. togo = element.get(0).tagName;
  8570. if (element.id) {
  8571. togo += "#" + element.id
  8572. }
  8573. if (element.attr("class")) {
  8574. togo += "." + element.attr("class")
  8575. }
  8576. return togo
  8577. }
  8578. })(jQuery, fluid_1_4);
  8579. var fluid_1_4 = fluid_1_4 || {};
  8580. (function ($, fluid) {
  8581. fluid.BINDING_ROOT_KEY = "fluid-binding-root";
  8582. fluid.findData = function (elem, name) {
  8583. while (elem) {
  8584. var data = $.data(elem, name);
  8585. if (data) {
  8586. return data
  8587. }
  8588. elem = elem.parentNode
  8589. }
  8590. };
  8591. fluid.bindFossils = function (node, data, fossils) {
  8592. $.data(node, fluid.BINDING_ROOT_KEY, {
  8593. data : data,
  8594. fossils : fossils
  8595. })
  8596. };
  8597. fluid.boundPathForNode = function (node, fossils) {
  8598. node = fluid.unwrap(node);
  8599. var key = node.name || node.id;
  8600. var record = fossils[key];
  8601. return record ? record.EL : null
  8602. };
  8603. fluid.findForm = function (node) {
  8604. return fluid.findAncestor(node, function (element) {
  8605. return element.nodeName.toLowerCase() === "form"
  8606. })
  8607. };
  8608. fluid.value = function (nodeIn, newValue) {
  8609. var node = fluid.unwrap(nodeIn);
  8610. var multiple = false;
  8611. if (node.nodeType === undefined && node.length > 1) {
  8612. node = node[0];
  8613. multiple = true
  8614. }
  8615. if ("input" !== node.nodeName.toLowerCase() || !/radio|checkbox/.test(node.type)) {
  8616. return newValue === undefined ? $(node).val() : $(node).val(newValue)
  8617. }
  8618. var name = node.name;
  8619. if (name === undefined) {
  8620. fluid.fail("Cannot acquire value from node " + fluid.dumpEl(node) + " which does not have name attribute set")
  8621. }
  8622. var elements;
  8623. if (multiple) {
  8624. elements = nodeIn
  8625. } else {
  8626. elements = document.getElementsByName(name);
  8627. var scope = fluid.findForm(node);
  8628. elements = $.grep(elements, function (element) {
  8629. if (element.name !== name) {
  8630. return false
  8631. }
  8632. return !scope || fluid.dom.isContainer(scope, element)
  8633. })
  8634. }
  8635. if (newValue !== undefined) {
  8636. if (typeof(newValue) === "boolean") {
  8637. newValue = (newValue ? "true" : "false")
  8638. }
  8639. $.each(elements, function () {
  8640. this.checked = (newValue instanceof Array ? $.inArray(this.value, newValue) !== -1 : newValue === this.value)
  8641. })
  8642. } else {
  8643. var checked = $.map(elements, function (element) {
  8644. return element.checked ? element.value : null
  8645. });
  8646. return node.type === "radio" ? checked[0] : checked
  8647. }
  8648. };
  8649. fluid.applyChange = function (node, newValue, applier) {
  8650. node = fluid.unwrap(node);
  8651. if (newValue === undefined) {
  8652. newValue = fluid.value(node)
  8653. }
  8654. if (node.nodeType === undefined && node.length > 0) {
  8655. node = node[0]
  8656. }
  8657. var root = fluid.findData(node, fluid.BINDING_ROOT_KEY);
  8658. if (!root) {
  8659. fluid.fail("Bound data could not be discovered in any node above " + fluid.dumpEl(node))
  8660. }
  8661. var name = node.name;
  8662. var fossil = root.fossils[name];
  8663. if (!fossil) {
  8664. fluid.fail("No fossil discovered for name " + name + " in fossil record above " + fluid.dumpEl(node))
  8665. }
  8666. if (typeof(fossil.oldvalue) === "boolean") {
  8667. newValue = newValue[0] ? true : false
  8668. }
  8669. var EL = root.fossils[name].EL;
  8670. if (applier) {
  8671. applier.fireChangeRequest({
  8672. path : EL,
  8673. value : newValue,
  8674. source : node.id
  8675. })
  8676. } else {
  8677. fluid.set(root.data, EL, newValue)
  8678. }
  8679. };
  8680. fluid.pathUtil = {};
  8681. var getPathSegmentImpl = function (accept, path, i) {
  8682. var segment = null;
  8683. if (accept) {
  8684. segment = ""
  8685. }
  8686. var escaped = false;
  8687. var limit = path.length;
  8688. for (; i < limit; ++i) {
  8689. var c = path.charAt(i);
  8690. if (!escaped) {
  8691. if (c === ".") {
  8692. break
  8693. } else {
  8694. if (c === "\\") {
  8695. escaped = true
  8696. } else {
  8697. if (segment !== null) {
  8698. segment += c
  8699. }
  8700. }
  8701. }
  8702. } else {
  8703. escaped = false;
  8704. if (segment !== null) {
  8705. accept += c
  8706. }
  8707. }
  8708. }
  8709. if (segment !== null) {
  8710. accept[0] = segment
  8711. }
  8712. return i
  8713. };
  8714. var globalAccept = [];
  8715. fluid.pathUtil.getPathSegment = function (path, i) {
  8716. getPathSegmentImpl(globalAccept, path, i);
  8717. return globalAccept[0]
  8718. };
  8719. fluid.pathUtil.getHeadPath = function (path) {
  8720. return fluid.pathUtil.getPathSegment(path, 0)
  8721. };
  8722. fluid.pathUtil.getFromHeadPath = function (path) {
  8723. var firstdot = getPathSegmentImpl(null, path, 0);
  8724. return firstdot === path.length ? null : path.substring(firstdot + 1)
  8725. };
  8726. function lastDotIndex(path) {
  8727. return path.lastIndexOf(".")
  8728. }
  8729. fluid.pathUtil.getToTailPath = function (path) {
  8730. var lastdot = lastDotIndex(path);
  8731. return lastdot === -1 ? null : path.substring(0, lastdot)
  8732. };
  8733. fluid.pathUtil.getTailPath = function (path) {
  8734. var lastdot = lastDotIndex(path);
  8735. return fluid.pathUtil.getPathSegment(path, lastdot + 1)
  8736. };
  8737. var composeSegment = function (prefix, toappend) {
  8738. for (var i = 0; i < toappend.length; ++i) {
  8739. var c = toappend.charAt(i);
  8740. if (c === "." || c === "\\" || c === "}") {
  8741. prefix += "\\"
  8742. }
  8743. prefix += c
  8744. }
  8745. return prefix
  8746. };
  8747. fluid.pathUtil.composePath = function (prefix, suffix) {
  8748. if (prefix.length !== 0) {
  8749. prefix += "."
  8750. }
  8751. return composeSegment(prefix, suffix)
  8752. };
  8753. fluid.pathUtil.matchPath = function (spec, path) {
  8754. var togo = "";
  8755. while (true) {
  8756. if (!spec || path === "") {
  8757. break
  8758. }
  8759. if (!path) {
  8760. return null
  8761. }
  8762. var spechead = fluid.pathUtil.getHeadPath(spec);
  8763. var pathhead = fluid.pathUtil.getHeadPath(path);
  8764. if (spechead !== "*" && spechead !== pathhead) {
  8765. return null
  8766. }
  8767. togo = fluid.pathUtil.composePath(togo, pathhead);
  8768. spec = fluid.pathUtil.getFromHeadPath(spec);
  8769. path = fluid.pathUtil.getFromHeadPath(path)
  8770. }
  8771. return togo
  8772. };
  8773. fluid.model.mergeModel = function (target, source, applier) {
  8774. var copySource = fluid.copy(source);
  8775. applier = applier || fluid.makeChangeApplier(source);
  8776. if (!fluid.isPrimitive(target)) {
  8777. applier.fireChangeRequest({
  8778. type : "ADD",
  8779. path : "",
  8780. value : target
  8781. })
  8782. }
  8783. applier.fireChangeRequest({
  8784. type : "MERGE",
  8785. path : "",
  8786. value : copySource
  8787. });
  8788. return source
  8789. };
  8790. fluid.model.isNullChange = function (model, request, resolverGetConfig) {
  8791. if (request.type === "ADD") {
  8792. var existing = fluid.get(model, request.path, resolverGetConfig);
  8793. if (existing === request.value) {
  8794. return true
  8795. }
  8796. }
  8797. };
  8798. fluid.model.applyChangeRequest = function (model, request, resolverSetConfig) {
  8799. var pen = fluid.model.getPenultimate(model, request.path, resolverSetConfig || fluid.model.defaultSetConfig);
  8800. if (request.type === "ADD" || request.type === "MERGE") {
  8801. if (request.path === "" || request.type === "MERGE") {
  8802. if (request.type === "ADD") {
  8803. fluid.clear(pen.root)
  8804. }
  8805. $.extend(true, request.path === "" ? pen.root : pen.root[pen.last], request.value)
  8806. } else {
  8807. pen.root[pen.last] = request.value
  8808. }
  8809. } else {
  8810. if (request.type === "DELETE") {
  8811. if (request.path === "") {
  8812. fluid.clear(pen.root)
  8813. } else {
  8814. delete pen.root[pen.last]
  8815. }
  8816. }
  8817. }
  8818. };
  8819. function bindRequestChange(that) {
  8820. that.requestChange = function (path, value, type) {
  8821. var changeRequest = {
  8822. path : path,
  8823. value : value,
  8824. type : type
  8825. };
  8826. that.fireChangeRequest(changeRequest)
  8827. }
  8828. }
  8829. fluid.makeChangeApplier = function (model, options) {
  8830. options = options || {};
  8831. var baseEvents = {
  8832. guards : fluid.event.getEventFirer(false, true),
  8833. postGuards : fluid.event.getEventFirer(false, true),
  8834. modelChanged : fluid.event.getEventFirer(false, false)
  8835. };
  8836. var that = {
  8837. model : model
  8838. };
  8839. function makeGuardWrapper(cullUnchanged) {
  8840. if (!cullUnchanged) {
  8841. return null
  8842. }
  8843. var togo = function (guard) {
  8844. return function (model, changeRequest, internalApplier) {
  8845. var oldRet = guard(model, changeRequest, internalApplier);
  8846. if (oldRet === false) {
  8847. return false
  8848. } else {
  8849. if (fluid.model.isNullChange(model, changeRequest)) {
  8850. togo.culled = true;
  8851. return false
  8852. }
  8853. }
  8854. }
  8855. };
  8856. return togo
  8857. }
  8858. function wrapListener(listener, spec) {
  8859. var pathSpec = spec;
  8860. var transactional = false;
  8861. var priority = Number.MAX_VALUE;
  8862. if (typeof(spec) !== "string") {
  8863. pathSpec = spec.path;
  8864. transactional = spec.transactional;
  8865. if (spec.priority !== undefined) {
  8866. priority = spec.priority
  8867. }
  8868. } else {
  8869. if (pathSpec.charAt(0) === "!") {
  8870. transactional = true;
  8871. pathSpec = pathSpec.substring(1)
  8872. }
  8873. }
  8874. return function (changePath, fireSpec, accum) {
  8875. var guid = fluid.event.identifyListener(listener);
  8876. var exist = fireSpec.guids[guid];
  8877. if (!exist) {
  8878. var match = fluid.pathUtil.matchPath(pathSpec, changePath);
  8879. if (match !== null) {
  8880. var record = {
  8881. changePath : changePath,
  8882. pathSpec : pathSpec,
  8883. listener : listener,
  8884. priority : priority,
  8885. transactional : transactional
  8886. };
  8887. if (accum) {
  8888. record.accumulate = [accum]
  8889. }
  8890. fireSpec.guids[guid] = record;
  8891. var collection = transactional ? "transListeners" : "listeners";
  8892. fireSpec[collection].push(record);
  8893. fireSpec.all.push(record)
  8894. }
  8895. } else {
  8896. if (accum) {
  8897. if (!exist.accumulate) {
  8898. exist.accumulate = []
  8899. }
  8900. exist.accumulate.push(accum)
  8901. }
  8902. }
  8903. }
  8904. }
  8905. function fireFromSpec(name, fireSpec, args, category, wrapper) {
  8906. return baseEvents[name].fireToListeners(fireSpec[category], args, wrapper)
  8907. }
  8908. function fireComparator(recA, recB) {
  8909. return recA.priority - recB.priority
  8910. }
  8911. function prepareFireEvent(name, changePath, fireSpec, accum) {
  8912. baseEvents[name].fire(changePath, fireSpec, accum);
  8913. fireSpec.all.sort(fireComparator);
  8914. fireSpec.listeners.sort(fireComparator);
  8915. fireSpec.transListeners.sort(fireComparator)
  8916. }
  8917. function makeFireSpec() {
  8918. return {
  8919. guids : {},
  8920. all : [],
  8921. listeners : [],
  8922. transListeners : []
  8923. }
  8924. }
  8925. function getFireSpec(name, changePath) {
  8926. var fireSpec = makeFireSpec();
  8927. prepareFireEvent(name, changePath, fireSpec);
  8928. return fireSpec
  8929. }
  8930. function fireEvent(name, changePath, args, wrapper) {
  8931. var fireSpec = getFireSpec(name, changePath);
  8932. return fireFromSpec(name, fireSpec, args, "all", wrapper)
  8933. }
  8934. function adaptListener(that, name) {
  8935. that[name] = {
  8936. addListener : function (spec, listener, namespace) {
  8937. baseEvents[name].addListener(wrapListener(listener, spec), namespace)
  8938. },
  8939. removeListener : function (listener) {
  8940. baseEvents[name].removeListener(listener)
  8941. }
  8942. }
  8943. }
  8944. adaptListener(that, "guards");
  8945. adaptListener(that, "postGuards");
  8946. adaptListener(that, "modelChanged");
  8947. function preFireChangeRequest(changeRequest) {
  8948. if (!changeRequest.type) {
  8949. changeRequest.type = "ADD"
  8950. }
  8951. }
  8952. var bareApplier = {
  8953. fireChangeRequest : function (changeRequest) {
  8954. that.fireChangeRequest(changeRequest, true)
  8955. }
  8956. };
  8957. bindRequestChange(bareApplier);
  8958. that.fireChangeRequest = function (changeRequest, defeatGuards) {
  8959. preFireChangeRequest(changeRequest);
  8960. var guardFireSpec = defeatGuards ? null : getFireSpec("guards", changeRequest.path);
  8961. if (guardFireSpec && guardFireSpec.transListeners.length > 0) {
  8962. var ation = that.initiate();
  8963. ation.fireChangeRequest(changeRequest, guardFireSpec);
  8964. ation.commit()
  8965. } else {
  8966. if (!defeatGuards) {
  8967. var prevent = fireFromSpec("guards", guardFireSpec, [model, changeRequest, bareApplier], "listeners");
  8968. if (prevent === false) {
  8969. return false
  8970. }
  8971. }
  8972. var oldModel = model;
  8973. if (!options.thin) {
  8974. oldModel = {};
  8975. fluid.model.copyModel(oldModel, model)
  8976. }
  8977. fluid.model.applyChangeRequest(model, changeRequest, options.resolverSetConfig);
  8978. fireEvent("modelChanged", changeRequest.path, [model, oldModel, [changeRequest]])
  8979. }
  8980. };
  8981. bindRequestChange(that);
  8982. function fireAgglomerated(eventName, formName, changes, args, accpos) {
  8983. var fireSpec = makeFireSpec();
  8984. for (var i = 0; i < changes.length; ++i) {
  8985. prepareFireEvent(eventName, changes[i].path, fireSpec, changes[i])
  8986. }
  8987. for (var j = 0; j < fireSpec[formName].length; ++j) {
  8988. var spec = fireSpec[formName][j];
  8989. if (accpos) {
  8990. args[accpos] = spec.accumulate
  8991. }
  8992. var ret = spec.listener.apply(null, args);
  8993. if (ret === false) {
  8994. return false
  8995. }
  8996. }
  8997. }
  8998. that.initiate = function (newModel) {
  8999. var cancelled = false;
  9000. var changes = [];
  9001. if (options.thin) {
  9002. newModel = model
  9003. } else {
  9004. newModel = newModel || {};
  9005. fluid.model.copyModel(newModel, model)
  9006. }
  9007. var internalApplier = {
  9008. fireChangeRequest : function (changeRequest) {
  9009. preFireChangeRequest(changeRequest);
  9010. fluid.model.applyChangeRequest(newModel, changeRequest, options.resolverSetConfig);
  9011. changes.push(changeRequest)
  9012. }
  9013. };
  9014. bindRequestChange(internalApplier);
  9015. var ation = {
  9016. commit : function () {
  9017. var oldModel;
  9018. if (cancelled) {
  9019. return false
  9020. }
  9021. var ret = fireAgglomerated("postGuards", "transListeners", changes, [newModel, null, internalApplier], 1);
  9022. if (ret === false) {
  9023. return false
  9024. }
  9025. if (options.thin) {
  9026. oldModel = model
  9027. } else {
  9028. oldModel = {};
  9029. fluid.model.copyModel(oldModel, model);
  9030. fluid.clear(model);
  9031. fluid.model.copyModel(model, newModel)
  9032. }
  9033. fireAgglomerated("modelChanged", "all", changes, [model, oldModel, null], 2)
  9034. },
  9035. fireChangeRequest : function (changeRequest) {
  9036. preFireChangeRequest(changeRequest);
  9037. if (options.cullUnchanged && fluid.model.isNullChange(model, changeRequest, options.resolverGetConfig)) {
  9038. return
  9039. }
  9040. var wrapper = makeGuardWrapper(options.cullUnchanged);
  9041. var prevent = fireEvent("guards", changeRequest.path, [newModel, changeRequest, internalApplier], wrapper);
  9042. if (prevent === false && !(wrapper && wrapper.culled)) {
  9043. cancelled = true
  9044. }
  9045. if (!cancelled) {
  9046. if (!(wrapper && wrapper.culled)) {
  9047. fluid.model.applyChangeRequest(newModel, changeRequest, options.resolverSetConfig);
  9048. changes.push(changeRequest)
  9049. }
  9050. }
  9051. }
  9052. };
  9053. bindRequestChange(ation);
  9054. return ation
  9055. };
  9056. return that
  9057. };
  9058. fluid.makeSuperApplier = function () {
  9059. var subAppliers = [];
  9060. var that = {};
  9061. that.addSubApplier = function (path, subApplier) {
  9062. subAppliers.push({
  9063. path : path,
  9064. subApplier : subApplier
  9065. })
  9066. };
  9067. that.fireChangeRequest = function (request) {
  9068. for (var i = 0; i < subAppliers.length; ++i) {
  9069. var path = subAppliers[i].path;
  9070. if (request.path.indexOf(path) === 0) {
  9071. var subpath = request.path.substring(path.length + 1);
  9072. var subRequest = fluid.copy(request);
  9073. subRequest.path = subpath;
  9074. subAppliers[i].subApplier.fireChangeRequest(subRequest)
  9075. }
  9076. }
  9077. };
  9078. bindRequestChange(that);
  9079. return that
  9080. };
  9081. fluid.attachModel = function (baseModel, path, model) {
  9082. var segs = fluid.model.parseEL(path);
  9083. for (var i = 0; i < segs.length - 1; ++i) {
  9084. var seg = segs[i];
  9085. var subModel = baseModel[seg];
  9086. if (!subModel) {
  9087. baseModel[seg] = subModel = {}
  9088. }
  9089. baseModel = subModel
  9090. }
  9091. baseModel[segs[segs.length - 1]] = model
  9092. };
  9093. fluid.assembleModel = function (modelSpec) {
  9094. var model = {};
  9095. var superApplier = fluid.makeSuperApplier();
  9096. var togo = {
  9097. model : model,
  9098. applier : superApplier
  9099. };
  9100. for (var path in modelSpec) {
  9101. var rec = modelSpec[path];
  9102. fluid.attachModel(model, path, rec.model);
  9103. if (rec.applier) {
  9104. superApplier.addSubApplier(path, rec.applier)
  9105. }
  9106. }
  9107. return togo
  9108. }
  9109. })(jQuery, fluid_1_4);
  9110. var fluid_1_4 = fluid_1_4 || {};
  9111. var fluid = fluid || fluid_1_4;
  9112. (function ($, fluid) {
  9113. fluid.thatistBridge = function (name, peer) {
  9114. var togo = function (funcname) {
  9115. var segs = funcname.split(".");
  9116. var move = peer;
  9117. for (var i = 0; i < segs.length; ++i) {
  9118. move = move[segs[i]]
  9119. }
  9120. var args = [this];
  9121. if (arguments.length === 2) {
  9122. args = args.concat($.makeArray(arguments[1]))
  9123. }
  9124. var ret = move.apply(null, args);
  9125. this.that = function () {
  9126. return ret
  9127. };
  9128. var type = typeof(ret);
  9129. return !ret || type === "string" || type === "number" || type === "boolean" || ret && ret.length !== undefined ? ret : this
  9130. };
  9131. $.fn[name] = togo;
  9132. return togo
  9133. };
  9134. fluid.thatistBridge("fluid", fluid);
  9135. fluid.thatistBridge("fluid_1_4", fluid_1_4);
  9136. var normalizeTabindexName = function () {
  9137. return $.browser.msie ? "tabIndex" : "tabindex"
  9138. };
  9139. var canHaveDefaultTabindex = function (elements) {
  9140. if (elements.length <= 0) {
  9141. return false
  9142. }
  9143. return $(elements[0]).is("a, input, button, select, area, textarea, object")
  9144. };
  9145. var getValue = function (elements) {
  9146. if (elements.length <= 0) {
  9147. return undefined
  9148. }
  9149. if (!fluid.tabindex.hasAttr(elements)) {
  9150. return canHaveDefaultTabindex(elements) ? Number(0) : undefined
  9151. }
  9152. var value = elements.attr(normalizeTabindexName());
  9153. return Number(value)
  9154. };
  9155. var setValue = function (elements, toIndex) {
  9156. return elements.each(function (i, item) {
  9157. $(item).attr(normalizeTabindexName(), toIndex)
  9158. })
  9159. };
  9160. fluid.tabindex = function (target, toIndex) {
  9161. target = $(target);
  9162. if (toIndex !== null && toIndex !== undefined) {
  9163. return setValue(target, toIndex)
  9164. } else {
  9165. return getValue(target)
  9166. }
  9167. };
  9168. fluid.tabindex.remove = function (target) {
  9169. target = $(target);
  9170. return target.each(function (i, item) {
  9171. $(item).removeAttr(normalizeTabindexName())
  9172. })
  9173. };
  9174. fluid.tabindex.hasAttr = function (target) {
  9175. target = $(target);
  9176. if (target.length <= 0) {
  9177. return false
  9178. }
  9179. var togo = target.map(function () {
  9180. var attributeNode = this.getAttributeNode(normalizeTabindexName());
  9181. return attributeNode ? attributeNode.specified : false
  9182. });
  9183. return togo.length === 1 ? togo[0] : togo
  9184. };
  9185. fluid.tabindex.has = function (target) {
  9186. target = $(target);
  9187. return fluid.tabindex.hasAttr(target) || canHaveDefaultTabindex(target)
  9188. };
  9189. fluid.a11y = $.a11y || {};
  9190. fluid.a11y.orientation = {
  9191. HORIZONTAL : 0,
  9192. VERTICAL : 1,
  9193. BOTH : 2
  9194. };
  9195. var UP_DOWN_KEYMAP = {
  9196. next : $.ui.keyCode.DOWN,
  9197. previous : $.ui.keyCode.UP
  9198. };
  9199. var LEFT_RIGHT_KEYMAP = {
  9200. next : $.ui.keyCode.RIGHT,
  9201. previous : $.ui.keyCode.LEFT
  9202. };
  9203. var unwrap = function (element) {
  9204. return element.jquery ? element[0] : element
  9205. };
  9206. var makeElementsTabFocussable = function (elements) {
  9207. elements.each(function (idx, item) {
  9208. item = $(item);
  9209. if (!item.fluid("tabindex.has") || item.fluid("tabindex") < 0) {
  9210. item.fluid("tabindex", 0)
  9211. }
  9212. })
  9213. };
  9214. fluid.tabbable = function (target) {
  9215. target = $(target);
  9216. makeElementsTabFocussable(target)
  9217. };
  9218. var CONTEXT_KEY = "selectionContext";
  9219. var NO_SELECTION = -32768;
  9220. var cleanUpWhenLeavingContainer = function (selectionContext) {
  9221. if (selectionContext.activeItemIndex !== NO_SELECTION) {
  9222. if (selectionContext.options.onLeaveContainer) {
  9223. selectionContext.options.onLeaveContainer(selectionContext.selectables[selectionContext.activeItemIndex])
  9224. } else {
  9225. if (selectionContext.options.onUnselect) {
  9226. selectionContext.options.onUnselect(selectionContext.selectables[selectionContext.activeItemIndex])
  9227. }
  9228. }
  9229. }
  9230. if (!selectionContext.options.rememberSelectionState) {
  9231. selectionContext.activeItemIndex = NO_SELECTION
  9232. }
  9233. };
  9234. var drawSelection = function (elementToSelect, handler) {
  9235. if (handler) {
  9236. handler(elementToSelect)
  9237. }
  9238. };
  9239. var eraseSelection = function (selectedElement, handler) {
  9240. if (handler && selectedElement) {
  9241. handler(selectedElement)
  9242. }
  9243. };
  9244. var unselectElement = function (selectedElement, selectionContext) {
  9245. eraseSelection(selectedElement, selectionContext.options.onUnselect)
  9246. };
  9247. var selectElement = function (elementToSelect, selectionContext) {
  9248. unselectElement(selectionContext.selectedElement(), selectionContext);
  9249. elementToSelect = unwrap(elementToSelect);
  9250. var newIndex = selectionContext.selectables.index(elementToSelect);
  9251. if (newIndex === -1) {
  9252. return
  9253. }
  9254. selectionContext.activeItemIndex = newIndex;
  9255. drawSelection(elementToSelect, selectionContext.options.onSelect)
  9256. };
  9257. var selectableFocusHandler = function (selectionContext) {
  9258. return function (evt) {
  9259. $(evt.target).fluid("tabindex", 0);
  9260. selectElement(evt.target, selectionContext);
  9261. return evt.stopPropagation()
  9262. }
  9263. };
  9264. var selectableBlurHandler = function (selectionContext) {
  9265. return function (evt) {
  9266. $(evt.target).fluid("tabindex", selectionContext.options.selectablesTabindex);
  9267. unselectElement(evt.target, selectionContext);
  9268. return evt.stopPropagation()
  9269. }
  9270. };
  9271. var reifyIndex = function (sc_that) {
  9272. var elements = sc_that.selectables;
  9273. if (sc_that.activeItemIndex >= elements.length) {
  9274. sc_that.activeItemIndex = 0
  9275. }
  9276. if (sc_that.activeItemIndex < 0 && sc_that.activeItemIndex !== NO_SELECTION) {
  9277. sc_that.activeItemIndex = elements.length - 1
  9278. }
  9279. if (sc_that.activeItemIndex >= 0) {
  9280. fluid.focus(elements[sc_that.activeItemIndex])
  9281. }
  9282. };
  9283. var prepareShift = function (selectionContext) {
  9284. var selElm = selectionContext.selectedElement();
  9285. if (selElm) {
  9286. fluid.blur(selElm)
  9287. }
  9288. unselectElement(selectionContext.selectedElement(), selectionContext);
  9289. if (selectionContext.activeItemIndex === NO_SELECTION) {
  9290. selectionContext.activeItemIndex = -1
  9291. }
  9292. };
  9293. var focusNextElement = function (selectionContext) {
  9294. prepareShift(selectionContext);
  9295. ++selectionContext.activeItemIndex;
  9296. reifyIndex(selectionContext)
  9297. };
  9298. var focusPreviousElement = function (selectionContext) {
  9299. prepareShift(selectionContext);
  9300. --selectionContext.activeItemIndex;
  9301. reifyIndex(selectionContext)
  9302. };
  9303. var arrowKeyHandler = function (selectionContext, keyMap, userHandlers) {
  9304. return function (evt) {
  9305. if (evt.which === keyMap.next) {
  9306. focusNextElement(selectionContext);
  9307. evt.preventDefault()
  9308. } else {
  9309. if (evt.which === keyMap.previous) {
  9310. focusPreviousElement(selectionContext);
  9311. evt.preventDefault()
  9312. }
  9313. }
  9314. }
  9315. };
  9316. var getKeyMapForDirection = function (direction) {
  9317. var keyMap;
  9318. if (direction === fluid.a11y.orientation.HORIZONTAL) {
  9319. keyMap = LEFT_RIGHT_KEYMAP
  9320. } else {
  9321. if (direction === fluid.a11y.orientation.VERTICAL) {
  9322. keyMap = UP_DOWN_KEYMAP
  9323. }
  9324. }
  9325. return keyMap
  9326. };
  9327. var tabKeyHandler = function (selectionContext) {
  9328. return function (evt) {
  9329. if (evt.which !== $.ui.keyCode.TAB) {
  9330. return
  9331. }
  9332. cleanUpWhenLeavingContainer(selectionContext);
  9333. if (evt.shiftKey) {
  9334. selectionContext.focusIsLeavingContainer = true
  9335. }
  9336. }
  9337. };
  9338. var containerFocusHandler = function (selectionContext) {
  9339. return function (evt) {
  9340. var shouldOrig = selectionContext.options.autoSelectFirstItem;
  9341. var shouldSelect = typeof(shouldOrig) === "function" ? shouldOrig() : shouldOrig;
  9342. if (selectionContext.focusIsLeavingContainer) {
  9343. shouldSelect = false
  9344. }
  9345. if (shouldSelect && evt.target === selectionContext.container.get(0)) {
  9346. if (selectionContext.activeItemIndex === NO_SELECTION) {
  9347. selectionContext.activeItemIndex = 0
  9348. }
  9349. fluid.focus(selectionContext.selectables[selectionContext.activeItemIndex])
  9350. }
  9351. return evt.stopPropagation()
  9352. }
  9353. };
  9354. var containerBlurHandler = function (selectionContext) {
  9355. return function (evt) {
  9356. selectionContext.focusIsLeavingContainer = false;
  9357. return evt.stopPropagation()
  9358. }
  9359. };
  9360. var makeElementsSelectable = function (container, defaults, userOptions) {
  9361. var options = $.extend(true, {}, defaults, userOptions);
  9362. var keyMap = getKeyMapForDirection(options.direction);
  9363. var selectableElements = options.selectableElements ? options.selectableElements : container.find(options.selectableSelector);
  9364. var that = {
  9365. container : container,
  9366. activeItemIndex : NO_SELECTION,
  9367. selectables : selectableElements,
  9368. focusIsLeavingContainer : false,
  9369. options : options
  9370. };
  9371. that.selectablesUpdated = function (focusedItem) {
  9372. if (typeof(that.options.selectablesTabindex) === "number") {
  9373. that.selectables.fluid("tabindex", that.options.selectablesTabindex)
  9374. }
  9375. that.selectables.unbind("focus." + CONTEXT_KEY);
  9376. that.selectables.unbind("blur." + CONTEXT_KEY);
  9377. that.selectables.bind("focus." + CONTEXT_KEY, selectableFocusHandler(that));
  9378. that.selectables.bind("blur." + CONTEXT_KEY, selectableBlurHandler(that));
  9379. if (keyMap && that.options.noBubbleListeners) {
  9380. that.selectables.unbind("keydown." + CONTEXT_KEY);
  9381. that.selectables.bind("keydown." + CONTEXT_KEY, arrowKeyHandler(that, keyMap))
  9382. }
  9383. if (focusedItem) {
  9384. selectElement(focusedItem, that)
  9385. } else {
  9386. reifyIndex(that)
  9387. }
  9388. };
  9389. that.refresh = function () {
  9390. if (!that.options.selectableSelector) {
  9391. throw("Cannot refresh selectable context which was not initialised by a selector")
  9392. }
  9393. that.selectables = container.find(options.selectableSelector);
  9394. that.selectablesUpdated()
  9395. };
  9396. that.selectedElement = function () {
  9397. return that.activeItemIndex < 0 ? null : that.selectables[that.activeItemIndex]
  9398. };
  9399. if (keyMap && !that.options.noBubbleListeners) {
  9400. container.keydown(arrowKeyHandler(that, keyMap))
  9401. }
  9402. container.keydown(tabKeyHandler(that));
  9403. container.focus(containerFocusHandler(that));
  9404. container.blur(containerBlurHandler(that));
  9405. that.selectablesUpdated();
  9406. return that
  9407. };
  9408. fluid.selectable = function (target, options) {
  9409. target = $(target);
  9410. var that = makeElementsSelectable(target, fluid.selectable.defaults, options);
  9411. fluid.setScopedData(target, CONTEXT_KEY, that);
  9412. return that
  9413. };
  9414. fluid.selectable.select = function (target, toSelect) {
  9415. fluid.focus(toSelect)
  9416. };
  9417. fluid.selectable.selectNext = function (target) {
  9418. target = $(target);
  9419. focusNextElement(fluid.getScopedData(target, CONTEXT_KEY))
  9420. };
  9421. fluid.selectable.selectPrevious = function (target) {
  9422. target = $(target);
  9423. focusPreviousElement(fluid.getScopedData(target, CONTEXT_KEY))
  9424. };
  9425. fluid.selectable.currentSelection = function (target) {
  9426. target = $(target);
  9427. var that = fluid.getScopedData(target, CONTEXT_KEY);
  9428. return $(that.selectedElement())
  9429. };
  9430. fluid.selectable.defaults = {
  9431. direction : fluid.a11y.orientation.VERTICAL,
  9432. selectablesTabindex : -1,
  9433. autoSelectFirstItem : true,
  9434. rememberSelectionState : true,
  9435. selectableSelector : ".selectable",
  9436. selectableElements : null,
  9437. onSelect : null,
  9438. onUnselect : null,
  9439. onLeaveContainer : null
  9440. };
  9441. var checkForModifier = function (binding, evt) {
  9442. if (!binding.modifier) {
  9443. return true
  9444. }
  9445. var modifierKey = binding.modifier;
  9446. var isCtrlKeyPresent = modifierKey && evt.ctrlKey;
  9447. var isAltKeyPresent = modifierKey && evt.altKey;
  9448. var isShiftKeyPresent = modifierKey && evt.shiftKey;
  9449. return isCtrlKeyPresent || isAltKeyPresent || isShiftKeyPresent
  9450. };
  9451. var makeActivationHandler = function (binding) {
  9452. return function (evt) {
  9453. var target = evt.target;
  9454. if (!fluid.enabled(evt.target)) {
  9455. return
  9456. }
  9457. var code = evt.which ? evt.which : evt.keyCode;
  9458. if (code === binding.key && binding.activateHandler && checkForModifier(binding, evt)) {
  9459. var event = $.Event("fluid-activate");
  9460. $(evt.target).trigger(event, [binding.activateHandler]);
  9461. if (event.isDefaultPrevented()) {
  9462. evt.preventDefault()
  9463. }
  9464. }
  9465. }
  9466. };
  9467. var makeElementsActivatable = function (elements, onActivateHandler, defaultKeys, options) {
  9468. var bindings = [];
  9469. $(defaultKeys).each(function (index, key) {
  9470. bindings.push({
  9471. modifier : null,
  9472. key : key,
  9473. activateHandler : onActivateHandler
  9474. })
  9475. });
  9476. if (options && options.additionalBindings) {
  9477. bindings = bindings.concat(options.additionalBindings)
  9478. }
  9479. fluid.initEnablement(elements);
  9480. for (var i = 0; i < bindings.length; ++i) {
  9481. var binding = bindings[i];
  9482. elements.keydown(makeActivationHandler(binding))
  9483. }
  9484. elements.bind("fluid-activate", function (evt, handler) {
  9485. handler = handler || onActivateHandler;
  9486. return handler ? handler(evt) : null
  9487. })
  9488. };
  9489. fluid.activatable = function (target, fn, options) {
  9490. target = $(target);
  9491. makeElementsActivatable(target, fn, fluid.activatable.defaults.keys, options)
  9492. };
  9493. fluid.activate = function (target) {
  9494. $(target).trigger("fluid-activate")
  9495. };
  9496. fluid.activatable.defaults = {
  9497. keys : [$.ui.keyCode.ENTER, $.ui.keyCode.SPACE]
  9498. }
  9499. })(jQuery, fluid_1_4);
  9500. var fluid_1_4 = fluid_1_4 || {};
  9501. (function ($, fluid) {
  9502. fluid.defaults("fluid.ariaLabeller", {
  9503. labelAttribute : "aria-label",
  9504. liveRegionMarkup : '<div class="liveRegion fl-offScreen-hidden" aria-live="polite"></div>',
  9505. liveRegionId : "fluid-ariaLabeller-liveRegion",
  9506. invokers : {
  9507. generateLiveElement : {
  9508. funcName : "fluid.ariaLabeller.generateLiveElement",
  9509. args : ["{ariaLabeller}"]
  9510. }
  9511. }
  9512. });
  9513. fluid.ariaLabeller = function (element, options) {
  9514. var that = fluid.initView("fluid.ariaLabeller", element, options);
  9515. fluid.initDependents(that);
  9516. that.update = function (newOptions) {
  9517. newOptions = newOptions || that.options;
  9518. that.container.attr(that.options.labelAttribute, newOptions.text);
  9519. if (newOptions.dynamicLabel) {
  9520. var live = fluid.jById(that.options.liveRegionId);
  9521. if (live.length === 0) {
  9522. live = that.generateLiveElement()
  9523. }
  9524. live.text(newOptions.text)
  9525. }
  9526. };
  9527. that.update();
  9528. return that
  9529. };
  9530. fluid.ariaLabeller.generateLiveElement = function (that) {
  9531. var liveEl = $(that.options.liveRegionMarkup);
  9532. liveEl.prop("id", that.options.liveRegionId);
  9533. $("body").append(liveEl);
  9534. return liveEl
  9535. };
  9536. var LABEL_KEY = "aria-labelling";
  9537. fluid.getAriaLabeller = function (element) {
  9538. element = $(element);
  9539. var that = fluid.getScopedData(element, LABEL_KEY);
  9540. return that
  9541. };
  9542. fluid.updateAriaLabel = function (element, text, options) {
  9543. options = $.extend({}, options || {}, {
  9544. text : text
  9545. });
  9546. var that = fluid.getAriaLabeller(element);
  9547. if (!that) {
  9548. that = fluid.ariaLabeller(element, options);
  9549. fluid.setScopedData(element, LABEL_KEY, that)
  9550. } else {
  9551. that.update(options)
  9552. }
  9553. return that
  9554. };
  9555. fluid.deadMansBlur = function (control, options) {
  9556. var that = fluid.initLittleComponent("fluid.deadMansBlur", options);
  9557. that.blurPending = false;
  9558. that.lastCancel = 0;
  9559. $(control).bind("focusout", function (event) {
  9560. fluid.log("Starting blur timer for element " + fluid.dumpEl(event.target));
  9561. var now = new Date().getTime();
  9562. fluid.log("back delay: " + (now - that.lastCancel));
  9563. if (now - that.lastCancel > that.options.backDelay) {
  9564. that.blurPending = true
  9565. }
  9566. setTimeout(function () {
  9567. if (that.blurPending) {
  9568. that.options.handler(control)
  9569. }
  9570. }, that.options.delay)
  9571. });
  9572. that.canceller = function (event) {
  9573. fluid.log("Cancellation through " + event.type + " on " + fluid.dumpEl(event.target));
  9574. that.lastCancel = new Date().getTime();
  9575. that.blurPending = false
  9576. };
  9577. fluid.each(that.options.exclusions, function (exclusion) {
  9578. exclusion = $(exclusion);
  9579. fluid.each(exclusion, function (excludeEl) {
  9580. $(excludeEl).bind("focusin", that.canceller).bind("fluid-focus", that.canceller).click(that.canceller).mousedown(that.canceller)
  9581. })
  9582. });
  9583. return that
  9584. };
  9585. fluid.defaults("fluid.deadMansBlur", {
  9586. delay : 150,
  9587. backDelay : 100
  9588. })
  9589. })(jQuery, fluid_1_4);
  9590. var fluid_1_4 = fluid_1_4 || {};
  9591. (function ($, fluid) {
  9592. var inCreationMarker = "__CURRENTLY_IN_CREATION__";
  9593. fluid.isFireBreak = function (component) {
  9594. return component.options && component.options["fluid.visitComponents.fireBreak"]
  9595. };
  9596. fluid.visitComponentChildren = function (that, visitor, options, up, down) {
  9597. options = options || {};
  9598. for (var name in that) {
  9599. var component = that[name];
  9600. if (!component || !component.typeName || (component.id && options.visited && options.visited[component.id])) {
  9601. continue
  9602. }
  9603. if (options.visited) {
  9604. options.visited[component.id] = true
  9605. }
  9606. if (visitor(component, name, options, up, down)) {
  9607. return true
  9608. }
  9609. if (!fluid.isFireBreak(component) && !options.flat) {
  9610. fluid.visitComponentChildren(component, visitor, options, up, down + 1)
  9611. }
  9612. }
  9613. };
  9614. var visitComponents = function (thatStack, visitor, options) {
  9615. options = options || {
  9616. visited : {},
  9617. flat : true
  9618. };
  9619. var up = 0;
  9620. for (var i = thatStack.length - 1; i >= 0; --i) {
  9621. var that = thatStack[i];
  9622. if (fluid.isFireBreak(that)) {
  9623. return
  9624. }
  9625. if (that.typeName) {
  9626. options.visited[that.id] = true;
  9627. if (visitor(that, "", options, 0, 0)) {
  9628. return
  9629. }
  9630. }
  9631. if (fluid.visitComponentChildren(that, visitor, options, up, 1)) {
  9632. return
  9633. }
  9634. ++up
  9635. }
  9636. };
  9637. function makeGingerStrategy(instantiator, that, thatStack) {
  9638. return function (component, thisSeg) {
  9639. var atval = component[thisSeg];
  9640. if (atval === undefined) {
  9641. var parentPath = instantiator.idToPath[component.id];
  9642. atval = instantiator.pathToComponent[fluid.composePath(parentPath, thisSeg)];
  9643. if (atval) {
  9644. atval[inCreationMarker] = true
  9645. }
  9646. }
  9647. if (atval !== undefined) {
  9648. if (atval[inCreationMarker]) {
  9649. fluid.fail("Component " + fluid.dumpThat(atval) + ' at path "' + thisSeg + '" of parent ' + fluid.dumpThat(component) + " cannot be used for lookup since it is still in creation. Please reorganise your dependencies so that they no longer contain circular references")
  9650. }
  9651. } else {
  9652. if (fluid.get(component, fluid.path("options", "components", thisSeg, "type"))) {
  9653. fluid.initDependent(component, thisSeg);
  9654. atval = component[thisSeg]
  9655. }
  9656. }
  9657. return atval
  9658. }
  9659. }
  9660. fluid.dumpThat = function (that, instantiator) {
  9661. return '{ typeName: "' + that.typeName + '" id: ' + that.id + "}"
  9662. };
  9663. fluid.dumpThatStack = function (thatStack, instantiator) {
  9664. var togo = fluid.transform(thatStack, function (that) {
  9665. var path = instantiator.idToPath[that.id];
  9666. return fluid.dumpThat(that) + (path ? (" - path: " + path) : "")
  9667. });
  9668. return togo.join("\n")
  9669. };
  9670. fluid.describeActivity = function () {
  9671. return fluid.threadLocal().activityStack || []
  9672. };
  9673. fluid.pushActivity = function (func, message) {
  9674. if (!message) {
  9675. return func()
  9676. }
  9677. var root = fluid.threadLocal();
  9678. if (!root.activityStack) {
  9679. root.activityStack = []
  9680. }
  9681. var frames = fluid.makeArray(message);
  9682. frames.push("\n");
  9683. frames.unshift("\n");
  9684. root.activityStack = frames.concat(root.activityStack);
  9685. return fluid.tryCatch(func, null, function () {
  9686. root.activityStack = root.activityStack.slice(frames.length)
  9687. })
  9688. };
  9689. fluid.wrapActivity = function (func, messageSpec) {
  9690. return function () {
  9691. var args = fluid.makeArray(arguments);
  9692. var message = fluid.transform(fluid.makeArray(messageSpec), function (specEl) {
  9693. if (specEl.indexOf("arguments.") === 0) {
  9694. var el = specEl.substring("arguments.".length);
  9695. return fluid.get(args, el)
  9696. } else {
  9697. return specEl
  9698. }
  9699. });
  9700. return fluid.pushActivity(function () {
  9701. return func.apply(null, args)
  9702. }, message)
  9703. }
  9704. };
  9705. var localRecordExpected = /arguments|options|container/;
  9706. function makeStackFetcher(instantiator, parentThat, localRecord, expandOptions) {
  9707. expandOptions = expandOptions || {};
  9708. var thatStack = instantiator.getFullStack(parentThat);
  9709. var fetchStrategies = [fluid.model.funcResolverStrategy, makeGingerStrategy(instantiator, parentThat, thatStack)];
  9710. var fetcher = function (parsed) {
  9711. var context = parsed.context;
  9712. if (localRecord && localRecordExpected.test(context)) {
  9713. var fetched = fluid.get(localRecord[context], parsed.path);
  9714. return (context === "arguments" || expandOptions.direct) ? fetched : {
  9715. marker : context === "options" ? fluid.EXPAND : fluid.EXPAND_NOW,
  9716. value : fetched
  9717. }
  9718. }
  9719. var foundComponent;
  9720. visitComponents(thatStack, function (component, name, options, up, down) {
  9721. if (context === name || context === component.typeName || context === component.nickName) {
  9722. foundComponent = component;
  9723. if (down > 1) {
  9724. fluid.log("***WARNING: value resolution for context " + context + " found at depth " + down + ": this may not be supported in future")
  9725. }
  9726. return true
  9727. }
  9728. if (fluid.get(component, fluid.path("options", "components", context, "type")) && !component[context]) {
  9729. foundComponent = fluid.get(component, context, {
  9730. strategies : fetchStrategies
  9731. });
  9732. return true
  9733. }
  9734. });
  9735. if (!foundComponent && parsed.path !== "") {
  9736. var ref = fluid.renderContextReference(parsed);
  9737. fluid.log("Failed to resolve reference " + ref + ": thatStack contains\n" + fluid.dumpThatStack(thatStack, instantiator));
  9738. fluid.fail("Failed to resolve reference " + ref + " - could not match context with name " + context + " from component root of type " + thatStack[0].typeName, "\ninstantiator contents: ", instantiator)
  9739. }
  9740. return fluid.get(foundComponent, parsed.path, fetchStrategies)
  9741. };
  9742. return fetcher
  9743. }
  9744. function makeStackResolverOptions(instantiator, parentThat, localRecord, expandOptions) {
  9745. return $.extend({}, fluid.defaults("fluid.resolveEnvironment"), {
  9746. fetcher : makeStackFetcher(instantiator, parentThat, localRecord, expandOptions)
  9747. })
  9748. }
  9749. fluid.instantiator = function (freeInstantiator) {
  9750. var preThat = {
  9751. options : {
  9752. "fluid.visitComponents.fireBreak" : true
  9753. },
  9754. idToPath : {},
  9755. pathToComponent : {},
  9756. stackCount : 0,
  9757. nickName : "instantiator"
  9758. };
  9759. var that = fluid.typeTag("fluid.instantiator");
  9760. that = $.extend(that, preThat);
  9761. that.stack = function (count) {
  9762. return that.stackCount += count
  9763. };
  9764. that.getThatStack = function (component) {
  9765. var path = that.idToPath[component.id] || "";
  9766. var parsed = fluid.model.parseEL(path);
  9767. var togo = fluid.transform(parsed, function (value, i) {
  9768. var parentPath = fluid.model.composeSegments.apply(null, parsed.slice(0, i + 1));
  9769. return that.pathToComponent[parentPath]
  9770. });
  9771. var root = that.pathToComponent[""];
  9772. if (root) {
  9773. togo.unshift(root)
  9774. }
  9775. return togo
  9776. };
  9777. that.getEnvironmentalStack = function () {
  9778. var togo = [fluid.staticEnvironment];
  9779. if (!freeInstantiator) {
  9780. togo.push(fluid.threadLocal())
  9781. }
  9782. return togo
  9783. };
  9784. that.getFullStack = function (component) {
  9785. var thatStack = component ? that.getThatStack(component) : [];
  9786. return that.getEnvironmentalStack().concat(thatStack)
  9787. };
  9788. function recordComponent(component, path) {
  9789. that.idToPath[component.id] = path;
  9790. if (that.pathToComponent[path]) {
  9791. fluid.fail("Error during instantiation - path " + path + " which has just created component " + fluid.dumpThat(component) + " has already been used for component " + fluid.dumpThat(that.pathToComponent[path]) + " - this is a circular instantiation or other oversight. Please clear the component using instantiator.clearComponent() before reusing the path.")
  9792. }
  9793. that.pathToComponent[path] = component
  9794. }
  9795. that.recordRoot = function (component) {
  9796. if (component && component.id && !that.pathToComponent[""]) {
  9797. recordComponent(component, "")
  9798. }
  9799. };
  9800. that.pushUpcomingInstantiation = function (parent, name) {
  9801. that.expectedParent = parent;
  9802. that.expectedName = name
  9803. };
  9804. that.recordComponent = function (component) {
  9805. if (that.expectedName) {
  9806. that.recordKnownComponent(that.expectedParent, component, that.expectedName);
  9807. delete that.expectedName;
  9808. delete that.expectedParent
  9809. } else {
  9810. that.recordRoot(component)
  9811. }
  9812. };
  9813. that.clearComponent = function (component, name, child, options, noModTree) {
  9814. options = options || {
  9815. visited : {},
  9816. flat : true
  9817. };
  9818. child = child || component[name];
  9819. fluid.visitComponentChildren(child, function (gchild, gchildname) {
  9820. that.clearComponent(child, gchildname, null, options, noModTree)
  9821. }, options);
  9822. var path = that.idToPath[child.id];
  9823. delete that.idToPath[child.id];
  9824. delete that.pathToComponent[path];
  9825. if (!noModTree) {
  9826. delete component[name]
  9827. }
  9828. };
  9829. that.recordKnownComponent = function (parent, component, name) {
  9830. var parentPath = that.idToPath[parent.id] || "";
  9831. var path = fluid.model.composePath(parentPath, name);
  9832. recordComponent(component, path)
  9833. };
  9834. return that
  9835. };
  9836. fluid.freeInstantiator = fluid.instantiator(true);
  9837. fluid.argMapToDemands = function (argMap) {
  9838. var togo = [];
  9839. fluid.each(argMap, function (value, key) {
  9840. togo[value] = "{" + key + "}"
  9841. });
  9842. return togo
  9843. };
  9844. fluid.makePassArgsSpec = function (initArgs) {
  9845. return fluid.transform(initArgs, function (arg, index) {
  9846. return "{arguments}." + index
  9847. })
  9848. };
  9849. function mergeToMergeAll(options) {
  9850. if (options && options.mergeOptions) {
  9851. options.mergeAllOptions = ["{options}"].concat(fluid.makeArray(options.mergeOptions))
  9852. }
  9853. }
  9854. function upgradeMergeOptions(demandspec) {
  9855. mergeToMergeAll(demandspec);
  9856. if (demandspec.mergeAllOptions) {
  9857. if (demandspec.options) {
  9858. fluid.fail("demandspec ", demandspec, " is invalid - cannot specify literal options together with mergeOptions or mergeAllOptions")
  9859. }
  9860. demandspec.options = {
  9861. mergeAllOptions : demandspec.mergeAllOptions
  9862. }
  9863. }
  9864. if (demandspec.options) {
  9865. delete demandspec.options.mergeOptions
  9866. }
  9867. }
  9868. fluid.embodyDemands = function (instantiator, parentThat, demandspec, initArgs, options) {
  9869. options = options || {};
  9870. upgradeMergeOptions(demandspec);
  9871. var oldOptions = fluid.get(options, "componentRecord.options");
  9872. options.componentRecord = $.extend(true, {}, options.componentRecord, fluid.censorKeys(demandspec, ["args", "funcName", "registeredFrom"]));
  9873. var mergeAllZero = fluid.get(options, "componentRecord.options.mergeAllOptions.0");
  9874. if (mergeAllZero === "{options}") {
  9875. fluid.set(options, "componentRecord.options.mergeAllOptions.0", oldOptions)
  9876. }
  9877. var demands = $.makeArray(demandspec.args);
  9878. var upDefaults = fluid.defaults(demandspec.funcName);
  9879. var argMap = upDefaults ? upDefaults.argumentMap : null;
  9880. var inferMap = false;
  9881. if (!argMap && (upDefaults || (options && options.componentRecord)) && !options.passArgs) {
  9882. inferMap = true;
  9883. if (demands.length < 2) {
  9884. argMap = fluid.rawDefaults("fluid.littleComponent").argumentMap
  9885. } else {
  9886. argMap = {
  9887. options : demands.length - 1
  9888. }
  9889. }
  9890. }
  9891. options = options || {};
  9892. if (demands.length === 0) {
  9893. if (options.componentRecord && argMap) {
  9894. demands = fluid.argMapToDemands(argMap)
  9895. } else {
  9896. if (options.passArgs) {
  9897. demands = fluid.makePassArgsSpec(initArgs)
  9898. }
  9899. }
  9900. }
  9901. var localRecord = $.extend({
  9902. arguments : initArgs
  9903. }, fluid.censorKeys(options.componentRecord, ["type"]));
  9904. fluid.each(argMap, function (index, name) {
  9905. if (initArgs.length > 0) {
  9906. localRecord[name] = localRecord.arguments[index]
  9907. }
  9908. if (demandspec[name] !== undefined && localRecord[name] === undefined) {
  9909. localRecord[name] = demandspec[name]
  9910. }
  9911. });
  9912. mergeToMergeAll(localRecord.options);
  9913. mergeToMergeAll(argMap && demands[argMap.options]);
  9914. var upstreamLocalRecord = $.extend({}, localRecord);
  9915. if (options.componentRecord.options !== undefined) {
  9916. upstreamLocalRecord.options = options.componentRecord.options
  9917. }
  9918. var expandOptions = makeStackResolverOptions(instantiator, parentThat, localRecord);
  9919. var args = [];
  9920. if (demands) {
  9921. for (var i = 0; i < demands.length; ++i) {
  9922. var arg = demands[i];
  9923. if (fluid.isMarker(arg) && arg.value === fluid.COMPONENT_OPTIONS.value) {
  9924. arg = "{options}";
  9925. if (inferMap) {
  9926. argMap = {
  9927. options : i
  9928. }
  9929. }
  9930. }
  9931. if (typeof(arg) === "string") {
  9932. if (arg.charAt(0) === "@") {
  9933. var argpos = arg.substring(1);
  9934. arg = "{arguments}." + argpos
  9935. }
  9936. }
  9937. if (!argMap || argMap.options !== i) {
  9938. args[i] = fluid.expander.expandLight(arg, expandOptions)
  9939. } else {
  9940. if (arg && typeof(arg) === "object" && !arg.targetTypeName) {
  9941. arg.targetTypeName = demandspec.funcName
  9942. }
  9943. args[i] = {
  9944. marker : fluid.EXPAND,
  9945. value : fluid.copy(arg),
  9946. localRecord : upstreamLocalRecord
  9947. }
  9948. }
  9949. if (args[i] && fluid.isMarker(args[i].marker, fluid.EXPAND_NOW)) {
  9950. args[i] = fluid.expander.expandLight(args[i].value, expandOptions)
  9951. }
  9952. }
  9953. } else {
  9954. args = initArgs ? initArgs : []
  9955. }
  9956. var togo = {
  9957. args : args,
  9958. funcName : demandspec.funcName
  9959. };
  9960. return togo
  9961. };
  9962. var aliasTable = {};
  9963. fluid.alias = function (demandingName, aliasName) {
  9964. if (aliasName) {
  9965. aliasTable[demandingName] = aliasName
  9966. } else {
  9967. return aliasTable[demandingName]
  9968. }
  9969. };
  9970. var dependentStore = {};
  9971. function searchDemands(demandingName, contextNames) {
  9972. var exist = dependentStore[demandingName] || [];
  9973. outer : for (var i = 0; i < exist.length; ++i) {
  9974. var rec = exist[i];
  9975. for (var j = 0; j < contextNames.length; ++j) {
  9976. if (rec.contexts[j] !== contextNames[j]) {
  9977. continue outer
  9978. }
  9979. }
  9980. return rec.spec
  9981. }
  9982. }
  9983. fluid.demands = function (demandingName, contextName, spec) {
  9984. var contextNames = $.makeArray(contextName).sort();
  9985. if (!spec) {
  9986. return searchDemands(demandingName, contextNames)
  9987. } else {
  9988. if (spec.length) {
  9989. spec = {
  9990. args : spec
  9991. }
  9992. }
  9993. }
  9994. if (fluid.getCallerInfo) {
  9995. var callerInfo = fluid.getCallerInfo(5);
  9996. if (callerInfo) {
  9997. spec.registeredFrom = callerInfo
  9998. }
  9999. }
  10000. var exist = dependentStore[demandingName];
  10001. if (!exist) {
  10002. exist = [];
  10003. dependentStore[demandingName] = exist
  10004. }
  10005. exist.push({
  10006. contexts : contextNames,
  10007. spec : spec
  10008. })
  10009. };
  10010. fluid.compareDemands = function (speca, specb) {
  10011. var p1 = speca.uncess - specb.uncess;
  10012. return p1 === 0 ? specb.intersect - speca.intersect : p1
  10013. };
  10014. fluid.isDemandLogging = function (demandingNames) {
  10015. return fluid.isLogging() && demandingNames[0] !== "fluid.threadLocal"
  10016. };
  10017. fluid.locateAllDemands = function (instantiator, parentThat, demandingNames) {
  10018. var demandLogging = fluid.isDemandLogging(demandingNames);
  10019. if (demandLogging) {
  10020. fluid.log("Resolving demands for function names ", demandingNames, " in context of " + (parentThat ? "component " + parentThat.typeName : "no component"))
  10021. }
  10022. var contextNames = {};
  10023. var visited = [];
  10024. var thatStack = instantiator.getFullStack(parentThat);
  10025. visitComponents(thatStack, function (component, xname, options, up, down) {
  10026. contextNames[component.typeName] = true;
  10027. visited.push(component)
  10028. });
  10029. if (demandLogging) {
  10030. fluid.log("Components in scope for resolution:\n" + fluid.dumpThatStack(visited, instantiator))
  10031. }
  10032. var matches = [];
  10033. for (var i = 0; i < demandingNames.length; ++i) {
  10034. var rec = dependentStore[demandingNames[i]] || [];
  10035. for (var j = 0; j < rec.length; ++j) {
  10036. var spec = rec[j];
  10037. var record = {
  10038. spec : spec,
  10039. intersect : 0,
  10040. uncess : 0
  10041. };
  10042. for (var k = 0; k < spec.contexts.length; ++k) {
  10043. record[contextNames[spec.contexts[k]] ? "intersect" : "uncess"] += 2
  10044. }
  10045. if (spec.contexts.length === 0) {
  10046. record.intersect++
  10047. }
  10048. matches.push(record)
  10049. }
  10050. }
  10051. matches.sort(fluid.compareDemands);
  10052. return matches
  10053. };
  10054. fluid.locateDemands = function (instantiator, parentThat, demandingNames) {
  10055. var matches = fluid.locateAllDemands(instantiator, parentThat, demandingNames);
  10056. var demandspec = matches.length === 0 || matches[0].intersect === 0 ? null : matches[0].spec.spec;
  10057. if (fluid.isDemandLogging(demandingNames)) {
  10058. if (demandspec) {
  10059. fluid.log("Located " + matches.length + " potential match" + (matches.length === 1 ? "" : "es") + ", selected best match with " + matches[0].intersect + " matched context names: ", demandspec)
  10060. } else {
  10061. fluid.log("No matches found for demands, using direct implementation")
  10062. }
  10063. }
  10064. return demandspec
  10065. };
  10066. fluid.determineDemands = function (instantiator, parentThat, funcNames) {
  10067. funcNames = $.makeArray(funcNames);
  10068. var newFuncName = funcNames[0];
  10069. var demandspec = fluid.locateDemands(instantiator, parentThat, funcNames) || {};
  10070. if (demandspec.funcName) {
  10071. newFuncName = demandspec.funcName
  10072. }
  10073. var aliasTo = fluid.alias(newFuncName);
  10074. if (aliasTo) {
  10075. newFuncName = aliasTo;
  10076. fluid.log("Following redirect from function name " + newFuncName + " to " + aliasTo);
  10077. var demandspec2 = fluid.locateDemands(instantiator, parentThat, [aliasTo]);
  10078. if (demandspec2) {
  10079. fluid.each(demandspec2, function (value, key) {
  10080. if (localRecordExpected.test(key)) {
  10081. fluid.fail("Error in demands block ", demandspec2, ' - content with key "' + key + '" is not supported since this demands block was resolved via an alias from "' + newFuncName + '"')
  10082. }
  10083. });
  10084. if (demandspec2.funcName) {
  10085. newFuncName = demandspec2.funcName;
  10086. fluid.log('Followed final inner demands to function name "' + newFuncName + '"')
  10087. }
  10088. }
  10089. }
  10090. return fluid.merge(null, {
  10091. funcName : newFuncName,
  10092. args : fluid.makeArray(demandspec.args)
  10093. }, fluid.censorKeys(demandspec, ["funcName", "args"]))
  10094. };
  10095. fluid.resolveDemands = function (instantiator, parentThat, funcNames, initArgs, options) {
  10096. var demandspec = fluid.determineDemands(instantiator, parentThat, funcNames);
  10097. return fluid.embodyDemands(instantiator, parentThat, demandspec, initArgs, options)
  10098. };
  10099. fluid.invoke = function (functionName, args, that, environment) {
  10100. args = fluid.makeArray(args);
  10101. return fluid.withInstantiator(that, function (instantiator) {
  10102. var invokeSpec = fluid.resolveDemands(instantiator, that, functionName, args, {
  10103. passArgs : true
  10104. });
  10105. return fluid.invokeGlobalFunction(invokeSpec.funcName, invokeSpec.args, environment)
  10106. })
  10107. };
  10108. fluid.invoke = fluid.wrapActivity(fluid.invoke, [' while invoking function with name "', "arguments.0", '" from component', "arguments.2"]);
  10109. fluid.makeFreeInvoker = function (functionName, environment) {
  10110. var demandSpec = fluid.determineDemands(fluid.freeInstantiator, null, functionName);
  10111. return function () {
  10112. var invokeSpec = fluid.embodyDemands(fluid.freeInstantiator, null, demandSpec, arguments, {
  10113. passArgs : true
  10114. });
  10115. return fluid.invokeGlobalFunction(invokeSpec.funcName, invokeSpec.args, environment)
  10116. }
  10117. };
  10118. fluid.makeInvoker = function (instantiator, that, demandspec, functionName, environment) {
  10119. demandspec = demandspec || fluid.determineDemands(instantiator, that, functionName);
  10120. return function () {
  10121. var args = arguments;
  10122. return fluid.pushActivity(function () {
  10123. var invokeSpec = fluid.embodyDemands(instantiator, that, demandspec, args, {
  10124. passArgs : true
  10125. });
  10126. return fluid.invokeGlobalFunction(invokeSpec.funcName, invokeSpec.args, environment)
  10127. }, [" while invoking invoker with name " + functionName + " on component", that])
  10128. }
  10129. };
  10130. fluid.event.dispatchListener = function (instantiator, that, listener, eventName, eventSpec) {
  10131. return function () {
  10132. var demandspec = fluid.determineDemands(instantiator, that, eventName);
  10133. if (demandspec.args.length === 0 && eventSpec.args) {
  10134. demandspec.args = eventSpec.args
  10135. }
  10136. var resolved = fluid.embodyDemands(instantiator, that, demandspec, arguments, {
  10137. passArgs : true,
  10138. componentOptions : eventSpec
  10139. });
  10140. listener.apply(null, resolved.args)
  10141. }
  10142. };
  10143. fluid.event.resolveEvent = function (that, eventName, eventSpec) {
  10144. return fluid.withInstantiator(that, function (instantiator) {
  10145. if (typeof(eventSpec) === "string") {
  10146. var firer = fluid.expandOptions(eventSpec, that);
  10147. if (!firer) {
  10148. fluid.fail("Error in fluid.event.resolveEvent - context path " + eventSpec + " could not be looked up to a valid event firer")
  10149. }
  10150. return firer
  10151. } else {
  10152. var event = eventSpec.event;
  10153. var origin;
  10154. if (!event) {
  10155. fluid.fail("Event specification for event with name " + eventName + " does not include a base event specification")
  10156. }
  10157. if (event.charAt(0) === "{") {
  10158. origin = fluid.expandOptions(event, that)
  10159. } else {
  10160. origin = that.events[event]
  10161. }
  10162. if (!origin) {
  10163. fluid.fail("Error in event specification - could not resolve base event reference " + event + " to an event firer")
  10164. }
  10165. var firer = {};
  10166. fluid.each(["fire", "removeListener"], function (method) {
  10167. firer[method] = function () {
  10168. origin[method].apply(null, arguments)
  10169. }
  10170. });
  10171. firer.addListener = function (listener, namespace, predicate, priority) {
  10172. origin.addListener(fluid.event.dispatchListener(instantiator, that, listener, eventName, eventSpec), namespace, predicate, priority)
  10173. };
  10174. return firer
  10175. }
  10176. })
  10177. };
  10178. fluid.registerNamespace("fluid.expander");
  10179. fluid.expander.preserveFromExpansion = function (options) {
  10180. var preserve = {};
  10181. var preserveList = fluid.arrayToHash(["mergePolicy", "mergeAllOptions", "components", "invokers", "events", "listeners", "transformOptions"]);
  10182. fluid.each(options.mergePolicy, function (value, key) {
  10183. if (fluid.mergePolicyIs(value, "noexpand")) {
  10184. preserveList[key] = true
  10185. }
  10186. });
  10187. fluid.each(preserveList, function (xvalue, path) {
  10188. var pen = fluid.model.getPenultimate(options, path);
  10189. var value = pen.root[pen.last];
  10190. delete pen.root[pen.last];
  10191. fluid.set(preserve, path, value)
  10192. });
  10193. return {
  10194. restore : function (target) {
  10195. fluid.each(preserveList, function (xvalue, path) {
  10196. var preserved = fluid.get(preserve, path);
  10197. if (preserved !== undefined) {
  10198. fluid.set(target, path, preserved)
  10199. }
  10200. })
  10201. }
  10202. }
  10203. };
  10204. fluid.expandOptions = function (args, that, localRecord, outerExpandOptions) {
  10205. if (!args) {
  10206. return args
  10207. }
  10208. return fluid.withInstantiator(that, function (instantiator) {
  10209. var expandOptions = makeStackResolverOptions(instantiator, that, localRecord, outerExpandOptions);
  10210. expandOptions.noCopy = true;
  10211. var pres;
  10212. if (!fluid.isArrayable(args) && !fluid.isPrimitive(args)) {
  10213. pres = fluid.expander.preserveFromExpansion(args)
  10214. }
  10215. var expanded = fluid.expander.expandLight(args, expandOptions);
  10216. if (pres) {
  10217. pres.restore(expanded)
  10218. }
  10219. return expanded
  10220. })
  10221. };
  10222. fluid.locateTransformationRecord = function (that) {
  10223. return fluid.withInstantiator(that, function (instantiator) {
  10224. var matches = fluid.locateAllDemands(instantiator, that, ["fluid.transformOptions"]);
  10225. return fluid.find(matches, function (match) {
  10226. return match.uncess === 0 && fluid.contains(match.spec.contexts, that.typeName) ? match.spec.spec : undefined
  10227. })
  10228. })
  10229. };
  10230. fluid.hashToArray = function (hash) {
  10231. var togo = [];
  10232. fluid.each(hash, function (value, key) {
  10233. togo.push(key)
  10234. });
  10235. return togo
  10236. };
  10237. fluid.localRecordExpected = ["type", "options", "arguments", "mergeOptions", "mergeAllOptions", "createOnEvent", "priority"];
  10238. fluid.checkComponentRecord = function (defaults, localRecord) {
  10239. var expected = fluid.arrayToHash(fluid.localRecordExpected);
  10240. fluid.each(defaults.argumentMap, function (value, key) {
  10241. expected[key] = true
  10242. });
  10243. fluid.each(localRecord, function (value, key) {
  10244. if (!expected[key]) {
  10245. fluid.fail('Probable error in subcomponent record - key "' + key + '" found, where the only legal options are ' + fluid.hashToArray(expected).join(", "))
  10246. }
  10247. })
  10248. };
  10249. fluid.expandComponentOptions = function (defaults, userOptions, that) {
  10250. if (userOptions && userOptions.localRecord) {
  10251. fluid.checkComponentRecord(defaults, userOptions.localRecord)
  10252. }
  10253. defaults = fluid.expandOptions(fluid.copy(defaults), that);
  10254. var localRecord = {};
  10255. if (userOptions && userOptions.marker === fluid.EXPAND) {
  10256. var localOptions = fluid.get(userOptions, "localRecord.options");
  10257. if (localOptions) {
  10258. if (defaults && defaults.mergePolicy) {
  10259. localOptions.mergePolicy = defaults.mergePolicy
  10260. }
  10261. localRecord.options = fluid.expandOptions(localOptions, that)
  10262. }
  10263. localRecord.arguments = fluid.get(userOptions, "localRecord.arguments");
  10264. var toExpand = userOptions.value;
  10265. userOptions = fluid.expandOptions(toExpand, that, localRecord, {
  10266. direct : true
  10267. })
  10268. }
  10269. localRecord.directOptions = userOptions;
  10270. if (!localRecord.options) {
  10271. localRecord.options = userOptions
  10272. }
  10273. var mergeOptions = (userOptions && userOptions.mergeAllOptions) || ["{directOptions}"];
  10274. var togo = fluid.transform(mergeOptions, function (path) {
  10275. return path === "{directOptions}" ? localRecord.directOptions : fluid.expandOptions(path, that, localRecord, {
  10276. direct : true
  10277. })
  10278. });
  10279. var transRec = fluid.locateTransformationRecord(that);
  10280. if (transRec) {
  10281. togo[0].transformOptions = transRec.options
  10282. }
  10283. return [defaults].concat(togo)
  10284. };
  10285. fluid.expandComponentOptions = fluid.wrapActivity(fluid.expandComponentOptions, [" while expanding component options ", "arguments.1.value", " with record ", "arguments.1", " for component ", "arguments.2"]);
  10286. fluid.initDependent = function (that, name, userInstantiator, directArgs) {
  10287. if (!that || that[name]) {
  10288. return
  10289. }
  10290. fluid.log('Beginning instantiation of component with name "' + name + '" as child of ' + fluid.dumpThat(that));
  10291. directArgs = directArgs || [];
  10292. var root = fluid.threadLocal();
  10293. if (userInstantiator) {
  10294. var existing = root["fluid.instantiator"];
  10295. if (existing && existing !== userInstantiator) {
  10296. fluid.fail("Error in initDependent: user instantiator supplied with id " + userInstantiator.id + " which differs from that for currently active instantiation with id " + existing.id)
  10297. } else {
  10298. root["fluid.instantiator"] = userInstantiator
  10299. }
  10300. }
  10301. var component = that.options.components[name];
  10302. fluid.withInstantiator(that, function (instantiator) {
  10303. if (typeof(component) === "string") {
  10304. that[name] = fluid.expandOptions([component], that)[0]
  10305. } else {
  10306. if (component.type) {
  10307. var invokeSpec = fluid.resolveDemands(instantiator, that, [component.type, name], directArgs, {
  10308. componentRecord : component
  10309. });
  10310. instantiator.pushUpcomingInstantiation(that, name);
  10311. fluid.tryCatch(function () {
  10312. that[inCreationMarker] = true;
  10313. var instance = fluid.initSubcomponentImpl(that, {
  10314. type : invokeSpec.funcName
  10315. }, invokeSpec.args);
  10316. var path = fluid.composePath(instantiator.idToPath[that.id] || "", name);
  10317. var existing = instantiator.pathToComponent[path];
  10318. if (existing && existing !== instance) {
  10319. instantiator.clearComponent(that, name, existing, null, true)
  10320. }
  10321. if (instance && instance.typeName && instance.id && instance !== existing) {
  10322. instantiator.recordKnownComponent(that, instance, name)
  10323. }
  10324. that[name] = instance
  10325. }, null, function () {
  10326. delete that[inCreationMarker];
  10327. instantiator.pushUpcomingInstantiation()
  10328. })
  10329. } else {
  10330. that[name] = component
  10331. }
  10332. }
  10333. }, [' while instantiating dependent component with name "' + name + '" with record ', component, " as child of ", that]);
  10334. fluid.log('Finished instantiation of component with name "' + name + '" as child of ' + fluid.dumpThat(that))
  10335. };
  10336. fluid.withInstantiator = function (that, func, message) {
  10337. var root = fluid.threadLocal();
  10338. var instantiator = root["fluid.instantiator"];
  10339. if (!instantiator) {
  10340. instantiator = root["fluid.instantiator"] = fluid.instantiator()
  10341. }
  10342. return fluid.pushActivity(function () {
  10343. return fluid.tryCatch(function () {
  10344. if (that) {
  10345. instantiator.recordComponent(that)
  10346. }
  10347. instantiator.stack(1);
  10348. return func(instantiator)
  10349. }, null, function () {
  10350. var count = instantiator.stack(-1);
  10351. if (count === 0) {
  10352. delete root["fluid.instantiator"]
  10353. }
  10354. })
  10355. }, message)
  10356. };
  10357. fluid.bindDeferredComponent = function (that, componentName, component, instantiator) {
  10358. var events = fluid.makeArray(component.createOnEvent);
  10359. fluid.each(events, function (eventName) {
  10360. that.events[eventName].addListener(function () {
  10361. if (that[componentName]) {
  10362. instantiator.clearComponent(that, componentName)
  10363. }
  10364. fluid.initDependent(that, componentName, instantiator)
  10365. }, null, null, component.priority)
  10366. })
  10367. };
  10368. fluid.priorityForComponent = function (component) {
  10369. return component.priority ? component.priority : (component.type === "fluid.typeFount" || fluid.hasGrade(fluid.defaults(component.type), "fluid.typeFount")) ? "first" : undefined
  10370. };
  10371. fluid.initDependents = function (that) {
  10372. var options = that.options;
  10373. var components = options.components || {};
  10374. var componentSort = {};
  10375. fluid.withInstantiator(that, function (instantiator) {
  10376. fluid.each(components, function (component, name) {
  10377. if (!component.createOnEvent) {
  10378. var priority = fluid.priorityForComponent(component);
  10379. componentSort[name] = {
  10380. key : name,
  10381. priority : fluid.event.mapPriority(priority, 0)
  10382. }
  10383. } else {
  10384. fluid.bindDeferredComponent(that, name, component, instantiator)
  10385. }
  10386. });
  10387. var componentList = fluid.event.sortListeners(componentSort);
  10388. fluid.each(componentList, function (entry) {
  10389. fluid.initDependent(that, entry.key)
  10390. });
  10391. var invokers = options.invokers || {};
  10392. for (var name in invokers) {
  10393. var invokerec = invokers[name];
  10394. var funcName = typeof(invokerec) === "string" ? invokerec : null;
  10395. that[name] = fluid.withInstantiator(that, function (instantiator) {
  10396. fluid.log('Beginning instantiation of invoker with name "' + name + '" as child of ' + fluid.dumpThat(that));
  10397. return fluid.makeInvoker(instantiator, that, funcName ? null : invokerec, funcName)
  10398. }, [' while instantiating invoker with name "' + name + '" with record ', invokerec, " as child of ", that]);
  10399. fluid.log('Finished instantiation of invoker with name "' + name + '" as child of ' + fluid.dumpThat(that))
  10400. }
  10401. })
  10402. };
  10403. fluid.staticEnvironment = fluid.typeTag("fluid.staticEnvironment");
  10404. fluid.staticEnvironment.environmentClass = fluid.typeTag("fluid.browser");
  10405. fluid.demands("fluid.threadLocal", "fluid.browser", {
  10406. funcName : "fluid.singleThreadLocal"
  10407. });
  10408. var singleThreadLocal = fluid.typeTag("fluid.dynamicEnvironment");
  10409. fluid.singleThreadLocal = function () {
  10410. return singleThreadLocal
  10411. };
  10412. fluid.threadLocal = function () {
  10413. var demands = fluid.locateDemands(fluid.freeInstantiator, null, ["fluid.threadLocal"]);
  10414. return fluid.invokeGlobalFunction(demands.funcName, arguments)
  10415. };
  10416. function applyLocalChange(applier, type, path, value) {
  10417. var change = {
  10418. type : type,
  10419. path : path,
  10420. value : value
  10421. };
  10422. applier.fireChangeRequest(change)
  10423. }
  10424. fluid.withEnvironment = function (envAdd, func, prefix) {
  10425. prefix = prefix || "";
  10426. var root = fluid.threadLocal();
  10427. var applier = fluid.makeChangeApplier(root, {
  10428. thin : true
  10429. });
  10430. return fluid.tryCatch(function () {
  10431. for (var key in envAdd) {
  10432. applyLocalChange(applier, "ADD", fluid.model.composePath(prefix, key), envAdd[key])
  10433. }
  10434. $.extend(root, envAdd);
  10435. return func()
  10436. }, null, function () {
  10437. for (var key in envAdd) {
  10438. applyLocalChange(applier, "DELETE", fluid.model.composePath(prefix, key))
  10439. }
  10440. })
  10441. };
  10442. fluid.makeEnvironmentFetcher = function (prefix, directModel) {
  10443. return function (parsed) {
  10444. var env = fluid.get(fluid.threadLocal(), prefix);
  10445. return fluid.fetchContextReference(parsed, directModel, env)
  10446. }
  10447. };
  10448. fluid.extractEL = function (string, options) {
  10449. if (options.ELstyle === "ALL") {
  10450. return string
  10451. } else {
  10452. if (options.ELstyle.length === 1) {
  10453. if (string.charAt(0) === options.ELstyle) {
  10454. return string.substring(1)
  10455. }
  10456. } else {
  10457. if (options.ELstyle === "${}") {
  10458. var i1 = string.indexOf("${");
  10459. var i2 = string.lastIndexOf("}");
  10460. if (i1 === 0 && i2 !== -1) {
  10461. return string.substring(2, i2)
  10462. }
  10463. }
  10464. }
  10465. }
  10466. };
  10467. fluid.extractELWithContext = function (string, options) {
  10468. var EL = fluid.extractEL(string, options);
  10469. if (EL && EL.charAt(0) === "{") {
  10470. return fluid.parseContextReference(EL, 0)
  10471. }
  10472. return EL ? {
  10473. path : EL
  10474. }
  10475. : EL
  10476. };
  10477. fluid.parseContextReference = function (reference, index, delimiter) {
  10478. var endcpos = reference.indexOf("}", index + 1);
  10479. if (endcpos === -1) {
  10480. fluid.fail('Cannot parse context reference "' + reference + '": Malformed context reference without }')
  10481. }
  10482. var context = reference.substring(index + 1, endcpos);
  10483. var endpos = delimiter ? reference.indexOf(delimiter, endcpos + 1) : reference.length;
  10484. var path = reference.substring(endcpos + 1, endpos);
  10485. if (path.charAt(0) === ".") {
  10486. path = path.substring(1)
  10487. }
  10488. return {
  10489. context : context,
  10490. path : path,
  10491. endpos : endpos
  10492. }
  10493. };
  10494. fluid.renderContextReference = function (parsed) {
  10495. return "{" + parsed.context + "}" + parsed.path
  10496. };
  10497. fluid.fetchContextReference = function (parsed, directModel, env) {
  10498. var base = parsed.context ? env[parsed.context] : directModel;
  10499. if (!base) {
  10500. return base
  10501. }
  10502. return fluid.get(base, parsed.path)
  10503. };
  10504. fluid.resolveContextValue = function (string, options) {
  10505. if (options.bareContextRefs && string.charAt(0) === "{") {
  10506. var parsed = fluid.parseContextReference(string, 0);
  10507. return options.fetcher(parsed)
  10508. } else {
  10509. if (options.ELstyle && options.ELstyle !== "${}") {
  10510. var parsed = fluid.extractELWithContext(string, options);
  10511. if (parsed) {
  10512. return options.fetcher(parsed)
  10513. }
  10514. }
  10515. }
  10516. while (typeof(string) === "string") {
  10517. var i1 = string.indexOf("${");
  10518. var i2 = string.indexOf("}", i1 + 2);
  10519. if (i1 !== -1 && i2 !== -1) {
  10520. var parsed;
  10521. if (string.charAt(i1 + 2) === "{") {
  10522. parsed = fluid.parseContextReference(string, i1 + 2, "}");
  10523. i2 = parsed.endpos
  10524. } else {
  10525. parsed = {
  10526. path : string.substring(i1 + 2, i2)
  10527. }
  10528. }
  10529. var subs = options.fetcher(parsed);
  10530. var all = (i1 === 0 && i2 === string.length - 1);
  10531. if (subs === undefined || subs === null) {
  10532. return subs
  10533. }
  10534. string = all ? subs : string.substring(0, i1) + subs + string.substring(i2 + 1)
  10535. } else {
  10536. break
  10537. }
  10538. }
  10539. return string
  10540. };
  10541. fluid.resolveContextValue = fluid.wrapActivity(fluid.resolveContextValue, [" while resolving context value ", "arguments.0"]);
  10542. function resolveEnvironmentImpl(obj, options) {
  10543. fluid.guardCircularity(options.seenIds, obj, "expansion", ' - please ensure options are not circularly connected, or protect from expansion using the "noexpand" policy or expander');
  10544. function recurse(arg) {
  10545. return resolveEnvironmentImpl(arg, options)
  10546. }
  10547. if (typeof(obj) === "string" && !options.noValue) {
  10548. return fluid.resolveContextValue(obj, options)
  10549. } else {
  10550. if (fluid.isPrimitive(obj) || obj.nodeType !== undefined || obj.jquery) {
  10551. return obj
  10552. } else {
  10553. if (options.filter) {
  10554. return options.filter(obj, recurse, options)
  10555. } else {
  10556. return (options.noCopy ? fluid.each : fluid.transform)(obj, function (value, key) {
  10557. return resolveEnvironmentImpl(value, options)
  10558. })
  10559. }
  10560. }
  10561. }
  10562. }
  10563. fluid.defaults("fluid.resolveEnvironment", {
  10564. ELstyle : "${}",
  10565. seenIds : {},
  10566. bareContextRefs : true
  10567. });
  10568. fluid.resolveEnvironment = function (obj, options) {
  10569. options = $.extend(true, {}, fluid.rawDefaults("fluid.resolveEnvironment"), options);
  10570. return resolveEnvironmentImpl(obj, options)
  10571. };
  10572. fluid.expander.deferredCall = function (target, source, recurse) {
  10573. var expander = source.expander;
  10574. var args = (!expander.args || fluid.isArrayable(expander.args)) ? expander.args : $.makeArray(expander.args);
  10575. args = recurse(args);
  10576. return fluid.invokeGlobalFunction(expander.func, args)
  10577. };
  10578. fluid.deferredCall = fluid.expander.deferredCall;
  10579. fluid.deferredInvokeCall = function (target, source, recurse) {
  10580. var expander = source.expander;
  10581. var args = (!expander.args || fluid.isArrayable(expander.args)) ? expander.args : $.makeArray(expander.args);
  10582. args = recurse(args);
  10583. return fluid.invoke(expander.func, args)
  10584. };
  10585. fluid.expander.noexpand = function (target, source) {
  10586. return $.extend(target, source.expander.tree)
  10587. };
  10588. fluid.noexpand = fluid.expander.noexpand;
  10589. fluid.expander.lightFilter = function (obj, recurse, options) {
  10590. var togo;
  10591. if (fluid.isArrayable(obj)) {
  10592. togo = options.noCopy ? obj : [];
  10593. fluid.each(obj, function (value, key) {
  10594. togo[key] = recurse(value)
  10595. })
  10596. } else {
  10597. togo = options.noCopy ? obj : {};
  10598. for (var key in obj) {
  10599. var value = obj[key];
  10600. var expander;
  10601. if (key === "expander" && !(options.expandOnly && options.expandOnly[value.type])) {
  10602. expander = fluid.getGlobalValue(value.type);
  10603. if (expander) {
  10604. return expander.call(null, togo, obj, recurse, options)
  10605. }
  10606. }
  10607. if (key !== "expander" || !expander) {
  10608. togo[key] = recurse(value)
  10609. }
  10610. }
  10611. }
  10612. return options.noCopy ? obj : togo
  10613. };
  10614. fluid.expander.expandLight = function (source, expandOptions) {
  10615. var options = $.extend({}, expandOptions);
  10616. options.filter = fluid.expander.lightFilter;
  10617. return fluid.resolveEnvironment(source, options)
  10618. }
  10619. })(jQuery, fluid_1_4);
  10620. var fluid_1_4 = fluid_1_4 || {};
  10621. (function ($, fluid) {
  10622. var resourceCache = {};
  10623. var pendingClass = {};
  10624. fluid.fetchResources = function (resourceSpecs, callback, options) {
  10625. var that = fluid.initLittleComponent("fluid.fetchResources", options);
  10626. that.resourceSpecs = resourceSpecs;
  10627. that.callback = callback;
  10628. that.operate = function () {
  10629. fluid.fetchResources.fetchResourcesImpl(that)
  10630. };
  10631. fluid.each(resourceSpecs, function (resourceSpec) {
  10632. resourceSpec.recurseFirer = fluid.event.getEventFirer();
  10633. resourceSpec.recurseFirer.addListener(that.operate);
  10634. if (resourceSpec.url && !resourceSpec.href) {
  10635. resourceSpec.href = resourceSpec.url
  10636. }
  10637. });
  10638. if (that.options.amalgamateClasses) {
  10639. fluid.fetchResources.amalgamateClasses(resourceSpecs, that.options.amalgamateClasses, that.operate)
  10640. }
  10641. that.operate();
  10642. return that
  10643. };
  10644. fluid.fetchResources.amalgamateClasses = function (specs, classes, operator) {
  10645. fluid.each(classes, function (clazz) {
  10646. var pending = pendingClass[clazz];
  10647. fluid.each(pending, function (pendingrec, canon) {
  10648. specs[clazz + "!" + canon] = pendingrec;
  10649. pendingrec.recurseFirer.addListener(operator)
  10650. })
  10651. })
  10652. };
  10653. fluid.fetchResources.timeSuccessCallback = function (resourceSpec) {
  10654. if (resourceSpec.timeSuccess && resourceSpec.options && resourceSpec.options.success) {
  10655. var success = resourceSpec.options.success;
  10656. resourceSpec.options.success = function () {
  10657. var startTime = new Date();
  10658. var ret = success.apply(null, arguments);
  10659. fluid.log("External callback for URL " + resourceSpec.href + " completed - callback time: " + (new Date().getTime() - startTime.getTime()) + "ms");
  10660. return ret
  10661. }
  10662. }
  10663. };
  10664. function canonUrl(url) {
  10665. return url
  10666. }
  10667. fluid.fetchResources.clearResourceCache = function (url) {
  10668. if (url) {
  10669. delete resourceCache[canonUrl(url)]
  10670. } else {
  10671. fluid.clear(resourceCache)
  10672. }
  10673. };
  10674. fluid.fetchResources.handleCachedRequest = function (resourceSpec, response) {
  10675. var canon = canonUrl(resourceSpec.href);
  10676. var cached = resourceCache[canon];
  10677. if (cached.$$firer$$) {
  10678. fluid.log("Handling request for " + canon + " from cache");
  10679. var fetchClass = resourceSpec.fetchClass;
  10680. if (fetchClass && pendingClass[fetchClass]) {
  10681. fluid.log("Clearing pendingClass entry for class " + fetchClass);
  10682. delete pendingClass[fetchClass][canon]
  10683. }
  10684. resourceCache[canon] = response;
  10685. cached.fire(response)
  10686. }
  10687. };
  10688. fluid.fetchResources.completeRequest = function (thisSpec, recurseCall) {
  10689. thisSpec.queued = false;
  10690. thisSpec.completeTime = new Date();
  10691. fluid.log("Request to URL " + thisSpec.href + " completed - total elapsed time: " + (thisSpec.completeTime.getTime() - thisSpec.initTime.getTime()) + "ms");
  10692. thisSpec.recurseFirer.fire()
  10693. };
  10694. fluid.fetchResources.makeResourceCallback = function (thisSpec) {
  10695. return {
  10696. success : function (response) {
  10697. thisSpec.resourceText = response;
  10698. thisSpec.resourceKey = thisSpec.href;
  10699. if (thisSpec.forceCache) {
  10700. fluid.fetchResources.handleCachedRequest(thisSpec, response)
  10701. }
  10702. fluid.fetchResources.completeRequest(thisSpec)
  10703. },
  10704. error : function (response, textStatus, errorThrown) {
  10705. thisSpec.fetchError = {
  10706. status : response.status,
  10707. textStatus : response.textStatus,
  10708. errorThrown : errorThrown
  10709. };
  10710. fluid.fetchResources.completeRequest(thisSpec)
  10711. }
  10712. }
  10713. };
  10714. fluid.fetchResources.issueCachedRequest = function (resourceSpec, options) {
  10715. var canon = canonUrl(resourceSpec.href);
  10716. var cached = resourceCache[canon];
  10717. if (!cached) {
  10718. fluid.log("First request for cached resource with url " + canon);
  10719. cached = fluid.event.getEventFirer();
  10720. cached.$$firer$$ = true;
  10721. resourceCache[canon] = cached;
  10722. var fetchClass = resourceSpec.fetchClass;
  10723. if (fetchClass) {
  10724. if (!pendingClass[fetchClass]) {
  10725. pendingClass[fetchClass] = {}
  10726. }
  10727. pendingClass[fetchClass][canon] = resourceSpec
  10728. }
  10729. options.cache = false;
  10730. $.ajax(options)
  10731. } else {
  10732. if (!cached.$$firer$$) {
  10733. options.success(cached)
  10734. } else {
  10735. fluid.log("Request for cached resource which is in flight: url " + canon);
  10736. cached.addListener(function (response) {
  10737. options.success(response)
  10738. })
  10739. }
  10740. }
  10741. };
  10742. fluid.fetchResources.composeCallbacks = function (internal, external) {
  10743. return external ? function () {
  10744. try {
  10745. external.apply(null, arguments)
  10746. } catch (e) {
  10747. fluid.log("Exception applying external fetchResources callback: " + e)
  10748. }
  10749. internal.apply(null, arguments)
  10750. }
  10751. : internal
  10752. };
  10753. fluid.fetchResources.composePolicy = function (target, source, key) {
  10754. return fluid.fetchResources.composeCallbacks(target, source)
  10755. };
  10756. fluid.defaults("fluid.fetchResources.issueRequest", {
  10757. mergePolicy : {
  10758. success : fluid.fetchResources.composePolicy,
  10759. error : fluid.fetchResources.composePolicy,
  10760. url : "reverse"
  10761. }
  10762. });
  10763. fluid.fetchResources.issueRequest = function (resourceSpec, key) {
  10764. var thisCallback = fluid.fetchResources.makeResourceCallback(resourceSpec);
  10765. var options = {
  10766. url : resourceSpec.href,
  10767. success : thisCallback.success,
  10768. error : thisCallback.error,
  10769. dataType : "text"
  10770. };
  10771. fluid.fetchResources.timeSuccessCallback(resourceSpec);
  10772. fluid.merge(fluid.defaults("fluid.fetchResources.issueRequest").mergePolicy, options, resourceSpec.options);
  10773. resourceSpec.queued = true;
  10774. resourceSpec.initTime = new Date();
  10775. fluid.log("Request with key " + key + " queued for " + resourceSpec.href);
  10776. if (resourceSpec.forceCache) {
  10777. fluid.fetchResources.issueCachedRequest(resourceSpec, options)
  10778. } else {
  10779. $.ajax(options)
  10780. }
  10781. };
  10782. fluid.fetchResources.fetchResourcesImpl = function (that) {
  10783. var complete = true;
  10784. var allSync = true;
  10785. var resourceSpecs = that.resourceSpecs;
  10786. for (var key in resourceSpecs) {
  10787. var resourceSpec = resourceSpecs[key];
  10788. if (!resourceSpec.options || resourceSpec.options.async) {
  10789. allSync = false
  10790. }
  10791. if (resourceSpec.href && !resourceSpec.completeTime) {
  10792. if (!resourceSpec.queued) {
  10793. fluid.fetchResources.issueRequest(resourceSpec, key)
  10794. }
  10795. if (resourceSpec.queued) {
  10796. complete = false
  10797. }
  10798. } else {
  10799. if (resourceSpec.nodeId && !resourceSpec.resourceText) {
  10800. var node = document.getElementById(resourceSpec.nodeId);
  10801. resourceSpec.resourceText = fluid.dom.getElementText(node);
  10802. resourceSpec.resourceKey = resourceSpec.nodeId
  10803. }
  10804. }
  10805. }
  10806. if (complete && that.callback && !that.callbackCalled) {
  10807. that.callbackCalled = true;
  10808. if ($.browser.mozilla && !allSync) {
  10809. setTimeout(function () {
  10810. that.callback(resourceSpecs)
  10811. }, 1)
  10812. } else {
  10813. that.callback(resourceSpecs)
  10814. }
  10815. }
  10816. };
  10817. fluid.fetchResources.primeCacheFromResources = function (componentName) {
  10818. var resources = fluid.defaults(componentName).resources;
  10819. var that = {
  10820. typeName : "fluid.fetchResources.primeCacheFromResources"
  10821. };
  10822. var expanded = (fluid.expandOptions ? fluid.expandOptions : fluid.identity)(fluid.copy(resources), that);
  10823. fluid.fetchResources(expanded)
  10824. };
  10825. fluid.registerNamespace("fluid.expander");
  10826. fluid.expander.makeDefaultFetchOptions = function (successdisposer, failid, options) {
  10827. return $.extend(true, {
  10828. dataType : "text"
  10829. }, options, {
  10830. success : function (response, environmentdisposer) {
  10831. var json = JSON.parse(response);
  10832. environmentdisposer(successdisposer(json))
  10833. },
  10834. error : function (response, textStatus) {
  10835. fluid.log("Error fetching " + failid + ": " + textStatus)
  10836. }
  10837. })
  10838. };
  10839. fluid.expander.makeFetchExpander = function (options) {
  10840. return {
  10841. expander : {
  10842. type : "fluid.expander.deferredFetcher",
  10843. href : options.url,
  10844. options : fluid.expander.makeDefaultFetchOptions(options.disposer, options.url, options.options),
  10845. resourceSpecCollector : "{resourceSpecCollector}",
  10846. fetchKey : options.fetchKey
  10847. }
  10848. }
  10849. };
  10850. fluid.expander.deferredFetcher = function (target, source, recurse, expandOptions) {
  10851. var expander = source.expander;
  10852. var spec = fluid.copy(expander);
  10853. var collector = fluid.resolveEnvironment(expander.resourceSpecCollector, expandOptions);
  10854. delete spec.type;
  10855. delete spec.resourceSpecCollector;
  10856. delete spec.fetchKey;
  10857. var environmentdisposer = function (disposed) {
  10858. $.extend(target, disposed)
  10859. };
  10860. spec.options.success = function (response) {
  10861. expander.options.success(response, environmentdisposer)
  10862. };
  10863. var key = expander.fetchKey || fluid.allocateGuid();
  10864. collector[key] = spec;
  10865. return target
  10866. }
  10867. })(jQuery, fluid_1_4);
  10868. var fluid_1_4 = fluid_1_4 || {};
  10869. (function ($, fluid) {
  10870. fluid.XMLP = function (strXML) {
  10871. return fluid.XMLP.XMLPImpl(strXML)
  10872. };
  10873. fluid.XMLP.closedTags = {
  10874. abbr : true,
  10875. br : true,
  10876. col : true,
  10877. img : true,
  10878. input : true,
  10879. link : true,
  10880. meta : true,
  10881. param : true,
  10882. hr : true,
  10883. area : true,
  10884. embed : true
  10885. };
  10886. fluid.XMLP._NONE = 0;
  10887. fluid.XMLP._ELM_B = 1;
  10888. fluid.XMLP._ELM_E = 2;
  10889. fluid.XMLP._ELM_EMP = 3;
  10890. fluid.XMLP._ATT = 4;
  10891. fluid.XMLP._TEXT = 5;
  10892. fluid.XMLP._ENTITY = 6;
  10893. fluid.XMLP._PI = 7;
  10894. fluid.XMLP._CDATA = 8;
  10895. fluid.XMLP._COMMENT = 9;
  10896. fluid.XMLP._DTD = 10;
  10897. fluid.XMLP._ERROR = 11;
  10898. fluid.XMLP._CONT_XML = 0;
  10899. fluid.XMLP._CONT_ALT = 1;
  10900. fluid.XMLP._ATT_NAME = 0;
  10901. fluid.XMLP._ATT_VAL = 1;
  10902. fluid.XMLP._STATE_PROLOG = 1;
  10903. fluid.XMLP._STATE_DOCUMENT = 2;
  10904. fluid.XMLP._STATE_MISC = 3;
  10905. fluid.XMLP._errs = [];
  10906. fluid.XMLP._errs[fluid.XMLP.ERR_CLOSE_PI = 0] = "PI: missing closing sequence";
  10907. fluid.XMLP._errs[fluid.XMLP.ERR_CLOSE_DTD = 1] = "DTD: missing closing sequence";
  10908. fluid.XMLP._errs[fluid.XMLP.ERR_CLOSE_COMMENT = 2] = "Comment: missing closing sequence";
  10909. fluid.XMLP._errs[fluid.XMLP.ERR_CLOSE_CDATA = 3] = "CDATA: missing closing sequence";
  10910. fluid.XMLP._errs[fluid.XMLP.ERR_CLOSE_ELM = 4] = "Element: missing closing sequence";
  10911. fluid.XMLP._errs[fluid.XMLP.ERR_CLOSE_ENTITY = 5] = "Entity: missing closing sequence";
  10912. fluid.XMLP._errs[fluid.XMLP.ERR_PI_TARGET = 6] = "PI: target is required";
  10913. fluid.XMLP._errs[fluid.XMLP.ERR_ELM_EMPTY = 7] = "Element: cannot be both empty and closing";
  10914. fluid.XMLP._errs[fluid.XMLP.ERR_ELM_NAME = 8] = 'Element: name must immediatly follow "<"';
  10915. fluid.XMLP._errs[fluid.XMLP.ERR_ELM_LT_NAME = 9] = 'Element: "<" not allowed in element names';
  10916. fluid.XMLP._errs[fluid.XMLP.ERR_ATT_VALUES = 10] = "Attribute: values are required and must be in quotes";
  10917. fluid.XMLP._errs[fluid.XMLP.ERR_ATT_LT_NAME = 11] = 'Element: "<" not allowed in attribute names';
  10918. fluid.XMLP._errs[fluid.XMLP.ERR_ATT_LT_VALUE = 12] = 'Attribute: "<" not allowed in attribute values';
  10919. fluid.XMLP._errs[fluid.XMLP.ERR_ATT_DUP = 13] = "Attribute: duplicate attributes not allowed";
  10920. fluid.XMLP._errs[fluid.XMLP.ERR_ENTITY_UNKNOWN = 14] = "Entity: unknown entity";
  10921. fluid.XMLP._errs[fluid.XMLP.ERR_INFINITELOOP = 15] = "Infinite loop";
  10922. fluid.XMLP._errs[fluid.XMLP.ERR_DOC_STRUCTURE = 16] = "Document: only comments, processing instructions, or whitespace allowed outside of document element";
  10923. fluid.XMLP._errs[fluid.XMLP.ERR_ELM_NESTING = 17] = "Element: must be nested correctly";
  10924. fluid.XMLP._checkStructure = function (that, iEvent) {
  10925. var stack = that.m_stack;
  10926. if (fluid.XMLP._STATE_PROLOG == that.m_iState) {
  10927. that.m_iState = fluid.XMLP._STATE_DOCUMENT
  10928. }
  10929. if (fluid.XMLP._STATE_DOCUMENT === that.m_iState) {
  10930. if ((fluid.XMLP._ELM_B == iEvent) || (fluid.XMLP._ELM_EMP == iEvent)) {
  10931. that.m_stack[stack.length] = that.getName()
  10932. }
  10933. if ((fluid.XMLP._ELM_E == iEvent) || (fluid.XMLP._ELM_EMP == iEvent)) {
  10934. if (stack.length === 0) {
  10935. return fluid.XMLP._NONE
  10936. }
  10937. var strTop = stack[stack.length - 1];
  10938. that.m_stack.length--;
  10939. if (strTop === null || strTop !== that.getName()) {
  10940. return that._setErr(that, fluid.XMLP.ERR_ELM_NESTING)
  10941. }
  10942. }
  10943. }
  10944. return iEvent
  10945. };
  10946. fluid.XMLP._parseCDATA = function (that, iB) {
  10947. var iE = that.m_xml.indexOf("]]>", iB);
  10948. if (iE == -1) {
  10949. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_CLOSE_CDATA)
  10950. }
  10951. fluid.XMLP._setContent(that, fluid.XMLP._CONT_XML, iB, iE);
  10952. that.m_iP = iE + 3;
  10953. return fluid.XMLP._CDATA
  10954. };
  10955. fluid.XMLP._parseComment = function (that, iB) {
  10956. var iE = that.m_xml.indexOf("-->", iB);
  10957. if (iE == -1) {
  10958. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_CLOSE_COMMENT)
  10959. }
  10960. fluid.XMLP._setContent(that, fluid.XMLP._CONT_XML, iB - 4, iE + 3);
  10961. that.m_iP = iE + 3;
  10962. return fluid.XMLP._COMMENT
  10963. };
  10964. fluid.XMLP._parseDTD = function (that, iB) {
  10965. var iE,
  10966. strClose,
  10967. iInt,
  10968. iLast;
  10969. iE = that.m_xml.indexOf(">", iB);
  10970. if (iE == -1) {
  10971. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_CLOSE_DTD)
  10972. }
  10973. iInt = that.m_xml.indexOf("[", iB);
  10974. strClose = ((iInt != -1) && (iInt < iE)) ? "]>" : ">";
  10975. while (true) {
  10976. if (iE == iLast) {
  10977. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_INFINITELOOP)
  10978. }
  10979. iLast = iE;
  10980. iE = that.m_xml.indexOf(strClose, iB);
  10981. if (iE == -1) {
  10982. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_CLOSE_DTD)
  10983. }
  10984. if (that.m_xml.substring(iE - 1, iE + 2) != "]]>") {
  10985. break
  10986. }
  10987. }
  10988. that.m_iP = iE + strClose.length;
  10989. return fluid.XMLP._DTD
  10990. };
  10991. fluid.XMLP._parsePI = function (that, iB) {
  10992. var iE,
  10993. iTB,
  10994. iTE,
  10995. iCB,
  10996. iCE;
  10997. iE = that.m_xml.indexOf("?>", iB);
  10998. if (iE == -1) {
  10999. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_CLOSE_PI)
  11000. }
  11001. iTB = fluid.SAXStrings.indexOfNonWhitespace(that.m_xml, iB, iE);
  11002. if (iTB == -1) {
  11003. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_PI_TARGET)
  11004. }
  11005. iTE = fluid.SAXStrings.indexOfWhitespace(that.m_xml, iTB, iE);
  11006. if (iTE == -1) {
  11007. iTE = iE
  11008. }
  11009. iCB = fluid.SAXStrings.indexOfNonWhitespace(that.m_xml, iTE, iE);
  11010. if (iCB == -1) {
  11011. iCB = iE
  11012. }
  11013. iCE = fluid.SAXStrings.lastIndexOfNonWhitespace(that.m_xml, iCB, iE);
  11014. if (iCE == -1) {
  11015. iCE = iE - 1
  11016. }
  11017. that.m_name = that.m_xml.substring(iTB, iTE);
  11018. fluid.XMLP._setContent(that, fluid.XMLP._CONT_XML, iCB, iCE + 1);
  11019. that.m_iP = iE + 2;
  11020. return fluid.XMLP._PI
  11021. };
  11022. fluid.XMLP._parseText = function (that, iB) {
  11023. var iE = that.m_xml.indexOf("<", iB);
  11024. if (iE == -1) {
  11025. iE = that.m_xml.length
  11026. }
  11027. fluid.XMLP._setContent(that, fluid.XMLP._CONT_XML, iB, iE);
  11028. that.m_iP = iE;
  11029. return fluid.XMLP._TEXT
  11030. };
  11031. fluid.XMLP._setContent = function (that, iSrc) {
  11032. var args = arguments;
  11033. if (fluid.XMLP._CONT_XML == iSrc) {
  11034. that.m_cAlt = null;
  11035. that.m_cB = args[2];
  11036. that.m_cE = args[3]
  11037. } else {
  11038. that.m_cAlt = args[2];
  11039. that.m_cB = 0;
  11040. that.m_cE = args[2].length
  11041. }
  11042. that.m_cSrc = iSrc
  11043. };
  11044. fluid.XMLP._setErr = function (that, iErr) {
  11045. var strErr = fluid.XMLP._errs[iErr];
  11046. that.m_cAlt = strErr;
  11047. that.m_cB = 0;
  11048. that.m_cE = strErr.length;
  11049. that.m_cSrc = fluid.XMLP._CONT_ALT;
  11050. return fluid.XMLP._ERROR
  11051. };
  11052. fluid.XMLP._parseElement = function (that, iB) {
  11053. var iE,
  11054. iDE,
  11055. iRet;
  11056. var iType,
  11057. strN,
  11058. iLast;
  11059. iDE = iE = that.m_xml.indexOf(">", iB);
  11060. if (iE == -1) {
  11061. return that._setErr(that, fluid.XMLP.ERR_CLOSE_ELM)
  11062. }
  11063. if (that.m_xml.charAt(iB) == "/") {
  11064. iType = fluid.XMLP._ELM_E;
  11065. iB++
  11066. } else {
  11067. iType = fluid.XMLP._ELM_B
  11068. }
  11069. if (that.m_xml.charAt(iE - 1) == "/") {
  11070. if (iType == fluid.XMLP._ELM_E) {
  11071. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_ELM_EMPTY)
  11072. }
  11073. iType = fluid.XMLP._ELM_EMP;
  11074. iDE--
  11075. }
  11076. that.nameRegex.lastIndex = iB;
  11077. var nameMatch = that.nameRegex.exec(that.m_xml);
  11078. if (!nameMatch) {
  11079. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_ELM_NAME)
  11080. }
  11081. strN = nameMatch[1].toLowerCase();
  11082. if ("li" === strN && iType !== fluid.XMLP._ELM_E && that.m_stack.length > 0 && that.m_stack[that.m_stack.length - 1] === "li" && !that.m_emitSynthetic) {
  11083. that.m_name = "li";
  11084. that.m_emitSynthetic = true;
  11085. return fluid.XMLP._ELM_E
  11086. }
  11087. that.m_attributes = {};
  11088. that.m_cAlt = "";
  11089. if (that.nameRegex.lastIndex < iDE) {
  11090. that.m_iP = that.nameRegex.lastIndex;
  11091. while (that.m_iP < iDE) {
  11092. that.attrStartRegex.lastIndex = that.m_iP;
  11093. var attrMatch = that.attrStartRegex.exec(that.m_xml);
  11094. if (!attrMatch) {
  11095. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_ATT_VALUES)
  11096. }
  11097. var attrname = attrMatch[1].toLowerCase();
  11098. var attrval;
  11099. if (that.m_xml.charCodeAt(that.attrStartRegex.lastIndex) === 61) {
  11100. var valRegex = that.m_xml.charCodeAt(that.attrStartRegex.lastIndex + 1) === 34 ? that.attrValRegex : that.attrValIERegex;
  11101. valRegex.lastIndex = that.attrStartRegex.lastIndex + 1;
  11102. attrMatch = valRegex.exec(that.m_xml);
  11103. if (!attrMatch) {
  11104. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_ATT_VALUES)
  11105. }
  11106. attrval = attrMatch[1]
  11107. } else {
  11108. attrval = attrname;
  11109. valRegex = that.attrStartRegex
  11110. }
  11111. if (!that.m_attributes[attrname]) {
  11112. that.m_attributes[attrname] = attrval
  11113. } else {
  11114. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_ATT_DUP)
  11115. }
  11116. that.m_iP = valRegex.lastIndex
  11117. }
  11118. }
  11119. if (strN.indexOf("<") != -1) {
  11120. return fluid.XMLP._setErr(that, fluid.XMLP.ERR_ELM_LT_NAME)
  11121. }
  11122. that.m_name = strN;
  11123. that.m_iP = iE + 1;
  11124. if (fluid.XMLP.closedTags[strN]) {
  11125. that.closeRegex.lastIndex = iE + 1;
  11126. var closeMatch = that.closeRegex.exec;
  11127. if (closeMatch) {
  11128. var matchclose = that.m_xml.indexOf(strN, closeMatch.lastIndex);
  11129. if (matchclose === closeMatch.lastIndex) {
  11130. return iType
  11131. } else {
  11132. return fluid.XMLP._ELM_EMP
  11133. }
  11134. }
  11135. }
  11136. that.m_emitSynthetic = false;
  11137. return iType
  11138. };
  11139. fluid.XMLP._parse = function (that) {
  11140. var iP = that.m_iP;
  11141. var xml = that.m_xml;
  11142. if (iP === xml.length) {
  11143. return fluid.XMLP._NONE
  11144. }
  11145. var c = xml.charAt(iP);
  11146. if (c === "<") {
  11147. var c2 = xml.charAt(iP + 1);
  11148. if (c2 === "?") {
  11149. return fluid.XMLP._parsePI(that, iP + 2)
  11150. } else {
  11151. if (c2 === "!") {
  11152. if (iP === xml.indexOf("<!DOCTYPE", iP)) {
  11153. return fluid.XMLP._parseDTD(that, iP + 9)
  11154. } else {
  11155. if (iP === xml.indexOf("<!--", iP)) {
  11156. return fluid.XMLP._parseComment(that, iP + 4)
  11157. } else {
  11158. if (iP === xml.indexOf("<![CDATA[", iP)) {
  11159. return fluid.XMLP._parseCDATA(that, iP + 9)
  11160. }
  11161. }
  11162. }
  11163. } else {
  11164. return fluid.XMLP._parseElement(that, iP + 1)
  11165. }
  11166. }
  11167. } else {
  11168. return fluid.XMLP._parseText(that, iP)
  11169. }
  11170. };
  11171. fluid.XMLP.XMLPImpl = function (strXML) {
  11172. var that = {};
  11173. that.m_xml = strXML;
  11174. that.m_iP = 0;
  11175. that.m_iState = fluid.XMLP._STATE_PROLOG;
  11176. that.m_stack = [];
  11177. that.m_attributes = {};
  11178. that.m_emitSynthetic = false;
  11179. that.getColumnNumber = function () {
  11180. return fluid.SAXStrings.getColumnNumber(that.m_xml, that.m_iP)
  11181. };
  11182. that.getContent = function () {
  11183. return (that.m_cSrc == fluid.XMLP._CONT_XML) ? that.m_xml : that.m_cAlt
  11184. };
  11185. that.getContentBegin = function () {
  11186. return that.m_cB
  11187. };
  11188. that.getContentEnd = function () {
  11189. return that.m_cE
  11190. };
  11191. that.getLineNumber = function () {
  11192. return fluid.SAXStrings.getLineNumber(that.m_xml, that.m_iP)
  11193. };
  11194. that.getName = function () {
  11195. return that.m_name
  11196. };
  11197. that.next = function () {
  11198. return fluid.XMLP._checkStructure(that, fluid.XMLP._parse(that))
  11199. };
  11200. that.nameRegex = /([^\s\/>]+)/g;
  11201. that.attrStartRegex = /\s*([\w:_][\w:_\-\.]*)/gm;
  11202. that.attrValRegex = /\"([^\"]*)\"\s*/gm;
  11203. that.attrValIERegex = /([^\>\s]+)\s*/gm;
  11204. that.closeRegex = /\s*<\//g;
  11205. return that
  11206. };
  11207. fluid.SAXStrings = {};
  11208. fluid.SAXStrings.WHITESPACE = " \t\n\r";
  11209. fluid.SAXStrings.QUOTES = "\"'";
  11210. fluid.SAXStrings.getColumnNumber = function (strD, iP) {
  11211. if (!strD) {
  11212. return -1
  11213. }
  11214. iP = iP || strD.length;
  11215. var arrD = strD.substring(0, iP).split("\n");
  11216. arrD.length--;
  11217. var iLinePos = arrD.join("\n").length;
  11218. return iP - iLinePos
  11219. };
  11220. fluid.SAXStrings.getLineNumber = function (strD, iP) {
  11221. if (!strD) {
  11222. return -1
  11223. }
  11224. iP = iP || strD.length;
  11225. return strD.substring(0, iP).split("\n").length
  11226. };
  11227. fluid.SAXStrings.indexOfNonWhitespace = function (strD, iB, iE) {
  11228. if (!strD) {
  11229. return -1
  11230. }
  11231. iB = iB || 0;
  11232. iE = iE || strD.length;
  11233. for (var i = iB; i < iE; ++i) {
  11234. var c = strD.charAt(i);
  11235. if (c !== " " && c !== "\t" && c !== "\n" && c !== "\r") {
  11236. return i
  11237. }
  11238. }
  11239. return -1
  11240. };
  11241. fluid.SAXStrings.indexOfWhitespace = function (strD, iB, iE) {
  11242. if (!strD) {
  11243. return -1
  11244. }
  11245. iB = iB || 0;
  11246. iE = iE || strD.length;
  11247. for (var i = iB; i < iE; i++) {
  11248. if (fluid.SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) != -1) {
  11249. return i
  11250. }
  11251. }
  11252. return -1
  11253. };
  11254. fluid.SAXStrings.lastIndexOfNonWhitespace = function (strD, iB, iE) {
  11255. if (!strD) {
  11256. return -1
  11257. }
  11258. iB = iB || 0;
  11259. iE = iE || strD.length;
  11260. for (var i = iE - 1; i >= iB; i--) {
  11261. if (fluid.SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1) {
  11262. return i
  11263. }
  11264. }
  11265. return -1
  11266. };
  11267. fluid.SAXStrings.replace = function (strD, iB, iE, strF, strR) {
  11268. if (!strD) {
  11269. return ""
  11270. }
  11271. iB = iB || 0;
  11272. iE = iE || strD.length;
  11273. return strD.substring(iB, iE).split(strF).join(strR)
  11274. }
  11275. })(jQuery, fluid_1_4);
  11276. fluid_1_4 = fluid_1_4 || {};
  11277. (function ($, fluid) {
  11278. fluid.parseTemplate = function (template, baseURL, scanStart, cutpoints_in, opts) {
  11279. opts = opts || {};
  11280. if (!template) {
  11281. fluid.fail("empty template supplied to fluid.parseTemplate")
  11282. }
  11283. var t;
  11284. var parser;
  11285. var tagstack;
  11286. var lumpindex = 0;
  11287. var nestingdepth = 0;
  11288. var justended = false;
  11289. var defstart = -1;
  11290. var defend = -1;
  11291. var debugMode = false;
  11292. var cutpoints = [];
  11293. var simpleClassCutpoints = {};
  11294. var cutstatus = [];
  11295. var XMLLump = function (lumpindex, nestingdepth) {
  11296. return {
  11297. nestingdepth : nestingdepth,
  11298. lumpindex : lumpindex,
  11299. parent : t
  11300. }
  11301. };
  11302. function isSimpleClassCutpoint(tree) {
  11303. return tree.length === 1 && tree[0].predList.length === 1 && tree[0].predList[0].clazz
  11304. }
  11305. function init(baseURLin, debugModeIn, cutpointsIn) {
  11306. t.rootlump = XMLLump(0, -1);
  11307. tagstack = [t.rootlump];
  11308. lumpindex = 0;
  11309. nestingdepth = 0;
  11310. justended = false;
  11311. defstart = -1;
  11312. defend = -1;
  11313. baseURL = baseURLin;
  11314. debugMode = debugModeIn;
  11315. if (cutpointsIn) {
  11316. for (var i = 0; i < cutpointsIn.length; ++i) {
  11317. var tree = fluid.parseSelector(cutpointsIn[i].selector);
  11318. var clazz = isSimpleClassCutpoint(tree);
  11319. if (clazz) {
  11320. simpleClassCutpoints[clazz] = cutpointsIn[i].id
  11321. } else {
  11322. cutstatus.push([]);
  11323. cutpoints.push($.extend({}, cutpointsIn[i], {
  11324. tree : tree
  11325. }))
  11326. }
  11327. }
  11328. }
  11329. }
  11330. function findTopContainer() {
  11331. for (var i = tagstack.length - 1; i >= 0; --i) {
  11332. var lump = tagstack[i];
  11333. if (lump.rsfID !== undefined) {
  11334. return lump
  11335. }
  11336. }
  11337. return t.rootlump
  11338. }
  11339. function newLump() {
  11340. var togo = XMLLump(lumpindex, nestingdepth);
  11341. if (debugMode) {
  11342. togo.line = parser.getLineNumber();
  11343. togo.column = parser.getColumnNumber()
  11344. }
  11345. t.lumps[lumpindex] = togo;
  11346. ++lumpindex;
  11347. return togo
  11348. }
  11349. function addLump(mmap, ID, lump) {
  11350. var list = mmap[ID];
  11351. if (!list) {
  11352. list = [];
  11353. mmap[ID] = list
  11354. }
  11355. list[list.length] = lump
  11356. }
  11357. function checkContribute(ID, lump) {
  11358. if (ID.indexOf("scr=contribute-") !== -1) {
  11359. var scr = ID.substring("scr=contribute-".length);
  11360. addLump(t.collectmap, scr, lump)
  11361. }
  11362. }
  11363. function debugLump(lump) {
  11364. return "<" + lump.tagname + ">"
  11365. }
  11366. function hasCssClass(clazz, totest) {
  11367. if (!totest) {
  11368. return false
  11369. }
  11370. return (" " + totest + " ").indexOf(" " + clazz + " ") !== -1
  11371. }
  11372. function matchNode(term, headlump, headclazz) {
  11373. if (term.predList) {
  11374. for (var i = 0; i < term.predList.length; ++i) {
  11375. var pred = term.predList[i];
  11376. if (pred.id && headlump.attributemap.id !== pred.id) {
  11377. return false
  11378. }
  11379. if (pred.clazz && !hasCssClass(pred.clazz, headclazz)) {
  11380. return false
  11381. }
  11382. if (pred.tag && headlump.tagname !== pred.tag) {
  11383. return false
  11384. }
  11385. }
  11386. return true
  11387. }
  11388. }
  11389. function tagStartCut(headlump) {
  11390. var togo;
  11391. var headclazz = headlump.attributemap["class"];
  11392. if (headclazz) {
  11393. var split = headclazz.split(" ");
  11394. for (var i = 0; i < split.length; ++i) {
  11395. var simpleCut = simpleClassCutpoints[$.trim(split[i])];
  11396. if (simpleCut) {
  11397. return simpleCut
  11398. }
  11399. }
  11400. }
  11401. for (var i = 0; i < cutpoints.length; ++i) {
  11402. var cut = cutpoints[i];
  11403. var cutstat = cutstatus[i];
  11404. var nextterm = cutstat.length;
  11405. if (nextterm < cut.tree.length) {
  11406. var term = cut.tree[nextterm];
  11407. if (nextterm > 0) {
  11408. if (cut.tree[nextterm - 1].child && cutstat[nextterm - 1] !== headlump.nestingdepth - 1) {
  11409. continue
  11410. }
  11411. }
  11412. var isMatch = matchNode(term, headlump, headclazz);
  11413. if (isMatch) {
  11414. cutstat[cutstat.length] = headlump.nestingdepth;
  11415. if (cutstat.length === cut.tree.length) {
  11416. if (togo !== undefined) {
  11417. fluid.fail("Cutpoint specification error - node " + debugLump(headlump) + " has already matched with rsf:id of " + togo)
  11418. }
  11419. if (cut.id === undefined || cut.id === null) {
  11420. fluid.fail("Error in cutpoints list - entry at position " + i + " does not have an id set")
  11421. }
  11422. togo = cut.id
  11423. }
  11424. }
  11425. }
  11426. }
  11427. return togo
  11428. }
  11429. function tagEndCut() {
  11430. if (cutpoints) {
  11431. for (var i = 0; i < cutpoints.length; ++i) {
  11432. var cutstat = cutstatus[i];
  11433. if (cutstat.length > 0 && cutstat[cutstat.length - 1] === nestingdepth) {
  11434. cutstat.length--
  11435. }
  11436. }
  11437. }
  11438. }
  11439. function processTagEnd() {
  11440. tagEndCut();
  11441. var endlump = newLump();
  11442. --nestingdepth;
  11443. endlump.text = "</" + parser.getName() + ">";
  11444. var oldtop = tagstack[tagstack.length - 1];
  11445. oldtop.close_tag = t.lumps[lumpindex - 1];
  11446. tagstack.length--;
  11447. justended = true
  11448. }
  11449. function processTagStart(isempty, text) {
  11450. ++nestingdepth;
  11451. if (justended) {
  11452. justended = false;
  11453. var backlump = newLump();
  11454. backlump.nestingdepth--
  11455. }
  11456. if (t.firstdocumentindex === -1) {
  11457. t.firstdocumentindex = lumpindex
  11458. }
  11459. var headlump = newLump();
  11460. var stacktop = tagstack[tagstack.length - 1];
  11461. headlump.uplump = stacktop;
  11462. var tagname = parser.getName();
  11463. headlump.tagname = tagname;
  11464. var attrs = headlump.attributemap = parser.m_attributes;
  11465. var ID = attrs[fluid.ID_ATTRIBUTE];
  11466. if (ID === undefined) {
  11467. ID = tagStartCut(headlump)
  11468. }
  11469. for (var attrname in attrs) {
  11470. if (ID === undefined) {
  11471. if (/href|src|codebase|action/.test(attrname)) {
  11472. ID = "scr=rewrite-url"
  11473. } else {
  11474. if (ID === undefined && /for|headers/.test(attrname)) {
  11475. ID = "scr=null"
  11476. }
  11477. }
  11478. }
  11479. }
  11480. if (ID) {
  11481. if (ID.charCodeAt(0) === 126) {
  11482. ID = ID.substring(1);
  11483. headlump.elide = true
  11484. }
  11485. checkContribute(ID, headlump);
  11486. headlump.rsfID = ID;
  11487. var downreg = findTopContainer();
  11488. if (!downreg.downmap) {
  11489. downreg.downmap = {}
  11490. }
  11491. while (downreg) {
  11492. if (downreg.downmap) {
  11493. addLump(downreg.downmap, ID, headlump)
  11494. }
  11495. downreg = downreg.uplump
  11496. }
  11497. addLump(t.globalmap, ID, headlump);
  11498. var colpos = ID.indexOf(":");
  11499. if (colpos !== -1) {
  11500. var prefix = ID.substring(0, colpos);
  11501. if (!stacktop.finallump) {
  11502. stacktop.finallump = {}
  11503. }
  11504. stacktop.finallump[prefix] = headlump
  11505. }
  11506. }
  11507. headlump.text = "<" + tagname + fluid.dumpAttributes(attrs) + (isempty && !ID ? "/>" : ">");
  11508. tagstack[tagstack.length] = headlump;
  11509. if (isempty) {
  11510. if (ID) {
  11511. processTagEnd()
  11512. } else {
  11513. --nestingdepth;
  11514. tagstack.length--
  11515. }
  11516. }
  11517. }
  11518. function processDefaultTag() {
  11519. if (defstart !== -1) {
  11520. if (t.firstdocumentindex === -1) {
  11521. t.firstdocumentindex = lumpindex
  11522. }
  11523. var text = parser.getContent().substr(defstart, defend - defstart);
  11524. justended = false;
  11525. var newlump = newLump();
  11526. newlump.text = text;
  11527. defstart = -1
  11528. }
  11529. }
  11530. t = fluid.XMLViewTemplate();
  11531. init(baseURL, opts.debugMode, cutpoints_in);
  11532. var idpos = template.indexOf(fluid.ID_ATTRIBUTE);
  11533. if (scanStart) {
  11534. var brackpos = template.indexOf(">", idpos);
  11535. parser = fluid.XMLP(template.substring(brackpos + 1))
  11536. } else {
  11537. parser = fluid.XMLP(template)
  11538. }
  11539. parseloop : while (true) {
  11540. var iEvent = parser.next();
  11541. switch (iEvent) {
  11542. case fluid.XMLP._ELM_B:
  11543. processDefaultTag();
  11544. processTagStart(false, "");
  11545. break;
  11546. case fluid.XMLP._ELM_E:
  11547. processDefaultTag();
  11548. processTagEnd();
  11549. break;
  11550. case fluid.XMLP._ELM_EMP:
  11551. processDefaultTag();
  11552. processTagStart(true, "");
  11553. break;
  11554. case fluid.XMLP._PI:
  11555. case fluid.XMLP._DTD:
  11556. defstart = -1;
  11557. continue;
  11558. case fluid.XMLP._TEXT:
  11559. case fluid.XMLP._ENTITY:
  11560. case fluid.XMLP._CDATA:
  11561. case fluid.XMLP._COMMENT:
  11562. if (defstart === -1) {
  11563. defstart = parser.m_cB
  11564. }
  11565. defend = parser.m_cE;
  11566. break;
  11567. case fluid.XMLP._ERROR:
  11568. fluid.setLogging(true);
  11569. var message = "Error parsing template: " + parser.m_cAlt + " at line " + parser.getLineNumber();
  11570. fluid.log(message);
  11571. fluid.log("Just read: " + parser.m_xml.substring(parser.m_iP - 30, parser.m_iP));
  11572. fluid.log("Still to read: " + parser.m_xml.substring(parser.m_iP, parser.m_iP + 30));
  11573. fluid.fail(message);
  11574. break parseloop;
  11575. case fluid.XMLP._NONE:
  11576. break parseloop
  11577. }
  11578. }
  11579. processDefaultTag();
  11580. var excess = tagstack.length - 1;
  11581. if (excess) {
  11582. fluid.fail("Error parsing template - unclosed tag(s) of depth " + (excess) + ": " + fluid.transform(tagstack.splice(1, excess), function (lump) {
  11583. return debugLump(lump)
  11584. }).join(", "))
  11585. }
  11586. return t
  11587. };
  11588. fluid.debugLump = function (lump) {
  11589. var togo = lump.text;
  11590. togo += " at ";
  11591. togo += "lump line " + lump.line + " column " + lump.column + " index " + lump.lumpindex;
  11592. togo += lump.parent.href === null ? "" : " in file " + lump.parent.href;
  11593. return togo
  11594. };
  11595. fluid.ID_ATTRIBUTE = "rsf:id";
  11596. fluid.getPrefix = function (id) {
  11597. var colpos = id.indexOf(":");
  11598. return colpos === -1 ? id : id.substring(0, colpos)
  11599. };
  11600. fluid.SplitID = function (id) {
  11601. var that = {};
  11602. var colpos = id.indexOf(":");
  11603. if (colpos === -1) {
  11604. that.prefix = id
  11605. } else {
  11606. that.prefix = id.substring(0, colpos);
  11607. that.suffix = id.substring(colpos + 1)
  11608. }
  11609. return that
  11610. };
  11611. fluid.XMLViewTemplate = function () {
  11612. return {
  11613. globalmap : {},
  11614. collectmap : {},
  11615. lumps : [],
  11616. firstdocumentindex : -1
  11617. }
  11618. };
  11619. fluid.XMLEncode = function (text) {
  11620. return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\"/g, "&quot;")
  11621. };
  11622. fluid.dumpAttributes = function (attrcopy) {
  11623. var togo = "";
  11624. for (var attrname in attrcopy) {
  11625. var attrvalue = attrcopy[attrname];
  11626. if (attrvalue !== null && attrvalue !== undefined) {
  11627. togo += " " + attrname + '="' + attrvalue + '"'
  11628. }
  11629. }
  11630. return togo
  11631. };
  11632. fluid.aggregateMMap = function (target, source) {
  11633. for (var key in source) {
  11634. var targhas = target[key];
  11635. if (!targhas) {
  11636. target[key] = []
  11637. }
  11638. target[key] = target[key].concat(source[key])
  11639. }
  11640. };
  11641. fluid.parseTemplates = function (resourceSpec, templateList, opts) {
  11642. var togo = [];
  11643. opts = opts || {};
  11644. togo.globalmap = {};
  11645. for (var i = 0; i < templateList.length; ++i) {
  11646. var resource = resourceSpec[templateList[i]];
  11647. var lastslash = resource.href.lastIndexOf("/");
  11648. var baseURL = lastslash === -1 ? "" : resource.href.substring(0, lastslash + 1);
  11649. var template = fluid.parseTemplate(resource.resourceText, baseURL, opts.scanStart && i === 0, resource.cutpoints, opts);
  11650. if (i === 0) {
  11651. fluid.aggregateMMap(togo.globalmap, template.globalmap)
  11652. }
  11653. template.href = resource.href;
  11654. template.baseURL = baseURL;
  11655. template.resourceKey = resource.resourceKey;
  11656. togo[i] = template;
  11657. fluid.aggregateMMap(togo.globalmap, template.rootlump.downmap)
  11658. }
  11659. return togo
  11660. };
  11661. var chars = "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)";
  11662. var quickClass = new RegExp("([#.]?)(" + chars + "+)", "g");
  11663. var childSeg = new RegExp("\\s*(>)?\\s*", "g");
  11664. fluid.parseSelector = function (selstring) {
  11665. var togo = [];
  11666. selstring = $.trim(selstring);
  11667. quickClass.lastIndex = 0;
  11668. var lastIndex = 0;
  11669. while (true) {
  11670. var atNode = [];
  11671. while (true) {
  11672. var segMatch = quickClass.exec(selstring);
  11673. if (!segMatch || segMatch.index !== lastIndex) {
  11674. break
  11675. }
  11676. var thisNode = {};
  11677. var text = segMatch[2];
  11678. if (segMatch[1] === "") {
  11679. thisNode.tag = text
  11680. } else {
  11681. if (segMatch[1] === "#") {
  11682. thisNode.id = text
  11683. } else {
  11684. if (segMatch[1] === ".") {
  11685. thisNode.clazz = text
  11686. }
  11687. }
  11688. }
  11689. atNode[atNode.length] = thisNode;
  11690. lastIndex = quickClass.lastIndex
  11691. }
  11692. childSeg.lastIndex = lastIndex;
  11693. var fullAtNode = {
  11694. predList : atNode
  11695. };
  11696. var childMatch = childSeg.exec(selstring);
  11697. if (!childMatch || childMatch.index !== lastIndex) {
  11698. var remainder = selstring.substring(lastIndex);
  11699. fluid.fail("Error in selector string - can not match child selector expression at " + remainder)
  11700. }
  11701. if (childMatch[1] === ">") {
  11702. fullAtNode.child = true
  11703. }
  11704. togo[togo.length] = fullAtNode;
  11705. if (childSeg.lastIndex >= selstring.length) {
  11706. break
  11707. }
  11708. lastIndex = childSeg.lastIndex;
  11709. quickClass.lastIndex = childSeg.lastIndex
  11710. }
  11711. return togo
  11712. }
  11713. })(jQuery, fluid_1_4);
  11714. fluid_1_4 = fluid_1_4 || {};
  11715. (function ($, fluid) {
  11716. function debugPosition(component) {
  11717. return "as child of " + (component.parent.fullID ? "component with full ID " + component.parent.fullID : "root")
  11718. }
  11719. function computeFullID(component) {
  11720. var togo = "";
  11721. var move = component;
  11722. if (component.children === undefined) {
  11723. togo = component.ID + (component.localID !== undefined ? component.localID : "");
  11724. move = component.parent
  11725. }
  11726. while (move.parent) {
  11727. var parent = move.parent;
  11728. if (move.fullID !== undefined) {
  11729. togo = move.fullID + togo;
  11730. return togo
  11731. }
  11732. if (move.noID === undefined) {
  11733. var ID = move.ID;
  11734. if (ID === undefined) {
  11735. fluid.fail("Error in component tree - component found with no ID " + debugPosition(parent) + ": please check structure")
  11736. }
  11737. var colpos = ID.indexOf(":");
  11738. var prefix = colpos === -1 ? ID : ID.substring(0, colpos);
  11739. togo = prefix + ":" + (move.localID === undefined ? "" : move.localID) + ":" + togo
  11740. }
  11741. move = parent
  11742. }
  11743. return togo
  11744. }
  11745. var renderer = {};
  11746. renderer.isBoundPrimitive = function (value) {
  11747. return fluid.isPrimitive(value) || value instanceof Array && (value.length === 0 || typeof(value[0]) === "string")
  11748. };
  11749. var unzipComponent;
  11750. function processChild(value, key) {
  11751. if (renderer.isBoundPrimitive(value)) {
  11752. return {
  11753. componentType : "UIBound",
  11754. value : value,
  11755. ID : key
  11756. }
  11757. } else {
  11758. var unzip = unzipComponent(value);
  11759. if (unzip.ID) {
  11760. return {
  11761. ID : key,
  11762. componentType : "UIContainer",
  11763. children : [unzip]
  11764. }
  11765. } else {
  11766. unzip.ID = key;
  11767. return unzip
  11768. }
  11769. }
  11770. }
  11771. function fixChildren(children) {
  11772. if (!(children instanceof Array)) {
  11773. var togo = [];
  11774. for (var key in children) {
  11775. var value = children[key];
  11776. if (value instanceof Array) {
  11777. for (var i = 0; i < value.length; ++i) {
  11778. var processed = processChild(value[i], key);
  11779. togo[togo.length] = processed
  11780. }
  11781. } else {
  11782. togo[togo.length] = processChild(value, key)
  11783. }
  11784. }
  11785. return togo
  11786. } else {
  11787. return children
  11788. }
  11789. }
  11790. function fixupValue(uibound, model, resolverGetConfig) {
  11791. if (uibound.value === undefined && uibound.valuebinding !== undefined) {
  11792. if (!model) {
  11793. fluid.fail("Cannot perform value fixup for valuebinding " + uibound.valuebinding + " since no model was supplied to rendering")
  11794. }
  11795. uibound.value = fluid.get(model, uibound.valuebinding, resolverGetConfig)
  11796. }
  11797. }
  11798. function upgradeBound(holder, property, model, resolverGetConfig) {
  11799. if (holder[property] !== undefined) {
  11800. if (renderer.isBoundPrimitive(holder[property])) {
  11801. holder[property] = {
  11802. value : holder[property]
  11803. }
  11804. } else {
  11805. if (holder[property].messagekey) {
  11806. holder[property].componentType = "UIMessage"
  11807. }
  11808. }
  11809. } else {
  11810. holder[property] = {
  11811. value : null
  11812. }
  11813. }
  11814. fixupValue(holder[property], model, resolverGetConfig)
  11815. }
  11816. renderer.duckMap = {
  11817. children : "UIContainer",
  11818. value : "UIBound",
  11819. valuebinding : "UIBound",
  11820. messagekey : "UIMessage",
  11821. markup : "UIVerbatim",
  11822. selection : "UISelect",
  11823. target : "UILink",
  11824. choiceindex : "UISelectChoice",
  11825. functionname : "UIInitBlock"
  11826. };
  11827. var boundMap = {
  11828. UISelect : ["selection", "optionlist", "optionnames"],
  11829. UILink : ["target", "linktext"],
  11830. UIVerbatim : ["markup"],
  11831. UIMessage : ["messagekey"]
  11832. };
  11833. renderer.boundMap = fluid.transform(boundMap, fluid.arrayToHash);
  11834. renderer.inferComponentType = function (component) {
  11835. for (var key in renderer.duckMap) {
  11836. if (component[key] !== undefined) {
  11837. return renderer.duckMap[key]
  11838. }
  11839. }
  11840. };
  11841. renderer.applyComponentType = function (component) {
  11842. component.componentType = renderer.inferComponentType(component);
  11843. if (component.componentType === undefined && component.ID !== undefined) {
  11844. component.componentType = "UIBound"
  11845. }
  11846. };
  11847. unzipComponent = function (component, model, resolverGetConfig) {
  11848. if (component) {
  11849. renderer.applyComponentType(component)
  11850. }
  11851. if (!component || component.componentType === undefined) {
  11852. var decorators = component.decorators;
  11853. if (decorators) {
  11854. delete component.decorators
  11855. }
  11856. component = {
  11857. componentType : "UIContainer",
  11858. children : component
  11859. };
  11860. component.decorators = decorators
  11861. }
  11862. var cType = component.componentType;
  11863. if (cType === "UIContainer") {
  11864. component.children = fixChildren(component.children)
  11865. } else {
  11866. var map = renderer.boundMap[cType];
  11867. if (map) {
  11868. fluid.each(map, function (value, key) {
  11869. upgradeBound(component, key, model, resolverGetConfig)
  11870. })
  11871. }
  11872. }
  11873. return component
  11874. };
  11875. function fixupTree(tree, model, resolverGetConfig) {
  11876. if (tree.componentType === undefined) {
  11877. tree = unzipComponent(tree, model, resolverGetConfig)
  11878. }
  11879. if (tree.componentType !== "UIContainer" && !tree.parent) {
  11880. tree = {
  11881. children : [tree]
  11882. }
  11883. }
  11884. if (tree.children) {
  11885. tree.childmap = {};
  11886. for (var i = 0; i < tree.children.length; ++i) {
  11887. var child = tree.children[i];
  11888. if (child.componentType === undefined) {
  11889. child = unzipComponent(child, model, resolverGetConfig);
  11890. tree.children[i] = child
  11891. }
  11892. child.parent = tree;
  11893. if (child.ID === undefined) {
  11894. fluid.fail("Error in component tree: component found with no ID " + debugPosition(child))
  11895. }
  11896. tree.childmap[child.ID] = child;
  11897. var colpos = child.ID.indexOf(":");
  11898. if (colpos === -1) {}
  11899. else {
  11900. var prefix = child.ID.substring(0, colpos);
  11901. var childlist = tree.childmap[prefix];
  11902. if (!childlist) {
  11903. childlist = [];
  11904. tree.childmap[prefix] = childlist
  11905. }
  11906. if (child.localID === undefined && childlist.length !== 0) {
  11907. child.localID = childlist.length
  11908. }
  11909. childlist[childlist.length] = child
  11910. }
  11911. child.fullID = computeFullID(child);
  11912. var componentType = child.componentType;
  11913. if (componentType === "UISelect") {
  11914. child.selection.fullID = child.fullID + "-selection"
  11915. } else {
  11916. if (componentType === "UIInitBlock") {
  11917. var call = child.functionname + "(";
  11918. for (var j = 0; j < child.arguments.length; ++j) {
  11919. if (child.arguments[j]instanceof fluid.ComponentReference) {
  11920. child.arguments[j] = child.parent.fullID + child.arguments[j].reference
  11921. }
  11922. call += JSON.stringify(child.arguments[j]);
  11923. if (j < child.arguments.length - 1) {
  11924. call += ", "
  11925. }
  11926. }
  11927. child.markup = {
  11928. value : call + ")\n"
  11929. };
  11930. child.componentType = "UIVerbatim"
  11931. } else {
  11932. if (componentType === "UIBound") {
  11933. fixupValue(child, model, resolverGetConfig)
  11934. }
  11935. }
  11936. }
  11937. fixupTree(child, model, resolverGetConfig)
  11938. }
  11939. }
  11940. return tree
  11941. }
  11942. fluid.NULL_STRING = "\u25a9null\u25a9";
  11943. var LINK_ATTRIBUTES = {
  11944. a : "href",
  11945. link : "href",
  11946. img : "src",
  11947. frame : "src",
  11948. script : "src",
  11949. style : "src",
  11950. input : "src",
  11951. embed : "src",
  11952. form : "action",
  11953. applet : "codebase",
  11954. object : "codebase"
  11955. };
  11956. renderer.decoratorComponentPrefix = "**-renderer-";
  11957. renderer.IDtoComponentName = function (ID, num) {
  11958. return renderer.decoratorComponentPrefix + ID.replace(/\./g, "") + "-" + num
  11959. };
  11960. renderer.invokeFluidDecorator = function (func, args, ID, num, options) {
  11961. var that;
  11962. if (options.instantiator && options.parentComponent) {
  11963. var parent = options.parentComponent;
  11964. var name = renderer.IDtoComponentName(ID, num);
  11965. fluid.set(parent, fluid.path("options", "components", name), {
  11966. type : func
  11967. });
  11968. that = fluid.initDependent(options.parentComponent, name, options.instantiator, args)
  11969. } else {
  11970. that = fluid.invokeGlobalFunction(func, args)
  11971. }
  11972. return that
  11973. };
  11974. fluid.renderer = function (templates, tree, options, fossilsIn) {
  11975. options = options || {};
  11976. tree = tree || {};
  11977. var debugMode = options.debugMode;
  11978. if (!options.messageLocator && options.messageSource) {
  11979. options.messageLocator = fluid.resolveMessageSource(options.messageSource)
  11980. }
  11981. options.document = options.document || document;
  11982. var directFossils = fossilsIn || {};
  11983. var globalmap = {};
  11984. var branchmap = {};
  11985. var rewritemap = {};
  11986. var seenset = {};
  11987. var collected = {};
  11988. var out = "";
  11989. var renderOptions = options;
  11990. var decoratorQueue = [];
  11991. var renderedbindings = {};
  11992. var usedIDs = {};
  11993. var that = {};
  11994. function getRewriteKey(template, parent, id) {
  11995. return template.resourceKey + parent.fullID + id
  11996. }
  11997. function resolveInScope(searchID, defprefix, scope, child) {
  11998. var deflump;
  11999. var scopelook = scope ? scope[searchID] : null;
  12000. if (scopelook) {
  12001. for (var i = 0; i < scopelook.length; ++i) {
  12002. var scopelump = scopelook[i];
  12003. if (!deflump && scopelump.rsfID === defprefix) {
  12004. deflump = scopelump
  12005. }
  12006. if (scopelump.rsfID === searchID) {
  12007. return scopelump
  12008. }
  12009. }
  12010. }
  12011. return deflump
  12012. }
  12013. function resolveCall(sourcescope, child) {
  12014. var searchID = child.jointID ? child.jointID : child.ID;
  12015. var split = fluid.SplitID(searchID);
  12016. var defprefix = split.prefix + ":";
  12017. var match = resolveInScope(searchID, defprefix, sourcescope.downmap, child);
  12018. if (match) {
  12019. return match
  12020. }
  12021. if (child.children) {
  12022. match = resolveInScope(searchID, defprefix, globalmap, child);
  12023. if (match) {
  12024. return match
  12025. }
  12026. }
  12027. return null
  12028. }
  12029. function noteCollected(template) {
  12030. if (!seenset[template.href]) {
  12031. fluid.aggregateMMap(collected, template.collectmap);
  12032. seenset[template.href] = true
  12033. }
  12034. }
  12035. var fetchComponent;
  12036. function resolveRecurse(basecontainer, parentlump) {
  12037. for (var i = 0; i < basecontainer.children.length; ++i) {
  12038. var branch = basecontainer.children[i];
  12039. if (branch.children) {
  12040. var resolved = resolveCall(parentlump, branch);
  12041. if (resolved) {
  12042. branchmap[branch.fullID] = resolved;
  12043. var id = resolved.attributemap.id;
  12044. if (id !== undefined) {
  12045. rewritemap[getRewriteKey(parentlump.parent, basecontainer, id)] = branch.fullID
  12046. }
  12047. noteCollected(resolved.parent);
  12048. resolveRecurse(branch, resolved)
  12049. }
  12050. }
  12051. }
  12052. if (parentlump.downmap) {
  12053. for (var id in parentlump.downmap) {
  12054. var lumps = parentlump.downmap[id];
  12055. for (var i = 0; i < lumps.length; ++i) {
  12056. var lump = lumps[i];
  12057. var lumpid = lump.attributemap.id;
  12058. if (lumpid !== undefined && lump.rsfID !== undefined) {
  12059. var resolved = fetchComponent(basecontainer, lump.rsfID);
  12060. if (resolved !== null) {
  12061. var resolveID = resolved.fullID;
  12062. if (resolved.componentType === "UISelect") {
  12063. resolveID = resolveID + "-selection"
  12064. }
  12065. rewritemap[getRewriteKey(parentlump.parent, basecontainer, lumpid)] = resolveID
  12066. }
  12067. }
  12068. }
  12069. }
  12070. }
  12071. }
  12072. function resolveBranches(globalmapp, basecontainer, parentlump) {
  12073. branchmap = {};
  12074. rewritemap = {};
  12075. seenset = {};
  12076. collected = {};
  12077. globalmap = globalmapp;
  12078. branchmap[basecontainer.fullID] = parentlump;
  12079. resolveRecurse(basecontainer, parentlump)
  12080. }
  12081. function dumpTillLump(lumps, start, limit) {
  12082. for (; start < limit; ++start) {
  12083. var text = lumps[start].text;
  12084. if (text) {
  12085. out += lumps[start].text
  12086. }
  12087. }
  12088. }
  12089. function dumpScan(lumps, renderindex, basedepth, closeparent, insideleaf) {
  12090. var start = renderindex;
  12091. while (true) {
  12092. if (renderindex === lumps.length) {
  12093. break
  12094. }
  12095. var lump = lumps[renderindex];
  12096. if (lump.nestingdepth < basedepth) {
  12097. break
  12098. }
  12099. if (lump.rsfID !== undefined) {
  12100. if (!insideleaf) {
  12101. break
  12102. }
  12103. if (insideleaf && lump.nestingdepth > basedepth + (closeparent ? 0 : 1)) {
  12104. fluid.log("Error in component tree - leaf component found to contain further components - at " + lump.toString())
  12105. } else {
  12106. break
  12107. }
  12108. }
  12109. ++renderindex
  12110. }
  12111. if (!closeparent && (renderindex === lumps.length || !lumps[renderindex].rsfID)) {
  12112. --renderindex
  12113. }
  12114. dumpTillLump(lumps, start, renderindex);
  12115. return renderindex
  12116. }
  12117. function isPlaceholder(value) {
  12118. return false
  12119. }
  12120. function isValue(value) {
  12121. return value !== null && value !== undefined && !isPlaceholder(value)
  12122. }
  12123. var trc = {};
  12124. function openTag() {
  12125. if (!trc.iselide) {
  12126. out += "<" + trc.uselump.tagname
  12127. }
  12128. }
  12129. function closeTag() {
  12130. if (!trc.iselide) {
  12131. out += "</" + trc.uselump.tagname + ">"
  12132. }
  12133. }
  12134. function renderUnchanged() {
  12135. dumpTillLump(trc.uselump.parent.lumps, trc.uselump.lumpindex + 1, trc.close.lumpindex + (trc.iselide ? 0 : 1))
  12136. }
  12137. function isSelfClose() {
  12138. return trc.endopen.lumpindex === trc.close.lumpindex && fluid.XMLP.closedTags[trc.uselump.tagname]
  12139. }
  12140. function dumpTemplateBody() {
  12141. if (isSelfClose()) {
  12142. if (!trc.iselide) {
  12143. out += "/>"
  12144. }
  12145. } else {
  12146. if (!trc.iselide) {
  12147. out += ">"
  12148. }
  12149. dumpTillLump(trc.uselump.parent.lumps, trc.endopen.lumpindex, trc.close.lumpindex + (trc.iselide ? 0 : 1))
  12150. }
  12151. }
  12152. function replaceAttributes() {
  12153. if (!trc.iselide) {
  12154. out += fluid.dumpAttributes(trc.attrcopy)
  12155. }
  12156. dumpTemplateBody()
  12157. }
  12158. function replaceAttributesOpen() {
  12159. if (trc.iselide) {
  12160. replaceAttributes()
  12161. } else {
  12162. out += fluid.dumpAttributes(trc.attrcopy);
  12163. var selfClose = isSelfClose();
  12164. out += selfClose ? "/>" : ">";
  12165. trc.nextpos = selfClose ? trc.close.lumpindex + 1 : trc.endopen.lumpindex
  12166. }
  12167. }
  12168. function replaceBody(value) {
  12169. out += fluid.dumpAttributes(trc.attrcopy);
  12170. if (!trc.iselide) {
  12171. out += ">"
  12172. }
  12173. out += fluid.XMLEncode(value.toString());
  12174. closeTag()
  12175. }
  12176. function rewriteLeaf(value) {
  12177. if (isValue(value)) {
  12178. replaceBody(value)
  12179. } else {
  12180. replaceAttributes()
  12181. }
  12182. }
  12183. function rewriteLeafOpen(value) {
  12184. if (trc.iselide) {
  12185. rewriteLeaf(trc.value)
  12186. } else {
  12187. if (isValue(value)) {
  12188. replaceBody(value)
  12189. } else {
  12190. replaceAttributesOpen()
  12191. }
  12192. }
  12193. }
  12194. function rewriteUrl(template, url) {
  12195. if (renderOptions.urlRewriter) {
  12196. var rewritten = renderOptions.urlRewriter(url);
  12197. if (rewritten) {
  12198. return rewritten
  12199. }
  12200. }
  12201. if (!renderOptions.rebaseURLs) {
  12202. return url
  12203. }
  12204. var protpos = url.indexOf(":/");
  12205. if (url.charAt(0) === "/" || protpos !== -1 && protpos < 7) {
  12206. return url
  12207. } else {
  12208. return renderOptions.baseURL + url
  12209. }
  12210. }
  12211. function dumpHiddenField(todump) {
  12212. out += '<input type="hidden" ';
  12213. var isvirtual = todump.virtual;
  12214. var outattrs = {};
  12215. outattrs[isvirtual ? "id" : "name"] = todump.name;
  12216. outattrs.value = todump.value;
  12217. out += fluid.dumpAttributes(outattrs);
  12218. out += " />\n"
  12219. }
  12220. var outDecoratorsImpl;
  12221. function applyAutoBind(torender, finalID) {
  12222. if (!finalID) {
  12223. return
  12224. }
  12225. var tagname = trc.uselump.tagname;
  12226. var applier = renderOptions.applier;
  12227. function applyFunc() {
  12228. fluid.applyChange(fluid.byId(finalID), undefined, applier)
  12229. }
  12230. if (renderOptions.autoBind && /input|select|textarea/.test(tagname) && !renderedbindings[finalID]) {
  12231. var decorators = [{
  12232. jQuery : ["change", applyFunc]
  12233. }
  12234. ];
  12235. if ($.browser.msie && tagname === "input" && /radio|checkbox/.test(trc.attrcopy.type)) {
  12236. decorators.push({
  12237. jQuery : ["click", applyFunc]
  12238. })
  12239. }
  12240. if ($.browser.safari && tagname === "input" && trc.attrcopy.type === "radio") {
  12241. decorators.push({
  12242. jQuery : ["keyup", applyFunc]
  12243. })
  12244. }
  12245. outDecoratorsImpl(torender, decorators, trc.attrcopy, finalID)
  12246. }
  12247. }
  12248. function dumpBoundFields(torender, parent) {
  12249. if (torender) {
  12250. var holder = parent ? parent : torender;
  12251. if (directFossils && holder.valuebinding) {
  12252. var fossilKey = holder.submittingname || torender.finalID;
  12253. directFossils[fossilKey] = {
  12254. name : fossilKey,
  12255. EL : holder.valuebinding,
  12256. oldvalue : holder.value
  12257. };
  12258. applyAutoBind(torender, torender.finalID)
  12259. }
  12260. if (torender.fossilizedbinding) {
  12261. dumpHiddenField(torender.fossilizedbinding)
  12262. }
  12263. if (torender.fossilizedshaper) {
  12264. dumpHiddenField(torender.fossilizedshaper)
  12265. }
  12266. }
  12267. }
  12268. function dumpSelectionBindings(uiselect) {
  12269. if (!renderedbindings[uiselect.selection.fullID]) {
  12270. renderedbindings[uiselect.selection.fullID] = true;
  12271. dumpBoundFields(uiselect.selection);
  12272. dumpBoundFields(uiselect.optionlist);
  12273. dumpBoundFields(uiselect.optionnames)
  12274. }
  12275. }
  12276. function isSelectedValue(torender, value) {
  12277. var selection = torender.selection;
  12278. return selection.value && typeof(selection.value) !== "string" && typeof(selection.value.length) === "number" ? $.inArray(value, selection.value, value) !== -1 : selection.value === value
  12279. }
  12280. function getRelativeComponent(component, relativeID) {
  12281. component = component.parent;
  12282. while (relativeID.indexOf("..::") === 0) {
  12283. relativeID = relativeID.substring(4);
  12284. component = component.parent
  12285. }
  12286. return component.childmap[relativeID]
  12287. }
  12288. function adjustForID(attrcopy, component, late, forceID) {
  12289. if (!late) {
  12290. delete attrcopy["rsf:id"]
  12291. }
  12292. if (component.finalID !== undefined) {
  12293. attrcopy.id = component.finalID
  12294. } else {
  12295. if (forceID !== undefined) {
  12296. attrcopy.id = forceID
  12297. } else {
  12298. if (attrcopy.id || late) {
  12299. attrcopy.id = component.fullID
  12300. }
  12301. }
  12302. }
  12303. var count = 1;
  12304. var baseid = attrcopy.id;
  12305. while (renderOptions.document.getElementById(attrcopy.id) || usedIDs[attrcopy.id]) {
  12306. attrcopy.id = baseid + "-" + (count++)
  12307. }
  12308. component.finalID = attrcopy.id;
  12309. return attrcopy.id
  12310. }
  12311. function assignSubmittingName(attrcopy, component, parent) {
  12312. var submitting = parent || component;
  12313. adjustForID(attrcopy, component, true, component.fullID);
  12314. if (submitting.submittingname === undefined && submitting.willinput !== false) {
  12315. submitting.submittingname = submitting.finalID || submitting.fullID
  12316. }
  12317. return submitting.submittingname
  12318. }
  12319. function explodeDecorators(decorators) {
  12320. var togo = [];
  12321. if (decorators.type) {
  12322. togo[0] = decorators
  12323. } else {
  12324. for (var key in decorators) {
  12325. if (key === "$") {
  12326. key = "jQuery"
  12327. }
  12328. var value = decorators[key];
  12329. var decorator = {
  12330. type : key
  12331. };
  12332. if (key === "jQuery") {
  12333. decorator.func = value[0];
  12334. decorator.args = value.slice(1)
  12335. } else {
  12336. if (key === "addClass" || key === "removeClass") {
  12337. decorator.classes = value
  12338. } else {
  12339. if (key === "attrs") {
  12340. decorator.attributes = value
  12341. } else {
  12342. if (key === "identify") {
  12343. decorator.key = value
  12344. }
  12345. }
  12346. }
  12347. }
  12348. togo[togo.length] = decorator
  12349. }
  12350. }
  12351. return togo
  12352. }
  12353. outDecoratorsImpl = function (torender, decorators, attrcopy, finalID) {
  12354. renderOptions.idMap = renderOptions.idMap || {};
  12355. for (var i = 0; i < decorators.length; ++i) {
  12356. var decorator = decorators[i];
  12357. var type = decorator.type;
  12358. if (!type) {
  12359. var explodedDecorators = explodeDecorators(decorator);
  12360. outDecoratorsImpl(torender, explodedDecorators, attrcopy, finalID);
  12361. continue
  12362. }
  12363. if (type === "$") {
  12364. type = decorator.type = "jQuery"
  12365. }
  12366. if (type === "jQuery" || type === "event" || type === "fluid") {
  12367. var id = adjustForID(attrcopy, torender, true, finalID);
  12368. if (decorator.ids === undefined) {
  12369. decorator.ids = [];
  12370. decoratorQueue[decoratorQueue.length] = decorator
  12371. }
  12372. decorator.ids.push(id)
  12373. } else {
  12374. if (type === "attrs") {
  12375. fluid.each(decorator.attributes, function (value, key) {
  12376. if (value === null || value === undefined) {
  12377. delete attrcopy[key]
  12378. } else {
  12379. attrcopy[key] = fluid.XMLEncode(value)
  12380. }
  12381. })
  12382. } else {
  12383. if (type === "addClass" || type === "removeClass") {
  12384. var fakeNode = {
  12385. nodeType : 1,
  12386. className : attrcopy["class"] || ""
  12387. };
  12388. $(fakeNode)[type](decorator.classes);
  12389. attrcopy["class"] = fakeNode.className
  12390. } else {
  12391. if (type === "identify") {
  12392. var id = adjustForID(attrcopy, torender, true, finalID);
  12393. renderOptions.idMap[decorator.key] = id
  12394. } else {
  12395. if (type !== "null") {
  12396. fluid.log("Unrecognised decorator of type " + type + " found at component of ID " + finalID)
  12397. }
  12398. }
  12399. }
  12400. }
  12401. }
  12402. }
  12403. };
  12404. function outDecorators(torender, attrcopy) {
  12405. if (!torender.decorators) {
  12406. return
  12407. }
  12408. if (torender.decorators.length === undefined) {
  12409. torender.decorators = explodeDecorators(torender.decorators)
  12410. }
  12411. outDecoratorsImpl(torender, torender.decorators, attrcopy)
  12412. }
  12413. function dumpBranchHead(branch, targetlump) {
  12414. if (targetlump.elide) {
  12415. return
  12416. }
  12417. var attrcopy = {};
  12418. $.extend(true, attrcopy, targetlump.attributemap);
  12419. adjustForID(attrcopy, branch);
  12420. outDecorators(branch, attrcopy);
  12421. out += "<" + targetlump.tagname + " ";
  12422. out += fluid.dumpAttributes(attrcopy);
  12423. out += ">"
  12424. }
  12425. function resolveArgs(args) {
  12426. if (!args) {
  12427. return args
  12428. }
  12429. return fluid.transform(args, function (arg, index) {
  12430. upgradeBound(args, index, renderOptions.model, renderOptions.resolverGetConfig);
  12431. return args[index].value
  12432. })
  12433. }
  12434. function degradeMessage(torender) {
  12435. if (torender.componentType === "UIMessage") {
  12436. torender.componentType = "UIBound";
  12437. if (!renderOptions.messageLocator) {
  12438. torender.value = "[No messageLocator is configured in options - please consult documentation on options.messageSource]"
  12439. } else {
  12440. upgradeBound(torender, "messagekey", renderOptions.model, renderOptions.resolverGetConfig);
  12441. var resArgs = resolveArgs(torender.args);
  12442. torender.value = renderOptions.messageLocator(torender.messagekey.value, resArgs)
  12443. }
  12444. }
  12445. }
  12446. function renderComponent(torender) {
  12447. var attrcopy = trc.attrcopy;
  12448. degradeMessage(torender);
  12449. var componentType = torender.componentType;
  12450. var tagname = trc.uselump.tagname;
  12451. outDecorators(torender, attrcopy);
  12452. function makeFail(torender, end) {
  12453. fluid.fail("Error in component tree - UISelectChoice with id " + torender.fullID + end)
  12454. }
  12455. if (componentType === "UIBound" || componentType === "UISelectChoice") {
  12456. var parent;
  12457. if (torender.choiceindex !== undefined) {
  12458. if (torender.parentRelativeID !== undefined) {
  12459. parent = getRelativeComponent(torender, torender.parentRelativeID);
  12460. if (!parent) {
  12461. makeFail(torender, " has parentRelativeID of " + torender.parentRelativeID + " which cannot be resolved")
  12462. }
  12463. } else {
  12464. makeFail(torender, " does not have parentRelativeID set")
  12465. }
  12466. assignSubmittingName(attrcopy, torender, parent.selection);
  12467. dumpSelectionBindings(parent)
  12468. }
  12469. var submittingname = parent ? parent.selection.submittingname : torender.submittingname;
  12470. if (!parent && torender.valuebinding) {
  12471. submittingname = assignSubmittingName(attrcopy, torender)
  12472. }
  12473. if (tagname === "input" || tagname === "textarea") {
  12474. if (submittingname !== undefined) {
  12475. attrcopy.name = submittingname
  12476. }
  12477. }
  12478. dumpBoundFields(torender, parent ? parent.selection : null);
  12479. if (typeof(torender.value) === "boolean" || attrcopy.type === "radio" || attrcopy.type === "checkbox") {
  12480. var underlyingValue;
  12481. var directValue = torender.value;
  12482. if (torender.choiceindex !== undefined) {
  12483. if (!parent.optionlist.value) {
  12484. fluid.fail("Error in component tree - selection control with full ID " + parent.fullID + " has no values")
  12485. }
  12486. underlyingValue = parent.optionlist.value[torender.choiceindex];
  12487. directValue = isSelectedValue(parent, underlyingValue)
  12488. }
  12489. if (isValue(directValue)) {
  12490. if (directValue) {
  12491. attrcopy.checked = "checked"
  12492. } else {
  12493. delete attrcopy.checked
  12494. }
  12495. }
  12496. attrcopy.value = fluid.XMLEncode(underlyingValue ? underlyingValue : "true");
  12497. rewriteLeaf(null)
  12498. } else {
  12499. if (torender.value instanceof Array) {
  12500. renderUnchanged()
  12501. } else {
  12502. var value = parent ? parent[tagname === "textarea" || tagname === "input" ? "optionlist" : "optionnames"].value[torender.choiceindex] : torender.value;
  12503. if (tagname === "textarea") {
  12504. if (isPlaceholder(value) && torender.willinput) {
  12505. value = ""
  12506. }
  12507. rewriteLeaf(value)
  12508. } else {
  12509. if (tagname === "input") {
  12510. if (torender.willinput || isValue(value)) {
  12511. attrcopy.value = fluid.XMLEncode(String(value))
  12512. }
  12513. rewriteLeaf(null)
  12514. } else {
  12515. delete attrcopy.name;
  12516. rewriteLeafOpen(value)
  12517. }
  12518. }
  12519. }
  12520. }
  12521. } else {
  12522. if (componentType === "UISelect") {
  12523. var ishtmlselect = tagname === "select";
  12524. var ismultiple = false;
  12525. if (torender.selection.value instanceof Array) {
  12526. ismultiple = true;
  12527. if (ishtmlselect) {
  12528. attrcopy.multiple = "multiple"
  12529. }
  12530. }
  12531. var oldid = attrcopy.id;
  12532. assignSubmittingName(attrcopy, torender.selection);
  12533. if (oldid !== undefined) {
  12534. attrcopy.id = oldid
  12535. }
  12536. if (ishtmlselect) {
  12537. if (torender.selection.willinput !== false) {
  12538. attrcopy.name = torender.selection.submittingname
  12539. }
  12540. applyAutoBind(torender, attrcopy.id)
  12541. }
  12542. out += fluid.dumpAttributes(attrcopy);
  12543. if (ishtmlselect) {
  12544. out += ">";
  12545. var values = torender.optionlist.value;
  12546. var names = torender.optionnames === null || torender.optionnames === undefined || !torender.optionnames.value ? values : torender.optionnames.value;
  12547. if (!names || !names.length) {
  12548. fluid.fail("Error in component tree - UISelect component with fullID " + torender.fullID + " does not have optionnames set")
  12549. }
  12550. for (var i = 0; i < names.length; ++i) {
  12551. out += '<option value="';
  12552. var value = values[i];
  12553. if (value === null) {
  12554. value = fluid.NULL_STRING
  12555. }
  12556. out += fluid.XMLEncode(value);
  12557. if (isSelectedValue(torender, value)) {
  12558. out += '" selected="selected'
  12559. }
  12560. out += '">';
  12561. out += fluid.XMLEncode(names[i]);
  12562. out += "</option>\n"
  12563. }
  12564. closeTag()
  12565. } else {
  12566. dumpTemplateBody()
  12567. }
  12568. dumpSelectionBindings(torender)
  12569. } else {
  12570. if (componentType === "UILink") {
  12571. var attrname = LINK_ATTRIBUTES[tagname];
  12572. if (attrname) {
  12573. degradeMessage(torender.target);
  12574. var target = torender.target.value;
  12575. if (!isValue(target)) {
  12576. target = attrcopy[attrname]
  12577. }
  12578. target = rewriteUrl(trc.uselump.parent, target);
  12579. attrcopy[attrname] = fluid.XMLEncode(target)
  12580. }
  12581. var value;
  12582. if (torender.linktext) {
  12583. degradeMessage(torender.linktext);
  12584. value = torender.linktext.value
  12585. }
  12586. if (!isValue(value)) {
  12587. replaceAttributesOpen()
  12588. } else {
  12589. rewriteLeaf(value)
  12590. }
  12591. } else {
  12592. if (torender.markup !== undefined) {
  12593. degradeMessage(torender.markup);
  12594. var rendered = torender.markup.value;
  12595. if (rendered === null) {
  12596. out += fluid.dumpAttributes(attrcopy);
  12597. out += ">";
  12598. renderUnchanged()
  12599. } else {
  12600. if (!trc.iselide) {
  12601. out += fluid.dumpAttributes(attrcopy);
  12602. out += ">"
  12603. }
  12604. out += rendered;
  12605. closeTag()
  12606. }
  12607. }
  12608. }
  12609. }
  12610. }
  12611. if (attrcopy.id !== undefined) {
  12612. usedIDs[attrcopy.id] = true
  12613. }
  12614. }
  12615. function rewriteIDRelation(context) {
  12616. var attrname;
  12617. var attrval = trc.attrcopy["for"];
  12618. if (attrval !== undefined) {
  12619. attrname = "for"
  12620. } else {
  12621. attrval = trc.attrcopy.headers;
  12622. if (attrval !== undefined) {
  12623. attrname = "headers"
  12624. }
  12625. }
  12626. if (!attrname) {
  12627. return
  12628. }
  12629. var tagname = trc.uselump.tagname;
  12630. if (attrname === "for" && tagname !== "label") {
  12631. return
  12632. }
  12633. if (attrname === "headers" && tagname !== "td" && tagname !== "th") {
  12634. return
  12635. }
  12636. var rewritten = rewritemap[getRewriteKey(trc.uselump.parent, context, attrval)];
  12637. if (rewritten !== undefined) {
  12638. trc.attrcopy[attrname] = rewritten
  12639. }
  12640. }
  12641. function renderComment(message) {
  12642. out += ("<!-- " + fluid.XMLEncode(message) + "-->")
  12643. }
  12644. function renderDebugMessage(message) {
  12645. out += '<span style="background-color:#FF466B;color:white;padding:1px;">';
  12646. out += message;
  12647. out += "</span><br/>"
  12648. }
  12649. function reportPath(branch) {
  12650. var path = branch.fullID;
  12651. return !path ? "component tree root" : "full path " + path
  12652. }
  12653. function renderComponentSystem(context, torendero, lump) {
  12654. var lumpindex = lump.lumpindex;
  12655. var lumps = lump.parent.lumps;
  12656. var nextpos = -1;
  12657. var outerendopen = lumps[lumpindex + 1];
  12658. var outerclose = lump.close_tag;
  12659. nextpos = outerclose.lumpindex + 1;
  12660. var payloadlist = lump.downmap ? lump.downmap["payload-component"] : null;
  12661. var payload = payloadlist ? payloadlist[0] : null;
  12662. var iselide = lump.rsfID.charCodeAt(0) === 126;
  12663. var endopen = outerendopen;
  12664. var close = outerclose;
  12665. var uselump = lump;
  12666. var attrcopy = {};
  12667. $.extend(true, attrcopy, (payload === null ? lump : payload).attributemap);
  12668. trc.attrcopy = attrcopy;
  12669. trc.uselump = uselump;
  12670. trc.endopen = endopen;
  12671. trc.close = close;
  12672. trc.nextpos = nextpos;
  12673. trc.iselide = iselide;
  12674. rewriteIDRelation(context);
  12675. if (torendero === null) {
  12676. if (lump.rsfID.indexOf("scr=") === (iselide ? 1 : 0)) {
  12677. var scrname = lump.rsfID.substring(4 + (iselide ? 1 : 0));
  12678. if (scrname === "ignore") {
  12679. nextpos = trc.close.lumpindex + 1
  12680. } else {
  12681. if (scrname === "rewrite-url") {
  12682. torendero = {
  12683. componentType : "UILink",
  12684. target : {}
  12685. }
  12686. } else {
  12687. openTag();
  12688. replaceAttributesOpen();
  12689. nextpos = trc.endopen.lumpindex
  12690. }
  12691. }
  12692. }
  12693. }
  12694. if (torendero !== null) {
  12695. if (payload) {
  12696. trc.endopen = lumps[payload.lumpindex + 1];
  12697. trc.close = payload.close_tag;
  12698. trc.uselump = payload;
  12699. dumpTillLump(lumps, lumpindex, payload.lumpindex);
  12700. lumpindex = payload.lumpindex
  12701. }
  12702. adjustForID(attrcopy, torendero);
  12703. openTag();
  12704. renderComponent(torendero);
  12705. if (payload !== null) {
  12706. if (trc.nextpos === nextpos) {
  12707. dumpTillLump(lumps, trc.close.lumpindex + 1, outerclose.lumpindex + 1)
  12708. }
  12709. }
  12710. nextpos = trc.nextpos
  12711. }
  12712. return nextpos
  12713. }
  12714. var renderRecurse;
  12715. function renderContainer(child, targetlump) {
  12716. var t2 = targetlump.parent;
  12717. var firstchild = t2.lumps[targetlump.lumpindex + 1];
  12718. if (child.children !== undefined) {
  12719. dumpBranchHead(child, targetlump)
  12720. } else {
  12721. renderComponentSystem(child.parent, child, targetlump)
  12722. }
  12723. renderRecurse(child, targetlump, firstchild)
  12724. }
  12725. fetchComponent = function (basecontainer, id, lump) {
  12726. if (id.indexOf("msg=") === 0) {
  12727. var key = id.substring(4);
  12728. return {
  12729. componentType : "UIMessage",
  12730. messagekey : key
  12731. }
  12732. }
  12733. while (basecontainer) {
  12734. var togo = basecontainer.childmap[id];
  12735. if (togo) {
  12736. return togo
  12737. }
  12738. basecontainer = basecontainer.parent
  12739. }
  12740. return null
  12741. };
  12742. function fetchComponents(basecontainer, id) {
  12743. var togo;
  12744. while (basecontainer) {
  12745. togo = basecontainer.childmap[id];
  12746. if (togo) {
  12747. break
  12748. }
  12749. basecontainer = basecontainer.parent
  12750. }
  12751. return togo
  12752. }
  12753. function findChild(sourcescope, child) {
  12754. var split = fluid.SplitID(child.ID);
  12755. var headlumps = sourcescope.downmap[child.ID];
  12756. if (!headlumps) {
  12757. headlumps = sourcescope.downmap[split.prefix + ":"]
  12758. }
  12759. return headlumps ? headlumps[0] : null
  12760. }
  12761. renderRecurse = function (basecontainer, parentlump, baselump) {
  12762. var renderindex = baselump.lumpindex;
  12763. var basedepth = parentlump.nestingdepth;
  12764. var t1 = parentlump.parent;
  12765. var rendered;
  12766. if (debugMode) {
  12767. rendered = {}
  12768. }
  12769. while (true) {
  12770. renderindex = dumpScan(t1.lumps, renderindex, basedepth, !parentlump.elide, false);
  12771. if (renderindex === t1.lumps.length) {
  12772. break
  12773. }
  12774. var lump = t1.lumps[renderindex];
  12775. var id = lump.rsfID;
  12776. if (lump.nestingdepth < basedepth || id === undefined) {
  12777. break
  12778. }
  12779. if (id.charCodeAt(0) === 126) {
  12780. id = id.substring(1)
  12781. }
  12782. if (id.indexOf(":") !== -1) {
  12783. var prefix = fluid.getPrefix(id);
  12784. var children = fetchComponents(basecontainer, prefix);
  12785. var finallump = lump.uplump.finallump[prefix];
  12786. var closefinal = finallump.close_tag;
  12787. if (children) {
  12788. for (var i = 0; i < children.length; ++i) {
  12789. var child = children[i];
  12790. if (child.children) {
  12791. if (debugMode) {
  12792. rendered[child.fullID] = true
  12793. }
  12794. var targetlump = branchmap[child.fullID];
  12795. if (targetlump) {
  12796. if (debugMode) {
  12797. renderComment("Branching for " + child.fullID + " from " + fluid.debugLump(lump) + " to " + fluid.debugLump(targetlump))
  12798. }
  12799. renderContainer(child, targetlump);
  12800. if (debugMode) {
  12801. renderComment("Branch returned for " + child.fullID + fluid.debugLump(lump) + " to " + fluid.debugLump(targetlump))
  12802. }
  12803. } else {
  12804. if (debugMode) {
  12805. renderDebugMessage("No matching template branch found for branch container with full ID " + child.fullID + " rendering from parent template branch " + fluid.debugLump(baselump))
  12806. }
  12807. }
  12808. } else {
  12809. var targetlump = findChild(parentlump, child);
  12810. if (!targetlump) {
  12811. if (debugMode) {
  12812. renderDebugMessage("Repetitive leaf with full ID " + child.fullID + " could not be rendered from parent template branch " + fluid.debugLump(baselump))
  12813. }
  12814. continue
  12815. }
  12816. var renderend = renderComponentSystem(basecontainer, child, targetlump);
  12817. var wasopentag = renderend < t1.lumps.lengtn && t1.lumps[renderend].nestingdepth >= targetlump.nestingdepth;
  12818. var newbase = child.children ? child : basecontainer;
  12819. if (wasopentag) {
  12820. renderRecurse(newbase, targetlump, t1.lumps[renderend]);
  12821. renderend = targetlump.close_tag.lumpindex + 1
  12822. }
  12823. if (i !== children.length - 1) {
  12824. if (renderend < closefinal.lumpindex) {
  12825. dumpScan(t1.lumps, renderend, targetlump.nestingdepth - 1, false, false)
  12826. }
  12827. } else {
  12828. dumpScan(t1.lumps, renderend, targetlump.nestingdepth, true, false)
  12829. }
  12830. }
  12831. }
  12832. } else {
  12833. if (debugMode) {
  12834. renderDebugMessage("No branch container with prefix " + prefix + ": found in container " + reportPath(basecontainer) + " rendering at template position " + fluid.debugLump(baselump) + ", skipping")
  12835. }
  12836. }
  12837. renderindex = closefinal.lumpindex + 1;
  12838. if (debugMode) {
  12839. renderComment("Stack returned from branch for ID " + id + " to " + fluid.debugLump(baselump) + ": skipping from " + fluid.debugLump(lump) + " to " + fluid.debugLump(closefinal))
  12840. }
  12841. } else {
  12842. var component;
  12843. if (id) {
  12844. component = fetchComponent(basecontainer, id, lump);
  12845. if (debugMode && component) {
  12846. rendered[component.fullID] = true
  12847. }
  12848. }
  12849. if (component && component.children !== undefined) {
  12850. renderContainer(component);
  12851. renderindex = lump.close_tag.lumpindex + 1
  12852. } else {
  12853. renderindex = renderComponentSystem(basecontainer, component, lump)
  12854. }
  12855. }
  12856. if (renderindex === t1.lumps.length) {
  12857. break
  12858. }
  12859. }
  12860. if (debugMode) {
  12861. var children = basecontainer.children;
  12862. for (var key = 0; key < children.length; ++key) {
  12863. var child = children[key];
  12864. if (!rendered[child.fullID]) {
  12865. renderDebugMessage("Component " + child.componentType + " with full ID " + child.fullID + " could not be found within template " + fluid.debugLump(baselump))
  12866. }
  12867. }
  12868. }
  12869. };
  12870. function renderCollect(collump) {
  12871. dumpTillLump(collump.parent.lumps, collump.lumpindex, collump.close_tag.lumpindex + 1)
  12872. }
  12873. function renderCollects() {
  12874. for (var key in collected) {
  12875. var collist = collected[key];
  12876. for (var i = 0; i < collist.length; ++i) {
  12877. renderCollect(collist[i])
  12878. }
  12879. }
  12880. }
  12881. function processDecoratorQueue() {
  12882. for (var i = 0; i < decoratorQueue.length; ++i) {
  12883. var decorator = decoratorQueue[i];
  12884. for (var j = 0; j < decorator.ids.length; ++j) {
  12885. var id = decorator.ids[j];
  12886. var node = fluid.byId(id, renderOptions.document);
  12887. if (!node) {
  12888. fluid.fail("Error during rendering - component with id " + id + " which has a queued decorator was not found in the output markup")
  12889. }
  12890. if (decorator.type === "jQuery") {
  12891. var jnode = $(node);
  12892. jnode[decorator.func].apply(jnode, $.makeArray(decorator.args))
  12893. } else {
  12894. if (decorator.type === "fluid") {
  12895. var args = decorator.args;
  12896. if (!args) {
  12897. if (!decorator.container) {
  12898. decorator.container = $(node)
  12899. } else {
  12900. decorator.container.push(node)
  12901. }
  12902. args = [node, decorator.options]
  12903. }
  12904. var that = renderer.invokeFluidDecorator(decorator.func, args, id, i, options);
  12905. decorator.that = that
  12906. } else {
  12907. if (decorator.type === "event") {
  12908. node[decorator.event] = decorator.handler
  12909. }
  12910. }
  12911. }
  12912. }
  12913. }
  12914. }
  12915. that.renderTemplates = function () {
  12916. tree = fixupTree(tree, options.model, options.resolverGetConfig);
  12917. var template = templates[0];
  12918. resolveBranches(templates.globalmap, tree, template.rootlump);
  12919. renderedbindings = {};
  12920. renderCollects();
  12921. renderRecurse(tree, template.rootlump, template.lumps[template.firstdocumentindex]);
  12922. return out
  12923. };
  12924. that.processDecoratorQueue = function () {
  12925. processDecoratorQueue()
  12926. };
  12927. return that
  12928. };
  12929. jQuery.extend(true, fluid.renderer, renderer);
  12930. fluid.ComponentReference = function (reference) {
  12931. this.reference = reference
  12932. };
  12933. fluid.explode = function (hash, basepath) {
  12934. var togo = [];
  12935. for (var key in hash) {
  12936. var binding = basepath === undefined ? key : basepath + "." + key;
  12937. togo[togo.length] = {
  12938. ID : key,
  12939. value : hash[key],
  12940. valuebinding : binding
  12941. }
  12942. }
  12943. return togo
  12944. };
  12945. fluid.explodeSelectionToInputs = function (optionlist, opts) {
  12946. return fluid.transform(optionlist, function (option, index) {
  12947. return {
  12948. ID : opts.rowID,
  12949. children : [{
  12950. ID : opts.inputID,
  12951. parentRelativeID : "..::" + opts.selectID,
  12952. choiceindex : index
  12953. }, {
  12954. ID : opts.labelID,
  12955. parentRelativeID : "..::" + opts.selectID,
  12956. choiceindex : index
  12957. }
  12958. ]
  12959. }
  12960. })
  12961. };
  12962. fluid.resolveMessageSource = function (messageSource) {
  12963. if (messageSource.type === "data") {
  12964. if (messageSource.url === undefined) {
  12965. return fluid.messageLocator(messageSource.messages, messageSource.resolveFunc)
  12966. } else {}
  12967. } else {
  12968. if (messageSource.type === "resolver") {
  12969. return messageSource.resolver.resolve
  12970. }
  12971. }
  12972. };
  12973. fluid.renderTemplates = function (templates, tree, options, fossilsIn) {
  12974. var renderer = fluid.renderer(templates, tree, options, fossilsIn);
  12975. var rendered = renderer.renderTemplates();
  12976. return rendered
  12977. };
  12978. fluid.reRender = function (templates, node, tree, options) {
  12979. options = options || {};
  12980. node = fluid.unwrap(node);
  12981. var lastFocusedElement = fluid.getLastFocusedElement ? fluid.getLastFocusedElement() : null;
  12982. var lastId;
  12983. if (lastFocusedElement && fluid.dom.isContainer(node, lastFocusedElement)) {
  12984. lastId = lastFocusedElement.id
  12985. }
  12986. if ($.browser.msie) {
  12987. $(node).empty()
  12988. } else {
  12989. node.innerHTML = ""
  12990. }
  12991. var fossils = options.fossils || {};
  12992. var renderer = fluid.renderer(templates, tree, options, fossils);
  12993. var rendered = renderer.renderTemplates();
  12994. if (options.renderRaw) {
  12995. rendered = fluid.XMLEncode(rendered);
  12996. rendered = rendered.replace(/\n/g, "<br/>")
  12997. }
  12998. if (options.model) {
  12999. fluid.bindFossils(node, options.model, fossils)
  13000. }
  13001. if ($.browser.msie) {
  13002. $(node).html(rendered)
  13003. } else {
  13004. node.innerHTML = rendered
  13005. }
  13006. renderer.processDecoratorQueue();
  13007. if (lastId) {
  13008. var element = fluid.byId(lastId);
  13009. if (element) {
  13010. $(element).focus()
  13011. }
  13012. }
  13013. return templates
  13014. };
  13015. function findNodeValue(rootNode) {
  13016. var node = fluid.dom.iterateDom(rootNode, function (node) {
  13017. return node.nodeType === 8 || node.nodeType === 4 ? "stop" : null
  13018. }, true);
  13019. var value = node.nodeValue;
  13020. if (value.indexOf("[CDATA[") === 0) {
  13021. return value.substring(6, value.length - 2)
  13022. } else {
  13023. return value
  13024. }
  13025. }
  13026. fluid.extractTemplate = function (node, armouring) {
  13027. if (!armouring) {
  13028. return node.innerHTML
  13029. } else {
  13030. return findNodeValue(node)
  13031. }
  13032. };
  13033. fluid.render = function (source, target, tree, options) {
  13034. options = options || {};
  13035. var template = source;
  13036. if (typeof(source) === "object") {
  13037. template = fluid.extractTemplate(fluid.unwrap(source.node), source.armouring)
  13038. }
  13039. target = fluid.unwrap(target);
  13040. var resourceSpec = {
  13041. base : {
  13042. resourceText : template,
  13043. href : ".",
  13044. resourceKey : ".",
  13045. cutpoints : options.cutpoints
  13046. }
  13047. };
  13048. var templates = fluid.parseTemplates(resourceSpec, ["base"], options);
  13049. return fluid.reRender(templates, target, tree, options)
  13050. };
  13051. fluid.selfRender = function (node, tree, options) {
  13052. options = options || {};
  13053. return fluid.render({
  13054. node : node,
  13055. armouring : options.armouring
  13056. }, node, tree, options)
  13057. }
  13058. })(jQuery, fluid_1_4);
  13059. fluid_1_4 = fluid_1_4 || {};
  13060. (function ($, fluid) {
  13061. if (!fluid.renderer) {
  13062. fluid.fail("fluidRenderer.js is a necessary dependency of RendererUtilities")
  13063. }
  13064. fluid.iota = function (count, first) {
  13065. first = first || 0;
  13066. var togo = [];
  13067. for (var i = 0; i < count; ++i) {
  13068. togo[togo.length] = first++
  13069. }
  13070. return togo
  13071. };
  13072. fluid.renderer.visitDecorators = function (that, visitor) {
  13073. fluid.visitComponentChildren(that, function (component, name) {
  13074. if (name.indexOf(fluid.renderer.decoratorComponentPrefix) === 0) {
  13075. visitor(component, name)
  13076. }
  13077. }, {
  13078. flat : true
  13079. })
  13080. };
  13081. fluid.renderer.clearDecorators = function (instantiator, that) {
  13082. fluid.renderer.visitDecorators(that, function (component, name) {
  13083. instantiator.clearComponent(that, name)
  13084. })
  13085. };
  13086. fluid.renderer.getDecoratorComponents = function (that) {
  13087. var togo = {};
  13088. fluid.renderer.visitDecorators(that, function (component, name) {
  13089. togo[name] = component
  13090. });
  13091. return togo
  13092. };
  13093. fluid.renderer.modeliseOptions = function (options, defaults, baseOptions) {
  13094. return $.extend({}, defaults, options, fluid.filterKeys(baseOptions, ["model", "applier"]))
  13095. };
  13096. fluid.renderer.reverseMerge = function (target, source, names) {
  13097. names = fluid.makeArray(names);
  13098. fluid.each(names, function (name) {
  13099. if (target[name] === undefined && source[name] !== undefined) {
  13100. target[name] = source[name]
  13101. }
  13102. })
  13103. };
  13104. fluid.renderer.createRendererSubcomponent = function (container, selectors, options, baseObject, fossils) {
  13105. options = options || {};
  13106. var source = options.templateSource ? options.templateSource : {
  13107. node : $(container)
  13108. };
  13109. var rendererOptions = fluid.renderer.modeliseOptions(options.rendererOptions, null, baseObject);
  13110. rendererOptions.fossils = fossils || {};
  13111. var expanderOptions = fluid.renderer.modeliseOptions(options.expanderOptions, {
  13112. ELstyle : "${}"
  13113. }, baseObject);
  13114. fluid.renderer.reverseMerge(expanderOptions, options, ["resolverGetConfig", "resolverSetConfig"]);
  13115. var that = {};
  13116. if (!options.noexpand) {
  13117. that.expander = fluid.renderer.makeProtoExpander(expanderOptions)
  13118. }
  13119. var templates = null;
  13120. that.render = function (tree) {
  13121. var cutpointFn = options.cutpointGenerator || "fluid.renderer.selectorsToCutpoints";
  13122. rendererOptions.cutpoints = rendererOptions.cutpoints || fluid.invokeGlobalFunction(cutpointFn, [selectors, options]);
  13123. container = typeof(container) === "function" ? container() : $(container);
  13124. if (templates) {
  13125. fluid.clear(rendererOptions.fossils);
  13126. fluid.reRender(templates, container, tree, rendererOptions)
  13127. } else {
  13128. if (typeof(source) === "function") {
  13129. source = source()
  13130. }
  13131. templates = fluid.render(source, container, tree, rendererOptions)
  13132. }
  13133. };
  13134. return that
  13135. };
  13136. fluid.defaults("fluid.rendererComponent", {
  13137. gradeNames : ["fluid.viewComponent"],
  13138. initFunction : "fluid.initRendererComponent",
  13139. mergePolicy : {
  13140. protoTree : "noexpand, replace"
  13141. },
  13142. rendererOptions : {
  13143. autoBind : true
  13144. },
  13145. events : {
  13146. prepareModelForRender : null,
  13147. onRenderTree : null,
  13148. afterRender : null,
  13149. produceTree : "unicast"
  13150. }
  13151. });
  13152. fluid.initRendererComponent = function (componentName, container, options) {
  13153. var that = fluid.initView(componentName, container, options, {
  13154. gradeNames : ["fluid.rendererComponent"]
  13155. });
  13156. fluid.fetchResources(that.options.resources);
  13157. var rendererOptions = fluid.renderer.modeliseOptions(that.options.rendererOptions, null, that);
  13158. if (!that.options.noUpgradeDecorators) {
  13159. fluid.withInstantiator(that, function (currentInst) {
  13160. rendererOptions.instantiator = currentInst;
  13161. rendererOptions.parentComponent = that
  13162. })
  13163. }
  13164. var messageResolver;
  13165. if (!rendererOptions.messageSource && that.options.strings) {
  13166. messageResolver = fluid.messageResolver({
  13167. messageBase : that.options.strings,
  13168. resolveFunc : that.options.messageResolverFunction,
  13169. parents : fluid.makeArray(that.options.parentBundle)
  13170. });
  13171. rendererOptions.messageSource = {
  13172. type : "resolver",
  13173. resolver : messageResolver
  13174. }
  13175. }
  13176. fluid.renderer.reverseMerge(rendererOptions, that.options, ["resolverGetConfig", "resolverSetConfig"]);
  13177. var rendererFnOptions = $.extend({}, that.options.rendererFnOptions, {
  13178. rendererOptions : rendererOptions,
  13179. repeatingSelectors : that.options.repeatingSelectors,
  13180. selectorsToIgnore : that.options.selectorsToIgnore,
  13181. expanderOptions : {
  13182. envAdd : {
  13183. styles : that.options.styles
  13184. }
  13185. }
  13186. });
  13187. if (that.options.resources && that.options.resources.template) {
  13188. rendererFnOptions.templateSource = function () {
  13189. return that.options.resources.template.resourceText
  13190. }
  13191. }
  13192. var produceTree = that.events.produceTree;
  13193. produceTree.addListener(function () {
  13194. return that.options.protoTree
  13195. });
  13196. if (that.options.produceTree) {
  13197. produceTree.addListener(that.options.produceTree)
  13198. }
  13199. fluid.renderer.reverseMerge(rendererFnOptions, that.options, ["resolverGetConfig", "resolverSetConfig"]);
  13200. if (rendererFnOptions.rendererTargetSelector) {
  13201. container = function () {
  13202. return that.dom.locate(rendererFnOptions.rendererTargetSelector)
  13203. }
  13204. }
  13205. var renderer = {
  13206. fossils : {},
  13207. boundPathForNode : function (node) {
  13208. return fluid.boundPathForNode(node, renderer.fossils)
  13209. }
  13210. };
  13211. var rendererSub = fluid.renderer.createRendererSubcomponent(container, that.options.selectors, rendererFnOptions, that, renderer.fossils);
  13212. that.renderer = $.extend(renderer, rendererSub);
  13213. if (messageResolver) {
  13214. that.messageResolver = messageResolver
  13215. }
  13216. that.refreshView = renderer.refreshView = function () {
  13217. if (rendererOptions.instantiator && rendererOptions.parentComponent) {
  13218. fluid.renderer.clearDecorators(rendererOptions.instantiator, rendererOptions.parentComponent)
  13219. }
  13220. that.events.prepareModelForRender.fire(that.model, that.applier, that);
  13221. var tree = produceTree.fire(that);
  13222. if (that.renderer.expander) {
  13223. tree = that.renderer.expander(tree)
  13224. }
  13225. that.events.onRenderTree.fire(that, tree);
  13226. that.renderer.render(tree);
  13227. that.events.afterRender.fire(that)
  13228. };
  13229. if (that.options.renderOnInit) {
  13230. that.refreshView()
  13231. }
  13232. return that
  13233. };
  13234. var removeSelectors = function (selectors, selectorsToIgnore) {
  13235. fluid.each(fluid.makeArray(selectorsToIgnore), function (selectorToIgnore) {
  13236. delete selectors[selectorToIgnore]
  13237. });
  13238. return selectors
  13239. };
  13240. var markRepeated = function (selectorKey, repeatingSelectors) {
  13241. if (repeatingSelectors) {
  13242. fluid.each(repeatingSelectors, function (repeatingSelector) {
  13243. if (selectorKey === repeatingSelector) {
  13244. selectorKey = selectorKey + ":"
  13245. }
  13246. })
  13247. }
  13248. return selectorKey
  13249. };
  13250. fluid.renderer.selectorsToCutpoints = function (selectors, options) {
  13251. var togo = [];
  13252. options = options || {};
  13253. selectors = fluid.copy(selectors);
  13254. if (options.selectorsToIgnore) {
  13255. selectors = removeSelectors(selectors, options.selectorsToIgnore)
  13256. }
  13257. for (var selectorKey in selectors) {
  13258. togo.push({
  13259. id : markRepeated(selectorKey, options.repeatingSelectors),
  13260. selector : selectors[selectorKey]
  13261. })
  13262. }
  13263. return togo
  13264. };
  13265. fluid.renderer.NO_COMPONENT = {};
  13266. fluid.renderer.mergeComponents = function (target, source) {
  13267. for (var key in source) {
  13268. target[key] = source[key]
  13269. }
  13270. return target
  13271. };
  13272. fluid.registerNamespace("fluid.renderer.selection");
  13273. fluid.renderer.selection.inputs = function (options, container, key, config) {
  13274. fluid.expect("Selection to inputs expander", ["selectID", "inputID", "labelID", "rowID"], options);
  13275. var selection = config.expander(options.tree);
  13276. var rows = fluid.transform(selection.optionlist.value, function (option, index) {
  13277. var togo = {};
  13278. var element = {
  13279. parentRelativeID : "..::" + options.selectID,
  13280. choiceindex : index
  13281. };
  13282. togo[options.inputID] = element;
  13283. togo[options.labelID] = fluid.copy(element);
  13284. return togo
  13285. });
  13286. var togo = {};
  13287. togo[options.selectID] = selection;
  13288. togo[options.rowID] = {
  13289. children : rows
  13290. };
  13291. togo = config.expander(togo);
  13292. return togo
  13293. };
  13294. fluid.renderer.repeat = function (options, container, key, config) {
  13295. fluid.expect("Repetition expander", ["controlledBy", "tree"], options);
  13296. var path = fluid.extractContextualPath(options.controlledBy, {
  13297. ELstyle : "ALL"
  13298. }, fluid.threadLocal());
  13299. var list = fluid.get(config.model, path, config.resolverGetConfig);
  13300. var togo = {};
  13301. if (!list || list.length === 0) {
  13302. return options.ifEmpty ? config.expander(options.ifEmpty) : togo
  13303. }
  13304. var expanded = [];
  13305. fluid.each(list, function (element, i) {
  13306. var EL = fluid.model.composePath(path, i);
  13307. var envAdd = {};
  13308. if (options.pathAs) {
  13309. envAdd[options.pathAs] = EL
  13310. }
  13311. if (options.valueAs) {
  13312. envAdd[options.valueAs] = fluid.get(config.model, EL, config.resolverGetConfig)
  13313. }
  13314. var expandrow = fluid.withEnvironment(envAdd, function () {
  13315. return config.expander(options.tree)
  13316. }, "rendererEnvironment");
  13317. if (fluid.isArrayable(expandrow)) {
  13318. if (expandrow.length > 0) {
  13319. expanded.push({
  13320. children : expandrow
  13321. })
  13322. }
  13323. } else {
  13324. if (expandrow !== fluid.renderer.NO_COMPONENT) {
  13325. expanded.push(expandrow)
  13326. }
  13327. }
  13328. });
  13329. var repeatID = options.repeatID;
  13330. if (repeatID.indexOf(":") === -1) {
  13331. repeatID = repeatID + ":"
  13332. }
  13333. fluid.each(expanded, function (entry) {
  13334. entry.ID = repeatID
  13335. });
  13336. return expanded
  13337. };
  13338. fluid.renderer.condition = function (options, container, key, config) {
  13339. fluid.expect("Selection to condition expander", ["condition"], options);
  13340. var condition;
  13341. if (options.condition.funcName) {
  13342. var args = config.expandLight(options.condition.args);
  13343. condition = fluid.invoke(options.condition.funcName, args)
  13344. } else {
  13345. if (options.condition.expander) {
  13346. condition = config.expander(options.condition)
  13347. } else {
  13348. condition = config.expandLight(options.condition)
  13349. }
  13350. }
  13351. var tree = (condition ? options.trueTree : options.falseTree);
  13352. if (!tree) {
  13353. tree = fluid.renderer.NO_COMPONENT
  13354. }
  13355. return config.expander(tree)
  13356. };
  13357. fluid.extractContextualPath = function (string, options, env) {
  13358. var parsed = fluid.extractELWithContext(string, options);
  13359. if (parsed) {
  13360. if (parsed.context) {
  13361. var fetched = env[parsed.context];
  13362. if (typeof(fetched) !== "string") {
  13363. fluid.fail("Could not look up context path named " + parsed.context + " to string value")
  13364. }
  13365. return fluid.model.composePath(fetched, parsed.path)
  13366. } else {
  13367. return parsed.path
  13368. }
  13369. }
  13370. };
  13371. fluid.renderer.makeProtoExpander = function (expandOptions) {
  13372. var options = $.extend({
  13373. ELstyle : "${}"
  13374. }, expandOptions);
  13375. options.fetcher = fluid.makeEnvironmentFetcher("rendererEnvironment", options.model);
  13376. var IDescape = options.IDescape || "\\";
  13377. function fetchEL(string) {
  13378. var env = fluid.threadLocal().rendererEnvironment;
  13379. return fluid.extractContextualPath(string, options, env)
  13380. }
  13381. var expandLight = function (source) {
  13382. return fluid.resolveEnvironment(source, options)
  13383. };
  13384. var expandBound = function (value, concrete) {
  13385. if (value.messagekey !== undefined) {
  13386. return {
  13387. componentType : "UIMessage",
  13388. messagekey : expandBound(value.messagekey),
  13389. args : expandLight(value.args)
  13390. }
  13391. }
  13392. var proto;
  13393. if (!fluid.isPrimitive(value) && !fluid.isArrayable(value)) {
  13394. proto = $.extend({}, value);
  13395. if (proto.decorators) {
  13396. proto.decorators = expandLight(proto.decorators)
  13397. }
  13398. value = proto.value;
  13399. delete proto.value
  13400. } else {
  13401. proto = {}
  13402. }
  13403. var EL = typeof(value) === "string" ? fetchEL(value) : null;
  13404. if (EL) {
  13405. proto.valuebinding = EL
  13406. } else {
  13407. if (value !== undefined) {
  13408. proto.value = value
  13409. }
  13410. }
  13411. if (options.model && proto.valuebinding && proto.value === undefined) {
  13412. proto.value = fluid.get(options.model, proto.valuebinding, options.resolverGetConfig)
  13413. }
  13414. if (concrete) {
  13415. proto.componentType = "UIBound"
  13416. }
  13417. return proto
  13418. };
  13419. options.filter = fluid.expander.lightFilter;
  13420. var expandCond;
  13421. var expandLeafOrCond;
  13422. var expandEntry = function (entry) {
  13423. var comp = [];
  13424. expandCond(entry, comp);
  13425. return {
  13426. children : comp
  13427. }
  13428. };
  13429. var expandExternal = function (entry) {
  13430. if (entry === fluid.renderer.NO_COMPONENT) {
  13431. return entry
  13432. }
  13433. var singleTarget;
  13434. var target = [];
  13435. var pusher = function (comp) {
  13436. singleTarget = comp
  13437. };
  13438. expandLeafOrCond(entry, target, pusher);
  13439. return singleTarget || target
  13440. };
  13441. var expandConfig = {
  13442. model : options.model,
  13443. resolverGetConfig : options.resolverGetConfig,
  13444. resolverSetConfig : options.resolverSetConfig,
  13445. expander : expandExternal,
  13446. expandLight : expandLight
  13447. };
  13448. var expandLeaf = function (leaf, componentType) {
  13449. var togo = {
  13450. componentType : componentType
  13451. };
  13452. var map = fluid.renderer.boundMap[componentType] || {};
  13453. for (var key in leaf) {
  13454. if (/decorators|args/.test(key)) {
  13455. togo[key] = expandLight(leaf[key]);
  13456. continue
  13457. } else {
  13458. if (map[key]) {
  13459. togo[key] = expandBound(leaf[key])
  13460. } else {
  13461. togo[key] = leaf[key]
  13462. }
  13463. }
  13464. }
  13465. return togo
  13466. };
  13467. var expandChildren = function (entry, pusher) {
  13468. var children = entry.children;
  13469. for (var i = 0; i < children.length; ++i) {
  13470. var target = [];
  13471. var comp = {
  13472. children : target
  13473. };
  13474. var child = children[i];
  13475. var childPusher = function (comp) {
  13476. target[target.length] = comp
  13477. };
  13478. expandLeafOrCond(child, target, childPusher);
  13479. if (comp.children.length === 1 && !comp.children[0].ID) {
  13480. comp = comp.children[0]
  13481. }
  13482. pusher(comp)
  13483. }
  13484. };
  13485. function detectBareBound(entry) {
  13486. return fluid.find(entry, function (value, key) {
  13487. return key === "decorators"
  13488. }) !== false
  13489. }
  13490. var expandLeafOrCond = function (entry, target, pusher) {
  13491. var componentType = fluid.renderer.inferComponentType(entry);
  13492. if (!componentType && (fluid.isPrimitive(entry) || detectBareBound(entry))) {
  13493. componentType = "UIBound"
  13494. }
  13495. if (componentType) {
  13496. pusher(componentType === "UIBound" ? expandBound(entry, true) : expandLeaf(entry, componentType))
  13497. } else {
  13498. if (!target) {
  13499. fluid.fail("Illegal cond->cond transition")
  13500. }
  13501. expandCond(entry, target)
  13502. }
  13503. };
  13504. expandCond = function (proto, target) {
  13505. for (var key in proto) {
  13506. var entry = proto[key];
  13507. if (key.charAt(0) === IDescape) {
  13508. key = key.substring(1)
  13509. }
  13510. if (key === "expander") {
  13511. var expanders = fluid.makeArray(entry);
  13512. fluid.each(expanders, function (expander) {
  13513. var expanded = fluid.invokeGlobalFunction(expander.type, [expander, proto, key, expandConfig]);
  13514. if (expanded !== fluid.renderer.NO_COMPONENT) {
  13515. fluid.each(expanded, function (el) {
  13516. target[target.length] = el
  13517. })
  13518. }
  13519. })
  13520. } else {
  13521. if (entry) {
  13522. var condPusher = function (comp) {
  13523. comp.ID = key;
  13524. target[target.length] = comp
  13525. };
  13526. if (entry.children) {
  13527. if (key.indexOf(":") === -1) {
  13528. key = key + ":"
  13529. }
  13530. expandChildren(entry, condPusher)
  13531. } else {
  13532. if (fluid.renderer.isBoundPrimitive(entry)) {
  13533. condPusher(expandBound(entry, true))
  13534. } else {
  13535. expandLeafOrCond(entry, null, condPusher)
  13536. }
  13537. }
  13538. }
  13539. }
  13540. }
  13541. };
  13542. return function (entry) {
  13543. var initEnvironment = $.extend({}, options.envAdd);
  13544. return fluid.withEnvironment({
  13545. rendererEnvironment : initEnvironment
  13546. }, function () {
  13547. return expandEntry(entry)
  13548. })
  13549. }
  13550. }
  13551. })(jQuery, fluid_1_4);
  13552. var fluid_1_4 = fluid_1_4 || {};
  13553. (function ($, fluid) {
  13554. fluid.registerNamespace("fluid.browser");
  13555. fluid.browser.binaryXHR = function () {
  13556. var canSendBinary = window.FormData || (window.XMLHttpRequest && window.XMLHttpRequest.prototype && window.XMLHttpRequest.prototype.sendAsBinary);
  13557. return canSendBinary ? fluid.typeTag("fluid.browser.supportsBinaryXHR") : undefined
  13558. };
  13559. fluid.browser.formData = function () {
  13560. return window.FormData ? fluid.typeTag("fluid.browser.supportsFormData") : undefined
  13561. };
  13562. fluid.browser.flash = function () {
  13563. var hasModernFlash = (typeof(swfobject) !== "undefined") && (swfobject.getFlashPlayerVersion().major > 8);
  13564. return hasModernFlash ? fluid.typeTag("fluid.browser.supportsFlash") : undefined
  13565. };
  13566. fluid.progressiveChecker = function (options) {
  13567. var that = fluid.initLittleComponent("fluid.progressiveChecker", options);
  13568. return fluid.typeTag(fluid.find(that.options.checks, function (check) {
  13569. if (check.feature) {
  13570. return check.contextName
  13571. }
  13572. }, that.options.defaultContextName))
  13573. };
  13574. fluid.defaults("fluid.progressiveChecker", {
  13575. gradeNames : "fluid.typeFount",
  13576. checks : [],
  13577. defaultContextName : undefined
  13578. });
  13579. fluid.progressiveCheckerForComponent = function (options) {
  13580. var that = fluid.initLittleComponent("fluid.progressiveCheckerForComponent", options);
  13581. var defaults = fluid.defaults(that.options.componentName);
  13582. return fluid.progressiveChecker(fluid.expandOptions(defaults.progressiveCheckerOptions, that))
  13583. };
  13584. fluid.defaults("fluid.progressiveCheckerForComponent", {
  13585. gradeNames : "fluid.typeFount"
  13586. });
  13587. $("head").append("<style type='text/css'>.fl-progEnhance-basic, .fl-ProgEnhance-basic { display: none; } .fl-progEnhance-enhanced, .fl-ProgEnhance-enhanced { display: block; }</style>");
  13588. var features = {
  13589. supportsBinaryXHR : fluid.browser.binaryXHR(),
  13590. supportsFormData : fluid.browser.formData(),
  13591. supportsFlash : fluid.browser.flash()
  13592. };
  13593. fluid.merge(null, fluid.staticEnvironment, features)
  13594. })(jQuery, fluid_1_4);
  13595. (function ($) {
  13596. var increments = 0;
  13597. $.widget("ui.tooltip", {
  13598. options : {
  13599. items : "[title]",
  13600. content : function () {
  13601. return $(this).attr("title")
  13602. },
  13603. position : {
  13604. my : "left center",
  13605. at : "right center",
  13606. offset : "15 0"
  13607. }
  13608. },
  13609. _create : function () {
  13610. var self = this;
  13611. this.tooltip = $("<div></div>").attr("id", "ui-tooltip-" + increments++).attr("role", "tooltip").attr("aria-hidden", "true").addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content").appendTo(document.body).hide();
  13612. this.tooltipContent = $("<div></div>").addClass("ui-tooltip-content").appendTo(this.tooltip);
  13613. this.opacity = this.tooltip.css("opacity");
  13614. this.element.bind("focus.tooltip mouseover.tooltip", function (event) {
  13615. self.open(event)
  13616. }).bind("blur.tooltip mouseout.tooltip", function (event) {
  13617. self.close(event)
  13618. })
  13619. },
  13620. enable : function () {
  13621. this.options.disabled = false
  13622. },
  13623. disable : function () {
  13624. this.options.disabled = true
  13625. },
  13626. destroy : function () {
  13627. this.tooltip.remove();
  13628. $.Widget.prototype.destroy.apply(this, arguments)
  13629. },
  13630. widget : function () {
  13631. return this.element.pushStack(this.tooltip.get())
  13632. },
  13633. open : function (event) {
  13634. var target = $(event && event.target || this.element).closest(this.options.items);
  13635. if (this.current && this.current[0] == target[0]) {
  13636. return
  13637. }
  13638. var self = this;
  13639. this.current = target;
  13640. this.currentTitle = target.attr("title");
  13641. var content = this.options.content.call(target[0], function (response) {
  13642. setTimeout(function () {
  13643. if (self.current == target) {
  13644. self._show(event, target, response)
  13645. }
  13646. }, 13)
  13647. });
  13648. if (content) {
  13649. self._show(event, target, content)
  13650. }
  13651. },
  13652. _show : function (event, target, content) {
  13653. if (!content) {
  13654. return
  13655. }
  13656. target.attr("title", "");
  13657. if (this.options.disabled) {
  13658. return
  13659. }
  13660. this.tooltipContent.html(content);
  13661. this.tooltip.css({
  13662. top : 0,
  13663. left : 0
  13664. }).show().position($.extend({
  13665. of : target
  13666. }, this.options.position)).hide();
  13667. this.tooltip.attr("aria-hidden", "false");
  13668. target.attr("aria-describedby", this.tooltip.attr("id"));
  13669. this.tooltip.stop(false, true).fadeIn();
  13670. this._trigger("open", event)
  13671. },
  13672. close : function (event) {
  13673. if (!this.current) {
  13674. return
  13675. }
  13676. var current = this.current;
  13677. this.current = null;
  13678. current.attr("title", this.currentTitle);
  13679. if (this.options.disabled) {
  13680. return
  13681. }
  13682. current.removeAttr("aria-describedby");
  13683. this.tooltip.attr("aria-hidden", "true");
  13684. this.tooltip.stop(false, true).fadeOut();
  13685. this._trigger("close", event)
  13686. }
  13687. })
  13688. })(jQuery);
  13689. var fluid_1_4 = fluid_1_4 || {};
  13690. (function ($, fluid) {
  13691. var STATE_INITIAL = "state_initial",
  13692. STATE_CHANGED = "state_changed",
  13693. STATE_REVERTED = "state_reverted";
  13694. function defaultRenderer(that, targetContainer) {
  13695. var str = that.options.strings;
  13696. var markup = "<span class='flc-undo'><a href='#' class='flc-undo-undoControl'>" + str.undo + "</a><a href='#' class='flc-undo-redoControl'>" + str.redo + "</a></span>";
  13697. var markupNode = $(markup).attr({
  13698. role : "region",
  13699. "aria-live" : "polite",
  13700. "aria-relevant" : "all"
  13701. });
  13702. targetContainer.append(markupNode);
  13703. return markupNode
  13704. }
  13705. function refreshView(that) {
  13706. if (that.state === STATE_INITIAL) {
  13707. that.locate("undoContainer").hide();
  13708. that.locate("redoContainer").hide()
  13709. } else {
  13710. if (that.state === STATE_CHANGED) {
  13711. that.locate("undoContainer").show();
  13712. that.locate("redoContainer").hide()
  13713. } else {
  13714. if (that.state === STATE_REVERTED) {
  13715. that.locate("undoContainer").hide();
  13716. that.locate("redoContainer").show()
  13717. }
  13718. }
  13719. }
  13720. }
  13721. var bindHandlers = function (that) {
  13722. that.locate("undoControl").click(function () {
  13723. if (that.state !== STATE_REVERTED) {
  13724. fluid.model.copyModel(that.extremalModel, that.component.model);
  13725. that.component.updateModel(that.initialModel, that);
  13726. that.state = STATE_REVERTED;
  13727. refreshView(that);
  13728. that.locate("redoControl").focus()
  13729. }
  13730. return false
  13731. });
  13732. that.locate("redoControl").click(function () {
  13733. if (that.state !== STATE_CHANGED) {
  13734. that.component.updateModel(that.extremalModel, that);
  13735. that.state = STATE_CHANGED;
  13736. refreshView(that);
  13737. that.locate("undoControl").focus()
  13738. }
  13739. return false
  13740. });
  13741. return {
  13742. modelChanged : function (newModel, oldModel, source) {
  13743. if (source !== that) {
  13744. that.state = STATE_CHANGED;
  13745. fluid.model.copyModel(that.initialModel, oldModel);
  13746. refreshView(that)
  13747. }
  13748. }
  13749. }
  13750. };
  13751. fluid.undoDecorator = function (component, userOptions) {
  13752. var that = fluid.initLittleComponent("undo", userOptions);
  13753. that.container = that.options.renderer(that, component.container);
  13754. fluid.initDomBinder(that);
  13755. fluid.tabindex(that.locate("undoControl"), 0);
  13756. fluid.tabindex(that.locate("redoControl"), 0);
  13757. that.component = component;
  13758. that.initialModel = {};
  13759. that.extremalModel = {};
  13760. fluid.model.copyModel(that.initialModel, component.model);
  13761. fluid.model.copyModel(that.extremalModel, component.model);
  13762. that.state = STATE_INITIAL;
  13763. refreshView(that);
  13764. var listeners = bindHandlers(that);
  13765. that.returnedOptions = {
  13766. listeners : listeners
  13767. };
  13768. return that
  13769. };
  13770. fluid.defaults("undo", {
  13771. selectors : {
  13772. undoContainer : ".flc-undo-undoControl",
  13773. undoControl : ".flc-undo-undoControl",
  13774. redoContainer : ".flc-undo-redoControl",
  13775. redoControl : ".flc-undo-redoControl"
  13776. },
  13777. strings : {
  13778. undo : "undo edit",
  13779. redo : "redo edit"
  13780. },
  13781. renderer : defaultRenderer
  13782. })
  13783. })(jQuery, fluid_1_4);
  13784. var fluid_1_4 = fluid_1_4 || {};
  13785. (function ($, fluid) {
  13786. var createContentFunc = function (content) {
  13787. return typeof content === "function" ? content : function () {
  13788. return content
  13789. }
  13790. };
  13791. var setup = function (that) {
  13792. that.container.tooltip({
  13793. content : createContentFunc(that.options.content),
  13794. position : that.options.position,
  13795. items : that.options.items,
  13796. open : function (event) {
  13797. var tt = $(event.target).tooltip("widget");
  13798. tt.stop(false, true);
  13799. tt.hide();
  13800. if (that.options.delay) {
  13801. tt.delay(that.options.delay).fadeIn("default", that.events.afterOpen.fire())
  13802. } else {
  13803. tt.show();
  13804. that.events.afterOpen.fire()
  13805. }
  13806. },
  13807. close : function (event) {
  13808. var tt = $(event.target).tooltip("widget");
  13809. tt.stop(false, true);
  13810. tt.hide();
  13811. tt.clearQueue();
  13812. that.events.afterClose.fire()
  13813. }
  13814. });
  13815. that.elm = that.container.tooltip("widget");
  13816. that.elm.addClass(that.options.styles.tooltip)
  13817. };
  13818. fluid.tooltip = function (container, options) {
  13819. var that = fluid.initView("fluid.tooltip", container, options);
  13820. that.updateContent = function (content) {
  13821. that.container.tooltip("option", "content", createContentFunc(content))
  13822. };
  13823. that.destroy = function () {
  13824. that.container.tooltip("destroy")
  13825. };
  13826. that.open = function () {
  13827. that.container.tooltip("open")
  13828. };
  13829. that.close = function () {
  13830. that.container.tooltip("close")
  13831. };
  13832. setup(that);
  13833. return that
  13834. };
  13835. fluid.defaults("fluid.tooltip", {
  13836. styles : {
  13837. tooltip : ""
  13838. },
  13839. events : {
  13840. afterOpen : null,
  13841. afterClose : null
  13842. },
  13843. content : "",
  13844. position : {
  13845. my : "left top",
  13846. at : "left bottom",
  13847. offset : "0 5"
  13848. },
  13849. items : "*",
  13850. delay : 300
  13851. })
  13852. })(jQuery, fluid_1_4);
  13853. var fluid_1_4 = fluid_1_4 || {};
  13854. (function ($, fluid) {
  13855. function sendKey(control, event, virtualCode, charCode) {
  13856. var kE = document.createEvent("KeyEvents");
  13857. kE.initKeyEvent(event, 1, 1, null, 0, 0, 0, 0, virtualCode, charCode);
  13858. control.dispatchEvent(kE)
  13859. }
  13860. fluid.setCaretToEnd = function (control, value) {
  13861. var pos = value ? value.length : 0;
  13862. try {
  13863. control.focus();
  13864. if (control.setSelectionRange) {
  13865. control.setSelectionRange(pos, pos);
  13866. if ($.browser.mozilla && pos > 0) {
  13867. sendKey(control, "keypress", 92, 92);
  13868. sendKey(control, "keydown", 8, 0);
  13869. sendKey(control, "keypress", 8, 0)
  13870. }
  13871. } else {
  13872. if (control.createTextRange) {
  13873. var range = control.createTextRange();
  13874. range.move("character", pos);
  13875. range.select()
  13876. }
  13877. }
  13878. } catch (e) {}
  13879. };
  13880. var switchToViewMode = function (that) {
  13881. that.editContainer.hide();
  13882. that.displayModeRenderer.show()
  13883. };
  13884. var cancel = function (that) {
  13885. if (that.isEditing()) {
  13886. setTimeout(function () {
  13887. that.editView.value(that.model.value)
  13888. }, 1);
  13889. switchToViewMode(that);
  13890. that.events.afterFinishEdit.fire(that.model.value, that.model.value, that.editField[0], that.viewEl[0])
  13891. }
  13892. };
  13893. var finish = function (that) {
  13894. var newValue = that.editView.value();
  13895. var oldValue = that.model.value;
  13896. var viewNode = that.viewEl[0];
  13897. var editNode = that.editField[0];
  13898. var ret = that.events.onFinishEdit.fire(newValue, oldValue, editNode, viewNode);
  13899. if (ret === false) {
  13900. return
  13901. }
  13902. that.updateModelValue(newValue);
  13903. that.events.afterFinishEdit.fire(newValue, oldValue, editNode, viewNode);
  13904. switchToViewMode(that)
  13905. };
  13906. var bindEditFinish = function (that) {
  13907. if (that.options.submitOnEnter === undefined) {
  13908. that.options.submitOnEnter = "textarea" !== fluid.unwrap(that.editField).nodeName.toLowerCase()
  13909. }
  13910. function keyCode(evt) {
  13911. return evt.keyCode ? evt.keyCode : (evt.which ? evt.which : 0)
  13912. }
  13913. var escHandler = function (evt) {
  13914. var code = keyCode(evt);
  13915. if (code === $.ui.keyCode.ESCAPE) {
  13916. that.textEditButton.focus(0);
  13917. cancel(that);
  13918. return false
  13919. }
  13920. };
  13921. var finishHandler = function (evt) {
  13922. var code = keyCode(evt);
  13923. if (code !== $.ui.keyCode.ENTER) {
  13924. that.textEditButton.blur();
  13925. return true
  13926. } else {
  13927. finish(that);
  13928. that.textEditButton.focus(0)
  13929. }
  13930. return false
  13931. };
  13932. if (that.options.submitOnEnter) {
  13933. that.editContainer.keypress(finishHandler)
  13934. }
  13935. that.editContainer.keydown(escHandler)
  13936. };
  13937. var bindBlurHandler = function (that) {
  13938. if (that.options.blurHandlerBinder) {
  13939. that.options.blurHandlerBinder(that)
  13940. } else {
  13941. var blurHandler = function (evt) {
  13942. if (that.isEditing()) {
  13943. finish(that)
  13944. }
  13945. return false
  13946. };
  13947. that.editField.blur(blurHandler)
  13948. }
  13949. };
  13950. var initializeEditView = function (that, initial) {
  13951. if (!that.editInitialized) {
  13952. fluid.inlineEdit.renderEditContainer(that, !that.options.lazyEditView || !initial);
  13953. if (!that.options.lazyEditView || !initial) {
  13954. that.editView = fluid.initSubcomponent(that, "editView", that.editField);
  13955. $.extend(true, that.editView, fluid.initSubcomponent(that, "editAccessor", that.editField));
  13956. bindEditFinish(that);
  13957. bindBlurHandler(that);
  13958. that.editView.refreshView(that);
  13959. that.editInitialized = true
  13960. }
  13961. }
  13962. };
  13963. var edit = function (that) {
  13964. initializeEditView(that, false);
  13965. var viewEl = that.viewEl;
  13966. var displayText = that.displayView.value();
  13967. that.updateModelValue(that.model.value === "" ? "" : displayText);
  13968. if (that.options.applyEditPadding) {
  13969. that.editField.width(Math.max(viewEl.width() + that.options.paddings.edit, that.options.paddings.minimumEdit))
  13970. }
  13971. that.displayModeRenderer.hide();
  13972. that.editContainer.show();
  13973. setTimeout(function () {
  13974. fluid.setCaretToEnd(that.editField[0], that.editView.value());
  13975. if (that.options.selectOnEdit) {
  13976. that.editField[0].select()
  13977. }
  13978. }, 0);
  13979. that.events.afterBeginEdit.fire()
  13980. };
  13981. var clearEmptyViewStyles = function (textEl, styles, originalViewPadding) {
  13982. textEl.removeClass(styles.defaultViewStyle);
  13983. textEl.css("padding-right", originalViewPadding);
  13984. textEl.removeClass(styles.emptyDefaultViewText)
  13985. };
  13986. var showDefaultViewText = function (that) {
  13987. that.displayView.value(that.options.defaultViewText);
  13988. that.viewEl.css("padding-right", that.existingPadding);
  13989. that.viewEl.addClass(that.options.styles.defaultViewStyle)
  13990. };
  13991. var showNothing = function (that) {
  13992. that.displayView.value("");
  13993. if ($.browser.msie) {
  13994. if (that.viewEl.css("display") === "inline") {
  13995. that.viewEl.css("display", "inline-block")
  13996. }
  13997. }
  13998. };
  13999. var showEditedText = function (that) {
  14000. that.displayView.value(that.model.value);
  14001. clearEmptyViewStyles(that.viewEl, that.options.styles, that.existingPadding)
  14002. };
  14003. var refreshView = function (that, source) {
  14004. that.displayView.refreshView(that, source);
  14005. if (that.editView) {
  14006. that.editView.refreshView(that, source)
  14007. }
  14008. };
  14009. var initModel = function (that, value) {
  14010. that.model.value = value;
  14011. that.refreshView()
  14012. };
  14013. var updateModelValue = function (that, newValue, source) {
  14014. var comparator = that.options.modelComparator;
  14015. var unchanged = comparator ? comparator(that.model.value, newValue) : that.model.value === newValue;
  14016. if (!unchanged) {
  14017. var oldModel = $.extend(true, {}, that.model);
  14018. that.model.value = newValue;
  14019. that.events.modelChanged.fire(that.model, oldModel, source);
  14020. that.refreshView(source)
  14021. }
  14022. };
  14023. var makeIsEditing = function (that) {
  14024. var isEditing = false;
  14025. that.events.onBeginEdit.addListener(function () {
  14026. isEditing = true
  14027. });
  14028. that.events.afterFinishEdit.addListener(function () {
  14029. isEditing = false
  14030. });
  14031. return function () {
  14032. return isEditing
  14033. }
  14034. };
  14035. var makeEditHandler = function (that) {
  14036. return function () {
  14037. var prevent = that.events.onBeginEdit.fire();
  14038. if (prevent === false) {
  14039. return false
  14040. }
  14041. edit(that);
  14042. return true
  14043. }
  14044. };
  14045. var initTooltips = function (that) {
  14046. var tooltipOptions = {
  14047. content : that.options.tooltipText,
  14048. position : {
  14049. my : "left top",
  14050. at : "left bottom",
  14051. offset : "0 5"
  14052. },
  14053. target : "*",
  14054. delay : that.options.tooltipDelay,
  14055. styles : {
  14056. tooltip : that.options.styles.tooltip
  14057. }
  14058. };
  14059. fluid.tooltip(that.viewEl, tooltipOptions);
  14060. if (that.textEditButton) {
  14061. fluid.tooltip(that.textEditButton, tooltipOptions)
  14062. }
  14063. };
  14064. var calculateInitialPadding = function (viewEl) {
  14065. var padding = viewEl.css("padding-right");
  14066. return padding ? parseFloat(padding) : 0
  14067. };
  14068. var setupInlineEdit = function (componentContainer, that) {
  14069. if (that.editContainer) {
  14070. that.editContainer.hide()
  14071. }
  14072. if (that.tooltipEnabled()) {
  14073. initTooltips(that)
  14074. }
  14075. that.decorators = fluid.initSubcomponents(that, "componentDecorators", [that, fluid.COMPONENT_OPTIONS])
  14076. };
  14077. var setupInlineEdits = function (editables, options) {
  14078. var editors = [];
  14079. editables.each(function (idx, editable) {
  14080. editors.push(fluid.inlineEdit($(editable), options))
  14081. });
  14082. return editors
  14083. };
  14084. fluid.inlineEdit = function (componentContainer, userOptions) {
  14085. var that = fluid.initView("inlineEdit", componentContainer, userOptions);
  14086. that.viewEl = fluid.inlineEdit.setupDisplayText(that);
  14087. that.displayView = fluid.initSubcomponent(that, "displayView", that.viewEl);
  14088. $.extend(true, that.displayView, fluid.initSubcomponent(that, "displayAccessor", that.viewEl));
  14089. that.model = {
  14090. value : ""
  14091. };
  14092. that.edit = makeEditHandler(that);
  14093. that.isEditing = makeIsEditing(that);
  14094. that.finish = function () {
  14095. finish(that)
  14096. };
  14097. that.cancel = function () {
  14098. cancel(that)
  14099. };
  14100. that.tooltipEnabled = function () {
  14101. return that.options.useTooltip && $.fn.tooltip
  14102. };
  14103. that.refreshView = function (source) {
  14104. refreshView(that, source)
  14105. };
  14106. that.updateModelValue = function (newValue, source) {
  14107. updateModelValue(that, newValue, source)
  14108. };
  14109. that.updateModel = function (newModel, source) {
  14110. updateModelValue(that, newModel.value, source)
  14111. };
  14112. that.existingPadding = calculateInitialPadding(that.viewEl);
  14113. initModel(that, that.displayView.value());
  14114. that.displayModeRenderer = that.options.displayModeRenderer(that);
  14115. initializeEditView(that, true);
  14116. setupInlineEdit(componentContainer, that);
  14117. return that
  14118. };
  14119. fluid.inlineEdit.setupEditField = function (editStyle, editField) {
  14120. var eField = $(editField);
  14121. eField = eField.length ? eField : $("<input type='text' class='flc-inlineEdit-edit'/>");
  14122. eField.addClass(editStyle);
  14123. return eField
  14124. };
  14125. fluid.inlineEdit.setupEditContainer = function (displayContainer, editField, editContainer) {
  14126. var eContainer = $(editContainer);
  14127. eContainer = eContainer.length ? eContainer : $("<span></span>");
  14128. displayContainer.after(eContainer);
  14129. eContainer.append(editField);
  14130. return eContainer
  14131. };
  14132. fluid.inlineEdit.defaultEditModeRenderer = function (that) {
  14133. var editField = fluid.inlineEdit.setupEditField(that.options.styles.edit, that.editField);
  14134. var editContainer = fluid.inlineEdit.setupEditContainer(that.displayModeRenderer, editField, that.editContainer);
  14135. var editModeInstruction = fluid.inlineEdit.setupEditModeInstruction(that.options.styles.editModeInstruction, that.options.strings.editModeInstruction);
  14136. var id = fluid.allocateSimpleId(editModeInstruction);
  14137. editField.attr("aria-describedby", id);
  14138. fluid.inlineEdit.positionEditModeInstruction(editModeInstruction, editContainer, editField);
  14139. return {
  14140. container : editContainer,
  14141. field : editField
  14142. }
  14143. };
  14144. fluid.inlineEdit.renderEditContainer = function (that, lazyEditView) {
  14145. that.editContainer = that.locate("editContainer");
  14146. that.editField = that.locate("edit");
  14147. if (that.editContainer.length !== 1) {
  14148. if (that.editContainer.length > 1) {
  14149. fluid.fail("InlineEdit did not find a unique container for selector " + that.options.selectors.editContainer + ": " + fluid.dumpEl(that.editContainer))
  14150. }
  14151. }
  14152. if (!lazyEditView) {
  14153. return
  14154. }
  14155. var editElms = that.options.editModeRenderer(that);
  14156. if (editElms) {
  14157. that.editContainer = editElms.container;
  14158. that.editField = editElms.field
  14159. }
  14160. };
  14161. fluid.inlineEdit.setupEditModeInstruction = function (editModeInstructionStyle, editModeInstructionText) {
  14162. var editModeInstruction = $("<p></p>");
  14163. editModeInstruction.addClass(editModeInstructionStyle);
  14164. editModeInstruction.text(editModeInstructionText);
  14165. return editModeInstruction
  14166. };
  14167. fluid.inlineEdit.positionEditModeInstruction = function (editModeInstruction, editContainer, editField) {
  14168. editContainer.append(editModeInstruction);
  14169. editField.focus(function () {
  14170. editModeInstruction.show();
  14171. var editFieldPosition = editField.offset();
  14172. editModeInstruction.css({
  14173. left : editFieldPosition.left
  14174. });
  14175. editModeInstruction.css({
  14176. top : editFieldPosition.top + editField.height() + 5
  14177. })
  14178. })
  14179. };
  14180. fluid.inlineEdit.setupDisplayModeContainer = function (styles, displayModeWrapper) {
  14181. var displayModeContainer = $(displayModeWrapper);
  14182. displayModeContainer = displayModeContainer.length ? displayModeContainer : $("<span></span>");
  14183. displayModeContainer.addClass(styles.displayView);
  14184. return displayModeContainer
  14185. };
  14186. fluid.inlineEdit.setupDisplayText = function (that) {
  14187. var viewEl = that.locate("text");
  14188. viewEl.attr("tabindex", "-1");
  14189. viewEl.addClass(that.options.styles.text);
  14190. return viewEl
  14191. };
  14192. fluid.inlineEdit.setupTextEditButton = function (that) {
  14193. var opts = that.options;
  14194. var textEditButton = that.locate("textEditButton");
  14195. if (textEditButton.length === 0) {
  14196. var markup = $("<a href='#_' class='flc-inlineEdit-textEditButton'></a>");
  14197. markup.addClass(opts.styles.textEditButton);
  14198. markup.text(opts.tooltipText);
  14199. fluid.inlineEdit.updateTextEditButton(markup, that.model.value || opts.defaultViewText, opts.strings.textEditButton);
  14200. that.events.modelChanged.addListener(function () {
  14201. fluid.inlineEdit.updateTextEditButton(markup, that.model.value || opts.defaultViewText, opts.strings.textEditButton)
  14202. });
  14203. that.locate("text").after(markup);
  14204. textEditButton = that.locate("textEditButton")
  14205. }
  14206. return textEditButton
  14207. };
  14208. fluid.inlineEdit.updateTextEditButton = function (textEditButton, value, stringTemplate) {
  14209. var buttonText = fluid.stringTemplate(stringTemplate, {
  14210. text : value
  14211. });
  14212. textEditButton.text(buttonText)
  14213. };
  14214. fluid.inlineEdit.bindHoverHandlers = function (displayModeRenderer, invitationStyle) {
  14215. var over = function (evt) {
  14216. displayModeRenderer.addClass(invitationStyle)
  14217. };
  14218. var out = function (evt) {
  14219. displayModeRenderer.removeClass(invitationStyle)
  14220. };
  14221. displayModeRenderer.hover(over, out)
  14222. };
  14223. fluid.inlineEdit.bindHighlightHandler = function (element, displayModeRenderer, styles) {
  14224. element = $(element);
  14225. var focusOn = function () {
  14226. displayModeRenderer.addClass(styles.focus);
  14227. displayModeRenderer.addClass(styles.invitation)
  14228. };
  14229. var focusOff = function () {
  14230. displayModeRenderer.removeClass(styles.focus);
  14231. displayModeRenderer.removeClass(styles.invitation)
  14232. };
  14233. element.focus(focusOn);
  14234. element.blur(focusOff)
  14235. };
  14236. fluid.inlineEdit.bindMouseHandlers = function (element, edit) {
  14237. element = $(element);
  14238. var triggerGuard = fluid.inlineEdit.makeEditTriggerGuard(element, edit);
  14239. element.click(function (e) {
  14240. triggerGuard(e);
  14241. return false
  14242. })
  14243. };
  14244. fluid.inlineEdit.bindKeyboardHandlers = function (element, edit) {
  14245. element = $(element);
  14246. element.attr("role", "button");
  14247. var guard = fluid.inlineEdit.makeEditTriggerGuard(element, edit);
  14248. fluid.activatable(element, function (event) {
  14249. return guard(event)
  14250. })
  14251. };
  14252. fluid.inlineEdit.makeEditTriggerGuard = function (element, edit) {
  14253. var selector = fluid.unwrap(element);
  14254. return function (event) {
  14255. var outer = fluid.findAncestor(event.target, function (elem) {
  14256. if (/input|select|textarea|button|a/i.test(elem.nodeName) || elem === selector) {
  14257. return true
  14258. }
  14259. });
  14260. if (outer === selector) {
  14261. edit();
  14262. return false
  14263. }
  14264. }
  14265. };
  14266. fluid.inlineEdit.defaultDisplayModeRenderer = function (that) {
  14267. var styles = that.options.styles;
  14268. var displayModeWrapper = fluid.inlineEdit.setupDisplayModeContainer(styles);
  14269. var displayModeRenderer = that.viewEl.wrap(displayModeWrapper).parent();
  14270. that.textEditButton = fluid.inlineEdit.setupTextEditButton(that);
  14271. displayModeRenderer.append(that.textEditButton);
  14272. fluid.inlineEdit.bindHoverHandlers(displayModeRenderer, styles.invitation);
  14273. fluid.inlineEdit.bindMouseHandlers(that.viewEl, that.edit);
  14274. fluid.inlineEdit.bindMouseHandlers(that.textEditButton, that.edit);
  14275. fluid.inlineEdit.bindKeyboardHandlers(that.textEditButton, that.edit);
  14276. fluid.inlineEdit.bindHighlightHandler(that.viewEl, displayModeRenderer, styles);
  14277. fluid.inlineEdit.bindHighlightHandler(that.textEditButton, displayModeRenderer, styles);
  14278. return displayModeRenderer
  14279. };
  14280. fluid.inlineEdit.standardAccessor = function (element) {
  14281. var nodeName = element.nodeName.toLowerCase();
  14282. return {
  14283. value : function (newValue) {
  14284. return "input" === nodeName || "textarea" === nodeName ? fluid.value($(element), newValue) : $(element).text(newValue)
  14285. }
  14286. }
  14287. };
  14288. fluid.inlineEdit.standardDisplayView = function (viewEl) {
  14289. var that = {
  14290. refreshView : function (componentThat, source) {
  14291. if (componentThat.model.value) {
  14292. showEditedText(componentThat)
  14293. } else {
  14294. if (componentThat.options.defaultViewText) {
  14295. showDefaultViewText(componentThat)
  14296. } else {
  14297. showNothing(componentThat)
  14298. }
  14299. }
  14300. if ($.trim(componentThat.viewEl.text()).length === 0) {
  14301. componentThat.viewEl.addClass(componentThat.options.styles.emptyDefaultViewText);
  14302. if (componentThat.existingPadding < componentThat.options.paddings.minimumView) {
  14303. componentThat.viewEl.css("padding-right", componentThat.options.paddings.minimumView)
  14304. }
  14305. }
  14306. }
  14307. };
  14308. return that
  14309. };
  14310. fluid.inlineEdit.standardEditView = function (editField) {
  14311. var that = {
  14312. refreshView : function (componentThat, source) {
  14313. if (!source || (componentThat.editField && componentThat.editField.index(source) === -1)) {
  14314. componentThat.editView.value(componentThat.model.value)
  14315. }
  14316. }
  14317. };
  14318. $.extend(true, that, fluid.inlineEdit.standardAccessor(editField));
  14319. return that
  14320. };
  14321. fluid.inlineEdits = function (componentContainer, options) {
  14322. options = options || {};
  14323. var selectors = $.extend({}, fluid.defaults("inlineEdits").selectors, options.selectors);
  14324. var container = fluid.container(componentContainer);
  14325. var editables = $(selectors.editables, container);
  14326. return setupInlineEdits(editables, options)
  14327. };
  14328. fluid.defaults("inlineEdit", {
  14329. selectors : {
  14330. text : ".flc-inlineEdit-text",
  14331. editContainer : ".flc-inlineEdit-editContainer",
  14332. edit : ".flc-inlineEdit-edit",
  14333. textEditButton : ".flc-inlineEdit-textEditButton"
  14334. },
  14335. styles : {
  14336. text : "fl-inlineEdit-text",
  14337. edit : "fl-inlineEdit-edit",
  14338. invitation : "fl-inlineEdit-invitation",
  14339. defaultViewStyle : "fl-inlineEdit-emptyText-invitation",
  14340. emptyDefaultViewText : "fl-inlineEdit-emptyDefaultViewText",
  14341. focus : "fl-inlineEdit-focus",
  14342. tooltip : "fl-inlineEdit-tooltip",
  14343. editModeInstruction : "fl-inlineEdit-editModeInstruction",
  14344. displayView : "fl-inlineEdit-simple-editableText fl-inlineEdit-textContainer",
  14345. textEditButton : "fl-offScreen-hidden"
  14346. },
  14347. events : {
  14348. modelChanged : null,
  14349. onBeginEdit : "preventable",
  14350. afterBeginEdit : null,
  14351. onFinishEdit : "preventable",
  14352. afterFinishEdit : null,
  14353. afterInitEdit : null
  14354. },
  14355. strings : {
  14356. textEditButton : "Edit text %text",
  14357. editModeInstruction : "Escape to cancel, Enter or Tab when finished"
  14358. },
  14359. paddings : {
  14360. edit : 10,
  14361. minimumEdit : 80,
  14362. minimumView : 60
  14363. },
  14364. applyEditPadding : true,
  14365. blurHandlerBinder : null,
  14366. submitOnEnter : undefined,
  14367. modelComparator : null,
  14368. displayAccessor : {
  14369. type : "fluid.inlineEdit.standardAccessor"
  14370. },
  14371. displayView : {
  14372. type : "fluid.inlineEdit.standardDisplayView"
  14373. },
  14374. editAccessor : {
  14375. type : "fluid.inlineEdit.standardAccessor"
  14376. },
  14377. editView : {
  14378. type : "fluid.inlineEdit.standardEditView"
  14379. },
  14380. displayModeRenderer : fluid.inlineEdit.defaultDisplayModeRenderer,
  14381. editModeRenderer : fluid.inlineEdit.defaultEditModeRenderer,
  14382. lazyEditView : false,
  14383. defaultViewText : "Click here to edit",
  14384. useTooltip : true,
  14385. tooltipText : "Select or press Enter to edit",
  14386. tooltipDelay : 1000,
  14387. selectOnEdit : false
  14388. });
  14389. fluid.defaults("inlineEdits", {
  14390. selectors : {
  14391. editables : ".flc-inlineEditable"
  14392. }
  14393. })
  14394. })(jQuery, fluid_1_4);
  14395. var fluid_1_4 = fluid_1_4 || {};
  14396. (function ($, fluid) {
  14397. fluid.inlineEdit.makeViewAccessor = function (editorGetFn, setValueFn, getValueFn) {
  14398. return function (editField) {
  14399. return {
  14400. value : function (newValue) {
  14401. var editor = editorGetFn(editField);
  14402. if (!editor) {
  14403. if (newValue) {
  14404. $(editField).val(newValue)
  14405. }
  14406. return ""
  14407. }
  14408. if (newValue) {
  14409. setValueFn(editField, editor, newValue)
  14410. } else {
  14411. return getValueFn(editor)
  14412. }
  14413. }
  14414. }
  14415. }
  14416. };
  14417. fluid.inlineEdit.richTextViewAccessor = function (element) {
  14418. return {
  14419. value : function (newValue) {
  14420. return $(element).html(newValue)
  14421. }
  14422. }
  14423. };
  14424. var configureInlineEdit = function (configurationName, container, options) {
  14425. var defaults = fluid.defaults(configurationName);
  14426. var assembleOptions = fluid.merge(defaults ? defaults.mergePolicy : null, {}, defaults, options);
  14427. return fluid.inlineEdit(container, assembleOptions)
  14428. };
  14429. fluid.inlineEdit.normalizeHTML = function (value) {
  14430. var togo = $.trim(value.replace(/\s+/g, " "));
  14431. togo = togo.replace(/\s+<\//g, "</");
  14432. togo = togo.replace(/\<([a-z0-9A-Z\/]+)\>/g, function (match) {
  14433. return match.toLowerCase()
  14434. });
  14435. return togo
  14436. };
  14437. fluid.inlineEdit.htmlComparator = function (el1, el2) {
  14438. return fluid.inlineEdit.normalizeHTML(el1) === fluid.inlineEdit.normalizeHTML(el2)
  14439. };
  14440. fluid.inlineEdit.bindRichTextHighlightHandler = function (element, displayModeRenderer, invitationStyle) {
  14441. element = $(element);
  14442. var focusOn = function () {
  14443. displayModeRenderer.addClass(invitationStyle)
  14444. };
  14445. var focusOff = function () {
  14446. displayModeRenderer.removeClass(invitationStyle)
  14447. };
  14448. element.focus(focusOn);
  14449. element.blur(focusOff)
  14450. };
  14451. fluid.inlineEdit.setupRichTextEditButton = function (that) {
  14452. var opts = that.options;
  14453. var textEditButton = that.locate("textEditButton");
  14454. if (textEditButton.length === 0) {
  14455. var markup = $("<a href='#_' class='flc-inlineEdit-textEditButton'></a>");
  14456. markup.text(opts.strings.textEditButton);
  14457. that.locate("text").after(markup);
  14458. textEditButton = that.locate("textEditButton")
  14459. }
  14460. return textEditButton
  14461. };
  14462. fluid.inlineEdit.richTextDisplayModeRenderer = function (that) {
  14463. var styles = that.options.styles;
  14464. var displayModeWrapper = fluid.inlineEdit.setupDisplayModeContainer(styles);
  14465. var displayModeRenderer = that.viewEl.wrap(displayModeWrapper).parent();
  14466. that.textEditButton = fluid.inlineEdit.setupRichTextEditButton(that);
  14467. displayModeRenderer.append(that.textEditButton);
  14468. displayModeRenderer.addClass(styles.focus);
  14469. fluid.inlineEdit.bindHoverHandlers(displayModeRenderer, styles.invitation);
  14470. fluid.inlineEdit.bindMouseHandlers(that.textEditButton, that.edit);
  14471. fluid.inlineEdit.bindKeyboardHandlers(that.textEditButton, that.edit);
  14472. fluid.inlineEdit.bindRichTextHighlightHandler(that.viewEl, displayModeRenderer, styles.invitation);
  14473. fluid.inlineEdit.bindRichTextHighlightHandler(that.textEditButton, displayModeRenderer, styles.invitation);
  14474. return displayModeRenderer
  14475. };
  14476. fluid.inlineEdit.tinyMCE = function (container, options) {
  14477. var inlineEditor = configureInlineEdit("fluid.inlineEdit.tinyMCE", container, options);
  14478. tinyMCE.init(inlineEditor.options.tinyMCE);
  14479. return inlineEditor
  14480. };
  14481. fluid.inlineEdit.tinyMCE.getEditor = function (editField) {
  14482. return tinyMCE.get(editField.id)
  14483. };
  14484. fluid.inlineEdit.tinyMCE.setValue = function (editField, editor, value) {
  14485. $(editField).val(value);
  14486. editor.setContent(value, {
  14487. format : "raw"
  14488. })
  14489. };
  14490. fluid.inlineEdit.tinyMCE.getValue = function (editor) {
  14491. return editor.getContent()
  14492. };
  14493. var flTinyMCE = fluid.inlineEdit.tinyMCE;
  14494. flTinyMCE.viewAccessor = fluid.inlineEdit.makeViewAccessor(flTinyMCE.getEditor, flTinyMCE.setValue, flTinyMCE.getValue);
  14495. fluid.inlineEdit.tinyMCE.blurHandlerBinder = function (that) {
  14496. function focusEditor(editor) {
  14497. setTimeout(function () {
  14498. tinyMCE.execCommand("mceFocus", false, that.editField[0].id);
  14499. if ($.browser.mozilla && $.browser.version.substring(0, 3) === "1.8") {
  14500. return
  14501. }
  14502. editor.selection.select(editor.getBody(), 1);
  14503. editor.selection.collapse(0)
  14504. }, 10)
  14505. }
  14506. that.events.afterInitEdit.addListener(function (editor) {
  14507. focusEditor(editor);
  14508. var editorBody = editor.getBody();
  14509. fluid.deadMansBlur(that.editField, {
  14510. exclusions : {
  14511. body : $(editorBody)
  14512. },
  14513. handler : function () {
  14514. that.cancel()
  14515. }
  14516. })
  14517. });
  14518. that.events.afterBeginEdit.addListener(function () {
  14519. var editor = tinyMCE.get(that.editField[0].id);
  14520. if (editor) {
  14521. focusEditor(editor)
  14522. }
  14523. })
  14524. };
  14525. fluid.inlineEdit.tinyMCE.editModeRenderer = function (that) {
  14526. var options = that.options.tinyMCE;
  14527. options.elements = fluid.allocateSimpleId(that.editField);
  14528. var oldinit = options.init_instance_callback;
  14529. options.init_instance_callback = function (instance) {
  14530. that.events.afterInitEdit.fire(instance);
  14531. if (oldinit) {
  14532. oldinit()
  14533. }
  14534. };
  14535. tinyMCE.init(options)
  14536. };
  14537. fluid.defaults("fluid.inlineEdit.tinyMCE", {
  14538. tinyMCE : {
  14539. mode : "exact",
  14540. theme : "simple"
  14541. },
  14542. useTooltip : true,
  14543. selectors : {
  14544. edit : "textarea"
  14545. },
  14546. styles : {
  14547. invitation : "fl-inlineEdit-richText-invitation",
  14548. displayView : "fl-inlineEdit-textContainer",
  14549. text : ""
  14550. },
  14551. strings : {
  14552. textEditButton : "Edit"
  14553. },
  14554. displayAccessor : {
  14555. type : "fluid.inlineEdit.richTextViewAccessor"
  14556. },
  14557. editAccessor : {
  14558. type : "fluid.inlineEdit.tinyMCE.viewAccessor"
  14559. },
  14560. lazyEditView : true,
  14561. defaultViewText : "Click Edit",
  14562. modelComparator : fluid.inlineEdit.htmlComparator,
  14563. blurHandlerBinder : fluid.inlineEdit.tinyMCE.blurHandlerBinder,
  14564. displayModeRenderer : fluid.inlineEdit.richTextDisplayModeRenderer,
  14565. editModeRenderer : fluid.inlineEdit.tinyMCE.editModeRenderer
  14566. });
  14567. fluid.inlineEdit.CKEditor = function (container, options) {
  14568. return configureInlineEdit("fluid.inlineEdit.CKEditor", container, options)
  14569. };
  14570. fluid.inlineEdit.CKEditor.getEditor = function (editField) {
  14571. return CKEDITOR.instances[editField.id]
  14572. };
  14573. fluid.inlineEdit.CKEditor.setValue = function (editField, editor, value) {
  14574. editor.setData(value)
  14575. };
  14576. fluid.inlineEdit.CKEditor.getValue = function (editor) {
  14577. return editor.getData()
  14578. };
  14579. var flCKEditor = fluid.inlineEdit.CKEditor;
  14580. flCKEditor.viewAccessor = fluid.inlineEdit.makeViewAccessor(flCKEditor.getEditor, flCKEditor.setValue, flCKEditor.getValue);
  14581. fluid.inlineEdit.CKEditor.focus = function (editor) {
  14582. setTimeout(function () {
  14583. editor.focus()
  14584. }, 0)
  14585. };
  14586. fluid.inlineEdit.CKEditor.normalizeHTML = function (value) {
  14587. var togo = fluid.inlineEdit.normalizeHTML(value);
  14588. var angpos = togo.indexOf(">");
  14589. if (angpos !== -1 && angpos < togo.length - 1) {
  14590. if (togo.charAt(angpos + 1) !== " ") {
  14591. togo = togo.substring(0, angpos + 1) + " " + togo.substring(angpos + 1)
  14592. }
  14593. }
  14594. return togo
  14595. };
  14596. fluid.inlineEdit.CKEditor.htmlComparator = function (el1, el2) {
  14597. return fluid.inlineEdit.CKEditor.normalizeHTML(el1) === fluid.inlineEdit.CKEditor.normalizeHTML(el2)
  14598. };
  14599. fluid.inlineEdit.CKEditor.blurHandlerBinder = function (that) {
  14600. that.events.afterInitEdit.addListener(fluid.inlineEdit.CKEditor.focus);
  14601. that.events.afterBeginEdit.addListener(function () {
  14602. var editor = fluid.inlineEdit.CKEditor.getEditor(that.editField[0]);
  14603. if (editor) {
  14604. fluid.inlineEdit.CKEditor.focus(editor)
  14605. }
  14606. })
  14607. };
  14608. fluid.inlineEdit.CKEditor.editModeRenderer = function (that) {
  14609. var id = fluid.allocateSimpleId(that.editField);
  14610. $.data(fluid.unwrap(that.editField), "fluid.inlineEdit.CKEditor", that);
  14611. var editor = CKEDITOR.replace(id, that.options.CKEditor);
  14612. editor.on("instanceReady", function (e) {
  14613. fluid.inlineEdit.CKEditor.focus(e.editor);
  14614. that.events.afterInitEdit.fire(e.editor)
  14615. })
  14616. };
  14617. fluid.defaults("fluid.inlineEdit.CKEditor", {
  14618. selectors : {
  14619. edit : "textarea"
  14620. },
  14621. styles : {
  14622. invitation : "fl-inlineEdit-richText-invitation",
  14623. displayView : "fl-inlineEdit-textContainer",
  14624. text : ""
  14625. },
  14626. strings : {
  14627. textEditButton : "Edit"
  14628. },
  14629. displayAccessor : {
  14630. type : "fluid.inlineEdit.richTextViewAccessor"
  14631. },
  14632. editAccessor : {
  14633. type : "fluid.inlineEdit.CKEditor.viewAccessor"
  14634. },
  14635. lazyEditView : true,
  14636. defaultViewText : "Click Edit",
  14637. modelComparator : fluid.inlineEdit.CKEditor.htmlComparator,
  14638. blurHandlerBinder : fluid.inlineEdit.CKEditor.blurHandlerBinder,
  14639. displayModeRenderer : fluid.inlineEdit.richTextDisplayModeRenderer,
  14640. editModeRenderer : fluid.inlineEdit.CKEditor.editModeRenderer,
  14641. CKEditor : {}
  14642. });
  14643. fluid.inlineEdit.dropdown = function (container, options) {
  14644. return configureInlineEdit("fluid.inlineEdit.dropdown", container, options)
  14645. };
  14646. fluid.inlineEdit.dropdown.editModeRenderer = function (that) {
  14647. var id = fluid.allocateSimpleId(that.editField);
  14648. that.editField.selectbox({
  14649. finishHandler : function () {
  14650. that.finish()
  14651. }
  14652. });
  14653. return {
  14654. container : that.editContainer,
  14655. field : $("input.selectbox", that.editContainer)
  14656. }
  14657. };
  14658. fluid.inlineEdit.dropdown.blurHandlerBinder = function (that) {
  14659. fluid.deadMansBlur(that.editField, {
  14660. exclusions : {
  14661. selectBox : $("div.selectbox-wrapper", that.editContainer)
  14662. },
  14663. handler : function () {
  14664. that.cancel()
  14665. }
  14666. })
  14667. };
  14668. fluid.defaults("fluid.inlineEdit.dropdown", {
  14669. applyEditPadding : false,
  14670. blurHandlerBinder : fluid.inlineEdit.dropdown.blurHandlerBinder,
  14671. editModeRenderer : fluid.inlineEdit.dropdown.editModeRenderer
  14672. })
  14673. })(jQuery, fluid_1_4);
  14674. (function ($) {
  14675. $.fn.bgIframe = $.fn.bgiframe = function (s) {
  14676. if ($.browser.msie && parseInt($.browser.version) <= 6) {
  14677. s = $.extend({
  14678. top : "auto",
  14679. left : "auto",
  14680. width : "auto",
  14681. height : "auto",
  14682. opacity : true,
  14683. src : "javascript:false;"
  14684. }, s || {});
  14685. var prop = function (n) {
  14686. return n && n.constructor == Number ? n + "px" : n
  14687. },
  14688. html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"style="display:block;position:absolute;z-index:-1;' + (s.opacity !== false ? "filter:Alpha(Opacity='0');" : "") + "top:" + (s.top == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')" : prop(s.top)) + ";left:" + (s.left == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')" : prop(s.left)) + ";width:" + (s.width == "auto" ? "expression(this.parentNode.offsetWidth+'px')" : prop(s.width)) + ";height:" + (s.height == "auto" ? "expression(this.parentNode.offsetHeight+'px')" : prop(s.height)) + ';"/>';
  14689. return this.each(function () {
  14690. if ($("> iframe.bgiframe", this).length == 0) {
  14691. this.insertBefore(document.createElement(html), this.firstChild)
  14692. }
  14693. })
  14694. }
  14695. return this
  14696. };
  14697. if (!$.browser.version) {
  14698. $.browser.version = navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1]
  14699. }
  14700. })(jQuery);
  14701. var fluid_1_4 = fluid_1_4 || {};
  14702. (function ($, fluid) {
  14703. function updateStyles(pageListThat, newModel, oldModel) {
  14704. if (!pageListThat.pageLinks) {
  14705. return
  14706. }
  14707. if (oldModel.pageIndex !== undefined) {
  14708. var oldLink = pageListThat.pageLinks.eq(oldModel.pageIndex);
  14709. oldLink.removeClass(pageListThat.options.styles.currentPage)
  14710. }
  14711. var pageLink = pageListThat.pageLinks.eq(newModel.pageIndex);
  14712. pageLink.addClass(pageListThat.options.styles.currentPage)
  14713. }
  14714. function bindLinkClick(link, events, eventArg) {
  14715. link.unbind("click.fluid.pager");
  14716. link.bind("click.fluid.pager", function () {
  14717. events.initiatePageChange.fire(eventArg)
  14718. })
  14719. }
  14720. function computePageCount(model) {
  14721. model.pageCount = Math.max(1, Math.floor((model.totalRange - 1) / model.pageSize) + 1)
  14722. }
  14723. fluid.pager = function () {
  14724. return fluid.pagerImpl.apply(null, arguments)
  14725. };
  14726. fluid.pager.computePageLimit = function (model) {
  14727. return Math.min(model.totalRange, (model.pageIndex + 1) * model.pageSize)
  14728. };
  14729. fluid.pager.directPageList = function (container, events, options) {
  14730. var that = fluid.initView("fluid.pager.directPageList", container, options);
  14731. that.pageLinks = that.locate("pageLinks");
  14732. for (var i = 0; i < that.pageLinks.length; ++i) {
  14733. var pageLink = that.pageLinks.eq(i);
  14734. bindLinkClick(pageLink, events, {
  14735. pageIndex : i
  14736. })
  14737. }
  14738. events.onModelChange.addListener(function (newModel, oldModel) {
  14739. updateStyles(that, newModel, oldModel)
  14740. });
  14741. that.defaultModel = {
  14742. pageIndex : undefined,
  14743. pageSize : 1,
  14744. totalRange : that.pageLinks.length
  14745. };
  14746. return that
  14747. };
  14748. fluid.iota = function (count, first) {
  14749. first = first || 0;
  14750. var togo = [];
  14751. for (var i = 0; i < count; ++i) {
  14752. togo[togo.length] = first++
  14753. }
  14754. return togo
  14755. };
  14756. fluid.pager.everyPageStrategy = fluid.iota;
  14757. fluid.pager.gappedPageStrategy = function (locality, midLocality) {
  14758. if (!locality) {
  14759. locality = 3
  14760. }
  14761. if (!midLocality) {
  14762. midLocality = locality
  14763. }
  14764. return function (count, first, mid) {
  14765. var togo = [];
  14766. var j = 0;
  14767. var lastSkip = false;
  14768. for (var i = 0; i < count; ++i) {
  14769. if (i < locality || (count - i - 1) < locality || (i >= mid - midLocality && i <= mid + midLocality)) {
  14770. togo[j++] = i;
  14771. lastSkip = false
  14772. } else {
  14773. if (!lastSkip) {
  14774. togo[j++] = -1;
  14775. lastSkip = true
  14776. }
  14777. }
  14778. }
  14779. return togo
  14780. }
  14781. };
  14782. fluid.pager.consistentGappedPageStrategy = function (endLinkCount, midLinkCount) {
  14783. if (!endLinkCount) {
  14784. endLinkCount = 1
  14785. }
  14786. if (!midLinkCount) {
  14787. midLinkCount = endLinkCount
  14788. }
  14789. var endWidth = endLinkCount + 2 + midLinkCount;
  14790. return function (count, first, mid) {
  14791. var pages = [];
  14792. var anchoredLeft = mid < endWidth;
  14793. var anchoredRight = mid >= count - endWidth;
  14794. var anchoredEndWidth = endWidth + midLinkCount;
  14795. var midStart = mid - midLinkCount;
  14796. var midEnd = mid + midLinkCount;
  14797. var lastSkip = false;
  14798. for (var page = 0; page < count; page++) {
  14799. if (page < endLinkCount || count - page <= endLinkCount || (anchoredLeft && page < anchoredEndWidth) || (anchoredRight && page >= count - anchoredEndWidth) || (page >= midStart && page <= midEnd)) {
  14800. pages.push(page);
  14801. lastSkip = false
  14802. } else {
  14803. if (!lastSkip) {
  14804. pages.push(-1);
  14805. lastSkip = true
  14806. }
  14807. }
  14808. }
  14809. return pages
  14810. }
  14811. };
  14812. fluid.pager.renderedPageList = function (container, events, pagerBarOptions, options, strings) {
  14813. options = $.extend(true, pagerBarOptions, options);
  14814. var that = fluid.initView("fluid.pager.renderedPageList", container, options);
  14815. options = that.options;
  14816. var idMap = {};
  14817. var renderOptions = {
  14818. cutpoints : [{
  14819. id : "page-link:link",
  14820. selector : pagerBarOptions.selectors.pageLinks
  14821. }, {
  14822. id : "page-link:skip",
  14823. selector : pagerBarOptions.selectors.pageLinkSkip
  14824. }
  14825. ],
  14826. idMap : idMap
  14827. };
  14828. if (options.linkBody) {
  14829. renderOptions.cutpoints[renderOptions.cutpoints.length] = {
  14830. id : "payload-component",
  14831. selector : options.linkBody
  14832. }
  14833. }
  14834. var assembleComponent = function (page, isCurrent) {
  14835. var obj = {
  14836. ID : "page-link:link",
  14837. localID : page + 1,
  14838. value : page + 1,
  14839. pageIndex : page,
  14840. decorators : [{
  14841. type : "jQuery",
  14842. func : "click",
  14843. args : function (event) {
  14844. events.initiatePageChange.fire({
  14845. pageIndex : page
  14846. });
  14847. event.preventDefault()
  14848. }
  14849. }
  14850. ]
  14851. };
  14852. if (isCurrent) {
  14853. obj.current = true;
  14854. obj.decorators = obj.decorators.concat([{
  14855. type : "addClass",
  14856. classes : that.options.styles.currentPage
  14857. }, {
  14858. type : "jQuery",
  14859. func : "attr",
  14860. args : ["aria-label", that.options.strings.currentPageIndexMsg]
  14861. }
  14862. ])
  14863. }
  14864. return obj
  14865. };
  14866. function pageToComponent(current) {
  14867. return function (page) {
  14868. return page === -1 ? {
  14869. ID : "page-link:skip"
  14870. }
  14871. : assembleComponent(page, page === current)
  14872. }
  14873. }
  14874. var root = that.locate("root");
  14875. fluid.expectFilledSelector(root, "Error finding root template for fluid.pager.renderedPageList");
  14876. var template = fluid.selfRender(root, {}, renderOptions);
  14877. events.onModelChange.addListener(function (newModel, oldModel) {
  14878. var pages = that.options.pageStrategy(newModel.pageCount, 0, newModel.pageIndex);
  14879. var pageTree = fluid.transform(pages, pageToComponent(newModel.pageIndex));
  14880. if (pageTree.length > 1) {
  14881. pageTree[pageTree.length - 1].value = pageTree[pageTree.length - 1].value + strings.last
  14882. }
  14883. events.onRenderPageLinks.fire(pageTree, newModel);
  14884. $.each(idMap, function (key, id) {
  14885. var pageLink = fluid.jById(id);
  14886. if (pageLink.tooltip) {
  14887. pageLink.tooltip("destroy")
  14888. }
  14889. });
  14890. fluid.reRender(template, root, pageTree, renderOptions);
  14891. updateStyles(that, newModel, oldModel)
  14892. });
  14893. return that
  14894. };
  14895. fluid.defaults("fluid.pager.renderedPageList", {
  14896. selectors : {
  14897. root : ".flc-pager-links"
  14898. },
  14899. linkBody : "a",
  14900. pageStrategy : fluid.pager.everyPageStrategy
  14901. });
  14902. var updatePreviousNext = function (that, options, newModel) {
  14903. if (newModel.pageIndex === 0) {
  14904. that.previous.addClass(options.styles.disabled)
  14905. } else {
  14906. that.previous.removeClass(options.styles.disabled)
  14907. }
  14908. if (newModel.pageIndex === newModel.pageCount - 1) {
  14909. that.next.addClass(options.styles.disabled)
  14910. } else {
  14911. that.next.removeClass(options.styles.disabled)
  14912. }
  14913. };
  14914. fluid.pager.previousNext = function (container, events, options) {
  14915. var that = fluid.initView("fluid.pager.previousNext", container, options);
  14916. that.previous = that.locate("previous");
  14917. bindLinkClick(that.previous, events, {
  14918. relativePage : -1
  14919. });
  14920. that.next = that.locate("next");
  14921. bindLinkClick(that.next, events, {
  14922. relativePage : +1
  14923. });
  14924. events.onModelChange.addListener(function (newModel, oldModel, overallThat) {
  14925. updatePreviousNext(that, options, newModel)
  14926. });
  14927. return that
  14928. };
  14929. fluid.pager.pagerBar = function (events, container, options, strings) {
  14930. var that = fluid.initView("fluid.pager.pagerBar", container, options);
  14931. that.pageList = fluid.initSubcomponent(that, "pageList", [container, events, that.options, fluid.COMPONENT_OPTIONS, strings]);
  14932. that.previousNext = fluid.initSubcomponent(that, "previousNext", [container, events, that.options, fluid.COMPONENT_OPTIONS, strings]);
  14933. return that
  14934. };
  14935. fluid.defaults("fluid.pager.pagerBar", {
  14936. previousNext : {
  14937. type : "fluid.pager.previousNext"
  14938. },
  14939. pageList : {
  14940. type : "fluid.pager.renderedPageList",
  14941. options : {
  14942. pageStrategy : fluid.pager.gappedPageStrategy(3, 1)
  14943. }
  14944. },
  14945. selectors : {
  14946. pageLinks : ".flc-pager-pageLink",
  14947. pageLinkSkip : ".flc-pager-pageLink-skip",
  14948. previous : ".flc-pager-previous",
  14949. next : ".flc-pager-next"
  14950. },
  14951. styles : {
  14952. currentPage : "fl-pager-currentPage",
  14953. disabled : "fl-pager-disabled"
  14954. },
  14955. strings : {
  14956. currentPageIndexMsg : "Current page"
  14957. }
  14958. });
  14959. function getColumnDefs(that) {
  14960. return that.options.columnDefs
  14961. }
  14962. fluid.pager.findColumnDef = function (columnDefs, key) {
  14963. var columnDef = $.grep(columnDefs, function (def) {
  14964. return def.key === key
  14965. })[0];
  14966. return columnDef
  14967. };
  14968. function getRoots(target, overallThat, index) {
  14969. var cellRoot = (overallThat.options.dataOffset ? overallThat.options.dataOffset + "." : "");
  14970. target.shortRoot = index;
  14971. target.longRoot = cellRoot + target.shortRoot
  14972. }
  14973. function expandPath(EL, shortRoot, longRoot) {
  14974. if (EL.charAt(0) === "*") {
  14975. return longRoot + EL.substring(1)
  14976. } else {
  14977. return EL.replace("*", shortRoot)
  14978. }
  14979. }
  14980. fluid.pager.fetchValue = function (that, dataModel, index, valuebinding, roots) {
  14981. getRoots(roots, that, index);
  14982. var path = expandPath(valuebinding, roots.shortRoot, roots.longRoot);
  14983. return fluid.get(dataModel, path)
  14984. };
  14985. fluid.pager.basicSorter = function (overallThat, model) {
  14986. var dataModel = overallThat.options.dataModel;
  14987. var roots = {};
  14988. var columnDefs = getColumnDefs(overallThat);
  14989. var columnDef = fluid.pager.findColumnDef(columnDefs, model.sortKey);
  14990. var sortrecs = [];
  14991. for (var i = 0; i < model.totalRange; ++i) {
  14992. sortrecs[i] = {
  14993. index : i,
  14994. value : fluid.pager.fetchValue(overallThat, dataModel, i, columnDef.valuebinding, roots)
  14995. }
  14996. }
  14997. function sortfunc(arec, brec) {
  14998. var a = arec.value;
  14999. var b = brec.value;
  15000. return a === b ? 0 : (a > b ? model.sortDir : -model.sortDir)
  15001. }
  15002. sortrecs.sort(sortfunc);
  15003. return fluid.transform(sortrecs, function (row) {
  15004. return row.index
  15005. })
  15006. };
  15007. fluid.pager.directModelFilter = function (model, pagerModel, perm) {
  15008. var togo = [];
  15009. var limit = fluid.pager.computePageLimit(pagerModel);
  15010. for (var i = pagerModel.pageIndex * pagerModel.pageSize; i < limit; ++i) {
  15011. var index = perm ? perm[i] : i;
  15012. togo[togo.length] = {
  15013. index : index,
  15014. row : model[index]
  15015. }
  15016. }
  15017. return togo
  15018. };
  15019. function expandVariables(value, opts) {
  15020. var togo = "";
  15021. var index = 0;
  15022. while (true) {
  15023. var nextindex = value.indexOf("${", index);
  15024. if (nextindex === -1) {
  15025. togo += value.substring(index);
  15026. break
  15027. } else {
  15028. togo += value.substring(index, nextindex);
  15029. var endi = value.indexOf("}", nextindex + 2);
  15030. var EL = value.substring(nextindex + 2, endi);
  15031. if (EL === "VALUE") {
  15032. EL = opts.EL
  15033. } else {
  15034. EL = expandPath(EL, opts.shortRoot, opts.longRoot)
  15035. }
  15036. var val = fluid.get(opts.dataModel, EL);
  15037. togo += val;
  15038. index = endi + 1
  15039. }
  15040. }
  15041. return togo
  15042. }
  15043. function expandPaths(target, tree, opts) {
  15044. for (var i in tree) {
  15045. var val = tree[i];
  15046. if (val === fluid.VALUE) {
  15047. if (i === "valuebinding") {
  15048. target[i] = opts.EL
  15049. } else {
  15050. target[i] = {
  15051. valuebinding : opts.EL
  15052. }
  15053. }
  15054. } else {
  15055. if (i === "valuebinding") {
  15056. target[i] = expandPath(tree[i], opts)
  15057. } else {
  15058. if (typeof(val) === "object") {
  15059. target[i] = val.length !== undefined ? [] : {};
  15060. expandPaths(target[i], val, opts)
  15061. } else {
  15062. if (typeof(val) === "string") {
  15063. target[i] = expandVariables(val, opts)
  15064. } else {
  15065. target[i] = tree[i]
  15066. }
  15067. }
  15068. }
  15069. }
  15070. }
  15071. return target
  15072. }
  15073. function iDforColumn(columnDef, opts) {
  15074. var options = opts.options;
  15075. var EL = columnDef.valuebinding;
  15076. var key = columnDef.key;
  15077. if (!EL) {
  15078. fluid.fail("Error in definition for column with key " + key + ": valuebinding is not set")
  15079. }
  15080. opts.EL = expandPath(EL, opts.shortRoot, opts.longRoot);
  15081. if (!key) {
  15082. var segs = fluid.model.parseEL(EL);
  15083. key = segs[segs.length - 1]
  15084. }
  15085. var ID = (options.keyPrefix ? options.keyPrefix : "") + key;
  15086. return ID
  15087. }
  15088. function expandColumnDefs(filteredRow, opts) {
  15089. var tree = fluid.transform(opts.columnDefs, function (columnDef) {
  15090. var ID = iDforColumn(columnDef, opts);
  15091. var togo;
  15092. if (!columnDef.components) {
  15093. return {
  15094. ID : ID,
  15095. valuebinding : opts.EL
  15096. }
  15097. } else {
  15098. if (typeof columnDef.components === "function") {
  15099. togo = columnDef.components(filteredRow.row, filteredRow.index)
  15100. } else {
  15101. togo = columnDef.components
  15102. }
  15103. }
  15104. togo = expandPaths({}, togo, opts);
  15105. togo.ID = ID;
  15106. return togo
  15107. });
  15108. return tree
  15109. }
  15110. function fetchModel(overallThat) {
  15111. return fluid.get(overallThat.options.dataModel, overallThat.options.dataOffset)
  15112. }
  15113. function bigHeaderForKey(key, opts) {
  15114. var id = opts.options.renderOptions.idMap["header:" + key];
  15115. var smallHeader = fluid.jById(id);
  15116. if (smallHeader.length === 0) {
  15117. return null
  15118. }
  15119. var headerSortStylisticOffset = opts.overallOptions.selectors.headerSortStylisticOffset;
  15120. var bigHeader = fluid.findAncestor(smallHeader, function (element) {
  15121. return $(element).is(headerSortStylisticOffset)
  15122. });
  15123. return bigHeader
  15124. }
  15125. function setSortHeaderClass(styles, element, sort) {
  15126. element = $(element);
  15127. element.removeClass(styles.ascendingHeader);
  15128. element.removeClass(styles.descendingHeader);
  15129. if (sort !== 0) {
  15130. element.addClass(sort === 1 ? styles.ascendingHeader : styles.descendingHeader);
  15131. element.attr("aria-sort", sort === 1 ? "ascending" : "descending")
  15132. }
  15133. }
  15134. function isCurrentColumnSortable(columnDefs, model) {
  15135. var columnDef = model.sortKey ? fluid.pager.findColumnDef(columnDefs, model.sortKey) : null;
  15136. return columnDef ? columnDef.sortable : false
  15137. }
  15138. function setModelSortHeaderClass(newModel, opts) {
  15139. var styles = opts.overallOptions.styles;
  15140. var sort = isCurrentColumnSortable(opts.columnDefs, newModel) ? newModel.sortDir : 0;
  15141. setSortHeaderClass(styles, bigHeaderForKey(newModel.sortKey, opts), sort)
  15142. }
  15143. function fireModelChange(that, newModel, forceUpdate) {
  15144. computePageCount(newModel);
  15145. if (newModel.pageIndex >= newModel.pageCount) {
  15146. newModel.pageIndex = newModel.pageCount - 1
  15147. }
  15148. if (forceUpdate || newModel.pageIndex !== that.model.pageIndex || newModel.pageSize !== that.model.pageSize || newModel.sortKey !== that.model.sortKey || newModel.sortDir !== that.model.sortDir) {
  15149. var sorted = isCurrentColumnSortable(getColumnDefs(that), newModel) ? that.options.sorter(that, newModel) : null;
  15150. that.permutation = sorted;
  15151. that.events.onModelChange.fire(newModel, that.model, that);
  15152. fluid.model.copyModel(that.model, newModel)
  15153. }
  15154. }
  15155. function generateColumnClick(overallThat, columnDef, opts) {
  15156. return function () {
  15157. if (columnDef.sortable === true) {
  15158. var model = overallThat.model;
  15159. var newModel = fluid.copy(model);
  15160. var styles = overallThat.options.styles;
  15161. var oldKey = model.sortKey;
  15162. if (columnDef.key !== model.sortKey) {
  15163. newModel.sortKey = columnDef.key;
  15164. newModel.sortDir = 1;
  15165. var oldBig = bigHeaderForKey(oldKey, opts);
  15166. if (oldBig) {
  15167. setSortHeaderClass(styles, oldBig, 0)
  15168. }
  15169. } else {
  15170. if (newModel.sortKey === columnDef.key) {
  15171. newModel.sortDir = -1 * newModel.sortDir
  15172. } else {
  15173. return false
  15174. }
  15175. }
  15176. newModel.pageIndex = 0;
  15177. fireModelChange(overallThat, newModel, true);
  15178. setModelSortHeaderClass(newModel, opts)
  15179. }
  15180. return false
  15181. }
  15182. }
  15183. function fetchHeaderDecorators(decorators, columnDef) {
  15184. return decorators[columnDef.sortable ? "sortableHeader" : "unsortableHeader"]
  15185. }
  15186. function generateHeader(overallThat, newModel, columnDefs, opts) {
  15187. var sortableColumnTxt = opts.options.strings.sortableColumnText;
  15188. if (newModel.sortDir === 1) {
  15189. sortableColumnTxt = opts.options.strings.sortableColumnTextAsc
  15190. } else {
  15191. if (newModel.sortDir === -1) {
  15192. sortableColumnTxt = opts.options.strings.sortableColumnTextDesc
  15193. }
  15194. }
  15195. return {
  15196. children : fluid.transform(columnDefs, function (columnDef) {
  15197. return {
  15198. ID : iDforColumn(columnDef, opts),
  15199. value : columnDef.label,
  15200. decorators : [{
  15201. jQuery : ["click", generateColumnClick(overallThat, columnDef, opts)]
  15202. }, {
  15203. identify : "header:" + columnDef.key
  15204. }, {
  15205. type : "attrs",
  15206. attributes : {
  15207. title : (columnDef.key === newModel.sortKey) ? sortableColumnTxt : opts.options.strings.sortableColumnText
  15208. }
  15209. }
  15210. ].concat(fetchHeaderDecorators(opts.overallOptions.decorators, columnDef))
  15211. }
  15212. })
  15213. }
  15214. }
  15215. fluid.pager.selfRender = function (overallThat, inOptions) {
  15216. var that = fluid.initView("fluid.pager.selfRender", overallThat.container, inOptions);
  15217. var options = that.options;
  15218. options.renderOptions.idMap = options.renderOptions.idMap || {};
  15219. var idMap = options.renderOptions.idMap;
  15220. var root = that.locate("root");
  15221. var template = fluid.selfRender(root, {}, options.renderOptions);
  15222. root.addClass(options.styles.root);
  15223. var columnDefs = getColumnDefs(overallThat);
  15224. var expOpts = {
  15225. options : options,
  15226. columnDefs : columnDefs,
  15227. overallOptions : overallThat.options,
  15228. dataModel : overallThat.options.dataModel,
  15229. idMap : idMap
  15230. };
  15231. var directModel = fetchModel(overallThat);
  15232. return {
  15233. returnedOptions : {
  15234. listeners : {
  15235. onModelChange : function (newModel, oldModel) {
  15236. var filtered = overallThat.options.modelFilter(directModel, newModel, overallThat.permutation);
  15237. var tree = fluid.transform(filtered, function (filteredRow) {
  15238. getRoots(expOpts, overallThat, filteredRow.index);
  15239. if (columnDefs === "explode") {
  15240. return fluid.explode(filteredRow.row, expOpts.longRoot)
  15241. } else {
  15242. if (columnDefs.length) {
  15243. return expandColumnDefs(filteredRow, expOpts)
  15244. }
  15245. }
  15246. });
  15247. var fullTree = {};
  15248. fullTree[options.row] = tree;
  15249. if (typeof(columnDefs) === "object") {
  15250. fullTree[options.header] = generateHeader(overallThat, newModel, columnDefs, expOpts)
  15251. }
  15252. options.renderOptions = options.renderOptions || {};
  15253. options.renderOptions.model = expOpts.dataModel;
  15254. fluid.reRender(template, root, fullTree, options.renderOptions);
  15255. overallThat.events.afterRender.fire(overallThat);
  15256. setModelSortHeaderClass(newModel, expOpts)
  15257. }
  15258. }
  15259. }
  15260. }
  15261. };
  15262. fluid.defaults("fluid.pager.selfRender", {
  15263. selectors : {
  15264. root : ".flc-pager-body-template"
  15265. },
  15266. styles : {
  15267. root : "fl-pager"
  15268. },
  15269. keyStrategy : "id",
  15270. keyPrefix : "",
  15271. row : "row:",
  15272. header : "header:",
  15273. strings : {
  15274. sortableColumnText : "Select to sort",
  15275. sortableColumnTextDesc : "Select to sort in ascending, currently in descending order.",
  15276. sortableColumnTextAsc : "Select to sort in descending, currently in ascending order."
  15277. },
  15278. renderOptions : {}
  15279. });
  15280. fluid.pager.summaryAria = function (element) {
  15281. element.attr({
  15282. "aria-relevant" : "all",
  15283. "aria-atomic" : "false",
  15284. "aria-live" : "assertive",
  15285. role : "status"
  15286. })
  15287. };
  15288. fluid.pager.summary = function (dom, options) {
  15289. var node = dom.locate("summary");
  15290. fluid.pager.summaryAria(node);
  15291. return {
  15292. returnedOptions : {
  15293. listeners : {
  15294. onModelChange : function (newModel, oldModel) {
  15295. var text = fluid.stringTemplate(options.message, {
  15296. first : newModel.pageIndex * newModel.pageSize + 1,
  15297. last : fluid.pager.computePageLimit(newModel),
  15298. total : newModel.totalRange,
  15299. currentPage : newModel.pageIndex + 1
  15300. });
  15301. if (node.length > 0) {
  15302. node.text(text)
  15303. }
  15304. }
  15305. }
  15306. }
  15307. }
  15308. };
  15309. fluid.pager.directPageSize = function (that) {
  15310. var node = that.locate("pageSize");
  15311. if (node.length > 0) {
  15312. that.events.onModelChange.addListener(function (newModel, oldModel) {
  15313. if (node.val() !== newModel.pageSize) {
  15314. node.val(newModel.pageSize)
  15315. }
  15316. });
  15317. node.change(function () {
  15318. that.events.initiatePageSizeChange.fire(node.val())
  15319. })
  15320. }
  15321. };
  15322. fluid.pager.rangeAnnotator = function (that, options) {
  15323. var roots = {};
  15324. that.events.onRenderPageLinks.addListener(function (tree, newModel) {
  15325. var column = that.options.annotateColumnRange;
  15326. var dataModel = that.options.dataModel;
  15327. var columnDefs = getColumnDefs(that);
  15328. if (!column || !dataModel || !columnDefs) {
  15329. return
  15330. }
  15331. var columnDef = fluid.pager.findColumnDef(columnDefs, column);
  15332. function fetchValue(index) {
  15333. index = that.permutation ? that.permutation[index] : index;
  15334. return fluid.pager.fetchValue(that, dataModel, index, columnDef.valuebinding, roots)
  15335. }
  15336. var tModel = {};
  15337. fluid.model.copyModel(tModel, newModel);
  15338. fluid.transform(tree, function (cell) {
  15339. if (cell.ID === "page-link:link") {
  15340. var page = cell.pageIndex;
  15341. var start = page * tModel.pageSize;
  15342. tModel.pageIndex = page;
  15343. var limit = fluid.pager.computePageLimit(tModel);
  15344. var iValue = fetchValue(start);
  15345. var lValue = fetchValue(limit - 1);
  15346. var tooltipOpts = fluid.copy(that.options.tooltip.options) || {};
  15347. if (!tooltipOpts.content) {
  15348. tooltipOpts.content = function () {
  15349. return fluid.stringTemplate(that.options.markup.rangeAnnotation, {
  15350. first : iValue,
  15351. last : lValue
  15352. })
  15353. }
  15354. }
  15355. if (!cell.current) {
  15356. var decorators = [{
  15357. type : "fluid",
  15358. func : that.options.tooltip.type,
  15359. options : tooltipOpts
  15360. }, {
  15361. identify : page
  15362. }
  15363. ];
  15364. cell.decorators = cell.decorators.concat(decorators)
  15365. }
  15366. }
  15367. })
  15368. })
  15369. };
  15370. fluid.pagerImpl = function (container, options) {
  15371. var that = fluid.initView("fluid.pager", container, options);
  15372. that.container.attr("role", "application");
  15373. that.events.initiatePageChange.addListener(function (arg) {
  15374. var newModel = fluid.copy(that.model);
  15375. if (arg.relativePage !== undefined) {
  15376. newModel.pageIndex = that.model.pageIndex + arg.relativePage
  15377. } else {
  15378. newModel.pageIndex = arg.pageIndex
  15379. }
  15380. if (newModel.pageIndex === undefined || newModel.pageIndex < 0) {
  15381. newModel.pageIndex = 0
  15382. }
  15383. fireModelChange(that, newModel, arg.forceUpdate)
  15384. });
  15385. that.events.initiatePageSizeChange.addListener(function (arg) {
  15386. var newModel = fluid.copy(that.model);
  15387. newModel.pageSize = arg;
  15388. fireModelChange(that, newModel)
  15389. });
  15390. var pagerBarElement = that.locate("pagerBar");
  15391. if (pagerBarElement.length > 0) {
  15392. that.pagerBar = fluid.initSubcomponent(that, "pagerBar", [that.events, pagerBarElement, fluid.COMPONENT_OPTIONS, that.options.strings])
  15393. }
  15394. var pagerBarSecondaryElement = that.locate("pagerBarSecondary");
  15395. if (pagerBarSecondaryElement.length > 0) {
  15396. that.pagerBarSecondary = fluid.initSubcomponent(that, "pagerBar", [that.events, pagerBarSecondaryElement, fluid.COMPONENT_OPTIONS, that.options.strings])
  15397. }
  15398. that.bodyRenderer = fluid.initSubcomponent(that, "bodyRenderer", [that, fluid.COMPONENT_OPTIONS]);
  15399. that.summary = fluid.initSubcomponent(that, "summary", [that.dom, fluid.COMPONENT_OPTIONS]);
  15400. that.pageSize = fluid.initSubcomponent(that, "pageSize", [that]);
  15401. that.rangeAnnotator = fluid.initSubcomponent(that, "rangeAnnotator", [that, fluid.COMPONENT_OPTIONS]);
  15402. that.model = fluid.copy(that.options.model);
  15403. var dataModel = fetchModel(that);
  15404. if (dataModel) {
  15405. that.model.totalRange = dataModel.length
  15406. }
  15407. if (that.model.totalRange === undefined) {
  15408. if (!that.pagerBar) {
  15409. fluid.fail("Error in Pager configuration - cannot determine total range, since not configured in model.totalRange and no PagerBar is configured")
  15410. }
  15411. that.model = that.pagerBar.pageList.defaultModel
  15412. }
  15413. that.applier = fluid.makeChangeApplier(that.model);
  15414. that.events.initiatePageChange.fire({
  15415. pageIndex : that.model.pageIndex ? that.model.pageIndex : 0,
  15416. forceUpdate : true
  15417. });
  15418. return that
  15419. };
  15420. fluid.defaults("fluid.pager", {
  15421. mergePolicy : {
  15422. dataModel : "preserve",
  15423. model : "preserve"
  15424. },
  15425. pagerBar : {
  15426. type : "fluid.pager.pagerBar"
  15427. },
  15428. summary : {
  15429. type : "fluid.pager.summary",
  15430. options : {
  15431. message : "Viewing page %currentPage. Showing records %first - %last of %total items."
  15432. }
  15433. },
  15434. pageSize : {
  15435. type : "fluid.pager.directPageSize"
  15436. },
  15437. modelFilter : fluid.pager.directModelFilter,
  15438. sorter : fluid.pager.basicSorter,
  15439. bodyRenderer : {
  15440. type : "fluid.pager.selfRender"
  15441. },
  15442. model : {
  15443. pageIndex : undefined,
  15444. pageSize : 10,
  15445. totalRange : undefined
  15446. },
  15447. dataModel : undefined,
  15448. dataOffset : "",
  15449. columnDefs : [],
  15450. annotateColumnRange : undefined,
  15451. tooltip : {
  15452. type : "fluid.tooltip"
  15453. },
  15454. rangeAnnotator : {
  15455. type : "fluid.pager.rangeAnnotator"
  15456. },
  15457. selectors : {
  15458. pagerBar : ".flc-pager-top",
  15459. pagerBarSecondary : ".flc-pager-bottom",
  15460. summary : ".flc-pager-summary",
  15461. pageSize : ".flc-pager-page-size",
  15462. headerSortStylisticOffset : ".flc-pager-sort-header"
  15463. },
  15464. styles : {
  15465. ascendingHeader : "fl-pager-asc",
  15466. descendingHeader : "fl-pager-desc"
  15467. },
  15468. decorators : {
  15469. sortableHeader : [],
  15470. unsortableHeader : []
  15471. },
  15472. strings : {
  15473. last : " (last)"
  15474. },
  15475. events : {
  15476. initiatePageChange : null,
  15477. initiatePageSizeChange : null,
  15478. onModelChange : null,
  15479. onRenderPageLinks : null,
  15480. afterRender : null
  15481. },
  15482. markup : {
  15483. rangeAnnotation : "<b> %first </b><br/>&mdash;<br/><b> %last </b>"
  15484. }
  15485. })
  15486. })(jQuery, fluid_1_4);
  15487. var fluid_1_4 = fluid_1_4 || {};
  15488. (function ($, fluid) {
  15489. var animateDisplay = function (elm, animation, defaultAnimation) {
  15490. animation = (animation) ? animation : defaultAnimation;
  15491. elm.animate(animation.params, animation.duration, animation.callback)
  15492. };
  15493. var animateProgress = function (elm, width, speed) {
  15494. elm.queue("fx", []);
  15495. elm.animate({
  15496. width : width,
  15497. queue : false
  15498. }, speed)
  15499. };
  15500. var showProgress = function (that, animation) {
  15501. if (animation === false) {
  15502. that.displayElement.show()
  15503. } else {
  15504. animateDisplay(that.displayElement, animation, that.options.showAnimation)
  15505. }
  15506. };
  15507. var hideProgress = function (that, delay, animation) {
  15508. delay = (delay === null || isNaN(delay)) ? that.options.delay : delay;
  15509. if (delay) {
  15510. var timeOut = setTimeout(function () {
  15511. hideProgress(that, 0, animation)
  15512. }, delay)
  15513. } else {
  15514. if (animation === false) {
  15515. that.displayElement.hide()
  15516. } else {
  15517. animateDisplay(that.displayElement, animation, that.options.hideAnimation)
  15518. }
  15519. }
  15520. };
  15521. var updateWidth = function (that, newWidth, dontAnimate) {
  15522. dontAnimate = dontAnimate || false;
  15523. var currWidth = that.indicator.width();
  15524. var direction = that.options.animate;
  15525. if ((newWidth > currWidth) && (direction === "both" || direction === "forward") && !dontAnimate) {
  15526. animateProgress(that.indicator, newWidth, that.options.speed)
  15527. } else {
  15528. if ((newWidth < currWidth) && (direction === "both" || direction === "backward") && !dontAnimate) {
  15529. animateProgress(that.indicator, newWidth, that.options.speed)
  15530. } else {
  15531. that.indicator.width(newWidth)
  15532. }
  15533. }
  15534. };
  15535. var percentToPixels = function (that, percent) {
  15536. return Math.round((Math.min(percent, 100) * that.progressBar.innerWidth()) / 100)
  15537. };
  15538. var refreshRelativeWidth = function (that) {
  15539. var pixels = Math.max(percentToPixels(that, parseFloat(that.storedPercent)), that.options.minWidth);
  15540. updateWidth(that, pixels, true)
  15541. };
  15542. var initARIA = function (ariaElement, ariaBusyText) {
  15543. ariaElement.attr("role", "progressbar");
  15544. ariaElement.attr("aria-valuemin", "0");
  15545. ariaElement.attr("aria-valuemax", "100");
  15546. ariaElement.attr("aria-valuenow", "0");
  15547. if (ariaBusyText) {
  15548. ariaElement.attr("aria-valuetext", "")
  15549. }
  15550. ariaElement.attr("aria-busy", "false")
  15551. };
  15552. var updateARIA = function (that, percent) {
  15553. var str = that.options.strings;
  15554. var busy = percent < 100 && percent > 0;
  15555. that.ariaElement.attr("aria-busy", busy);
  15556. that.ariaElement.attr("aria-valuenow", percent);
  15557. if (str.ariaBusyText) {
  15558. if (busy) {
  15559. var busyString = fluid.stringTemplate(str.ariaBusyText, {
  15560. percentComplete : percent
  15561. });
  15562. that.ariaElement.attr("aria-valuetext", busyString)
  15563. } else {
  15564. if (percent === 100) {
  15565. that.ariaElement.attr("aria-valuetext", str.ariaDoneText)
  15566. }
  15567. }
  15568. }
  15569. };
  15570. var updateText = function (label, value) {
  15571. label.html(value)
  15572. };
  15573. var repositionIndicator = function (that) {
  15574. that.indicator.css("top", that.progressBar.position().top).css("left", 0).height(that.progressBar.height());
  15575. refreshRelativeWidth(that)
  15576. };
  15577. var updateProgress = function (that, percent, labelText, animationForShow) {
  15578. showProgress(that, animationForShow);
  15579. if (percent !== null) {
  15580. that.storedPercent = percent;
  15581. var pixels = Math.max(percentToPixels(that, parseFloat(percent)), that.options.minWidth);
  15582. updateWidth(that, pixels)
  15583. }
  15584. if (labelText !== null) {
  15585. updateText(that.label, labelText)
  15586. }
  15587. if (that.ariaElement) {
  15588. updateARIA(that, percent)
  15589. }
  15590. };
  15591. var setupProgress = function (that) {
  15592. that.displayElement = that.locate("displayElement");
  15593. if (that.options.initiallyHidden) {
  15594. that.displayElement.hide()
  15595. }
  15596. that.progressBar = that.locate("progressBar");
  15597. that.label = that.locate("label");
  15598. that.indicator = that.locate("indicator");
  15599. that.ariaElement = that.locate("ariaElement");
  15600. that.indicator.width(that.options.minWidth);
  15601. that.storedPercent = 0;
  15602. if (that.ariaElement) {
  15603. initARIA(that.ariaElement, that.options.strings.ariaBusyText)
  15604. }
  15605. if (that.options.hideAnimation.callback) {
  15606. that.events.afterProgressHidden.addListener(that.options.hideAnimation.callback)
  15607. }
  15608. that.options.hideAnimation.callback = that.events.afterProgressHidden.fire;
  15609. if (that.options.showAnimation.callback) {
  15610. that.events.onProgressBegin.addListener(that.options.showAnimation.callback)
  15611. }
  15612. that.options.showAnimation.callback = that.events.onProgressBegin.fire
  15613. };
  15614. fluid.progress = function (container, options) {
  15615. var that = fluid.initView("fluid.progress", container, options);
  15616. setupProgress(that);
  15617. that.show = function (animation) {
  15618. showProgress(that, animation)
  15619. };
  15620. that.hide = function (delay, animation) {
  15621. hideProgress(that, delay, animation)
  15622. };
  15623. that.update = function (percentage, labelValue, animationForShow) {
  15624. updateProgress(that, percentage, labelValue, animationForShow)
  15625. };
  15626. that.refreshView = function () {
  15627. repositionIndicator(that)
  15628. };
  15629. return that
  15630. };
  15631. fluid.defaults("fluid.progress", {
  15632. gradeNames : "fluid.viewComponent",
  15633. selectors : {
  15634. displayElement : ".flc-progress",
  15635. progressBar : ".flc-progress-bar",
  15636. indicator : ".flc-progress-indicator",
  15637. label : ".flc-progress-label",
  15638. ariaElement : ".flc-progress-bar"
  15639. },
  15640. strings : {
  15641. ariaBusyText : "Progress is %percentComplete percent complete",
  15642. ariaDoneText : "Progress is complete."
  15643. },
  15644. showAnimation : {
  15645. params : {
  15646. opacity : "show"
  15647. },
  15648. duration : "slow",
  15649. callback : null
  15650. },
  15651. hideAnimation : {
  15652. params : {
  15653. opacity : "hide"
  15654. },
  15655. duration : "slow",
  15656. callback : null
  15657. },
  15658. events : {
  15659. onProgressBegin : null,
  15660. afterProgressHidden : null
  15661. },
  15662. minWidth : 5,
  15663. delay : 0,
  15664. speed : 200,
  15665. animate : "forward",
  15666. initiallyHidden : true,
  15667. updatePosition : false
  15668. })
  15669. })(jQuery, fluid_1_4);
  15670. (function ($, undefined) {
  15671. $.widget("ui.draggable", $.ui.mouse, {
  15672. widgetEventPrefix : "drag",
  15673. options : {
  15674. addClasses : true,
  15675. appendTo : "parent",
  15676. axis : false,
  15677. connectToSortable : false,
  15678. containment : false,
  15679. cursor : "auto",
  15680. cursorAt : false,
  15681. grid : false,
  15682. handle : false,
  15683. helper : "original",
  15684. iframeFix : false,
  15685. opacity : false,
  15686. refreshPositions : false,
  15687. revert : false,
  15688. revertDuration : 500,
  15689. scope : "default",
  15690. scroll : true,
  15691. scrollSensitivity : 20,
  15692. scrollSpeed : 20,
  15693. snap : false,
  15694. snapMode : "both",
  15695. snapTolerance : 20,
  15696. stack : false,
  15697. zIndex : false
  15698. },
  15699. _create : function () {
  15700. if (this.options.helper == "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  15701. this.element[0].style.position = "relative"
  15702. }
  15703. (this.options.addClasses && this.element.addClass("ui-draggable"));
  15704. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  15705. this._mouseInit()
  15706. },
  15707. destroy : function () {
  15708. if (!this.element.data("draggable")) {
  15709. return
  15710. }
  15711. this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");
  15712. this._mouseDestroy();
  15713. return this
  15714. },
  15715. _mouseCapture : function (event) {
  15716. var o = this.options;
  15717. if (this.helper || o.disabled || $(event.target).is(".ui-resizable-handle")) {
  15718. return false
  15719. }
  15720. this.handle = this._getHandle(event);
  15721. if (!this.handle) {
  15722. return false
  15723. }
  15724. return true
  15725. },
  15726. _mouseStart : function (event) {
  15727. var o = this.options;
  15728. this.helper = this._createHelper(event);
  15729. this._cacheHelperProportions();
  15730. if ($.ui.ddmanager) {
  15731. $.ui.ddmanager.current = this
  15732. }
  15733. this._cacheMargins();
  15734. this.cssPosition = this.helper.css("position");
  15735. this.scrollParent = this.helper.scrollParent();
  15736. this.offset = this.positionAbs = this.element.offset();
  15737. this.offset = {
  15738. top : this.offset.top - this.margins.top,
  15739. left : this.offset.left - this.margins.left
  15740. };
  15741. $.extend(this.offset, {
  15742. click : {
  15743. left : event.pageX - this.offset.left,
  15744. top : event.pageY - this.offset.top
  15745. },
  15746. parent : this._getParentOffset(),
  15747. relative : this._getRelativeOffset()
  15748. });
  15749. this.originalPosition = this.position = this._generatePosition(event);
  15750. this.originalPageX = event.pageX;
  15751. this.originalPageY = event.pageY;
  15752. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  15753. if (o.containment) {
  15754. this._setContainment()
  15755. }
  15756. if (this._trigger("start", event) === false) {
  15757. this._clear();
  15758. return false
  15759. }
  15760. this._cacheHelperProportions();
  15761. if ($.ui.ddmanager && !o.dropBehaviour) {
  15762. $.ui.ddmanager.prepareOffsets(this, event)
  15763. }
  15764. this.helper.addClass("ui-draggable-dragging");
  15765. this._mouseDrag(event, true);
  15766. return true
  15767. },
  15768. _mouseDrag : function (event, noPropagation) {
  15769. this.position = this._generatePosition(event);
  15770. this.positionAbs = this._convertPositionTo("absolute");
  15771. if (!noPropagation) {
  15772. var ui = this._uiHash();
  15773. if (this._trigger("drag", event, ui) === false) {
  15774. this._mouseUp({});
  15775. return false
  15776. }
  15777. this.position = ui.position
  15778. }
  15779. if (!this.options.axis || this.options.axis != "y") {
  15780. this.helper[0].style.left = this.position.left + "px"
  15781. }
  15782. if (!this.options.axis || this.options.axis != "x") {
  15783. this.helper[0].style.top = this.position.top + "px"
  15784. }
  15785. if ($.ui.ddmanager) {
  15786. $.ui.ddmanager.drag(this, event)
  15787. }
  15788. return false
  15789. },
  15790. _mouseStop : function (event) {
  15791. var dropped = false;
  15792. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  15793. dropped = $.ui.ddmanager.drop(this, event)
  15794. }
  15795. if (this.dropped) {
  15796. dropped = this.dropped;
  15797. this.dropped = false
  15798. }
  15799. if ((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original") {
  15800. return false
  15801. }
  15802. if ((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  15803. var self = this;
  15804. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function () {
  15805. if (self._trigger("stop", event) !== false) {
  15806. self._clear()
  15807. }
  15808. })
  15809. } else {
  15810. if (this._trigger("stop", event) !== false) {
  15811. this._clear()
  15812. }
  15813. }
  15814. return false
  15815. },
  15816. cancel : function () {
  15817. if (this.helper.is(".ui-draggable-dragging")) {
  15818. this._mouseUp({})
  15819. } else {
  15820. this._clear()
  15821. }
  15822. return this
  15823. },
  15824. _getHandle : function (event) {
  15825. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  15826. $(this.options.handle, this.element).find("*").andSelf().each(function () {
  15827. if (this == event.target) {
  15828. handle = true
  15829. }
  15830. });
  15831. return handle
  15832. },
  15833. _createHelper : function (event) {
  15834. var o = this.options;
  15835. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == "clone" ? this.element.clone() : this.element);
  15836. if (!helper.parents("body").length) {
  15837. helper.appendTo((o.appendTo == "parent" ? this.element[0].parentNode : o.appendTo))
  15838. }
  15839. if (helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  15840. helper.css("position", "absolute")
  15841. }
  15842. return helper
  15843. },
  15844. _adjustOffsetFromHelper : function (obj) {
  15845. if (typeof obj == "string") {
  15846. obj = obj.split(" ")
  15847. }
  15848. if ($.isArray(obj)) {
  15849. obj = {
  15850. left : +obj[0],
  15851. top : +obj[1] || 0
  15852. }
  15853. }
  15854. if ("left" in obj) {
  15855. this.offset.click.left = obj.left + this.margins.left
  15856. }
  15857. if ("right" in obj) {
  15858. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left
  15859. }
  15860. if ("top" in obj) {
  15861. this.offset.click.top = obj.top + this.margins.top
  15862. }
  15863. if ("bottom" in obj) {
  15864. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top
  15865. }
  15866. },
  15867. _getParentOffset : function () {
  15868. this.offsetParent = this.helper.offsetParent();
  15869. var po = this.offsetParent.offset();
  15870. if (this.cssPosition == "absolute" && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  15871. po.left += this.scrollParent.scrollLeft();
  15872. po.top += this.scrollParent.scrollTop()
  15873. }
  15874. if ((this.offsetParent[0] == document.body) || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == "html" && $.browser.msie)) {
  15875. po = {
  15876. top : 0,
  15877. left : 0
  15878. }
  15879. }
  15880. return {
  15881. top : po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  15882. left : po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  15883. }
  15884. },
  15885. _getRelativeOffset : function () {
  15886. if (this.cssPosition == "relative") {
  15887. var p = this.element.position();
  15888. return {
  15889. top : p.top - (parseInt(this.helper.css("top"), 10) || 0) + this.scrollParent.scrollTop(),
  15890. left : p.left - (parseInt(this.helper.css("left"), 10) || 0) + this.scrollParent.scrollLeft()
  15891. }
  15892. } else {
  15893. return {
  15894. top : 0,
  15895. left : 0
  15896. }
  15897. }
  15898. },
  15899. _cacheMargins : function () {
  15900. this.margins = {
  15901. left : (parseInt(this.element.css("marginLeft"), 10) || 0),
  15902. top : (parseInt(this.element.css("marginTop"), 10) || 0),
  15903. right : (parseInt(this.element.css("marginRight"), 10) || 0),
  15904. bottom : (parseInt(this.element.css("marginBottom"), 10) || 0)
  15905. }
  15906. },
  15907. _cacheHelperProportions : function () {
  15908. this.helperProportions = {
  15909. width : this.helper.outerWidth(),
  15910. height : this.helper.outerHeight()
  15911. }
  15912. },
  15913. _setContainment : function () {
  15914. var o = this.options;
  15915. if (o.containment == "parent") {
  15916. o.containment = this.helper[0].parentNode
  15917. }
  15918. if (o.containment == "document" || o.containment == "window") {
  15919. this.containment = [(o.containment == "document" ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left, (o.containment == "document" ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top, (o.containment == "document" ? 0 : $(window).scrollLeft()) + $(o.containment == "document" ? document : window).width() - this.helperProportions.width - this.margins.left, (o.containment == "document" ? 0 : $(window).scrollTop()) + ($(o.containment == "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top]
  15920. }
  15921. if (!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  15922. var ce = $(o.containment)[0];
  15923. if (!ce) {
  15924. return
  15925. }
  15926. var co = $(o.containment).offset();
  15927. var over = ($(ce).css("overflow") != "hidden");
  15928. this.containment = [co.left + (parseInt($(ce).css("borderLeftWidth"), 10) || 0) + (parseInt($(ce).css("paddingLeft"), 10) || 0), co.top + (parseInt($(ce).css("borderTopWidth"), 10) || 0) + (parseInt($(ce).css("paddingTop"), 10) || 0), co.left + (over ? Math.max(ce.scrollWidth, ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"), 10) || 0) - (parseInt($(ce).css("paddingRight"), 10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, co.top + (over ? Math.max(ce.scrollHeight, ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"), 10) || 0) - (parseInt($(ce).css("paddingBottom"), 10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom]
  15929. } else {
  15930. if (o.containment.constructor == Array) {
  15931. this.containment = o.containment
  15932. }
  15933. }
  15934. },
  15935. _convertPositionTo : function (d, pos) {
  15936. if (!pos) {
  15937. pos = this.position
  15938. }
  15939. var mod = d == "absolute" ? 1 : -1;
  15940. var o = this.options,
  15941. scroll = this.cssPosition == "absolute" && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  15942. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  15943. return {
  15944. top : (pos.top + this.offset.relative.top * mod + this.offset.parent.top * mod - ($.browser.safari && $.browser.version < 526 && this.cssPosition == "fixed" ? 0 : (this.cssPosition == "fixed" ? -this.scrollParent.scrollTop() : (scrollIsRootNode ? 0 : scroll.scrollTop())) * mod)),
  15945. left : (pos.left + this.offset.relative.left * mod + this.offset.parent.left * mod - ($.browser.safari && $.browser.version < 526 && this.cssPosition == "fixed" ? 0 : (this.cssPosition == "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft()) * mod))
  15946. }
  15947. },
  15948. _generatePosition : function (event) {
  15949. var o = this.options,
  15950. scroll = this.cssPosition == "absolute" && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  15951. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  15952. var pageX = event.pageX;
  15953. var pageY = event.pageY;
  15954. if (this.originalPosition) {
  15955. if (this.containment) {
  15956. if (event.pageX - this.offset.click.left < this.containment[0]) {
  15957. pageX = this.containment[0] + this.offset.click.left
  15958. }
  15959. if (event.pageY - this.offset.click.top < this.containment[1]) {
  15960. pageY = this.containment[1] + this.offset.click.top
  15961. }
  15962. if (event.pageX - this.offset.click.left > this.containment[2]) {
  15963. pageX = this.containment[2] + this.offset.click.left
  15964. }
  15965. if (event.pageY - this.offset.click.top > this.containment[3]) {
  15966. pageY = this.containment[3] + this.offset.click.top
  15967. }
  15968. }
  15969. if (o.grid) {
  15970. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  15971. pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  15972. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  15973. pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left
  15974. }
  15975. }
  15976. return {
  15977. top : (pageY - this.offset.click.top - this.offset.relative.top - this.offset.parent.top + ($.browser.safari && $.browser.version < 526 && this.cssPosition == "fixed" ? 0 : (this.cssPosition == "fixed" ? -this.scrollParent.scrollTop() : (scrollIsRootNode ? 0 : scroll.scrollTop())))),
  15978. left : (pageX - this.offset.click.left - this.offset.relative.left - this.offset.parent.left + ($.browser.safari && $.browser.version < 526 && this.cssPosition == "fixed" ? 0 : (this.cssPosition == "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft())))
  15979. }
  15980. },
  15981. _clear : function () {
  15982. this.helper.removeClass("ui-draggable-dragging");
  15983. if (this.helper[0] != this.element[0] && !this.cancelHelperRemoval) {
  15984. this.helper.remove()
  15985. }
  15986. this.helper = null;
  15987. this.cancelHelperRemoval = false
  15988. },
  15989. _trigger : function (type, event, ui) {
  15990. ui = ui || this._uiHash();
  15991. $.ui.plugin.call(this, type, [event, ui]);
  15992. if (type == "drag") {
  15993. this.positionAbs = this._convertPositionTo("absolute")
  15994. }
  15995. return $.Widget.prototype._trigger.call(this, type, event, ui)
  15996. },
  15997. plugins : {},
  15998. _uiHash : function (event) {
  15999. return {
  16000. helper : this.helper,
  16001. position : this.position,
  16002. originalPosition : this.originalPosition,
  16003. offset : this.positionAbs
  16004. }
  16005. }
  16006. });
  16007. $.extend($.ui.draggable, {
  16008. version : "1.8.12"
  16009. });
  16010. $.ui.plugin.add("draggable", "connectToSortable", {
  16011. start : function (event, ui) {
  16012. var inst = $(this).data("draggable"),
  16013. o = inst.options,
  16014. uiSortable = $.extend({}, ui, {
  16015. item : inst.element
  16016. });
  16017. inst.sortables = [];
  16018. $(o.connectToSortable).each(function () {
  16019. var sortable = $.data(this, "sortable");
  16020. if (sortable && !sortable.options.disabled) {
  16021. inst.sortables.push({
  16022. instance : sortable,
  16023. shouldRevert : sortable.options.revert
  16024. });
  16025. sortable.refreshPositions();
  16026. sortable._trigger("activate", event, uiSortable)
  16027. }
  16028. })
  16029. },
  16030. stop : function (event, ui) {
  16031. var inst = $(this).data("draggable"),
  16032. uiSortable = $.extend({}, ui, {
  16033. item : inst.element
  16034. });
  16035. $.each(inst.sortables, function () {
  16036. if (this.instance.isOver) {
  16037. this.instance.isOver = 0;
  16038. inst.cancelHelperRemoval = true;
  16039. this.instance.cancelHelperRemoval = false;
  16040. if (this.shouldRevert) {
  16041. this.instance.options.revert = true
  16042. }
  16043. this.instance._mouseStop(event);
  16044. this.instance.options.helper = this.instance.options._helper;
  16045. if (inst.options.helper == "original") {
  16046. this.instance.currentItem.css({
  16047. top : "auto",
  16048. left : "auto"
  16049. })
  16050. }
  16051. } else {
  16052. this.instance.cancelHelperRemoval = false;
  16053. this.instance._trigger("deactivate", event, uiSortable)
  16054. }
  16055. })
  16056. },
  16057. drag : function (event, ui) {
  16058. var inst = $(this).data("draggable"),
  16059. self = this;
  16060. var checkPos = function (o) {
  16061. var dyClick = this.offset.click.top,
  16062. dxClick = this.offset.click.left;
  16063. var helperTop = this.positionAbs.top,
  16064. helperLeft = this.positionAbs.left;
  16065. var itemHeight = o.height,
  16066. itemWidth = o.width;
  16067. var itemTop = o.top,
  16068. itemLeft = o.left;
  16069. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth)
  16070. };
  16071. $.each(inst.sortables, function (i) {
  16072. this.instance.positionAbs = inst.positionAbs;
  16073. this.instance.helperProportions = inst.helperProportions;
  16074. this.instance.offset.click = inst.offset.click;
  16075. if (this.instance._intersectsWith(this.instance.containerCache)) {
  16076. if (!this.instance.isOver) {
  16077. this.instance.isOver = 1;
  16078. this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
  16079. this.instance.options._helper = this.instance.options.helper;
  16080. this.instance.options.helper = function () {
  16081. return ui.helper[0]
  16082. };
  16083. event.target = this.instance.currentItem[0];
  16084. this.instance._mouseCapture(event, true);
  16085. this.instance._mouseStart(event, true, true);
  16086. this.instance.offset.click.top = inst.offset.click.top;
  16087. this.instance.offset.click.left = inst.offset.click.left;
  16088. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  16089. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  16090. inst._trigger("toSortable", event);
  16091. inst.dropped = this.instance.element;
  16092. inst.currentItem = inst.element;
  16093. this.instance.fromOutside = inst
  16094. }
  16095. if (this.instance.currentItem) {
  16096. this.instance._mouseDrag(event)
  16097. }
  16098. } else {
  16099. if (this.instance.isOver) {
  16100. this.instance.isOver = 0;
  16101. this.instance.cancelHelperRemoval = true;
  16102. this.instance.options.revert = false;
  16103. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  16104. this.instance._mouseStop(event, true);
  16105. this.instance.options.helper = this.instance.options._helper;
  16106. this.instance.currentItem.remove();
  16107. if (this.instance.placeholder) {
  16108. this.instance.placeholder.remove()
  16109. }
  16110. inst._trigger("fromSortable", event);
  16111. inst.dropped = false
  16112. }
  16113. }
  16114. })
  16115. }
  16116. });
  16117. $.ui.plugin.add("draggable", "cursor", {
  16118. start : function (event, ui) {
  16119. var t = $("body"),
  16120. o = $(this).data("draggable").options;
  16121. if (t.css("cursor")) {
  16122. o._cursor = t.css("cursor")
  16123. }
  16124. t.css("cursor", o.cursor)
  16125. },
  16126. stop : function (event, ui) {
  16127. var o = $(this).data("draggable").options;
  16128. if (o._cursor) {
  16129. $("body").css("cursor", o._cursor)
  16130. }
  16131. }
  16132. });
  16133. $.ui.plugin.add("draggable", "iframeFix", {
  16134. start : function (event, ui) {
  16135. var o = $(this).data("draggable").options;
  16136. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function () {
  16137. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({
  16138. width : this.offsetWidth + "px",
  16139. height : this.offsetHeight + "px",
  16140. position : "absolute",
  16141. opacity : "0.001",
  16142. zIndex : 1000
  16143. }).css($(this).offset()).appendTo("body")
  16144. })
  16145. },
  16146. stop : function (event, ui) {
  16147. $("div.ui-draggable-iframeFix").each(function () {
  16148. this.parentNode.removeChild(this)
  16149. })
  16150. }
  16151. });
  16152. $.ui.plugin.add("draggable", "opacity", {
  16153. start : function (event, ui) {
  16154. var t = $(ui.helper),
  16155. o = $(this).data("draggable").options;
  16156. if (t.css("opacity")) {
  16157. o._opacity = t.css("opacity")
  16158. }
  16159. t.css("opacity", o.opacity)
  16160. },
  16161. stop : function (event, ui) {
  16162. var o = $(this).data("draggable").options;
  16163. if (o._opacity) {
  16164. $(ui.helper).css("opacity", o._opacity)
  16165. }
  16166. }
  16167. });
  16168. $.ui.plugin.add("draggable", "scroll", {
  16169. start : function (event, ui) {
  16170. var i = $(this).data("draggable");
  16171. if (i.scrollParent[0] != document && i.scrollParent[0].tagName != "HTML") {
  16172. i.overflowOffset = i.scrollParent.offset()
  16173. }
  16174. },
  16175. drag : function (event, ui) {
  16176. var i = $(this).data("draggable"),
  16177. o = i.options,
  16178. scrolled = false;
  16179. if (i.scrollParent[0] != document && i.scrollParent[0].tagName != "HTML") {
  16180. if (!o.axis || o.axis != "x") {
  16181. if ((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  16182. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed
  16183. } else {
  16184. if (event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  16185. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed
  16186. }
  16187. }
  16188. }
  16189. if (!o.axis || o.axis != "y") {
  16190. if ((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  16191. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed
  16192. } else {
  16193. if (event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  16194. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed
  16195. }
  16196. }
  16197. }
  16198. } else {
  16199. if (!o.axis || o.axis != "x") {
  16200. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  16201. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed)
  16202. } else {
  16203. if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  16204. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed)
  16205. }
  16206. }
  16207. }
  16208. if (!o.axis || o.axis != "y") {
  16209. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  16210. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed)
  16211. } else {
  16212. if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  16213. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed)
  16214. }
  16215. }
  16216. }
  16217. }
  16218. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  16219. $.ui.ddmanager.prepareOffsets(i, event)
  16220. }
  16221. }
  16222. });
  16223. $.ui.plugin.add("draggable", "snap", {
  16224. start : function (event, ui) {
  16225. var i = $(this).data("draggable"),
  16226. o = i.options;
  16227. i.snapElements = [];
  16228. $(o.snap.constructor != String ? (o.snap.items || ":data(draggable)") : o.snap).each(function () {
  16229. var $t = $(this);
  16230. var $o = $t.offset();
  16231. if (this != i.element[0]) {
  16232. i.snapElements.push({
  16233. item : this,
  16234. width : $t.outerWidth(),
  16235. height : $t.outerHeight(),
  16236. top : $o.top,
  16237. left : $o.left
  16238. })
  16239. }
  16240. })
  16241. },
  16242. drag : function (event, ui) {
  16243. var inst = $(this).data("draggable"),
  16244. o = inst.options;
  16245. var d = o.snapTolerance;
  16246. var x1 = ui.offset.left,
  16247. x2 = x1 + inst.helperProportions.width,
  16248. y1 = ui.offset.top,
  16249. y2 = y1 + inst.helperProportions.height;
  16250. for (var i = inst.snapElements.length - 1; i >= 0; i--) {
  16251. var l = inst.snapElements[i].left,
  16252. r = l + inst.snapElements[i].width,
  16253. t = inst.snapElements[i].top,
  16254. b = t + inst.snapElements[i].height;
  16255. if (!((l - d < x1 && x1 < r + d && t - d < y1 && y1 < b + d) || (l - d < x1 && x1 < r + d && t - d < y2 && y2 < b + d) || (l - d < x2 && x2 < r + d && t - d < y1 && y1 < b + d) || (l - d < x2 && x2 < r + d && t - d < y2 && y2 < b + d))) {
  16256. if (inst.snapElements[i].snapping) {
  16257. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), {
  16258. snapItem : inst.snapElements[i].item
  16259. })))
  16260. }
  16261. inst.snapElements[i].snapping = false;
  16262. continue
  16263. }
  16264. if (o.snapMode != "inner") {
  16265. var ts = Math.abs(t - y2) <= d;
  16266. var bs = Math.abs(b - y1) <= d;
  16267. var ls = Math.abs(l - x2) <= d;
  16268. var rs = Math.abs(r - x1) <= d;
  16269. if (ts) {
  16270. ui.position.top = inst._convertPositionTo("relative", {
  16271. top : t - inst.helperProportions.height,
  16272. left : 0
  16273. }).top - inst.margins.top
  16274. }
  16275. if (bs) {
  16276. ui.position.top = inst._convertPositionTo("relative", {
  16277. top : b,
  16278. left : 0
  16279. }).top - inst.margins.top
  16280. }
  16281. if (ls) {
  16282. ui.position.left = inst._convertPositionTo("relative", {
  16283. top : 0,
  16284. left : l - inst.helperProportions.width
  16285. }).left - inst.margins.left
  16286. }
  16287. if (rs) {
  16288. ui.position.left = inst._convertPositionTo("relative", {
  16289. top : 0,
  16290. left : r
  16291. }).left - inst.margins.left
  16292. }
  16293. }
  16294. var first = (ts || bs || ls || rs);
  16295. if (o.snapMode != "outer") {
  16296. var ts = Math.abs(t - y1) <= d;
  16297. var bs = Math.abs(b - y2) <= d;
  16298. var ls = Math.abs(l - x1) <= d;
  16299. var rs = Math.abs(r - x2) <= d;
  16300. if (ts) {
  16301. ui.position.top = inst._convertPositionTo("relative", {
  16302. top : t,
  16303. left : 0
  16304. }).top - inst.margins.top
  16305. }
  16306. if (bs) {
  16307. ui.position.top = inst._convertPositionTo("relative", {
  16308. top : b - inst.helperProportions.height,
  16309. left : 0
  16310. }).top - inst.margins.top
  16311. }
  16312. if (ls) {
  16313. ui.position.left = inst._convertPositionTo("relative", {
  16314. top : 0,
  16315. left : l
  16316. }).left - inst.margins.left
  16317. }
  16318. if (rs) {
  16319. ui.position.left = inst._convertPositionTo("relative", {
  16320. top : 0,
  16321. left : r - inst.helperProportions.width
  16322. }).left - inst.margins.left
  16323. }
  16324. }
  16325. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  16326. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), {
  16327. snapItem : inst.snapElements[i].item
  16328. })))
  16329. }
  16330. inst.snapElements[i].snapping = (ts || bs || ls || rs || first)
  16331. }
  16332. }
  16333. });
  16334. $.ui.plugin.add("draggable", "stack", {
  16335. start : function (event, ui) {
  16336. var o = $(this).data("draggable").options;
  16337. var group = $.makeArray($(o.stack)).sort(function (a, b) {
  16338. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0)
  16339. });
  16340. if (!group.length) {
  16341. return
  16342. }
  16343. var min = parseInt(group[0].style.zIndex) || 0;
  16344. $(group).each(function (i) {
  16345. this.style.zIndex = min + i
  16346. });
  16347. this[0].style.zIndex = min + group.length
  16348. }
  16349. });
  16350. $.ui.plugin.add("draggable", "zIndex", {
  16351. start : function (event, ui) {
  16352. var t = $(ui.helper),
  16353. o = $(this).data("draggable").options;
  16354. if (t.css("zIndex")) {
  16355. o._zIndex = t.css("zIndex")
  16356. }
  16357. t.css("zIndex", o.zIndex)
  16358. },
  16359. stop : function (event, ui) {
  16360. var o = $(this).data("draggable").options;
  16361. if (o._zIndex) {
  16362. $(ui.helper).css("zIndex", o._zIndex)
  16363. }
  16364. }
  16365. })
  16366. })(jQuery);
  16367. (function ($, undefined) {
  16368. var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
  16369. sizeRelatedOptions = {
  16370. buttons : true,
  16371. height : true,
  16372. maxHeight : true,
  16373. maxWidth : true,
  16374. minHeight : true,
  16375. minWidth : true,
  16376. width : true
  16377. },
  16378. resizableRelatedOptions = {
  16379. maxHeight : true,
  16380. maxWidth : true,
  16381. minHeight : true,
  16382. minWidth : true
  16383. },
  16384. attrFn = $.attrFn || {
  16385. val : true,
  16386. css : true,
  16387. html : true,
  16388. text : true,
  16389. data : true,
  16390. width : true,
  16391. height : true,
  16392. offset : true,
  16393. click : true
  16394. };
  16395. $.widget("ui.dialog", {
  16396. options : {
  16397. autoOpen : true,
  16398. buttons : {},
  16399. closeOnEscape : true,
  16400. closeText : "close",
  16401. dialogClass : "",
  16402. draggable : true,
  16403. hide : null,
  16404. height : "auto",
  16405. maxHeight : false,
  16406. maxWidth : false,
  16407. minHeight : 150,
  16408. minWidth : 150,
  16409. modal : false,
  16410. position : {
  16411. my : "center",
  16412. at : "center",
  16413. collision : "fit",
  16414. using : function (pos) {
  16415. var topOffset = $(this).css(pos).offset().top;
  16416. if (topOffset < 0) {
  16417. $(this).css("top", pos.top - topOffset)
  16418. }
  16419. }
  16420. },
  16421. resizable : true,
  16422. show : null,
  16423. stack : true,
  16424. title : "",
  16425. width : 300,
  16426. zIndex : 1000
  16427. },
  16428. _create : function () {
  16429. this.originalTitle = this.element.attr("title");
  16430. if (typeof this.originalTitle !== "string") {
  16431. this.originalTitle = ""
  16432. }
  16433. this.options.title = this.options.title || this.originalTitle;
  16434. var self = this,
  16435. options = self.options,
  16436. title = options.title || "&#160;",
  16437. titleId = $.ui.dialog.getTitleId(self.element),
  16438. uiDialog = (self.uiDialog = $("<div></div>")).appendTo(document.body).hide().addClass(uiDialogClasses + options.dialogClass).css({
  16439. zIndex : options.zIndex
  16440. }).attr("tabIndex", -1).css("outline", 0).keydown(function (event) {
  16441. if (options.closeOnEscape && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE) {
  16442. self.close(event);
  16443. event.preventDefault()
  16444. }
  16445. }).attr({
  16446. role : "dialog",
  16447. "aria-labelledby" : titleId
  16448. }).mousedown(function (event) {
  16449. self.moveToTop(false, event)
  16450. }),
  16451. uiDialogContent = self.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(uiDialog),
  16452. uiDialogTitlebar = (self.uiDialogTitlebar = $("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(uiDialog),
  16453. uiDialogTitlebarClose = $('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role", "button").hover(function () {
  16454. uiDialogTitlebarClose.addClass("ui-state-hover")
  16455. }, function () {
  16456. uiDialogTitlebarClose.removeClass("ui-state-hover")
  16457. }).focus(function () {
  16458. uiDialogTitlebarClose.addClass("ui-state-focus")
  16459. }).blur(function () {
  16460. uiDialogTitlebarClose.removeClass("ui-state-focus")
  16461. }).click(function (event) {
  16462. self.close(event);
  16463. return false
  16464. }).appendTo(uiDialogTitlebar),
  16465. uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $("<span></span>")).addClass("ui-icon ui-icon-closethick").text(options.closeText).appendTo(uiDialogTitlebarClose),
  16466. uiDialogTitle = $("<span></span>").addClass("ui-dialog-title").attr("id", titleId).html(title).prependTo(uiDialogTitlebar);
  16467. if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
  16468. options.beforeClose = options.beforeclose
  16469. }
  16470. uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
  16471. if (options.draggable && $.fn.draggable) {
  16472. self._makeDraggable()
  16473. }
  16474. if (options.resizable && $.fn.resizable) {
  16475. self._makeResizable()
  16476. }
  16477. self._createButtons(options.buttons);
  16478. self._isOpen = false;
  16479. if ($.fn.bgiframe) {
  16480. uiDialog.bgiframe()
  16481. }
  16482. },
  16483. _init : function () {
  16484. if (this.options.autoOpen) {
  16485. this.open()
  16486. }
  16487. },
  16488. destroy : function () {
  16489. var self = this;
  16490. if (self.overlay) {
  16491. self.overlay.destroy()
  16492. }
  16493. self.uiDialog.hide();
  16494. self.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");
  16495. self.uiDialog.remove();
  16496. if (self.originalTitle) {
  16497. self.element.attr("title", self.originalTitle)
  16498. }
  16499. return self
  16500. },
  16501. widget : function () {
  16502. return this.uiDialog
  16503. },
  16504. close : function (event) {
  16505. var self = this,
  16506. maxZ,
  16507. thisZ;
  16508. if (false === self._trigger("beforeClose", event)) {
  16509. return
  16510. }
  16511. if (self.overlay) {
  16512. self.overlay.destroy()
  16513. }
  16514. self.uiDialog.unbind("keypress.ui-dialog");
  16515. self._isOpen = false;
  16516. if (self.options.hide) {
  16517. self.uiDialog.hide(self.options.hide, function () {
  16518. self._trigger("close", event)
  16519. })
  16520. } else {
  16521. self.uiDialog.hide();
  16522. self._trigger("close", event)
  16523. }
  16524. $.ui.dialog.overlay.resize();
  16525. if (self.options.modal) {
  16526. maxZ = 0;
  16527. $(".ui-dialog").each(function () {
  16528. if (this !== self.uiDialog[0]) {
  16529. thisZ = $(this).css("z-index");
  16530. if (!isNaN(thisZ)) {
  16531. maxZ = Math.max(maxZ, thisZ)
  16532. }
  16533. }
  16534. });
  16535. $.ui.dialog.maxZ = maxZ
  16536. }
  16537. return self
  16538. },
  16539. isOpen : function () {
  16540. return this._isOpen
  16541. },
  16542. moveToTop : function (force, event) {
  16543. var self = this,
  16544. options = self.options,
  16545. saveScroll;
  16546. if ((options.modal && !force) || (!options.stack && !options.modal)) {
  16547. return self._trigger("focus", event)
  16548. }
  16549. if (options.zIndex > $.ui.dialog.maxZ) {
  16550. $.ui.dialog.maxZ = options.zIndex
  16551. }
  16552. if (self.overlay) {
  16553. $.ui.dialog.maxZ += 1;
  16554. self.overlay.$el.css("z-index", $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ)
  16555. }
  16556. saveScroll = {
  16557. scrollTop : self.element.attr("scrollTop"),
  16558. scrollLeft : self.element.attr("scrollLeft")
  16559. };
  16560. $.ui.dialog.maxZ += 1;
  16561. self.uiDialog.css("z-index", $.ui.dialog.maxZ);
  16562. self.element.attr(saveScroll);
  16563. self._trigger("focus", event);
  16564. return self
  16565. },
  16566. open : function () {
  16567. if (this._isOpen) {
  16568. return
  16569. }
  16570. var self = this,
  16571. options = self.options,
  16572. uiDialog = self.uiDialog;
  16573. self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
  16574. self._size();
  16575. self._position(options.position);
  16576. uiDialog.show(options.show);
  16577. self.moveToTop(true);
  16578. if (options.modal) {
  16579. uiDialog.bind("keypress.ui-dialog", function (event) {
  16580. if (event.keyCode !== $.ui.keyCode.TAB) {
  16581. return
  16582. }
  16583. var tabbables = $(":tabbable", this),
  16584. first = tabbables.filter(":first"),
  16585. last = tabbables.filter(":last");
  16586. if (event.target === last[0] && !event.shiftKey) {
  16587. first.focus(1);
  16588. return false
  16589. } else {
  16590. if (event.target === first[0] && event.shiftKey) {
  16591. last.focus(1);
  16592. return false
  16593. }
  16594. }
  16595. })
  16596. }
  16597. $(self.element.find(":tabbable").get().concat(uiDialog.find(".ui-dialog-buttonpane :tabbable").get().concat(uiDialog.get()))).eq(0).focus();
  16598. self._isOpen = true;
  16599. self._trigger("open");
  16600. return self
  16601. },
  16602. _createButtons : function (buttons) {
  16603. var self = this,
  16604. hasButtons = false,
  16605. uiDialogButtonPane = $("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),
  16606. uiButtonSet = $("<div></div>").addClass("ui-dialog-buttonset").appendTo(uiDialogButtonPane);
  16607. self.uiDialog.find(".ui-dialog-buttonpane").remove();
  16608. if (typeof buttons === "object" && buttons !== null) {
  16609. $.each(buttons, function () {
  16610. return !(hasButtons = true)
  16611. })
  16612. }
  16613. if (hasButtons) {
  16614. $.each(buttons, function (name, props) {
  16615. props = $.isFunction(props) ? {
  16616. click : props,
  16617. text : name
  16618. }
  16619. : props;
  16620. var button = $('<button type="button"></button>').click(function () {
  16621. props.click.apply(self.element[0], arguments)
  16622. }).appendTo(uiButtonSet);
  16623. $.each(props, function (key, value) {
  16624. if (key === "click") {
  16625. return
  16626. }
  16627. if (key in attrFn) {
  16628. button[key](value)
  16629. } else {
  16630. button.attr(key, value)
  16631. }
  16632. });
  16633. if ($.fn.button) {
  16634. button.button()
  16635. }
  16636. });
  16637. uiDialogButtonPane.appendTo(self.uiDialog)
  16638. }
  16639. },
  16640. _makeDraggable : function () {
  16641. var self = this,
  16642. options = self.options,
  16643. doc = $(document),
  16644. heightBeforeDrag;
  16645. function filteredUi(ui) {
  16646. return {
  16647. position : ui.position,
  16648. offset : ui.offset
  16649. }
  16650. }
  16651. self.uiDialog.draggable({
  16652. cancel : ".ui-dialog-content, .ui-dialog-titlebar-close",
  16653. handle : ".ui-dialog-titlebar",
  16654. containment : "document",
  16655. start : function (event, ui) {
  16656. heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
  16657. $(this).height($(this).height()).addClass("ui-dialog-dragging");
  16658. self._trigger("dragStart", event, filteredUi(ui))
  16659. },
  16660. drag : function (event, ui) {
  16661. self._trigger("drag", event, filteredUi(ui))
  16662. },
  16663. stop : function (event, ui) {
  16664. options.position = [ui.position.left - doc.scrollLeft(), ui.position.top - doc.scrollTop()];
  16665. $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
  16666. self._trigger("dragStop", event, filteredUi(ui));
  16667. $.ui.dialog.overlay.resize()
  16668. }
  16669. })
  16670. },
  16671. _makeResizable : function (handles) {
  16672. handles = (handles === undefined ? this.options.resizable : handles);
  16673. var self = this,
  16674. options = self.options,
  16675. position = self.uiDialog.css("position"),
  16676. resizeHandles = (typeof handles === "string" ? handles : "n,e,s,w,se,sw,ne,nw");
  16677. function filteredUi(ui) {
  16678. return {
  16679. originalPosition : ui.originalPosition,
  16680. originalSize : ui.originalSize,
  16681. position : ui.position,
  16682. size : ui.size
  16683. }
  16684. }
  16685. self.uiDialog.resizable({
  16686. cancel : ".ui-dialog-content",
  16687. containment : "document",
  16688. alsoResize : self.element,
  16689. maxWidth : options.maxWidth,
  16690. maxHeight : options.maxHeight,
  16691. minWidth : options.minWidth,
  16692. minHeight : self._minHeight(),
  16693. handles : resizeHandles,
  16694. start : function (event, ui) {
  16695. $(this).addClass("ui-dialog-resizing");
  16696. self._trigger("resizeStart", event, filteredUi(ui))
  16697. },
  16698. resize : function (event, ui) {
  16699. self._trigger("resize", event, filteredUi(ui))
  16700. },
  16701. stop : function (event, ui) {
  16702. $(this).removeClass("ui-dialog-resizing");
  16703. options.height = $(this).height();
  16704. options.width = $(this).width();
  16705. self._trigger("resizeStop", event, filteredUi(ui));
  16706. $.ui.dialog.overlay.resize()
  16707. }
  16708. }).css("position", position).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")
  16709. },
  16710. _minHeight : function () {
  16711. var options = this.options;
  16712. if (options.height === "auto") {
  16713. return options.minHeight
  16714. } else {
  16715. return Math.min(options.minHeight, options.height)
  16716. }
  16717. },
  16718. _position : function (position) {
  16719. var myAt = [],
  16720. offset = [0, 0],
  16721. isVisible;
  16722. if (position) {
  16723. if (typeof position === "string" || (typeof position === "object" && "0" in position)) {
  16724. myAt = position.split ? position.split(" ") : [position[0], position[1]];
  16725. if (myAt.length === 1) {
  16726. myAt[1] = myAt[0]
  16727. }
  16728. $.each(["left", "top"], function (i, offsetPosition) {
  16729. if (+myAt[i] === myAt[i]) {
  16730. offset[i] = myAt[i];
  16731. myAt[i] = offsetPosition
  16732. }
  16733. });
  16734. position = {
  16735. my : myAt.join(" "),
  16736. at : myAt.join(" "),
  16737. offset : offset.join(" ")
  16738. }
  16739. }
  16740. position = $.extend({}, $.ui.dialog.prototype.options.position, position)
  16741. } else {
  16742. position = $.ui.dialog.prototype.options.position
  16743. }
  16744. isVisible = this.uiDialog.is(":visible");
  16745. if (!isVisible) {
  16746. this.uiDialog.show()
  16747. }
  16748. this.uiDialog.css({
  16749. top : 0,
  16750. left : 0
  16751. }).position($.extend({
  16752. of : window
  16753. }, position));
  16754. if (!isVisible) {
  16755. this.uiDialog.hide()
  16756. }
  16757. },
  16758. _setOptions : function (options) {
  16759. var self = this,
  16760. resizableOptions = {},
  16761. resize = false;
  16762. $.each(options, function (key, value) {
  16763. self._setOption(key, value);
  16764. if (key in sizeRelatedOptions) {
  16765. resize = true
  16766. }
  16767. if (key in resizableRelatedOptions) {
  16768. resizableOptions[key] = value
  16769. }
  16770. });
  16771. if (resize) {
  16772. this._size()
  16773. }
  16774. if (this.uiDialog.is(":data(resizable)")) {
  16775. this.uiDialog.resizable("option", resizableOptions)
  16776. }
  16777. },
  16778. _setOption : function (key, value) {
  16779. var self = this,
  16780. uiDialog = self.uiDialog;
  16781. switch (key) {
  16782. case "beforeclose":
  16783. key = "beforeClose";
  16784. break;
  16785. case "buttons":
  16786. self._createButtons(value);
  16787. break;
  16788. case "closeText":
  16789. self.uiDialogTitlebarCloseText.text("" + value);
  16790. break;
  16791. case "dialogClass":
  16792. uiDialog.removeClass(self.options.dialogClass).addClass(uiDialogClasses + value);
  16793. break;
  16794. case "disabled":
  16795. if (value) {
  16796. uiDialog.addClass("ui-dialog-disabled")
  16797. } else {
  16798. uiDialog.removeClass("ui-dialog-disabled")
  16799. }
  16800. break;
  16801. case "draggable":
  16802. var isDraggable = uiDialog.is(":data(draggable)");
  16803. if (isDraggable && !value) {
  16804. uiDialog.draggable("destroy")
  16805. }
  16806. if (!isDraggable && value) {
  16807. self._makeDraggable()
  16808. }
  16809. break;
  16810. case "position":
  16811. self._position(value);
  16812. break;
  16813. case "resizable":
  16814. var isResizable = uiDialog.is(":data(resizable)");
  16815. if (isResizable && !value) {
  16816. uiDialog.resizable("destroy")
  16817. }
  16818. if (isResizable && typeof value === "string") {
  16819. uiDialog.resizable("option", "handles", value)
  16820. }
  16821. if (!isResizable && value !== false) {
  16822. self._makeResizable(value)
  16823. }
  16824. break;
  16825. case "title":
  16826. $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || "&#160;"));
  16827. break
  16828. }
  16829. $.Widget.prototype._setOption.apply(self, arguments)
  16830. },
  16831. _size : function () {
  16832. var options = this.options,
  16833. nonContentHeight,
  16834. minContentHeight,
  16835. isVisible = this.uiDialog.is(":visible");
  16836. this.element.show().css({
  16837. width : "auto",
  16838. minHeight : 0,
  16839. height : 0
  16840. });
  16841. if (options.minWidth > options.width) {
  16842. options.width = options.minWidth
  16843. }
  16844. nonContentHeight = this.uiDialog.css({
  16845. height : "auto",
  16846. width : options.width
  16847. }).height();
  16848. minContentHeight = Math.max(0, options.minHeight - nonContentHeight);
  16849. if (options.height === "auto") {
  16850. if ($.support.minHeight) {
  16851. this.element.css({
  16852. minHeight : minContentHeight,
  16853. height : "auto"
  16854. })
  16855. } else {
  16856. this.uiDialog.show();
  16857. var autoHeight = this.element.css("height", "auto").height();
  16858. if (!isVisible) {
  16859. this.uiDialog.hide()
  16860. }
  16861. this.element.height(Math.max(autoHeight, minContentHeight))
  16862. }
  16863. } else {
  16864. this.element.height(Math.max(options.height - nonContentHeight, 0))
  16865. }
  16866. if (this.uiDialog.is(":data(resizable)")) {
  16867. this.uiDialog.resizable("option", "minHeight", this._minHeight())
  16868. }
  16869. }
  16870. });
  16871. $.extend($.ui.dialog, {
  16872. version : "1.8.12",
  16873. uuid : 0,
  16874. maxZ : 0,
  16875. getTitleId : function ($el) {
  16876. var id = $el.attr("id");
  16877. if (!id) {
  16878. this.uuid += 1;
  16879. id = this.uuid
  16880. }
  16881. return "ui-dialog-title-" + id
  16882. },
  16883. overlay : function (dialog) {
  16884. this.$el = $.ui.dialog.overlay.create(dialog)
  16885. }
  16886. });
  16887. $.extend($.ui.dialog.overlay, {
  16888. instances : [],
  16889. oldInstances : [],
  16890. maxZ : 0,
  16891. events : $.map("focus,mousedown,mouseup,keydown,keypress,click".split(","), function (event) {
  16892. return event + ".dialog-overlay"
  16893. }).join(" "),
  16894. create : function (dialog) {
  16895. if (this.instances.length === 0) {
  16896. setTimeout(function () {
  16897. if ($.ui.dialog.overlay.instances.length) {
  16898. $(document).bind($.ui.dialog.overlay.events, function (event) {
  16899. if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
  16900. return false
  16901. }
  16902. })
  16903. }
  16904. }, 1);
  16905. $(document).bind("keydown.dialog-overlay", function (event) {
  16906. if (dialog.options.closeOnEscape && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE) {
  16907. dialog.close(event);
  16908. event.preventDefault()
  16909. }
  16910. });
  16911. $(window).bind("resize.dialog-overlay", $.ui.dialog.overlay.resize)
  16912. }
  16913. var $el = (this.oldInstances.pop() || $("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({
  16914. width : this.width(),
  16915. height : this.height()
  16916. });
  16917. if ($.fn.bgiframe) {
  16918. $el.bgiframe()
  16919. }
  16920. this.instances.push($el);
  16921. return $el
  16922. },
  16923. destroy : function ($el) {
  16924. var indexOf = $.inArray($el, this.instances);
  16925. if (indexOf != -1) {
  16926. this.oldInstances.push(this.instances.splice(indexOf, 1)[0])
  16927. }
  16928. if (this.instances.length === 0) {
  16929. $([document, window]).unbind(".dialog-overlay")
  16930. }
  16931. $el.remove();
  16932. var maxZ = 0;
  16933. $.each(this.instances, function () {
  16934. maxZ = Math.max(maxZ, this.css("z-index"))
  16935. });
  16936. this.maxZ = maxZ
  16937. },
  16938. height : function () {
  16939. var scrollHeight,
  16940. offsetHeight;
  16941. if ($.browser.msie && $.browser.version < 7) {
  16942. scrollHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
  16943. offsetHeight = Math.max(document.documentElement.offsetHeight, document.body.offsetHeight);
  16944. if (scrollHeight < offsetHeight) {
  16945. return $(window).height() + "px"
  16946. } else {
  16947. return scrollHeight + "px"
  16948. }
  16949. } else {
  16950. return $(document).height() + "px"
  16951. }
  16952. },
  16953. width : function () {
  16954. var scrollWidth,
  16955. offsetWidth;
  16956. if ($.browser.msie && $.browser.version < 7) {
  16957. scrollWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
  16958. offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
  16959. if (scrollWidth < offsetWidth) {
  16960. return $(window).width() + "px"
  16961. } else {
  16962. return scrollWidth + "px"
  16963. }
  16964. } else {
  16965. return $(document).width() + "px"
  16966. }
  16967. },
  16968. resize : function () {
  16969. var $overlays = $([]);
  16970. $.each($.ui.dialog.overlay.instances, function () {
  16971. $overlays = $overlays.add(this)
  16972. });
  16973. $overlays.css({
  16974. width : 0,
  16975. height : 0
  16976. }).css({
  16977. width : $.ui.dialog.overlay.width(),
  16978. height : $.ui.dialog.overlay.height()
  16979. })
  16980. }
  16981. });
  16982. $.extend($.ui.dialog.overlay.prototype, {
  16983. destroy : function () {
  16984. $.ui.dialog.overlay.destroy(this.$el)
  16985. }
  16986. })
  16987. }
  16988. (jQuery));
  16989. (function ($, undefined) {
  16990. var numPages = 5;
  16991. $.widget("ui.slider", $.ui.mouse, {
  16992. widgetEventPrefix : "slide",
  16993. options : {
  16994. animate : false,
  16995. distance : 0,
  16996. max : 100,
  16997. min : 0,
  16998. orientation : "horizontal",
  16999. range : false,
  17000. step : 1,
  17001. value : 0,
  17002. values : null
  17003. },
  17004. _create : function () {
  17005. var self = this,
  17006. o = this.options;
  17007. this._keySliding = false;
  17008. this._mouseSliding = false;
  17009. this._animateOff = true;
  17010. this._handleIndex = null;
  17011. this._detectOrientation();
  17012. this._mouseInit();
  17013. this.element.addClass("ui-slider ui-slider-" + this.orientation + " ui-widget ui-widget-content ui-corner-all");
  17014. if (o.disabled) {
  17015. this.element.addClass("ui-slider-disabled ui-disabled")
  17016. }
  17017. this.range = $([]);
  17018. if (o.range) {
  17019. if (o.range === true) {
  17020. this.range = $("<div></div>");
  17021. if (!o.values) {
  17022. o.values = [this._valueMin(), this._valueMin()]
  17023. }
  17024. if (o.values.length && o.values.length !== 2) {
  17025. o.values = [o.values[0], o.values[0]]
  17026. }
  17027. } else {
  17028. this.range = $("<div></div>")
  17029. }
  17030. this.range.appendTo(this.element).addClass("ui-slider-range");
  17031. if (o.range === "min" || o.range === "max") {
  17032. this.range.addClass("ui-slider-range-" + o.range)
  17033. }
  17034. this.range.addClass("ui-widget-header")
  17035. }
  17036. if ($(".ui-slider-handle", this.element).length === 0) {
  17037. $("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle")
  17038. }
  17039. if (o.values && o.values.length) {
  17040. while ($(".ui-slider-handle", this.element).length < o.values.length) {
  17041. $("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle")
  17042. }
  17043. }
  17044. this.handles = $(".ui-slider-handle", this.element).addClass("ui-state-default ui-corner-all");
  17045. this.handle = this.handles.eq(0);
  17046. this.handles.add(this.range).filter("a").click(function (event) {
  17047. event.preventDefault()
  17048. }).hover(function () {
  17049. if (!o.disabled) {
  17050. $(this).addClass("ui-state-hover")
  17051. }
  17052. }, function () {
  17053. $(this).removeClass("ui-state-hover")
  17054. }).focus(function () {
  17055. if (!o.disabled) {
  17056. $(".ui-slider .ui-state-focus").removeClass("ui-state-focus");
  17057. $(this).addClass("ui-state-focus")
  17058. } else {
  17059. $(this).blur()
  17060. }
  17061. }).blur(function () {
  17062. $(this).removeClass("ui-state-focus")
  17063. });
  17064. this.handles.each(function (i) {
  17065. $(this).data("index.ui-slider-handle", i)
  17066. });
  17067. this.handles.keydown(function (event) {
  17068. var ret = true,
  17069. index = $(this).data("index.ui-slider-handle"),
  17070. allowed,
  17071. curVal,
  17072. newVal,
  17073. step;
  17074. if (self.options.disabled) {
  17075. return
  17076. }
  17077. switch (event.keyCode) {
  17078. case $.ui.keyCode.HOME:
  17079. case $.ui.keyCode.END:
  17080. case $.ui.keyCode.PAGE_UP:
  17081. case $.ui.keyCode.PAGE_DOWN:
  17082. case $.ui.keyCode.UP:
  17083. case $.ui.keyCode.RIGHT:
  17084. case $.ui.keyCode.DOWN:
  17085. case $.ui.keyCode.LEFT:
  17086. ret = false;
  17087. if (!self._keySliding) {
  17088. self._keySliding = true;
  17089. $(this).addClass("ui-state-active");
  17090. allowed = self._start(event, index);
  17091. if (allowed === false) {
  17092. return
  17093. }
  17094. }
  17095. break
  17096. }
  17097. step = self.options.step;
  17098. if (self.options.values && self.options.values.length) {
  17099. curVal = newVal = self.values(index)
  17100. } else {
  17101. curVal = newVal = self.value()
  17102. }
  17103. switch (event.keyCode) {
  17104. case $.ui.keyCode.HOME:
  17105. newVal = self._valueMin();
  17106. break;
  17107. case $.ui.keyCode.END:
  17108. newVal = self._valueMax();
  17109. break;
  17110. case $.ui.keyCode.PAGE_UP:
  17111. newVal = self._trimAlignValue(curVal + ((self._valueMax() - self._valueMin()) / numPages));
  17112. break;
  17113. case $.ui.keyCode.PAGE_DOWN:
  17114. newVal = self._trimAlignValue(curVal - ((self._valueMax() - self._valueMin()) / numPages));
  17115. break;
  17116. case $.ui.keyCode.UP:
  17117. case $.ui.keyCode.RIGHT:
  17118. if (curVal === self._valueMax()) {
  17119. return
  17120. }
  17121. newVal = self._trimAlignValue(curVal + step);
  17122. break;
  17123. case $.ui.keyCode.DOWN:
  17124. case $.ui.keyCode.LEFT:
  17125. if (curVal === self._valueMin()) {
  17126. return
  17127. }
  17128. newVal = self._trimAlignValue(curVal - step);
  17129. break
  17130. }
  17131. self._slide(event, index, newVal);
  17132. return ret
  17133. }).keyup(function (event) {
  17134. var index = $(this).data("index.ui-slider-handle");
  17135. if (self._keySliding) {
  17136. self._keySliding = false;
  17137. self._stop(event, index);
  17138. self._change(event, index);
  17139. $(this).removeClass("ui-state-active")
  17140. }
  17141. });
  17142. this._refreshValue();
  17143. this._animateOff = false
  17144. },
  17145. destroy : function () {
  17146. this.handles.remove();
  17147. this.range.remove();
  17148. this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");
  17149. this._mouseDestroy();
  17150. return this
  17151. },
  17152. _mouseCapture : function (event) {
  17153. var o = this.options,
  17154. position,
  17155. normValue,
  17156. distance,
  17157. closestHandle,
  17158. self,
  17159. index,
  17160. allowed,
  17161. offset,
  17162. mouseOverHandle;
  17163. if (o.disabled) {
  17164. return false
  17165. }
  17166. this.elementSize = {
  17167. width : this.element.outerWidth(),
  17168. height : this.element.outerHeight()
  17169. };
  17170. this.elementOffset = this.element.offset();
  17171. position = {
  17172. x : event.pageX,
  17173. y : event.pageY
  17174. };
  17175. normValue = this._normValueFromMouse(position);
  17176. distance = this._valueMax() - this._valueMin() + 1;
  17177. self = this;
  17178. this.handles.each(function (i) {
  17179. var thisDistance = Math.abs(normValue - self.values(i));
  17180. if (distance > thisDistance) {
  17181. distance = thisDistance;
  17182. closestHandle = $(this);
  17183. index = i
  17184. }
  17185. });
  17186. if (o.range === true && this.values(1) === o.min) {
  17187. index += 1;
  17188. closestHandle = $(this.handles[index])
  17189. }
  17190. allowed = this._start(event, index);
  17191. if (allowed === false) {
  17192. return false
  17193. }
  17194. this._mouseSliding = true;
  17195. self._handleIndex = index;
  17196. closestHandle.addClass("ui-state-active").focus();
  17197. offset = closestHandle.offset();
  17198. mouseOverHandle = !$(event.target).parents().andSelf().is(".ui-slider-handle");
  17199. this._clickOffset = mouseOverHandle ? {
  17200. left : 0,
  17201. top : 0
  17202. }
  17203. : {
  17204. left : event.pageX - offset.left - (closestHandle.width() / 2),
  17205. top : event.pageY - offset.top - (closestHandle.height() / 2) - (parseInt(closestHandle.css("borderTopWidth"), 10) || 0) - (parseInt(closestHandle.css("borderBottomWidth"), 10) || 0) + (parseInt(closestHandle.css("marginTop"), 10) || 0)
  17206. };
  17207. if (!this.handles.hasClass("ui-state-hover")) {
  17208. this._slide(event, index, normValue)
  17209. }
  17210. this._animateOff = true;
  17211. return true
  17212. },
  17213. _mouseStart : function (event) {
  17214. return true
  17215. },
  17216. _mouseDrag : function (event) {
  17217. var position = {
  17218. x : event.pageX,
  17219. y : event.pageY
  17220. },
  17221. normValue = this._normValueFromMouse(position);
  17222. this._slide(event, this._handleIndex, normValue);
  17223. return false
  17224. },
  17225. _mouseStop : function (event) {
  17226. this.handles.removeClass("ui-state-active");
  17227. this._mouseSliding = false;
  17228. this._stop(event, this._handleIndex);
  17229. this._change(event, this._handleIndex);
  17230. this._handleIndex = null;
  17231. this._clickOffset = null;
  17232. this._animateOff = false;
  17233. return false
  17234. },
  17235. _detectOrientation : function () {
  17236. this.orientation = (this.options.orientation === "vertical") ? "vertical" : "horizontal"
  17237. },
  17238. _normValueFromMouse : function (position) {
  17239. var pixelTotal,
  17240. pixelMouse,
  17241. percentMouse,
  17242. valueTotal,
  17243. valueMouse;
  17244. if (this.orientation === "horizontal") {
  17245. pixelTotal = this.elementSize.width;
  17246. pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0)
  17247. } else {
  17248. pixelTotal = this.elementSize.height;
  17249. pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0)
  17250. }
  17251. percentMouse = (pixelMouse / pixelTotal);
  17252. if (percentMouse > 1) {
  17253. percentMouse = 1
  17254. }
  17255. if (percentMouse < 0) {
  17256. percentMouse = 0
  17257. }
  17258. if (this.orientation === "vertical") {
  17259. percentMouse = 1 - percentMouse
  17260. }
  17261. valueTotal = this._valueMax() - this._valueMin();
  17262. valueMouse = this._valueMin() + percentMouse * valueTotal;
  17263. return this._trimAlignValue(valueMouse)
  17264. },
  17265. _start : function (event, index) {
  17266. var uiHash = {
  17267. handle : this.handles[index],
  17268. value : this.value()
  17269. };
  17270. if (this.options.values && this.options.values.length) {
  17271. uiHash.value = this.values(index);
  17272. uiHash.values = this.values()
  17273. }
  17274. return this._trigger("start", event, uiHash)
  17275. },
  17276. _slide : function (event, index, newVal) {
  17277. var otherVal,
  17278. newValues,
  17279. allowed;
  17280. if (this.options.values && this.options.values.length) {
  17281. otherVal = this.values(index ? 0 : 1);
  17282. if ((this.options.values.length === 2 && this.options.range === true) && ((index === 0 && newVal > otherVal) || (index === 1 && newVal < otherVal))) {
  17283. newVal = otherVal
  17284. }
  17285. if (newVal !== this.values(index)) {
  17286. newValues = this.values();
  17287. newValues[index] = newVal;
  17288. allowed = this._trigger("slide", event, {
  17289. handle : this.handles[index],
  17290. value : newVal,
  17291. values : newValues
  17292. });
  17293. otherVal = this.values(index ? 0 : 1);
  17294. if (allowed !== false) {
  17295. this.values(index, newVal, true)
  17296. }
  17297. }
  17298. } else {
  17299. if (newVal !== this.value()) {
  17300. allowed = this._trigger("slide", event, {
  17301. handle : this.handles[index],
  17302. value : newVal
  17303. });
  17304. if (allowed !== false) {
  17305. this.value(newVal)
  17306. }
  17307. }
  17308. }
  17309. },
  17310. _stop : function (event, index) {
  17311. var uiHash = {
  17312. handle : this.handles[index],
  17313. value : this.value()
  17314. };
  17315. if (this.options.values && this.options.values.length) {
  17316. uiHash.value = this.values(index);
  17317. uiHash.values = this.values()
  17318. }
  17319. this._trigger("stop", event, uiHash)
  17320. },
  17321. _change : function (event, index) {
  17322. if (!this._keySliding && !this._mouseSliding) {
  17323. var uiHash = {
  17324. handle : this.handles[index],
  17325. value : this.value()
  17326. };
  17327. if (this.options.values && this.options.values.length) {
  17328. uiHash.value = this.values(index);
  17329. uiHash.values = this.values()
  17330. }
  17331. this._trigger("change", event, uiHash)
  17332. }
  17333. },
  17334. value : function (newValue) {
  17335. if (arguments.length) {
  17336. this.options.value = this._trimAlignValue(newValue);
  17337. this._refreshValue();
  17338. this._change(null, 0);
  17339. return
  17340. }
  17341. return this._value()
  17342. },
  17343. values : function (index, newValue) {
  17344. var vals,
  17345. newValues,
  17346. i;
  17347. if (arguments.length > 1) {
  17348. this.options.values[index] = this._trimAlignValue(newValue);
  17349. this._refreshValue();
  17350. this._change(null, index);
  17351. return
  17352. }
  17353. if (arguments.length) {
  17354. if ($.isArray(arguments[0])) {
  17355. vals = this.options.values;
  17356. newValues = arguments[0];
  17357. for (i = 0; i < vals.length; i += 1) {
  17358. vals[i] = this._trimAlignValue(newValues[i]);
  17359. this._change(null, i)
  17360. }
  17361. this._refreshValue()
  17362. } else {
  17363. if (this.options.values && this.options.values.length) {
  17364. return this._values(index)
  17365. } else {
  17366. return this.value()
  17367. }
  17368. }
  17369. } else {
  17370. return this._values()
  17371. }
  17372. },
  17373. _setOption : function (key, value) {
  17374. var i,
  17375. valsLength = 0;
  17376. if ($.isArray(this.options.values)) {
  17377. valsLength = this.options.values.length
  17378. }
  17379. $.Widget.prototype._setOption.apply(this, arguments);
  17380. switch (key) {
  17381. case "disabled":
  17382. if (value) {
  17383. this.handles.filter(".ui-state-focus").blur();
  17384. this.handles.removeClass("ui-state-hover");
  17385. this.handles.attr("disabled", "disabled");
  17386. this.element.addClass("ui-disabled")
  17387. } else {
  17388. this.handles.removeAttr("disabled");
  17389. this.element.removeClass("ui-disabled")
  17390. }
  17391. break;
  17392. case "orientation":
  17393. this._detectOrientation();
  17394. this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-" + this.orientation);
  17395. this._refreshValue();
  17396. break;
  17397. case "value":
  17398. this._animateOff = true;
  17399. this._refreshValue();
  17400. this._change(null, 0);
  17401. this._animateOff = false;
  17402. break;
  17403. case "values":
  17404. this._animateOff = true;
  17405. this._refreshValue();
  17406. for (i = 0; i < valsLength; i += 1) {
  17407. this._change(null, i)
  17408. }
  17409. this._animateOff = false;
  17410. break
  17411. }
  17412. },
  17413. _value : function () {
  17414. var val = this.options.value;
  17415. val = this._trimAlignValue(val);
  17416. return val
  17417. },
  17418. _values : function (index) {
  17419. var val,
  17420. vals,
  17421. i;
  17422. if (arguments.length) {
  17423. val = this.options.values[index];
  17424. val = this._trimAlignValue(val);
  17425. return val
  17426. } else {
  17427. vals = this.options.values.slice();
  17428. for (i = 0; i < vals.length; i += 1) {
  17429. vals[i] = this._trimAlignValue(vals[i])
  17430. }
  17431. return vals
  17432. }
  17433. },
  17434. _trimAlignValue : function (val) {
  17435. if (val <= this._valueMin()) {
  17436. return this._valueMin()
  17437. }
  17438. if (val >= this._valueMax()) {
  17439. return this._valueMax()
  17440. }
  17441. var step = (this.options.step > 0) ? this.options.step : 1,
  17442. valModStep = (val - this._valueMin()) % step;
  17443. alignValue = val - valModStep;
  17444. if (Math.abs(valModStep) * 2 >= step) {
  17445. alignValue += (valModStep > 0) ? step : (-step)
  17446. }
  17447. return parseFloat(alignValue.toFixed(5))
  17448. },
  17449. _valueMin : function () {
  17450. return this.options.min
  17451. },
  17452. _valueMax : function () {
  17453. return this.options.max
  17454. },
  17455. _refreshValue : function () {
  17456. var oRange = this.options.range,
  17457. o = this.options,
  17458. self = this,
  17459. animate = (!this._animateOff) ? o.animate : false,
  17460. valPercent,
  17461. _set = {},
  17462. lastValPercent,
  17463. value,
  17464. valueMin,
  17465. valueMax;
  17466. if (this.options.values && this.options.values.length) {
  17467. this.handles.each(function (i, j) {
  17468. valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100;
  17469. _set[self.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
  17470. $(this).stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
  17471. if (self.options.range === true) {
  17472. if (self.orientation === "horizontal") {
  17473. if (i === 0) {
  17474. self.range.stop(1, 1)[animate ? "animate" : "css"]({
  17475. left : valPercent + "%"
  17476. }, o.animate)
  17477. }
  17478. if (i === 1) {
  17479. self.range[animate ? "animate" : "css"]({
  17480. width : (valPercent - lastValPercent) + "%"
  17481. }, {
  17482. queue : false,
  17483. duration : o.animate
  17484. })
  17485. }
  17486. } else {
  17487. if (i === 0) {
  17488. self.range.stop(1, 1)[animate ? "animate" : "css"]({
  17489. bottom : (valPercent) + "%"
  17490. }, o.animate)
  17491. }
  17492. if (i === 1) {
  17493. self.range[animate ? "animate" : "css"]({
  17494. height : (valPercent - lastValPercent) + "%"
  17495. }, {
  17496. queue : false,
  17497. duration : o.animate
  17498. })
  17499. }
  17500. }
  17501. }
  17502. lastValPercent = valPercent
  17503. })
  17504. } else {
  17505. value = this.value();
  17506. valueMin = this._valueMin();
  17507. valueMax = this._valueMax();
  17508. valPercent = (valueMax !== valueMin) ? (value - valueMin) / (valueMax - valueMin) * 100 : 0;
  17509. _set[self.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
  17510. this.handle.stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
  17511. if (oRange === "min" && this.orientation === "horizontal") {
  17512. this.range.stop(1, 1)[animate ? "animate" : "css"]({
  17513. width : valPercent + "%"
  17514. }, o.animate)
  17515. }
  17516. if (oRange === "max" && this.orientation === "horizontal") {
  17517. this.range[animate ? "animate" : "css"]({
  17518. width : (100 - valPercent) + "%"
  17519. }, {
  17520. queue : false,
  17521. duration : o.animate
  17522. })
  17523. }
  17524. if (oRange === "min" && this.orientation === "vertical") {
  17525. this.range.stop(1, 1)[animate ? "animate" : "css"]({
  17526. height : valPercent + "%"
  17527. }, o.animate)
  17528. }
  17529. if (oRange === "max" && this.orientation === "vertical") {
  17530. this.range[animate ? "animate" : "css"]({
  17531. height : (100 - valPercent) + "%"
  17532. }, {
  17533. queue : false,
  17534. duration : o.animate
  17535. })
  17536. }
  17537. }
  17538. }
  17539. });
  17540. $.extend($.ui.slider, {
  17541. version : "1.8.12"
  17542. })
  17543. }
  17544. (jQuery));
  17545. (function ($, undefined) {
  17546. var tabId = 0,
  17547. listId = 0;
  17548. function getNextTabId() {
  17549. return ++tabId
  17550. }
  17551. function getNextListId() {
  17552. return ++listId
  17553. }
  17554. $.widget("ui.tabs", {
  17555. options : {
  17556. add : null,
  17557. ajaxOptions : null,
  17558. cache : false,
  17559. cookie : null,
  17560. collapsible : false,
  17561. disable : null,
  17562. disabled : [],
  17563. enable : null,
  17564. event : "click",
  17565. fx : null,
  17566. idPrefix : "ui-tabs-",
  17567. load : null,
  17568. panelTemplate : "<div></div>",
  17569. remove : null,
  17570. select : null,
  17571. show : null,
  17572. spinner : "<em>Loading&#8230;</em>",
  17573. tabTemplate : "<li><a href='#{href}'><span>#{label}</span></a></li>"
  17574. },
  17575. _create : function () {
  17576. this._tabify(true)
  17577. },
  17578. _setOption : function (key, value) {
  17579. if (key == "selected") {
  17580. if (this.options.collapsible && value == this.options.selected) {
  17581. return
  17582. }
  17583. this.select(value)
  17584. } else {
  17585. this.options[key] = value;
  17586. this._tabify()
  17587. }
  17588. },
  17589. _tabId : function (a) {
  17590. return a.title && a.title.replace(/\s/g, "_").replace(/[^\w\u00c0-\uFFFF-]/g, "") || this.options.idPrefix + getNextTabId()
  17591. },
  17592. _sanitizeSelector : function (hash) {
  17593. return hash.replace(/:/g, "\\:")
  17594. },
  17595. _cookie : function () {
  17596. var cookie = this.cookie || (this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId());
  17597. return $.cookie.apply(null, [cookie].concat($.makeArray(arguments)))
  17598. },
  17599. _ui : function (tab, panel) {
  17600. return {
  17601. tab : tab,
  17602. panel : panel,
  17603. index : this.anchors.index(tab)
  17604. }
  17605. },
  17606. _cleanup : function () {
  17607. this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function () {
  17608. var el = $(this);
  17609. el.html(el.data("label.tabs")).removeData("label.tabs")
  17610. })
  17611. },
  17612. _tabify : function (init) {
  17613. var self = this,
  17614. o = this.options,
  17615. fragmentId = /^#.+/;
  17616. this.list = this.element.find("ol,ul").eq(0);
  17617. this.lis = $(" > li:has(a[href])", this.list);
  17618. this.anchors = this.lis.map(function () {
  17619. return $("a", this)[0]
  17620. });
  17621. this.panels = $([]);
  17622. this.anchors.each(function (i, a) {
  17623. var href = $(a).attr("href");
  17624. var hrefBase = href.split("#")[0],
  17625. baseEl;
  17626. if (hrefBase && (hrefBase === location.toString().split("#")[0] || (baseEl = $("base")[0]) && hrefBase === baseEl.href)) {
  17627. href = a.hash;
  17628. a.href = href
  17629. }
  17630. if (fragmentId.test(href)) {
  17631. self.panels = self.panels.add(self.element.find(self._sanitizeSelector(href)))
  17632. } else {
  17633. if (href && href !== "#") {
  17634. $.data(a, "href.tabs", href);
  17635. $.data(a, "load.tabs", href.replace(/#.*$/, ""));
  17636. var id = self._tabId(a);
  17637. a.href = "#" + id;
  17638. var $panel = self.element.find("#" + id);
  17639. if (!$panel.length) {
  17640. $panel = $(o.panelTemplate).attr("id", id).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(self.panels[i - 1] || self.list);
  17641. $panel.data("destroy.tabs", true)
  17642. }
  17643. self.panels = self.panels.add($panel)
  17644. } else {
  17645. o.disabled.push(i)
  17646. }
  17647. }
  17648. });
  17649. if (init) {
  17650. this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
  17651. this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");
  17652. this.lis.addClass("ui-state-default ui-corner-top");
  17653. this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");
  17654. if (o.selected === undefined) {
  17655. if (location.hash) {
  17656. this.anchors.each(function (i, a) {
  17657. if (a.hash == location.hash) {
  17658. o.selected = i;
  17659. return false
  17660. }
  17661. })
  17662. }
  17663. if (typeof o.selected !== "number" && o.cookie) {
  17664. o.selected = parseInt(self._cookie(), 10)
  17665. }
  17666. if (typeof o.selected !== "number" && this.lis.filter(".ui-tabs-selected").length) {
  17667. o.selected = this.lis.index(this.lis.filter(".ui-tabs-selected"))
  17668. }
  17669. o.selected = o.selected || (this.lis.length ? 0 : -1)
  17670. } else {
  17671. if (o.selected === null) {
  17672. o.selected = -1
  17673. }
  17674. }
  17675. o.selected = ((o.selected >= 0 && this.anchors[o.selected]) || o.selected < 0) ? o.selected : 0;
  17676. o.disabled = $.unique(o.disabled.concat($.map(this.lis.filter(".ui-state-disabled"), function (n, i) {
  17677. return self.lis.index(n)
  17678. }))).sort();
  17679. if ($.inArray(o.selected, o.disabled) != -1) {
  17680. o.disabled.splice($.inArray(o.selected, o.disabled), 1)
  17681. }
  17682. this.panels.addClass("ui-tabs-hide");
  17683. this.lis.removeClass("ui-tabs-selected ui-state-active");
  17684. if (o.selected >= 0 && this.anchors.length) {
  17685. self.element.find(self._sanitizeSelector(self.anchors[o.selected].hash)).removeClass("ui-tabs-hide");
  17686. this.lis.eq(o.selected).addClass("ui-tabs-selected ui-state-active");
  17687. self.element.queue("tabs", function () {
  17688. self._trigger("show", null, self._ui(self.anchors[o.selected], self.element.find(self._sanitizeSelector(self.anchors[o.selected].hash))[0]))
  17689. });
  17690. this.load(o.selected)
  17691. }
  17692. $(window).bind("unload", function () {
  17693. self.lis.add(self.anchors).unbind(".tabs");
  17694. self.lis = self.anchors = self.panels = null
  17695. })
  17696. } else {
  17697. o.selected = this.lis.index(this.lis.filter(".ui-tabs-selected"))
  17698. }
  17699. this.element[o.collapsible ? "addClass" : "removeClass"]("ui-tabs-collapsible");
  17700. if (o.cookie) {
  17701. this._cookie(o.selected, o.cookie)
  17702. }
  17703. for (var i = 0, li; (li = this.lis[i]); i++) {
  17704. $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass("ui-tabs-selected") ? "addClass" : "removeClass"]("ui-state-disabled")
  17705. }
  17706. if (o.cache === false) {
  17707. this.anchors.removeData("cache.tabs")
  17708. }
  17709. this.lis.add(this.anchors).unbind(".tabs");
  17710. if (o.event !== "mouseover") {
  17711. var addState = function (state, el) {
  17712. if (el.is(":not(.ui-state-disabled)")) {
  17713. el.addClass("ui-state-" + state)
  17714. }
  17715. };
  17716. var removeState = function (state, el) {
  17717. el.removeClass("ui-state-" + state)
  17718. };
  17719. this.lis.bind("mouseover.tabs", function () {
  17720. addState("hover", $(this))
  17721. });
  17722. this.lis.bind("mouseout.tabs", function () {
  17723. removeState("hover", $(this))
  17724. });
  17725. this.anchors.bind("focus.tabs", function () {
  17726. addState("focus", $(this).closest("li"))
  17727. });
  17728. this.anchors.bind("blur.tabs", function () {
  17729. removeState("focus", $(this).closest("li"))
  17730. })
  17731. }
  17732. var hideFx,
  17733. showFx;
  17734. if (o.fx) {
  17735. if ($.isArray(o.fx)) {
  17736. hideFx = o.fx[0];
  17737. showFx = o.fx[1]
  17738. } else {
  17739. hideFx = showFx = o.fx
  17740. }
  17741. }
  17742. function resetStyle($el, fx) {
  17743. $el.css("display", "");
  17744. if (!$.support.opacity && fx.opacity) {
  17745. $el[0].style.removeAttribute("filter")
  17746. }
  17747. }
  17748. var showTab = showFx ? function (clicked, $show) {
  17749. $(clicked).closest("li").addClass("ui-tabs-selected ui-state-active");
  17750. $show.hide().removeClass("ui-tabs-hide").animate(showFx, showFx.duration || "normal", function () {
  17751. resetStyle($show, showFx);
  17752. self._trigger("show", null, self._ui(clicked, $show[0]))
  17753. })
  17754. }
  17755. : function (clicked, $show) {
  17756. $(clicked).closest("li").addClass("ui-tabs-selected ui-state-active");
  17757. $show.removeClass("ui-tabs-hide");
  17758. self._trigger("show", null, self._ui(clicked, $show[0]))
  17759. };
  17760. var hideTab = hideFx ? function (clicked, $hide) {
  17761. $hide.animate(hideFx, hideFx.duration || "normal", function () {
  17762. self.lis.removeClass("ui-tabs-selected ui-state-active");
  17763. $hide.addClass("ui-tabs-hide");
  17764. resetStyle($hide, hideFx);
  17765. self.element.dequeue("tabs")
  17766. })
  17767. }
  17768. : function (clicked, $hide, $show) {
  17769. self.lis.removeClass("ui-tabs-selected ui-state-active");
  17770. $hide.addClass("ui-tabs-hide");
  17771. self.element.dequeue("tabs")
  17772. };
  17773. this.anchors.bind(o.event + ".tabs", function () {
  17774. var el = this,
  17775. $li = $(el).closest("li"),
  17776. $hide = self.panels.filter(":not(.ui-tabs-hide)"),
  17777. $show = self.element.find(self._sanitizeSelector(el.hash));
  17778. if (($li.hasClass("ui-tabs-selected") && !o.collapsible) || $li.hasClass("ui-state-disabled") || $li.hasClass("ui-state-processing") || self.panels.filter(":animated").length || self._trigger("select", null, self._ui(this, $show[0])) === false) {
  17779. this.blur();
  17780. return false
  17781. }
  17782. o.selected = self.anchors.index(this);
  17783. self.abort();
  17784. if (o.collapsible) {
  17785. if ($li.hasClass("ui-tabs-selected")) {
  17786. o.selected = -1;
  17787. if (o.cookie) {
  17788. self._cookie(o.selected, o.cookie)
  17789. }
  17790. self.element.queue("tabs", function () {
  17791. hideTab(el, $hide)
  17792. }).dequeue("tabs");
  17793. this.blur();
  17794. return false
  17795. } else {
  17796. if (!$hide.length) {
  17797. if (o.cookie) {
  17798. self._cookie(o.selected, o.cookie)
  17799. }
  17800. self.element.queue("tabs", function () {
  17801. showTab(el, $show)
  17802. });
  17803. self.load(self.anchors.index(this));
  17804. this.blur();
  17805. return false
  17806. }
  17807. }
  17808. }
  17809. if (o.cookie) {
  17810. self._cookie(o.selected, o.cookie)
  17811. }
  17812. if ($show.length) {
  17813. if ($hide.length) {
  17814. self.element.queue("tabs", function () {
  17815. hideTab(el, $hide)
  17816. })
  17817. }
  17818. self.element.queue("tabs", function () {
  17819. showTab(el, $show)
  17820. });
  17821. self.load(self.anchors.index(this))
  17822. } else {
  17823. throw "jQuery UI Tabs: Mismatching fragment identifier."
  17824. }
  17825. if ($.browser.msie) {
  17826. this.blur()
  17827. }
  17828. });
  17829. this.anchors.bind("click.tabs", function () {
  17830. return false
  17831. })
  17832. },
  17833. _getIndex : function (index) {
  17834. if (typeof index == "string") {
  17835. index = this.anchors.index(this.anchors.filter("[href$=" + index + "]"))
  17836. }
  17837. return index
  17838. },
  17839. destroy : function () {
  17840. var o = this.options;
  17841. this.abort();
  17842. this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");
  17843. this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");
  17844. this.anchors.each(function () {
  17845. var href = $.data(this, "href.tabs");
  17846. if (href) {
  17847. this.href = href
  17848. }
  17849. var $this = $(this).unbind(".tabs");
  17850. $.each(["href", "load", "cache"], function (i, prefix) {
  17851. $this.removeData(prefix + ".tabs")
  17852. })
  17853. });
  17854. this.lis.unbind(".tabs").add(this.panels).each(function () {
  17855. if ($.data(this, "destroy.tabs")) {
  17856. $(this).remove()
  17857. } else {
  17858. $(this).removeClass(["ui-state-default", "ui-corner-top", "ui-tabs-selected", "ui-state-active", "ui-state-hover", "ui-state-focus", "ui-state-disabled", "ui-tabs-panel", "ui-widget-content", "ui-corner-bottom", "ui-tabs-hide"].join(" "))
  17859. }
  17860. });
  17861. if (o.cookie) {
  17862. this._cookie(null, o.cookie)
  17863. }
  17864. return this
  17865. },
  17866. add : function (url, label, index) {
  17867. if (index === undefined) {
  17868. index = this.anchors.length
  17869. }
  17870. var self = this,
  17871. o = this.options,
  17872. $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)),
  17873. id = !url.indexOf("#") ? url.replace("#", "") : this._tabId($("a", $li)[0]);
  17874. $li.addClass("ui-state-default ui-corner-top").data("destroy.tabs", true);
  17875. var $panel = self.element.find("#" + id);
  17876. if (!$panel.length) {
  17877. $panel = $(o.panelTemplate).attr("id", id).data("destroy.tabs", true)
  17878. }
  17879. $panel.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");
  17880. if (index >= this.lis.length) {
  17881. $li.appendTo(this.list);
  17882. $panel.appendTo(this.list[0].parentNode)
  17883. } else {
  17884. $li.insertBefore(this.lis[index]);
  17885. $panel.insertBefore(this.panels[index])
  17886. }
  17887. o.disabled = $.map(o.disabled, function (n, i) {
  17888. return n >= index ? ++n : n
  17889. });
  17890. this._tabify();
  17891. if (this.anchors.length == 1) {
  17892. o.selected = 0;
  17893. $li.addClass("ui-tabs-selected ui-state-active");
  17894. $panel.removeClass("ui-tabs-hide");
  17895. this.element.queue("tabs", function () {
  17896. self._trigger("show", null, self._ui(self.anchors[0], self.panels[0]))
  17897. });
  17898. this.load(0)
  17899. }
  17900. this._trigger("add", null, this._ui(this.anchors[index], this.panels[index]));
  17901. return this
  17902. },
  17903. remove : function (index) {
  17904. index = this._getIndex(index);
  17905. var o = this.options,
  17906. $li = this.lis.eq(index).remove(),
  17907. $panel = this.panels.eq(index).remove();
  17908. if ($li.hasClass("ui-tabs-selected") && this.anchors.length > 1) {
  17909. this.select(index + (index + 1 < this.anchors.length ? 1 : -1))
  17910. }
  17911. o.disabled = $.map($.grep(o.disabled, function (n, i) {
  17912. return n != index
  17913. }), function (n, i) {
  17914. return n >= index ? --n : n
  17915. });
  17916. this._tabify();
  17917. this._trigger("remove", null, this._ui($li.find("a")[0], $panel[0]));
  17918. return this
  17919. },
  17920. enable : function (index) {
  17921. index = this._getIndex(index);
  17922. var o = this.options;
  17923. if ($.inArray(index, o.disabled) == -1) {
  17924. return
  17925. }
  17926. this.lis.eq(index).removeClass("ui-state-disabled");
  17927. o.disabled = $.grep(o.disabled, function (n, i) {
  17928. return n != index
  17929. });
  17930. this._trigger("enable", null, this._ui(this.anchors[index], this.panels[index]));
  17931. return this
  17932. },
  17933. disable : function (index) {
  17934. index = this._getIndex(index);
  17935. var self = this,
  17936. o = this.options;
  17937. if (index != o.selected) {
  17938. this.lis.eq(index).addClass("ui-state-disabled");
  17939. o.disabled.push(index);
  17940. o.disabled.sort();
  17941. this._trigger("disable", null, this._ui(this.anchors[index], this.panels[index]))
  17942. }
  17943. return this
  17944. },
  17945. select : function (index) {
  17946. index = this._getIndex(index);
  17947. if (index == -1) {
  17948. if (this.options.collapsible && this.options.selected != -1) {
  17949. index = this.options.selected
  17950. } else {
  17951. return this
  17952. }
  17953. }
  17954. this.anchors.eq(index).trigger(this.options.event + ".tabs");
  17955. return this
  17956. },
  17957. load : function (index) {
  17958. index = this._getIndex(index);
  17959. var self = this,
  17960. o = this.options,
  17961. a = this.anchors.eq(index)[0],
  17962. url = $.data(a, "load.tabs");
  17963. this.abort();
  17964. if (!url || this.element.queue("tabs").length !== 0 && $.data(a, "cache.tabs")) {
  17965. this.element.dequeue("tabs");
  17966. return
  17967. }
  17968. this.lis.eq(index).addClass("ui-state-processing");
  17969. if (o.spinner) {
  17970. var span = $("span", a);
  17971. span.data("label.tabs", span.html()).html(o.spinner)
  17972. }
  17973. this.xhr = $.ajax($.extend({}, o.ajaxOptions, {
  17974. url : url,
  17975. success : function (r, s) {
  17976. self.element.find(self._sanitizeSelector(a.hash)).html(r);
  17977. self._cleanup();
  17978. if (o.cache) {
  17979. $.data(a, "cache.tabs", true)
  17980. }
  17981. self._trigger("load", null, self._ui(self.anchors[index], self.panels[index]));
  17982. try {
  17983. o.ajaxOptions.success(r, s)
  17984. } catch (e) {}
  17985. },
  17986. error : function (xhr, s, e) {
  17987. self._cleanup();
  17988. self._trigger("load", null, self._ui(self.anchors[index], self.panels[index]));
  17989. try {
  17990. o.ajaxOptions.error(xhr, s, index, a)
  17991. } catch (e) {}
  17992. }
  17993. }));
  17994. self.element.dequeue("tabs");
  17995. return this
  17996. },
  17997. abort : function () {
  17998. this.element.queue([]);
  17999. this.panels.stop(false, true);
  18000. this.element.queue("tabs", this.element.queue("tabs").splice(-2, 2));
  18001. if (this.xhr) {
  18002. this.xhr.abort();
  18003. delete this.xhr
  18004. }
  18005. this._cleanup();
  18006. return this
  18007. },
  18008. url : function (index, url) {
  18009. this.anchors.eq(index).removeData("cache.tabs").data("load.tabs", url);
  18010. return this
  18011. },
  18012. length : function () {
  18013. return this.anchors.length
  18014. }
  18015. });
  18016. $.extend($.ui.tabs, {
  18017. version : "1.8.12"
  18018. });
  18019. $.extend($.ui.tabs.prototype, {
  18020. rotation : null,
  18021. rotate : function (ms, continuing) {
  18022. var self = this,
  18023. o = this.options;
  18024. var rotate = self._rotate || (self._rotate = function (e) {
  18025. clearTimeout(self.rotation);
  18026. self.rotation = setTimeout(function () {
  18027. var t = o.selected;
  18028. self.select(++t < self.anchors.length ? t : 0)
  18029. }, ms);
  18030. if (e) {
  18031. e.stopPropagation()
  18032. }
  18033. });
  18034. var stop = self._unrotate || (self._unrotate = !continuing ? function (e) {
  18035. if (e.clientX) {
  18036. self.rotate(null)
  18037. }
  18038. }
  18039. : function (e) {
  18040. t = o.selected;
  18041. rotate()
  18042. });
  18043. if (ms) {
  18044. this.element.bind("tabsshow", rotate);
  18045. this.anchors.bind(o.event + ".tabs", stop);
  18046. rotate()
  18047. } else {
  18048. clearTimeout(self.rotation);
  18049. this.element.unbind("tabsshow", rotate);
  18050. this.anchors.unbind(o.event + ".tabs", stop);
  18051. delete this._rotate;
  18052. delete this._unrotate
  18053. }
  18054. return this
  18055. }
  18056. })
  18057. })(jQuery);
  18058. if (!this.JSON) {
  18059. JSON = function () {
  18060. function f(n) {
  18061. return n < 10 ? "0" + n : n
  18062. }
  18063. Date.prototype.toJSON = function () {
  18064. return this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z"
  18065. };
  18066. var m = {
  18067. "\b" : "\\b",
  18068. "\t" : "\\t",
  18069. "\n" : "\\n",
  18070. "\f" : "\\f",
  18071. "\r" : "\\r",
  18072. '"' : '\\"',
  18073. "\\" : "\\\\"
  18074. };
  18075. function stringify(value, whitelist) {
  18076. var a,
  18077. i,
  18078. k,
  18079. l,
  18080. r = /["\\\x00-\x1f\x7f-\x9f]/g,
  18081. v;
  18082. switch (typeof value) {
  18083. case "string":
  18084. return r.test(value) ? '"' + value.replace(r, function (a) {
  18085. var c = m[a];
  18086. if (c) {
  18087. return c
  18088. }
  18089. c = a.charCodeAt();
  18090. return "\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16)
  18091. }) + '"' : '"' + value + '"';
  18092. case "number":
  18093. return isFinite(value) ? String(value) : "null";
  18094. case "boolean":
  18095. case "null":
  18096. return String(value);
  18097. case "object":
  18098. if (!value) {
  18099. return "null"
  18100. }
  18101. if (typeof value.toJSON === "function") {
  18102. return stringify(value.toJSON())
  18103. }
  18104. a = [];
  18105. if (typeof value.length === "number" && !(value.propertyIsEnumerable("length"))) {
  18106. l = value.length;
  18107. for (i = 0; i < l; i += 1) {
  18108. a.push(stringify(value[i], whitelist) || "null")
  18109. }
  18110. return "[" + a.join(",") + "]"
  18111. }
  18112. if (whitelist) {
  18113. l = whitelist.length;
  18114. for (i = 0; i < l; i += 1) {
  18115. k = whitelist[i];
  18116. if (typeof k === "string") {
  18117. v = stringify(value[k], whitelist);
  18118. if (v) {
  18119. a.push(stringify(k) + ":" + v)
  18120. }
  18121. }
  18122. }
  18123. } else {
  18124. for (k in value) {
  18125. if (typeof k === "string") {
  18126. v = stringify(value[k], whitelist);
  18127. if (v) {
  18128. a.push(stringify(k) + ":" + v)
  18129. }
  18130. }
  18131. }
  18132. }
  18133. return "{" + a.join(",") + "}"
  18134. }
  18135. }
  18136. return {
  18137. stringify : stringify,
  18138. parse : function (text, filter) {
  18139. var j;
  18140. function walk(k, v) {
  18141. var i,
  18142. n;
  18143. if (v && typeof v === "object") {
  18144. for (i in v) {
  18145. if (Object.prototype.hasOwnProperty.apply(v, [i])) {
  18146. n = walk(i, v[i]);
  18147. if (n !== undefined) {
  18148. v[i] = n
  18149. }
  18150. }
  18151. }
  18152. }
  18153. return filter(k, v)
  18154. }
  18155. if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
  18156. j = eval("(" + text + ")");
  18157. return typeof filter === "function" ? walk("", j) : j
  18158. }
  18159. throw new SyntaxError("parseJSON")
  18160. }
  18161. }
  18162. }
  18163. ()
  18164. };
  18165. var fluid_1_4 = fluid_1_4 || {};
  18166. (function ($, fluid) {
  18167. fluid.dom.computeAbsolutePosition = function (element) {
  18168. var curleft = 0,
  18169. curtop = 0;
  18170. if (element.offsetParent) {
  18171. do {
  18172. curleft += element.offsetLeft;
  18173. curtop += element.offsetTop;
  18174. element = element.offsetParent
  18175. } while (element);
  18176. return [curleft, curtop]
  18177. }
  18178. };
  18179. fluid.dom.cleanseScripts = function (element) {
  18180. var cleansed = $.data(element, fluid.dom.cleanseScripts.MARKER);
  18181. if (!cleansed) {
  18182. fluid.dom.iterateDom(element, function (node) {
  18183. return node.tagName.toLowerCase() === "script" ? "delete" : null
  18184. });
  18185. $.data(element, fluid.dom.cleanseScripts.MARKER, true)
  18186. }
  18187. };
  18188. fluid.dom.cleanseScripts.MARKER = "fluid-scripts-cleansed";
  18189. fluid.dom.insertAfter = function (newChild, refChild) {
  18190. var nextSib = refChild.nextSibling;
  18191. if (!nextSib) {
  18192. refChild.parentNode.appendChild(newChild)
  18193. } else {
  18194. refChild.parentNode.insertBefore(newChild, nextSib)
  18195. }
  18196. };
  18197. fluid.dom.isWhitespaceNode = function (node) {
  18198. return !(/[^\t\n\r ]/.test(node.data))
  18199. };
  18200. fluid.dom.isIgnorableNode = function (node) {
  18201. return (node.nodeType === 8) || ((node.nodeType === 3) && fluid.dom.isWhitespaceNode(node))
  18202. }
  18203. })(jQuery, fluid_1_4);
  18204. var fluid_1_4 = fluid_1_4 || {};
  18205. (function ($, fluid) {
  18206. fluid.orientation = {
  18207. HORIZONTAL : 4,
  18208. VERTICAL : 1
  18209. };
  18210. fluid.rectSides = {
  18211. 4 : ["left", "right"],
  18212. 1 : ["top", "bottom"],
  18213. 8 : "top",
  18214. 12 : "bottom",
  18215. 2 : "left",
  18216. 3 : "right"
  18217. };
  18218. fluid.position = {
  18219. BEFORE : -1,
  18220. AFTER : 1,
  18221. INSIDE : 2,
  18222. REPLACE : 3
  18223. };
  18224. fluid.direction = {
  18225. NEXT : 1,
  18226. PREVIOUS : -1,
  18227. UP : 8,
  18228. DOWN : 12,
  18229. LEFT : 2,
  18230. RIGHT : 3
  18231. };
  18232. fluid.directionSign = function (direction) {
  18233. return direction === fluid.direction.UP || direction === fluid.direction.LEFT ? fluid.direction.PREVIOUS : fluid.direction.NEXT
  18234. };
  18235. fluid.directionAxis = function (direction) {
  18236. return direction === fluid.direction.LEFT || direction === fluid.direction.RIGHT ? 0 : 1
  18237. };
  18238. fluid.directionOrientation = function (direction) {
  18239. return fluid.directionAxis(direction) ? fluid.orientation.VERTICAL : fluid.orientation.HORIZONTAL
  18240. };
  18241. fluid.keycodeDirection = {
  18242. up : fluid.direction.UP,
  18243. down : fluid.direction.DOWN,
  18244. left : fluid.direction.LEFT,
  18245. right : fluid.direction.RIGHT
  18246. };
  18247. fluid.moveDom = function (source, target, position) {
  18248. source = fluid.unwrap(source);
  18249. target = fluid.unwrap(target);
  18250. var scan;
  18251. if (position === fluid.position.INSIDE) {
  18252. target.appendChild(source)
  18253. } else {
  18254. if (position === fluid.position.BEFORE) {
  18255. for (scan = target.previousSibling; ; scan = scan.previousSibling) {
  18256. if (!scan || !fluid.dom.isIgnorableNode(scan)) {
  18257. if (scan !== source) {
  18258. fluid.dom.cleanseScripts(source);
  18259. target.parentNode.insertBefore(source, target)
  18260. }
  18261. break
  18262. }
  18263. }
  18264. } else {
  18265. if (position === fluid.position.AFTER) {
  18266. for (scan = target.nextSibling; ; scan = scan.nextSibling) {
  18267. if (!scan || !fluid.dom.isIgnorableNode(scan)) {
  18268. if (scan !== source) {
  18269. fluid.dom.cleanseScripts(source);
  18270. fluid.dom.insertAfter(source, target)
  18271. }
  18272. break
  18273. }
  18274. }
  18275. } else {
  18276. fluid.fail("Unrecognised position supplied to fluid.moveDom: " + position)
  18277. }
  18278. }
  18279. }
  18280. };
  18281. fluid.normalisePosition = function (position, samespan, targeti, sourcei) {
  18282. if (position === fluid.position.REPLACE) {
  18283. position = samespan && targeti >= sourcei ? fluid.position.AFTER : fluid.position.BEFORE
  18284. }
  18285. return position
  18286. };
  18287. fluid.permuteDom = function (element, target, position, sourceelements, targetelements) {
  18288. element = fluid.unwrap(element);
  18289. target = fluid.unwrap(target);
  18290. var sourcei = $.inArray(element, sourceelements);
  18291. if (sourcei === -1) {
  18292. fluid.fail("Error in permuteDom: source element " + fluid.dumpEl(element) + " not found in source list " + fluid.dumpEl(sourceelements))
  18293. }
  18294. var targeti = $.inArray(target, targetelements);
  18295. if (targeti === -1) {
  18296. fluid.fail("Error in permuteDom: target element " + fluid.dumpEl(target) + " not found in source list " + fluid.dumpEl(targetelements))
  18297. }
  18298. var samespan = sourceelements === targetelements;
  18299. position = fluid.normalisePosition(position, samespan, targeti, sourcei);
  18300. var oldn = {};
  18301. oldn[fluid.position.AFTER] = element.nextSibling;
  18302. oldn[fluid.position.BEFORE] = element.previousSibling;
  18303. fluid.moveDom(sourceelements[sourcei], targetelements[targeti], position);
  18304. var frontlimit = samespan ? targeti - 1 : sourceelements.length - 2;
  18305. var i;
  18306. if (position === fluid.position.BEFORE && samespan) {
  18307. frontlimit--
  18308. }
  18309. if (!samespan || targeti > sourcei) {
  18310. for (i = frontlimit; i > sourcei; --i) {
  18311. fluid.moveDom(sourceelements[i + 1], sourceelements[i], fluid.position.AFTER)
  18312. }
  18313. if (sourcei + 1 < sourceelements.length) {
  18314. fluid.moveDom(sourceelements[sourcei + 1], oldn[fluid.position.AFTER], fluid.position.BEFORE)
  18315. }
  18316. }
  18317. var backlimit = samespan ? sourcei - 1 : targetelements.length - 1;
  18318. if (position === fluid.position.AFTER) {
  18319. targeti++
  18320. }
  18321. if (!samespan || targeti < sourcei) {
  18322. for (i = targeti; i < backlimit; ++i) {
  18323. fluid.moveDom(targetelements[i], targetelements[i + 1], fluid.position.BEFORE)
  18324. }
  18325. if (backlimit >= 0 && backlimit < targetelements.length - 1) {
  18326. fluid.moveDom(targetelements[backlimit], oldn[fluid.position.BEFORE], fluid.position.AFTER)
  18327. }
  18328. }
  18329. };
  18330. var curCss = function (a, name) {
  18331. return window.getComputedStyle ? window.getComputedStyle(a, null).getPropertyValue(name) : a.currentStyle[name]
  18332. };
  18333. var isAttached = function (node) {
  18334. while (node && node.nodeName) {
  18335. if (node.nodeName === "BODY") {
  18336. return true
  18337. }
  18338. node = node.parentNode
  18339. }
  18340. return false
  18341. };
  18342. var generalHidden = function (a) {
  18343. return "hidden" === a.type || curCss(a, "display") === "none" || curCss(a, "visibility") === "hidden" || !isAttached(a)
  18344. };
  18345. var computeGeometry = function (element, orientation, disposition) {
  18346. var elem = {};
  18347. elem.element = element;
  18348. elem.orientation = orientation;
  18349. if (disposition === fluid.position.INSIDE) {
  18350. elem.position = disposition
  18351. }
  18352. if (generalHidden(element)) {
  18353. elem.clazz = "hidden"
  18354. }
  18355. var pos = fluid.dom.computeAbsolutePosition(element) || [0, 0];
  18356. var width = element.offsetWidth;
  18357. var height = element.offsetHeight;
  18358. elem.rect = {
  18359. left : pos[0],
  18360. top : pos[1]
  18361. };
  18362. elem.rect.right = pos[0] + width;
  18363. elem.rect.bottom = pos[1] + height;
  18364. return elem
  18365. };
  18366. var SENTINEL_DIMENSION = 10000;
  18367. function dumprect(rect) {
  18368. return "Rect top: " + rect.top + " left: " + rect.left + " bottom: " + rect.bottom + " right: " + rect.right
  18369. }
  18370. function dumpelem(cacheelem) {
  18371. if (!cacheelem || !cacheelem.rect) {
  18372. return "null"
  18373. } else {
  18374. return dumprect(cacheelem.rect) + " position: " + cacheelem.position + " for " + fluid.dumpEl(cacheelem.element)
  18375. }
  18376. }
  18377. fluid.dropManager = function () {
  18378. var targets = [];
  18379. var cache = {};
  18380. var that = {};
  18381. var lastClosest;
  18382. var lastGeometry;
  18383. var displacementX,
  18384. displacementY;
  18385. that.updateGeometry = function (geometricInfo) {
  18386. lastGeometry = geometricInfo;
  18387. targets = [];
  18388. cache = {};
  18389. var mapper = geometricInfo.elementMapper;
  18390. for (var i = 0; i < geometricInfo.extents.length; ++i) {
  18391. var thisInfo = geometricInfo.extents[i];
  18392. var orientation = thisInfo.orientation;
  18393. var sides = fluid.rectSides[orientation];
  18394. var processElement = function (element, sentB, sentF, disposition, j) {
  18395. var cacheelem = computeGeometry(element, orientation, disposition);
  18396. cacheelem.owner = thisInfo;
  18397. if (cacheelem.clazz !== "hidden" && mapper) {
  18398. cacheelem.clazz = mapper(element)
  18399. }
  18400. cache[fluid.dropManager.cacheKey(element)] = cacheelem;
  18401. var backClass = fluid.dropManager.getRelativeClass(thisInfo.elements, j, fluid.position.BEFORE, cacheelem.clazz, mapper);
  18402. var frontClass = fluid.dropManager.getRelativeClass(thisInfo.elements, j, fluid.position.AFTER, cacheelem.clazz, mapper);
  18403. if (disposition === fluid.position.INSIDE) {
  18404. targets[targets.length] = cacheelem
  18405. } else {
  18406. fluid.dropManager.splitElement(targets, sides, cacheelem, disposition, backClass, frontClass)
  18407. }
  18408. if (sentB && geometricInfo.sentinelize) {
  18409. fluid.dropManager.sentinelizeElement(targets, sides, cacheelem, 1, disposition, backClass)
  18410. }
  18411. if (sentF && geometricInfo.sentinelize) {
  18412. fluid.dropManager.sentinelizeElement(targets, sides, cacheelem, 0, disposition, frontClass)
  18413. }
  18414. return cacheelem
  18415. };
  18416. var allHidden = true;
  18417. for (var j = 0; j < thisInfo.elements.length; ++j) {
  18418. var element = thisInfo.elements[j];
  18419. var cacheelem = processElement(element, j === 0, j === thisInfo.elements.length - 1, fluid.position.INTERLEAVED, j);
  18420. if (cacheelem.clazz !== "hidden") {
  18421. allHidden = false
  18422. }
  18423. }
  18424. if (allHidden && thisInfo.parentElement) {
  18425. processElement(thisInfo.parentElement, true, true, fluid.position.INSIDE)
  18426. }
  18427. }
  18428. };
  18429. that.startDrag = function (event, handlePos, handleWidth, handleHeight) {
  18430. var handleMidX = handlePos[0] + handleWidth / 2;
  18431. var handleMidY = handlePos[1] + handleHeight / 2;
  18432. var dX = handleMidX - event.pageX;
  18433. var dY = handleMidY - event.pageY;
  18434. that.updateGeometry(lastGeometry);
  18435. lastClosest = null;
  18436. displacementX = dX;
  18437. displacementY = dY;
  18438. $("body").bind("mousemove.fluid-dropManager", that.mouseMove)
  18439. };
  18440. that.lastPosition = function () {
  18441. return lastClosest
  18442. };
  18443. that.endDrag = function () {
  18444. $("body").unbind("mousemove.fluid-dropManager")
  18445. };
  18446. that.mouseMove = function (evt) {
  18447. var x = evt.pageX + displacementX;
  18448. var y = evt.pageY + displacementY;
  18449. var closestTarget = that.closestTarget(x, y, lastClosest);
  18450. if (closestTarget && closestTarget !== fluid.dropManager.NO_CHANGE) {
  18451. lastClosest = closestTarget;
  18452. that.dropChangeFirer.fire(closestTarget)
  18453. }
  18454. };
  18455. that.dropChangeFirer = fluid.event.getEventFirer();
  18456. var blankHolder = {
  18457. element : null
  18458. };
  18459. that.closestTarget = function (x, y, lastClosest) {
  18460. var mindistance = Number.MAX_VALUE;
  18461. var minelem = blankHolder;
  18462. var minlockeddistance = Number.MAX_VALUE;
  18463. var minlockedelem = blankHolder;
  18464. for (var i = 0; i < targets.length; ++i) {
  18465. var cacheelem = targets[i];
  18466. if (cacheelem.clazz === "hidden") {
  18467. continue
  18468. }
  18469. var distance = fluid.geom.minPointRectangle(x, y, cacheelem.rect);
  18470. if (cacheelem.clazz === "locked") {
  18471. if (distance < minlockeddistance) {
  18472. minlockeddistance = distance;
  18473. minlockedelem = cacheelem
  18474. }
  18475. } else {
  18476. if (distance < mindistance) {
  18477. mindistance = distance;
  18478. minelem = cacheelem
  18479. }
  18480. if (distance === 0) {
  18481. break
  18482. }
  18483. }
  18484. }
  18485. if (!minelem) {
  18486. return minelem
  18487. }
  18488. if (minlockeddistance >= mindistance) {
  18489. minlockedelem = blankHolder
  18490. }
  18491. if (lastClosest && lastClosest.position === minelem.position && fluid.unwrap(lastClosest.element) === fluid.unwrap(minelem.element) && fluid.unwrap(lastClosest.lockedelem) === fluid.unwrap(minlockedelem.element)) {
  18492. return fluid.dropManager.NO_CHANGE
  18493. }
  18494. return {
  18495. position : minelem.position,
  18496. element : minelem.element,
  18497. lockedelem : minlockedelem.element
  18498. }
  18499. };
  18500. that.shuffleProjectFrom = function (element, direction, includeLocked, disableWrap) {
  18501. var togo = that.projectFrom(element, direction, includeLocked, disableWrap);
  18502. if (togo) {
  18503. togo.position = fluid.position.REPLACE
  18504. }
  18505. return togo
  18506. };
  18507. that.projectFrom = function (element, direction, includeLocked, disableWrap) {
  18508. that.updateGeometry(lastGeometry);
  18509. var cacheelem = cache[fluid.dropManager.cacheKey(element)];
  18510. var projected = fluid.geom.projectFrom(cacheelem.rect, direction, targets, includeLocked, disableWrap);
  18511. if (!projected.cacheelem) {
  18512. return null
  18513. }
  18514. var retpos = projected.cacheelem.position;
  18515. return {
  18516. element : projected.cacheelem.element,
  18517. position : retpos ? retpos : fluid.position.BEFORE
  18518. }
  18519. };
  18520. that.logicalFrom = function (element, direction, includeLocked, disableWrap) {
  18521. var orderables = that.getOwningSpan(element, fluid.position.INTERLEAVED, includeLocked);
  18522. var pos;
  18523. switch (direction) {
  18524. case fluid.direction.UP:
  18525. case fluid.direction.LEFT:
  18526. case fluid.direction.PREVIOUS:
  18527. pos = fluid.position.BEFORE;
  18528. break;
  18529. case fluid.direction.DOWN:
  18530. case fluid.direction.RIGHT:
  18531. case fluid.direction.NEXT:
  18532. pos = fluid.position.AFTER;
  18533. break;
  18534. }
  18535. return {
  18536. element : fluid.dropManager.getRelativeElement(element, direction, orderables, disableWrap),
  18537. position : pos
  18538. }
  18539. };
  18540. that.lockedWrapFrom = function (element, direction, includeLocked, disableWrap) {
  18541. var base = that.logicalFrom(element, direction, includeLocked, disableWrap);
  18542. var selectables = that.getOwningSpan(element, fluid.position.INTERLEAVED, includeLocked);
  18543. var allElements = cache[fluid.dropManager.cacheKey(element)].owner.elements;
  18544. if (includeLocked || selectables[0] === allElements[0]) {
  18545. return base
  18546. }
  18547. var directElement = fluid.dropManager.getRelativeElement(element, direction, allElements, disableWrap);
  18548. if (lastGeometry.elementMapper(directElement) === "locked") {
  18549. base.element = null;
  18550. base.clazz = "locked"
  18551. }
  18552. return base
  18553. };
  18554. that.getOwningSpan = function (element, position, includeLocked) {
  18555. var owner = cache[fluid.dropManager.cacheKey(element)].owner;
  18556. var elements = position === fluid.position.INSIDE ? [owner.parentElement] : owner.elements;
  18557. if (!includeLocked && lastGeometry.elementMapper) {
  18558. elements = $.makeArray(elements);
  18559. fluid.remove_if(elements, function (element) {
  18560. return lastGeometry.elementMapper(element) === "locked"
  18561. })
  18562. }
  18563. return elements
  18564. };
  18565. that.geometricMove = function (element, target, position) {
  18566. var sourceElements = that.getOwningSpan(element, null, true);
  18567. var targetElements = that.getOwningSpan(target, position, true);
  18568. fluid.permuteDom(element, target, position, sourceElements, targetElements)
  18569. };
  18570. return that
  18571. };
  18572. fluid.dropManager.NO_CHANGE = "no change";
  18573. fluid.dropManager.cacheKey = function (element) {
  18574. return fluid.allocateSimpleId(element)
  18575. };
  18576. fluid.dropManager.sentinelizeElement = function (targets, sides, cacheelem, fc, disposition, clazz) {
  18577. var elemCopy = $.extend(true, {}, cacheelem);
  18578. elemCopy.rect[sides[fc]] = elemCopy.rect[sides[1 - fc]] + (fc ? 1 : -1);
  18579. elemCopy.rect[sides[1 - fc]] = (fc ? -1 : 1) * SENTINEL_DIMENSION;
  18580. elemCopy.position = disposition === fluid.position.INSIDE ? disposition : (fc ? fluid.position.BEFORE : fluid.position.AFTER);
  18581. elemCopy.clazz = clazz;
  18582. targets[targets.length] = elemCopy
  18583. };
  18584. fluid.dropManager.splitElement = function (targets, sides, cacheelem, disposition, clazz1, clazz2) {
  18585. var elem1 = $.extend(true, {}, cacheelem);
  18586. var elem2 = $.extend(true, {}, cacheelem);
  18587. var midpoint = (elem1.rect[sides[0]] + elem1.rect[sides[1]]) / 2;
  18588. elem1.rect[sides[1]] = midpoint;
  18589. elem1.position = fluid.position.BEFORE;
  18590. elem2.rect[sides[0]] = midpoint;
  18591. elem2.position = fluid.position.AFTER;
  18592. elem1.clazz = clazz1;
  18593. elem2.clazz = clazz2;
  18594. targets[targets.length] = elem1;
  18595. targets[targets.length] = elem2
  18596. };
  18597. fluid.dropManager.getRelativeClass = function (thisElements, index, relative, thisclazz, mapper) {
  18598. index += relative;
  18599. if (index < 0 && thisclazz === "locked") {
  18600. return "locked"
  18601. }
  18602. if (index >= thisElements.length || mapper === null) {
  18603. return null
  18604. } else {
  18605. relative = thisElements[index];
  18606. return mapper(relative) === "locked" && thisclazz === "locked" ? "locked" : null
  18607. }
  18608. };
  18609. fluid.dropManager.getRelativeElement = function (element, direction, elements, disableWrap) {
  18610. var folded = fluid.directionSign(direction);
  18611. var index = $(elements).index(element) + folded;
  18612. if (index < 0) {
  18613. index += elements.length
  18614. }
  18615. if (disableWrap) {
  18616. if (index === elements.length || index === (elements.length + folded)) {
  18617. return element
  18618. }
  18619. }
  18620. index %= elements.length;
  18621. return elements[index]
  18622. };
  18623. fluid.geom = fluid.geom || {};
  18624. fluid.geom.minPointRectangle = function (x, y, rectangle) {
  18625. var dx = x < rectangle.left ? (rectangle.left - x) : (x > rectangle.right ? (x - rectangle.right) : 0);
  18626. var dy = y < rectangle.top ? (rectangle.top - y) : (y > rectangle.bottom ? (y - rectangle.bottom) : 0);
  18627. return dx * dx + dy * dy
  18628. };
  18629. fluid.geom.minRectRect = function (rect1, rect2) {
  18630. var dx = rect1.right < rect2.left ? rect2.left - rect1.right : rect2.right < rect1.left ? rect1.left - rect2.right : 0;
  18631. var dy = rect1.bottom < rect2.top ? rect2.top - rect1.bottom : rect2.bottom < rect1.top ? rect1.top - rect2.bottom : 0;
  18632. return dx * dx + dy * dy
  18633. };
  18634. var makePenCollect = function () {
  18635. return {
  18636. mindist : Number.MAX_VALUE,
  18637. minrdist : Number.MAX_VALUE
  18638. }
  18639. };
  18640. fluid.geom.projectFrom = function (baserect, direction, targets, forSelection, disableWrap) {
  18641. var axis = fluid.directionAxis(direction);
  18642. var frontSide = fluid.rectSides[direction];
  18643. var backSide = fluid.rectSides[axis * 15 + 5 - direction];
  18644. var dirSign = fluid.directionSign(direction);
  18645. var penrect = {
  18646. left : (7 * baserect.left + 1 * baserect.right) / 8,
  18647. right : (5 * baserect.left + 3 * baserect.right) / 8,
  18648. top : (7 * baserect.top + 1 * baserect.bottom) / 8,
  18649. bottom : (5 * baserect.top + 3 * baserect.bottom) / 8
  18650. };
  18651. penrect[frontSide] = dirSign * SENTINEL_DIMENSION;
  18652. penrect[backSide] = -penrect[frontSide];
  18653. function accPen(collect, cacheelem, backSign) {
  18654. var thisrect = cacheelem.rect;
  18655. var pdist = fluid.geom.minRectRect(penrect, thisrect);
  18656. var rdist = -dirSign * backSign * (baserect[backSign === 1 ? frontSide : backSide] - thisrect[backSign === 1 ? backSide : frontSide]);
  18657. if (pdist <= collect.mindist && rdist >= 0) {
  18658. if (pdist === collect.mindist && rdist * backSign > collect.minrdist) {
  18659. return
  18660. }
  18661. collect.minrdist = rdist * backSign;
  18662. collect.mindist = pdist;
  18663. collect.minelem = cacheelem
  18664. }
  18665. }
  18666. var collect = makePenCollect();
  18667. var backcollect = makePenCollect();
  18668. var lockedcollect = makePenCollect();
  18669. for (var i = 0; i < targets.length; ++i) {
  18670. var elem = targets[i];
  18671. var isPure = elem.owner && elem.element === elem.owner.parentElement;
  18672. if (elem.clazz === "hidden" || (forSelection && isPure)) {
  18673. continue
  18674. } else {
  18675. if (!forSelection && elem.clazz === "locked") {
  18676. accPen(lockedcollect, elem, 1)
  18677. } else {
  18678. accPen(collect, elem, 1);
  18679. accPen(backcollect, elem, -1)
  18680. }
  18681. }
  18682. }
  18683. var wrap = !collect.minelem || backcollect.mindist < collect.mindist;
  18684. wrap = wrap && !disableWrap;
  18685. var mincollect = wrap ? backcollect : collect;
  18686. var togo = {
  18687. wrapped : wrap,
  18688. cacheelem : mincollect.minelem
  18689. };
  18690. if (lockedcollect.mindist < mincollect.mindist) {
  18691. togo.lockedelem = lockedcollect.minelem
  18692. }
  18693. return togo
  18694. }
  18695. })(jQuery, fluid_1_4);
  18696. var fluid_1_4 = fluid_1_4 || {};
  18697. (function ($, fluid) {
  18698. var defaultAvatarCreator = function (item, cssClass, dropWarning) {
  18699. fluid.dom.cleanseScripts(fluid.unwrap(item));
  18700. var avatar = $(item).clone();
  18701. fluid.dom.iterateDom(avatar.get(0), function (node) {
  18702. node.removeAttribute("id");
  18703. if (node.tagName.toLowerCase() === "input") {
  18704. node.setAttribute("disabled", "disabled")
  18705. }
  18706. });
  18707. avatar.removeProp("id");
  18708. avatar.removeClass("ui-droppable");
  18709. avatar.addClass(cssClass);
  18710. if (dropWarning) {
  18711. var avatarContainer = $(document.createElement("div"));
  18712. avatarContainer.append(avatar);
  18713. avatarContainer.append(dropWarning);
  18714. avatar = avatarContainer
  18715. }
  18716. $("body").append(avatar);
  18717. if (!$.browser.safari) {
  18718. avatar.css("display", "block").width(item.offsetWidth).height(item.offsetHeight)
  18719. }
  18720. if ($.browser.opera) {
  18721. avatar.hide()
  18722. }
  18723. return avatar
  18724. };
  18725. function bindHandlersToContainer(container, keyDownHandler, keyUpHandler, mouseMoveHandler) {
  18726. var actualKeyDown = keyDownHandler;
  18727. var advancedPrevention = false;
  18728. if ($.browser.opera) {
  18729. container.keypress(function (evt) {
  18730. if (advancedPrevention) {
  18731. advancedPrevention = false;
  18732. evt.preventDefault();
  18733. return false
  18734. }
  18735. });
  18736. actualKeyDown = function (evt) {
  18737. var oldret = keyDownHandler(evt);
  18738. if (oldret === false) {
  18739. advancedPrevention = true
  18740. }
  18741. }
  18742. }
  18743. container.keydown(actualKeyDown);
  18744. container.keyup(keyUpHandler)
  18745. }
  18746. function addRolesToContainer(that) {
  18747. that.container.attr("role", that.options.containerRole.container);
  18748. that.container.attr("aria-multiselectable", "false");
  18749. that.container.attr("aria-readonly", "false");
  18750. that.container.attr("aria-disabled", "false")
  18751. }
  18752. function createAvatarId(parentId) {
  18753. return parentId + "_avatar"
  18754. }
  18755. var adaptKeysets = function (options) {
  18756. if (options.keysets && !(options.keysets instanceof Array)) {
  18757. options.keysets = [options.keysets]
  18758. }
  18759. };
  18760. fluid.reorderer = function (container, options) {
  18761. if (!container) {
  18762. fluid.fail("Reorderer initialised with no container")
  18763. }
  18764. var thatReorderer = fluid.initView("fluid.reorderer", container, options);
  18765. options = thatReorderer.options;
  18766. var dropManager = fluid.dropManager();
  18767. thatReorderer.layoutHandler = fluid.initSubcomponent(thatReorderer, "layoutHandler", [thatReorderer.container, options, dropManager, thatReorderer.dom]);
  18768. thatReorderer.activeItem = undefined;
  18769. adaptKeysets(options);
  18770. var kbDropWarning = thatReorderer.locate("dropWarning");
  18771. var mouseDropWarning;
  18772. if (kbDropWarning) {
  18773. mouseDropWarning = kbDropWarning.clone()
  18774. }
  18775. var isMove = function (evt) {
  18776. var keysets = options.keysets;
  18777. for (var i = 0; i < keysets.length; i++) {
  18778. if (keysets[i].modifier(evt)) {
  18779. return true
  18780. }
  18781. }
  18782. return false
  18783. };
  18784. var isActiveItemMovable = function () {
  18785. return $.inArray(thatReorderer.activeItem, thatReorderer.dom.fastLocate("movables")) >= 0
  18786. };
  18787. var setDropEffects = function (value) {
  18788. thatReorderer.dom.fastLocate("dropTargets").attr("aria-dropeffect", value)
  18789. };
  18790. var styles = options.styles;
  18791. var noModifier = function (evt) {
  18792. return (!evt.ctrlKey && !evt.altKey && !evt.shiftKey && !evt.metaKey)
  18793. };
  18794. var handleDirectionKeyDown = function (evt) {
  18795. var item = thatReorderer.activeItem;
  18796. if (!item) {
  18797. return true
  18798. }
  18799. var keysets = options.keysets;
  18800. for (var i = 0; i < keysets.length; i++) {
  18801. var keyset = keysets[i];
  18802. var keydir = fluid.keyForValue(keyset, evt.keyCode);
  18803. if (!keydir) {
  18804. continue
  18805. }
  18806. var isMovement = keyset.modifier(evt);
  18807. var dirnum = fluid.keycodeDirection[keydir];
  18808. var relativeItem = thatReorderer.layoutHandler.getRelativePosition(item, dirnum, !isMovement);
  18809. if (!relativeItem) {
  18810. continue
  18811. }
  18812. if (isMovement) {
  18813. var prevent = thatReorderer.events.onBeginMove.fire(item);
  18814. if (prevent === false) {
  18815. return false
  18816. }
  18817. if (kbDropWarning.length > 0) {
  18818. if (relativeItem.clazz === "locked") {
  18819. thatReorderer.events.onShowKeyboardDropWarning.fire(item, kbDropWarning);
  18820. kbDropWarning.show()
  18821. } else {
  18822. kbDropWarning.hide()
  18823. }
  18824. }
  18825. if (relativeItem.element) {
  18826. thatReorderer.requestMovement(relativeItem, item)
  18827. }
  18828. } else {
  18829. if (noModifier(evt)) {
  18830. item.blur();
  18831. $(relativeItem.element).focus()
  18832. }
  18833. }
  18834. return false
  18835. }
  18836. return true
  18837. };
  18838. thatReorderer.handleKeyDown = function (evt) {
  18839. if (!thatReorderer.activeItem || thatReorderer.activeItem !== evt.target) {
  18840. return true
  18841. }
  18842. var jActiveItem = $(thatReorderer.activeItem);
  18843. if (!jActiveItem.hasClass(styles.dragging) && isMove(evt)) {
  18844. if (isActiveItemMovable()) {
  18845. jActiveItem.removeClass(styles.selected);
  18846. jActiveItem.addClass(styles.dragging);
  18847. jActiveItem.attr("aria-grabbed", "true");
  18848. setDropEffects("move")
  18849. }
  18850. return false
  18851. }
  18852. return handleDirectionKeyDown(evt)
  18853. };
  18854. thatReorderer.handleKeyUp = function (evt) {
  18855. if (!thatReorderer.activeItem || thatReorderer.activeItem !== evt.target) {
  18856. return true
  18857. }
  18858. var jActiveItem = $(thatReorderer.activeItem);
  18859. if (jActiveItem.hasClass(styles.dragging) && !isMove(evt)) {
  18860. if (kbDropWarning) {
  18861. kbDropWarning.hide()
  18862. }
  18863. jActiveItem.removeClass(styles.dragging);
  18864. jActiveItem.addClass(styles.selected);
  18865. jActiveItem.attr("aria-grabbed", "false");
  18866. setDropEffects("none");
  18867. return false
  18868. }
  18869. return false
  18870. };
  18871. var dropMarker;
  18872. var createDropMarker = function (tagName) {
  18873. var dropMarker = $(document.createElement(tagName));
  18874. dropMarker.addClass(options.styles.dropMarker);
  18875. dropMarker.hide();
  18876. return dropMarker
  18877. };
  18878. thatReorderer.requestMovement = function (requestedPosition, item) {
  18879. item = fluid.unwrap(item);
  18880. if (!requestedPosition || fluid.unwrap(requestedPosition.element) === item) {
  18881. return
  18882. }
  18883. var activeItem = $(thatReorderer.activeItem);
  18884. activeItem.unbind("blur.fluid.reorderer");
  18885. var prevent = thatReorderer.events.onMove.fire(item, requestedPosition);
  18886. if (prevent === false) {
  18887. return false
  18888. }
  18889. dropManager.geometricMove(item, requestedPosition.element, requestedPosition.position);
  18890. activeItem.focus();
  18891. thatReorderer.refresh();
  18892. dropManager.updateGeometry(thatReorderer.layoutHandler.getGeometricInfo());
  18893. thatReorderer.events.afterMove.fire(item, requestedPosition, thatReorderer.dom.fastLocate("movables"))
  18894. };
  18895. var hoverStyleHandler = function (item, state) {
  18896. thatReorderer.dom.fastLocate("grabHandle", item)[state ? "addClass" : "removeClass"](styles.hover)
  18897. };
  18898. function initMovable(item) {
  18899. var styles = options.styles;
  18900. item.attr("aria-grabbed", "false");
  18901. item.mouseover(function () {
  18902. thatReorderer.events.onHover.fire(item, true)
  18903. });
  18904. item.mouseout(function () {
  18905. thatReorderer.events.onHover.fire(item, false)
  18906. });
  18907. var avatar;
  18908. thatReorderer.dom.fastLocate("grabHandle", item).draggable({
  18909. refreshPositions : false,
  18910. scroll : true,
  18911. helper : function () {
  18912. var dropWarningEl;
  18913. if (mouseDropWarning) {
  18914. dropWarningEl = mouseDropWarning[0]
  18915. }
  18916. avatar = $(options.avatarCreator(item[0], styles.avatar, dropWarningEl));
  18917. avatar.prop("id", createAvatarId(thatReorderer.container.id));
  18918. return avatar
  18919. },
  18920. start : function (e, ui) {
  18921. var prevent = thatReorderer.events.onBeginMove.fire(item);
  18922. if (prevent === false) {
  18923. return false
  18924. }
  18925. var handle = thatReorderer.dom.fastLocate("grabHandle", item)[0];
  18926. var handlePos = fluid.dom.computeAbsolutePosition(handle);
  18927. var handleWidth = handle.offsetWidth;
  18928. var handleHeight = handle.offsetHeight;
  18929. item.focus();
  18930. item.removeClass(options.styles.selected);
  18931. item.addClass(options.styles.mouseDrag);
  18932. item.attr("aria-grabbed", "true");
  18933. setDropEffects("move");
  18934. dropManager.startDrag(e, handlePos, handleWidth, handleHeight);
  18935. avatar.show()
  18936. },
  18937. stop : function (e, ui) {
  18938. item.removeClass(options.styles.mouseDrag);
  18939. item.addClass(options.styles.selected);
  18940. $(thatReorderer.activeItem).attr("aria-grabbed", "false");
  18941. var markerNode = fluid.unwrap(dropMarker);
  18942. if (markerNode.parentNode) {
  18943. markerNode.parentNode.removeChild(markerNode)
  18944. }
  18945. avatar.hide();
  18946. ui.helper = null;
  18947. setDropEffects("none");
  18948. dropManager.endDrag();
  18949. thatReorderer.requestMovement(dropManager.lastPosition(), item);
  18950. thatReorderer.activeItem.focus()
  18951. },
  18952. handle : thatReorderer.dom.fastLocate("grabHandle", item)
  18953. })
  18954. }
  18955. function changeSelectedToDefault(jItem, styles) {
  18956. jItem.removeClass(styles.selected);
  18957. jItem.removeClass(styles.dragging);
  18958. jItem.addClass(styles.defaultStyle);
  18959. jItem.attr("aria-selected", "false")
  18960. }
  18961. var selectItem = function (anItem) {
  18962. thatReorderer.events.onSelect.fire(anItem);
  18963. var styles = options.styles;
  18964. if (thatReorderer.activeItem && thatReorderer.activeItem !== anItem) {
  18965. changeSelectedToDefault($(thatReorderer.activeItem), styles)
  18966. }
  18967. thatReorderer.activeItem = anItem;
  18968. var jItem = $(anItem);
  18969. jItem.removeClass(styles.defaultStyle);
  18970. jItem.addClass(styles.selected);
  18971. jItem.attr("aria-selected", "true")
  18972. };
  18973. var initSelectables = function () {
  18974. var handleBlur = function (evt) {
  18975. changeSelectedToDefault($(this), options.styles);
  18976. return evt.stopPropagation()
  18977. };
  18978. var handleFocus = function (evt) {
  18979. selectItem(this);
  18980. return evt.stopPropagation()
  18981. };
  18982. var selectables = thatReorderer.dom.fastLocate("selectables");
  18983. for (var i = 0; i < selectables.length; ++i) {
  18984. var selectable = $(selectables[i]);
  18985. if (!$.data(selectable[0], "fluid.reorderer.selectable-initialised")) {
  18986. selectable.addClass(styles.defaultStyle);
  18987. selectable.bind("blur.fluid.reorderer", handleBlur);
  18988. selectable.focus(handleFocus);
  18989. selectable.click(function (evt) {
  18990. var handle = fluid.unwrap(thatReorderer.dom.fastLocate("grabHandle", this));
  18991. if (fluid.dom.isContainer(handle, evt.target)) {
  18992. $(this).focus()
  18993. }
  18994. });
  18995. selectable.attr("role", options.containerRole.item);
  18996. selectable.attr("aria-selected", "false");
  18997. selectable.attr("aria-disabled", "false");
  18998. $.data(selectable[0], "fluid.reorderer.selectable-initialised", true)
  18999. }
  19000. }
  19001. if (!thatReorderer.selectableContext) {
  19002. thatReorderer.selectableContext = fluid.selectable(thatReorderer.container, {
  19003. selectableElements : selectables,
  19004. selectablesTabindex : thatReorderer.options.selectablesTabindex,
  19005. direction : null
  19006. })
  19007. }
  19008. };
  19009. var dropChangeListener = function (dropTarget) {
  19010. fluid.moveDom(dropMarker, dropTarget.element, dropTarget.position);
  19011. dropMarker.css("display", "");
  19012. if (mouseDropWarning) {
  19013. if (dropTarget.lockedelem) {
  19014. mouseDropWarning.show()
  19015. } else {
  19016. mouseDropWarning.hide()
  19017. }
  19018. }
  19019. };
  19020. var initItems = function () {
  19021. var movables = thatReorderer.dom.fastLocate("movables");
  19022. var dropTargets = thatReorderer.dom.fastLocate("dropTargets");
  19023. initSelectables();
  19024. for (var i = 0; i < movables.length; i++) {
  19025. var item = movables[i];
  19026. if (!$.data(item, "fluid.reorderer.movable-initialised")) {
  19027. initMovable($(item));
  19028. $.data(item, "fluid.reorderer.movable-initialised", true)
  19029. }
  19030. }
  19031. if (movables.length > 0 && !dropMarker) {
  19032. dropMarker = createDropMarker(movables[0].tagName)
  19033. }
  19034. dropManager.updateGeometry(thatReorderer.layoutHandler.getGeometricInfo());
  19035. dropManager.dropChangeFirer.addListener(dropChangeListener, "fluid.Reorderer");
  19036. dropTargets.attr("aria-dropeffect", "none")
  19037. };
  19038. if (thatReorderer.container) {
  19039. bindHandlersToContainer(thatReorderer.container, thatReorderer.handleKeyDown, thatReorderer.handleKeyUp);
  19040. addRolesToContainer(thatReorderer);
  19041. fluid.tabbable(thatReorderer.container);
  19042. initItems()
  19043. }
  19044. if (options.afterMoveCallbackUrl) {
  19045. thatReorderer.events.afterMove.addListener(function () {
  19046. var layoutHandler = thatReorderer.layoutHandler;
  19047. var model = layoutHandler.getModel ? layoutHandler.getModel() : options.acquireModel(thatReorderer);
  19048. $.post(options.afterMoveCallbackUrl, JSON.stringify(model))
  19049. }, "postModel")
  19050. }
  19051. thatReorderer.events.onHover.addListener(hoverStyleHandler, "style");
  19052. thatReorderer.refresh = function () {
  19053. thatReorderer.dom.refresh("movables");
  19054. thatReorderer.dom.refresh("selectables");
  19055. thatReorderer.dom.refresh("grabHandle", thatReorderer.dom.fastLocate("movables"));
  19056. thatReorderer.dom.refresh("stylisticOffset", thatReorderer.dom.fastLocate("movables"));
  19057. thatReorderer.dom.refresh("dropTargets");
  19058. thatReorderer.events.onRefresh.fire();
  19059. initItems();
  19060. thatReorderer.selectableContext.selectables = thatReorderer.dom.fastLocate("selectables");
  19061. thatReorderer.selectableContext.selectablesUpdated(thatReorderer.activeItem)
  19062. };
  19063. fluid.initDependents(thatReorderer);
  19064. thatReorderer.refresh();
  19065. return thatReorderer
  19066. };
  19067. fluid.reorderer.keys = {
  19068. TAB : 9,
  19069. ENTER : 13,
  19070. SHIFT : 16,
  19071. CTRL : 17,
  19072. ALT : 18,
  19073. META : 19,
  19074. SPACE : 32,
  19075. LEFT : 37,
  19076. UP : 38,
  19077. RIGHT : 39,
  19078. DOWN : 40,
  19079. i : 73,
  19080. j : 74,
  19081. k : 75,
  19082. m : 77
  19083. };
  19084. fluid.reorderer.defaultKeysets = [{
  19085. modifier : function (evt) {
  19086. return evt.ctrlKey
  19087. },
  19088. up : fluid.reorderer.keys.UP,
  19089. down : fluid.reorderer.keys.DOWN,
  19090. right : fluid.reorderer.keys.RIGHT,
  19091. left : fluid.reorderer.keys.LEFT
  19092. }, {
  19093. modifier : function (evt) {
  19094. return evt.ctrlKey
  19095. },
  19096. up : fluid.reorderer.keys.i,
  19097. down : fluid.reorderer.keys.m,
  19098. right : fluid.reorderer.keys.k,
  19099. left : fluid.reorderer.keys.j
  19100. }
  19101. ];
  19102. fluid.reorderer.roles = {
  19103. GRID : {
  19104. container : "grid",
  19105. item : "gridcell"
  19106. },
  19107. LIST : {
  19108. container : "list",
  19109. item : "listitem"
  19110. },
  19111. REGIONS : {
  19112. container : "main",
  19113. item : "article"
  19114. }
  19115. };
  19116. var simpleInit = function (container, layoutHandler, options) {
  19117. options = options || {};
  19118. options.layoutHandler = layoutHandler;
  19119. return fluid.reorderer(container, options)
  19120. };
  19121. fluid.reorderList = function (container, options) {
  19122. return simpleInit(container, "fluid.listLayoutHandler", options)
  19123. };
  19124. fluid.reorderGrid = function (container, options) {
  19125. return simpleInit(container, "fluid.gridLayoutHandler", options)
  19126. };
  19127. fluid.reorderer.SHUFFLE_GEOMETRIC_STRATEGY = "shuffleProjectFrom";
  19128. fluid.reorderer.GEOMETRIC_STRATEGY = "projectFrom";
  19129. fluid.reorderer.LOGICAL_STRATEGY = "logicalFrom";
  19130. fluid.reorderer.WRAP_LOCKED_STRATEGY = "lockedWrapFrom";
  19131. fluid.reorderer.NO_STRATEGY = null;
  19132. fluid.reorderer.relativeInfoGetter = function (orientation, coStrategy, contraStrategy, dropManager, dom, disableWrap) {
  19133. return function (item, direction, forSelection) {
  19134. var dirorient = fluid.directionOrientation(direction);
  19135. var strategy = dirorient === orientation ? coStrategy : contraStrategy;
  19136. return strategy !== null ? dropManager[strategy](item, direction, forSelection, disableWrap) : null
  19137. }
  19138. };
  19139. fluid.defaults("fluid.reorderer", {
  19140. styles : {
  19141. defaultStyle : "fl-reorderer-movable-default",
  19142. selected : "fl-reorderer-movable-selected",
  19143. dragging : "fl-reorderer-movable-dragging",
  19144. mouseDrag : "fl-reorderer-movable-dragging",
  19145. hover : "fl-reorderer-movable-hover",
  19146. dropMarker : "fl-reorderer-dropMarker",
  19147. avatar : "fl-reorderer-avatar"
  19148. },
  19149. selectors : {
  19150. dropWarning : ".flc-reorderer-dropWarning",
  19151. movables : ".flc-reorderer-movable",
  19152. grabHandle : "",
  19153. stylisticOffset : ""
  19154. },
  19155. avatarCreator : defaultAvatarCreator,
  19156. keysets : fluid.reorderer.defaultKeysets,
  19157. layoutHandler : {
  19158. type : "fluid.listLayoutHandler"
  19159. },
  19160. events : {
  19161. onShowKeyboardDropWarning : null,
  19162. onSelect : null,
  19163. onBeginMove : "preventable",
  19164. onMove : "preventable",
  19165. afterMove : null,
  19166. onHover : null,
  19167. onRefresh : null
  19168. },
  19169. mergePolicy : {
  19170. keysets : "replace",
  19171. "selectors.labelSource" : "selectors.grabHandle",
  19172. "selectors.selectables" : "selectors.movables",
  19173. "selectors.dropTargets" : "selectors.movables"
  19174. },
  19175. components : {
  19176. labeller : {
  19177. type : "fluid.reorderer.labeller",
  19178. options : {
  19179. dom : "{reorderer}.dom",
  19180. getGeometricInfo : "{reorderer}.layoutHandler.getGeometricInfo",
  19181. orientation : "{reorderer}.options.orientation",
  19182. layoutType : "{reorderer}.options.layoutHandler"
  19183. }
  19184. }
  19185. },
  19186. disableWrap : false
  19187. });
  19188. fluid.reorderer.makeGeometricInfoGetter = function (orientation, sentinelize, dom) {
  19189. return function () {
  19190. var that = {
  19191. sentinelize : sentinelize,
  19192. extents : [{
  19193. orientation : orientation,
  19194. elements : dom.fastLocate("dropTargets")
  19195. }
  19196. ],
  19197. elementMapper : function (element) {
  19198. return $.inArray(element, dom.fastLocate("movables")) === -1 ? "locked" : null
  19199. },
  19200. elementIndexer : function (element) {
  19201. var selectables = dom.fastLocate("selectables");
  19202. return {
  19203. elementClass : that.elementMapper(element),
  19204. index : $.inArray(element, selectables),
  19205. length : selectables.length
  19206. }
  19207. }
  19208. };
  19209. return that
  19210. }
  19211. };
  19212. fluid.defaults(true, "fluid.listLayoutHandler", {
  19213. orientation : fluid.orientation.VERTICAL,
  19214. containerRole : fluid.reorderer.roles.LIST,
  19215. selectablesTabindex : -1,
  19216. sentinelize : true
  19217. });
  19218. fluid.listLayoutHandler = function (container, options, dropManager, dom) {
  19219. var that = {};
  19220. that.getRelativePosition = fluid.reorderer.relativeInfoGetter(options.orientation, fluid.reorderer.LOGICAL_STRATEGY, null, dropManager, dom, options.disableWrap);
  19221. that.getGeometricInfo = fluid.reorderer.makeGeometricInfoGetter(options.orientation, options.sentinelize, dom);
  19222. return that
  19223. };
  19224. fluid.defaults(true, "fluid.gridLayoutHandler", {
  19225. orientation : fluid.orientation.HORIZONTAL,
  19226. containerRole : fluid.reorderer.roles.GRID,
  19227. selectablesTabindex : -1,
  19228. sentinelize : false
  19229. });
  19230. fluid.gridLayoutHandler = function (container, options, dropManager, dom) {
  19231. var that = {};
  19232. that.getRelativePosition = fluid.reorderer.relativeInfoGetter(options.orientation, options.disableWrap ? fluid.reorderer.SHUFFLE_GEOMETRIC_STRATEGY : fluid.reorderer.LOGICAL_STRATEGY, fluid.reorderer.SHUFFLE_GEOMETRIC_STRATEGY, dropManager, dom, options.disableWrap);
  19233. that.getGeometricInfo = fluid.reorderer.makeGeometricInfoGetter(options.orientation, options.sentinelize, dom);
  19234. return that
  19235. };
  19236. fluid.defaults("fluid.reorderer.labeller", {
  19237. strings : {
  19238. overallTemplate : "%recentStatus %item %position %movable",
  19239. position : "%index of %length",
  19240. position_moduleLayoutHandler : "%index of %length in %moduleCell %moduleIndex of %moduleLength",
  19241. moduleCell_0 : "row",
  19242. moduleCell_1 : "column",
  19243. movable : "movable",
  19244. fixed : "fixed",
  19245. recentStatus : "moved from position %position"
  19246. },
  19247. components : {
  19248. resolver : {
  19249. type : "fluid.messageResolver",
  19250. options : {
  19251. messageBase : "{labeller}.options.strings"
  19252. }
  19253. }
  19254. },
  19255. invokers : {
  19256. renderLabel : {
  19257. funcName : "fluid.reorderer.labeller.renderLabel",
  19258. args : ["{labeller}", "@0", "@1"]
  19259. }
  19260. }
  19261. });
  19262. fluid.reorderer.indexRebaser = function (indices) {
  19263. indices.index++;
  19264. if (indices.moduleIndex !== undefined) {
  19265. indices.moduleIndex++
  19266. }
  19267. return indices
  19268. };
  19269. fluid.reorderer.labeller = function (options) {
  19270. var that = fluid.initLittleComponent("fluid.reorderer.labeller", options);
  19271. fluid.initDependents(that);
  19272. that.dom = that.options.dom;
  19273. that.moduleCell = that.resolver.resolve("moduleCell_" + that.options.orientation);
  19274. var layoutType = fluid.computeNickName(that.options.layoutType);
  19275. that.positionTemplate = that.resolver.lookup(["position_" + layoutType, "position"]);
  19276. var movedMap = {};
  19277. that.returnedOptions = {
  19278. listeners : {
  19279. onRefresh : function () {
  19280. var selectables = that.dom.locate("selectables");
  19281. fluid.each(selectables, function (selectable) {
  19282. var labelOptions = {};
  19283. var id = fluid.allocateSimpleId(selectable);
  19284. var moved = movedMap[id];
  19285. var label = that.renderLabel(selectable);
  19286. var plainLabel = label;
  19287. if (moved) {
  19288. moved.newRender = plainLabel;
  19289. label = that.renderLabel(selectable, moved.oldRender.position);
  19290. $(selectable).one("focusout", function () {
  19291. if (movedMap[id]) {
  19292. var oldLabel = movedMap[id].newRender.label;
  19293. delete movedMap[id];
  19294. fluid.updateAriaLabel(selectable, oldLabel)
  19295. }
  19296. });
  19297. labelOptions.dynamicLabel = true
  19298. }
  19299. fluid.updateAriaLabel(selectable, label.label, labelOptions)
  19300. })
  19301. },
  19302. onMove : function (item, newPosition) {
  19303. fluid.clear(movedMap);
  19304. var movingId = fluid.allocateSimpleId(item);
  19305. movedMap[movingId] = {
  19306. oldRender : that.renderLabel(item)
  19307. }
  19308. }
  19309. }
  19310. };
  19311. return that
  19312. };
  19313. fluid.reorderer.labeller.renderLabel = function (that, selectable, recentPosition) {
  19314. var geom = that.options.getGeometricInfo();
  19315. var indices = fluid.reorderer.indexRebaser(geom.elementIndexer(selectable));
  19316. indices.moduleCell = that.moduleCell;
  19317. var elementClass = geom.elementMapper(selectable);
  19318. var labelSource = that.dom.locate("labelSource", selectable);
  19319. var recentStatus;
  19320. if (recentPosition) {
  19321. recentStatus = that.resolver.resolve("recentStatus", {
  19322. position : recentPosition
  19323. })
  19324. }
  19325. var topModel = {
  19326. item : typeof(labelSource) === "string" ? labelSource : fluid.dom.getElementText(fluid.unwrap(labelSource)),
  19327. position : that.positionTemplate.resolveFunc(that.positionTemplate.template, indices),
  19328. movable : that.resolver.resolve(elementClass === "locked" ? "fixed" : "movable"),
  19329. recentStatus : recentStatus || ""
  19330. };
  19331. var template = that.resolver.lookup(["overallTemplate"]);
  19332. var label = template.resolveFunc(template.template, topModel);
  19333. return {
  19334. position : topModel.position,
  19335. label : label
  19336. }
  19337. }
  19338. })(jQuery, fluid_1_4);
  19339. var fluid_1_4 = fluid_1_4 || {};
  19340. (function ($, fluid) {
  19341. var deriveLightboxCellBase = function (namebase, index) {
  19342. return namebase + "lightbox-cell:" + index + ":"
  19343. };
  19344. var addThumbnailActivateHandler = function (container) {
  19345. var enterKeyHandler = function (evt) {
  19346. if (evt.which === fluid.reorderer.keys.ENTER) {
  19347. var thumbnailAnchors = $("a", evt.target);
  19348. document.location = thumbnailAnchors.attr("href")
  19349. }
  19350. };
  19351. container.keypress(enterKeyHandler)
  19352. };
  19353. var seekNodesById = function (rootnode, tagname, idmatch) {
  19354. var inputs = rootnode.getElementsByTagName(tagname);
  19355. var togo = [];
  19356. for (var i = 0; i < inputs.length; i += 1) {
  19357. var input = inputs[i];
  19358. var id = input.id;
  19359. if (id && id.match(idmatch)) {
  19360. togo.push(input)
  19361. }
  19362. }
  19363. return togo
  19364. };
  19365. var createImageCellFinder = function (parentNode, containerId) {
  19366. parentNode = fluid.unwrap(parentNode);
  19367. var lightboxCellNamePattern = "^" + deriveLightboxCellBase(containerId, "[0-9]+") + "$";
  19368. return function () {
  19369. return seekNodesById(parentNode, "div", lightboxCellNamePattern)
  19370. }
  19371. };
  19372. var seekForm = function (container) {
  19373. return fluid.findAncestor(container, function (element) {
  19374. return $(element).is("form")
  19375. })
  19376. };
  19377. var seekInputs = function (container, reorderform) {
  19378. return seekNodesById(reorderform, "input", "^" + deriveLightboxCellBase(container.prop("id"), "[^:]*") + "reorder-index$")
  19379. };
  19380. var mapIdsToNames = function (container, reorderform) {
  19381. var inputs = seekInputs(container, reorderform);
  19382. for (var i = 0; i < inputs.length; i++) {
  19383. var input = inputs[i];
  19384. var name = input.name;
  19385. input.name = name || input.id
  19386. }
  19387. };
  19388. var createIDAfterMoveListener = function (container) {
  19389. var reorderform = seekForm(container);
  19390. mapIdsToNames(container, reorderform);
  19391. return function () {
  19392. var inputs,
  19393. i;
  19394. inputs = seekInputs(container, reorderform);
  19395. for (i = 0; i < inputs.length; i += 1) {
  19396. inputs[i].value = i
  19397. }
  19398. if (reorderform && reorderform.action) {
  19399. var order = $(reorderform).serialize();
  19400. $.post(reorderform.action, order, function (type, data, evt) {})
  19401. }
  19402. }
  19403. };
  19404. var setDefaultValue = function (target, path, value) {
  19405. var previousValue = fluid.get(target, path);
  19406. var valueToSet = previousValue || value;
  19407. fluid.set(target, path, valueToSet)
  19408. };
  19409. fluid.reorderImages = function (container, options) {
  19410. var defaults = fluid.defaults("fluid.reorderImages");
  19411. var mergedOptions = fluid.merge(defaults.mergePolicy, {}, defaults, options);
  19412. container = fluid.container(container);
  19413. setDefaultValue(mergedOptions, "listeners.afterMove", mergedOptions.afterMoveCallback || createIDAfterMoveListener(container));
  19414. setDefaultValue(mergedOptions, "selectors.movables", createImageCellFinder(container, container.prop("id")));
  19415. var reorderer = fluid.reorderer(container, mergedOptions);
  19416. fluid.tabindex($("a", container), -1);
  19417. addThumbnailActivateHandler(container);
  19418. return reorderer
  19419. };
  19420. fluid.lightbox = fluid.reorderImages;
  19421. fluid.defaults("fluid.reorderImages", {
  19422. layoutHandler : "fluid.gridLayoutHandler",
  19423. selectors : {
  19424. labelSource : ".flc-reorderer-imageTitle"
  19425. }
  19426. })
  19427. })(jQuery, fluid_1_4);
  19428. var fluid_1_4 = fluid_1_4 || {};
  19429. (function ($, fluid) {
  19430. fluid.registerNamespace("fluid.moduleLayout");
  19431. fluid.moduleLayout.findColumnAndItemIndices = function (item, layout) {
  19432. return fluid.find(layout.columns, function (column, colIndex) {
  19433. var index = $.inArray(item, column.elements);
  19434. return index === -1 ? undefined : {
  19435. columnIndex : colIndex,
  19436. itemIndex : index
  19437. }
  19438. }, {
  19439. columnIndex : -1,
  19440. itemIndex : -1
  19441. })
  19442. };
  19443. fluid.moduleLayout.findColIndex = function (item, layout) {
  19444. return fluid.find(layout.columns, function (column, colIndex) {
  19445. return item === column.container ? colIndex : undefined
  19446. }, -1)
  19447. };
  19448. fluid.moduleLayout.updateLayout = function (item, target, position, layout) {
  19449. item = fluid.unwrap(item);
  19450. target = fluid.unwrap(target);
  19451. var itemIndices = fluid.moduleLayout.findColumnAndItemIndices(item, layout);
  19452. layout.columns[itemIndices.columnIndex].elements.splice(itemIndices.itemIndex, 1);
  19453. var targetCol;
  19454. if (position === fluid.position.INSIDE) {
  19455. targetCol = layout.columns[fluid.moduleLayout.findColIndex(target, layout)].elements;
  19456. targetCol.splice(targetCol.length, 0, item)
  19457. } else {
  19458. var relativeItemIndices = fluid.moduleLayout.findColumnAndItemIndices(target, layout);
  19459. targetCol = layout.columns[relativeItemIndices.columnIndex].elements;
  19460. position = fluid.normalisePosition(position, itemIndices.columnIndex === relativeItemIndices.columnIndex, relativeItemIndices.itemIndex, itemIndices.itemIndex);
  19461. var relative = position === fluid.position.BEFORE ? 0 : 1;
  19462. targetCol.splice(relativeItemIndices.itemIndex + relative, 0, item)
  19463. }
  19464. };
  19465. fluid.moduleLayout.layoutFromFlat = function (container, columns, portlets) {
  19466. var layout = {};
  19467. layout.container = container;
  19468. layout.columns = fluid.transform(columns, function (column) {
  19469. return {
  19470. container : column,
  19471. elements : $.makeArray(portlets.filter(function () {
  19472. return fluid.dom.isContainer(column, this)
  19473. }))
  19474. }
  19475. });
  19476. return layout
  19477. };
  19478. fluid.moduleLayout.layoutFromIds = function (idLayout) {
  19479. return {
  19480. container : fluid.byId(idLayout.id),
  19481. columns : fluid.transform(idLayout.columns, function (column) {
  19482. return {
  19483. container : fluid.byId(column.id),
  19484. elements : fluid.transform(column.children, fluid.byId)
  19485. }
  19486. })
  19487. }
  19488. };
  19489. fluid.moduleLayout.layoutToIds = function (idLayout) {
  19490. return {
  19491. id : fluid.getId(idLayout.container),
  19492. columns : fluid.transform(idLayout.columns, function (column) {
  19493. return {
  19494. id : fluid.getId(column.container),
  19495. children : fluid.transform(column.elements, fluid.getId)
  19496. }
  19497. })
  19498. }
  19499. };
  19500. var defaultOnShowKeyboardDropWarning = function (item, dropWarning) {
  19501. if (dropWarning) {
  19502. var offset = $(item).offset();
  19503. dropWarning = $(dropWarning);
  19504. dropWarning.css("position", "absolute");
  19505. dropWarning.css("top", offset.top);
  19506. dropWarning.css("left", offset.left)
  19507. }
  19508. };
  19509. fluid.defaults(true, "fluid.moduleLayoutHandler", {
  19510. orientation : fluid.orientation.VERTICAL,
  19511. containerRole : fluid.reorderer.roles.REGIONS,
  19512. selectablesTabindex : -1,
  19513. sentinelize : true
  19514. });
  19515. fluid.moduleLayoutHandler = function (container, options, dropManager, dom) {
  19516. var that = {};
  19517. function computeLayout() {
  19518. var togo;
  19519. if (options.selectors.modules) {
  19520. togo = fluid.moduleLayout.layoutFromFlat(container, dom.locate("columns"), dom.locate("modules"))
  19521. }
  19522. if (!togo) {
  19523. var idLayout = fluid.get(options, "moduleLayout.layout");
  19524. fluid.moduleLayout.layoutFromIds(idLayout)
  19525. }
  19526. return togo
  19527. }
  19528. var layout = computeLayout();
  19529. that.layout = layout;
  19530. function isLocked(item) {
  19531. var lockedModules = options.selectors.lockedModules ? dom.fastLocate("lockedModules") : [];
  19532. return $.inArray(item, lockedModules) !== -1
  19533. }
  19534. that.getRelativePosition = fluid.reorderer.relativeInfoGetter(options.orientation, fluid.reorderer.WRAP_LOCKED_STRATEGY, fluid.reorderer.GEOMETRIC_STRATEGY, dropManager, dom, options.disableWrap);
  19535. that.getGeometricInfo = function () {
  19536. var extents = [];
  19537. var togo = {
  19538. extents : extents,
  19539. sentinelize : options.sentinelize
  19540. };
  19541. togo.elementMapper = function (element) {
  19542. return isLocked(element) ? "locked" : null
  19543. };
  19544. togo.elementIndexer = function (element) {
  19545. var indices = fluid.moduleLayout.findColumnAndItemIndices(element, that.layout);
  19546. return {
  19547. index : indices.itemIndex,
  19548. length : layout.columns[indices.columnIndex].elements.length,
  19549. moduleIndex : indices.columnIndex,
  19550. moduleLength : layout.columns.length
  19551. }
  19552. };
  19553. for (var col = 0; col < layout.columns.length; col++) {
  19554. var column = layout.columns[col];
  19555. var thisEls = {
  19556. orientation : options.orientation,
  19557. elements : $.makeArray(column.elements),
  19558. parentElement : column.container
  19559. };
  19560. extents.push(thisEls)
  19561. }
  19562. return togo
  19563. };
  19564. function computeModules(all) {
  19565. return function () {
  19566. var modules = fluid.accumulate(layout.columns, function (column, list) {
  19567. return list.concat(column.elements)
  19568. }, []);
  19569. if (!all) {
  19570. fluid.remove_if(modules, isLocked)
  19571. }
  19572. return modules
  19573. }
  19574. }
  19575. that.returnedOptions = {
  19576. selectors : {
  19577. movables : computeModules(false),
  19578. dropTargets : computeModules(false),
  19579. selectables : computeModules(true)
  19580. },
  19581. listeners : {
  19582. onMove : {
  19583. priority : "last",
  19584. listener : function (item, requestedPosition) {
  19585. fluid.moduleLayout.updateLayout(item, requestedPosition.element, requestedPosition.position, layout)
  19586. }
  19587. },
  19588. onRefresh : function () {
  19589. layout = computeLayout();
  19590. that.layout = layout
  19591. },
  19592. "onShowKeyboardDropWarning.setPosition" : defaultOnShowKeyboardDropWarning
  19593. }
  19594. };
  19595. that.getModel = function () {
  19596. return fluid.moduleLayout.layoutToIds(layout)
  19597. };
  19598. return that
  19599. }
  19600. })(jQuery, fluid_1_4);
  19601. var fluid_1_4 = fluid_1_4 || {};
  19602. (function ($, fluid) {
  19603. fluid.reorderLayout = function (container, userOptions) {
  19604. var assembleOptions = {
  19605. layoutHandler : "fluid.moduleLayoutHandler",
  19606. selectors : {
  19607. columns : ".flc-reorderer-column",
  19608. modules : ".flc-reorderer-module"
  19609. }
  19610. };
  19611. var options = $.extend(true, assembleOptions, userOptions);
  19612. return fluid.reorderer(container, options)
  19613. }
  19614. })(jQuery, fluid_1_4);
  19615. /*
  19616. * jQuery UI AriaTabs (12.07.10)
  19617. * http://github.com/fnagel/jQuery-Accessible-RIA
  19618. *
  19619. * Copyright (c) 2009 Felix Nagel for Namics (Deustchland) GmbH
  19620. * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
  19621. *
  19622. * Depends: ui.core.js 1.8
  19623. * ui.tabs.js
  19624. */
  19625. (function ($) {
  19626. $.fn.extend($.ui.tabs.prototype, {
  19627. _create : function () {
  19628. var self = this,
  19629. options = this.options;
  19630. if ($.address) {
  19631. var jqAddressDefOpt = {
  19632. enable : true,
  19633. title : {
  19634. enable : true,
  19635. split : " | "
  19636. }
  19637. };
  19638. if (!$.isEmptyObject(options.jqAddress)) {
  19639. $.extend(true, jqAddressDefOpt, options.jqAddress)
  19640. } else {
  19641. options.jqAddress = {}
  19642. }
  19643. $.extend(true, options.jqAddress, jqAddressDefOpt)
  19644. }
  19645. if ($.address && options.jqAddress.enable) {
  19646. var anchorId = "#" + $.address.value().replace("/", "")
  19647. }
  19648. self._tabify(true);
  19649. this.anchors.bind(options.event + ".tabs-accessibility", function () {
  19650. this.focus()
  19651. });
  19652. self.list.attr("role", "tablist");
  19653. for (var x = 0; x < self.anchors.length; x++) {
  19654. if ($.address && options.jqAddress.enable && anchorId != "#" && $(self.anchors[x]).attr("href") == anchorId) {
  19655. self.select(x)
  19656. }
  19657. self._ariaInit(x)
  19658. }
  19659. self.list.keydown(function (event) {
  19660. switch (event.keyCode) {
  19661. case $.ui.keyCode.RIGHT:
  19662. self.select(options.selected + 1);
  19663. return false;
  19664. break;
  19665. case $.ui.keyCode.DOWN:
  19666. self.select(options.selected + 1);
  19667. break;
  19668. case $.ui.keyCode.UP:
  19669. self.select(options.selected - 1);
  19670. return false;
  19671. break;
  19672. case $.ui.keyCode.LEFT:
  19673. self.select(options.selected - 1);
  19674. return false;
  19675. break;
  19676. case $.ui.keyCode.END:
  19677. self.select(self.anchors.length - 1);
  19678. return false;
  19679. break;
  19680. case $.ui.keyCode.HOME:
  19681. self.select(0);
  19682. return false;
  19683. break
  19684. }
  19685. });
  19686. if ($.address && this.options.jqAddress.enable) {
  19687. $.address.externalChange(function (event) {
  19688. var anchorId = "#" + event.value.replace("/", "");
  19689. var x = 0;
  19690. while (x < self.anchors.length) {
  19691. if ($(self.anchors[x]).attr("href") == anchorId) {
  19692. self.select(x);
  19693. return
  19694. }
  19695. x++
  19696. }
  19697. })
  19698. }
  19699. },
  19700. _original_load : $.ui.tabs.prototype.load,
  19701. load : function (index) {
  19702. if ($.address && this.options.jqAddress.enable) {
  19703. if ($(this.anchors[0]).attr("aria-selected") !== undefined) {
  19704. if (this.options.forceFirst === 0 && index !== 0) {
  19705. if ($.address.value() == "") {
  19706. $.address.history(false)
  19707. }
  19708. $.address.value($(this.anchors[0]).attr("href").replace(/^#/, ""));
  19709. $.address.history(true);
  19710. this.options.forceFirst = false
  19711. }
  19712. if (this.options.jqAddress.title.enable) {
  19713. $.address.title($.address.title().split(this.options.jqAddress.title.split)[0] + this.options.jqAddress.title.split + $(this.anchors[index]).text())
  19714. }
  19715. $.address.value($(this.anchors[index]).attr("href").replace(/^#/, ""))
  19716. } else {
  19717. this.options.forceFirst = index
  19718. }
  19719. }
  19720. for (var x = 0; x < this.anchors.length; x++) {
  19721. this._ariaSet(x, false);
  19722. if ($.data(this.anchors[x], "href.tabs")) {
  19723. $(this.panels[x]).removeAttr("aria-live").removeAttr("aria-busy")
  19724. }
  19725. }
  19726. if ($.data(this.anchors[index], "href.tabs")) {
  19727. $(this.panels[index]).attr("aria-live", "polite").attr("aria-busy", "true")
  19728. }
  19729. this._original_load(index);
  19730. if ($.data(this.anchors[index], "href.tabs")) {
  19731. $(this.panels[index]).attr("aria-busy", "false")
  19732. }
  19733. this._ariaSet(index, true)
  19734. },
  19735. _ariaSet : function (index, state) {
  19736. var tabindex = (state) ? 0 : -1;
  19737. var anchor = $(this.anchors[index]);
  19738. anchor.attr("tabindex", tabindex).attr("aria-selected", state);
  19739. if (state) {
  19740. if (!$.browser.msie) {
  19741. anchor.focus()
  19742. }
  19743. } else {
  19744. anchor.closest("li").removeClass("ui-state-focus")
  19745. }
  19746. $(this.panels[index]).attr("aria-hidden", !state).attr("aria-expanded", state);
  19747. if ($.browser.msie) {
  19748. this.options.timeout = window.setTimeout(function () {
  19749. anchor.focus()
  19750. }, 100)
  19751. }
  19752. if (state) {
  19753. this._updateVirtualBuffer()
  19754. }
  19755. },
  19756. _ariaInit : function (index) {
  19757. var self = this;
  19758. var panelId = $(this.panels[index]).attr("id");
  19759. $(this.anchors[index]).attr("role", "tab").attr("aria-controls", panelId).attr("id", panelId + "-tab").parent().attr("role", "presentation");
  19760. $(this.panels[index]).attr("role", "tabpanel").attr("tabindex", 0).attr("aria-labelledby", panelId + "-tab");
  19761. if (this.options.collapsible) {
  19762. $(this.anchors[index]).bind(this.options.event, function (event) {
  19763. self._ariaSet(index, !$(self.panels[index]).hasClass("ui-tabs-hide"))
  19764. })
  19765. }
  19766. },
  19767. _original_add : $.ui.tabs.prototype.add,
  19768. add : function (url, label, index) {
  19769. this._original_add(url, label, index);
  19770. this.element.attr("aria-live", "polite").attr("aria-relevant", "additions");
  19771. if (index) {
  19772. this._ariaInit(index);
  19773. this._ariaSet(index, false)
  19774. } else {
  19775. this._ariaInit(this.anchors.length - 1);
  19776. this._ariaSet(this.anchors.length - 1, false)
  19777. }
  19778. },
  19779. _original_remove : $.ui.tabs.prototype.remove,
  19780. remove : function (index) {
  19781. this._original_remove(index);
  19782. this.element.attr("aria-live", "polite").attr("aria-relevant", "removals")
  19783. },
  19784. _original_destroy : $.ui.tabs.prototype.destroy,
  19785. destroy : function () {
  19786. var self = this,
  19787. options = this.options;
  19788. self.element.removeAttr("role").removeAttr("aria-live").removeAttr("aria-relevant");
  19789. self.list.removeAttr("role");
  19790. for (var x = 0; x < self.anchors.length; x++) {
  19791. $(self.anchors[x]).removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("role").removeAttr("id").removeAttr("tabindex").parent().removeAttr("role");
  19792. $(self.panels[x]).removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("aria-labelledby").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-relevant").removeAttr("role")
  19793. }
  19794. $("body>form #virtualBufferForm").parent().remove();
  19795. this._original_destroy()
  19796. },
  19797. _updateVirtualBuffer : function () {
  19798. var form = $("body>form #virtualBufferForm");
  19799. if (form.length) {
  19800. if (form.val() == "1") {
  19801. form.val("0")
  19802. } else {
  19803. form.val("1")
  19804. }
  19805. if (form.hasClass("ui-accessibility-odd")) {
  19806. form.addClass("ui-accessibility-even").removeClass("ui-accessibility-odd")
  19807. } else {
  19808. form.addClass("ui-accessibility-odd").removeClass("ui-accessibility-even")
  19809. }
  19810. } else {
  19811. $("body").append('<form><input id="virtualBufferForm" type="hidden" value="1" /></form>')
  19812. }
  19813. }
  19814. })
  19815. })(jQuery);
  19816. var fluid_1_4 = fluid_1_4 || {};
  19817. (function ($, fluid) {
  19818. fluid.defaults("fluid.tabs", {
  19819. gradeNames : ["fluid.viewComponent", "autoInit"],
  19820. tabOptions : {},
  19821. events : {
  19822. tabsselect : "preventable",
  19823. tabsload : null,
  19824. tabsshow : null
  19825. },
  19826. finalInitFunction : "fluid.tabs.finalInit"
  19827. });
  19828. fluid.tabs.finalInit = function (that) {
  19829. that.container.tabs(that.options.tabOptions);
  19830. fluid.each(that.options.events, function (value, eventName) {
  19831. that.container.bind(eventName, function (event, ui) {
  19832. return that.events[eventName].fire(that, event, ui)
  19833. })
  19834. })
  19835. }
  19836. })(jQuery, fluid_1_4);
  19837. var fluid_1_4 = fluid_1_4 || {};
  19838. (function ($, fluid) {
  19839. fluid.registerNamespace("fluid.tableOfContents");
  19840. fluid.tableOfContents.insertAnchor = function (name, element) {
  19841. var anchor = $("<a></a>", element.ownerDocument);
  19842. anchor.prop({
  19843. name : name,
  19844. id : name
  19845. });
  19846. anchor.insertBefore(element)
  19847. };
  19848. fluid.tableOfContents.generateGUID = function () {
  19849. return fluid.allocateSimpleId()
  19850. };
  19851. fluid.tableOfContents.filterHeadings = function (headings) {
  19852. return headings.filter(":visible")
  19853. };
  19854. fluid.tableOfContents.finalInit = function (that) {
  19855. var headings = that.filterHeadings(that.locate("headings"));
  19856. that.headingTextToAnchor = function (heading) {
  19857. var guid = that.generateGUID();
  19858. var anchorInfo = {
  19859. id : guid,
  19860. url : "#" + guid
  19861. };
  19862. that.insertAnchor(anchorInfo.id, heading);
  19863. return anchorInfo
  19864. };
  19865. that.anchorInfo = fluid.transform(headings, function (heading) {
  19866. return that.headingTextToAnchor(heading)
  19867. });
  19868. that.hide = function () {
  19869. that.locate("tocContainer").hide()
  19870. };
  19871. that.show = function () {
  19872. that.locate("tocContainer").show()
  19873. };
  19874. that.model = that.modelBuilder.assembleModel(headings, that.anchorInfo);
  19875. that.events.onReady.fire()
  19876. };
  19877. fluid.defaults("fluid.tableOfContents", {
  19878. gradeNames : ["fluid.viewComponent", "autoInit"],
  19879. finalInitFunction : "fluid.tableOfContents.finalInit",
  19880. components : {
  19881. levels : {
  19882. type : "fluid.tableOfContents.levels",
  19883. container : "{tableOfContents}.dom.tocContainer",
  19884. createOnEvent : "onReady",
  19885. options : {
  19886. model : {
  19887. headings : "{tableOfContents}.model"
  19888. },
  19889. events : {
  19890. afterRender : "{tableOfContents}.events.afterRender"
  19891. }
  19892. }
  19893. },
  19894. modelBuilder : {
  19895. type : "fluid.tableOfContents.modelBuilder"
  19896. }
  19897. },
  19898. invokers : {
  19899. insertAnchor : "fluid.tableOfContents.insertAnchor",
  19900. generateGUID : "fluid.tableOfContents.generateGUID",
  19901. filterHeadings : "fluid.tableOfContents.filterHeadings"
  19902. },
  19903. selectors : {
  19904. headings : ":header",
  19905. tocContainer : ".flc-toc-tocContainer"
  19906. },
  19907. events : {
  19908. onReady : null,
  19909. afterRender : null
  19910. }
  19911. });
  19912. fluid.registerNamespace("fluid.tableOfContents.modelBuilder");
  19913. fluid.tableOfContents.modelBuilder.toModel = function (headingInfo, modelLevelFn) {
  19914. var headings = fluid.copy(headingInfo);
  19915. var buildModelLevel = function (headings, level) {
  19916. var modelLevel = [];
  19917. while (headings.length > 0) {
  19918. var heading = headings[0];
  19919. if (heading.level < level) {
  19920. break
  19921. }
  19922. if (heading.level > level) {
  19923. var subHeadings = buildModelLevel(headings, level + 1);
  19924. if (modelLevel.length > 0) {
  19925. modelLevel[modelLevel.length - 1].headings = subHeadings
  19926. } else {
  19927. modelLevel = modelLevelFn(modelLevel, subHeadings)
  19928. }
  19929. }
  19930. if (heading.level === level) {
  19931. modelLevel.push(heading);
  19932. headings.shift()
  19933. }
  19934. }
  19935. return modelLevel
  19936. };
  19937. return buildModelLevel(headings, 1)
  19938. };
  19939. fluid.tableOfContents.modelBuilder.gradualModelLevelFn = function (modelLevel, subHeadings) {
  19940. var subHeadingsClone = fluid.copy(subHeadings);
  19941. subHeadingsClone[0].level--;
  19942. return subHeadingsClone
  19943. };
  19944. fluid.tableOfContents.modelBuilder.skippedModelLevelFn = function (modelLevel, subHeadings) {
  19945. modelLevel.push({
  19946. headings : subHeadings
  19947. });
  19948. return modelLevel
  19949. };
  19950. fluid.tableOfContents.modelBuilder.finalInit = function (that) {
  19951. that.convertToHeadingObjects = function (headings, anchorInfo) {
  19952. headings = $(headings);
  19953. return fluid.transform(headings, function (heading, index) {
  19954. return {
  19955. level : that.headingCalculator.getHeadingLevel(heading),
  19956. text : $(heading).text(),
  19957. url : anchorInfo[index].url
  19958. }
  19959. })
  19960. };
  19961. that.assembleModel = function (headings, anchorInfo) {
  19962. var headingInfo = that.convertToHeadingObjects(headings, anchorInfo);
  19963. return that.toModel(headingInfo)
  19964. }
  19965. };
  19966. fluid.defaults("fluid.tableOfContents.modelBuilder", {
  19967. gradeNames : ["fluid.littleComponent", "autoInit"],
  19968. finalInitFunction : "fluid.tableOfContents.modelBuilder.finalInit",
  19969. components : {
  19970. headingCalculator : {
  19971. type : "fluid.tableOfContents.modelBuilder.headingCalculator"
  19972. }
  19973. },
  19974. invokers : {
  19975. toModel : {
  19976. funcName : "fluid.tableOfContents.modelBuilder.toModel",
  19977. args : ["{arguments}.0", "{modelBuilder}.modelLevelFn"]
  19978. },
  19979. modelLevelFn : "fluid.tableOfContents.modelBuilder.gradualModelLevelFn"
  19980. }
  19981. });
  19982. fluid.registerNamespace("fluid.tableOfContents.modelBuilder.headingCalculator");
  19983. fluid.tableOfContents.modelBuilder.headingCalculator.finalInit = function (that) {
  19984. that.getHeadingLevel = function (heading) {
  19985. return $.inArray(heading.tagName, that.options.levels) + 1
  19986. }
  19987. };
  19988. fluid.defaults("fluid.tableOfContents.modelBuilder.headingCalculator", {
  19989. gradeNames : ["fluid.littleComponent", "autoInit"],
  19990. finalInitFunction : "fluid.tableOfContents.modelBuilder.headingCalculator.finalInit",
  19991. levels : ["H1", "H2", "H3", "H4", "H5", "H6"]
  19992. });
  19993. fluid.registerNamespace("fluid.tableOfContents.levels");
  19994. fluid.tableOfContents.levels.finalInit = function (that) {
  19995. fluid.fetchResources(that.options.resources, function () {
  19996. that.container.append(that.options.resources.template.resourceText);
  19997. that.refreshView()
  19998. })
  19999. };
  20000. fluid.tableOfContents.levels.objModel = function (type, ID) {
  20001. var objModel = {
  20002. ID : type + ID + ":",
  20003. children : []
  20004. };
  20005. return objModel
  20006. };
  20007. fluid.tableOfContents.levels.handleEmptyItemObj = function (itemObj) {
  20008. itemObj.decorators = [{
  20009. type : "addClass",
  20010. classes : "fl-tableOfContents-hide-bullet"
  20011. }
  20012. ]
  20013. };
  20014. fluid.tableOfContents.levels.generateTree = function (headingsModel, currentLevel) {
  20015. currentLevel = currentLevel || 0;
  20016. var levelObj = fluid.tableOfContents.levels.objModel("level", currentLevel);
  20017. if (headingsModel.headings.length === 0) {
  20018. return []
  20019. }
  20020. if (currentLevel === 0) {
  20021. var tree = {
  20022. children : [fluid.tableOfContents.levels.generateTree(headingsModel, currentLevel + 1)]
  20023. };
  20024. return tree
  20025. }
  20026. $.each(headingsModel.headings, function (index, model) {
  20027. var itemObj = fluid.tableOfContents.levels.objModel("items", currentLevel);
  20028. var linkObj = {
  20029. ID : "link" + currentLevel,
  20030. target : model.url,
  20031. linktext : model.text
  20032. };
  20033. if (!model.level) {
  20034. fluid.tableOfContents.levels.handleEmptyItemObj(itemObj)
  20035. } else {
  20036. itemObj.children.push(linkObj)
  20037. }
  20038. if (model.headings) {
  20039. itemObj.children.push(fluid.tableOfContents.levels.generateTree(model, currentLevel + 1))
  20040. }
  20041. levelObj.children.push(itemObj)
  20042. });
  20043. return levelObj
  20044. };
  20045. fluid.tableOfContents.levels.produceTree = function (that) {
  20046. return fluid.tableOfContents.levels.generateTree(that.model)
  20047. };
  20048. fluid.defaults("fluid.tableOfContents.levels", {
  20049. gradeNames : ["fluid.rendererComponent", "autoInit"],
  20050. finalInitFunction : "fluid.tableOfContents.levels.finalInit",
  20051. produceTree : "fluid.tableOfContents.levels.produceTree",
  20052. selectors : {
  20053. level1 : ".flc-toc-levels-level1",
  20054. level2 : ".flc-toc-levels-level2",
  20055. level3 : ".flc-toc-levels-level3",
  20056. level4 : ".flc-toc-levels-level4",
  20057. level5 : ".flc-toc-levels-level5",
  20058. level6 : ".flc-toc-levels-level6",
  20059. items1 : ".flc-toc-levels-items1",
  20060. items2 : ".flc-toc-levels-items2",
  20061. items3 : ".flc-toc-levels-items3",
  20062. items4 : ".flc-toc-levels-items4",
  20063. items5 : ".flc-toc-levels-items5",
  20064. items6 : ".flc-toc-levels-items6",
  20065. link1 : ".flc-toc-levels-link1",
  20066. link2 : ".flc-toc-levels-link2",
  20067. link3 : ".flc-toc-levels-link3",
  20068. link4 : ".flc-toc-levels-link4",
  20069. link5 : ".flc-toc-levels-link5",
  20070. link6 : ".flc-toc-levels-link6"
  20071. },
  20072. repeatingSelectors : ["level1", "level2", "level3", "level4", "level5", "level6", "items1", "items2", "items3", "items4", "items5", "items6"],
  20073. model : {
  20074. headings : []
  20075. },
  20076. resources : {
  20077. template : {
  20078. forceCache : true,
  20079. url : "../html/TableOfContents.html"
  20080. }
  20081. },
  20082. rendererFnOptions : {
  20083. noexpand : true
  20084. },
  20085. rendererOptions : {
  20086. debugMode : false
  20087. }
  20088. })
  20089. })(jQuery, fluid_1_4);
  20090. var fluid_1_4 = fluid_1_4 || {};
  20091. (function ($, fluid) {
  20092. fluid.generate = function (n, generator) {
  20093. var togo = [];
  20094. for (var i = 0; i < n; ++i) {
  20095. togo[i] = typeof(generator) === "function" ? generator.call(null, i) : generator
  20096. }
  20097. return togo
  20098. };
  20099. fluid.registerNamespace("fluid.url");
  20100. fluid.url.generateDepth = function (depth) {
  20101. return fluid.generate(depth, "../").join("")
  20102. };
  20103. fluid.url.parsePathInfo = function (pathInfo) {
  20104. var togo = {};
  20105. var segs = pathInfo.split("/");
  20106. if (segs.length > 0) {
  20107. var top = segs.length - 1;
  20108. var dotpos = segs[top].indexOf(".");
  20109. if (dotpos !== -1) {
  20110. togo.extension = segs[top].substring(dotpos + 1);
  20111. segs[top] = segs[top].substring(0, dotpos)
  20112. }
  20113. }
  20114. togo.pathInfo = segs;
  20115. return togo
  20116. };
  20117. fluid.url.parsePathInfoTrim = function (pathInfo) {
  20118. var togo = fluid.url.parsePathInfo(pathInfo);
  20119. if (togo.pathInfo[togo.pathInfo.length - 1] === "") {
  20120. togo.pathInfo.length--
  20121. }
  20122. return togo
  20123. };
  20124. fluid.url.collapseSegs = function (segs, from, to) {
  20125. var togo = "";
  20126. if (from === undefined) {
  20127. from = 0
  20128. }
  20129. if (to === undefined) {
  20130. to = segs.length
  20131. }
  20132. for (var i = from; i < to - 1; ++i) {
  20133. togo += segs[i] + "/"
  20134. }
  20135. if (to > from) {
  20136. togo += segs[to - 1]
  20137. }
  20138. return togo
  20139. };
  20140. fluid.url.makeRelPath = function (parsed, index) {
  20141. var togo = fluid.kettle.collapseSegs(parsed.pathInfo, index);
  20142. if (parsed.extension) {
  20143. togo += "." + parsed.extension
  20144. }
  20145. return togo
  20146. };
  20147. fluid.url.cononocolosePath = function (pathInfo) {
  20148. var consume = 0;
  20149. for (var i = 0; i < pathInfo.length; ++i) {
  20150. if (pathInfo[i] === "..") {
  20151. ++consume
  20152. } else {
  20153. if (consume !== 0) {
  20154. pathInfo.splice(i - consume * 2, consume * 2);
  20155. i -= consume * 2;
  20156. consume = 0
  20157. }
  20158. }
  20159. }
  20160. return pathInfo
  20161. };
  20162. fluid.url.parseUri = function (str) {
  20163. var o = fluid.url.parseUri.options,
  20164. m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
  20165. uri = {},
  20166. i = 14;
  20167. while (i--) {
  20168. uri[o.key[i]] = m[i] || ""
  20169. }
  20170. uri[o.q.name] = {};
  20171. uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
  20172. if ($1) {
  20173. uri[o.q.name][$1] = $2
  20174. }
  20175. });
  20176. return uri
  20177. };
  20178. fluid.url.parseUri.options = {
  20179. strictMode : true,
  20180. key : ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
  20181. q : {
  20182. name : "queryKey",
  20183. parser : /(?:^|&)([^&=]*)=?([^&]*)/g
  20184. },
  20185. parser : {
  20186. strict : /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
  20187. loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
  20188. }
  20189. };
  20190. fluid.url.parseSegs = function (url) {
  20191. var parsed = fluid.url.parseUri(url);
  20192. var parsedSegs = fluid.url.parsePathInfoTrim(parsed.directory);
  20193. return parsedSegs.pathInfo
  20194. };
  20195. fluid.url.isAbsoluteUrl = function (url) {
  20196. var parseRel = fluid.url.parseUri(url);
  20197. return (parseRel.host || parseRel.protocol || parseRel.directory.charAt(0) === "/")
  20198. };
  20199. fluid.url.computeRelativePrefix = function (outerLocation, iframeLocation, relPath) {
  20200. if (fluid.url.isAbsoluteUrl(relPath)) {
  20201. return relPath
  20202. }
  20203. var relSegs = fluid.url.parsePathInfo(relPath).pathInfo;
  20204. var parsedOuter = fluid.url.parseSegs(outerLocation);
  20205. var parsedRel = parsedOuter.concat(relSegs);
  20206. fluid.url.cononocolosePath(parsedRel);
  20207. var parsedInner = fluid.url.parseSegs(iframeLocation);
  20208. var seg = 0;
  20209. for (; seg < parsedRel.length; ++seg) {
  20210. if (parsedRel[seg] != parsedInner[seg]) {
  20211. break
  20212. }
  20213. }
  20214. var excess = parsedInner.length - seg;
  20215. var back = fluid.url.generateDepth(excess);
  20216. var front = fluid.url.collapseSegs(parsedRel, seg);
  20217. return back + front
  20218. }
  20219. })(jQuery, fluid_1_4);
  20220. var fluid_1_4 = fluid_1_4 || {};
  20221. (function ($, fluid) {
  20222. fluid.defaults("fluid.uiOptions.store", {
  20223. gradeNames : ["fluid.littleComponent", "autoInit"],
  20224. defaultSiteSettings : {
  20225. textFont : "default",
  20226. theme : "default",
  20227. textSize : 1,
  20228. lineSpacing : 1,
  20229. layout : false,
  20230. toc : false,
  20231. links : false,
  20232. inputsLarger : false
  20233. }
  20234. });
  20235. fluid.defaults("fluid.cookieStore", {
  20236. gradeNames : ["fluid.uiOptions.store", "autoInit"],
  20237. invokers : {
  20238. fetch : {
  20239. funcName : "fluid.cookieStore.fetch",
  20240. args : ["{cookieStore}.options.cookie.name", "{cookieStore}.options.defaultSiteSettings"]
  20241. },
  20242. save : {
  20243. funcName : "fluid.cookieStore.save",
  20244. args : ["{arguments}.0", "{cookieStore}.options.cookie"]
  20245. }
  20246. },
  20247. cookie : {
  20248. name : "fluid-ui-settings",
  20249. path : "/",
  20250. expires : ""
  20251. }
  20252. });
  20253. fluid.cookieStore.fetch = function (cookieName, defaults) {
  20254. var cookie = document.cookie;
  20255. var cookiePrefix = cookieName + "=";
  20256. var retObj,
  20257. startIndex,
  20258. endIndex;
  20259. if (cookie.length > 0) {
  20260. startIndex = cookie.indexOf(cookiePrefix);
  20261. if (startIndex > -1) {
  20262. startIndex = startIndex + cookiePrefix.length;
  20263. endIndex = cookie.indexOf(";", startIndex);
  20264. if (endIndex < startIndex) {
  20265. endIndex = cookie.length
  20266. }
  20267. retObj = JSON.parse(decodeURIComponent(cookie.substring(startIndex, endIndex)))
  20268. }
  20269. }
  20270. return retObj || defaults
  20271. };
  20272. fluid.cookieStore.assembleCookie = function (cookieOptions) {
  20273. var cookieStr = cookieOptions.name + "=" + cookieOptions.data;
  20274. if (cookieOptions.expires) {
  20275. cookieStr += "; expires=" + cookieOptions.expires
  20276. }
  20277. if (cookieOptions.path) {
  20278. cookieStr += "; path=" + cookieOptions.path
  20279. }
  20280. return cookieStr
  20281. };
  20282. fluid.cookieStore.save = function (settings, cookieOptions) {
  20283. cookieOptions.data = encodeURIComponent(JSON.stringify(settings));
  20284. document.cookie = fluid.cookieStore.assembleCookie(cookieOptions)
  20285. };
  20286. fluid.defaults("fluid.tempStore", {
  20287. gradeNames : ["fluid.uiOptions.store", "autoInit"],
  20288. invokers : {
  20289. fetch : {
  20290. funcName : "fluid.tempStore.fetch",
  20291. args : ["{tempStore}"]
  20292. },
  20293. save : {
  20294. funcName : "fluid.tempStore.save",
  20295. args : ["{arguments}.0", "{tempStore}"]
  20296. }
  20297. },
  20298. finalInitFunction : "fluid.tempStore.finalInit"
  20299. });
  20300. fluid.tempStore.finalInit = function (that) {
  20301. that.model = that.options.defaultSiteSettings
  20302. };
  20303. fluid.tempStore.fetch = function (that) {
  20304. return that.model
  20305. };
  20306. fluid.tempStore.save = function (settings, that) {
  20307. that.model = settings
  20308. }
  20309. })(jQuery, fluid_1_4);
  20310. var fluid_1_4 = fluid_1_4 || {};
  20311. (function ($, fluid) {
  20312. fluid.registerNamespace("fluid.browser.version");
  20313. fluid.browser.msie = function () {
  20314. var isIE = ($.browser.msie);
  20315. return isIE ? fluid.typeTag("fluid.browser.msie") : undefined
  20316. };
  20317. fluid.browser.majorVersion = function () {
  20318. var version = $.browser.version;
  20319. var dotpos = version.indexOf(".");
  20320. var majorVersion = version.substring(0, dotpos);
  20321. return fluid.typeTag("fluid.browser.majorVersion." + majorVersion)
  20322. };
  20323. var features = {
  20324. browserIE : fluid.browser.msie(),
  20325. browserMajorVersion : fluid.browser.majorVersion()
  20326. };
  20327. fluid.merge(null, fluid.staticEnvironment, features);
  20328. fluid.hasFeature = function (tagName) {
  20329. return fluid.find(fluid.staticEnvironment, function (value) {
  20330. return value && value.typeName === tagName ? true : undefined
  20331. })
  20332. };
  20333. fluid.defaults("fluid.uiEnhancer", {
  20334. gradeNames : ["fluid.viewComponent", "autoInit"],
  20335. components : {
  20336. textSize : {
  20337. type : "fluid.uiEnhancer.textSizer",
  20338. container : "{uiEnhancer}.container",
  20339. options : {
  20340. invokers : {
  20341. calcInitSize : {
  20342. funcName : "fluid.uiEnhancer.textSizer.calcInitSize",
  20343. args : ["{textSizer}.container", "{uiEnhancer}.options.fontSizeMap"]
  20344. }
  20345. }
  20346. }
  20347. },
  20348. tableOfContents : {
  20349. type : "fluid.tableOfContents",
  20350. container : "{uiEnhancer}.container",
  20351. createOnEvent : "onCreateTOCReady",
  20352. options : {
  20353. components : {
  20354. levels : {
  20355. type : "fluid.tableOfContents.levels",
  20356. options : {
  20357. resources : {
  20358. template : {
  20359. forceCache : true,
  20360. url : "{uiEnhancer}.options.tocTemplate"
  20361. }
  20362. }
  20363. }
  20364. }
  20365. },
  20366. listeners : {
  20367. afterRender : "{uiEnhancer}.lateRefreshRelay"
  20368. }
  20369. }
  20370. },
  20371. textFont : {
  20372. type : "fluid.uiEnhancer.classSwapper",
  20373. container : "{uiEnhancer}.container",
  20374. options : {
  20375. classes : "{uiEnhancer}.options.classnameMap.textFont"
  20376. }
  20377. },
  20378. lineSpacing : {
  20379. type : "fluid.uiEnhancer.lineSpacer",
  20380. container : "{uiEnhancer}.container",
  20381. options : {
  20382. invokers : {
  20383. calcInitSize : {
  20384. funcName : "fluid.uiEnhancer.lineSpacer.calcInitSize",
  20385. args : ["{lineSpacer}.container", "{uiEnhancer}.options.fontSizeMap"]
  20386. }
  20387. }
  20388. }
  20389. },
  20390. theme : {
  20391. type : "fluid.uiEnhancer.classSwapper",
  20392. container : "{uiEnhancer}.container",
  20393. options : {
  20394. classes : "{uiEnhancer}.options.classnameMap.theme"
  20395. }
  20396. },
  20397. settingsStore : {
  20398. type : "fluid.uiOptions.store",
  20399. options : {
  20400. defaultSiteSettings : "{uiEnhancer}.options.defaultSiteSettings"
  20401. }
  20402. }
  20403. },
  20404. invokers : {
  20405. updateModel : {
  20406. funcName : "fluid.uiEnhancer.updateModel",
  20407. args : ["@0", "{uiEnhancer}.applier"]
  20408. },
  20409. updateFromSettingsStore : {
  20410. funcName : "fluid.uiEnhancer.updateFromSettingsStore",
  20411. args : ["{uiEnhancer}"]
  20412. },
  20413. refreshView : {
  20414. funcName : "fluid.uiEnhancer.refreshView",
  20415. args : ["{uiEnhancer}"]
  20416. },
  20417. styleElements : "fluid.uiEnhancer.styleElements",
  20418. setLayout : "fluid.uiEnhancer.setLayout",
  20419. styleLinks : "fluid.uiEnhancer.styleLinks",
  20420. styleInputs : "fluid.uiEnhancer.styleInputs",
  20421. setIE6ColorInversion : "fluid.uiEnhancer.setIE6ColorInversion"
  20422. },
  20423. events : {
  20424. onCreateTOCReady : null,
  20425. lateRefreshView : null,
  20426. modelChanged : null
  20427. },
  20428. listeners : {
  20429. "lateRefreshView.domReading" : "fluid.uiEnhancer.applyDomReadingSettings"
  20430. },
  20431. classnameMap : {
  20432. textFont : {
  20433. "default" : "",
  20434. times : "fl-font-uio-times",
  20435. comic : "fl-font-uio-comic-sans",
  20436. arial : "fl-font-uio-arial",
  20437. verdana : "fl-font-uio-verdana"
  20438. },
  20439. theme : {
  20440. "default" : "fl-uio-default-theme",
  20441. bw : "fl-theme-uio-bw fl-theme-bw",
  20442. wb : "fl-theme-uio-wb fl-theme-wb",
  20443. by : "fl-theme-uio-by fl-theme-by",
  20444. yb : "fl-theme-uio-yb fl-theme-yb"
  20445. },
  20446. layout : "fl-layout-linear",
  20447. links : "fl-text-underline fl-text-bold fl-text-larger",
  20448. inputsLarger : "fl-text-larger"
  20449. },
  20450. fontSizeMap : {
  20451. "xx-small" : "9px",
  20452. "x-small" : "11px",
  20453. small : "13px",
  20454. medium : "15px",
  20455. large : "18px",
  20456. "x-large" : "23px",
  20457. "xx-large" : "30px"
  20458. },
  20459. selectors : {
  20460. colorInversion : ".fl-inverted-color"
  20461. },
  20462. styles : {
  20463. colorInversionClass : "fl-inverted-color"
  20464. },
  20465. finalInitFunction : "fluid.uiEnhancer.finalInit"
  20466. });
  20467. fluid.uiEnhancer.finalInit = function (that) {
  20468. that.applier.modelChanged.addListener("", function (newModel, oldModel, changeRequest) {
  20469. that.events.modelChanged.fire(newModel, oldModel, changeRequest);
  20470. that.refreshView()
  20471. });
  20472. that.lateRefreshRelay = function () {
  20473. that.events.lateRefreshView.fire(that)
  20474. };
  20475. that.updateFromSettingsStore();
  20476. return that
  20477. };
  20478. fluid.uiEnhancer.updateFromSettingsStore = function (that) {
  20479. that.updateModel(that.settingsStore.fetch())
  20480. };
  20481. fluid.uiEnhancer.updateModel = function (newModel, applier) {
  20482. applier.requestChange("", newModel)
  20483. };
  20484. fluid.uiEnhancer.applyTocSetting = function (that) {
  20485. var async = false;
  20486. if (that.model.toc) {
  20487. if (that.tableOfContents) {
  20488. that.tableOfContents.show()
  20489. } else {
  20490. that.events.onCreateTOCReady.fire();
  20491. async = true
  20492. }
  20493. } else {
  20494. if (that.tableOfContents) {
  20495. that.tableOfContents.hide()
  20496. }
  20497. }
  20498. if (!async) {
  20499. that.lateRefreshRelay()
  20500. }
  20501. };
  20502. fluid.uiEnhancer.applyDomReadingSettings = function (that) {
  20503. that.setLayout(that);
  20504. that.styleLinks(that);
  20505. that.styleInputs(that);
  20506. that.setIE6ColorInversion(that)
  20507. };
  20508. fluid.uiEnhancer.refreshView = function (that) {
  20509. that.textSize.set(that.model.textSize);
  20510. that.textFont.swap(that.model.textFont);
  20511. that.lineSpacing.set(that.model.lineSpacing);
  20512. that.theme.swap(that.model.theme);
  20513. $(document).ready(function () {
  20514. fluid.uiEnhancer.applyTocSetting(that)
  20515. })
  20516. };
  20517. fluid.uiEnhancer.styleElements = function (elements, setting, classname) {
  20518. if (setting) {
  20519. elements.addClass(classname)
  20520. } else {
  20521. $("." + classname, elements).andSelf().removeClass(classname)
  20522. }
  20523. };
  20524. fluid.uiEnhancer.setLayout = function (that) {
  20525. that.styleElements(that.container, that.model.layout, that.options.classnameMap.layout)
  20526. };
  20527. fluid.uiEnhancer.styleLinks = function (that) {
  20528. var links = $("a", that.container);
  20529. that.styleElements(links, that.model.links, that.options.classnameMap.links)
  20530. };
  20531. fluid.uiEnhancer.styleInputs = function (that) {
  20532. that.styleElements($("input, button", that.container), that.model.inputsLarger, that.options.classnameMap.inputsLarger)
  20533. };
  20534. fluid.uiEnhancer.setIE6ColorInversion = function (that) {
  20535. if (fluid.hasFeature("fluid.browser.msie") && fluid.hasFeature("fluid.browser.majorVersion.6") && that.model.theme === "default") {
  20536. that.locate("colorInversion").removeClass(that.options.styles.colorInversionClass)
  20537. }
  20538. };
  20539. fluid.uiEnhancer.getTextSizeInPx = function (container, fontSizeMap) {
  20540. var fontSize = container.css("font-size");
  20541. if (fontSizeMap[fontSize]) {
  20542. fontSize = fontSizeMap[fontSize]
  20543. }
  20544. return parseFloat(fontSize)
  20545. };
  20546. fluid.uiEnhancer.getTextSizeInEm = function (container, fontSizeMap) {
  20547. var px2emFactor = fluid.uiEnhancer.getPx2EmFactor(container, fontSizeMap);
  20548. return Math.round(fluid.uiEnhancer.getTextSizeInPx(container, fontSizeMap) / px2emFactor * 10000) / 10000
  20549. };
  20550. fluid.uiEnhancer.getPx2EmFactor = function (container, fontSizeMap) {
  20551. if (container.get(0).tagName !== "BODY") {
  20552. container = container.parent()
  20553. }
  20554. return fluid.uiEnhancer.getTextSizeInPx(container, fontSizeMap)
  20555. };
  20556. fluid.uiEnhancer.getLineHeight = function (container) {
  20557. var lineHeight;
  20558. if (container[0].currentStyle) {
  20559. lineHeight = container[0].currentStyle.lineHeight
  20560. } else {
  20561. lineHeight = container.css("line-height")
  20562. }
  20563. return lineHeight
  20564. };
  20565. fluid.uiEnhancer.numerizeLineHeight = function (lineHeight, fontSize) {
  20566. if (!lineHeight) {
  20567. return 0
  20568. }
  20569. if (lineHeight === "normal") {
  20570. return 1.2
  20571. }
  20572. if (lineHeight.match(/[0-9]$/)) {
  20573. return lineHeight
  20574. }
  20575. return Math.round(parseFloat(lineHeight) / fontSize * 100) / 100
  20576. };
  20577. fluid.defaults("fluid.uiEnhancer.textSizer", {
  20578. gradeNames : ["fluid.viewComponent", "autoInit"],
  20579. invokers : {
  20580. set : {
  20581. funcName : "fluid.uiEnhancer.textSizer.set",
  20582. args : ["@0", "{textSizer}"]
  20583. }
  20584. }
  20585. });
  20586. fluid.uiEnhancer.textSizer.set = function (times, that) {
  20587. if (!that.initialSize) {
  20588. that.initialSize = that.calcInitSize()
  20589. }
  20590. if (that.initialSize) {
  20591. var targetSize = times * that.initialSize;
  20592. that.container.css("font-size", targetSize + "em")
  20593. }
  20594. };
  20595. fluid.uiEnhancer.textSizer.calcInitSize = function (container, fontSizeMap) {
  20596. return fluid.uiEnhancer.getTextSizeInEm(container, fontSizeMap)
  20597. };
  20598. fluid.defaults("fluid.uiEnhancer.classSwapper", {
  20599. gradeNames : ["fluid.viewComponent", "autoInit"],
  20600. invokers : {
  20601. clearClasses : {
  20602. funcName : "fluid.uiEnhancer.classSwapper.clearClasses",
  20603. args : ["{classSwapper}"]
  20604. },
  20605. swap : {
  20606. funcName : "fluid.uiEnhancer.classSwapper.swap",
  20607. args : ["@0", "{classSwapper}"]
  20608. }
  20609. },
  20610. classes : {},
  20611. finalInitFunction : "fluid.uiEnhancer.classSwapper.finalInit"
  20612. });
  20613. fluid.uiEnhancer.classSwapper.finalInit = function (that) {
  20614. that.classSelector = "";
  20615. that.classStr = "";
  20616. fluid.each(that.options.classes, function (className) {
  20617. if (className) {
  20618. that.classSelector += that.classSelector ? ", ." + className : "." + className;
  20619. that.classStr += that.classStr ? " " + className : className
  20620. }
  20621. })
  20622. };
  20623. fluid.uiEnhancer.classSwapper.clearClasses = function (that) {
  20624. that.container.removeClass(that.classStr)
  20625. };
  20626. fluid.uiEnhancer.classSwapper.swap = function (classname, that) {
  20627. that.clearClasses(that);
  20628. that.container.addClass(that.options.classes[classname])
  20629. };
  20630. fluid.defaults("fluid.uiEnhancer.lineSpacer", {
  20631. gradeNames : ["fluid.viewComponent", "autoInit"],
  20632. invokers : {
  20633. set : {
  20634. funcName : "fluid.uiEnhancer.lineSpacer.set",
  20635. args : ["@0", "{lineSpacer}"]
  20636. }
  20637. }
  20638. });
  20639. fluid.uiEnhancer.lineSpacer.set = function (times, that) {
  20640. if (!that.initialSize) {
  20641. that.initialSize = that.calcInitSize()
  20642. }
  20643. if (that.initialSize) {
  20644. var targetLineSpacing = times * that.initialSize;
  20645. that.container.css("line-height", targetLineSpacing + "em")
  20646. }
  20647. };
  20648. fluid.uiEnhancer.lineSpacer.calcInitSize = function (container, fontSizeMap) {
  20649. var lineHeight = fluid.uiEnhancer.getLineHeight(container);
  20650. var fontSize = fluid.uiEnhancer.getTextSizeInPx(container, fontSizeMap);
  20651. return fluid.uiEnhancer.numerizeLineHeight(lineHeight, fontSize)
  20652. };
  20653. fluid.pageEnhancer = function (uiEnhancerOptions) {
  20654. var that = fluid.initLittleComponent("fluid.pageEnhancer");
  20655. uiEnhancerOptions = fluid.copy(uiEnhancerOptions);
  20656. uiEnhancerOptions.originalUserOptions = fluid.copy(uiEnhancerOptions);
  20657. that.uiEnhancerOptions = uiEnhancerOptions;
  20658. fluid.initDependents(that);
  20659. fluid.staticEnvironment.uiEnhancer = that.uiEnhancer;
  20660. return that
  20661. };
  20662. fluid.defaults("fluid.pageEnhancer", {
  20663. gradeNames : ["fluid.littleComponent"],
  20664. components : {
  20665. uiEnhancer : {
  20666. type : "fluid.uiEnhancer",
  20667. container : "body",
  20668. options : "{pageEnhancer}.uiEnhancerOptions"
  20669. }
  20670. }
  20671. });
  20672. fluid.demands("fluid.uiOptions.store", ["fluid.uiEnhancer"], {
  20673. funcName : "fluid.cookieStore"
  20674. })
  20675. })(jQuery, fluid_1_4);
  20676. var fluid_1_4 = fluid_1_4 || {};
  20677. (function ($, fluid) {
  20678. fluid.defaults("fluid.textfieldSlider", {
  20679. gradeNames : ["fluid.viewComponent", "autoInit"],
  20680. components : {
  20681. textfield : {
  20682. type : "fluid.textfieldSlider.textfield",
  20683. container : "{textfieldSlider}.dom.textfield",
  20684. options : {
  20685. model : "{textfieldSlider}.model",
  20686. applier : "{textfieldSlider}.applier"
  20687. }
  20688. },
  20689. slider : {
  20690. type : "fluid.textfieldSlider.slider",
  20691. container : "{textfieldSlider}.dom.slider",
  20692. options : {
  20693. model : "{textfieldSlider}.model",
  20694. applier : "{textfieldSlider}.applier"
  20695. }
  20696. }
  20697. },
  20698. selectors : {
  20699. textfield : ".flc-textfieldSlider-field",
  20700. slider : ".flc-textfieldSlider-slider"
  20701. },
  20702. events : {
  20703. modelChanged : null
  20704. },
  20705. model : {
  20706. value : null,
  20707. min : 0,
  20708. max : 100
  20709. },
  20710. sliderOptions : {
  20711. orientation : "horizontal",
  20712. step : 0.1
  20713. },
  20714. finalInitFunction : "fluid.textfieldSlider.finalInit"
  20715. });
  20716. fluid.textfieldSlider.finalInit = function (that) {
  20717. var sliderOptions = $.extend(true, {}, that.options.sliderOptions, that.model);
  20718. that.slider.initSlider(sliderOptions);
  20719. that.refreshView = function () {
  20720. var val = that.model.value;
  20721. that.textfield.container.val(val);
  20722. that.slider.setSliderValue(val);
  20723. that.slider.setSliderAria(val)
  20724. };
  20725. that.applier.modelChanged.addListener("value", function (newModel) {
  20726. that.events.modelChanged.fire(newModel.value)
  20727. });
  20728. that.events.modelChanged.addListener(that.refreshView);
  20729. that.refreshView()
  20730. };
  20731. fluid.defaults("fluid.textfieldSlider.textfield", {
  20732. gradeNames : ["fluid.viewComponent", "autoInit"],
  20733. finalInitFunction : "fluid.textfieldSlider.textfield.finalInit"
  20734. });
  20735. fluid.textfieldSlider.validateValue = function (model, changeRequest, applier) {
  20736. var oldValue = model.value;
  20737. var newValue = changeRequest.value;
  20738. var isValidNum = !isNaN(parseInt(newValue, 10));
  20739. if (isValidNum) {
  20740. if (newValue < model.min) {
  20741. newValue = model.min
  20742. } else {
  20743. if (newValue > model.max) {
  20744. newValue = model.max
  20745. }
  20746. }
  20747. changeRequest.value = newValue
  20748. } else {
  20749. changeRequest.value = oldValue
  20750. }
  20751. };
  20752. fluid.textfieldSlider.textfield.finalInit = function (that) {
  20753. that.applier.guards.addListener({
  20754. path : "value",
  20755. transactional : true
  20756. }, fluid.textfieldSlider.validateValue);
  20757. that.container.change(function (source) {
  20758. that.applier.requestChange("value", source.target.value)
  20759. })
  20760. };
  20761. fluid.defaults("fluid.textfieldSlider.slider", {
  20762. gradeNames : ["fluid.viewComponent", "autoInit"],
  20763. finalInitFunction : "fluid.textfieldSlider.slider.finalInit",
  20764. selectors : {
  20765. thumb : ".ui-slider-handle"
  20766. }
  20767. });
  20768. var initSliderAria = function (thumb, opts) {
  20769. var ariaDefaults = {
  20770. role : "slider",
  20771. "aria-valuenow" : opts.value,
  20772. "aria-valuemin" : opts.min,
  20773. "aria-valuemax" : opts.max
  20774. };
  20775. thumb.attr(ariaDefaults)
  20776. };
  20777. fluid.textfieldSlider.slider.finalInit = function (that) {
  20778. that.slider = that.container.slider(that.model);
  20779. that.initSlider = function (sliderOptions) {
  20780. var slider = that.slider.slider(sliderOptions);
  20781. initSliderAria(that.locate("thumb"), sliderOptions)
  20782. };
  20783. that.setSliderValue = function (value) {
  20784. that.slider.slider("value", value)
  20785. };
  20786. that.setSliderAria = function (value) {
  20787. that.locate("thumb").attr("aria-valuenow", value)
  20788. };
  20789. that.slider.bind("slide", function (e, ui) {
  20790. that.applier.requestChange("value", ui.value)
  20791. })
  20792. }
  20793. })(jQuery, fluid_1_4);
  20794. (function ($, fluid) {
  20795. fluid.registerNamespace("fluid.uiOptions.inline");
  20796. fluid.defaults("fluid.uiOptions.inline", {
  20797. gradeNames : ["fluid.viewComponent"],
  20798. mergePolicy : {
  20799. uiOptionsTransform : "noexpand",
  20800. derivedDefaults : "noexpand"
  20801. },
  20802. components : {
  20803. uiOptionsLoader : {
  20804. type : "fluid.uiOptions.loader"
  20805. },
  20806. templateLoader : {
  20807. priority : "first",
  20808. type : "fluid.uiOptions.templateLoader"
  20809. }
  20810. },
  20811. uiOptionsTransform : {
  20812. transformer : "fluid.uiOptions.mapOptions",
  20813. config : {
  20814. "*.templateLoader" : "templateLoader",
  20815. "*.templateLoader.*.templatePath.options.value" : "prefix",
  20816. "*.uiOptionsLoader" : "uiOptionsLoader",
  20817. "*.uiOptionsLoader.container" : "container",
  20818. "*.uiOptionsLoader.*.uiOptions" : "uiOptions",
  20819. "*.uiOptionsLoader.*.uiOptions.*.textControls" : "textControls",
  20820. "*.uiOptionsLoader.*.uiOptions.*.layoutControls" : "layoutControls",
  20821. "*.uiOptionsLoader.*.uiOptions.*.linksControls" : "linksControls",
  20822. "*.uiOptionsLoader.*.uiOptions.*.preview" : "preview",
  20823. "*.uiOptionsLoader.*.uiOptions.*.preview.*.enhancer" : "previewEnhancer"
  20824. }
  20825. },
  20826. derivedDefaults : {
  20827. uiOptions : {
  20828. options : {
  20829. components : {
  20830. settingsStore : "{uiEnhancer}.settingsStore"
  20831. },
  20832. listeners : {
  20833. onUIOptionsRefresh : "{uiEnhancer}.updateFromSettingsStore"
  20834. }
  20835. }
  20836. }
  20837. }
  20838. });
  20839. fluid.uiOptions.inline.makeCreator = function (componentName, processor) {
  20840. fluid.setGlobalValue(componentName, function (container, options) {
  20841. var defaults = fluid.defaults(componentName);
  20842. options.container = container;
  20843. options = processor(options);
  20844. var mappedOptions = fluid.uiOptions.mapOptions(options, defaults.uiOptionsTransform.config, defaults.mergePolicy, fluid.copy(defaults.derivedDefaults));
  20845. var that = fluid.initView(componentName, container, mappedOptions);
  20846. fluid.diagnoseFailedView(componentName, that, fluid.defaults(componentName), [componentName, container, mappedOptions]);
  20847. fluid.initDependents(that);
  20848. return that
  20849. })
  20850. };
  20851. fluid.uiOptions.sortByKeyLength = function (inObject) {
  20852. var keys = [];
  20853. for (var k in inObject) {
  20854. keys.push(k)
  20855. }
  20856. keys.sort(function (a, b) {
  20857. return a.length - b.length
  20858. });
  20859. return keys
  20860. };
  20861. fluid.uiOptions.mapOptionsRecord = function (options, sortedConfigKeys, config) {
  20862. var opRecs = [{}, {}, options || {}
  20863. ];
  20864. var appliers = fluid.transform(opRecs, function (opRec) {
  20865. return fluid.makeChangeApplier(opRec)
  20866. });
  20867. fluid.each(sortedConfigKeys, function (origDest) {
  20868. var source = config[origDest];
  20869. var dest = fluid.uiOptions.expandShortPath(origDest);
  20870. var applier = appliers[origDest.charAt(0) === "!" ? 0 : 1];
  20871. var value = fluid.get(options, source);
  20872. if (value) {
  20873. applier.requestChange(dest, value, "ADD");
  20874. appliers[2].requestChange(source, value, "DELETE")
  20875. }
  20876. });
  20877. return opRecs
  20878. };
  20879. fluid.uiOptions.mapOptions = function (options, config, mergePolicy, derivedDefaults) {
  20880. var sortedConfigKeys = fluid.uiOptions.sortByKeyLength(config);
  20881. var optrecs = fluid.uiOptions.mapOptionsRecord(options, sortedConfigKeys, config);
  20882. var devrecs = fluid.uiOptions.mapOptionsRecord(derivedDefaults, sortedConfigKeys, config);
  20883. var mergeOpts = [mergePolicy].concat(devrecs).concat(optrecs);
  20884. return fluid.merge.apply(null, mergeOpts)
  20885. };
  20886. fluid.uiOptions.expandShortPath = function (path) {
  20887. if (path.charAt(0) === "!") {
  20888. path = path.substring(1)
  20889. }
  20890. var strToreplaceFirst = "components";
  20891. var strToreplaceRest = "options.components";
  20892. var newPath = (path.charAt(0) === "*") ? path.replace("*", strToreplaceFirst) : path;
  20893. newPath = newPath.replace(/\*/g, strToreplaceRest);
  20894. return newPath
  20895. };
  20896. fluid.defaults("fluid.uiOptions.templateLoader", {
  20897. gradeNames : ["fluid.eventedComponent", "autoInit"],
  20898. finalInitFunction : "fluid.uiOptions.templateLoader.resolveTemplates",
  20899. templates : {
  20900. uiOptions : "%prefix/FatPanelUIOptions.html",
  20901. textControls : "%prefix/UIOptionsTemplate-text.html",
  20902. layoutControls : "%prefix/UIOptionsTemplate-layout.html",
  20903. linksControls : "%prefix/UIOptionsTemplate-links.html"
  20904. },
  20905. components : {
  20906. templatePath : {
  20907. type : "fluid.uiOptions.templatePath"
  20908. }
  20909. },
  20910. invokers : {
  20911. transformURL : {
  20912. funcName : "fluid.stringTemplate",
  20913. args : ["{arguments}.0", {
  20914. "prefix/" : "{templateLoader}.templatePath.options.value"
  20915. }
  20916. ]
  20917. }
  20918. }
  20919. });
  20920. fluid.uiOptions.templateLoader.resolveTemplates = function (that) {
  20921. var mapped = fluid.transform(that.options.templates, that.transformURL);
  20922. that.resources = fluid.transform(mapped, function (url) {
  20923. return {
  20924. url : url,
  20925. forceCache : true
  20926. }
  20927. })
  20928. };
  20929. fluid.defaults("fluid.uiOptions.templatePath", {
  20930. gradeNames : ["fluid.littleComponent", "autoInit"],
  20931. value : "../html/"
  20932. });
  20933. fluid.demands("fluid.uiOptions.textControls", ["fluid.uiOptions"], {
  20934. options : {
  20935. classnameMap : "{uiEnhancer}.options.classnameMap"
  20936. }
  20937. });
  20938. fluid.demands("fluid.uiOptions.layoutControls", ["fluid.uiOptions"], {
  20939. options : {
  20940. classnameMap : "{uiEnhancer}.options.classnameMap"
  20941. }
  20942. });
  20943. fluid.demands("fluid.uiOptions.linksControls", ["fluid.uiOptions"], {
  20944. options : {
  20945. classnameMap : "{uiEnhancer}.options.classnameMap"
  20946. }
  20947. });
  20948. fluid.uiOptions.onReadyFirer = function (uiOptionsLoader, uiOptions) {
  20949. uiOptionsLoader.events.onReady.fire(uiOptionsLoader, uiOptions)
  20950. };
  20951. fluid.defaults("fluid.uiOptions.loader", {
  20952. gradeNames : ["fluid.viewComponent", "autoInit"],
  20953. resources : "{templateLoader}.resources",
  20954. finalInitFunction : "fluid.uiOptions.loader.finalInit",
  20955. events : {
  20956. onUIOptionsTemplateReady : null,
  20957. onUIOptionsComponentReady : null,
  20958. onUIOptionsReadyBridge : {
  20959. event : "onUIOptionsComponentReady",
  20960. args : ["{fluid.uiOptions.loader}", "{arguments}.0"]
  20961. },
  20962. onReady : null
  20963. },
  20964. listeners : {
  20965. onUIOptionsReadyBridge : {
  20966. listener : fluid.uiOptions.onReadyFirer,
  20967. priority : "last"
  20968. }
  20969. },
  20970. components : {
  20971. uiOptions : {
  20972. type : "fluid.uiOptions",
  20973. container : "{loader}.container",
  20974. createOnEvent : "onUIOptionsTemplateReady",
  20975. options : {
  20976. events : {
  20977. onUIOptionsComponentReady : "{loader}.events.onUIOptionsComponentReady"
  20978. }
  20979. }
  20980. }
  20981. }
  20982. });
  20983. fluid.uiOptions.loader.finalInit = function (that) {
  20984. fluid.fetchResources(that.options.resources, function () {
  20985. that.events.onUIOptionsTemplateReady.fire()
  20986. })
  20987. };
  20988. fluid.defaults("fluid.uiOptions", {
  20989. gradeNames : ["fluid.viewComponent", "autoInit"],
  20990. components : {
  20991. textControls : {
  20992. type : "fluid.uiOptions.textControls",
  20993. container : "{uiOptions}.dom.textControls",
  20994. createOnEvent : "onUIOptionsComponentReady",
  20995. options : {
  20996. model : "{uiOptions}.model",
  20997. applier : "{uiOptions}.applier",
  20998. events : {
  20999. onUIOptionsRefresh : "{uiOptions}.events.onUIOptionsRefresh"
  21000. }
  21001. }
  21002. },
  21003. layoutControls : {
  21004. type : "fluid.uiOptions.layoutControls",
  21005. container : "{uiOptions}.dom.layoutControls",
  21006. createOnEvent : "onUIOptionsComponentReady",
  21007. options : {
  21008. model : "{uiOptions}.model",
  21009. applier : "{uiOptions}.applier",
  21010. events : {
  21011. onUIOptionsRefresh : "{uiOptions}.events.onUIOptionsRefresh"
  21012. }
  21013. }
  21014. },
  21015. linksControls : {
  21016. type : "fluid.uiOptions.linksControls",
  21017. container : "{uiOptions}.dom.linksControls",
  21018. createOnEvent : "onUIOptionsComponentReady",
  21019. options : {
  21020. model : "{uiOptions}.model",
  21021. applier : "{uiOptions}.applier",
  21022. events : {
  21023. onUIOptionsRefresh : "{uiOptions}.events.onUIOptionsRefresh"
  21024. }
  21025. }
  21026. },
  21027. preview : {
  21028. type : "fluid.uiOptions.preview",
  21029. createOnEvent : "onUIOptionsComponentReady",
  21030. container : "{uiOptions}.dom.previewFrame"
  21031. },
  21032. eventBinder : {
  21033. type : "fluid.uiOptions.eventBinder"
  21034. }
  21035. },
  21036. selectors : {
  21037. textControls : ".flc-uiOptions-text-controls",
  21038. layoutControls : ".flc-uiOptions-layout-controls",
  21039. linksControls : ".flc-uiOptions-links-controls",
  21040. cancel : ".flc-uiOptions-cancel",
  21041. reset : ".flc-uiOptions-reset",
  21042. save : ".flc-uiOptions-save",
  21043. previewFrame : ".flc-uiOptions-preview-frame"
  21044. },
  21045. events : {
  21046. onSave : null,
  21047. onCancel : null,
  21048. onReset : null,
  21049. onAutoSave : null,
  21050. modelChanged : null,
  21051. onUIOptionsRefresh : null,
  21052. onUIOptionsComponentReady : null
  21053. },
  21054. finalInitFunction : "fluid.uiOptions.finalInit",
  21055. resources : {
  21056. template : "{templateLoader}.resources.uiOptions"
  21057. },
  21058. autoSave : false
  21059. });
  21060. fluid.uiOptions.finalInit = function (that) {
  21061. that.applier.requestChange("selections", fluid.copy(that.settingsStore.fetch()));
  21062. that.save = function () {
  21063. that.events.onSave.fire(that.model.selections);
  21064. var savedSelections = fluid.copy(that.model.selections);
  21065. that.settingsStore.save(savedSelections)
  21066. };
  21067. that.saveAndApply = function () {
  21068. that.save();
  21069. that.events.onUIOptionsRefresh.fire()
  21070. };
  21071. that.reset = function () {
  21072. that.updateModel(fluid.copy(that.settingsStore.options.defaultSiteSettings));
  21073. that.events.onReset.fire(that);
  21074. that.events.onUIOptionsRefresh.fire()
  21075. };
  21076. that.cancel = function () {
  21077. that.events.onCancel.fire();
  21078. that.updateModel(that.settingsStore.fetch());
  21079. that.events.onUIOptionsRefresh.fire()
  21080. };
  21081. that.updateModel = function (newModel) {
  21082. that.applier.requestChange("selections", newModel)
  21083. };
  21084. that.applier.modelChanged.addListener("selections", function (newModel, oldModel, changeRequest) {
  21085. that.events.modelChanged.fire(newModel, oldModel, changeRequest.source);
  21086. if (that.options.autoSave) {
  21087. that.events.onAutoSave.fire()
  21088. }
  21089. });
  21090. var bindHandlers = function (that) {
  21091. var saveButton = that.locate("save");
  21092. if (saveButton.length > 0) {
  21093. saveButton.click(that.saveAndApply);
  21094. var form = fluid.findForm(saveButton);
  21095. $(form).submit(function () {
  21096. that.saveAndApply()
  21097. })
  21098. }
  21099. that.locate("reset").click(that.reset);
  21100. that.locate("cancel").click(that.cancel)
  21101. };
  21102. var bindEventHandlers = function (that) {
  21103. that.events.onAutoSave.addListener(function () {
  21104. that.save()
  21105. })
  21106. };
  21107. fluid.fetchResources(that.options.resources, function () {
  21108. setTimeout(function () {
  21109. that.container.append(that.options.resources.template.resourceText);
  21110. bindHandlers(that);
  21111. bindEventHandlers(that);
  21112. that.events.onUIOptionsComponentReady.fire(that)
  21113. }, 1)
  21114. })
  21115. };
  21116. fluid.defaults("fluid.uiOptions.eventBinder", {
  21117. gradeNames : ["fluid.eventedComponent", "autoInit"]
  21118. });
  21119. var initModel = function (that) {
  21120. fluid.each(that.options.controlValues, function (item, key) {
  21121. that.applier.requestChange("labelMap." + key, {
  21122. values : that.options.controlValues[key],
  21123. names : that.options.strings[key],
  21124. classes : that.options.classnameMap[key]
  21125. })
  21126. })
  21127. };
  21128. var createSliderNode = function (that, item) {
  21129. return {
  21130. decorators : {
  21131. type : "fluid",
  21132. func : "fluid.textfieldSlider",
  21133. options : {
  21134. listeners : {
  21135. modelChanged : function (value) {
  21136. that.applier.requestChange("selections." + item, value)
  21137. }
  21138. },
  21139. model : {
  21140. min : that.options[item].min,
  21141. max : that.options[item].max,
  21142. value : that.model.selections[item]
  21143. }
  21144. }
  21145. }
  21146. }
  21147. };
  21148. fluid.uiOptions.controlsFinalInit = function (that) {
  21149. initModel(that);
  21150. that.refreshView()
  21151. };
  21152. fluid.uiOptions.lateRefreshViewBinder = function (that) {
  21153. that.refreshView = function () {
  21154. that.renderer.refreshView()
  21155. }
  21156. };
  21157. fluid.defaults("fluid.uiOptions.textControls", {
  21158. gradeNames : ["fluid.rendererComponent", "autoInit"],
  21159. strings : {
  21160. textFont : ["Default", "Times New Roman", "Comic Sans", "Arial", "Verdana"],
  21161. theme : ["Default", "Black on white", "White on black", "Black on yellow", "Yellow on black"]
  21162. },
  21163. controlValues : {
  21164. textFont : ["default", "times", "comic", "arial", "verdana"],
  21165. theme : ["default", "bw", "wb", "by", "yb"]
  21166. },
  21167. textSize : {
  21168. min : 1,
  21169. max : 2
  21170. },
  21171. lineSpacing : {
  21172. min : 1,
  21173. max : 2
  21174. },
  21175. selectors : {
  21176. textFont : ".flc-uiOptions-text-font",
  21177. theme : ".flc-uiOptions-theme",
  21178. textSize : ".flc-uiOptions-min-text-size",
  21179. lineSpacing : ".flc-uiOptions-line-spacing"
  21180. },
  21181. events : {
  21182. onUIOptionsRefresh : null
  21183. },
  21184. listeners : {
  21185. onUIOptionsRefresh : "{textControls}.refreshView"
  21186. },
  21187. preInitFunction : "fluid.uiOptions.lateRefreshViewBinder",
  21188. finalInitFunction : "fluid.uiOptions.controlsFinalInit",
  21189. produceTree : "fluid.uiOptions.textControls.produceTree",
  21190. resources : {
  21191. template : "{templateLoader}.resources.textControls"
  21192. }
  21193. });
  21194. fluid.uiOptions.textControls.produceTree = function (that) {
  21195. var tree = {};
  21196. for (var item in that.model.selections) {
  21197. if (item === "textFont" || item === "theme") {
  21198. tree[item] = {
  21199. optionnames : "${labelMap." + item + ".names}",
  21200. optionlist : "${labelMap." + item + ".values}",
  21201. selection : "${selections." + item + "}",
  21202. decorators : {
  21203. type : "fluid",
  21204. func : "fluid.uiOptions.selectDecorator",
  21205. options : {
  21206. styles : that.options.classnameMap[item]
  21207. }
  21208. }
  21209. }
  21210. } else {
  21211. if (item === "textSize" || item === "lineSpacing") {
  21212. tree[item] = createSliderNode(that, item)
  21213. }
  21214. }
  21215. }
  21216. return tree
  21217. };
  21218. fluid.demands("fluid.uiOptions.selectDecorator", "fluid.uiOptions", {
  21219. container : "{arguments}.0"
  21220. });
  21221. fluid.defaults("fluid.uiOptions.selectDecorator", {
  21222. gradeNames : ["fluid.viewComponent", "autoInit"],
  21223. finalInitFunction : "fluid.uiOptions.selectDecorator.finalInit",
  21224. styles : {
  21225. preview : "fl-preview-theme"
  21226. }
  21227. });
  21228. fluid.uiOptions.selectDecorator.finalInit = function (that) {
  21229. fluid.each($("option", that.container), function (option) {
  21230. var styles = that.options.styles;
  21231. $(option).addClass(styles.preview + " " + styles[fluid.value(option)])
  21232. })
  21233. };
  21234. fluid.defaults("fluid.uiOptions.layoutControls", {
  21235. gradeNames : ["fluid.rendererComponent", "autoInit"],
  21236. selectors : {
  21237. layout : ".flc-uiOptions-layout",
  21238. toc : ".flc-uiOptions-toc"
  21239. },
  21240. events : {
  21241. onUIOptionsRefresh : null
  21242. },
  21243. listeners : {
  21244. onUIOptionsRefresh : "{layoutControls}.refreshView"
  21245. },
  21246. preInitFunction : "fluid.uiOptions.lateRefreshViewBinder",
  21247. finalInitFunction : "fluid.uiOptions.controlsFinalInit",
  21248. produceTree : "fluid.uiOptions.layoutControls.produceTree",
  21249. resources : {
  21250. template : "{templateLoader}.resources.layoutControls"
  21251. }
  21252. });
  21253. fluid.uiOptions.layoutControls.produceTree = function (that) {
  21254. var tree = {};
  21255. for (var item in that.model.selections) {
  21256. if (item === "layout" || item === "toc") {
  21257. tree[item] = "${selections." + item + "}"
  21258. }
  21259. }
  21260. return tree
  21261. };
  21262. fluid.defaults("fluid.uiOptions.linksControls", {
  21263. gradeNames : ["fluid.rendererComponent", "autoInit"],
  21264. selectors : {
  21265. links : ".flc-uiOptions-links",
  21266. inputsLarger : ".flc-uiOptions-inputs-larger"
  21267. },
  21268. events : {
  21269. onUIOptionsRefresh : null
  21270. },
  21271. listeners : {
  21272. onUIOptionsRefresh : "{linksControls}.refreshView"
  21273. },
  21274. preInitFunction : "fluid.uiOptions.lateRefreshViewBinder",
  21275. finalInitFunction : "fluid.uiOptions.controlsFinalInit",
  21276. produceTree : "fluid.uiOptions.linksControls.produceTree",
  21277. resources : {
  21278. template : "{templateLoader}.resources.linksControls"
  21279. }
  21280. });
  21281. fluid.uiOptions.linksControls.produceTree = function (that) {
  21282. var tree = {};
  21283. for (var item in that.model.selections) {
  21284. if (item === "links" || item === "inputsLarger") {
  21285. tree[item] = "${selections." + item + "}"
  21286. }
  21287. }
  21288. return tree
  21289. };
  21290. fluid.defaults("fluid.uiOptions.preview", {
  21291. gradeNames : ["fluid.viewComponent", "autoInit"],
  21292. components : {
  21293. enhancer : {
  21294. type : "fluid.uiEnhancer",
  21295. createOnEvent : "onReady",
  21296. options : {
  21297. settingsStore : {
  21298. type : "fluid.uiEnhancer.tempStore"
  21299. }
  21300. }
  21301. },
  21302. eventBinder : {
  21303. type : "fluid.uiOptions.preview.eventBinder",
  21304. createOnEvent : "onReady"
  21305. },
  21306. templateLoader : "{templateLoader}"
  21307. },
  21308. invokers : {
  21309. updateModel : {
  21310. funcName : "fluid.uiOptions.preview.updateModel",
  21311. args : ["{preview}", "{uiOptions}.model.selections"]
  21312. }
  21313. },
  21314. finalInitFunction : "fluid.uiOptions.preview.finalInit",
  21315. events : {
  21316. onReady : null
  21317. },
  21318. templateUrl : "%prefix/UIOptionsPreview.html"
  21319. });
  21320. fluid.uiOptions.preview.updateModel = function (that, selections) {
  21321. setTimeout(function () {
  21322. if (that.enhancer) {
  21323. that.enhancer.updateModel(selections)
  21324. }
  21325. }, 0)
  21326. };
  21327. fluid.uiOptions.preview.finalInit = function (that) {
  21328. var templateUrl = that.templateLoader.transformURL(that.options.templateUrl);
  21329. that.container.load(function () {
  21330. that.enhancerContainer = $("body", that.container.contents());
  21331. that.events.onReady.fire()
  21332. });
  21333. that.container.attr("src", templateUrl)
  21334. };
  21335. fluid.demands("fluid.uiEnhancer", "fluid.uiOptions.preview", {
  21336. funcName : "fluid.uiEnhancer",
  21337. args : ["{preview}.enhancerContainer", "{options}"]
  21338. });
  21339. fluid.defaults("fluid.uiOptions.preview.eventBinder", {
  21340. gradeNames : ["fluid.eventedComponent", "autoInit"]
  21341. });
  21342. fluid.demands("fluid.uiOptions.preview.eventBinder", ["fluid.uiOptions.preview", "fluid.uiOptions"], {
  21343. options : {
  21344. listeners : {
  21345. "{uiOptions}.events.modelChanged" : "{preview}.updateModel"
  21346. }
  21347. }
  21348. })
  21349. })(jQuery, fluid_1_4);
  21350. var fluid_1_4 = fluid_1_4 || {};
  21351. (function ($, fluid) {
  21352. fluid.defaults("fluid.uiOptions.fatPanelEventBinder", {
  21353. gradeNames : ["fluid.eventedComponent", "autoInit"],
  21354. finalInitFunction : "fluid.uiOptions.fatPanelEventBinder.finalInit",
  21355. components : {
  21356. uiOptionsLoader : {
  21357. type : "fluid.uiOptions.loader"
  21358. },
  21359. slidingPanel : {
  21360. type : "fluid.slidingPanel"
  21361. }
  21362. }
  21363. });
  21364. fluid.defaults("fluid.uiOptions.fatPanelEventBinder.binder", {
  21365. gradeNames : ["fluid.eventedComponent", "autoInit"]
  21366. });
  21367. fluid.registerNamespace("fluid.dom");
  21368. fluid.dom.getDocumentHeight = function (dokkument) {
  21369. var body = $("body", dokkument)[0];
  21370. return body.offsetHeight
  21371. };
  21372. fluid.uiOptions.fatPanelEventBinder.updateView = function (uiOptions) {
  21373. uiOptions.uiEnhancer.updateFromSettingsStore();
  21374. uiOptions.events.onSignificantDOMChange.fire()
  21375. };
  21376. fluid.uiOptions.fatPanelEventBinder.bindLateEvents = function (uiOptions, eventBinder, fatPanel) {
  21377. eventBinder.uiOptions = uiOptions;
  21378. uiOptions.events.modelChanged.addListener(function (model) {
  21379. eventBinder.uiEnhancer.updateModel(model.selections);
  21380. uiOptions.save()
  21381. });
  21382. uiOptions.events.onReset.addListener(function (uiOptions) {
  21383. fluid.uiOptions.fatPanelEventBinder.updateView(uiOptions)
  21384. });
  21385. uiOptions.events.onSignificantDOMChange.addListener(function () {
  21386. var dokkument = uiOptions.container[0].ownerDocument;
  21387. var height = fluid.dom.getDocumentHeight(dokkument);
  21388. var iframe = fatPanel.markupRenderer.iframe;
  21389. var attrs = {
  21390. height : height + 15
  21391. };
  21392. iframe.animate(attrs, 400)
  21393. });
  21394. fatPanel.slidingPanel.events.afterPanelHide.addListener(function () {
  21395. fatPanel.markupRenderer.iframe.height(0)
  21396. })
  21397. };
  21398. fluid.uiOptions.fatPanelEventBinder.finalInit = function (that) {
  21399. that.slidingPanel.events.afterPanelShow.addListener(function () {
  21400. fluid.uiOptions.fatPanelEventBinder.updateView(that.uiOptions)
  21401. })
  21402. };
  21403. fluid.uiOptions.fatPanelEventBinder.showPanel = function (panel, callback) {
  21404. panel.show();
  21405. setTimeout(callback, 1)
  21406. };
  21407. fluid.defaults("fluid.uiOptions.fatPanel", {
  21408. gradeNames : ["fluid.viewComponent"],
  21409. selectors : {
  21410. iframe : ".flc-uiOptions-iframe"
  21411. },
  21412. relativePrefix : "./",
  21413. components : {
  21414. slidingPanel : {
  21415. type : "fluid.slidingPanel",
  21416. container : "{fatPanel}.container",
  21417. options : {
  21418. invokers : {
  21419. operateShow : {
  21420. funcName : "fluid.uiOptions.fatPanelEventBinder.showPanel"
  21421. }
  21422. }
  21423. },
  21424. createOnEvent : "afterRender"
  21425. },
  21426. markupRenderer : {
  21427. type : "fluid.uiOptions.renderIframe",
  21428. container : "{fatPanel}.dom.iframe",
  21429. options : {
  21430. markupProps : {
  21431. src : "%prefix/FatPanelUIOptionsFrame.html"
  21432. },
  21433. events : {
  21434. afterRender : "{fatPanel}.events.afterRender"
  21435. }
  21436. }
  21437. },
  21438. uiEnhancer : "{uiEnhancer}",
  21439. eventBinder : {
  21440. type : "fluid.uiOptions.fatPanelEventBinder",
  21441. options : {
  21442. components : {
  21443. uiEnhancer : "{fatPanel}.uiEnhancer",
  21444. uiOptionsLoader : "{fatPanel}.bridge.uiOptionsLoader",
  21445. slidingPanel : "{fatPanel}.slidingPanel",
  21446. binder : {
  21447. type : "fluid.uiOptions.fatPanelEventBinder.binder",
  21448. priority : "last",
  21449. options : {
  21450. events : {
  21451. onUIOptionsComponentReady : {
  21452. event : "{uiOptionsLoader}.events.onUIOptionsComponentReady",
  21453. args : ["{arguments}.0", "{fluid.uiOptions.fatPanelEventBinder}", "{fatPanel}"]
  21454. }
  21455. },
  21456. listeners : {
  21457. onUIOptionsComponentReady : fluid.uiOptions.fatPanelEventBinder.bindLateEvents
  21458. }
  21459. }
  21460. }
  21461. }
  21462. },
  21463. createOnEvent : "afterRender",
  21464. priority : "last"
  21465. },
  21466. bridge : {
  21467. type : "fluid.uiOptions.bridge",
  21468. createOnEvent : "afterRender",
  21469. priority : "first",
  21470. options : {
  21471. components : {
  21472. uiEnhancer : "{fatPanel}.uiEnhancer",
  21473. markupRenderer : "{fatPanel}.markupRenderer"
  21474. }
  21475. }
  21476. }
  21477. },
  21478. uiOptionsTransform : {
  21479. transformer : "fluid.uiOptions.mapOptions",
  21480. config : {
  21481. "*.slidingPanel" : "slidingPanel",
  21482. "*.markupRenderer" : "markupRenderer",
  21483. "*.markupRenderer.options.prefix" : "prefix",
  21484. "*.eventBinder" : "eventBinder",
  21485. "selectors.iframe" : "iframe",
  21486. "*.bridge.options.templateLoader" : "templateLoader",
  21487. "*.bridge.options.prefix" : "relativePrefix",
  21488. "*.bridge.options.uiOptionsLoader" : "uiOptionsLoader",
  21489. "*.bridge.options.uiOptions" : "uiOptions",
  21490. "*.bridge.options.textControls" : "textControls",
  21491. "*.bridge.options.layoutControls" : "layoutControls",
  21492. "*.bridge.options.linksControls" : "linksControls",
  21493. "*.bridge.options.uiEnhancer" : "uiEnhancer"
  21494. }
  21495. },
  21496. events : {
  21497. afterRender : null
  21498. }
  21499. });
  21500. fluid.defaults("fluid.uiOptions.renderIframe", {
  21501. gradeNames : ["fluid.viewComponent", "autoInit"],
  21502. finalInitFunction : "fluid.uiOptions.renderIframe.finalInit",
  21503. events : {
  21504. afterRender : null
  21505. },
  21506. styles : {
  21507. containerFlex : "fl-container-flex",
  21508. container : "fl-uiOptions-fatPanel-iframe"
  21509. },
  21510. prefix : "./",
  21511. markupProps : {
  21512. style : "overflow-x:hidden; overflow-y:auto;",
  21513. "class" : "flc-iframe",
  21514. src : "%prefix/uiOptionsIframe.html"
  21515. }
  21516. });
  21517. fluid.uiOptions.renderIframe.finalInit = function (that) {
  21518. var styles = that.options.styles;
  21519. that.options.markupProps.src = fluid.stringTemplate(that.options.markupProps.src, {
  21520. "prefix/" : that.options.prefix
  21521. });
  21522. that.iframeSrc = that.options.markupProps.src;
  21523. that.iframe = $("<iframe/>");
  21524. that.iframe.load(function () {
  21525. that.events.afterRender.fire()
  21526. });
  21527. that.iframe.attr(that.options.markupProps);
  21528. that.iframe.addClass(styles.containerFlex);
  21529. that.iframe.addClass(styles.container);
  21530. that.iframe.appendTo(that.container)
  21531. };
  21532. fluid.defaults("fluid.uiOptions.bridge", {
  21533. gradeNames : ["fluid.littleComponent", "autoInit"],
  21534. finalInitFunction : "fluid.uiOptions.bridge.finalInit",
  21535. iframe : null
  21536. });
  21537. fluid.uiOptions.tabSelectRelay = function (uiOptions) {
  21538. uiOptions.events.onSignificantDOMChange.fire()
  21539. };
  21540. fluid.defaults("fluid.uiOptions.FatPanelOtherWorldLoader", {
  21541. gradeNames : ["fluid.uiOptions.inline", "autoInit"],
  21542. derivedDefaults : {
  21543. uiOptions : {
  21544. options : {
  21545. events : {
  21546. onSignificantDOMChange : null
  21547. },
  21548. components : {
  21549. uiEnhancer : {
  21550. type : "fluid.uiEnhancer",
  21551. container : "body",
  21552. priority : "first",
  21553. options : {
  21554. tocTemplate : "../../tableOfContents/html/TableOfContents.html"
  21555. }
  21556. },
  21557. settingsStore : "{uiEnhancer}.settingsStore",
  21558. preview : {
  21559. type : "fluid.emptySubcomponent"
  21560. },
  21561. tabs : {
  21562. type : "fluid.tabs",
  21563. container : "body",
  21564. createOnEvent : "onUIOptionsComponentReady",
  21565. options : {
  21566. events : {
  21567. boiledTabShow : {
  21568. event : "tabsshow",
  21569. args : ["{uiOptions}"]
  21570. }
  21571. },
  21572. listeners : {
  21573. boiledTabShow : fluid.uiOptions.tabSelectRelay
  21574. }
  21575. }
  21576. }
  21577. }
  21578. }
  21579. }
  21580. },
  21581. uiOptionsTransform : {
  21582. config : {
  21583. "!*.uiOptionsLoader.*.uiOptions.*.uiEnhancer.options" : "uiEnhancer.options"
  21584. }
  21585. }
  21586. });
  21587. fluid.uiOptions.bridge.finalInit = function (that) {
  21588. var iframe = that.markupRenderer.iframe;
  21589. var origPrefix = that.markupRenderer.options.prefix;
  21590. var iframeDoc = iframe.contents();
  21591. var iframeWin = iframe[0].contentWindow;
  21592. var innerFluid = iframeWin.fluid;
  21593. var container = $("body", iframeDoc);
  21594. var outerLocation = window.location.href;
  21595. var iframeLocation = iframeWin.location.href;
  21596. var relativePrefix = fluid.url.computeRelativePrefix(outerLocation, iframeLocation, origPrefix);
  21597. that.options.relativePrefix = relativePrefix;
  21598. var overallOptions = {};
  21599. overallOptions.container = container;
  21600. var bridgeMapping = fluid.defaults("fluid.uiOptions.fatPanel").uiOptionsTransform.config;
  21601. var swappedBridgeMapping = {};
  21602. fluid.each(bridgeMapping, function (value, key) {
  21603. swappedBridgeMapping[value] = key
  21604. });
  21605. var bridgeSymbol = "*.bridge.options";
  21606. fluid.each(swappedBridgeMapping, function (value, key) {
  21607. if (value.indexOf(bridgeSymbol) === 0 && that.options[key]) {
  21608. var keyInOtherWorld = value.substring(bridgeSymbol.length + 1);
  21609. fluid.set(overallOptions, keyInOtherWorld, that.options[key])
  21610. }
  21611. });
  21612. var defaults = fluid.defaults("fluid.uiOptions.FatPanelOtherWorldLoader");
  21613. fluid.set(overallOptions, "uiEnhancer.options", that.uiEnhancer.options.originalUserOptions);
  21614. var mappedOptions = fluid.uiOptions.mapOptions(overallOptions, defaults.uiOptionsTransform.config, defaults.mergePolicy, fluid.copy(defaults.derivedDefaults));
  21615. var component = innerFluid.invokeGlobalFunction("fluid.uiOptions.FatPanelOtherWorldLoader", [container, mappedOptions]);
  21616. that.uiOptionsLoader = component.uiOptionsLoader
  21617. };
  21618. fluid.uiOptions.fatPanel = function (container, options) {
  21619. var defaults = fluid.defaults("fluid.uiOptions.fatPanel");
  21620. var config = defaults.uiOptionsTransform.config;
  21621. var mappedOptions = fluid.uiOptions.mapOptions(options, config, defaults.mergePolicy);
  21622. var that = fluid.initView("fluid.uiOptions.fatPanel", container, mappedOptions);
  21623. fluid.initDependents(that);
  21624. return that
  21625. }
  21626. })(jQuery, fluid_1_4);
  21627. var fluid_1_4 = fluid_1_4 || {};
  21628. (function ($, fluid) {
  21629. fluid.defaults("fluid.uiOptions.fullNoPreview", {
  21630. gradeNames : ["fluid.uiOptions.inline"],
  21631. container : "{fullNoPreview}.container",
  21632. derivedDefaults : {
  21633. templateLoader : {
  21634. options : {
  21635. templates : {
  21636. uiOptions : "%prefix/FullNoPreviewUIOptions.html"
  21637. }
  21638. }
  21639. },
  21640. uiOptions : {
  21641. options : {
  21642. components : {
  21643. preview : {
  21644. type : "fluid.emptySubcomponent"
  21645. }
  21646. },
  21647. listeners : {
  21648. onReset : function (uiOptions) {
  21649. uiOptions.save()
  21650. }
  21651. }
  21652. }
  21653. }
  21654. }
  21655. });
  21656. fluid.uiOptions.inline.makeCreator("fluid.uiOptions.fullNoPreview", fluid.identity)
  21657. })(jQuery, fluid_1_4);
  21658. var fluid_1_4 = fluid_1_4 || {};
  21659. (function ($, fluid) {
  21660. fluid.defaults("fluid.uiOptions.fullPreview", {
  21661. gradeNames : ["fluid.uiOptions.inline"],
  21662. container : "{fullPreview}.container",
  21663. uiOptionsTransform : {
  21664. config : {
  21665. "!*.uiOptionsLoader.*.uiOptions.*.preview.*.enhancer.options" : "outerPreviewEnhancerOptions"
  21666. }
  21667. },
  21668. derivedDefaults : {
  21669. templateLoader : {
  21670. options : {
  21671. templates : {
  21672. uiOptions : "%prefix/FullPreviewUIOptions.html"
  21673. }
  21674. }
  21675. }
  21676. }
  21677. });
  21678. fluid.uiOptions.inline.makeCreator("fluid.uiOptions.fullPreview", function (options) {
  21679. var enhancerOptions = fluid.get(fluid, "staticEnvironment.uiEnhancer.options.originalUserOptions");
  21680. options.outerPreviewEnhancerOptions = enhancerOptions;
  21681. return options
  21682. })
  21683. })(jQuery, fluid_1_4);
  21684. var fluid_1_4 = fluid_1_4 || {};
  21685. (function ($, fluid) {
  21686. fluid.defaults("fluid.slidingPanel", {
  21687. gradeNames : ["fluid.viewComponent", "autoInit"],
  21688. selectors : {
  21689. panel : ".flc-slidingPanel-panel",
  21690. toggleButton : ".flc-slidingPanel-toggleButton"
  21691. },
  21692. strings : {
  21693. showText : "+ Show Display Preferences",
  21694. hideText : "- Hide"
  21695. },
  21696. events : {
  21697. onPanelHide : null,
  21698. onPanelShow : null,
  21699. afterPanelHide : null,
  21700. afterPanelShow : null
  21701. },
  21702. finalInitFunction : "fluid.slidingPanel.finalInit",
  21703. invokers : {
  21704. operateHide : "fluid.slidingPanel.slideUp",
  21705. operateShow : "fluid.slidingPanel.slideDown"
  21706. },
  21707. hideByDefault : true
  21708. });
  21709. fluid.slidingPanel.slideUp = function (element, callback, duration) {
  21710. $(element).slideUp(duration || "400", callback)
  21711. };
  21712. fluid.slidingPanel.slideDown = function (element, callback, duration) {
  21713. $(element).slideDown(duration || "400", callback)
  21714. };
  21715. fluid.slidingPanel.finalInit = function (that) {
  21716. that.showPanel = function () {
  21717. that.events.onPanelShow.fire(that);
  21718. that.locate("toggleButton").text(that.options.strings.hideText);
  21719. that.operateShow(that.locate("panel"), that.events.afterPanelShow.fire)
  21720. };
  21721. that.hidePanel = function () {
  21722. that.events.onPanelHide.fire(that);
  21723. that.locate("toggleButton").text(that.options.strings.showText);
  21724. that.operateHide(that.locate("panel"), that.events.afterPanelHide.fire)
  21725. };
  21726. that.togglePanel = function () {
  21727. if (that.locate("panel").is(":hidden")) {
  21728. that.showPanel()
  21729. } else {
  21730. that.hidePanel()
  21731. }
  21732. };
  21733. that.setPanelHeight = function (newHeight) {
  21734. that.locate("panel").height(newHeight)
  21735. };
  21736. that.locate("toggleButton").click(that.togglePanel);
  21737. if (that.options.hideByDefault) {
  21738. that.locate("toggleButton").text(that.options.strings.showText);
  21739. that.locate("panel").hide()
  21740. }
  21741. }
  21742. })(jQuery, fluid_1_4);
  21743. (function ($) {
  21744. var $scrollTo = $.scrollTo = function (target, duration, settings) {
  21745. $(window).scrollTo(target, duration, settings)
  21746. };
  21747. $scrollTo.defaults = {
  21748. axis : "xy",
  21749. duration : parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
  21750. };
  21751. $scrollTo.window = function (scope) {
  21752. return $(window)._scrollable()
  21753. };
  21754. $.fn._scrollable = function () {
  21755. return this.map(function () {
  21756. var elem = this,
  21757. isWin = !elem.nodeName || $.inArray(elem.nodeName.toLowerCase(), ["iframe", "#document", "html", "body"]) != -1;
  21758. if (!isWin) {
  21759. return elem
  21760. }
  21761. var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
  21762. return $.browser.safari || doc.compatMode == "BackCompat" ? doc.body : doc.documentElement
  21763. })
  21764. };
  21765. $.fn.scrollTo = function (target, duration, settings) {
  21766. if (typeof duration == "object") {
  21767. settings = duration;
  21768. duration = 0
  21769. }
  21770. if (typeof settings == "function") {
  21771. settings = {
  21772. onAfter : settings
  21773. }
  21774. }
  21775. if (target == "max") {
  21776. target = 9000000000
  21777. }
  21778. settings = $.extend({}, $scrollTo.defaults, settings);
  21779. duration = duration || settings.speed || settings.duration;
  21780. settings.queue = settings.queue && settings.axis.length > 1;
  21781. if (settings.queue) {
  21782. duration /= 2
  21783. }
  21784. settings.offset = both(settings.offset);
  21785. settings.over = both(settings.over);
  21786. return this._scrollable().each(function () {
  21787. var elem = this,
  21788. $elem = $(elem),
  21789. targ = target,
  21790. toff,
  21791. attr = {},
  21792. win = $elem.is("html,body");
  21793. switch (typeof targ) {
  21794. case "number":
  21795. case "string":
  21796. if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
  21797. targ = both(targ);
  21798. break
  21799. }
  21800. targ = $(targ, this);
  21801. case "object":
  21802. if (targ.is || targ.style) {
  21803. toff = (targ = $(targ)).offset()
  21804. }
  21805. }
  21806. $.each(settings.axis.split(""), function (i, axis) {
  21807. var Pos = axis == "x" ? "Left" : "Top",
  21808. pos = Pos.toLowerCase(),
  21809. key = "scroll" + Pos,
  21810. old = elem[key],
  21811. max = $scrollTo.max(elem, axis);
  21812. if (toff) {
  21813. attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]);
  21814. if (settings.margin) {
  21815. attr[key] -= parseInt(targ.css("margin" + Pos)) || 0;
  21816. attr[key] -= parseInt(targ.css("border" + Pos + "Width")) || 0
  21817. }
  21818. attr[key] += settings.offset[pos] || 0;
  21819. if (settings.over[pos]) {
  21820. attr[key] += targ[axis == "x" ? "width" : "height"]() * settings.over[pos]
  21821. }
  21822. } else {
  21823. var val = targ[pos];
  21824. attr[key] = val.slice && val.slice(-1) == "%" ? parseFloat(val) / 100 * max : val
  21825. }
  21826. if (/^\d+$/.test(attr[key])) {
  21827. attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max)
  21828. }
  21829. if (!i && settings.queue) {
  21830. if (old != attr[key]) {
  21831. animate(settings.onAfterFirst)
  21832. }
  21833. delete attr[key]
  21834. }
  21835. });
  21836. animate(settings.onAfter);
  21837. function animate(callback) {
  21838. $elem.animate(attr, duration, settings.easing, callback && function () {
  21839. callback.call(this, target, settings)
  21840. })
  21841. }
  21842. }).end()
  21843. };
  21844. $scrollTo.max = function (elem, axis) {
  21845. var Dim = axis == "x" ? "Width" : "Height",
  21846. scroll = "scroll" + Dim;
  21847. if (!$(elem).is("html,body")) {
  21848. return elem[scroll] - $(elem)[Dim.toLowerCase()]()
  21849. }
  21850. var size = "client" + Dim,
  21851. html = elem.ownerDocument.documentElement,
  21852. body = elem.ownerDocument.body;
  21853. return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size])
  21854. };
  21855. function both(val) {
  21856. return typeof val == "object" ? val : {
  21857. top : val,
  21858. left : val
  21859. }
  21860. }
  21861. })(jQuery);
  21862. /* SWFObject v2.2 <http://code.google.com/p/swfobject/>
  21863. is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  21864. */
  21865. var swfobject = function () {
  21866. var UNDEF = "undefined",
  21867. OBJECT = "object",
  21868. SHOCKWAVE_FLASH = "Shockwave Flash",
  21869. SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
  21870. FLASH_MIME_TYPE = "application/x-shockwave-flash",
  21871. EXPRESS_INSTALL_ID = "SWFObjectExprInst",
  21872. ON_READY_STATE_CHANGE = "onreadystatechange",
  21873. win = window,
  21874. doc = document,
  21875. nav = navigator,
  21876. plugin = false,
  21877. domLoadFnArr = [main],
  21878. regObjArr = [],
  21879. objIdArr = [],
  21880. listenersArr = [],
  21881. storedAltContent,
  21882. storedAltContentId,
  21883. storedCallbackFn,
  21884. storedCallbackObj,
  21885. isDomLoaded = false,
  21886. isExpressInstallActive = false,
  21887. dynamicStylesheet,
  21888. dynamicStylesheetMedia,
  21889. autoHideShow = true,
  21890. ua = function () {
  21891. var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
  21892. u = nav.userAgent.toLowerCase(),
  21893. p = nav.platform.toLowerCase(),
  21894. windows = p ? /win/.test(p) : /win/.test(u),
  21895. mac = p ? /mac/.test(p) : /mac/.test(u),
  21896. webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false,
  21897. ie = ! + "\v1",
  21898. playerVersion = [0, 0, 0],
  21899. d = null;
  21900. if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
  21901. d = nav.plugins[SHOCKWAVE_FLASH].description;
  21902. if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) {
  21903. plugin = true;
  21904. ie = false;
  21905. d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
  21906. playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
  21907. playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
  21908. playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0
  21909. }
  21910. } else {
  21911. if (typeof win.ActiveXObject != UNDEF) {
  21912. try {
  21913. var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
  21914. if (a) {
  21915. d = a.GetVariable("$version");
  21916. if (d) {
  21917. ie = true;
  21918. d = d.split(" ")[1].split(",");
  21919. playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]
  21920. }
  21921. }
  21922. } catch (e) {}
  21923. }
  21924. }
  21925. return {
  21926. w3 : w3cdom,
  21927. pv : playerVersion,
  21928. wk : webkit,
  21929. ie : ie,
  21930. win : windows,
  21931. mac : mac
  21932. }
  21933. }
  21934. (),
  21935. onDomLoad = function () {
  21936. if (!ua.w3) {
  21937. return
  21938. }
  21939. if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) {
  21940. callDomLoadFunctions()
  21941. }
  21942. if (!isDomLoaded) {
  21943. if (typeof doc.addEventListener != UNDEF) {
  21944. doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false)
  21945. }
  21946. if (ua.ie && ua.win) {
  21947. doc.attachEvent(ON_READY_STATE_CHANGE, function () {
  21948. if (doc.readyState == "complete") {
  21949. doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
  21950. callDomLoadFunctions()
  21951. }
  21952. });
  21953. if (win == top) {
  21954. (function () {
  21955. if (isDomLoaded) {
  21956. return
  21957. }
  21958. try {
  21959. doc.documentElement.doScroll("left")
  21960. } catch (e) {
  21961. setTimeout(arguments.callee, 0);
  21962. return
  21963. }
  21964. callDomLoadFunctions()
  21965. })()
  21966. }
  21967. }
  21968. if (ua.wk) {
  21969. (function () {
  21970. if (isDomLoaded) {
  21971. return
  21972. }
  21973. if (!/loaded|complete/.test(doc.readyState)) {
  21974. setTimeout(arguments.callee, 0);
  21975. return
  21976. }
  21977. callDomLoadFunctions()
  21978. })()
  21979. }
  21980. addLoadEvent(callDomLoadFunctions)
  21981. }
  21982. }
  21983. ();
  21984. function callDomLoadFunctions() {
  21985. if (isDomLoaded) {
  21986. return
  21987. }
  21988. try {
  21989. var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
  21990. t.parentNode.removeChild(t)
  21991. } catch (e) {
  21992. return
  21993. }
  21994. isDomLoaded = true;
  21995. var dl = domLoadFnArr.length;
  21996. for (var i = 0; i < dl; i++) {
  21997. domLoadFnArr[i]()
  21998. }
  21999. }
  22000. function addDomLoadEvent(fn) {
  22001. if (isDomLoaded) {
  22002. fn()
  22003. } else {
  22004. domLoadFnArr[domLoadFnArr.length] = fn
  22005. }
  22006. }
  22007. function addLoadEvent(fn) {
  22008. if (typeof win.addEventListener != UNDEF) {
  22009. win.addEventListener("load", fn, false)
  22010. } else {
  22011. if (typeof doc.addEventListener != UNDEF) {
  22012. doc.addEventListener("load", fn, false)
  22013. } else {
  22014. if (typeof win.attachEvent != UNDEF) {
  22015. addListener(win, "onload", fn)
  22016. } else {
  22017. if (typeof win.onload == "function") {
  22018. var fnOld = win.onload;
  22019. win.onload = function () {
  22020. fnOld();
  22021. fn()
  22022. }
  22023. } else {
  22024. win.onload = fn
  22025. }
  22026. }
  22027. }
  22028. }
  22029. }
  22030. function main() {
  22031. if (plugin) {
  22032. testPlayerVersion()
  22033. } else {
  22034. matchVersions()
  22035. }
  22036. }
  22037. function testPlayerVersion() {
  22038. var b = doc.getElementsByTagName("body")[0];
  22039. var o = createElement(OBJECT);
  22040. o.setAttribute("type", FLASH_MIME_TYPE);
  22041. var t = b.appendChild(o);
  22042. if (t) {
  22043. var counter = 0;
  22044. (function () {
  22045. if (typeof t.GetVariable != UNDEF) {
  22046. var d = t.GetVariable("$version");
  22047. if (d) {
  22048. d = d.split(" ")[1].split(",");
  22049. ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]
  22050. }
  22051. } else {
  22052. if (counter < 10) {
  22053. counter++;
  22054. setTimeout(arguments.callee, 10);
  22055. return
  22056. }
  22057. }
  22058. b.removeChild(o);
  22059. t = null;
  22060. matchVersions()
  22061. })()
  22062. } else {
  22063. matchVersions()
  22064. }
  22065. }
  22066. function matchVersions() {
  22067. var rl = regObjArr.length;
  22068. if (rl > 0) {
  22069. for (var i = 0; i < rl; i++) {
  22070. var id = regObjArr[i].id;
  22071. var cb = regObjArr[i].callbackFn;
  22072. var cbObj = {
  22073. success : false,
  22074. id : id
  22075. };
  22076. if (ua.pv[0] > 0) {
  22077. var obj = getElementById(id);
  22078. if (obj) {
  22079. if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) {
  22080. setVisibility(id, true);
  22081. if (cb) {
  22082. cbObj.success = true;
  22083. cbObj.ref = getObjectById(id);
  22084. cb(cbObj)
  22085. }
  22086. } else {
  22087. if (regObjArr[i].expressInstall && canExpressInstall()) {
  22088. var att = {};
  22089. att.data = regObjArr[i].expressInstall;
  22090. att.width = obj.getAttribute("width") || "0";
  22091. att.height = obj.getAttribute("height") || "0";
  22092. if (obj.getAttribute("class")) {
  22093. att.styleclass = obj.getAttribute("class")
  22094. }
  22095. if (obj.getAttribute("align")) {
  22096. att.align = obj.getAttribute("align")
  22097. }
  22098. var par = {};
  22099. var p = obj.getElementsByTagName("param");
  22100. var pl = p.length;
  22101. for (var j = 0; j < pl; j++) {
  22102. if (p[j].getAttribute("name").toLowerCase() != "movie") {
  22103. par[p[j].getAttribute("name")] = p[j].getAttribute("value")
  22104. }
  22105. }
  22106. showExpressInstall(att, par, id, cb)
  22107. } else {
  22108. displayAltContent(obj);
  22109. if (cb) {
  22110. cb(cbObj)
  22111. }
  22112. }
  22113. }
  22114. }
  22115. } else {
  22116. setVisibility(id, true);
  22117. if (cb) {
  22118. var o = getObjectById(id);
  22119. if (o && typeof o.SetVariable != UNDEF) {
  22120. cbObj.success = true;
  22121. cbObj.ref = o
  22122. }
  22123. cb(cbObj)
  22124. }
  22125. }
  22126. }
  22127. }
  22128. }
  22129. function getObjectById(objectIdStr) {
  22130. var r = null;
  22131. var o = getElementById(objectIdStr);
  22132. if (o && o.nodeName == "OBJECT") {
  22133. if (typeof o.SetVariable != UNDEF) {
  22134. r = o
  22135. } else {
  22136. var n = o.getElementsByTagName(OBJECT)[0];
  22137. if (n) {
  22138. r = n
  22139. }
  22140. }
  22141. }
  22142. return r
  22143. }
  22144. function canExpressInstall() {
  22145. return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312)
  22146. }
  22147. function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
  22148. isExpressInstallActive = true;
  22149. storedCallbackFn = callbackFn || null;
  22150. storedCallbackObj = {
  22151. success : false,
  22152. id : replaceElemIdStr
  22153. };
  22154. var obj = getElementById(replaceElemIdStr);
  22155. if (obj) {
  22156. if (obj.nodeName == "OBJECT") {
  22157. storedAltContent = abstractAltContent(obj);
  22158. storedAltContentId = null
  22159. } else {
  22160. storedAltContent = obj;
  22161. storedAltContentId = replaceElemIdStr
  22162. }
  22163. att.id = EXPRESS_INSTALL_ID;
  22164. if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) {
  22165. att.width = "310"
  22166. }
  22167. if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) {
  22168. att.height = "137"
  22169. }
  22170. doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
  22171. var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
  22172. fv = "MMredirectURL=" + win.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
  22173. if (typeof par.flashvars != UNDEF) {
  22174. par.flashvars += "&" + fv
  22175. } else {
  22176. par.flashvars = fv
  22177. }
  22178. if (ua.ie && ua.win && obj.readyState != 4) {
  22179. var newObj = createElement("div");
  22180. replaceElemIdStr += "SWFObjectNew";
  22181. newObj.setAttribute("id", replaceElemIdStr);
  22182. obj.parentNode.insertBefore(newObj, obj);
  22183. obj.style.display = "none";
  22184. (function () {
  22185. if (obj.readyState == 4) {
  22186. obj.parentNode.removeChild(obj)
  22187. } else {
  22188. setTimeout(arguments.callee, 10)
  22189. }
  22190. })()
  22191. }
  22192. createSWF(att, par, replaceElemIdStr)
  22193. }
  22194. }
  22195. function displayAltContent(obj) {
  22196. if (ua.ie && ua.win && obj.readyState != 4) {
  22197. var el = createElement("div");
  22198. obj.parentNode.insertBefore(el, obj);
  22199. el.parentNode.replaceChild(abstractAltContent(obj), el);
  22200. obj.style.display = "none";
  22201. (function () {
  22202. if (obj.readyState == 4) {
  22203. obj.parentNode.removeChild(obj)
  22204. } else {
  22205. setTimeout(arguments.callee, 10)
  22206. }
  22207. })()
  22208. } else {
  22209. obj.parentNode.replaceChild(abstractAltContent(obj), obj)
  22210. }
  22211. }
  22212. function abstractAltContent(obj) {
  22213. var ac = createElement("div");
  22214. if (ua.win && ua.ie) {
  22215. ac.innerHTML = obj.innerHTML
  22216. } else {
  22217. var nestedObj = obj.getElementsByTagName(OBJECT)[0];
  22218. if (nestedObj) {
  22219. var c = nestedObj.childNodes;
  22220. if (c) {
  22221. var cl = c.length;
  22222. for (var i = 0; i < cl; i++) {
  22223. if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
  22224. ac.appendChild(c[i].cloneNode(true))
  22225. }
  22226. }
  22227. }
  22228. }
  22229. }
  22230. return ac
  22231. }
  22232. function createSWF(attObj, parObj, id) {
  22233. var r,
  22234. el = getElementById(id);
  22235. if (ua.wk && ua.wk < 312) {
  22236. return r
  22237. }
  22238. if (el) {
  22239. if (typeof attObj.id == UNDEF) {
  22240. attObj.id = id
  22241. }
  22242. if (ua.ie && ua.win) {
  22243. var att = "";
  22244. for (var i in attObj) {
  22245. if (attObj[i] != Object.prototype[i]) {
  22246. if (i.toLowerCase() == "data") {
  22247. parObj.movie = attObj[i]
  22248. } else {
  22249. if (i.toLowerCase() == "styleclass") {
  22250. att += ' class="' + attObj[i] + '"'
  22251. } else {
  22252. if (i.toLowerCase() != "classid") {
  22253. att += " " + i + '="' + attObj[i] + '"'
  22254. }
  22255. }
  22256. }
  22257. }
  22258. }
  22259. var par = "";
  22260. for (var j in parObj) {
  22261. if (parObj[j] != Object.prototype[j]) {
  22262. par += '<param name="' + j + '" value="' + parObj[j] + '" />'
  22263. }
  22264. }
  22265. el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + ">" + par + "</object>";
  22266. objIdArr[objIdArr.length] = attObj.id;
  22267. r = getElementById(attObj.id)
  22268. } else {
  22269. var o = createElement(OBJECT);
  22270. o.setAttribute("type", FLASH_MIME_TYPE);
  22271. for (var m in attObj) {
  22272. if (attObj[m] != Object.prototype[m]) {
  22273. if (m.toLowerCase() == "styleclass") {
  22274. o.setAttribute("class", attObj[m])
  22275. } else {
  22276. if (m.toLowerCase() != "classid") {
  22277. o.setAttribute(m, attObj[m])
  22278. }
  22279. }
  22280. }
  22281. }
  22282. for (var n in parObj) {
  22283. if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") {
  22284. createObjParam(o, n, parObj[n])
  22285. }
  22286. }
  22287. el.parentNode.replaceChild(o, el);
  22288. r = o
  22289. }
  22290. }
  22291. return r
  22292. }
  22293. function createObjParam(el, pName, pValue) {
  22294. var p = createElement("param");
  22295. p.setAttribute("name", pName);
  22296. p.setAttribute("value", pValue);
  22297. el.appendChild(p)
  22298. }
  22299. function removeSWF(id) {
  22300. var obj = getElementById(id);
  22301. if (obj && obj.nodeName == "OBJECT") {
  22302. if (ua.ie && ua.win) {
  22303. obj.style.display = "none";
  22304. (function () {
  22305. if (obj.readyState == 4) {
  22306. removeObjectInIE(id)
  22307. } else {
  22308. setTimeout(arguments.callee, 10)
  22309. }
  22310. })()
  22311. } else {
  22312. obj.parentNode.removeChild(obj)
  22313. }
  22314. }
  22315. }
  22316. function removeObjectInIE(id) {
  22317. var obj = getElementById(id);
  22318. if (obj) {
  22319. for (var i in obj) {
  22320. if (typeof obj[i] == "function") {
  22321. obj[i] = null
  22322. }
  22323. }
  22324. obj.parentNode.removeChild(obj)
  22325. }
  22326. }
  22327. function getElementById(id) {
  22328. var el = null;
  22329. try {
  22330. el = doc.getElementById(id)
  22331. } catch (e) {}
  22332. return el
  22333. }
  22334. function createElement(el) {
  22335. return doc.createElement(el)
  22336. }
  22337. function addListener(target, eventType, fn) {
  22338. target.attachEvent(eventType, fn);
  22339. listenersArr[listenersArr.length] = [target, eventType, fn]
  22340. }
  22341. function hasPlayerVersion(rv) {
  22342. var pv = ua.pv,
  22343. v = rv.split(".");
  22344. v[0] = parseInt(v[0], 10);
  22345. v[1] = parseInt(v[1], 10) || 0;
  22346. v[2] = parseInt(v[2], 10) || 0;
  22347. return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false
  22348. }
  22349. function createCSS(sel, decl, media, newStyle) {
  22350. if (ua.ie && ua.mac) {
  22351. return
  22352. }
  22353. var h = doc.getElementsByTagName("head")[0];
  22354. if (!h) {
  22355. return
  22356. }
  22357. var m = (media && typeof media == "string") ? media : "screen";
  22358. if (newStyle) {
  22359. dynamicStylesheet = null;
  22360. dynamicStylesheetMedia = null
  22361. }
  22362. if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
  22363. var s = createElement("style");
  22364. s.setAttribute("type", "text/css");
  22365. s.setAttribute("media", m);
  22366. dynamicStylesheet = h.appendChild(s);
  22367. if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
  22368. dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]
  22369. }
  22370. dynamicStylesheetMedia = m
  22371. }
  22372. if (ua.ie && ua.win) {
  22373. if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
  22374. dynamicStylesheet.addRule(sel, decl)
  22375. }
  22376. } else {
  22377. if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
  22378. dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"))
  22379. }
  22380. }
  22381. }
  22382. function setVisibility(id, isVisible) {
  22383. if (!autoHideShow) {
  22384. return
  22385. }
  22386. var v = isVisible ? "visible" : "hidden";
  22387. if (isDomLoaded && getElementById(id)) {
  22388. getElementById(id).style.visibility = v
  22389. } else {
  22390. createCSS("#" + id, "visibility:" + v)
  22391. }
  22392. }
  22393. function urlEncodeIfNecessary(s) {
  22394. var regex = /[\\\"<>\.;]/;
  22395. var hasBadChars = regex.exec(s) != null;
  22396. return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s
  22397. }
  22398. var cleanup = function () {
  22399. if (ua.ie && ua.win) {
  22400. window.attachEvent("onunload", function () {
  22401. var ll = listenersArr.length;
  22402. for (var i = 0; i < ll; i++) {
  22403. listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2])
  22404. }
  22405. var il = objIdArr.length;
  22406. for (var j = 0; j < il; j++) {
  22407. removeSWF(objIdArr[j])
  22408. }
  22409. for (var k in ua) {
  22410. ua[k] = null
  22411. }
  22412. ua = null;
  22413. for (var l in swfobject) {
  22414. swfobject[l] = null
  22415. }
  22416. swfobject = null
  22417. })
  22418. }
  22419. }
  22420. ();
  22421. return {
  22422. registerObject : function (objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
  22423. if (ua.w3 && objectIdStr && swfVersionStr) {
  22424. var regObj = {};
  22425. regObj.id = objectIdStr;
  22426. regObj.swfVersion = swfVersionStr;
  22427. regObj.expressInstall = xiSwfUrlStr;
  22428. regObj.callbackFn = callbackFn;
  22429. regObjArr[regObjArr.length] = regObj;
  22430. setVisibility(objectIdStr, false)
  22431. } else {
  22432. if (callbackFn) {
  22433. callbackFn({
  22434. success : false,
  22435. id : objectIdStr
  22436. })
  22437. }
  22438. }
  22439. },
  22440. getObjectById : function (objectIdStr) {
  22441. if (ua.w3) {
  22442. return getObjectById(objectIdStr)
  22443. }
  22444. },
  22445. embedSWF : function (swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
  22446. var callbackObj = {
  22447. success : false,
  22448. id : replaceElemIdStr
  22449. };
  22450. if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
  22451. setVisibility(replaceElemIdStr, false);
  22452. addDomLoadEvent(function () {
  22453. widthStr += "";
  22454. heightStr += "";
  22455. var att = {};
  22456. if (attObj && typeof attObj === OBJECT) {
  22457. for (var i in attObj) {
  22458. att[i] = attObj[i]
  22459. }
  22460. }
  22461. att.data = swfUrlStr;
  22462. att.width = widthStr;
  22463. att.height = heightStr;
  22464. var par = {};
  22465. if (parObj && typeof parObj === OBJECT) {
  22466. for (var j in parObj) {
  22467. par[j] = parObj[j]
  22468. }
  22469. }
  22470. if (flashvarsObj && typeof flashvarsObj === OBJECT) {
  22471. for (var k in flashvarsObj) {
  22472. if (typeof par.flashvars != UNDEF) {
  22473. par.flashvars += "&" + k + "=" + flashvarsObj[k]
  22474. } else {
  22475. par.flashvars = k + "=" + flashvarsObj[k]
  22476. }
  22477. }
  22478. }
  22479. if (hasPlayerVersion(swfVersionStr)) {
  22480. var obj = createSWF(att, par, replaceElemIdStr);
  22481. if (att.id == replaceElemIdStr) {
  22482. setVisibility(replaceElemIdStr, true)
  22483. }
  22484. callbackObj.success = true;
  22485. callbackObj.ref = obj
  22486. } else {
  22487. if (xiSwfUrlStr && canExpressInstall()) {
  22488. att.data = xiSwfUrlStr;
  22489. showExpressInstall(att, par, replaceElemIdStr, callbackFn);
  22490. return
  22491. } else {
  22492. setVisibility(replaceElemIdStr, true)
  22493. }
  22494. }
  22495. if (callbackFn) {
  22496. callbackFn(callbackObj)
  22497. }
  22498. })
  22499. } else {
  22500. if (callbackFn) {
  22501. callbackFn(callbackObj)
  22502. }
  22503. }
  22504. },
  22505. switchOffAutoHideShow : function () {
  22506. autoHideShow = false
  22507. },
  22508. ua : ua,
  22509. getFlashPlayerVersion : function () {
  22510. return {
  22511. major : ua.pv[0],
  22512. minor : ua.pv[1],
  22513. release : ua.pv[2]
  22514. }
  22515. },
  22516. hasFlashPlayerVersion : hasPlayerVersion,
  22517. createSWF : function (attObj, parObj, replaceElemIdStr) {
  22518. if (ua.w3) {
  22519. return createSWF(attObj, parObj, replaceElemIdStr)
  22520. } else {
  22521. return undefined
  22522. }
  22523. },
  22524. showExpressInstall : function (att, par, replaceElemIdStr, callbackFn) {
  22525. if (ua.w3 && canExpressInstall()) {
  22526. showExpressInstall(att, par, replaceElemIdStr, callbackFn)
  22527. }
  22528. },
  22529. removeSWF : function (objElemIdStr) {
  22530. if (ua.w3) {
  22531. removeSWF(objElemIdStr)
  22532. }
  22533. },
  22534. createCSS : function (selStr, declStr, mediaStr, newStyleBoolean) {
  22535. if (ua.w3) {
  22536. createCSS(selStr, declStr, mediaStr, newStyleBoolean)
  22537. }
  22538. },
  22539. addDomLoadEvent : addDomLoadEvent,
  22540. addLoadEvent : addLoadEvent,
  22541. getQueryParamValue : function (param) {
  22542. var q = doc.location.search || doc.location.hash;
  22543. if (q) {
  22544. if (/\?/.test(q)) {
  22545. q = q.split("?")[1]
  22546. }
  22547. if (param == null) {
  22548. return urlEncodeIfNecessary(q)
  22549. }
  22550. var pairs = q.split("&");
  22551. for (var i = 0; i < pairs.length; i++) {
  22552. if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
  22553. return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)))
  22554. }
  22555. }
  22556. }
  22557. return ""
  22558. },
  22559. expressInstallCallback : function () {
  22560. if (isExpressInstallActive) {
  22561. var obj = getElementById(EXPRESS_INSTALL_ID);
  22562. if (obj && storedAltContent) {
  22563. obj.parentNode.replaceChild(storedAltContent, obj);
  22564. if (storedAltContentId) {
  22565. setVisibility(storedAltContentId, true);
  22566. if (ua.ie && ua.win) {
  22567. storedAltContent.style.display = "block"
  22568. }
  22569. }
  22570. if (storedCallbackFn) {
  22571. storedCallbackFn(storedCallbackObj)
  22572. }
  22573. }
  22574. isExpressInstallActive = false
  22575. }
  22576. }
  22577. }
  22578. }
  22579. ();
  22580. var SWFUpload;
  22581. if (SWFUpload == undefined) {
  22582. SWFUpload = function (settings) {
  22583. this.initSWFUpload(settings)
  22584. }
  22585. }
  22586. SWFUpload.prototype.initSWFUpload = function (settings) {
  22587. try {
  22588. this.customSettings = {};
  22589. this.settings = settings;
  22590. this.eventQueue = [];
  22591. this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
  22592. this.movieElement = null;
  22593. SWFUpload.instances[this.movieName] = this;
  22594. this.initSettings();
  22595. this.loadFlash();
  22596. this.displayDebugInfo()
  22597. } catch (ex) {
  22598. delete SWFUpload.instances[this.movieName];
  22599. throw ex
  22600. }
  22601. };
  22602. SWFUpload.instances = {};
  22603. SWFUpload.movieCount = 0;
  22604. SWFUpload.version = "2.2.0 2009-03-25";
  22605. SWFUpload.QUEUE_ERROR = {
  22606. QUEUE_LIMIT_EXCEEDED : -100,
  22607. FILE_EXCEEDS_SIZE_LIMIT : -110,
  22608. ZERO_BYTE_FILE : -120,
  22609. INVALID_FILETYPE : -130
  22610. };
  22611. SWFUpload.UPLOAD_ERROR = {
  22612. HTTP_ERROR : -200,
  22613. MISSING_UPLOAD_URL : -210,
  22614. IO_ERROR : -220,
  22615. SECURITY_ERROR : -230,
  22616. UPLOAD_LIMIT_EXCEEDED : -240,
  22617. UPLOAD_FAILED : -250,
  22618. SPECIFIED_FILE_ID_NOT_FOUND : -260,
  22619. FILE_VALIDATION_FAILED : -270,
  22620. FILE_CANCELLED : -280,
  22621. UPLOAD_STOPPED : -290
  22622. };
  22623. SWFUpload.FILE_STATUS = {
  22624. QUEUED : -1,
  22625. IN_PROGRESS : -2,
  22626. ERROR : -3,
  22627. COMPLETE : -4,
  22628. CANCELLED : -5
  22629. };
  22630. SWFUpload.BUTTON_ACTION = {
  22631. SELECT_FILE : -100,
  22632. SELECT_FILES : -110,
  22633. START_UPLOAD : -120
  22634. };
  22635. SWFUpload.CURSOR = {
  22636. ARROW : -1,
  22637. HAND : -2
  22638. };
  22639. SWFUpload.WINDOW_MODE = {
  22640. WINDOW : "window",
  22641. TRANSPARENT : "transparent",
  22642. OPAQUE : "opaque"
  22643. };
  22644. SWFUpload.completeURL = function (url) {
  22645. if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
  22646. return url
  22647. }
  22648. var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
  22649. var indexSlash = window.location.pathname.lastIndexOf("/");
  22650. if (indexSlash <= 0) {
  22651. path = "/"
  22652. } else {
  22653. path = window.location.pathname.substr(0, indexSlash) + "/"
  22654. }
  22655. return path + url
  22656. };
  22657. SWFUpload.prototype.initSettings = function () {
  22658. this.ensureDefault = function (settingName, defaultValue) {
  22659. this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName]
  22660. };
  22661. this.ensureDefault("upload_url", "");
  22662. this.ensureDefault("preserve_relative_urls", false);
  22663. this.ensureDefault("file_post_name", "Filedata");
  22664. this.ensureDefault("post_params", {});
  22665. this.ensureDefault("use_query_string", false);
  22666. this.ensureDefault("requeue_on_error", false);
  22667. this.ensureDefault("http_success", []);
  22668. this.ensureDefault("assume_success_timeout", 0);
  22669. this.ensureDefault("file_types", "*.*");
  22670. this.ensureDefault("file_types_description", "All Files");
  22671. this.ensureDefault("file_size_limit", 0);
  22672. this.ensureDefault("file_upload_limit", 0);
  22673. this.ensureDefault("file_queue_limit", 0);
  22674. this.ensureDefault("flash_url", "swfupload.swf");
  22675. this.ensureDefault("prevent_swf_caching", true);
  22676. this.ensureDefault("button_image_url", "");
  22677. this.ensureDefault("button_width", 1);
  22678. this.ensureDefault("button_height", 1);
  22679. this.ensureDefault("button_text", "");
  22680. this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
  22681. this.ensureDefault("button_text_top_padding", 0);
  22682. this.ensureDefault("button_text_left_padding", 0);
  22683. this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
  22684. this.ensureDefault("button_disabled", false);
  22685. this.ensureDefault("button_placeholder_id", "");
  22686. this.ensureDefault("button_placeholder", null);
  22687. this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
  22688. this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
  22689. this.ensureDefault("debug", false);
  22690. this.settings.debug_enabled = this.settings.debug;
  22691. this.settings.return_upload_start_handler = this.returnUploadStart;
  22692. this.ensureDefault("swfupload_loaded_handler", null);
  22693. this.ensureDefault("file_dialog_start_handler", null);
  22694. this.ensureDefault("file_queued_handler", null);
  22695. this.ensureDefault("file_queue_error_handler", null);
  22696. this.ensureDefault("file_dialog_complete_handler", null);
  22697. this.ensureDefault("upload_start_handler", null);
  22698. this.ensureDefault("upload_progress_handler", null);
  22699. this.ensureDefault("upload_error_handler", null);
  22700. this.ensureDefault("upload_success_handler", null);
  22701. this.ensureDefault("upload_complete_handler", null);
  22702. this.ensureDefault("debug_handler", this.debugMessage);
  22703. this.ensureDefault("custom_settings", {});
  22704. this.customSettings = this.settings.custom_settings;
  22705. if (!!this.settings.prevent_swf_caching) {
  22706. this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime()
  22707. }
  22708. if (!this.settings.preserve_relative_urls) {
  22709. this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
  22710. this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url)
  22711. }
  22712. delete this.ensureDefault
  22713. };
  22714. SWFUpload.prototype.loadFlash = function () {
  22715. var targetElement,
  22716. tempParent;
  22717. if (document.getElementById(this.movieName) !== null) {
  22718. throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"
  22719. }
  22720. targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
  22721. if (targetElement == undefined) {
  22722. throw "Could not find the placeholder element: " + this.settings.button_placeholder_id
  22723. }
  22724. tempParent = document.createElement("div");
  22725. tempParent.innerHTML = this.getFlashHTML();
  22726. targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
  22727. if (window[this.movieName] == undefined) {
  22728. window[this.movieName] = this.getMovieElement()
  22729. }
  22730. };
  22731. SWFUpload.prototype.getFlashHTML = function () {
  22732. return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">', '<param name="wmode" value="', this.settings.button_window_mode, '" />', '<param name="movie" value="', this.settings.flash_url, '" />', '<param name="quality" value="high" />', '<param name="menu" value="false" />', '<param name="allowScriptAccess" value="always" />', '<param name="flashvars" value="' + this.getFlashVars() + '" />', "</object>"].join("")
  22733. };
  22734. SWFUpload.prototype.getFlashVars = function () {
  22735. var paramString = this.buildParamString();
  22736. var httpSuccessString = this.settings.http_success.join(",");
  22737. return ["movieName=", encodeURIComponent(this.movieName), "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url), "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string), "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), "&amp;httpSuccess=", encodeURIComponent(httpSuccessString), "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), "&amp;params=", encodeURIComponent(paramString), "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name), "&amp;fileTypes=", encodeURIComponent(this.settings.file_types), "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled), "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url), "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width), "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height), "&amp;buttonText=", encodeURIComponent(this.settings.button_text), "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), "&amp;buttonAction=", encodeURIComponent(this.settings.button_action), "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled), "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)].join("")
  22738. };
  22739. SWFUpload.prototype.getMovieElement = function () {
  22740. if (this.movieElement == undefined) {
  22741. this.movieElement = document.getElementById(this.movieName)
  22742. }
  22743. if (this.movieElement === null) {
  22744. throw "Could not find Flash element"
  22745. }
  22746. return this.movieElement
  22747. };
  22748. SWFUpload.prototype.buildParamString = function () {
  22749. var postParams = this.settings.post_params;
  22750. var paramStringPairs = [];
  22751. if (typeof(postParams) === "object") {
  22752. for (var name in postParams) {
  22753. if (postParams.hasOwnProperty(name)) {
  22754. paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()))
  22755. }
  22756. }
  22757. }
  22758. return paramStringPairs.join("&amp;")
  22759. };
  22760. SWFUpload.prototype.destroy = function () {
  22761. try {
  22762. this.cancelUpload(null, false);
  22763. var movieElement = null;
  22764. movieElement = this.getMovieElement();
  22765. if (movieElement && typeof(movieElement.CallFunction) === "unknown") {
  22766. for (var i in movieElement) {
  22767. try {
  22768. if (typeof(movieElement[i]) === "function") {
  22769. movieElement[i] = null
  22770. }
  22771. } catch (ex1) {}
  22772. }
  22773. try {
  22774. movieElement.parentNode.removeChild(movieElement)
  22775. } catch (ex) {}
  22776. }
  22777. window[this.movieName] = null;
  22778. SWFUpload.instances[this.movieName] = null;
  22779. delete SWFUpload.instances[this.movieName];
  22780. this.movieElement = null;
  22781. this.settings = null;
  22782. this.customSettings = null;
  22783. this.eventQueue = null;
  22784. this.movieName = null;
  22785. return true
  22786. } catch (ex2) {
  22787. return false
  22788. }
  22789. };
  22790. SWFUpload.prototype.displayDebugInfo = function () {
  22791. this.debug(["---SWFUpload Instance Info---\n", "Version: ", SWFUpload.version, "\n", "Movie Name: ", this.movieName, "\n", "Settings:\n", "\t", "upload_url: ", this.settings.upload_url, "\n", "\t", "flash_url: ", this.settings.flash_url, "\n", "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", "\t", "http_success: ", this.settings.http_success.join(", "), "\n", "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", "\t", "file_post_name: ", this.settings.file_post_name, "\n", "\t", "post_params: ", this.settings.post_params.toString(), "\n", "\t", "file_types: ", this.settings.file_types, "\n", "\t", "file_types_description: ", this.settings.file_types_description, "\n", "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", "\t", "debug: ", this.settings.debug.toString(), "\n", "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", "\t", "button_width: ", this.settings.button_width.toString(), "\n", "\t", "button_height: ", this.settings.button_height.toString(), "\n", "\t", "button_text: ", this.settings.button_text.toString(), "\n", "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", "\t", "button_action: ", this.settings.button_action.toString(), "\n", "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", "Event Handlers:\n", "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"].join(""))
  22792. };
  22793. SWFUpload.prototype.addSetting = function (name, value, default_value) {
  22794. if (value == undefined) {
  22795. return (this.settings[name] = default_value)
  22796. } else {
  22797. return (this.settings[name] = value)
  22798. }
  22799. };
  22800. SWFUpload.prototype.getSetting = function (name) {
  22801. if (this.settings[name] != undefined) {
  22802. return this.settings[name]
  22803. }
  22804. return ""
  22805. };
  22806. SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
  22807. argumentArray = argumentArray || [];
  22808. var movieElement = this.getMovieElement();
  22809. var returnValue,
  22810. returnString;
  22811. try {
  22812. returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + "</invoke>");
  22813. returnValue = eval(returnString)
  22814. } catch (ex) {
  22815. throw "Call to " + functionName + " failed"
  22816. }
  22817. if (returnValue != undefined && typeof returnValue.post === "object") {
  22818. returnValue = this.unescapeFilePostParams(returnValue)
  22819. }
  22820. return returnValue
  22821. };
  22822. SWFUpload.prototype.selectFile = function () {
  22823. this.callFlash("SelectFile")
  22824. };
  22825. SWFUpload.prototype.selectFiles = function () {
  22826. this.callFlash("SelectFiles")
  22827. };
  22828. SWFUpload.prototype.startUpload = function (fileID) {
  22829. this.callFlash("StartUpload", [fileID])
  22830. };
  22831. SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
  22832. if (triggerErrorEvent !== false) {
  22833. triggerErrorEvent = true
  22834. }
  22835. this.callFlash("CancelUpload", [fileID, triggerErrorEvent])
  22836. };
  22837. SWFUpload.prototype.stopUpload = function () {
  22838. this.callFlash("StopUpload")
  22839. };
  22840. SWFUpload.prototype.getStats = function () {
  22841. return this.callFlash("GetStats")
  22842. };
  22843. SWFUpload.prototype.setStats = function (statsObject) {
  22844. this.callFlash("SetStats", [statsObject])
  22845. };
  22846. SWFUpload.prototype.getFile = function (fileID) {
  22847. if (typeof(fileID) === "number") {
  22848. return this.callFlash("GetFileByIndex", [fileID])
  22849. } else {
  22850. return this.callFlash("GetFile", [fileID])
  22851. }
  22852. };
  22853. SWFUpload.prototype.addFileParam = function (fileID, name, value) {
  22854. return this.callFlash("AddFileParam", [fileID, name, value])
  22855. };
  22856. SWFUpload.prototype.removeFileParam = function (fileID, name) {
  22857. this.callFlash("RemoveFileParam", [fileID, name])
  22858. };
  22859. SWFUpload.prototype.setUploadURL = function (url) {
  22860. this.settings.upload_url = url.toString();
  22861. this.callFlash("SetUploadURL", [url])
  22862. };
  22863. SWFUpload.prototype.setPostParams = function (paramsObject) {
  22864. this.settings.post_params = paramsObject;
  22865. this.callFlash("SetPostParams", [paramsObject])
  22866. };
  22867. SWFUpload.prototype.addPostParam = function (name, value) {
  22868. this.settings.post_params[name] = value;
  22869. this.callFlash("SetPostParams", [this.settings.post_params])
  22870. };
  22871. SWFUpload.prototype.removePostParam = function (name) {
  22872. delete this.settings.post_params[name];
  22873. this.callFlash("SetPostParams", [this.settings.post_params])
  22874. };
  22875. SWFUpload.prototype.setFileTypes = function (types, description) {
  22876. this.settings.file_types = types;
  22877. this.settings.file_types_description = description;
  22878. this.callFlash("SetFileTypes", [types, description])
  22879. };
  22880. SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
  22881. this.settings.file_size_limit = fileSizeLimit;
  22882. this.callFlash("SetFileSizeLimit", [fileSizeLimit])
  22883. };
  22884. SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
  22885. this.settings.file_upload_limit = fileUploadLimit;
  22886. this.callFlash("SetFileUploadLimit", [fileUploadLimit])
  22887. };
  22888. SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
  22889. this.settings.file_queue_limit = fileQueueLimit;
  22890. this.callFlash("SetFileQueueLimit", [fileQueueLimit])
  22891. };
  22892. SWFUpload.prototype.setFilePostName = function (filePostName) {
  22893. this.settings.file_post_name = filePostName;
  22894. this.callFlash("SetFilePostName", [filePostName])
  22895. };
  22896. SWFUpload.prototype.setUseQueryString = function (useQueryString) {
  22897. this.settings.use_query_string = useQueryString;
  22898. this.callFlash("SetUseQueryString", [useQueryString])
  22899. };
  22900. SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
  22901. this.settings.requeue_on_error = requeueOnError;
  22902. this.callFlash("SetRequeueOnError", [requeueOnError])
  22903. };
  22904. SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
  22905. if (typeof http_status_codes === "string") {
  22906. http_status_codes = http_status_codes.replace(" ", "").split(",")
  22907. }
  22908. this.settings.http_success = http_status_codes;
  22909. this.callFlash("SetHTTPSuccess", [http_status_codes])
  22910. };
  22911. SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
  22912. this.settings.assume_success_timeout = timeout_seconds;
  22913. this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds])
  22914. };
  22915. SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
  22916. this.settings.debug_enabled = debugEnabled;
  22917. this.callFlash("SetDebugEnabled", [debugEnabled])
  22918. };
  22919. SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
  22920. if (buttonImageURL == undefined) {
  22921. buttonImageURL = ""
  22922. }
  22923. this.settings.button_image_url = buttonImageURL;
  22924. this.callFlash("SetButtonImageURL", [buttonImageURL])
  22925. };
  22926. SWFUpload.prototype.setButtonDimensions = function (width, height) {
  22927. this.settings.button_width = width;
  22928. this.settings.button_height = height;
  22929. var movie = this.getMovieElement();
  22930. if (movie != undefined) {
  22931. movie.style.width = width + "px";
  22932. movie.style.height = height + "px"
  22933. }
  22934. this.callFlash("SetButtonDimensions", [width, height])
  22935. };
  22936. SWFUpload.prototype.setButtonText = function (html) {
  22937. this.settings.button_text = html;
  22938. this.callFlash("SetButtonText", [html])
  22939. };
  22940. SWFUpload.prototype.setButtonTextPadding = function (left, top) {
  22941. this.settings.button_text_top_padding = top;
  22942. this.settings.button_text_left_padding = left;
  22943. this.callFlash("SetButtonTextPadding", [left, top])
  22944. };
  22945. SWFUpload.prototype.setButtonTextStyle = function (css) {
  22946. this.settings.button_text_style = css;
  22947. this.callFlash("SetButtonTextStyle", [css])
  22948. };
  22949. SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
  22950. this.settings.button_disabled = isDisabled;
  22951. this.callFlash("SetButtonDisabled", [isDisabled])
  22952. };
  22953. SWFUpload.prototype.setButtonAction = function (buttonAction) {
  22954. this.settings.button_action = buttonAction;
  22955. this.callFlash("SetButtonAction", [buttonAction])
  22956. };
  22957. SWFUpload.prototype.setButtonCursor = function (cursor) {
  22958. this.settings.button_cursor = cursor;
  22959. this.callFlash("SetButtonCursor", [cursor])
  22960. };
  22961. SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
  22962. if (argumentArray == undefined) {
  22963. argumentArray = []
  22964. } else {
  22965. if (!(argumentArray instanceof Array)) {
  22966. argumentArray = [argumentArray]
  22967. }
  22968. }
  22969. var self = this;
  22970. if (typeof this.settings[handlerName] === "function") {
  22971. this.eventQueue.push(function () {
  22972. this.settings[handlerName].apply(this, argumentArray)
  22973. });
  22974. setTimeout(function () {
  22975. self.executeNextEvent()
  22976. }, 0)
  22977. } else {
  22978. if (this.settings[handlerName] !== null) {
  22979. throw "Event handler " + handlerName + " is unknown or is not a function"
  22980. }
  22981. }
  22982. };
  22983. SWFUpload.prototype.executeNextEvent = function () {
  22984. var f = this.eventQueue ? this.eventQueue.shift() : null;
  22985. if (typeof(f) === "function") {
  22986. f.apply(this)
  22987. }
  22988. };
  22989. SWFUpload.prototype.unescapeFilePostParams = function (file) {
  22990. var reg = /[$]([0-9a-f]{4})/i;
  22991. var unescapedPost = {};
  22992. var uk;
  22993. if (file != undefined) {
  22994. for (var k in file.post) {
  22995. if (file.post.hasOwnProperty(k)) {
  22996. uk = k;
  22997. var match;
  22998. while ((match = reg.exec(uk)) !== null) {
  22999. uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)))
  23000. }
  23001. unescapedPost[uk] = file.post[k]
  23002. }
  23003. }
  23004. file.post = unescapedPost
  23005. }
  23006. return file
  23007. };
  23008. SWFUpload.prototype.testExternalInterface = function () {
  23009. try {
  23010. return this.callFlash("TestExternalInterface")
  23011. } catch (ex) {
  23012. return false
  23013. }
  23014. };
  23015. SWFUpload.prototype.flashReady = function () {
  23016. var movieElement = this.getMovieElement();
  23017. if (!movieElement) {
  23018. this.debug("Flash called back ready but the flash movie can't be found.");
  23019. return
  23020. }
  23021. this.cleanUp(movieElement);
  23022. this.queueEvent("swfupload_loaded_handler")
  23023. };
  23024. SWFUpload.prototype.cleanUp = function (movieElement) {
  23025. try {
  23026. if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") {
  23027. this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
  23028. for (var key in movieElement) {
  23029. try {
  23030. if (typeof(movieElement[key]) === "function") {
  23031. movieElement[key] = null
  23032. }
  23033. } catch (ex) {}
  23034. }
  23035. }
  23036. } catch (ex1) {}
  23037. window.__flash__removeCallback = function (instance, name) {
  23038. try {
  23039. if (instance) {
  23040. instance[name] = null
  23041. }
  23042. } catch (flashEx) {}
  23043. }
  23044. };
  23045. SWFUpload.prototype.fileDialogStart = function () {
  23046. this.queueEvent("file_dialog_start_handler")
  23047. };
  23048. SWFUpload.prototype.fileQueued = function (file) {
  23049. file = this.unescapeFilePostParams(file);
  23050. this.queueEvent("file_queued_handler", file)
  23051. };
  23052. SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
  23053. file = this.unescapeFilePostParams(file);
  23054. this.queueEvent("file_queue_error_handler", [file, errorCode, message])
  23055. };
  23056. SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
  23057. this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue])
  23058. };
  23059. SWFUpload.prototype.uploadStart = function (file) {
  23060. file = this.unescapeFilePostParams(file);
  23061. this.queueEvent("return_upload_start_handler", file)
  23062. };
  23063. SWFUpload.prototype.returnUploadStart = function (file) {
  23064. var returnValue;
  23065. if (typeof this.settings.upload_start_handler === "function") {
  23066. file = this.unescapeFilePostParams(file);
  23067. returnValue = this.settings.upload_start_handler.call(this, file)
  23068. } else {
  23069. if (this.settings.upload_start_handler != undefined) {
  23070. throw "upload_start_handler must be a function"
  23071. }
  23072. }
  23073. if (returnValue === undefined) {
  23074. returnValue = true
  23075. }
  23076. returnValue = !!returnValue;
  23077. this.callFlash("ReturnUploadStart", [returnValue])
  23078. };
  23079. SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
  23080. file = this.unescapeFilePostParams(file);
  23081. this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal])
  23082. };
  23083. SWFUpload.prototype.uploadError = function (file, errorCode, message) {
  23084. file = this.unescapeFilePostParams(file);
  23085. this.queueEvent("upload_error_handler", [file, errorCode, message])
  23086. };
  23087. SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
  23088. file = this.unescapeFilePostParams(file);
  23089. this.queueEvent("upload_success_handler", [file, serverData, responseReceived])
  23090. };
  23091. SWFUpload.prototype.uploadComplete = function (file) {
  23092. file = this.unescapeFilePostParams(file);
  23093. this.queueEvent("upload_complete_handler", file)
  23094. };
  23095. SWFUpload.prototype.debug = function (message) {
  23096. this.queueEvent("debug_handler", message)
  23097. };
  23098. SWFUpload.prototype.debugMessage = function (message) {
  23099. if (this.settings.debug) {
  23100. var exceptionMessage,
  23101. exceptionValues = [];
  23102. if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
  23103. for (var key in message) {
  23104. if (message.hasOwnProperty(key)) {
  23105. exceptionValues.push(key + ": " + message[key])
  23106. }
  23107. }
  23108. exceptionMessage = exceptionValues.join("\n") || "";
  23109. exceptionValues = exceptionMessage.split("\n");
  23110. exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
  23111. SWFUpload.Console.writeLine(exceptionMessage)
  23112. } else {
  23113. SWFUpload.Console.writeLine(message)
  23114. }
  23115. }
  23116. };
  23117. SWFUpload.Console = {};
  23118. SWFUpload.Console.writeLine = function (message) {
  23119. var console,
  23120. documentForm;
  23121. try {
  23122. console = document.getElementById("SWFUpload_Console");
  23123. if (!console) {
  23124. documentForm = document.createElement("form");
  23125. document.getElementsByTagName("body")[0].appendChild(documentForm);
  23126. console = document.createElement("textarea");
  23127. console.id = "SWFUpload_Console";
  23128. console.style.fontFamily = "monospace";
  23129. console.setAttribute("wrap", "off");
  23130. console.wrap = "off";
  23131. console.style.overflow = "auto";
  23132. console.style.width = "700px";
  23133. console.style.height = "350px";
  23134. console.style.margin = "5px";
  23135. documentForm.appendChild(console)
  23136. }
  23137. console.value += message + "\n";
  23138. console.scrollTop = console.scrollHeight - console.clientHeight
  23139. } catch (ex) {
  23140. alert("Exception: " + ex.name + " Message: " + ex.message)
  23141. }
  23142. };
  23143. var fluid_1_4 = fluid_1_4 || {};
  23144. (function ($, fluid) {
  23145. var fileOrFiles = function (that, numFiles) {
  23146. return (numFiles === 1) ? that.options.strings.progress.singleFile : that.options.strings.progress.pluralFiles
  23147. };
  23148. var enableElement = function (that, elm) {
  23149. elm.prop("disabled", false);
  23150. elm.removeClass(that.options.styles.dim)
  23151. };
  23152. var disableElement = function (that, elm) {
  23153. elm.prop("disabled", true);
  23154. elm.addClass(that.options.styles.dim)
  23155. };
  23156. var showElement = function (that, elm) {
  23157. elm.removeClass(that.options.styles.hidden)
  23158. };
  23159. var hideElement = function (that, elm) {
  23160. elm.addClass(that.options.styles.hidden)
  23161. };
  23162. var maxFilesUploaded = function (that) {
  23163. var fileUploadLimit = that.queue.getUploadedFiles().length + that.queue.getReadyFiles().length + that.queue.getErroredFiles().length;
  23164. return (fileUploadLimit === that.options.queueSettings.fileUploadLimit)
  23165. };
  23166. var setTotalProgressStyle = function (that, didError) {
  23167. didError = didError || false;
  23168. var indicator = that.totalProgress.indicator;
  23169. indicator.toggleClass(that.options.styles.totalProgress, !didError);
  23170. indicator.toggleClass(that.options.styles.totalProgressError, didError)
  23171. };
  23172. var setStateEmpty = function (that) {
  23173. disableElement(that, that.locate("uploadButton"));
  23174. if (that.queue.files.length === 0) {
  23175. that.locate("browseButtonText").text(that.options.strings.buttons.browse);
  23176. that.locate("browseButton").removeClass(that.options.styles.browseButton);
  23177. showElement(that, that.locate("instructions"))
  23178. }
  23179. };
  23180. var enableBrowseButton = function (that) {
  23181. if (!maxFilesUploaded(that)) {
  23182. enableElement(that, that.locate("browseButton"));
  23183. that.strategy.local.enableBrowseButton()
  23184. }
  23185. };
  23186. var setStateDone = function (that) {
  23187. disableElement(that, that.locate("uploadButton"));
  23188. hideElement(that, that.locate("pauseButton"));
  23189. showElement(that, that.locate("uploadButton"));
  23190. enableBrowseButton(that)
  23191. };
  23192. var setStateLoaded = function (that) {
  23193. that.locate("browseButtonText").text(that.options.strings.buttons.addMore);
  23194. that.locate("browseButton").addClass(that.options.styles.browseButton);
  23195. hideElement(that, that.locate("pauseButton"));
  23196. showElement(that, that.locate("uploadButton"));
  23197. enableElement(that, that.locate("uploadButton"));
  23198. hideElement(that, that.locate("instructions"));
  23199. that.totalProgress.hide();
  23200. enableBrowseButton(that)
  23201. };
  23202. var setStateUploading = function (that) {
  23203. that.totalProgress.hide(false, false);
  23204. setTotalProgressStyle(that);
  23205. hideElement(that, that.locate("uploadButton"));
  23206. disableElement(that, that.locate("browseButton"));
  23207. that.strategy.local.disableBrowseButton();
  23208. enableElement(that, that.locate("pauseButton"));
  23209. showElement(that, that.locate("pauseButton"));
  23210. that.locate(that.options.focusWithEvent.afterUploadStart).focus()
  23211. };
  23212. var setStateFull = function (that) {
  23213. that.locate("browseButtonText").text(that.options.strings.buttons.addMore);
  23214. that.locate("browseButton").addClass(that.options.styles.browseButton);
  23215. hideElement(that, that.locate("pauseButton"));
  23216. showElement(that, that.locate("uploadButton"));
  23217. enableElement(that, that.locate("uploadButton"));
  23218. disableElement(that, that.locate("browseButton"));
  23219. that.strategy.local.disableBrowseButton();
  23220. hideElement(that, that.locate("instructions"));
  23221. that.totalProgress.hide()
  23222. };
  23223. var renderUploadTotalMessage = function (that) {
  23224. var numReadyFiles = that.queue.getReadyFiles().length;
  23225. var bytesReadyFiles = that.queue.sizeOfReadyFiles();
  23226. var fileLabelStr = fileOrFiles(that, numReadyFiles);
  23227. var totalStateStr = fluid.stringTemplate(that.options.strings.progress.toUploadLabel, {
  23228. fileCount : numReadyFiles,
  23229. fileLabel : fileLabelStr,
  23230. totalBytes : fluid.uploader.formatFileSize(bytesReadyFiles)
  23231. });
  23232. that.locate("totalFileStatusText").html(totalStateStr)
  23233. };
  23234. var renderFileUploadLimit = function (that) {
  23235. if (that.options.queueSettings.fileUploadLimit > 0) {
  23236. var fileUploadLimitText = fluid.stringTemplate(that.options.strings.progress.fileUploadLimitLabel, {
  23237. fileUploadLimit : that.options.queueSettings.fileUploadLimit,
  23238. fileLabel : fileOrFiles(that, that.options.queueSettings.fileUploadLimit)
  23239. });
  23240. that.locate("fileUploadLimitText").html(fileUploadLimitText)
  23241. }
  23242. };
  23243. var updateTotalProgress = function (that) {
  23244. var batch = that.queue.currentBatch;
  23245. var totalPercent = fluid.uploader.derivePercent(batch.totalBytesUploaded, batch.totalBytes);
  23246. var numFilesInBatch = batch.files.length;
  23247. var fileLabelStr = fileOrFiles(that, numFilesInBatch);
  23248. var totalProgressStr = fluid.stringTemplate(that.options.strings.progress.totalProgressLabel, {
  23249. curFileN : batch.fileIdx,
  23250. totalFilesN : numFilesInBatch,
  23251. fileLabel : fileLabelStr,
  23252. currBytes : fluid.uploader.formatFileSize(batch.totalBytesUploaded),
  23253. totalBytes : fluid.uploader.formatFileSize(batch.totalBytes)
  23254. });
  23255. that.totalProgress.update(totalPercent, totalProgressStr)
  23256. };
  23257. var updateTotalAtCompletion = function (that) {
  23258. var numErroredFiles = that.queue.getErroredFiles().length;
  23259. var numTotalFiles = that.queue.files.length;
  23260. var fileLabelStr = fileOrFiles(that, numTotalFiles);
  23261. var errorStr = "";
  23262. if (numErroredFiles > 0) {
  23263. var errorLabelString = (numErroredFiles === 1) ? that.options.strings.progress.singleError : that.options.strings.progress.pluralErrors;
  23264. setTotalProgressStyle(that, true);
  23265. errorStr = fluid.stringTemplate(that.options.strings.progress.numberOfErrors, {
  23266. errorsN : numErroredFiles,
  23267. errorLabel : errorLabelString
  23268. })
  23269. }
  23270. var totalProgressStr = fluid.stringTemplate(that.options.strings.progress.completedLabel, {
  23271. curFileN : that.queue.getUploadedFiles().length,
  23272. totalFilesN : numTotalFiles,
  23273. errorString : errorStr,
  23274. fileLabel : fileLabelStr,
  23275. totalCurrBytes : fluid.uploader.formatFileSize(that.queue.sizeOfUploadedFiles())
  23276. });
  23277. that.totalProgress.update(100, totalProgressStr)
  23278. };
  23279. var updateQueueSummaryText = function (that) {
  23280. var fileQueueTable = that.locate("fileQueue");
  23281. if (that.queue.files.length === 0) {
  23282. fileQueueTable.attr("summary", that.options.strings.queue.emptyQueue)
  23283. } else {
  23284. var queueSummary = fluid.stringTemplate(that.options.strings.queue.queueSummary, {
  23285. totalUploaded : that.queue.getUploadedFiles().length,
  23286. totalInUploadQueue : that.queue.files.length - that.queue.getUploadedFiles().length
  23287. });
  23288. fileQueueTable.attr("summary", queueSummary)
  23289. }
  23290. };
  23291. var bindDOMEvents = function (that) {
  23292. that.locate("uploadButton").click(function () {
  23293. that.start()
  23294. });
  23295. that.locate("pauseButton").click(function () {
  23296. that.stop()
  23297. })
  23298. };
  23299. var updateStateAfterFileDialog = function (that) {
  23300. var queueLength = that.queue.getReadyFiles().length;
  23301. if (queueLength > 0) {
  23302. if (queueLength === that.options.queueSettings.fileUploadLimit) {
  23303. setStateFull(that)
  23304. } else {
  23305. setStateLoaded(that)
  23306. }
  23307. renderUploadTotalMessage(that);
  23308. that.locate(that.options.focusWithEvent.afterFileDialog).focus();
  23309. updateQueueSummaryText(that)
  23310. }
  23311. };
  23312. var updateStateAfterFileRemoval = function (that) {
  23313. if (that.queue.getReadyFiles().length === 0) {
  23314. setStateEmpty(that)
  23315. } else {
  23316. setStateLoaded(that)
  23317. }
  23318. renderUploadTotalMessage(that);
  23319. updateQueueSummaryText(that)
  23320. };
  23321. var updateStateAfterCompletion = function (that) {
  23322. if (that.queue.getReadyFiles().length === 0) {
  23323. setStateDone(that)
  23324. } else {
  23325. setStateLoaded(that)
  23326. }
  23327. updateTotalAtCompletion(that);
  23328. updateQueueSummaryText(that)
  23329. };
  23330. var uploadNextOrFinish = function (that) {
  23331. if (that.queue.shouldUploadNextFile()) {
  23332. that.strategy.remote.uploadNextFile()
  23333. } else {
  23334. that.events.afterUploadComplete.fire(that.queue.currentBatch.files);
  23335. that.queue.clearCurrentBatch()
  23336. }
  23337. };
  23338. var bindEvents = function (that) {
  23339. that.events.afterFileDialog.addListener(function () {
  23340. updateStateAfterFileDialog(that)
  23341. });
  23342. that.events.afterFileQueued.addListener(function (file) {
  23343. that.queue.addFile(file)
  23344. });
  23345. that.events.onFileRemoved.addListener(function (file) {
  23346. that.removeFile(file)
  23347. });
  23348. that.events.afterFileRemoved.addListener(function () {
  23349. updateStateAfterFileRemoval(that)
  23350. });
  23351. that.events.onUploadStart.addListener(function () {
  23352. setStateUploading(that)
  23353. });
  23354. that.events.onUploadStop.addListener(function () {
  23355. that.locate(that.options.focusWithEvent.onUploadStop).focus()
  23356. });
  23357. that.events.onFileStart.addListener(function (file) {
  23358. file.filestatus = fluid.uploader.fileStatusConstants.IN_PROGRESS;
  23359. that.queue.startFile()
  23360. });
  23361. that.events.onFileProgress.addListener(function (file, currentBytes, totalBytes) {
  23362. that.queue.updateBatchStatus(currentBytes);
  23363. updateTotalProgress(that)
  23364. });
  23365. that.events.onFileComplete.addListener(function (file) {
  23366. that.queue.finishFile(file);
  23367. that.events.afterFileComplete.fire(file);
  23368. uploadNextOrFinish(that)
  23369. });
  23370. that.events.onFileSuccess.addListener(function (file) {
  23371. file.filestatus = fluid.uploader.fileStatusConstants.COMPLETE;
  23372. if (that.queue.currentBatch.bytesUploadedForFile === 0) {
  23373. that.queue.currentBatch.totalBytesUploaded += file.size
  23374. }
  23375. updateTotalProgress(that)
  23376. });
  23377. that.events.onFileError.addListener(function (file, error) {
  23378. if (error === fluid.uploader.errorConstants.UPLOAD_STOPPED) {
  23379. file.filestatus = fluid.uploader.fileStatusConstants.CANCELLED;
  23380. return
  23381. } else {
  23382. file.filestatus = fluid.uploader.fileStatusConstants.ERROR;
  23383. if (that.queue.isUploading) {
  23384. that.queue.currentBatch.totalBytesUploaded += file.size;
  23385. that.queue.currentBatch.numFilesErrored++;
  23386. uploadNextOrFinish(that)
  23387. }
  23388. }
  23389. });
  23390. that.events.afterUploadComplete.addListener(function () {
  23391. that.queue.isUploading = false;
  23392. updateStateAfterCompletion(that)
  23393. })
  23394. };
  23395. var setupUploader = function (that) {
  23396. that.demo = fluid.typeTag(that.options.demo ? "fluid.uploader.demo" : "fluid.uploader.live");
  23397. fluid.initDependents(that);
  23398. disableElement(that, that.locate("uploadButton"));
  23399. bindDOMEvents(that);
  23400. bindEvents(that);
  23401. updateQueueSummaryText(that);
  23402. that.statusUpdater();
  23403. renderFileUploadLimit(that);
  23404. that.container.attr("role", "application")
  23405. };
  23406. fluid.uploader = function (container, uploaderOptions) {
  23407. var that = fluid.initView("fluid.uploader", container);
  23408. if (fluid.uploader.transformOptions) {
  23409. uploaderOptions = fluid.uploader.transformOptions(uploaderOptions)
  23410. }
  23411. that.uploaderOptions = uploaderOptions;
  23412. fluid.initDependents(that);
  23413. return that.uploaderImpl
  23414. };
  23415. fluid.uploaderImpl = function () {
  23416. fluid.fail('Error creating uploader component - please make sure that a progressiveCheckerForComponent for "fluid.uploader" is registered either in the static environment or else is visible in the current component tree')
  23417. };
  23418. fluid.defaults("fluid.uploader", {
  23419. gradeNames : ["fluid.viewComponent"],
  23420. components : {
  23421. uploaderContext : {
  23422. type : "fluid.progressiveCheckerForComponent",
  23423. options : {
  23424. componentName : "fluid.uploader"
  23425. }
  23426. },
  23427. uploaderImpl : {
  23428. type : "fluid.uploaderImpl",
  23429. container : "{uploader}.container",
  23430. options : "{uploader}.uploaderOptions"
  23431. }
  23432. },
  23433. progressiveCheckerOptions : {
  23434. checks : [{
  23435. feature : "{fluid.browser.supportsBinaryXHR}",
  23436. contextName : "fluid.uploader.html5"
  23437. }, {
  23438. feature : "{fluid.browser.supportsFlash}",
  23439. contextName : "fluid.uploader.swfUpload"
  23440. }
  23441. ],
  23442. defaultContextName : "fluid.uploader.singleFile"
  23443. }
  23444. });
  23445. fluid.alias("fluid.uploader", "fluid.uploaderImpl");
  23446. fluid.progressiveEnhanceableUploader = function (container, enhanceable, options) {
  23447. return fluid.uploader(container, options)
  23448. };
  23449. fluid.uploader.multiFileUploader = function (container, options) {
  23450. var that = fluid.initView("fluid.uploader.multiFileUploader", container, options);
  23451. that.queue = fluid.uploader.fileQueue();
  23452. that.browse = function () {
  23453. if (!that.queue.isUploading) {
  23454. that.strategy.local.browse()
  23455. }
  23456. };
  23457. that.removeFile = function (file) {
  23458. that.queue.removeFile(file);
  23459. that.strategy.local.removeFile(file);
  23460. that.events.afterFileRemoved.fire(file)
  23461. };
  23462. that.start = function () {
  23463. that.queue.start();
  23464. that.events.onUploadStart.fire(that.queue.currentBatch.files);
  23465. that.strategy.remote.uploadNextFile()
  23466. };
  23467. that.stop = function () {
  23468. that.events.onUploadStop.fire();
  23469. that.strategy.remote.stop()
  23470. };
  23471. setupUploader(that);
  23472. return that
  23473. };
  23474. fluid.defaults("fluid.uploader.multiFileUploader", {
  23475. gradeNames : "fluid.viewComponent",
  23476. components : {
  23477. strategy : {
  23478. type : "fluid.uploader.progressiveStrategy"
  23479. },
  23480. errorPanel : {
  23481. type : "fluid.uploader.errorPanel"
  23482. },
  23483. fileQueueView : {
  23484. type : "fluid.uploader.fileQueueView",
  23485. options : {
  23486. model : "{multiFileUploader}.queue.files",
  23487. uploaderContainer : "{multiFileUploader}.container"
  23488. }
  23489. },
  23490. totalProgress : {
  23491. type : "fluid.uploader.totalProgressBar",
  23492. options : {
  23493. selectors : {
  23494. progressBar : ".flc-uploader-queue-footer",
  23495. displayElement : ".flc-uploader-total-progress",
  23496. label : ".flc-uploader-total-progress-text",
  23497. indicator : ".flc-uploader-total-progress",
  23498. ariaElement : ".flc-uploader-total-progress"
  23499. }
  23500. }
  23501. }
  23502. },
  23503. invokers : {
  23504. statusUpdater : "fluid.uploader.ariaLiveRegionUpdater"
  23505. },
  23506. queueSettings : {
  23507. uploadURL : "",
  23508. postParams : {},
  23509. fileSizeLimit : "20480",
  23510. fileTypes : null,
  23511. fileTypesDescription : null,
  23512. fileUploadLimit : 0,
  23513. fileQueueLimit : 0
  23514. },
  23515. demo : false,
  23516. selectors : {
  23517. fileQueue : ".flc-uploader-queue",
  23518. browseButton : ".flc-uploader-button-browse",
  23519. browseButtonText : ".flc-uploader-button-browse-text",
  23520. uploadButton : ".flc-uploader-button-upload",
  23521. pauseButton : ".flc-uploader-button-pause",
  23522. totalFileStatusText : ".flc-uploader-total-progress-text",
  23523. fileUploadLimitText : ".flc-uploader-upload-limit-text",
  23524. instructions : ".flc-uploader-browse-instructions",
  23525. statusRegion : ".flc-uploader-status-region",
  23526. errorsPanel : ".flc-uploader-errorsPanel"
  23527. },
  23528. focusWithEvent : {
  23529. afterFileDialog : "uploadButton",
  23530. afterUploadStart : "pauseButton",
  23531. onUploadStop : "uploadButton"
  23532. },
  23533. styles : {
  23534. disabled : "fl-uploader-disabled",
  23535. hidden : "fl-uploader-hidden",
  23536. dim : "fl-uploader-dim",
  23537. totalProgress : "fl-uploader-total-progress-okay",
  23538. totalProgressError : "fl-uploader-total-progress-errored",
  23539. browseButton : "fl-uploader-browseMore"
  23540. },
  23541. events : {
  23542. afterReady : null,
  23543. onFileDialog : null,
  23544. onFilesSelected : null,
  23545. onFileQueued : null,
  23546. afterFileQueued : null,
  23547. onFileRemoved : null,
  23548. afterFileRemoved : null,
  23549. afterFileDialog : null,
  23550. onUploadStart : null,
  23551. onUploadStop : null,
  23552. onFileStart : null,
  23553. onFileProgress : null,
  23554. onFileError : null,
  23555. onQueueError : null,
  23556. onFileSuccess : null,
  23557. onFileComplete : null,
  23558. afterFileComplete : null,
  23559. afterUploadComplete : null
  23560. },
  23561. strings : {
  23562. progress : {
  23563. fileUploadLimitLabel : "%fileUploadLimit %fileLabel maximum",
  23564. toUploadLabel : "To upload: %fileCount %fileLabel (%totalBytes)",
  23565. totalProgressLabel : "Uploading: %curFileN of %totalFilesN %fileLabel (%currBytes of %totalBytes)",
  23566. completedLabel : "Uploaded: %curFileN of %totalFilesN %fileLabel (%totalCurrBytes)%errorString",
  23567. numberOfErrors : ", %errorsN %errorLabel",
  23568. singleFile : "file",
  23569. pluralFiles : "files",
  23570. singleError : "error",
  23571. pluralErrors : "errors"
  23572. },
  23573. buttons : {
  23574. browse : "Browse Files",
  23575. addMore : "Add More",
  23576. stopUpload : "Stop Upload",
  23577. cancelRemaning : "Cancel remaining Uploads",
  23578. resumeUpload : "Resume Upload"
  23579. },
  23580. queue : {
  23581. emptyQueue : "File list: No files waiting to be uploaded.",
  23582. queueSummary : "File list: %totalUploaded files uploaded, %totalInUploadQueue file waiting to be uploaded."
  23583. }
  23584. },
  23585. mergePolicy : {
  23586. "fileQueueView.options.model" : "preserve"
  23587. }
  23588. });
  23589. fluid.demands("fluid.uploader.totalProgressBar", "fluid.uploader.multiFileUploader", {
  23590. funcName : "fluid.progress",
  23591. container : "{multiFileUploader}.container"
  23592. });
  23593. fluid.demands("fluid.uploader.fileQueueView", "fluid.uploader.multiFileUploader", {
  23594. container : "{multiFileUploader}.dom.fileQueue",
  23595. options : {
  23596. events : {
  23597. onFileRemoved : "{multiFileUploader}.events.onFileRemoved"
  23598. }
  23599. }
  23600. });
  23601. fluid.demands("fluid.uploader.fileQueueView.eventBinder", ["fluid.uploader.multiFileUploader", "fluid.uploader.fileQueueView"], {
  23602. options : {
  23603. listeners : {
  23604. "{multiFileUploader}.events.afterFileQueued" : "{fileQueueView}.addFile",
  23605. "{multiFileUploader}.events.onUploadStart" : "{fileQueueView}.prepareForUpload",
  23606. "{multiFileUploader}.events.onFileStart" : "{fileQueueView}.showFileProgress",
  23607. "{multiFileUploader}.events.onFileProgress" : "{fileQueueView}.updateFileProgress",
  23608. "{multiFileUploader}.events.onFileSuccess" : "{fileQueueView}.markFileComplete",
  23609. "{multiFileUploader}.events.onFileError" : "{fileQueueView}.showErrorForFile",
  23610. "{multiFileUploader}.events.afterFileComplete" : "{fileQueueView}.hideFileProgress",
  23611. "{multiFileUploader}.events.afterUploadComplete" : "{fileQueueView}.refreshAfterUpload"
  23612. }
  23613. }
  23614. });
  23615. fluid.uploader.formatFileSize = function (bytes) {
  23616. if (typeof(bytes) === "number") {
  23617. if (bytes === 0) {
  23618. return "0.0 KB"
  23619. } else {
  23620. if (bytes > 0) {
  23621. if (bytes < 1048576) {
  23622. return (Math.ceil(bytes / 1024 * 10) / 10).toFixed(1) + " KB"
  23623. } else {
  23624. return (Math.ceil(bytes / 1048576 * 10) / 10).toFixed(1) + " MB"
  23625. }
  23626. }
  23627. }
  23628. }
  23629. return ""
  23630. };
  23631. fluid.uploader.derivePercent = function (num, total) {
  23632. return Math.round((num * 100) / total)
  23633. };
  23634. fluid.uploader.ariaLiveRegionUpdater = function (statusRegion, totalFileStatusText, events) {
  23635. statusRegion.attr("role", "log");
  23636. statusRegion.attr("aria-live", "assertive");
  23637. statusRegion.attr("aria-relevant", "text");
  23638. statusRegion.attr("aria-atomic", "true");
  23639. var regionUpdater = function () {
  23640. statusRegion.text(totalFileStatusText.text())
  23641. };
  23642. events.afterFileDialog.addListener(regionUpdater);
  23643. events.afterFileRemoved.addListener(regionUpdater);
  23644. events.afterUploadComplete.addListener(regionUpdater)
  23645. };
  23646. fluid.demands("fluid.uploader.ariaLiveRegionUpdater", "fluid.uploader.multiFileUploader", {
  23647. funcName : "fluid.uploader.ariaLiveRegionUpdater",
  23648. args : ["{multiFileUploader}.dom.statusRegion", "{multiFileUploader}.dom.totalFileStatusText", "{multiFileUploader}.events"]
  23649. });
  23650. fluid.uploader.queueErrorConstants = {
  23651. QUEUE_LIMIT_EXCEEDED : -100,
  23652. FILE_EXCEEDS_SIZE_LIMIT : -110,
  23653. ZERO_BYTE_FILE : -120,
  23654. INVALID_FILETYPE : -130
  23655. };
  23656. fluid.uploader.errorConstants = {
  23657. HTTP_ERROR : -200,
  23658. MISSING_UPLOAD_URL : -210,
  23659. IO_ERROR : -220,
  23660. SECURITY_ERROR : -230,
  23661. UPLOAD_LIMIT_EXCEEDED : -240,
  23662. UPLOAD_FAILED : -250,
  23663. SPECIFIED_FILE_ID_NOT_FOUND : -260,
  23664. FILE_VALIDATION_FAILED : -270,
  23665. FILE_CANCELLED : -280,
  23666. UPLOAD_STOPPED : -290
  23667. };
  23668. fluid.uploader.fileStatusConstants = {
  23669. QUEUED : -1,
  23670. IN_PROGRESS : -2,
  23671. ERROR : -3,
  23672. COMPLETE : -4,
  23673. CANCELLED : -5
  23674. };
  23675. var toggleVisibility = function (toShow, toHide) {
  23676. if (window.opera) {
  23677. toShow.show().removeClass("hideUploaderForOpera");
  23678. toHide.show().addClass("hideUploaderForOpera")
  23679. } else {
  23680. toShow.show();
  23681. toHide.hide()
  23682. }
  23683. };
  23684. fluid.uploader.singleFileUploader = function (container, options) {
  23685. var that = fluid.initView("fluid.uploader.singleFileUploader", container, options);
  23686. toggleVisibility($(that.options.selectors.basicUpload), that.container);
  23687. return that
  23688. };
  23689. fluid.defaults("fluid.uploader.singleFileUploader", {
  23690. gradeNames : "fluid.viewComponent",
  23691. selectors : {
  23692. basicUpload : ".fl-progEnhance-basic"
  23693. }
  23694. });
  23695. fluid.demands("fluid.uploaderImpl", "fluid.uploader.singleFile", {
  23696. funcName : "fluid.uploader.singleFileUploader"
  23697. })
  23698. })(jQuery, fluid_1_4);
  23699. var fluid_1_4 = fluid_1_4 || {};
  23700. (function ($, fluid) {
  23701. fluid.uploader = fluid.uploader || {};
  23702. var filterFiles = function (files, filterFn) {
  23703. var filteredFiles = [];
  23704. for (var i = 0; i < files.length; i++) {
  23705. var file = files[i];
  23706. if (filterFn(file) === true) {
  23707. filteredFiles.push(file)
  23708. }
  23709. }
  23710. return filteredFiles
  23711. };
  23712. fluid.uploader.fileQueue = function () {
  23713. var that = {};
  23714. that.files = [];
  23715. that.isUploading = false;
  23716. that.start = function () {
  23717. that.setupCurrentBatch();
  23718. that.isUploading = true;
  23719. that.shouldStop = false
  23720. };
  23721. that.startFile = function () {
  23722. that.currentBatch.fileIdx++;
  23723. that.currentBatch.bytesUploadedForFile = 0;
  23724. that.currentBatch.previousBytesUploadedForFile = 0
  23725. };
  23726. that.finishFile = function (file) {
  23727. that.currentBatch.numFilesCompleted++
  23728. };
  23729. that.shouldUploadNextFile = function () {
  23730. return !that.shouldStop && that.isUploading && (that.currentBatch.numFilesCompleted + that.currentBatch.numFilesErrored) < that.currentBatch.files.length
  23731. };
  23732. that.addFile = function (file) {
  23733. that.files.push(file)
  23734. };
  23735. that.removeFile = function (file) {
  23736. var idx = $.inArray(file, that.files);
  23737. that.files.splice(idx, 1)
  23738. };
  23739. that.totalBytes = function () {
  23740. return fluid.uploader.fileQueue.sizeOfFiles(that.files)
  23741. };
  23742. that.getReadyFiles = function () {
  23743. return filterFiles(that.files, function (file) {
  23744. return (file.filestatus === fluid.uploader.fileStatusConstants.QUEUED || file.filestatus === fluid.uploader.fileStatusConstants.CANCELLED)
  23745. })
  23746. };
  23747. that.getErroredFiles = function () {
  23748. return filterFiles(that.files, function (file) {
  23749. return (file.filestatus === fluid.uploader.fileStatusConstants.ERROR)
  23750. })
  23751. };
  23752. that.sizeOfReadyFiles = function () {
  23753. return fluid.uploader.fileQueue.sizeOfFiles(that.getReadyFiles())
  23754. };
  23755. that.getUploadedFiles = function () {
  23756. return filterFiles(that.files, function (file) {
  23757. return (file.filestatus === fluid.uploader.fileStatusConstants.COMPLETE)
  23758. })
  23759. };
  23760. that.sizeOfUploadedFiles = function () {
  23761. return fluid.uploader.fileQueue.sizeOfFiles(that.getUploadedFiles())
  23762. };
  23763. that.setupCurrentBatch = function () {
  23764. that.clearCurrentBatch();
  23765. that.updateCurrentBatch()
  23766. };
  23767. that.clearCurrentBatch = function () {
  23768. that.currentBatch = {
  23769. fileIdx : 0,
  23770. files : [],
  23771. totalBytes : 0,
  23772. numFilesCompleted : 0,
  23773. numFilesErrored : 0,
  23774. bytesUploadedForFile : 0,
  23775. previousBytesUploadedForFile : 0,
  23776. totalBytesUploaded : 0
  23777. }
  23778. };
  23779. that.updateCurrentBatch = function () {
  23780. var readyFiles = that.getReadyFiles();
  23781. that.currentBatch.files = readyFiles;
  23782. that.currentBatch.totalBytes = fluid.uploader.fileQueue.sizeOfFiles(readyFiles)
  23783. };
  23784. that.updateBatchStatus = function (currentBytes) {
  23785. var byteIncrement = currentBytes - that.currentBatch.previousBytesUploadedForFile;
  23786. that.currentBatch.totalBytesUploaded += byteIncrement;
  23787. that.currentBatch.bytesUploadedForFile += byteIncrement;
  23788. that.currentBatch.previousBytesUploadedForFile = currentBytes
  23789. };
  23790. return that
  23791. };
  23792. fluid.uploader.fileQueue.sizeOfFiles = function (files) {
  23793. var totalBytes = 0;
  23794. for (var i = 0; i < files.length; i++) {
  23795. var file = files[i];
  23796. totalBytes += file.size
  23797. }
  23798. return totalBytes
  23799. }
  23800. })(jQuery, fluid_1_4);
  23801. var fluid_1_4 = fluid_1_4 || {};
  23802. (function ($, fluid) {
  23803. var rowForFile = function (that, file) {
  23804. return that.locate("fileQueue").find("#" + file.id)
  23805. };
  23806. var errorRowForFile = function (that, file) {
  23807. return $("#" + file.id + "_error", that.container)
  23808. };
  23809. var fileForRow = function (that, row) {
  23810. var files = that.model;
  23811. var i;
  23812. for (i = 0; i < files.length; i++) {
  23813. var file = files[i];
  23814. if (file.id.toString() === row.prop("id")) {
  23815. return file
  23816. }
  23817. }
  23818. return null
  23819. };
  23820. var progressorForFile = function (that, file) {
  23821. var progressId = file.id + "_progress";
  23822. return that.fileProgressors[progressId]
  23823. };
  23824. var startFileProgress = function (that, file) {
  23825. var fileRowElm = rowForFile(that, file);
  23826. that.scroller.scrollTo(fileRowElm);
  23827. var fileProgressor = progressorForFile(that, file);
  23828. fileProgressor.refreshView();
  23829. fileProgressor.show()
  23830. };
  23831. var updateFileProgress = function (that, file, fileBytesComplete, fileTotalBytes) {
  23832. var filePercent = fluid.uploader.derivePercent(fileBytesComplete, fileTotalBytes);
  23833. var filePercentStr = filePercent + "%";
  23834. progressorForFile(that, file).update(filePercent, filePercentStr)
  23835. };
  23836. var hideFileProgress = function (that, file) {
  23837. var fileRowElm = rowForFile(that, file);
  23838. progressorForFile(that, file).hide();
  23839. if (file.filestatus === fluid.uploader.fileStatusConstants.COMPLETE) {
  23840. that.locate("fileIconBtn", fileRowElm).removeClass(that.options.styles.dim)
  23841. }
  23842. };
  23843. var removeFileProgress = function (that, file) {
  23844. var fileProgressor = progressorForFile(that, file);
  23845. if (!fileProgressor) {
  23846. return
  23847. }
  23848. var rowProgressor = fileProgressor.displayElement;
  23849. rowProgressor.remove()
  23850. };
  23851. var animateRowRemoval = function (that, row) {
  23852. row.fadeOut("fast", function () {
  23853. row.remove();
  23854. that.refreshView()
  23855. })
  23856. };
  23857. var removeFileErrorRow = function (that, file) {
  23858. if (file.filestatus === fluid.uploader.fileStatusConstants.ERROR) {
  23859. animateRowRemoval(that, errorRowForFile(that, file))
  23860. }
  23861. };
  23862. var removeFileAndRow = function (that, file, row) {
  23863. removeFileProgress(that, file);
  23864. removeFileErrorRow(that, file);
  23865. that.events.onFileRemoved.fire(file);
  23866. animateRowRemoval(that, row)
  23867. };
  23868. var removeFileForRow = function (that, row) {
  23869. var file = fileForRow(that, row);
  23870. if (!file || file.filestatus === fluid.uploader.fileStatusConstants.COMPLETE) {
  23871. return
  23872. }
  23873. removeFileAndRow(that, file, row)
  23874. };
  23875. var removeRowForFile = function (that, file) {
  23876. var row = rowForFile(that, file);
  23877. removeFileAndRow(that, file, row)
  23878. };
  23879. var bindHover = function (row, styles) {
  23880. var over = function () {
  23881. if (row.hasClass(styles.ready) && !row.hasClass(styles.uploading)) {
  23882. row.addClass(styles.hover)
  23883. }
  23884. };
  23885. var out = function () {
  23886. if (row.hasClass(styles.ready) && !row.hasClass(styles.uploading)) {
  23887. row.removeClass(styles.hover)
  23888. }
  23889. };
  23890. row.hover(over, out)
  23891. };
  23892. var bindDeleteKey = function (that, row) {
  23893. var deleteHandler = function () {
  23894. removeFileForRow(that, row)
  23895. };
  23896. fluid.activatable(row, null, {
  23897. additionalBindings : [{
  23898. key : $.ui.keyCode.DELETE,
  23899. activateHandler : deleteHandler
  23900. }
  23901. ]
  23902. })
  23903. };
  23904. var bindRowHandlers = function (that, row) {
  23905. if ($.browser.msie && $.browser.version < 7) {
  23906. bindHover(row, that.options.styles)
  23907. }
  23908. that.locate("fileIconBtn", row).click(function () {
  23909. removeFileForRow(that, row)
  23910. });
  23911. bindDeleteKey(that, row)
  23912. };
  23913. var renderRowFromTemplate = function (that, file) {
  23914. var row = that.rowTemplate.clone(),
  23915. fileName = file.name,
  23916. fileSize = fluid.uploader.formatFileSize(file.size);
  23917. row.removeClass(that.options.styles.hiddenTemplate);
  23918. that.locate("fileName", row).text(fileName);
  23919. that.locate("fileSize", row).text(fileSize);
  23920. that.locate("fileIconBtn", row).addClass(that.options.styles.remove);
  23921. row.prop("id", file.id);
  23922. row.addClass(that.options.styles.ready);
  23923. bindRowHandlers(that, row);
  23924. fluid.updateAriaLabel(row, fileName + " " + fileSize);
  23925. return row
  23926. };
  23927. var createProgressorFromTemplate = function (that, row) {
  23928. var rowProgressor = that.rowProgressorTemplate.clone();
  23929. var rowId = row.prop("id");
  23930. var progressId = rowId + "_progress";
  23931. rowProgressor.prop("id", progressId);
  23932. rowProgressor.css("top", row.position().top);
  23933. rowProgressor.height(row.height()).width(5);
  23934. that.container.after(rowProgressor);
  23935. that.fileProgressors[progressId] = fluid.progress(that.options.uploaderContainer, {
  23936. selectors : {
  23937. progressBar : "#" + rowId,
  23938. displayElement : "#" + progressId,
  23939. label : "#" + progressId + " .fl-uploader-file-progress-text",
  23940. indicator : "#" + progressId
  23941. }
  23942. })
  23943. };
  23944. var addFile = function (that, file) {
  23945. var row = renderRowFromTemplate(that, file);
  23946. if (!($.browser.msie && ($.browser.version >= 8))) {
  23947. row.hide()
  23948. }
  23949. that.container.append(row);
  23950. row.attr("title", that.options.strings.status.remove);
  23951. row.fadeIn("slow");
  23952. createProgressorFromTemplate(that, row);
  23953. that.refreshView();
  23954. that.scroller.scrollTo("100%")
  23955. };
  23956. var enableRows = function (rows, state) {
  23957. var i;
  23958. for (i = 0; i < rows.length; i++) {
  23959. fluid.enabled(rows[i], state)
  23960. }
  23961. };
  23962. var prepareForUpload = function (that) {
  23963. var rowButtons = that.locate("fileIconBtn", that.locate("fileRows"));
  23964. rowButtons.prop("disabled", true);
  23965. rowButtons.addClass(that.options.styles.dim);
  23966. enableRows(that.locate("fileRows"), false)
  23967. };
  23968. var refreshAfterUpload = function (that) {
  23969. var rowButtons = that.locate("fileIconBtn", that.locate("fileRows"));
  23970. rowButtons.prop("disabled", false);
  23971. rowButtons.removeClass(that.options.styles.dim);
  23972. enableRows(that.locate("fileRows"), true)
  23973. };
  23974. var changeRowState = function (that, row, newState) {
  23975. row.removeClass(that.options.styles.ready).removeClass(that.options.styles.error).addClass(newState)
  23976. };
  23977. var markRowAsComplete = function (that, file) {
  23978. var row = rowForFile(that, file);
  23979. changeRowState(that, row, that.options.styles.uploaded);
  23980. row.attr("title", that.options.strings.status.success);
  23981. fluid.enabled(row, false);
  23982. var removeRowBtn = that.locate("fileIconBtn", row);
  23983. removeRowBtn.unbind("click");
  23984. removeRowBtn.removeClass(that.options.styles.remove);
  23985. removeRowBtn.attr("title", that.options.strings.status.success)
  23986. };
  23987. var renderErrorInfoRowFromTemplate = function (that, fileRow, error) {
  23988. var errorRow = that.errorInfoRowTemplate.clone();
  23989. errorRow.prop("id", fileRow.prop("id") + "_error");
  23990. var errorType = fluid.keyForValue(fluid.uploader.errorConstants, error);
  23991. var errorMsg = that.options.strings.errors[errorType];
  23992. that.locate("errorText", errorRow).text(errorMsg);
  23993. fileRow.after(errorRow);
  23994. that.scroller.scrollTo(errorRow)
  23995. };
  23996. var showErrorForFile = function (that, file, error) {
  23997. hideFileProgress(that, file);
  23998. if (file.filestatus === fluid.uploader.fileStatusConstants.ERROR) {
  23999. var fileRowElm = rowForFile(that, file);
  24000. changeRowState(that, fileRowElm, that.options.styles.error);
  24001. renderErrorInfoRowFromTemplate(that, fileRowElm, error)
  24002. }
  24003. };
  24004. var addKeyboardNavigation = function (that) {
  24005. fluid.tabbable(that.container);
  24006. that.selectableContext = fluid.selectable(that.container, {
  24007. selectableSelector : that.options.selectors.fileRows,
  24008. onSelect : function (itemToSelect) {
  24009. $(itemToSelect).addClass(that.options.styles.selected)
  24010. },
  24011. onUnselect : function (selectedItem) {
  24012. $(selectedItem).removeClass(that.options.styles.selected)
  24013. }
  24014. })
  24015. };
  24016. var prepareTemplateElements = function (that) {
  24017. that.rowTemplate = that.locate("rowTemplate").remove();
  24018. that.errorInfoRowTemplate = that.locate("errorInfoRowTemplate").remove();
  24019. that.errorInfoRowTemplate.removeClass(that.options.styles.hiddenTemplate);
  24020. that.rowProgressorTemplate = that.locate("rowProgressorTemplate", that.options.uploaderContainer).remove()
  24021. };
  24022. fluid.registerNamespace("fluid.uploader.fileQueueView");
  24023. fluid.uploader.fileQueueView.finalInit = function (that) {
  24024. prepareTemplateElements(that);
  24025. addKeyboardNavigation(that)
  24026. };
  24027. fluid.uploader.fileQueueView.preInit = function (that) {
  24028. that.fileProgressors = {};
  24029. that.addFile = function (file) {
  24030. addFile(that, file)
  24031. };
  24032. that.removeFile = function (file) {
  24033. removeRowForFile(that, file)
  24034. };
  24035. that.prepareForUpload = function () {
  24036. prepareForUpload(that)
  24037. };
  24038. that.refreshAfterUpload = function () {
  24039. refreshAfterUpload(that)
  24040. };
  24041. that.showFileProgress = function (file) {
  24042. startFileProgress(that, file)
  24043. };
  24044. that.updateFileProgress = function (file, fileBytesComplete, fileTotalBytes) {
  24045. updateFileProgress(that, file, fileBytesComplete, fileTotalBytes)
  24046. };
  24047. that.markFileComplete = function (file) {
  24048. progressorForFile(that, file).update(100, "100%");
  24049. markRowAsComplete(that, file)
  24050. };
  24051. that.showErrorForFile = function (file, error) {
  24052. showErrorForFile(that, file, error)
  24053. };
  24054. that.hideFileProgress = function (file) {
  24055. hideFileProgress(that, file)
  24056. };
  24057. that.refreshView = function () {
  24058. that.selectableContext.refresh();
  24059. that.scroller.refreshView()
  24060. }
  24061. };
  24062. fluid.defaults("fluid.uploader.fileQueueView", {
  24063. gradeNames : ["fluid.viewComponent", "autoInit"],
  24064. preInitFunction : "fluid.uploader.fileQueueView.preInit",
  24065. finalInitFunction : "fluid.uploader.fileQueueView.finalInit",
  24066. components : {
  24067. scroller : {
  24068. type : "fluid.scrollableTable"
  24069. },
  24070. eventBinder : {
  24071. type : "fluid.uploader.fileQueueView.eventBinder"
  24072. }
  24073. },
  24074. selectors : {
  24075. fileRows : ".flc-uploader-file",
  24076. fileName : ".flc-uploader-file-name",
  24077. fileSize : ".flc-uploader-file-size",
  24078. fileIconBtn : ".flc-uploader-file-action",
  24079. errorText : ".flc-uploader-file-error",
  24080. rowTemplate : ".flc-uploader-file-tmplt",
  24081. errorInfoRowTemplate : ".flc-uploader-file-error-tmplt",
  24082. rowProgressorTemplate : ".flc-uploader-file-progressor-tmplt"
  24083. },
  24084. styles : {
  24085. hover : "fl-uploader-file-hover",
  24086. selected : "fl-uploader-file-focus",
  24087. ready : "fl-uploader-file-state-ready",
  24088. uploading : "fl-uploader-file-state-uploading",
  24089. uploaded : "fl-uploader-file-state-uploaded",
  24090. error : "fl-uploader-file-state-error",
  24091. remove : "fl-uploader-file-action-remove",
  24092. dim : "fl-uploader-dim",
  24093. hiddenTemplate : "fl-uploader-hidden-templates"
  24094. },
  24095. strings : {
  24096. progress : {
  24097. toUploadLabel : "To upload: %fileCount %fileLabel (%totalBytes)",
  24098. singleFile : "file",
  24099. pluralFiles : "files"
  24100. },
  24101. status : {
  24102. success : "File Uploaded",
  24103. error : "File Upload Error",
  24104. remove : "Press Delete key to remove file"
  24105. },
  24106. errors : {
  24107. HTTP_ERROR : "File upload error: a network error occured or the file was rejected (reason unknown).",
  24108. IO_ERROR : "File upload error: a network error occured.",
  24109. UPLOAD_LIMIT_EXCEEDED : "File upload error: you have uploaded as many files as you are allowed during this session",
  24110. UPLOAD_FAILED : "File upload error: the upload failed for an unknown reason.",
  24111. QUEUE_LIMIT_EXCEEDED : "You have as many files in the queue as can be added at one time. Removing files from the queue may allow you to add different files.",
  24112. FILE_EXCEEDS_SIZE_LIMIT : "One or more of the files that you attempted to add to the queue exceeded the limit of %fileSizeLimit.",
  24113. ZERO_BYTE_FILE : "One or more of the files that you attempted to add contained no data.",
  24114. INVALID_FILETYPE : "One or more files were not added to the queue because they were of the wrong type."
  24115. }
  24116. },
  24117. events : {
  24118. onFileRemoved : null
  24119. },
  24120. mergePolicy : {
  24121. model : "preserve"
  24122. }
  24123. });
  24124. fluid.defaults("fluid.uploader.fileQueueView.eventBinder", {
  24125. gradeNames : ["fluid.eventedComponent", "autoInit"]
  24126. });
  24127. fluid.demands("fluid.uploader.fileQueueView.eventBinder", [], {});
  24128. fluid.scrollable = function (element, options) {
  24129. var that = fluid.initView("fluid.scrollable", element, options);
  24130. that.scrollable = that.options.makeScrollableFn(that.container, that.options);
  24131. that.maxHeight = that.scrollable.css("max-height");
  24132. that.scrollTo = function () {
  24133. that.scrollable.scrollTo.apply(that.scrollable, arguments)
  24134. };
  24135. that.refreshView = function () {
  24136. if ($.browser.msie && $.browser.version === "6.0") {
  24137. that.scrollable.css("height", "");
  24138. if (that.scrollable.height() >= parseInt(that.maxHeight, 10)) {
  24139. that.scrollable.css("height", that.maxHeight)
  24140. }
  24141. }
  24142. };
  24143. that.refreshView();
  24144. return that
  24145. };
  24146. fluid.scrollable.makeSimple = function (element, options) {
  24147. return fluid.container(element)
  24148. };
  24149. fluid.scrollable.makeTable = function (table, options) {
  24150. table.wrap(options.wrapperMarkup);
  24151. return table.closest(".fl-scrollable-scroller")
  24152. };
  24153. fluid.defaults("fluid.scrollable", {
  24154. makeScrollableFn : fluid.scrollable.makeSimple
  24155. });
  24156. fluid.scrollableTable = function (table, options) {
  24157. options = $.extend({}, fluid.defaults("fluid.scrollableTable"), options);
  24158. return fluid.scrollable(table, options)
  24159. };
  24160. fluid.defaults("fluid.scrollableTable", {
  24161. gradeNames : "fluid.viewComponent",
  24162. makeScrollableFn : fluid.scrollable.makeTable,
  24163. wrapperMarkup : "<div class='fl-scrollable-scroller'><div class='fl-scrollable-inner'></div></div>"
  24164. });
  24165. fluid.demands("fluid.scrollableTable", "fluid.uploader.fileQueueView", {
  24166. funcName : "fluid.scrollableTable",
  24167. args : ["{fileQueueView}.container"]
  24168. })
  24169. })(jQuery, fluid_1_4);
  24170. var fluid_1_4 = fluid_1_4 || {};
  24171. (function ($, fluid) {
  24172. fluid.uploader = fluid.uploader || {};
  24173. fluid.defaults("fluid.uploader.errorPanel", {
  24174. gradeNames : ["fluid.viewComponent", "autoInit"],
  24175. preInitFunction : "fluid.uploader.errorPanel.preInit",
  24176. postInitFunction : "fluid.uploader.errorPanel.renderSectionTemplates",
  24177. finalInitFunction : "fluid.uploader.errorPanel.finalInit",
  24178. components : {
  24179. fileSizeErrorSection : {
  24180. type : "fluid.uploader.errorPanel.section",
  24181. container : "{errorPanel}.dom.fileSizeErrorSection",
  24182. options : {
  24183. model : {
  24184. errorCode : fluid.uploader.queueErrorConstants.FILE_EXCEEDS_SIZE_LIMIT
  24185. },
  24186. strings : {
  24187. header : "{errorPanel}.options.strings.exceedsFileSize"
  24188. }
  24189. }
  24190. },
  24191. numFilesErrorSection : {
  24192. type : "fluid.uploader.errorPanel.section",
  24193. container : "{errorPanel}.dom.numFilesErrorSection",
  24194. options : {
  24195. model : {
  24196. errorCode : fluid.uploader.queueErrorConstants.QUEUE_LIMIT_EXCEEDED
  24197. },
  24198. strings : {
  24199. header : "{errorPanel}.options.strings.exceedsNumFilesLimit"
  24200. }
  24201. }
  24202. }
  24203. },
  24204. selectors : {
  24205. header : ".flc-uploader-errorPanel-header",
  24206. sectionTemplate : ".flc-uploader-errorPanel-section-tmplt",
  24207. fileSizeErrorSection : ".flc-uploader-errorPanel-section-fileSize",
  24208. numFilesErrorSection : ".flc-uploader-errorPanel-section-numFiles"
  24209. },
  24210. strings : {
  24211. headerText : "Warning(s)",
  24212. exceedsNumFilesLimit : "Too many files were selected. %numFiles were not added to the queue.",
  24213. exceedsFileSize : "%numFiles files were too large and were not added to the queue."
  24214. },
  24215. styles : {
  24216. hiddenTemplate : "fl-hidden-templates"
  24217. }
  24218. });
  24219. fluid.uploader.errorPanel.preInit = function (that) {
  24220. that.refreshView = function () {
  24221. for (var i = 0; i < that.sections.length; i++) {
  24222. if (that.sections[i].model.files.length > 0) {
  24223. that.container.show();
  24224. return
  24225. }
  24226. }
  24227. that.container.hide()
  24228. }
  24229. };
  24230. fluid.uploader.errorPanel.renderSectionTemplates = function (that) {
  24231. var sectionTmpl = that.locate("sectionTemplate").remove().removeClass(that.options.styles.hiddenTemplate);
  24232. that.locate("fileSizeErrorSection").append(sectionTmpl.clone());
  24233. that.locate("numFilesErrorSection").append(sectionTmpl.clone())
  24234. };
  24235. fluid.uploader.errorPanel.finalInit = function (that) {
  24236. that.sections = [that.fileSizeErrorSection, that.numFilesErrorSection];
  24237. that.locate("header").text(that.options.strings.headerText);
  24238. that.container.hide()
  24239. };
  24240. fluid.demands("fluid.uploader.errorPanel", "fluid.uploader.multiFileUploader", {
  24241. container : "{multiFileUploader}.dom.errorsPanel",
  24242. options : {
  24243. listeners : {
  24244. "{multiFileUploader}.events.afterFileDialog" : "{errorPanel}.refreshView"
  24245. }
  24246. }
  24247. });
  24248. fluid.defaults("fluid.uploader.errorPanel.section", {
  24249. gradeNames : ["fluid.viewComponent", "autoInit"],
  24250. preInitFunction : "fluid.uploader.errorPanel.section.preInit",
  24251. finalInitFunction : "fluid.uploader.errorPanel.section.finalInit",
  24252. model : {
  24253. errorCode : undefined,
  24254. files : [],
  24255. showingDetails : false
  24256. },
  24257. events : {
  24258. afterErrorsCleared : null
  24259. },
  24260. selectors : {
  24261. errorTitle : ".fl-uploader-errorPanel-section-title",
  24262. deleteErrorButton : ".flc-uploader-errorPanel-section-removeButton",
  24263. errorDetails : ".flc-uploader-errorPanel-section-details",
  24264. erroredFiles : ".flc-uploader-errorPanel-section-files",
  24265. showHideFilesToggle : ".flc-uploader-errorPanel-section-toggleDetails"
  24266. },
  24267. strings : {
  24268. hideFiles : "Hide files",
  24269. showFiles : "Show files",
  24270. fileListDelimiter : ", "
  24271. }
  24272. });
  24273. fluid.uploader.errorPanel.section.preInit = function (that) {
  24274. that.toggleDetails = function () {
  24275. var detailsAction = that.model.showingDetails ? that.hideDetails : that.showDetails;
  24276. detailsAction()
  24277. };
  24278. that.showDetails = function () {
  24279. that.locate("errorDetails").show();
  24280. that.locate("showHideFilesToggle").text(that.options.strings.hideFiles);
  24281. that.model.showingDetails = true
  24282. };
  24283. that.hideDetails = function () {
  24284. that.locate("errorDetails").hide();
  24285. that.locate("showHideFilesToggle").text(that.options.strings.showFiles);
  24286. that.model.showingDetails = false
  24287. };
  24288. that.addFile = function (file, errorCode) {
  24289. if (errorCode === that.model.errorCode) {
  24290. that.model.files.push(file.name);
  24291. that.refreshView()
  24292. }
  24293. };
  24294. that.clear = function () {
  24295. that.model.files = [];
  24296. that.refreshView();
  24297. that.events.afterErrorsCleared.fire()
  24298. };
  24299. that.refreshView = function () {
  24300. fluid.uploader.errorPanel.section.renderHeader(that);
  24301. fluid.uploader.errorPanel.section.renderErrorDetails(that);
  24302. that.hideDetails();
  24303. if (that.model.files.length <= 0) {
  24304. that.container.hide()
  24305. } else {
  24306. that.container.show()
  24307. }
  24308. }
  24309. };
  24310. fluid.uploader.errorPanel.section.finalInit = function (that) {
  24311. that.locate("deleteErrorButton").click(that.clear);
  24312. that.locate("showHideFilesToggle").click(that.toggleDetails);
  24313. that.refreshView()
  24314. };
  24315. fluid.uploader.errorPanel.section.renderHeader = function (that) {
  24316. var errorTitle = fluid.stringTemplate(that.options.strings.header, {
  24317. numFiles : that.model.files.length
  24318. });
  24319. that.locate("errorTitle").text(errorTitle)
  24320. };
  24321. fluid.uploader.errorPanel.section.renderErrorDetails = function (that) {
  24322. var files = that.model.files;
  24323. var filesList = files.length > 0 ? files.join(that.options.strings.fileListDelimiter) : "";
  24324. that.locate("erroredFiles").text(filesList)
  24325. };
  24326. fluid.demands("fluid.uploader.errorPanel.section", ["fluid.uploader.errorPanel", "fluid.uploader.multiFileUploader"], {
  24327. options : {
  24328. listeners : {
  24329. "{multiFileUploader}.events.onQueueError" : "{section}.addFile",
  24330. "{multiFileUploader}.events.onFilesSelected" : "{section}.clear",
  24331. "{multiFileUploader}.events.onUploadStart" : "{section}.clear",
  24332. "{section}.events.afterErrorsCleared" : "{errorPanel}.refreshView"
  24333. }
  24334. }
  24335. })
  24336. })(jQuery, fluid_1_4);
  24337. var fluid_1_4 = fluid_1_4 || {};
  24338. (function ($, fluid) {
  24339. fluid.uploader = fluid.uploader || {};
  24340. fluid.demands("fluid.uploaderImpl", "fluid.uploader.swfUpload", {
  24341. funcName : "fluid.uploader.multiFileUploader"
  24342. });
  24343. fluid.uploader.swfUploadStrategy = function (options) {
  24344. var that = fluid.initLittleComponent("fluid.uploader.swfUploadStrategy", options);
  24345. fluid.initDependents(that);
  24346. return that
  24347. };
  24348. fluid.defaults("fluid.uploader.swfUploadStrategy", {
  24349. components : {
  24350. engine : {
  24351. type : "fluid.uploader.swfUploadStrategy.engine",
  24352. options : {
  24353. queueSettings : "{multiFileUploader}.options.queueSettings",
  24354. flashMovieSettings : "{swfUploadStrategy}.options.flashMovieSettings"
  24355. }
  24356. },
  24357. local : {
  24358. type : "fluid.uploader.local",
  24359. options : {
  24360. errorHandler : "{multiFileUploader}.dom.errorHandler"
  24361. }
  24362. },
  24363. remote : {
  24364. type : "fluid.uploader.remote"
  24365. }
  24366. },
  24367. flashMovieSettings : {
  24368. flashURL : "../../../lib/swfupload/flash/swfupload.swf",
  24369. flashButtonPeerId : "",
  24370. flashButtonAlwaysVisible : false,
  24371. flashButtonTransparentEvenInIE : true,
  24372. flashButtonImageURL : "../images/browse.png",
  24373. flashButtonCursorEffect : SWFUpload.CURSOR.HAND,
  24374. debug : false
  24375. },
  24376. styles : {
  24377. browseButtonOverlay : "fl-uploader-browse-overlay",
  24378. flash9Container : "fl-uploader-flash9-container",
  24379. uploaderWrapperFlash10 : "fl-uploader-flash10-wrapper"
  24380. }
  24381. });
  24382. fluid.demands("fluid.uploader.progressiveStrategy", "fluid.uploader.swfUpload", {
  24383. funcName : "fluid.uploader.swfUploadStrategy"
  24384. });
  24385. fluid.uploader.swfUploadStrategy.remote = function (swfUpload, queue, options) {
  24386. var that = fluid.initLittleComponent("fluid.uploader.swfUploadStrategy.remote", options);
  24387. that.swfUpload = swfUpload;
  24388. that.queue = queue;
  24389. that.uploadNextFile = function () {
  24390. that.swfUpload.startUpload()
  24391. };
  24392. that.stop = function () {
  24393. that.queue.shouldStop = true
  24394. };
  24395. return that
  24396. };
  24397. fluid.demands("fluid.uploader.remote", "fluid.uploader.swfUploadStrategy", {
  24398. funcName : "fluid.uploader.swfUploadStrategy.remote",
  24399. args : ["{engine}.swfUpload", "{multiFileUploader}.queue", "{options}"]
  24400. });
  24401. fluid.uploader.swfUploadStrategy.local = function (swfUpload, options) {
  24402. var that = fluid.initLittleComponent("fluid.uploader.swfUploadStrategy.local", options);
  24403. that.swfUpload = swfUpload;
  24404. that.browse = function () {
  24405. if (that.options.file_queue_limit === 1) {
  24406. that.swfUpload.selectFile()
  24407. } else {
  24408. that.swfUpload.selectFiles()
  24409. }
  24410. };
  24411. that.removeFile = function (file) {
  24412. that.swfUpload.cancelUpload(file.id)
  24413. };
  24414. that.enableBrowseButton = function () {
  24415. that.swfUpload.setButtonDisabled(false)
  24416. };
  24417. that.disableBrowseButton = function () {
  24418. that.swfUpload.setButtonDisabled(true)
  24419. };
  24420. return that
  24421. };
  24422. fluid.demands("fluid.uploader.local", "fluid.uploader.swfUploadStrategy", {
  24423. funcName : "fluid.uploader.swfUploadStrategy.local",
  24424. args : ["{engine}.swfUpload", "{options}"]
  24425. });
  24426. fluid.uploader.swfUploadStrategy.engine = function (options) {
  24427. var that = fluid.initLittleComponent("fluid.uploader.swfUploadStrategy.engine", options);
  24428. var flashVersion = swfobject.getFlashPlayerVersion().major;
  24429. that.flashVersionContext = fluid.typeTag("fluid.uploader.flash." + flashVersion);
  24430. that.config = $.extend({}, that.options.queueSettings, that.options.flashMovieSettings);
  24431. fluid.initDependents(that);
  24432. that.flashContainer = that.setupDOM();
  24433. that.swfUploadConfig = that.setupConfig();
  24434. that.swfUpload = new SWFUpload(that.swfUploadConfig);
  24435. that.bindEvents();
  24436. return that
  24437. };
  24438. fluid.defaults("fluid.uploader.swfUploadStrategy.engine", {
  24439. invokers : {
  24440. setupDOM : "fluid.uploader.swfUploadStrategy.setupDOM",
  24441. setupConfig : "fluid.uploader.swfUploadStrategy.setupConfig",
  24442. bindEvents : "fluid.uploader.swfUploadStrategy.eventBinder"
  24443. }
  24444. });
  24445. fluid.demands("fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.swfUploadStrategy", {
  24446. funcName : "fluid.uploader.swfUploadStrategy.engine",
  24447. args : [fluid.COMPONENT_OPTIONS]
  24448. });
  24449. fluid.uploader.swfUploadStrategy.fileTypeTransformer = function (model, expandSpec) {
  24450. var fileExts = "";
  24451. var mimeTypes = fluid.get(model, expandSpec.path);
  24452. var mimeTypesMap = fluid.uploader.mimeTypeRegistry;
  24453. if (!mimeTypes) {
  24454. return "*"
  24455. } else {
  24456. if (typeof(mimeTypes) === "string") {
  24457. return mimeTypes
  24458. }
  24459. }
  24460. fluid.each(mimeTypes, function (mimeType) {
  24461. fluid.each(mimeTypesMap, function (mimeTypeForExt, ext) {
  24462. if (mimeTypeForExt === mimeType) {
  24463. fileExts += "*." + ext + ";"
  24464. }
  24465. })
  24466. });
  24467. return fileExts.length === 0 ? "*" : fileExts.substring(0, fileExts.length - 1)
  24468. };
  24469. fluid.uploader.swfUploadStrategy.flash10SetupDOM = function (uploaderContainer, browseButton, progressBar, styles) {
  24470. uploaderContainer.wrap("<div class='" + styles.uploaderWrapperFlash10 + "'></div>");
  24471. var flashContainer = $("<div><span></span></div>");
  24472. flashContainer.addClass(styles.browseButtonOverlay);
  24473. uploaderContainer.after(flashContainer);
  24474. progressBar.append(flashContainer);
  24475. browseButton.attr("tabindex", -1);
  24476. return flashContainer
  24477. };
  24478. fluid.demands("fluid.uploader.swfUploadStrategy.setupDOM", ["fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.flash.10"], {
  24479. funcName : "fluid.uploader.swfUploadStrategy.flash10SetupDOM",
  24480. args : ["{multiFileUploader}.container", "{multiFileUploader}.dom.browseButton", "{totalProgress}.dom.progressBar", "{swfUploadStrategy}.options.styles"]
  24481. });
  24482. var swfUploadOptionsMap = {
  24483. uploadURL : "upload_url",
  24484. flashURL : "flash_url",
  24485. postParams : "post_params",
  24486. fileSizeLimit : "file_size_limit",
  24487. fileTypes : "file_types",
  24488. fileUploadLimit : "file_upload_limit",
  24489. fileQueueLimit : "file_queue_limit",
  24490. flashButtonPeerId : "button_placeholder_id",
  24491. flashButtonImageURL : "button_image_url",
  24492. flashButtonHeight : "button_height",
  24493. flashButtonWidth : "button_width",
  24494. flashButtonWindowMode : "button_window_mode",
  24495. flashButtonCursorEffect : "button_cursor",
  24496. debug : "debug"
  24497. };
  24498. var swfUploadEventMap = {
  24499. afterReady : "swfupload_loaded_handler",
  24500. onFileDialog : "file_dialog_start_handler",
  24501. onFileQueued : "file_queued_handler",
  24502. onQueueError : "file_queue_error_handler",
  24503. afterFileDialog : "file_dialog_complete_handler",
  24504. onFileStart : "upload_start_handler",
  24505. onFileProgress : "upload_progress_handler",
  24506. onFileComplete : "upload_complete_handler",
  24507. onFileError : "upload_error_handler",
  24508. onFileSuccess : "upload_success_handler"
  24509. };
  24510. var mapNames = function (nameMap, source, target) {
  24511. var result = target || {};
  24512. for (var key in source) {
  24513. var mappedKey = nameMap[key];
  24514. if (mappedKey) {
  24515. result[mappedKey] = source[key]
  24516. }
  24517. }
  24518. return result
  24519. };
  24520. var mapSWFUploadEvents = function (nameMap, events, target) {
  24521. var result = target || {};
  24522. for (var eventType in events) {
  24523. var fireFn = events[eventType].fire;
  24524. var mappedName = nameMap[eventType];
  24525. if (mappedName) {
  24526. result[mappedName] = fireFn
  24527. }
  24528. }
  24529. return result
  24530. };
  24531. fluid.uploader.swfUploadStrategy.convertConfigForSWFUpload = function (flashContainer, config, events, queueSettings) {
  24532. config.flashButtonPeerId = fluid.allocateSimpleId(flashContainer.children().eq(0));
  24533. config.fileTypes = fluid.uploader.swfUploadStrategy.fileTypeTransformer(queueSettings, {
  24534. path : "fileTypes"
  24535. });
  24536. var convertedConfig = mapNames(swfUploadOptionsMap, config);
  24537. convertedConfig.file_upload_limit = 0;
  24538. convertedConfig.file_size_limit = 0;
  24539. return mapSWFUploadEvents(swfUploadEventMap, events, convertedConfig)
  24540. };
  24541. fluid.uploader.swfUploadStrategy.flash10SetupConfig = function (config, events, flashContainer, browseButton, queueSettings) {
  24542. var isTransparent = config.flashButtonAlwaysVisible ? false : (!$.browser.msie || config.flashButtonTransparentEvenInIE);
  24543. config.flashButtonImageURL = isTransparent ? undefined : config.flashButtonImageURL;
  24544. config.flashButtonHeight = config.flashButtonHeight || browseButton.outerHeight();
  24545. config.flashButtonWidth = config.flashButtonWidth || browseButton.outerWidth();
  24546. config.flashButtonWindowMode = isTransparent ? SWFUpload.WINDOW_MODE.TRANSPARENT : SWFUpload.WINDOW_MODE.OPAQUE;
  24547. return fluid.uploader.swfUploadStrategy.convertConfigForSWFUpload(flashContainer, config, events, queueSettings)
  24548. };
  24549. fluid.demands("fluid.uploader.swfUploadStrategy.setupConfig", ["fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.flash.10"], {
  24550. funcName : "fluid.uploader.swfUploadStrategy.flash10SetupConfig",
  24551. args : ["{engine}.config", "{multiFileUploader}.events", "{engine}.flashContainer", "{multiFileUploader}.dom.browseButton", "{multiFileUploader}.options.queueSettings"]
  24552. });
  24553. var unbindSWFUploadSelectFiles = function () {
  24554. var emptyFunction = function () {};
  24555. SWFUpload.prototype.selectFile = emptyFunction;
  24556. SWFUpload.prototype.selectFiles = emptyFunction
  24557. };
  24558. fluid.uploader.swfUploadStrategy.bindFileEventListeners = function (model, events) {
  24559. var manualModelUpdater = function (file) {
  24560. fluid.find(model, function (potentialMatch) {
  24561. if (potentialMatch.id === file.id) {
  24562. potentialMatch.filestatus = file.filestatus;
  24563. return true
  24564. }
  24565. })
  24566. };
  24567. events.onFileStart.addListener(manualModelUpdater);
  24568. events.onFileProgress.addListener(manualModelUpdater);
  24569. events.onFileError.addListener(manualModelUpdater);
  24570. events.onFileSuccess.addListener(manualModelUpdater)
  24571. };
  24572. var filterErroredFiles = function (file, events, queue, queueSettings) {
  24573. var fileSizeLimit = queueSettings.fileSizeLimit * 1000;
  24574. var fileUploadLimit = queueSettings.fileUploadLimit;
  24575. var processedFiles = queue.getReadyFiles().length + queue.getUploadedFiles().length;
  24576. if (file.size > fileSizeLimit) {
  24577. file.filestatus = fluid.uploader.fileStatusConstants.ERROR;
  24578. events.onQueueError.fire(file, fluid.uploader.queueErrorConstants.FILE_EXCEEDS_SIZE_LIMIT)
  24579. } else {
  24580. if (processedFiles >= fileUploadLimit) {
  24581. events.onQueueError.fire(file, fluid.uploader.queueErrorConstants.QUEUE_LIMIT_EXCEEDED)
  24582. } else {
  24583. events.afterFileQueued.fire(file)
  24584. }
  24585. }
  24586. };
  24587. fluid.uploader.swfUploadStrategy.flash10EventBinder = function (queue, queueSettings, events) {
  24588. var model = queue.files;
  24589. unbindSWFUploadSelectFiles();
  24590. events.onFileQueued.addListener(function (file) {
  24591. filterErroredFiles(file, events, queue, queueSettings)
  24592. });
  24593. fluid.uploader.swfUploadStrategy.bindFileEventListeners(model, events)
  24594. };
  24595. fluid.demands("fluid.uploader.swfUploadStrategy.eventBinder", ["fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.flash.10"], {
  24596. funcName : "fluid.uploader.swfUploadStrategy.flash10EventBinder",
  24597. args : ["{multiFileUploader}.queue", "{multiFileUploader}.queue.files", "{multiFileUploader}.events"]
  24598. })
  24599. })(jQuery, fluid_1_4);
  24600. var fluid_1_4 = fluid_1_4 || {};
  24601. (function ($, fluid) {
  24602. fluid.registerNamespace("fluid.uploader.swfUploadStrategy");
  24603. fluid.uploader.swfUploadStrategy.flash9SetupDOM = function (styles) {
  24604. var container = $("<div><span></span></div>");
  24605. container.addClass(styles.flash9Container);
  24606. $("body").append(container);
  24607. return container
  24608. };
  24609. fluid.demands("fluid.uploader.swfUploadStrategy.setupDOM", ["fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.flash.9"], {
  24610. funcName : "fluid.uploader.swfUploadStrategy.flash9SetupDOM",
  24611. args : ["{swfUploadStrategy}.options.styles"]
  24612. });
  24613. fluid.uploader.swfUploadStrategy.flash9SetupConfig = function (flashContainer, config, events) {
  24614. return fluid.uploader.swfUploadStrategy.convertConfigForSWFUpload(flashContainer, config, events)
  24615. };
  24616. fluid.demands("fluid.uploader.swfUploadStrategy.setupConfig", ["fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.flash.9"], {
  24617. funcName : "fluid.uploader.swfUploadStrategy.flash9SetupConfig",
  24618. args : ["{engine}.flashContainer", "{engine}.config", "{multiFileUploader}.events"]
  24619. });
  24620. fluid.uploader.swfUploadStrategy.flash9EventBinder = function (model, events, local, browseButton) {
  24621. browseButton.click(function (e) {
  24622. local.browse();
  24623. e.preventDefault()
  24624. });
  24625. fluid.uploader.swfUploadStrategy.bindFileEventListeners(model, events)
  24626. };
  24627. fluid.demands("fluid.uploader.swfUploadStrategy.eventBinder", ["fluid.uploader.swfUploadStrategy.engine", "fluid.uploader.flash.9"], {
  24628. funcName : "fluid.uploader.swfUploadStrategy.flash9EventBinder",
  24629. args : ["{multiFileUploader}.queue.files", "{multiFileUploader}.events", "{local}", "{multiFileUploader}.dom.browseButton"]
  24630. })
  24631. })(jQuery, fluid_1_4);
  24632. var fluid_1_4 = fluid_1_4 || {};
  24633. (function ($, fluid) {
  24634. fluid.demands("fluid.uploaderImpl", "fluid.uploader.html5", {
  24635. funcName : "fluid.uploader.multiFileUploader"
  24636. });
  24637. fluid.demands("fluid.uploader.progressiveStrategy", "fluid.uploader.html5", {
  24638. funcName : "fluid.uploader.html5Strategy"
  24639. });
  24640. fluid.defaults("fluid.uploader.html5Strategy", {
  24641. gradeNames : ["fluid.littleComponent", "autoInit"],
  24642. components : {
  24643. local : {
  24644. type : "fluid.uploader.local",
  24645. options : {
  24646. queueSettings : "{multiFileUploader}.options.queueSettings",
  24647. events : {
  24648. onFileDialog : "{multiFileUploader}.events.onFileDialog",
  24649. onFilesSelected : "{multiFileUploader}.events.onFilesSelected",
  24650. afterFileDialog : "{multiFileUploader}.events.afterFileDialog",
  24651. afterFileQueued : "{multiFileUploader}.events.afterFileQueued",
  24652. onQueueError : "{multiFileUploader}.events.onQueueError"
  24653. }
  24654. }
  24655. },
  24656. remote : {
  24657. type : "fluid.uploader.remote",
  24658. options : {
  24659. queueSettings : "{multiFileUploader}.options.queueSettings",
  24660. events : {
  24661. afterReady : "{multiFileUploader}.events.afterReady",
  24662. onFileStart : "{multiFileUploader}.events.onFileStart",
  24663. onFileProgress : "{multiFileUploader}.events.onFileProgress",
  24664. onFileSuccess : "{multiFileUploader}.events.onFileSuccess",
  24665. onFileError : "{multiFileUploader}.events.onFileError",
  24666. onFileComplete : "{multiFileUploader}.events.onFileComplete"
  24667. }
  24668. }
  24669. }
  24670. },
  24671. legacyBrowserFileLimit : 100000
  24672. });
  24673. fluid.uploader.html5Strategy.fileSuccessHandler = function (file, events, xhr) {
  24674. events.onFileSuccess.fire(file, xhr.responseText, xhr);
  24675. events.onFileComplete.fire(file)
  24676. };
  24677. fluid.uploader.html5Strategy.fileErrorHandler = function (file, events, xhr) {
  24678. events.onFileError.fire(file, fluid.uploader.errorConstants.UPLOAD_FAILED, xhr.status, xhr);
  24679. events.onFileComplete.fire(file)
  24680. };
  24681. fluid.uploader.html5Strategy.fileStopHandler = function (file, events, xhr) {
  24682. events.onFileError.fire(file, fluid.uploader.errorConstants.UPLOAD_STOPPED, xhr.status, xhr);
  24683. events.onFileComplete.fire(file)
  24684. };
  24685. fluid.uploader.html5Strategy.monitorFileUploadXHR = function (file, events, xhr) {
  24686. xhr.onreadystatechange = function () {
  24687. if (xhr.readyState === 4) {
  24688. var status = xhr.status;
  24689. if (status === 200) {
  24690. fluid.uploader.html5Strategy.fileSuccessHandler(file, events, xhr)
  24691. } else {
  24692. if (status === 0) {
  24693. fluid.uploader.html5Strategy.fileStopHandler(file, events, xhr)
  24694. } else {
  24695. fluid.uploader.html5Strategy.fileErrorHandler(file, events, xhr)
  24696. }
  24697. }
  24698. }
  24699. };
  24700. xhr.upload.onprogress = function (pe) {
  24701. events.onFileProgress.fire(file, pe.loaded, pe.total)
  24702. }
  24703. };
  24704. fluid.uploader.html5Strategy.remote = function (queue, options) {
  24705. var that = fluid.initLittleComponent("fluid.uploader.html5Strategy.remote", options);
  24706. that.queue = queue;
  24707. that.queueSettings = that.options.queueSettings;
  24708. that.uploadNextFile = function () {
  24709. var batch = that.queue.currentBatch;
  24710. var file = batch.files[batch.fileIdx];
  24711. that.uploadFile(file)
  24712. };
  24713. that.uploadFile = function (file) {
  24714. that.events.onFileStart.fire(file);
  24715. that.currentXHR = that.createXHR();
  24716. fluid.uploader.html5Strategy.monitorFileUploadXHR(file, that.events, that.currentXHR);
  24717. that.fileSender.send(file, that.queueSettings, that.currentXHR)
  24718. };
  24719. that.stop = function () {
  24720. that.queue.isUploading = false;
  24721. that.currentXHR.abort()
  24722. };
  24723. fluid.initDependents(that);
  24724. that.events.afterReady.fire();
  24725. return that
  24726. };
  24727. fluid.defaults("fluid.uploader.html5Strategy.remote", {
  24728. gradeNames : ["fluid.eventedComponent"],
  24729. argumentMap : {
  24730. options : 1
  24731. },
  24732. components : {
  24733. fileSender : {
  24734. type : "fluid.uploader.html5Strategy.fileSender"
  24735. }
  24736. },
  24737. invokers : {
  24738. createXHR : "fluid.uploader.html5Strategy.createXHR"
  24739. }
  24740. });
  24741. fluid.demands("fluid.uploader.remote", ["fluid.uploader.html5Strategy", "fluid.uploader.live"], {
  24742. funcName : "fluid.uploader.html5Strategy.remote",
  24743. args : ["{multiFileUploader}.queue", fluid.COMPONENT_OPTIONS]
  24744. });
  24745. fluid.uploader.html5Strategy.createXHR = function () {
  24746. return new XMLHttpRequest()
  24747. };
  24748. fluid.uploader.html5Strategy.createFormData = function () {
  24749. return new FormData()
  24750. };
  24751. var setPostParams = function (formData, postParams) {
  24752. $.each(postParams, function (key, value) {
  24753. formData.append(key, value)
  24754. })
  24755. };
  24756. fluid.defaults("fluid.uploader.html5Strategy.formDataSender", {
  24757. gradeNames : ["fluid.littleComponent", "autoInit"],
  24758. finalInitFunction : "fluid.uploader.html5Strategy.formDataSender.init",
  24759. invokers : {
  24760. createFormData : "fluid.uploader.html5Strategy.createFormData"
  24761. }
  24762. });
  24763. fluid.uploader.html5Strategy.formDataSender.init = function (that) {
  24764. that.send = function (file, queueSettings, xhr) {
  24765. var formData = that.createFormData();
  24766. formData.append("file", file);
  24767. setPostParams(formData, queueSettings.postParams);
  24768. xhr.open("POST", queueSettings.uploadURL, true);
  24769. xhr.send(formData);
  24770. return formData
  24771. }
  24772. };
  24773. fluid.demands("fluid.uploader.html5Strategy.fileSender", ["fluid.uploader.html5Strategy.remote", "fluid.browser.supportsFormData"], {
  24774. funcName : "fluid.uploader.html5Strategy.formDataSender"
  24775. });
  24776. fluid.uploader.html5Strategy.generateMultipartBoundary = function () {
  24777. var boundary = "---------------------------";
  24778. boundary += Math.floor(Math.random() * 32768);
  24779. boundary += Math.floor(Math.random() * 32768);
  24780. boundary += Math.floor(Math.random() * 32768);
  24781. return boundary
  24782. };
  24783. fluid.uploader.html5Strategy.generateMultiPartContent = function (boundary, file) {
  24784. var CRLF = "\r\n";
  24785. var multipart = "";
  24786. multipart += "--" + boundary + CRLF;
  24787. multipart += 'Content-Disposition: form-data; name="fileData"; filename="' + file.name + '"' + CRLF;
  24788. multipart += "Content-Type: " + file.type + CRLF + CRLF;
  24789. multipart += file.getAsBinary();
  24790. multipart += CRLF + "--" + boundary + "--" + CRLF;
  24791. return multipart
  24792. };
  24793. fluid.defaults("fluid.uploader.html5Strategy.rawMIMESender", {
  24794. gradeNames : ["fluid.littleComponent", "autoInit"],
  24795. finalInitFunction : "fluid.uploader.html5Strategy.rawMIMESender.init"
  24796. });
  24797. fluid.uploader.html5Strategy.rawMIMESender.init = function (that) {
  24798. that.send = function (file, queueSettings, xhr) {
  24799. var boundary = fluid.uploader.html5Strategy.generateMultipartBoundary();
  24800. var multipart = fluid.uploader.html5Strategy.generateMultiPartContent(boundary, file);
  24801. xhr.open("POST", queueSettings.uploadURL, true);
  24802. xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
  24803. xhr.sendAsBinary(multipart);
  24804. return multipart
  24805. }
  24806. };
  24807. fluid.demands("fluid.uploader.html5Strategy.fileSender", "fluid.uploader.html5Strategy.remote", {
  24808. funcName : "fluid.uploader.html5Strategy.rawMIMESender"
  24809. });
  24810. fluid.uploader.html5Strategy.local = function (queue, legacyBrowserFileLimit, options) {
  24811. var that = fluid.initLittleComponent("fluid.uploader.html5Strategy.local", options);
  24812. that.queue = queue;
  24813. that.queueSettings = that.options.queueSettings;
  24814. that.addFiles = function (files) {
  24815. var sizeLimit = (legacyBrowserFileLimit || that.queueSettings.fileSizeLimit) * 1024;
  24816. var fileLimit = that.queueSettings.fileUploadLimit;
  24817. var uploaded = that.queue.getUploadedFiles().length;
  24818. var queued = that.queue.getReadyFiles().length;
  24819. var remainingUploadLimit = fileLimit - uploaded - queued;
  24820. that.events.onFilesSelected.fire(files.length);
  24821. var numFilesAdded = 0;
  24822. for (var i = 0; i < files.length; i++) {
  24823. var file = files[i];
  24824. if (fileLimit && remainingUploadLimit === 0) {
  24825. that.events.onQueueError.fire(file, fluid.uploader.queueErrorConstants.QUEUE_LIMIT_EXCEEDED)
  24826. } else {
  24827. if (file.size >= sizeLimit) {
  24828. file.filestatus = fluid.uploader.fileStatusConstants.ERROR;
  24829. that.events.onQueueError.fire(file, fluid.uploader.queueErrorConstants.FILE_EXCEEDS_SIZE_LIMIT)
  24830. } else {
  24831. if (!fileLimit || remainingUploadLimit > 0) {
  24832. file.id = "file-" + fluid.allocateGuid();
  24833. file.filestatus = fluid.uploader.fileStatusConstants.QUEUED;
  24834. that.events.afterFileQueued.fire(file);
  24835. remainingUploadLimit--;
  24836. numFilesAdded++
  24837. }
  24838. }
  24839. }
  24840. }
  24841. that.events.afterFileDialog.fire(numFilesAdded)
  24842. };
  24843. that.removeFile = function (file) {};
  24844. that.enableBrowseButton = function () {
  24845. that.browseButtonView.enable()
  24846. };
  24847. that.disableBrowseButton = function () {
  24848. that.browseButtonView.disable()
  24849. };
  24850. fluid.initDependents(that);
  24851. return that
  24852. };
  24853. fluid.defaults("fluid.uploader.html5Strategy.local", {
  24854. argumentMap : {
  24855. options : 2
  24856. },
  24857. gradeNames : ["fluid.eventedComponent"],
  24858. components : {
  24859. browseButtonView : {
  24860. type : "fluid.uploader.html5Strategy.browseButtonView",
  24861. options : {
  24862. queueSettings : "{multiFileUploader}.options.queueSettings",
  24863. selectors : {
  24864. browseButton : "{multiFileUploader}.selectors.browseButton"
  24865. },
  24866. listeners : {
  24867. onFilesQueued : "{local}.addFiles"
  24868. }
  24869. }
  24870. }
  24871. }
  24872. });
  24873. fluid.demands("fluid.uploader.local", "fluid.uploader.html5Strategy", {
  24874. funcName : "fluid.uploader.html5Strategy.local",
  24875. args : ["{multiFileUploader}.queue", "{html5Strategy}.options.legacyBrowserFileLimit", "{options}"]
  24876. });
  24877. fluid.demands("fluid.uploader.local", ["fluid.uploader.html5Strategy", "fluid.browser.supportsFormData"], {
  24878. funcName : "fluid.uploader.html5Strategy.local",
  24879. args : ["{multiFileUploader}.queue", undefined, "{options}"]
  24880. });
  24881. var bindEventsToFileInput = function (that, fileInput) {
  24882. fileInput.click(function () {
  24883. that.events.onBrowse.fire()
  24884. });
  24885. fileInput.change(function () {
  24886. var files = fileInput[0].files;
  24887. that.renderFreshMultiFileInput();
  24888. that.events.onFilesQueued.fire(files)
  24889. });
  24890. fileInput.focus(function () {
  24891. that.browseButton.addClass("focus")
  24892. });
  24893. fileInput.blur(function () {
  24894. that.browseButton.removeClass("focus")
  24895. })
  24896. };
  24897. var renderMultiFileInput = function (that) {
  24898. var multiFileInput = $(that.options.multiFileInputMarkup);
  24899. var fileTypes = that.options.queueSettings.fileTypes;
  24900. if (fluid.isArrayable(fileTypes)) {
  24901. fileTypes = fileTypes.join();
  24902. multiFileInput.attr("accept", fileTypes)
  24903. }
  24904. bindEventsToFileInput(that, multiFileInput);
  24905. return multiFileInput
  24906. };
  24907. var setupBrowseButtonView = function (that) {
  24908. var multiFileInput = renderMultiFileInput(that);
  24909. that.browseButton.append(multiFileInput);
  24910. that.browseButton.attr("tabindex", -1)
  24911. };
  24912. fluid.uploader.html5Strategy.browseButtonView = function (container, options) {
  24913. var that = fluid.initView("fluid.uploader.html5Strategy.browseButtonView", container, options);
  24914. that.browseButton = that.locate("browseButton");
  24915. that.renderFreshMultiFileInput = function () {
  24916. var previousInput = that.locate("fileInputs").last();
  24917. previousInput.hide();
  24918. previousInput.attr("tabindex", -1);
  24919. var newInput = renderMultiFileInput(that);
  24920. previousInput.after(newInput)
  24921. };
  24922. that.enable = function () {
  24923. that.locate("fileInputs").prop("disabled", false)
  24924. };
  24925. that.disable = function () {
  24926. that.locate("fileInputs").prop("disabled", true)
  24927. };
  24928. that.isEnabled = function () {
  24929. return !that.locate("fileInputs").prop("disabled")
  24930. };
  24931. setupBrowseButtonView(that);
  24932. return that
  24933. };
  24934. fluid.defaults("fluid.uploader.html5Strategy.browseButtonView", {
  24935. gradeNames : "fluid.viewComponent",
  24936. multiFileInputMarkup : "<input type='file' multiple='' class='flc-uploader-html5-input' />",
  24937. queueSettings : {},
  24938. selectors : {
  24939. browseButton : ".flc-uploader-button-browse",
  24940. fileInputs : ".flc-uploader-html5-input"
  24941. },
  24942. events : {
  24943. onBrowse : null,
  24944. onFilesQueued : null
  24945. }
  24946. });
  24947. fluid.demands("fluid.uploader.html5Strategy.browseButtonView", "fluid.uploader.html5Strategy.local", {
  24948. container : "{multiFileUploader}.container",
  24949. mergeOptions : {
  24950. events : {
  24951. onBrowse : "{local}.events.onFileDialog"
  24952. }
  24953. }
  24954. })
  24955. })(jQuery, fluid_1_4);
  24956. var fluid_1_4 = fluid_1_4 || {};
  24957. (function ($, fluid) {
  24958. fluid.uploader = fluid.uploader || {};
  24959. var startUploading;
  24960. var updateProgress = function (file, events, demoState, isUploading) {
  24961. if (!isUploading) {
  24962. return
  24963. }
  24964. var chunk = Math.min(demoState.chunkSize, file.size);
  24965. demoState.bytesUploaded = Math.min(demoState.bytesUploaded + chunk, file.size);
  24966. events.onFileProgress.fire(file, demoState.bytesUploaded, file.size)
  24967. };
  24968. var finishAndContinueOrCleanup = function (that, file) {
  24969. that.queue.finishFile(file);
  24970. that.events.afterFileComplete.fire(file);
  24971. if (that.queue.shouldUploadNextFile()) {
  24972. startUploading(that)
  24973. } else {
  24974. that.events.afterUploadComplete.fire(that.queue.currentBatch.files);
  24975. if (file.status !== fluid.uploader.fileStatusConstants.CANCELLED) {
  24976. that.queue.clearCurrentBatch()
  24977. }
  24978. }
  24979. };
  24980. var finishUploading = function (that) {
  24981. if (!that.queue.isUploading) {
  24982. return
  24983. }
  24984. var file = that.demoState.currentFile;
  24985. that.events.onFileSuccess.fire(file);
  24986. that.demoState.fileIdx++;
  24987. finishAndContinueOrCleanup(that, file)
  24988. };
  24989. var simulateUpload = function (that) {
  24990. if (!that.queue.isUploading) {
  24991. return
  24992. }
  24993. var file = that.demoState.currentFile;
  24994. if (that.demoState.bytesUploaded < file.size) {
  24995. fluid.invokeAfterRandomDelay(function () {
  24996. updateProgress(file, that.events, that.demoState, that.queue.isUploading);
  24997. simulateUpload(that)
  24998. })
  24999. } else {
  25000. finishUploading(that)
  25001. }
  25002. };
  25003. startUploading = function (that) {
  25004. that.demoState.currentFile = that.queue.files[that.demoState.fileIdx];
  25005. that.demoState.chunksForCurrentFile = Math.ceil(that.demoState.currentFile / that.demoState.chunkSize);
  25006. that.demoState.bytesUploaded = 0;
  25007. that.queue.isUploading = true;
  25008. that.events.onFileStart.fire(that.demoState.currentFile);
  25009. simulateUpload(that)
  25010. };
  25011. var stopDemo = function (that) {
  25012. var file = that.demoState.currentFile;
  25013. file.filestatus = fluid.uploader.fileStatusConstants.CANCELLED;
  25014. that.queue.shouldStop = true;
  25015. that.events.onFileError.fire(file, fluid.uploader.errorConstants.UPLOAD_STOPPED, "The demo upload was paused by the user.");
  25016. finishAndContinueOrCleanup(that, file);
  25017. that.events.onUploadStop.fire()
  25018. };
  25019. var setupDemo = function (that) {
  25020. if (that.simulateDelay === undefined || that.simulateDelay === null) {
  25021. that.simulateDelay = true
  25022. }
  25023. that.demoState = {
  25024. fileIdx : 0,
  25025. chunkSize : 200000
  25026. };
  25027. return that
  25028. };
  25029. fluid.uploader.demoRemote = function (queue, options) {
  25030. var that = fluid.initLittleComponent("fluid.uploader.demoRemote", options);
  25031. that.queue = queue;
  25032. that.uploadNextFile = function () {
  25033. startUploading(that)
  25034. };
  25035. that.stop = function () {
  25036. stopDemo(that)
  25037. };
  25038. setupDemo(that);
  25039. return that
  25040. };
  25041. fluid.invokeAfterRandomDelay = function (fn) {
  25042. var delay = Math.floor(Math.random() * 1000 + 100);
  25043. setTimeout(fn, delay)
  25044. };
  25045. fluid.defaults("fluid.uploader.demoRemote", {
  25046. gradeNames : ["fluid.eventedComponent"],
  25047. argumentMap : {
  25048. options : 1
  25049. },
  25050. events : {
  25051. onFileProgress : "{multiFileUploader}.events.onFileProgress",
  25052. afterFileComplete : "{multiFileUploader}.events.afterFileComplete",
  25053. afterUploadComplete : "{multiFileUploader}.events.afterUploadComplete",
  25054. onFileSuccess : "{multiFileUploader}.events.onFileSuccess",
  25055. onFileStart : "{multiFileUploader}.events.onFileStart",
  25056. onFileError : "{multiFileUploader}.events.onFileError",
  25057. onUploadStop : "{multiFileUploader}.events.onUploadStop"
  25058. }
  25059. });
  25060. fluid.demands("fluid.uploader.remote", ["fluid.uploader.multiFileUploader", "fluid.uploader.demo"], {
  25061. funcName : "fluid.uploader.demoRemote",
  25062. args : ["{multiFileUploader}.queue", "{multiFileUploader}.events", fluid.COMPONENT_OPTIONS]
  25063. })
  25064. })(jQuery, fluid_1_4);
  25065. var fluid_1_4 = fluid_1_4 || {};
  25066. (function (fluid) {
  25067. fluid.uploader = fluid.uploader || {};
  25068. fluid.uploader.mimeTypeRegistry = {
  25069. jpg : "image/jpeg",
  25070. jpeg : "image/jpeg",
  25071. bmp : "image/bmp",
  25072. png : "image/png",
  25073. tif : "image/tiff",
  25074. tiff : "image/tiff",
  25075. mp3 : "audio/mpeg",
  25076. m4a : "audio/mp4a-latm",
  25077. ogg : "audio/ogg",
  25078. wav : "audio/x-wav",
  25079. aiff : "audio/x-aiff",
  25080. mpg : "video/mpeg",
  25081. mpeg : "video/mpeg",
  25082. m4v : "video/x-m4v",
  25083. ogv : "video/ogg",
  25084. mov : "video/quicktime",
  25085. avi : "video/x-msvideo",
  25086. html : "text/html",
  25087. htm : "text/html",
  25088. text : "text/plain",
  25089. doc : "application/msword",
  25090. docx : "application/msword",
  25091. xls : "application/vnd.ms-excel",
  25092. xlsx : "application/vnd.ms-excel",
  25093. ppt : "application/vnd.ms-powerpoint",
  25094. pptx : "application/vnd.ms-powerpoint"
  25095. }
  25096. })(fluid_1_4);