ext-modern-debug.js 2.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613
  1. /*
  2. This file is part of Ext JS 7.0.0.168
  3. Copyright (c) 2011-2020 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Version: 7.0.0.168 Build date: 2020-01-14 07:07:49 (513838d69a96c96beec9d0851e67aa660b7f288d)
  14. */
  15. // @tag core
  16. var Ext = Ext || {};
  17. Ext.Boot = Ext.Boot || (function(emptyFn) {
  18. var doc = document,
  19. _emptyArray = [],
  20. _config = {
  21. disableCaching: (/[?&](?:cache|disableCacheBuster)\b/i.test(location.search) || !(/http[s]?\:/i.test(location.href)) || /(^|[ ;])ext-cache=1/.test(doc.cookie)) ? false : true,
  22. disableCachingParam: '_dc',
  23. loadDelay: false,
  24. preserveScripts: true,
  25. charset: 'UTF-8'
  26. },
  27. _assetConfig = {},
  28. cssRe = /\.css(?:\?|$)/i,
  29. resolverEl = doc.createElement('a'),
  30. isBrowser = typeof window !== 'undefined',
  31. _environment = {
  32. browser: isBrowser,
  33. node: !isBrowser && (typeof require === 'function'),
  34. phantom: (window && (window._phantom || window.callPhantom)) || /PhantomJS/.test(window.navigator.userAgent)
  35. },
  36. _tags = (Ext.platformTags = {}),
  37. _debug = function(message) {},
  38. _apply = function(object, config, defaults) {
  39. if (defaults) {
  40. _apply(object, defaults);
  41. }
  42. if (object && config && typeof config === 'object') {
  43. for (var i in config) {
  44. object[i] = config[i];
  45. }
  46. }
  47. return object;
  48. },
  49. _merge = function() {
  50. var lowerCase = false,
  51. obj = Array.prototype.shift.call(arguments),
  52. index, i, len, value;
  53. if (typeof arguments[arguments.length - 1] === 'boolean') {
  54. lowerCase = Array.prototype.pop.call(arguments);
  55. }
  56. len = arguments.length;
  57. for (index = 0; index < len; index++) {
  58. value = arguments[index];
  59. if (typeof value === 'object') {
  60. for (i in value) {
  61. obj[lowerCase ? i.toLowerCase() : i] = value[i];
  62. }
  63. }
  64. }
  65. return obj;
  66. },
  67. _getKeys = (typeof Object.keys == 'function') ? function(object) {
  68. if (!object) {
  69. return [];
  70. }
  71. return Object.keys(object);
  72. } : function(object) {
  73. var keys = [],
  74. property;
  75. for (property in object) {
  76. if (object.hasOwnProperty(property)) {
  77. keys.push(property);
  78. }
  79. }
  80. return keys;
  81. },
  82. Boot = {
  83. loading: 0,
  84. loaded: 0,
  85. apply: _apply,
  86. env: _environment,
  87. config: _config,
  88. assetConfig: _assetConfig,
  89. scripts: {},
  90. currentFile: null,
  91. suspendedQueue: [],
  92. currentRequest: null,
  93. syncMode: false,
  94. debug: _debug,
  95. useElements: true,
  96. listeners: [],
  97. Request: Request,
  98. Entry: Entry,
  99. allowMultipleBrowsers: false,
  100. browserNames: {
  101. ie: 'IE',
  102. firefox: 'Firefox',
  103. safari: 'Safari',
  104. chrome: 'Chrome',
  105. opera: 'Opera',
  106. dolfin: 'Dolfin',
  107. edge: 'Edge',
  108. webosbrowser: 'webOSBrowser',
  109. chromeMobile: 'ChromeMobile',
  110. chromeiOS: 'ChromeiOS',
  111. silk: 'Silk',
  112. other: 'Other'
  113. },
  114. osNames: {
  115. ios: 'iOS',
  116. android: 'Android',
  117. windowsPhone: 'WindowsPhone',
  118. webos: 'webOS',
  119. blackberry: 'BlackBerry',
  120. rimTablet: 'RIMTablet',
  121. mac: 'MacOS',
  122. win: 'Windows',
  123. tizen: 'Tizen',
  124. linux: 'Linux',
  125. bada: 'Bada',
  126. chromeOS: 'ChromeOS',
  127. other: 'Other'
  128. },
  129. browserPrefixes: {
  130. ie: 'MSIE ',
  131. edge: 'Edge/',
  132. firefox: 'Firefox/',
  133. chrome: 'Chrome/',
  134. safari: 'Version/',
  135. opera: 'OPR/',
  136. dolfin: 'Dolfin/',
  137. webosbrowser: 'wOSBrowser/',
  138. chromeMobile: 'CrMo/',
  139. chromeiOS: 'CriOS/',
  140. silk: 'Silk/'
  141. },
  142. browserPriority: [
  143. 'edge',
  144. 'opera',
  145. 'dolfin',
  146. 'webosbrowser',
  147. 'silk',
  148. 'chromeiOS',
  149. 'chromeMobile',
  150. 'ie',
  151. 'firefox',
  152. 'safari',
  153. 'chrome'
  154. ],
  155. osPrefixes: {
  156. tizen: '(Tizen )',
  157. ios: 'i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ',
  158. android: '(Android |HTC_|Silk/)',
  159. windowsPhone: 'Windows Phone ',
  160. blackberry: '(?:BlackBerry|BB)(?:.*)Version/',
  161. rimTablet: 'RIM Tablet OS ',
  162. webos: '(?:webOS|hpwOS)/',
  163. bada: 'Bada/',
  164. chromeOS: 'CrOS '
  165. },
  166. fallbackOSPrefixes: {
  167. windows: 'win',
  168. mac: 'mac',
  169. linux: 'linux'
  170. },
  171. devicePrefixes: {
  172. iPhone: 'iPhone',
  173. iPod: 'iPod',
  174. iPad: 'iPad'
  175. },
  176. maxIEVersion: 12,
  177. detectPlatformTags: function() {
  178. var me = this,
  179. ua = navigator.userAgent,
  180. isMobile = /Mobile(\/|\s)/.test(ua),
  181. element = document.createElement('div'),
  182. isEventSupported = function(name, tag) {
  183. if (tag === undefined) {
  184. tag = window;
  185. }
  186. var eventName = 'on' + name.toLowerCase(),
  187. isSupported = (eventName in element);
  188. if (!isSupported) {
  189. if (element.setAttribute && element.removeAttribute) {
  190. element.setAttribute(eventName, '');
  191. isSupported = typeof element[eventName] === 'function';
  192. if (typeof element[eventName] !== 'undefined') {
  193. element[eventName] = undefined;
  194. }
  195. element.removeAttribute(eventName);
  196. }
  197. }
  198. return isSupported;
  199. },
  200. getBrowsers = function() {
  201. var browsers = {},
  202. maxIEVersion, prefix, value, key, index, len, match, version, matched;
  203. len = me.browserPriority.length;
  204. for (index = 0; index < len; index++) {
  205. key = me.browserPriority[index];
  206. if (!matched) {
  207. value = me.browserPrefixes[key];
  208. match = ua.match(new RegExp('(' + value + ')([\\w\\._]+)'));
  209. version = match && match.length > 1 ? parseInt(match[2]) : 0;
  210. if (version) {
  211. matched = true;
  212. }
  213. } else {
  214. version = 0;
  215. }
  216. browsers[key] = version;
  217. }
  218. if (browsers.ie) {
  219. var mode = document.documentMode;
  220. if (mode >= 8) {
  221. browsers.ie = mode;
  222. }
  223. }
  224. version = browsers.ie || false;
  225. maxIEVersion = Math.max(version, me.maxIEVersion);
  226. for (index = 8; index <= maxIEVersion; ++index) {
  227. prefix = 'ie' + index;
  228. browsers[prefix + 'm'] = version ? version <= index : 0;
  229. browsers[prefix] = version ? version === index : 0;
  230. browsers[prefix + 'p'] = version ? version >= index : 0;
  231. }
  232. return browsers;
  233. },
  234. getOperatingSystems = function() {
  235. var systems = {},
  236. value, key, keys, index, len, match, matched, version, activeCount;
  237. keys = _getKeys(me.osPrefixes);
  238. len = keys.length;
  239. for (index = 0 , activeCount = 0; index < len; index++) {
  240. key = keys[index];
  241. value = me.osPrefixes[key];
  242. match = ua.match(new RegExp('(' + value + ')([^\\s;]+)'));
  243. matched = match ? match[1] : null;
  244. if (matched && (matched === 'HTC_' || matched === 'Silk/')) {
  245. version = 2.3;
  246. } else {
  247. version = match && match.length > 1 ? parseFloat(match[match.length - 1]) : 0;
  248. }
  249. if (version) {
  250. activeCount++;
  251. }
  252. systems[key] = version;
  253. }
  254. keys = _getKeys(me.fallbackOSPrefixes);
  255. len = keys.length;
  256. for (index = 0; index < len; index++) {
  257. key = keys[index];
  258. if (activeCount === 0) {
  259. value = me.fallbackOSPrefixes[key];
  260. match = ua.toLowerCase().match(new RegExp(value));
  261. systems[key] = match ? true : 0;
  262. } else {
  263. systems[key] = 0;
  264. }
  265. }
  266. return systems;
  267. },
  268. getDevices = function() {
  269. var devices = {},
  270. value, key, keys, index, len, match;
  271. keys = _getKeys(me.devicePrefixes);
  272. len = keys.length;
  273. for (index = 0; index < len; index++) {
  274. key = keys[index];
  275. value = me.devicePrefixes[key];
  276. match = ua.match(new RegExp(value));
  277. devices[key] = match ? true : 0;
  278. }
  279. return devices;
  280. },
  281. browsers = getBrowsers(),
  282. systems = getOperatingSystems(),
  283. devices = getDevices(),
  284. platformParams = Boot.loadPlatformsParam();
  285. _merge(_tags, browsers, systems, devices, platformParams, true);
  286. _tags.phone = !!((_tags.iphone || _tags.ipod) || (!_tags.silk && (_tags.android && (_tags.android < 3 || isMobile))) || (_tags.blackberry && isMobile) || (_tags.windowsphone));
  287. _tags.tablet = !!(!_tags.phone && (_tags.ipad || _tags.android || _tags.silk || _tags.rimtablet || (_tags.ie10 && /; Touch/.test(ua))));
  288. _tags.touch =
  289. isEventSupported('touchend') ||
  290. navigator.maxTouchPoints ||
  291. navigator.msMaxTouchPoints;
  292. _tags.desktop = !_tags.phone && !_tags.tablet;
  293. _tags.cordova = _tags.phonegap = !!(window.PhoneGap || window.Cordova || window.cordova);
  294. _tags.webview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)(?!.*FBAN)/i.test(ua);
  295. _tags.androidstock = (_tags.android <= 4.3) && (_tags.safari || _tags.silk);
  296. _merge(_tags, platformParams, true);
  297. },
  298. loadPlatformsParam: function() {
  299. var paramsString = window.location.search.substr(1),
  300. paramsArray = paramsString.split("&"),
  301. params = {},
  302. i,
  303. platforms = {},
  304. tmpArray, tmplen, platform, name, enabled;
  305. for (i = 0; i < paramsArray.length; i++) {
  306. tmpArray = paramsArray[i].split("=");
  307. params[tmpArray[0]] = tmpArray[1];
  308. }
  309. if (params.platformTags) {
  310. tmpArray = params.platformTags.split(",");
  311. for (tmplen = tmpArray.length , i = 0; i < tmplen; i++) {
  312. platform = tmpArray[i].split(":");
  313. name = platform[0];
  314. enabled = true;
  315. if (platform.length > 1) {
  316. enabled = platform[1];
  317. if (enabled === 'false' || enabled === '0') {
  318. enabled = false;
  319. }
  320. }
  321. platforms[name] = enabled;
  322. }
  323. }
  324. return platforms;
  325. },
  326. filterPlatform: function(platform, excludes) {
  327. platform = _emptyArray.concat(platform || _emptyArray);
  328. excludes = _emptyArray.concat(excludes || _emptyArray);
  329. var plen = platform.length,
  330. elen = excludes.length,
  331. include = (!plen && elen),
  332. i, tag;
  333. for (i = 0; i < plen && !include; i++) {
  334. tag = platform[i];
  335. include = !!_tags[tag];
  336. }
  337. for (i = 0; i < elen && include; i++) {
  338. tag = excludes[i];
  339. include = !_tags[tag];
  340. }
  341. return include;
  342. },
  343. init: function() {
  344. var scriptEls = doc.getElementsByTagName('script'),
  345. script = scriptEls[0],
  346. len = scriptEls.length,
  347. re = /\/ext(\-[a-z\-]+)?\.js$/,
  348. entry, src, state, baseUrl, key, n, origin;
  349. Boot.hasReadyState = ("readyState" in script);
  350. Boot.hasAsync = ("async" in script);
  351. Boot.hasDefer = ("defer" in script);
  352. Boot.hasOnLoad = ("onload" in script);
  353. Boot.isIE8 = Boot.hasReadyState && !Boot.hasAsync && Boot.hasDefer && !Boot.hasOnLoad;
  354. Boot.isIE9 = Boot.hasReadyState && !Boot.hasAsync && Boot.hasDefer && Boot.hasOnLoad;
  355. Boot.isIE10p = Boot.hasReadyState && Boot.hasAsync && Boot.hasDefer && Boot.hasOnLoad;
  356. if (Boot.isIE8) {
  357. Boot.isIE10 = false;
  358. Boot.isIE10m = true;
  359. } else {
  360. Boot.isIE10 = navigator.appVersion.indexOf('MSIE 10') !== -1;
  361. Boot.isIE10m = Boot.isIE10 || Boot.isIE9 || Boot.isIE8;
  362. }
  363. Boot.isIE11 = Boot.isIE10p && !Boot.isIE10;
  364. for (n = 0; n < len; n++) {
  365. src = (script = scriptEls[n]).src;
  366. if (!src) {
  367. continue;
  368. }
  369. state = script.readyState || null;
  370. if (!baseUrl && re.test(src)) {
  371. baseUrl = src;
  372. }
  373. if (!Boot.scripts[key = Boot.canonicalUrl(src)]) {
  374. entry = new Entry({
  375. key: key,
  376. url: src,
  377. done: state === null ||
  378. state === 'loaded' || state === 'complete',
  379. el: script,
  380. prop: 'src'
  381. });
  382. }
  383. }
  384. if (!baseUrl) {
  385. script = scriptEls[scriptEls.length - 1];
  386. baseUrl = script.src;
  387. }
  388. Boot.baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1);
  389. origin = window.location.origin || window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
  390. Boot.origin = origin;
  391. Boot.detectPlatformTags();
  392. Ext.filterPlatform = Boot.filterPlatform;
  393. },
  394. canonicalUrl: function(url) {
  395. resolverEl.href = url;
  396. var ret = resolverEl.href,
  397. dc = _config.disableCachingParam,
  398. pos = dc ? ret.indexOf(dc + '=') : -1,
  399. c, end;
  400. if (pos > 0 && ((c = ret.charAt(pos - 1)) === '?' || c === '&')) {
  401. end = ret.indexOf('&', pos);
  402. end = (end < 0) ? '' : ret.substring(end);
  403. if (end && c === '?') {
  404. ++pos;
  405. end = end.substring(1);
  406. }
  407. ret = ret.substring(0, pos - 1) + end;
  408. }
  409. return ret;
  410. },
  411. getConfig: function(name) {
  412. return name ? Boot.config[name] : Boot.config;
  413. },
  414. setConfig: function(name, value) {
  415. if (typeof name === 'string') {
  416. Boot.config[name] = value;
  417. } else {
  418. for (var s in name) {
  419. Boot.setConfig(s, name[s]);
  420. }
  421. }
  422. return Boot;
  423. },
  424. getHead: function() {
  425. return Boot.docHead || (Boot.docHead = doc.head || doc.getElementsByTagName('head')[0]);
  426. },
  427. create: function(url, key, cfg) {
  428. var config = cfg || {};
  429. config.url = url;
  430. config.key = key;
  431. return Boot.scripts[key] = new Entry(config);
  432. },
  433. getEntry: function(url, cfg, canonicalPath) {
  434. var key, entry;
  435. key = canonicalPath ? url : Boot.canonicalUrl(url);
  436. entry = Boot.scripts[key];
  437. if (!entry) {
  438. entry = Boot.create(url, key, cfg);
  439. if (canonicalPath) {
  440. entry.canonicalPath = true;
  441. }
  442. }
  443. return entry;
  444. },
  445. registerContent: function(url, type, content) {
  446. var cfg = {
  447. content: content,
  448. loaded: true,
  449. css: type === 'css'
  450. };
  451. return Boot.getEntry(url, cfg);
  452. },
  453. processRequest: function(request, sync) {
  454. request.loadEntries(sync);
  455. },
  456. load: function(request) {
  457. var request = new Request(request);
  458. if (request.sync || Boot.syncMode) {
  459. return Boot.loadSync(request);
  460. }
  461. if (Boot.currentRequest) {
  462. request.getEntries();
  463. Boot.suspendedQueue.push(request);
  464. } else {
  465. Boot.currentRequest = request;
  466. Boot.processRequest(request, false);
  467. }
  468. return Boot;
  469. },
  470. loadSync: function(request) {
  471. var request = new Request(request);
  472. Boot.syncMode++;
  473. Boot.processRequest(request, true);
  474. Boot.syncMode--;
  475. return Boot;
  476. },
  477. loadBasePrefix: function(request) {
  478. request = new Request(request);
  479. request.prependBaseUrl = true;
  480. return Boot.load(request);
  481. },
  482. loadSyncBasePrefix: function(request) {
  483. request = new Request(request);
  484. request.prependBaseUrl = true;
  485. return Boot.loadSync(request);
  486. },
  487. requestComplete: function(request) {
  488. var next;
  489. if (Boot.currentRequest === request) {
  490. Boot.currentRequest = null;
  491. while (Boot.suspendedQueue.length > 0) {
  492. next = Boot.suspendedQueue.shift();
  493. if (!next.done) {
  494. Boot.load(next);
  495. break;
  496. }
  497. }
  498. }
  499. if (!Boot.currentRequest && Boot.suspendedQueue.length == 0) {
  500. Boot.fireListeners();
  501. }
  502. },
  503. isLoading: function() {
  504. return !Boot.currentRequest && Boot.suspendedQueue.length == 0;
  505. },
  506. fireListeners: function() {
  507. var listener;
  508. while (Boot.isLoading() && (listener = Boot.listeners.shift())) {
  509. listener();
  510. }
  511. },
  512. onBootReady: function(listener) {
  513. if (!Boot.isLoading()) {
  514. listener();
  515. } else {
  516. Boot.listeners.push(listener);
  517. }
  518. },
  519. getPathsFromIndexes: function(indexMap, loadOrder) {
  520. if (!('length' in indexMap)) {
  521. var indexArray = [],
  522. index;
  523. for (index in indexMap) {
  524. if (!isNaN(+index)) {
  525. indexArray[+index] = indexMap[index];
  526. }
  527. }
  528. indexMap = indexArray;
  529. }
  530. return Request.prototype.getPathsFromIndexes(indexMap, loadOrder);
  531. },
  532. createLoadOrderMap: function(loadOrder) {
  533. return Request.prototype.createLoadOrderMap(loadOrder);
  534. },
  535. fetch: function(url, complete, scope, async) {
  536. async = (async === undefined) ? !!complete : async;
  537. var xhr = new XMLHttpRequest(),
  538. result, status, content,
  539. exception = false,
  540. readyStateChange = function() {
  541. if (xhr && xhr.readyState == 4) {
  542. status = (xhr.status === 1223) ? 204 : (xhr.status === 0 && ((self.location || {}).protocol === 'file:' || (self.location || {}).protocol === 'ionp:')) ? 200 : xhr.status;
  543. content = xhr.responseText;
  544. result = {
  545. content: content,
  546. status: status,
  547. exception: exception
  548. };
  549. if (complete) {
  550. complete.call(scope, result);
  551. }
  552. xhr.onreadystatechange = emptyFn;
  553. xhr = null;
  554. }
  555. };
  556. if (async) {
  557. xhr.onreadystatechange = readyStateChange;
  558. }
  559. try {
  560. xhr.open('GET', url, async);
  561. xhr.send(null);
  562. } catch (err) {
  563. exception = err;
  564. readyStateChange();
  565. return result;
  566. }
  567. if (!async) {
  568. readyStateChange();
  569. }
  570. return result;
  571. },
  572. notifyAll: function(entry) {
  573. entry.notifyRequests();
  574. }
  575. };
  576. function Request(cfg) {
  577. if (cfg.$isRequest) {
  578. return cfg;
  579. }
  580. var cfg = cfg.url ? cfg : {
  581. url: cfg
  582. },
  583. url = cfg.url,
  584. urls = url.charAt ? [
  585. url
  586. ] : url,
  587. charset = cfg.charset || Boot.config.charset;
  588. _apply(this, cfg);
  589. delete this.url;
  590. this.urls = urls;
  591. this.charset = charset;
  592. }
  593. Request.prototype = {
  594. $isRequest: true,
  595. createLoadOrderMap: function(loadOrder) {
  596. var len = loadOrder.length,
  597. loadOrderMap = {},
  598. i, element;
  599. for (i = 0; i < len; i++) {
  600. element = loadOrder[i];
  601. loadOrderMap[element.path] = element;
  602. }
  603. return loadOrderMap;
  604. },
  605. getLoadIndexes: function(item, indexMap, loadOrder, includeUses, skipLoaded) {
  606. var resolved = [],
  607. queue = [
  608. item
  609. ],
  610. itemIndex = item.idx,
  611. queue, entry, dependencies, depIndex, i, len;
  612. if (indexMap[itemIndex]) {
  613. return resolved;
  614. }
  615. indexMap[itemIndex] = resolved[itemIndex] = true;
  616. while (item = queue.shift()) {
  617. if (item.canonicalPath) {
  618. entry = Boot.getEntry(item.path, null, true);
  619. } else {
  620. entry = Boot.getEntry(this.prepareUrl(item.path));
  621. }
  622. if (!(skipLoaded && entry.done)) {
  623. if (includeUses && item.uses && item.uses.length) {
  624. dependencies = item.requires.concat(item.uses);
  625. } else {
  626. dependencies = item.requires;
  627. }
  628. for (i = 0 , len = dependencies.length; i < len; i++) {
  629. depIndex = dependencies[i];
  630. if (!indexMap[depIndex]) {
  631. indexMap[depIndex] = resolved[depIndex] = true;
  632. queue.push(loadOrder[depIndex]);
  633. }
  634. }
  635. }
  636. }
  637. return resolved;
  638. },
  639. getPathsFromIndexes: function(indexes, loadOrder) {
  640. var paths = [],
  641. index, len;
  642. for (index = 0 , len = indexes.length; index < len; index++) {
  643. if (indexes[index]) {
  644. paths.push(loadOrder[index].path);
  645. }
  646. }
  647. return paths;
  648. },
  649. expandUrl: function(url, loadOrder, loadOrderMap, indexMap, includeUses, skipLoaded) {
  650. var item, resolved;
  651. if (loadOrder) {
  652. item = loadOrderMap[url];
  653. if (item) {
  654. resolved = this.getLoadIndexes(item, indexMap, loadOrder, includeUses, skipLoaded);
  655. if (resolved.length) {
  656. return this.getPathsFromIndexes(resolved, loadOrder);
  657. }
  658. }
  659. }
  660. return [
  661. url
  662. ];
  663. },
  664. expandUrls: function(urls, includeUses) {
  665. var me = this,
  666. loadOrder = me.loadOrder,
  667. expanded = [],
  668. expandMap = {},
  669. indexMap = [],
  670. loadOrderMap, tmpExpanded, i, len, t, tlen, tUrl;
  671. if (typeof urls === "string") {
  672. urls = [
  673. urls
  674. ];
  675. }
  676. if (loadOrder) {
  677. loadOrderMap = me.loadOrderMap;
  678. if (!loadOrderMap) {
  679. loadOrderMap = me.loadOrderMap = me.createLoadOrderMap(loadOrder);
  680. }
  681. }
  682. for (i = 0 , len = urls.length; i < len; i++) {
  683. tmpExpanded = this.expandUrl(urls[i], loadOrder, loadOrderMap, indexMap, includeUses, false);
  684. for (t = 0 , tlen = tmpExpanded.length; t < tlen; t++) {
  685. tUrl = tmpExpanded[t];
  686. if (!expandMap[tUrl]) {
  687. expandMap[tUrl] = true;
  688. expanded.push(tUrl);
  689. }
  690. }
  691. }
  692. if (expanded.length === 0) {
  693. expanded = urls;
  694. }
  695. return expanded;
  696. },
  697. expandLoadOrder: function() {
  698. var me = this,
  699. urls = me.urls,
  700. expanded;
  701. if (!me.expanded) {
  702. expanded = this.expandUrls(urls, true);
  703. me.expanded = true;
  704. } else {
  705. expanded = urls;
  706. }
  707. me.urls = expanded;
  708. if (urls.length != expanded.length) {
  709. me.sequential = true;
  710. }
  711. return me;
  712. },
  713. getUrls: function() {
  714. this.expandLoadOrder();
  715. return this.urls;
  716. },
  717. prepareUrl: function(url) {
  718. if (this.prependBaseUrl) {
  719. return Boot.baseUrl + url;
  720. }
  721. return url;
  722. },
  723. getEntries: function() {
  724. var me = this,
  725. entries = me.entries,
  726. loadOrderMap, item, i, entry, urls, url;
  727. if (!entries) {
  728. entries = [];
  729. urls = me.getUrls();
  730. if (me.loadOrder) {
  731. loadOrderMap = me.loadOrderMap;
  732. }
  733. for (i = 0; i < urls.length; i++) {
  734. url = me.prepareUrl(urls[i]);
  735. if (loadOrderMap) {
  736. item = loadOrderMap[url];
  737. }
  738. entry = Boot.getEntry(url, {
  739. buster: me.buster,
  740. charset: me.charset
  741. }, item && item.canonicalPath);
  742. entry.requests.push(me);
  743. entries.push(entry);
  744. }
  745. me.entries = entries;
  746. }
  747. return entries;
  748. },
  749. loadEntries: function(sync) {
  750. var me = this,
  751. entries = me.getEntries(),
  752. len = entries.length,
  753. start = me.loadStart || 0,
  754. continueLoad, entries, entry, i;
  755. if (sync !== undefined) {
  756. me.sync = sync;
  757. }
  758. me.loaded = me.loaded || 0;
  759. me.loading = me.loading || len;
  760. for (i = start; i < len; i++) {
  761. entry = entries[i];
  762. if (!entry.loaded) {
  763. continueLoad = entries[i].load(me.sync);
  764. } else {
  765. continueLoad = true;
  766. }
  767. if (!continueLoad) {
  768. me.loadStart = i;
  769. entry.onDone(function() {
  770. me.loadEntries(sync);
  771. });
  772. break;
  773. }
  774. }
  775. me.processLoadedEntries();
  776. },
  777. processLoadedEntries: function() {
  778. var me = this,
  779. entries = me.getEntries(),
  780. len = entries.length,
  781. start = me.startIndex || 0,
  782. i, entry;
  783. if (!me.done) {
  784. for (i = start; i < len; i++) {
  785. entry = entries[i];
  786. if (!entry.loaded) {
  787. me.startIndex = i;
  788. return;
  789. }
  790. if (!entry.evaluated) {
  791. entry.evaluate();
  792. }
  793. if (entry.error) {
  794. me.error = true;
  795. }
  796. }
  797. me.notify();
  798. }
  799. },
  800. notify: function() {
  801. var me = this;
  802. if (!me.done) {
  803. var error = me.error,
  804. fn = me[error ? 'failure' : 'success'],
  805. delay = ('delay' in me) ? me.delay : (error ? 1 : Boot.config.chainDelay),
  806. scope = me.scope || me;
  807. me.done = true;
  808. if (fn) {
  809. if (delay === 0 || delay > 0) {
  810. setTimeout(function() {
  811. fn.call(scope, me);
  812. }, delay);
  813. } else {
  814. fn.call(scope, me);
  815. }
  816. }
  817. me.fireListeners();
  818. Boot.requestComplete(me);
  819. }
  820. },
  821. onDone: function(listener) {
  822. var me = this,
  823. listeners = me.listeners || (me.listeners = []);
  824. if (me.done) {
  825. listener(me);
  826. } else {
  827. listeners.push(listener);
  828. }
  829. },
  830. fireListeners: function() {
  831. var listeners = this.listeners,
  832. listener;
  833. if (listeners) {
  834. while ((listener = listeners.shift())) {
  835. listener(this);
  836. }
  837. }
  838. }
  839. };
  840. function Entry(cfg) {
  841. if (cfg.$isEntry) {
  842. return cfg;
  843. }
  844. var charset = cfg.charset || Boot.config.charset,
  845. manifest = Ext.manifest,
  846. loader = manifest && manifest.loader,
  847. cache = (cfg.cache !== undefined) ? cfg.cache : (loader && loader.cache),
  848. buster, busterParam;
  849. if (Boot.config.disableCaching) {
  850. if (cache === undefined) {
  851. cache = !Boot.config.disableCaching;
  852. }
  853. if (cache === false) {
  854. buster = +new Date();
  855. } else if (cache !== true) {
  856. buster = cache;
  857. }
  858. if (buster) {
  859. busterParam = (loader && loader.cacheParam) || Boot.config.disableCachingParam;
  860. buster = busterParam + "=" + buster;
  861. }
  862. }
  863. _apply(this, cfg);
  864. this.charset = charset;
  865. this.buster = buster;
  866. this.requests = [];
  867. }
  868. Entry.prototype = {
  869. $isEntry: true,
  870. done: false,
  871. evaluated: false,
  872. loaded: false,
  873. isCrossDomain: function() {
  874. var me = this;
  875. if (me.crossDomain === undefined) {
  876. me.crossDomain = (me.getLoadUrl().indexOf(Boot.origin) !== 0);
  877. }
  878. return me.crossDomain;
  879. },
  880. isCss: function() {
  881. var me = this;
  882. if (me.css === undefined) {
  883. if (me.url) {
  884. var assetConfig = Boot.assetConfig[me.url];
  885. me.css = assetConfig ? assetConfig.type === "css" : cssRe.test(me.url);
  886. } else {
  887. me.css = false;
  888. }
  889. }
  890. return this.css;
  891. },
  892. getElement: function(tag) {
  893. var me = this,
  894. el = me.el;
  895. if (!el) {
  896. if (me.isCss()) {
  897. tag = tag || "link";
  898. el = doc.createElement(tag);
  899. if (tag == "link") {
  900. el.rel = 'stylesheet';
  901. me.prop = 'href';
  902. } else {
  903. me.prop = "textContent";
  904. }
  905. el.type = "text/css";
  906. } else {
  907. tag = tag || "script";
  908. el = doc.createElement(tag);
  909. el.type = 'text/javascript';
  910. me.prop = 'src';
  911. if (me.charset) {
  912. el.charset = me.charset;
  913. }
  914. if (Boot.hasAsync) {
  915. el.async = false;
  916. }
  917. }
  918. me.el = el;
  919. }
  920. return el;
  921. },
  922. getLoadUrl: function() {
  923. var me = this,
  924. url;
  925. url = me.canonicalPath ? me.url : Boot.canonicalUrl(me.url);
  926. if (!me.loadUrl) {
  927. me.loadUrl = !!me.buster ? (url + (url.indexOf('?') === -1 ? '?' : '&') + me.buster) : url;
  928. }
  929. return me.loadUrl;
  930. },
  931. fetch: function(req) {
  932. var url = this.getLoadUrl(),
  933. async = !!req.async,
  934. complete = req.complete;
  935. Boot.fetch(url, complete, this, async);
  936. },
  937. onContentLoaded: function(response) {
  938. var me = this,
  939. status = response.status,
  940. content = response.content,
  941. exception = response.exception,
  942. url = this.getLoadUrl();
  943. me.loaded = true;
  944. if ((exception || status === 0) && !_environment.phantom) {
  945. me.error =
  946. ("Failed loading synchronously via XHR: '" + url + "'. It's likely that the file is either being loaded from a " + "different domain or from the local file system where cross " + "origin requests are not allowed for security reasons. Try " + "asynchronous loading instead.") ||
  947. true;
  948. me.evaluated = true;
  949. } else if ((status >= 200 && status < 300) || status === 304 || _environment.phantom || (status === 0 && content.length > 0)) {
  950. me.content = content;
  951. } else {
  952. me.error =
  953. ("Failed loading synchronously via XHR: '" + url + "'. Please verify that the file exists. XHR status code: " + status) ||
  954. true;
  955. me.evaluated = true;
  956. }
  957. },
  958. createLoadElement: function(callback) {
  959. var me = this,
  960. el = me.getElement();
  961. me.preserve = true;
  962. el.onerror = function() {
  963. me.error = true;
  964. if (callback) {
  965. callback();
  966. callback = null;
  967. }
  968. };
  969. if (Boot.isIE10m) {
  970. el.onreadystatechange = function() {
  971. if (this.readyState === 'loaded' || this.readyState === 'complete') {
  972. if (callback) {
  973. callback();
  974. callback = this.onreadystatechange = this.onerror = null;
  975. }
  976. }
  977. };
  978. } else {
  979. el.onload = function() {
  980. callback();
  981. callback = this.onload = this.onerror = null;
  982. };
  983. }
  984. el[me.prop] = me.getLoadUrl();
  985. },
  986. onLoadElementReady: function() {
  987. Boot.getHead().appendChild(this.getElement());
  988. this.evaluated = true;
  989. },
  990. inject: function(content, asset) {
  991. var me = this,
  992. head = Boot.getHead(),
  993. url = me.url,
  994. key = me.key,
  995. base, el, ieMode, basePath;
  996. if (me.isCss()) {
  997. me.preserve = true;
  998. basePath = key.substring(0, key.lastIndexOf("/") + 1);
  999. base = doc.createElement('base');
  1000. base.href = basePath;
  1001. if (head.firstChild) {
  1002. head.insertBefore(base, head.firstChild);
  1003. } else {
  1004. head.appendChild(base);
  1005. }
  1006. base.href = base.href;
  1007. if (url) {
  1008. content += "\n/*# sourceURL=" + key + " */";
  1009. }
  1010. el = me.getElement("style");
  1011. ieMode = ('styleSheet' in el);
  1012. head.appendChild(base);
  1013. if (ieMode) {
  1014. head.appendChild(el);
  1015. el.styleSheet.cssText = content;
  1016. } else {
  1017. el.textContent = content;
  1018. head.appendChild(el);
  1019. }
  1020. head.removeChild(base);
  1021. } else {
  1022. if (url) {
  1023. content += "\n//# sourceURL=" + key;
  1024. }
  1025. Ext.globalEval(content);
  1026. }
  1027. return me;
  1028. },
  1029. loadCrossDomain: function() {
  1030. var me = this,
  1031. complete = function() {
  1032. me.el.onerror = me.el.onload = emptyFn;
  1033. me.el = null;
  1034. me.loaded = me.evaluated = me.done = true;
  1035. me.notifyRequests();
  1036. };
  1037. me.createLoadElement(function() {
  1038. complete();
  1039. });
  1040. me.evaluateLoadElement();
  1041. return false;
  1042. },
  1043. loadElement: function() {
  1044. var me = this,
  1045. complete = function() {
  1046. me.el.onerror = me.el.onload = emptyFn;
  1047. me.el = null;
  1048. me.loaded = me.evaluated = me.done = true;
  1049. me.notifyRequests();
  1050. };
  1051. me.createLoadElement(function() {
  1052. complete();
  1053. });
  1054. me.evaluateLoadElement();
  1055. return true;
  1056. },
  1057. loadSync: function() {
  1058. var me = this;
  1059. me.fetch({
  1060. async: false,
  1061. complete: function(response) {
  1062. me.onContentLoaded(response);
  1063. }
  1064. });
  1065. me.evaluate();
  1066. me.notifyRequests();
  1067. },
  1068. load: function(sync) {
  1069. var me = this;
  1070. if (!me.loaded) {
  1071. if (me.loading) {
  1072. return false;
  1073. }
  1074. me.loading = true;
  1075. if (!sync) {
  1076. if (Boot.isIE10 || me.isCrossDomain()) {
  1077. return me.loadCrossDomain();
  1078. }
  1079. else if (!me.isCss() && Boot.hasReadyState) {
  1080. me.createLoadElement(function() {
  1081. me.loaded = true;
  1082. me.notifyRequests();
  1083. });
  1084. } else if (Boot.useElements &&
  1085. !(me.isCss() && _environment.phantom)) {
  1086. return me.loadElement();
  1087. } else
  1088. {
  1089. me.fetch({
  1090. async: !sync,
  1091. complete: function(response) {
  1092. me.onContentLoaded(response);
  1093. me.notifyRequests();
  1094. }
  1095. });
  1096. }
  1097. } else
  1098. {
  1099. me.loadSync();
  1100. }
  1101. }
  1102. return true;
  1103. },
  1104. evaluateContent: function() {
  1105. this.inject(this.content);
  1106. this.content = null;
  1107. },
  1108. evaluateLoadElement: function() {
  1109. Boot.getHead().appendChild(this.getElement());
  1110. },
  1111. evaluate: function() {
  1112. var me = this;
  1113. if (!me.evaluated) {
  1114. if (me.evaluating) {
  1115. return;
  1116. }
  1117. me.evaluating = true;
  1118. if (me.content !== undefined) {
  1119. me.evaluateContent();
  1120. } else if (!me.error) {
  1121. me.evaluateLoadElement();
  1122. }
  1123. me.evaluated = me.done = true;
  1124. me.cleanup();
  1125. }
  1126. },
  1127. cleanup: function() {
  1128. var me = this,
  1129. el = me.el,
  1130. prop;
  1131. if (!el) {
  1132. return;
  1133. }
  1134. if (!me.preserve) {
  1135. me.el = null;
  1136. el.parentNode.removeChild(el);
  1137. for (prop in el) {
  1138. try {
  1139. if (prop !== me.prop) {
  1140. el[prop] = null;
  1141. }
  1142. delete el[prop];
  1143. }
  1144. catch (cleanEx) {}
  1145. }
  1146. }
  1147. el.onload = el.onerror = el.onreadystatechange = emptyFn;
  1148. },
  1149. notifyRequests: function() {
  1150. var requests = this.requests,
  1151. len = requests.length,
  1152. i, request;
  1153. for (i = 0; i < len; i++) {
  1154. request = requests[i];
  1155. request.processLoadedEntries();
  1156. }
  1157. if (this.done) {
  1158. this.fireListeners();
  1159. }
  1160. },
  1161. onDone: function(listener) {
  1162. var me = this,
  1163. listeners = me.listeners || (me.listeners = []);
  1164. if (me.done) {
  1165. listener(me);
  1166. } else {
  1167. listeners.push(listener);
  1168. }
  1169. },
  1170. fireListeners: function() {
  1171. var listeners = this.listeners,
  1172. listener;
  1173. if (listeners && listeners.length > 0) {
  1174. while ((listener = listeners.shift())) {
  1175. listener(this);
  1176. }
  1177. }
  1178. }
  1179. };
  1180. Ext.disableCacheBuster = function(disable, path) {
  1181. var date = new Date();
  1182. date.setTime(date.getTime() + (disable ? 10 * 365 : -1) * 24 * 60 * 60 * 1000);
  1183. date = date.toGMTString();
  1184. doc.cookie = 'ext-cache=1; expires=' + date + '; path=' + (path || '/');
  1185. };
  1186. Boot.init();
  1187. return Boot;
  1188. }(
  1189. function() {}));
  1190. Ext.globalEval = Ext.globalEval || (this.execScript ? function(code) {
  1191. execScript(code);
  1192. } : function($$code) {
  1193. eval.call(window, $$code);
  1194. });
  1195. if (!Function.prototype.bind) {
  1196. (function() {
  1197. var slice = Array.prototype.slice,
  1198. bind = function(me) {
  1199. var args = slice.call(arguments, 1),
  1200. method = this;
  1201. if (args.length) {
  1202. return function() {
  1203. var t = arguments;
  1204. return method.apply(me, t.length ? args.concat(slice.call(t)) : args);
  1205. };
  1206. }
  1207. args = null;
  1208. return function() {
  1209. return method.apply(me, arguments);
  1210. };
  1211. };
  1212. Function.prototype.bind = bind;
  1213. bind.$extjs = true;
  1214. }());
  1215. }
  1216. Ext.setResourcePath = function(poolName, path) {
  1217. var manifest = Ext.manifest || (Ext.manifest = {}),
  1218. paths = manifest.resources || (manifest.resources = {});
  1219. if (manifest) {
  1220. if (typeof poolName !== 'string') {
  1221. Ext.apply(paths, poolName);
  1222. } else {
  1223. paths[poolName] = path;
  1224. }
  1225. manifest.resources = paths;
  1226. }
  1227. };
  1228. Ext.getResourcePath = function(path, poolName, packageName) {
  1229. if (typeof path !== 'string') {
  1230. poolName = path.pool;
  1231. packageName = path.packageName;
  1232. path = path.path;
  1233. }
  1234. var manifest = Ext.manifest,
  1235. paths = manifest && manifest.resources,
  1236. poolPath = paths[poolName],
  1237. output = [];
  1238. if (poolPath == null) {
  1239. poolPath = paths.path;
  1240. if (poolPath == null) {
  1241. poolPath = 'resources';
  1242. }
  1243. }
  1244. if (poolPath) {
  1245. output.push(poolPath);
  1246. }
  1247. if (packageName) {
  1248. output.push(packageName);
  1249. }
  1250. output.push(path);
  1251. return output.join('/');
  1252. };
  1253. var Ext = Ext || {};
  1254. (function() {
  1255. var global = this,
  1256. objectPrototype = Object.prototype,
  1257. toString = objectPrototype.toString,
  1258. enumerables = [
  1259. 'valueOf',
  1260. 'toLocaleString',
  1261. 'toString',
  1262. 'constructor'
  1263. ],
  1264. emptyFn = Ext.fireIdle = function() {},
  1265. privateFn = function() {},
  1266. identityFn = function(o) {
  1267. return o;
  1268. },
  1269. callOverrideParent = function() {
  1270. var method = callOverrideParent.caller.caller;
  1271. return method.$owner.prototype[method.$name].apply(this, arguments);
  1272. },
  1273. manifest = Ext.manifest || {},
  1274. iterableRe = /\[object\s*(?:Array|Arguments|\w*Collection|\w*List|HTML\s+document\.all\s+class)\]/,
  1275. MSDateRe = /^\\?\/Date\(([-+])?(\d+)(?:[+-]\d{4})?\)\\?\/$/,
  1276. elevateArgs, elevateFn, elevateRet, elevateScope, i;
  1277. Ext.global = global;
  1278. Ext.$nextIid = 0;
  1279. Ext.now = Date.now || (Date.now = function() {
  1280. return +new Date();
  1281. });
  1282. Ext.ticks = (global.performance && global.performance.now) ? function() {
  1283. return performance.now();
  1284. } : Ext.now;
  1285. Ext._startTime = Ext.ticks();
  1286. emptyFn.$nullFn = identityFn.$nullFn = emptyFn.$emptyFn = identityFn.$identityFn = privateFn.$nullFn = true;
  1287. privateFn.$privacy = 'framework';
  1288. emptyFn.$noClearOnDestroy = identityFn.$noClearOnDestroy = true;
  1289. privateFn.$noClearOnDestroy = true;
  1290. Ext['suspendLayouts'] = Ext['resumeLayouts'] = emptyFn;
  1291. for (i in {
  1292. toString: 1
  1293. }) {
  1294. enumerables = null;
  1295. }
  1296. Ext.enumerables = enumerables;
  1297. Ext.apply = function(object, config, defaults) {
  1298. var i, j, k;
  1299. if (object) {
  1300. if (defaults) {
  1301. Ext.apply(object, defaults);
  1302. }
  1303. if (config && typeof config === 'object') {
  1304. for (i in config) {
  1305. object[i] = config[i];
  1306. }
  1307. if (enumerables) {
  1308. for (j = enumerables.length; j--; ) {
  1309. k = enumerables[j];
  1310. if (config.hasOwnProperty(k)) {
  1311. object[k] = config[k];
  1312. }
  1313. }
  1314. }
  1315. }
  1316. }
  1317. return object;
  1318. };
  1319. function addInstanceOverrides(target, owner, overrides) {
  1320. var name, value;
  1321. for (name in overrides) {
  1322. if (overrides.hasOwnProperty(name)) {
  1323. value = overrides[name];
  1324. if (typeof value === 'function') {
  1325. if (owner.$className) {
  1326. value.name = owner.$className + '#' + name;
  1327. }
  1328. value.$name = name;
  1329. value.$owner = owner;
  1330. value.$previous = target.hasOwnProperty(name) ? target[name] :
  1331. callOverrideParent;
  1332. }
  1333. target[name] = value;
  1334. }
  1335. }
  1336. }
  1337. Ext.buildSettings = Ext.apply({
  1338. baseCSSPrefix: 'x-'
  1339. }, Ext.buildSettings || {});
  1340. Ext.apply(Ext, {
  1341. idSeed: 0,
  1342. idPrefix: 'ext-',
  1343. isRobot: false,
  1344. isSecure: /^https/i.test(window.location.protocol),
  1345. enableGarbageCollector: false,
  1346. enableListenerCollection: true,
  1347. name: Ext.sandboxName || 'Ext',
  1348. privateFn: privateFn,
  1349. emptyFn: emptyFn,
  1350. identityFn: identityFn,
  1351. frameStartTime: Ext.now(),
  1352. manifest: manifest,
  1353. debugConfig: Ext.debugConfig || manifest.debug || {
  1354. hooks: {
  1355. '*': true
  1356. }
  1357. },
  1358. enableAria: true,
  1359. startsWithHashRe: /^#/,
  1360. validIdRe: /^[a-z_][a-z0-9\-_]*$/i,
  1361. BLANK_IMAGE_URL: 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
  1362. makeIdSelector: function(id) {
  1363. if (!Ext.validIdRe.test(id)) {
  1364. Ext.raise('Invalid id selector: "' + id + '"');
  1365. }
  1366. return '#' + id;
  1367. },
  1368. id: function(o, prefix) {
  1369. if (o && o.id) {
  1370. return o.id;
  1371. }
  1372. var id = (prefix || Ext.idPrefix) + (++Ext.idSeed);
  1373. if (o) {
  1374. o.id = id;
  1375. }
  1376. return id;
  1377. },
  1378. returnId: function(o) {
  1379. return o.getId();
  1380. },
  1381. returnTrue: function() {
  1382. return true;
  1383. },
  1384. emptyString: new String(),
  1385. emptyArray: Object.freeze ? Object.freeze([]) : [],
  1386. baseCSSPrefix: Ext.buildSettings.baseCSSPrefix,
  1387. $eventNameMap: {},
  1388. $vendorEventRe: /^(DOMMouse|Moz.+|MS.+|webkit.+)/,
  1389. canonicalEventName: function(name) {
  1390. return Ext.$eventNameMap[name] || (Ext.$eventNameMap[name] = (Ext.$vendorEventRe.test(name) ? name : name.toLowerCase()));
  1391. },
  1392. applyIf: function(object, config) {
  1393. var property;
  1394. if (object && config && typeof config === 'object') {
  1395. for (property in config) {
  1396. if (object[property] === undefined) {
  1397. object[property] = config[property];
  1398. }
  1399. }
  1400. }
  1401. return object;
  1402. },
  1403. destroy: function() {
  1404. var ln = arguments.length,
  1405. i, arg;
  1406. for (i = 0; i < ln; i++) {
  1407. arg = arguments[i];
  1408. if (arg) {
  1409. if (Ext.isArray(arg)) {
  1410. this.destroy.apply(this, arg);
  1411. } else if (Ext.isFunction(arg.destroy) && !arg.destroyed) {
  1412. arg.destroy();
  1413. }
  1414. }
  1415. }
  1416. return null;
  1417. },
  1418. destroyMembers: function(object) {
  1419. for (var ref, name,
  1420. i = 1,
  1421. a = arguments,
  1422. len = a.length; i < len; i++) {
  1423. ref = object[name = a[i]];
  1424. if (ref != null) {
  1425. object[name] = Ext.destroy(ref);
  1426. }
  1427. }
  1428. },
  1429. override: function(target, overrides) {
  1430. if (target.$isClass) {
  1431. target.override(overrides);
  1432. } else if (typeof target === 'function') {
  1433. Ext.apply(target.prototype, overrides);
  1434. } else {
  1435. var owner = target.self,
  1436. privates;
  1437. if (owner && owner.$isClass) {
  1438. privates = overrides.privates;
  1439. if (privates) {
  1440. overrides = Ext.apply({}, overrides);
  1441. delete overrides.privates;
  1442. addInstanceOverrides(target, owner, privates);
  1443. }
  1444. addInstanceOverrides(target, owner, overrides);
  1445. } else {
  1446. Ext.apply(target, overrides);
  1447. }
  1448. }
  1449. return target;
  1450. },
  1451. valueFrom: function(value, defaultValue, allowBlank) {
  1452. return Ext.isEmpty(value, allowBlank) ? defaultValue : value;
  1453. },
  1454. isEmpty: function(value, allowEmptyString) {
  1455. return (value == null) || (!allowEmptyString ? value === '' : false) || (Ext.isArray(value) && value.length === 0);
  1456. },
  1457. isArray: ('isArray' in Array) ? Array.isArray : function(value) {
  1458. return toString.call(value) === '[object Array]';
  1459. },
  1460. isDate: function(obj) {
  1461. return toString.call(obj) === '[object Date]';
  1462. },
  1463. isMSDate: function(value) {
  1464. if (!Ext.isString(value)) {
  1465. return false;
  1466. }
  1467. return MSDateRe.test(value);
  1468. },
  1469. isObject: (toString.call(null) === '[object Object]') ? function(value) {
  1470. return value != null && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;
  1471. } : function(value) {
  1472. return toString.call(value) === '[object Object]';
  1473. },
  1474. isSimpleObject: function(value) {
  1475. return value instanceof Object && value.constructor === Object;
  1476. },
  1477. isPrimitive: function(value) {
  1478. var type = typeof value;
  1479. return type === 'string' || type === 'number' || type === 'boolean';
  1480. },
  1481. isFunction:
  1482. (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') ? function(value) {
  1483. return !!value && toString.call(value) === '[object Function]';
  1484. } : function(value) {
  1485. return !!value && typeof value === 'function';
  1486. },
  1487. isNumber: function(value) {
  1488. return typeof value === 'number' && isFinite(value);
  1489. },
  1490. isNumeric: function(value) {
  1491. return !isNaN(parseFloat(value)) && isFinite(value);
  1492. },
  1493. isString: function(value) {
  1494. return typeof value === 'string';
  1495. },
  1496. isBoolean: function(value) {
  1497. return typeof value === 'boolean';
  1498. },
  1499. isElement: function(value) {
  1500. return value ? value.nodeType === 1 : false;
  1501. },
  1502. isTextNode: function(value) {
  1503. return value ? value.nodeName === "#text" : false;
  1504. },
  1505. isDefined: function(value) {
  1506. return typeof value !== 'undefined';
  1507. },
  1508. isIterable: function(value) {
  1509. if (!value || typeof value.length !== 'number' || typeof value === 'string' || Ext.isFunction(value)) {
  1510. return false;
  1511. }
  1512. if (!value.propertyIsEnumerable) {
  1513. return !!value.item;
  1514. }
  1515. if (value.hasOwnProperty('length') && !value.propertyIsEnumerable('length')) {
  1516. return true;
  1517. }
  1518. return iterableRe.test(toString.call(value));
  1519. },
  1520. isDebugEnabled:
  1521. function(className, defaultEnabled) {
  1522. var debugConfig = Ext.debugConfig.hooks;
  1523. if (debugConfig.hasOwnProperty(className)) {
  1524. return debugConfig[className];
  1525. }
  1526. var enabled = debugConfig['*'],
  1527. prefixLength = 0;
  1528. if (defaultEnabled !== undefined) {
  1529. enabled = defaultEnabled;
  1530. }
  1531. if (!className) {
  1532. return enabled;
  1533. }
  1534. for (var prefix in debugConfig) {
  1535. var value = debugConfig[prefix];
  1536. if (className.charAt(prefix.length) === '.') {
  1537. if (className.substring(0, prefix.length) === prefix) {
  1538. if (prefixLength < prefix.length) {
  1539. prefixLength = prefix.length;
  1540. enabled = value;
  1541. }
  1542. }
  1543. }
  1544. }
  1545. return enabled;
  1546. } ||
  1547. emptyFn,
  1548. clone: function(item, cloneDom) {
  1549. if (item == null) {
  1550. return item;
  1551. }
  1552. if (cloneDom !== false && item.nodeType && item.cloneNode) {
  1553. return item.cloneNode(true);
  1554. }
  1555. var type = toString.call(item),
  1556. i, j, k, clone, key;
  1557. if (type === '[object Date]') {
  1558. return new Date(item.getTime());
  1559. }
  1560. if (type === '[object Array]') {
  1561. i = item.length;
  1562. clone = [];
  1563. while (i--) {
  1564. clone[i] = Ext.clone(item[i], cloneDom);
  1565. }
  1566. }
  1567. else if (type === '[object Object]' && item.constructor === Object) {
  1568. clone = {};
  1569. for (key in item) {
  1570. clone[key] = Ext.clone(item[key], cloneDom);
  1571. }
  1572. if (enumerables) {
  1573. for (j = enumerables.length; j--; ) {
  1574. k = enumerables[j];
  1575. if (item.hasOwnProperty(k)) {
  1576. clone[k] = item[k];
  1577. }
  1578. }
  1579. }
  1580. }
  1581. return clone || item;
  1582. },
  1583. getUniqueGlobalNamespace: function() {
  1584. var uniqueGlobalNamespace = this.uniqueGlobalNamespace,
  1585. i;
  1586. if (uniqueGlobalNamespace === undefined) {
  1587. i = 0;
  1588. do {
  1589. uniqueGlobalNamespace = 'ExtBox' + (++i);
  1590. } while (global[uniqueGlobalNamespace] !== undefined);
  1591. global[uniqueGlobalNamespace] = Ext;
  1592. this.uniqueGlobalNamespace = uniqueGlobalNamespace;
  1593. }
  1594. return uniqueGlobalNamespace;
  1595. },
  1596. functionFactoryCache: {},
  1597. cacheableFunctionFactory: function() {
  1598. var me = this,
  1599. args = Array.prototype.slice.call(arguments),
  1600. cache = me.functionFactoryCache,
  1601. idx, fn, ln;
  1602. if (Ext.isSandboxed) {
  1603. ln = args.length;
  1604. if (ln > 0) {
  1605. ln--;
  1606. args[ln] = 'var Ext=window.' + Ext.name + ';' + args[ln];
  1607. }
  1608. }
  1609. idx = args.join('');
  1610. fn = cache[idx];
  1611. if (!fn) {
  1612. fn = Function.prototype.constructor.apply(Function.prototype, args);
  1613. cache[idx] = fn;
  1614. }
  1615. return fn;
  1616. },
  1617. functionFactory: function() {
  1618. var args = Array.prototype.slice.call(arguments),
  1619. ln;
  1620. if (Ext.isSandboxed) {
  1621. ln = args.length;
  1622. if (ln > 0) {
  1623. ln--;
  1624. args[ln] = 'var Ext=window.' + Ext.name + ';' + args[ln];
  1625. }
  1626. }
  1627. return Function.prototype.constructor.apply(Function.prototype, args);
  1628. },
  1629. Logger: {
  1630. log: function(message, priority) {
  1631. if (message && global.console) {
  1632. if (!priority || !(priority in global.console)) {
  1633. priority = 'log';
  1634. }
  1635. message = '[' + priority.toUpperCase() + '] ' + message;
  1636. global.console[priority](message);
  1637. }
  1638. },
  1639. verbose: function(message) {
  1640. this.log(message, 'verbose');
  1641. },
  1642. info: function(message) {
  1643. this.log(message, 'info');
  1644. },
  1645. warn: function(message) {
  1646. this.log(message, 'warn');
  1647. },
  1648. error: function(message) {
  1649. throw new Error(message);
  1650. },
  1651. deprecate: function(message) {
  1652. this.log(message, 'warn');
  1653. }
  1654. } || {
  1655. verbose: emptyFn,
  1656. log: emptyFn,
  1657. info: emptyFn,
  1658. warn: emptyFn,
  1659. error: function(message) {
  1660. throw new Error(message);
  1661. },
  1662. deprecate: emptyFn
  1663. },
  1664. ariaWarn: function(target, msg) {
  1665. if (Ext.enableAria && !Ext.slicer) {
  1666. if (!Ext.ariaWarn.first) {
  1667. Ext.ariaWarn.first = true;
  1668. Ext.log.warn("WAI-ARIA compatibility warnings can be suppressed " + "by adding the following to application startup code:");
  1669. Ext.log.warn(" Ext.ariaWarn = Ext.emptyFn;");
  1670. }
  1671. Ext.log.warn({
  1672. msg: msg,
  1673. dump: target
  1674. });
  1675. }
  1676. },
  1677. getElementById: function(id) {
  1678. return document.getElementById(id);
  1679. },
  1680. splitAndUnescape: (function() {
  1681. var cache = {};
  1682. return function(origin, delimiter) {
  1683. if (!origin) {
  1684. return [];
  1685. } else if (!delimiter) {
  1686. return [
  1687. origin
  1688. ];
  1689. }
  1690. var replaceRe = cache[delimiter] || (cache[delimiter] = new RegExp('\\\\' + delimiter, 'g')),
  1691. result = [],
  1692. parts, part;
  1693. parts = origin.split(delimiter);
  1694. while ((part = parts.shift()) !== undefined) {
  1695. while (part.charAt(part.length - 1) === '\\' && parts.length > 0) {
  1696. part = part + delimiter + parts.shift();
  1697. }
  1698. part = part.replace(replaceRe, delimiter);
  1699. result.push(part);
  1700. }
  1701. return result;
  1702. };
  1703. })(),
  1704. doElevate: function() {
  1705. var fn = elevateFn,
  1706. args = elevateArgs,
  1707. scope = elevateScope;
  1708. elevateFn = elevateArgs = elevateScope = null;
  1709. elevateRet = args ? fn.apply(scope, args) : fn.call(scope);
  1710. Ext.fireIdle();
  1711. },
  1712. elevate: function(fn, scope, args,
  1713. timer)
  1714. {
  1715. var ret;
  1716. if (args && !args.length) {
  1717. args = null;
  1718. }
  1719. Ext._suppressIdle = false;
  1720. if (timer) {
  1721. timer.tick();
  1722. }
  1723. if (Ext.elevateFunction) {
  1724. elevateFn = fn;
  1725. elevateScope = scope;
  1726. elevateArgs = args;
  1727. Ext.elevateFunction(Ext.doElevate);
  1728. ret = elevateRet;
  1729. elevateRet = null;
  1730. } else {
  1731. ret = args ? fn.apply(scope, args) : fn.call(scope);
  1732. Ext.fireIdle();
  1733. }
  1734. if (timer) {
  1735. timer.tock();
  1736. }
  1737. return ret;
  1738. },
  1739. Timer: {
  1740. all: {},
  1741. track: false,
  1742. captureStack: true,
  1743. created: function(kind, id, info) {
  1744. if (!Ext.Timer.track) {
  1745. return null;
  1746. }
  1747. var timer = Ext.apply({
  1748. kind: kind,
  1749. id: id,
  1750. done: false,
  1751. firing: false,
  1752. creator: Ext.Timer.captureStack ? new Error().stack : null,
  1753. tick: Ext.Timer.tick,
  1754. tock: Ext.Timer.tock
  1755. }, info);
  1756. var timers = Ext.Timer.all[kind] || (Ext.Timer.all[kind] = {});
  1757. timers[timer.id] = timer;
  1758. if (Ext.Timer.hook) {
  1759. Ext.Timer.hook(timer);
  1760. }
  1761. return timer;
  1762. },
  1763. get: function(id, kind) {
  1764. kind = kind || 'timeout';
  1765. var timers = Ext.Timer.all[kind];
  1766. return timers && timers[id] || null;
  1767. },
  1768. cancel: function(kind, id) {
  1769. var timers = Ext.Timer.all[kind],
  1770. timer = timers && timers[id];
  1771. if (timer) {
  1772. timer.cancelled = true;
  1773. timers[id] = null;
  1774. delete timers[id];
  1775. }
  1776. },
  1777. tick: function() {
  1778. if (Ext.Timer.firing) {
  1779. Ext.log.error('Previous timer state not cleaned up properly: ' + Ext.Timer.firing.creator);
  1780. }
  1781. if (this.kind !== 'interval') {
  1782. this.done = true;
  1783. Ext.Timer.all[this.kind][this.id] = null;
  1784. delete Ext.Timer.all[this.kind][this.id];
  1785. }
  1786. this.firing = true;
  1787. Ext.Timer.firing = this;
  1788. },
  1789. tock: function() {
  1790. this.firing = false;
  1791. if (Ext.Timer.firing === this) {
  1792. Ext.Timer.firing = null;
  1793. }
  1794. }
  1795. },
  1796. getExpando: function(target, id) {
  1797. var expandos = target.$expandos;
  1798. return expandos && expandos[id] || null;
  1799. },
  1800. setExpando: function(target, id, value) {
  1801. var expandos = target.$expandos;
  1802. if (value !== undefined) {
  1803. (expandos || (target.$expandos = {}))[id] = value;
  1804. } else if (expandos) {
  1805. delete expandos[id];
  1806. }
  1807. return value;
  1808. }
  1809. });
  1810. Ext.returnTrue.$nullFn = Ext.returnId.$nullFn = true;
  1811. }());
  1812. (function() {
  1813. function toString() {
  1814. var me = this,
  1815. cls = me.sourceClass,
  1816. method = me.sourceMethod,
  1817. msg = me.msg;
  1818. if (method) {
  1819. if (msg) {
  1820. method += '(): ';
  1821. method += msg;
  1822. } else {
  1823. method += '()';
  1824. }
  1825. }
  1826. if (cls) {
  1827. method = method ? (cls + '.' + method) : cls;
  1828. }
  1829. return method || msg || '';
  1830. }
  1831. Ext.Error = function(config) {
  1832. var error = new Error();
  1833. if (Ext.isString(config)) {
  1834. config = {
  1835. msg: config
  1836. };
  1837. }
  1838. Ext.apply(error, config);
  1839. error.message = error.message || error.msg;
  1840. error.toString = toString;
  1841. return error;
  1842. };
  1843. Ext.apply(Ext.Error, {
  1844. ignore: false,
  1845. raise: function(err) {
  1846. var me = this,
  1847. method = me.raise.caller,
  1848. msg, name;
  1849. err = err || {};
  1850. if (Ext.isString(err)) {
  1851. err = {
  1852. msg: err
  1853. };
  1854. }
  1855. if (method === Ext.raise) {
  1856. method = method.caller;
  1857. }
  1858. if (method) {
  1859. if (!err.sourceMethod && (name = method.$name)) {
  1860. err.sourceMethod = name;
  1861. }
  1862. if (!err.sourceClass && (name = method.$owner) && (name = name.$className)) {
  1863. err.sourceClass = name;
  1864. }
  1865. }
  1866. if (me.handle(err) !== true) {
  1867. msg = toString.call(err);
  1868. Ext.log({
  1869. msg: msg,
  1870. level: 'error',
  1871. dump: err,
  1872. stack: true
  1873. });
  1874. throw new Ext.Error(err);
  1875. }
  1876. },
  1877. handle: function() {
  1878. return this.ignore;
  1879. }
  1880. });
  1881. })();
  1882. Ext.deprecated = function(suggestion) {
  1883. if (!suggestion) {
  1884. suggestion = '';
  1885. }
  1886. function fail() {
  1887. Ext.raise('The method "' + fail.$owner.$className + '.' + fail.$name + '" has been removed. ' + suggestion);
  1888. }
  1889. return fail;
  1890. return Ext.emptyFn;
  1891. };
  1892. Ext.raise = function() {
  1893. Ext.Error.raise.apply(Ext.Error, arguments);
  1894. };
  1895. (function(skipNotify) {
  1896. if (skipNotify || typeof window === 'undefined') {
  1897. return;
  1898. }
  1899. var last = 0,
  1900. notify = function() {
  1901. var cnt = Ext.log && Ext.log.counters,
  1902. n = cnt && (cnt.error + cnt.warn + cnt.info + cnt.log),
  1903. msg;
  1904. if (n && last !== n) {
  1905. msg = [];
  1906. if (cnt.error) {
  1907. msg.push('Errors: ' + cnt.error);
  1908. }
  1909. if (cnt.warn) {
  1910. msg.push('Warnings: ' + cnt.warn);
  1911. }
  1912. if (cnt.info) {
  1913. msg.push('Info: ' + cnt.info);
  1914. }
  1915. if (cnt.log) {
  1916. msg.push('Log: ' + cnt.log);
  1917. }
  1918. window.status = '*** ' + msg.join(' -- ');
  1919. last = n;
  1920. }
  1921. };
  1922. notify.$skipTimerCheck = true;
  1923. setInterval(notify, 1000);
  1924. }(!!window.__UNIT_TESTING__));
  1925. Ext.Array = (function() {
  1926. var arrayPrototype = Array.prototype,
  1927. slice = arrayPrototype.slice,
  1928. supportsSplice = (function() {
  1929. var array = [],
  1930. lengthBefore,
  1931. j = 20;
  1932. if (!array.splice) {
  1933. return false;
  1934. }
  1935. while (j--) {
  1936. array.push("A");
  1937. }
  1938. array.splice(15, 0, "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F");
  1939. lengthBefore = array.length;
  1940. array.splice(13, 0, "XXX");
  1941. if (lengthBefore + 1 !== array.length) {
  1942. return false;
  1943. }
  1944. return true;
  1945. }()),
  1946. supportsIndexOf = 'indexOf' in arrayPrototype,
  1947. supportsSliceOnNodeList = true;
  1948. function stableSort(array, userComparator) {
  1949. var len = array.length,
  1950. indices = new Array(len),
  1951. i;
  1952. for (i = 0; i < len; i++) {
  1953. indices[i] = i;
  1954. }
  1955. indices.sort(function(index1, index2) {
  1956. return userComparator(array[index1], array[index2]) || (index1 - index2);
  1957. });
  1958. for (i = 0; i < len; i++) {
  1959. indices[i] = array[indices[i]];
  1960. }
  1961. for (i = 0; i < len; i++) {
  1962. array[i] = indices[i];
  1963. }
  1964. return array;
  1965. }
  1966. try {
  1967. if (typeof document !== 'undefined') {
  1968. slice.call(document.getElementsByTagName('body'));
  1969. }
  1970. } catch (e) {
  1971. supportsSliceOnNodeList = false;
  1972. }
  1973. var fixArrayIndex = function(array, index) {
  1974. return (index < 0) ? Math.max(0, array.length + index) : Math.min(array.length, index);
  1975. },
  1976. replaceSim = function(array, index, removeCount, insert) {
  1977. var add = insert ? insert.length : 0,
  1978. length = array.length,
  1979. pos = fixArrayIndex(array, index);
  1980. if (pos === length) {
  1981. if (add) {
  1982. array.push.apply(array, insert);
  1983. }
  1984. } else {
  1985. var remove = Math.min(removeCount, length - pos),
  1986. tailOldPos = pos + remove,
  1987. tailNewPos = tailOldPos + add - remove,
  1988. tailCount = length - tailOldPos,
  1989. lengthAfterRemove = length - remove,
  1990. i;
  1991. if (tailNewPos < tailOldPos) {
  1992. for (i = 0; i < tailCount; ++i) {
  1993. array[tailNewPos + i] = array[tailOldPos + i];
  1994. }
  1995. } else if (tailNewPos > tailOldPos) {
  1996. for (i = tailCount; i--; ) {
  1997. array[tailNewPos + i] = array[tailOldPos + i];
  1998. }
  1999. }
  2000. if (add && pos === lengthAfterRemove) {
  2001. array.length = lengthAfterRemove;
  2002. array.push.apply(array, insert);
  2003. } else {
  2004. array.length = lengthAfterRemove + add;
  2005. for (i = 0; i < add; ++i) {
  2006. array[pos + i] = insert[i];
  2007. }
  2008. }
  2009. }
  2010. return array;
  2011. },
  2012. replaceNative = function(array, index, removeCount, insert) {
  2013. if (insert && insert.length) {
  2014. if (index === 0 && !removeCount) {
  2015. array.unshift.apply(array, insert);
  2016. }
  2017. else if (index < array.length) {
  2018. array.splice.apply(array, [
  2019. index,
  2020. removeCount
  2021. ].concat(insert));
  2022. } else
  2023. {
  2024. array.push.apply(array, insert);
  2025. }
  2026. } else {
  2027. array.splice(index, removeCount);
  2028. }
  2029. return array;
  2030. },
  2031. eraseSim = function(array, index, removeCount) {
  2032. return replaceSim(array, index, removeCount);
  2033. },
  2034. eraseNative = function(array, index, removeCount) {
  2035. array.splice(index, removeCount);
  2036. return array;
  2037. },
  2038. spliceSim = function(array, index, removeCount) {
  2039. var len = arguments.length,
  2040. pos = fixArrayIndex(array, index),
  2041. removed;
  2042. if (len < 3) {
  2043. removeCount = array.length - pos;
  2044. }
  2045. removed = array.slice(index, fixArrayIndex(array, pos + removeCount));
  2046. if (len < 4) {
  2047. replaceSim(array, pos, removeCount);
  2048. } else {
  2049. replaceSim(array, pos, removeCount, slice.call(arguments, 3));
  2050. }
  2051. return removed;
  2052. },
  2053. spliceNative = function(array) {
  2054. return array.splice.apply(array, slice.call(arguments, 1));
  2055. },
  2056. erase = supportsSplice ? eraseNative : eraseSim,
  2057. replace = supportsSplice ? replaceNative : replaceSim,
  2058. splice = supportsSplice ? spliceNative : spliceSim,
  2059. ExtArray = {
  2060. binarySearch: function(array, item, begin, end, compareFn) {
  2061. var length = array.length,
  2062. middle, comparison;
  2063. if (begin instanceof Function) {
  2064. compareFn = begin;
  2065. begin = 0;
  2066. end = length;
  2067. } else if (end instanceof Function) {
  2068. compareFn = end;
  2069. end = length;
  2070. } else {
  2071. if (begin === undefined) {
  2072. begin = 0;
  2073. }
  2074. if (end === undefined) {
  2075. end = length;
  2076. }
  2077. compareFn = compareFn || ExtArray.lexicalCompare;
  2078. }
  2079. --end;
  2080. while (begin <= end) {
  2081. middle = (begin + end) >> 1;
  2082. comparison = compareFn(item, array[middle]);
  2083. if (comparison >= 0) {
  2084. begin = middle + 1;
  2085. } else if (comparison < 0) {
  2086. end = middle - 1;
  2087. }
  2088. }
  2089. return begin;
  2090. },
  2091. defaultCompare: function(lhs, rhs) {
  2092. return (lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0);
  2093. },
  2094. lexicalCompare: function(lhs, rhs) {
  2095. lhs = String(lhs);
  2096. rhs = String(rhs);
  2097. return (lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0);
  2098. },
  2099. each: function(array, fn, scope, reverse) {
  2100. var i, ln;
  2101. array = ExtArray.from(array);
  2102. ln = array.length;
  2103. if (reverse !== true) {
  2104. for (i = 0; i < ln; i++) {
  2105. if (fn.call(scope || array[i], array[i], i, array) === false) {
  2106. return i;
  2107. }
  2108. }
  2109. } else {
  2110. for (i = ln - 1; i > -1; i--) {
  2111. if (fn.call(scope || array[i], array[i], i, array) === false) {
  2112. return i;
  2113. }
  2114. }
  2115. }
  2116. return true;
  2117. },
  2118. findInsertionIndex: function(item, items, comparatorFn, index) {
  2119. var len = items.length,
  2120. beforeCheck, afterCheck;
  2121. comparatorFn = comparatorFn || ExtArray.lexicalCompare;
  2122. if (0 <= index && index < len) {
  2123. beforeCheck = index > 0 ? comparatorFn(item, items[index - 1]) : 0;
  2124. afterCheck = (index < len) ? comparatorFn(item, items[index]) : 0;
  2125. if (0 <= beforeCheck && afterCheck < 1) {
  2126. return index;
  2127. }
  2128. }
  2129. return ExtArray.binarySearch(items, item, comparatorFn);
  2130. },
  2131. forEach: ('forEach' in arrayPrototype) ? function(array, fn, scope) {
  2132. array.forEach(fn, scope);
  2133. } : function(array, fn, scope) {
  2134. var i, ln;
  2135. for (i = 0 , ln = array.length; i < ln; i++) {
  2136. fn.call(scope, array[i], i, array);
  2137. }
  2138. },
  2139. indexOf: supportsIndexOf ? function(array, item, from) {
  2140. return array ? arrayPrototype.indexOf.call(array, item, from) : -1;
  2141. } : function(array, item, from) {
  2142. var i,
  2143. length = array ? array.length : 0;
  2144. for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) {
  2145. if (array[i] === item) {
  2146. return i;
  2147. }
  2148. }
  2149. return -1;
  2150. },
  2151. contains: supportsIndexOf ? function(array, item) {
  2152. return arrayPrototype.indexOf.call(array, item) !== -1;
  2153. } : function(array, item) {
  2154. var i, ln;
  2155. for (i = 0 , ln = array.length; i < ln; i++) {
  2156. if (array[i] === item) {
  2157. return true;
  2158. }
  2159. }
  2160. return false;
  2161. },
  2162. toArray: function(iterable, start, end) {
  2163. var array = [],
  2164. i;
  2165. if (!iterable || !iterable.length) {
  2166. return array;
  2167. }
  2168. if (typeof iterable === 'string') {
  2169. iterable = iterable.split('');
  2170. }
  2171. if (supportsSliceOnNodeList) {
  2172. return slice.call(iterable, start || 0, end || iterable.length);
  2173. }
  2174. start = start || 0;
  2175. end = end ? ((end < 0) ? iterable.length + end : end) : iterable.length;
  2176. for (i = start; i < end; i++) {
  2177. array.push(iterable[i]);
  2178. }
  2179. return array;
  2180. },
  2181. pluck: function(array, propertyName) {
  2182. var ret = [],
  2183. i, ln, item;
  2184. for (i = 0 , ln = array.length; i < ln; i++) {
  2185. item = array[i];
  2186. ret.push(item[propertyName]);
  2187. }
  2188. return ret;
  2189. },
  2190. map: ('map' in arrayPrototype) ? function(array, fn, scope) {
  2191. Ext.Assert.isFunction(fn, 'Ext.Array.map must have a callback function passed as second argument.');
  2192. return array.map(fn, scope);
  2193. } : function(array, fn, scope) {
  2194. Ext.Assert.isFunction(fn, 'Ext.Array.map must have a callback function passed as second argument.');
  2195. var len = array.length,
  2196. results = new Array(len),
  2197. i;
  2198. for (i = 0; i < len; i++) {
  2199. results[i] = fn.call(scope, array[i], i, array);
  2200. }
  2201. return results;
  2202. },
  2203. every: ('every' in arrayPrototype) ? function(array, fn, scope) {
  2204. Ext.Assert.isFunction(fn, 'Ext.Array.every must have a callback function passed as second argument.');
  2205. return array.every(fn, scope);
  2206. } : function(array, fn, scope) {
  2207. var i, ln;
  2208. Ext.Assert.isFunction(fn, 'Ext.Array.every must have a callback function passed as second argument.');
  2209. for (i = 0 , ln = array.length; i < ln; ++i) {
  2210. if (!fn.call(scope, array[i], i, array)) {
  2211. return false;
  2212. }
  2213. }
  2214. return true;
  2215. },
  2216. some: ('some' in arrayPrototype) ? function(array, fn, scope) {
  2217. Ext.Assert.isFunction(fn, 'Ext.Array.some must have a callback function passed as second argument.');
  2218. return array.some(fn, scope);
  2219. } : function(array, fn, scope) {
  2220. var i, ln;
  2221. Ext.Assert.isFunction(fn, 'Ext.Array.some must have a callback function passed as second argument.');
  2222. for (i = 0 , ln = array.length; i < ln; ++i) {
  2223. if (fn.call(scope, array[i], i, array)) {
  2224. return true;
  2225. }
  2226. }
  2227. return false;
  2228. },
  2229. equals: function(array1, array2) {
  2230. var len1 = array1.length,
  2231. len2 = array2.length,
  2232. i;
  2233. if (array1 === array2) {
  2234. return true;
  2235. }
  2236. if (len1 !== len2) {
  2237. return false;
  2238. }
  2239. for (i = 0; i < len1; ++i) {
  2240. if (array1[i] !== array2[i]) {
  2241. return false;
  2242. }
  2243. }
  2244. return true;
  2245. },
  2246. clean: function(array) {
  2247. var results = [],
  2248. i, ln, item;
  2249. for (i = 0 , ln = array.length; i < ln; i++) {
  2250. item = array[i];
  2251. if (!Ext.isEmpty(item)) {
  2252. results.push(item);
  2253. }
  2254. }
  2255. return results;
  2256. },
  2257. unique: function(array) {
  2258. var clone = [],
  2259. i, ln, item;
  2260. for (i = 0 , ln = array.length; i < ln; i++) {
  2261. item = array[i];
  2262. if (ExtArray.indexOf(clone, item) === -1) {
  2263. clone.push(item);
  2264. }
  2265. }
  2266. return clone;
  2267. },
  2268. filter: ('filter' in arrayPrototype) ? function(array, fn, scope) {
  2269. Ext.Assert.isFunction(fn, 'Ext.Array.filter must have a filter function passed as second argument.');
  2270. return array.filter(fn, scope);
  2271. } : function(array, fn, scope) {
  2272. var results = [],
  2273. i, ln;
  2274. Ext.Assert.isFunction(fn, 'Ext.Array.filter must have a filter function passed as second argument.');
  2275. for (i = 0 , ln = array.length; i < ln; i++) {
  2276. if (fn.call(scope, array[i], i, array)) {
  2277. results.push(array[i]);
  2278. }
  2279. }
  2280. return results;
  2281. },
  2282. findBy: function(array, fn, scope) {
  2283. var i, len;
  2284. for (i = 0 , len = array.length; i < len; i++) {
  2285. if (fn.call(scope || array, array[i], i)) {
  2286. return array[i];
  2287. }
  2288. }
  2289. return null;
  2290. },
  2291. from: function(value, newReference) {
  2292. var type;
  2293. if (value === undefined || value === null) {
  2294. return [];
  2295. }
  2296. if (Ext.isArray(value)) {
  2297. return (newReference) ? slice.call(value) : value;
  2298. }
  2299. type = typeof value;
  2300. if (value && value.length !== undefined && type !== 'string' && (type !== 'function' || !value.apply)) {
  2301. return ExtArray.toArray(value);
  2302. }
  2303. return [
  2304. value
  2305. ];
  2306. },
  2307. remove: function(array, item) {
  2308. var index = ExtArray.indexOf(array, item);
  2309. if (index !== -1) {
  2310. erase(array, index, 1);
  2311. }
  2312. return array;
  2313. },
  2314. removeAt: function(array, index, count) {
  2315. var len = array.length;
  2316. if (index >= 0 && index < len) {
  2317. count = count || 1;
  2318. count = Math.min(count, len - index);
  2319. erase(array, index, count);
  2320. }
  2321. return array;
  2322. },
  2323. include: function(array, item) {
  2324. if (!ExtArray.contains(array, item)) {
  2325. array.push(item);
  2326. }
  2327. },
  2328. clone: function(array) {
  2329. return slice.call(array);
  2330. },
  2331. merge: function() {
  2332. var args = slice.call(arguments),
  2333. array = [],
  2334. i, ln;
  2335. for (i = 0 , ln = args.length; i < ln; i++) {
  2336. array = array.concat(args[i]);
  2337. }
  2338. return ExtArray.unique(array);
  2339. },
  2340. intersect: function() {
  2341. var intersection = [],
  2342. arrays = slice.call(arguments),
  2343. arraysLength, array, arrayLength, minArray, minArrayIndex, minArrayCandidate, minArrayLength, element, elementCandidate, elementCount, i, j, k;
  2344. if (!arrays.length) {
  2345. return intersection;
  2346. }
  2347. arraysLength = arrays.length;
  2348. for (i = minArrayIndex = 0; i < arraysLength; i++) {
  2349. minArrayCandidate = arrays[i];
  2350. if (!minArray || minArrayCandidate.length < minArray.length) {
  2351. minArray = minArrayCandidate;
  2352. minArrayIndex = i;
  2353. }
  2354. }
  2355. minArray = ExtArray.unique(minArray);
  2356. erase(arrays, minArrayIndex, 1);
  2357. minArrayLength = minArray.length;
  2358. arraysLength = arrays.length;
  2359. for (i = 0; i < minArrayLength; i++) {
  2360. element = minArray[i];
  2361. elementCount = 0;
  2362. for (j = 0; j < arraysLength; j++) {
  2363. array = arrays[j];
  2364. arrayLength = array.length;
  2365. for (k = 0; k < arrayLength; k++) {
  2366. elementCandidate = array[k];
  2367. if (element === elementCandidate) {
  2368. elementCount++;
  2369. break;
  2370. }
  2371. }
  2372. }
  2373. if (elementCount === arraysLength) {
  2374. intersection.push(element);
  2375. }
  2376. }
  2377. return intersection;
  2378. },
  2379. difference: function(arrayA, arrayB) {
  2380. var clone = slice.call(arrayA),
  2381. ln = clone.length,
  2382. i, j, lnB;
  2383. for (i = 0 , lnB = arrayB.length; i < lnB; i++) {
  2384. for (j = 0; j < ln; j++) {
  2385. if (clone[j] === arrayB[i]) {
  2386. erase(clone, j, 1);
  2387. j--;
  2388. ln--;
  2389. }
  2390. }
  2391. }
  2392. return clone;
  2393. },
  2394. reduce: Array.prototype.reduce ? function(array, reduceFn, initialValue) {
  2395. if (arguments.length === 3) {
  2396. return Array.prototype.reduce.call(array, reduceFn, initialValue);
  2397. }
  2398. return Array.prototype.reduce.call(array, reduceFn);
  2399. } : function(array, reduceFn, initialValue) {
  2400. array = Object(array);
  2401. if (!Ext.isFunction(reduceFn)) {
  2402. Ext.raise('Invalid parameter: expected a function.');
  2403. }
  2404. var index = 0,
  2405. length = array.length >>> 0,
  2406. reduced = initialValue;
  2407. if (arguments.length < 3) {
  2408. while (true) {
  2409. if (index in array) {
  2410. reduced = array[index++];
  2411. break;
  2412. }
  2413. if (++index >= length) {
  2414. throw new TypeError('Reduce of empty array with no initial value');
  2415. }
  2416. }
  2417. }
  2418. for (; index < length; ++index) {
  2419. if (index in array) {
  2420. reduced = reduceFn(reduced, array[index], index, array);
  2421. }
  2422. }
  2423. return reduced;
  2424. },
  2425. slice: ([
  2426. 1,
  2427. 2
  2428. ].slice(1, undefined).length ? function(array, begin, end) {
  2429. return slice.call(array, begin, end);
  2430. } : function(array, begin, end) {
  2431. if (typeof begin === 'undefined') {
  2432. return slice.call(array);
  2433. }
  2434. if (typeof end === 'undefined') {
  2435. return slice.call(array, begin);
  2436. }
  2437. return slice.call(array, begin, end);
  2438. }),
  2439. sort: function(array, sortFn) {
  2440. return stableSort(array, sortFn || ExtArray.lexicalCompare);
  2441. },
  2442. flatten: function(array) {
  2443. var worker = [];
  2444. function rFlatten(a) {
  2445. var i, ln, v;
  2446. for (i = 0 , ln = a.length; i < ln; i++) {
  2447. v = a[i];
  2448. if (Ext.isArray(v)) {
  2449. rFlatten(v);
  2450. } else {
  2451. worker.push(v);
  2452. }
  2453. }
  2454. return worker;
  2455. }
  2456. return rFlatten(array);
  2457. },
  2458. min: function(array, comparisonFn) {
  2459. var min = array[0],
  2460. i, ln, item;
  2461. for (i = 0 , ln = array.length; i < ln; i++) {
  2462. item = array[i];
  2463. if (comparisonFn) {
  2464. if (comparisonFn(min, item) === 1) {
  2465. min = item;
  2466. }
  2467. } else {
  2468. if (item < min) {
  2469. min = item;
  2470. }
  2471. }
  2472. }
  2473. return min;
  2474. },
  2475. max: function(array, comparisonFn) {
  2476. var max = array[0],
  2477. i, ln, item;
  2478. for (i = 0 , ln = array.length; i < ln; i++) {
  2479. item = array[i];
  2480. if (comparisonFn) {
  2481. if (comparisonFn(max, item) === -1) {
  2482. max = item;
  2483. }
  2484. } else {
  2485. if (item > max) {
  2486. max = item;
  2487. }
  2488. }
  2489. }
  2490. return max;
  2491. },
  2492. mean: function(array) {
  2493. return array.length > 0 ? ExtArray.sum(array) / array.length : undefined;
  2494. },
  2495. sum: function(array) {
  2496. var sum = 0,
  2497. i, ln, item;
  2498. for (i = 0 , ln = array.length; i < ln; i++) {
  2499. item = array[i];
  2500. sum += item;
  2501. }
  2502. return sum;
  2503. },
  2504. toMap: function(strings, getKey, scope) {
  2505. var map, i;
  2506. if (!strings) {
  2507. return null;
  2508. }
  2509. map = {};
  2510. i = strings.length;
  2511. if (typeof strings === 'string') {
  2512. map[strings] = 1;
  2513. } else if (!getKey) {
  2514. while (i--) {
  2515. map[strings[i]] = i + 1;
  2516. }
  2517. } else if (typeof getKey === 'string') {
  2518. while (i--) {
  2519. map[strings[i][getKey]] = i + 1;
  2520. }
  2521. } else {
  2522. while (i--) {
  2523. map[getKey.call(scope, strings[i])] = i + 1;
  2524. }
  2525. }
  2526. return map;
  2527. },
  2528. toValueMap: function(array, getKey, scope, arrayify) {
  2529. var map = {},
  2530. i = array.length,
  2531. autoArray, alwaysArray, entry, fn, key, value;
  2532. if (!getKey) {
  2533. while (i--) {
  2534. value = array[i];
  2535. map[value] = value;
  2536. }
  2537. } else {
  2538. if (!(fn = (typeof getKey !== 'string'))) {
  2539. arrayify = scope;
  2540. }
  2541. alwaysArray = arrayify === 1;
  2542. autoArray = arrayify === 2;
  2543. while (i--) {
  2544. value = array[i];
  2545. key = fn ? getKey.call(scope, value) : value[getKey];
  2546. if (alwaysArray) {
  2547. if (key in map) {
  2548. map[key].push(value);
  2549. } else {
  2550. map[key] = [
  2551. value
  2552. ];
  2553. }
  2554. } else if (autoArray && (key in map)) {
  2555. if ((entry = map[key]) instanceof Array) {
  2556. entry.push(value);
  2557. } else {
  2558. map[key] = [
  2559. entry,
  2560. value
  2561. ];
  2562. }
  2563. } else {
  2564. map[key] = value;
  2565. }
  2566. }
  2567. }
  2568. return map;
  2569. },
  2570. _replaceSim: replaceSim,
  2571. _spliceSim: spliceSim,
  2572. erase: erase,
  2573. insert: function(array, index, items) {
  2574. return replace(array, index, 0, items);
  2575. },
  2576. move: function(array, fromIdx, toIdx) {
  2577. if (toIdx === fromIdx) {
  2578. return;
  2579. }
  2580. var item = array[fromIdx],
  2581. incr = toIdx > fromIdx ? 1 : -1,
  2582. i;
  2583. for (i = fromIdx; i !== toIdx; i += incr) {
  2584. array[i] = array[i + incr];
  2585. }
  2586. array[toIdx] = item;
  2587. },
  2588. replace: replace,
  2589. splice: splice,
  2590. push: function(target) {
  2591. var args = arguments,
  2592. len = args.length,
  2593. i, newItem;
  2594. if (target === undefined) {
  2595. target = [];
  2596. } else if (!Ext.isArray(target)) {
  2597. target = [
  2598. target
  2599. ];
  2600. }
  2601. for (i = 1; i < len; i++) {
  2602. newItem = args[i];
  2603. Array.prototype.push[Ext.isIterable(newItem) ? 'apply' : 'call'](target, newItem);
  2604. }
  2605. return target;
  2606. },
  2607. numericSortFn: function(a, b) {
  2608. return a - b;
  2609. }
  2610. };
  2611. Ext.each = ExtArray.each;
  2612. ExtArray.union = ExtArray.merge;
  2613. Ext.min = ExtArray.min;
  2614. Ext.max = ExtArray.max;
  2615. Ext.sum = ExtArray.sum;
  2616. Ext.mean = ExtArray.mean;
  2617. Ext.flatten = ExtArray.flatten;
  2618. Ext.clean = ExtArray.clean;
  2619. Ext.unique = ExtArray.unique;
  2620. Ext.pluck = ExtArray.pluck;
  2621. Ext.toArray = function() {
  2622. return ExtArray.toArray.apply(ExtArray, arguments);
  2623. };
  2624. return ExtArray;
  2625. }());
  2626. Ext.Assert = {
  2627. falsey: function(b, msg) {
  2628. if (b) {
  2629. Ext.raise(msg || ('Expected a falsey value but was ' + b));
  2630. }
  2631. },
  2632. falseyProp: function(object, property) {
  2633. var b;
  2634. Ext.Assert.truthy(object);
  2635. b = object[property];
  2636. if (b) {
  2637. if (object.$className) {
  2638. property = object.$className + '#' + property;
  2639. }
  2640. Ext.raise('Expected a falsey value for ' + property + ' but was ' + b);
  2641. }
  2642. },
  2643. truthy: function(b, msg) {
  2644. if (!b) {
  2645. Ext.raise(msg || ('Expected a truthy value but was ' + typeof b));
  2646. }
  2647. },
  2648. truthyProp: function(object, property) {
  2649. var b;
  2650. Ext.Assert.truthy(object);
  2651. b = object[property];
  2652. if (!b) {
  2653. if (object.$className) {
  2654. property = object.$className + '#' + property;
  2655. }
  2656. Ext.raise('Expected a truthy value for ' + property + ' but was ' + typeof b);
  2657. }
  2658. }
  2659. };
  2660. (function() {
  2661. var name, kind;
  2662. function makeAssert(name, kind) {
  2663. var testFn = Ext[name],
  2664. def;
  2665. return function(value, msg) {
  2666. if (!testFn(value)) {
  2667. Ext.raise(msg || def || (def = 'Expected value to be ' + kind));
  2668. }
  2669. };
  2670. }
  2671. function makeAssertProp(name, kind) {
  2672. var testFn = Ext[name],
  2673. def;
  2674. return function(object, prop) {
  2675. Ext.Assert.truthy(object);
  2676. if (!testFn(object[prop])) {
  2677. Ext.raise(def || (def = 'Expected ' + (object.$className ? object.$className + '#' : '') + prop + ' to be ' + kind));
  2678. }
  2679. };
  2680. }
  2681. function makeNotAssert(name, kind) {
  2682. var testFn = Ext[name],
  2683. def;
  2684. return function(value, msg) {
  2685. if (testFn(value)) {
  2686. Ext.raise(msg || def || (def = 'Expected value to NOT be ' + kind));
  2687. }
  2688. };
  2689. }
  2690. function makeNotAssertProp(name, kind) {
  2691. var testFn = Ext[name],
  2692. def;
  2693. return function(object, prop) {
  2694. Ext.Assert.truthy(object);
  2695. if (testFn(object[prop])) {
  2696. Ext.raise(def || (def = 'Expected ' + (object.$className ? object.$className + '#' : '') + prop + ' to NOT be ' + kind));
  2697. }
  2698. };
  2699. }
  2700. for (name in Ext) {
  2701. if (name.substring(0, 2) === "is" && Ext.isFunction(Ext[name])) {
  2702. kind = name.substring(2);
  2703. Ext.Assert[name] = makeAssert(name, kind);
  2704. Ext.Assert[name + 'Prop'] = makeAssertProp(name, kind);
  2705. Ext.Assert['isNot' + kind] = makeNotAssert(name, kind);
  2706. Ext.Assert['isNot' + kind + 'Prop'] = makeNotAssertProp(name, kind);
  2707. }
  2708. }
  2709. }());
  2710. Ext.String = (function() {
  2711. var trimRegex = /^[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+|[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+$/g,
  2712. escapeRe = /('|\\)/g,
  2713. escapeRegexRe = /([-.*+?\^${}()|\[\]\/\\])/g,
  2714. basicTrimRe = /^\s+|\s+$/g,
  2715. whitespaceRe = /\s+/,
  2716. varReplace = /(^[^a-z]*|[^\w])/gi,
  2717. charToEntity, entityToChar, charToEntityRegex, entityToCharRegex,
  2718. htmlEncodeReplaceFn = function(match, capture) {
  2719. return charToEntity[capture];
  2720. },
  2721. htmlDecodeReplaceFn = function(match, capture) {
  2722. return (capture in entityToChar) ? entityToChar[capture] : String.fromCharCode(parseInt(capture.substr(2), 10));
  2723. },
  2724. boundsCheck = function(s, other) {
  2725. if (s === null || s === undefined || other === null || other === undefined) {
  2726. return false;
  2727. }
  2728. return other.length <= s.length;
  2729. },
  2730. fromCharCode = String.fromCharCode,
  2731. ExtString;
  2732. return ExtString = {
  2733. fromCodePoint: String.fromCodePoint || function() {
  2734. var codePoint,
  2735. result = '',
  2736. codeUnits = [],
  2737. index = -1,
  2738. length = arguments.length;
  2739. while (++index < length) {
  2740. codePoint = Number(arguments[index]);
  2741. if (!isFinite(codePoint) ||
  2742. codePoint < 0 ||
  2743. codePoint > 1114111 ||
  2744. Math.floor(codePoint) !== codePoint)
  2745. {
  2746. Ext.raise('Invalid code point: ' + codePoint);
  2747. }
  2748. if (codePoint <= 65535) {
  2749. codeUnits.push(codePoint);
  2750. } else {
  2751. codePoint -= 65536;
  2752. codeUnits.push((codePoint >> 10) + 55296, (codePoint % 1024) + 56320);
  2753. }
  2754. if (index + 1 === length) {
  2755. result += fromCharCode(codeUnits);
  2756. codeUnits.length = 0;
  2757. }
  2758. }
  2759. return result;
  2760. },
  2761. insert: function(s, value, index) {
  2762. var len;
  2763. if (!s) {
  2764. return value;
  2765. }
  2766. if (!value) {
  2767. return s;
  2768. }
  2769. len = s.length;
  2770. if (!index && index !== 0) {
  2771. index = len;
  2772. }
  2773. if (index < 0) {
  2774. index *= -1;
  2775. if (index >= len) {
  2776. index = 0;
  2777. } else {
  2778. index = len - index;
  2779. }
  2780. }
  2781. if (index === 0) {
  2782. s = value + s;
  2783. } else if (index >= s.length) {
  2784. s += value;
  2785. } else {
  2786. s = s.substr(0, index) + value + s.substr(index);
  2787. }
  2788. return s;
  2789. },
  2790. startsWith: function(s, start, ignoreCase) {
  2791. var result = boundsCheck(s, start);
  2792. if (result) {
  2793. if (ignoreCase) {
  2794. s = s.toLowerCase();
  2795. start = start.toLowerCase();
  2796. }
  2797. result = s.lastIndexOf(start, 0) === 0;
  2798. }
  2799. return result;
  2800. },
  2801. endsWith: function(s, end, ignoreCase) {
  2802. var result = boundsCheck(s, end);
  2803. if (result) {
  2804. if (ignoreCase) {
  2805. s = s.toLowerCase();
  2806. end = end.toLowerCase();
  2807. }
  2808. result = s.indexOf(end, s.length - end.length) !== -1;
  2809. }
  2810. return result;
  2811. },
  2812. createVarName: function(s) {
  2813. return s.replace(varReplace, '');
  2814. },
  2815. htmlEncode: function(value) {
  2816. return (!value) ? value : String(value).replace(charToEntityRegex, htmlEncodeReplaceFn);
  2817. },
  2818. htmlDecode: function(value) {
  2819. return (!value) ? value : String(value).replace(entityToCharRegex, htmlDecodeReplaceFn);
  2820. },
  2821. hasHtmlCharacters: function(s) {
  2822. return charToEntityRegex.test(s);
  2823. },
  2824. addCharacterEntities: function(newEntities) {
  2825. var charKeys = [],
  2826. entityKeys = [],
  2827. key, echar;
  2828. for (key in newEntities) {
  2829. echar = newEntities[key];
  2830. entityToChar[key] = echar;
  2831. charToEntity[echar] = key;
  2832. charKeys.push(echar);
  2833. entityKeys.push(key);
  2834. }
  2835. charToEntityRegex = new RegExp('(' + charKeys.join('|') + ')', 'g');
  2836. entityToCharRegex = new RegExp('(' + entityKeys.join('|') + '|&#[0-9]{1,5};' + ')', 'g');
  2837. },
  2838. resetCharacterEntities: function() {
  2839. charToEntity = {};
  2840. entityToChar = {};
  2841. this.addCharacterEntities({
  2842. '&amp;': '&',
  2843. '&gt;': '>',
  2844. '&lt;': '<',
  2845. '&quot;': '"',
  2846. '&#39;': "'"
  2847. });
  2848. },
  2849. urlAppend: function(url, string) {
  2850. if (!Ext.isEmpty(string)) {
  2851. return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
  2852. }
  2853. return url;
  2854. },
  2855. trim: function(string) {
  2856. if (string) {
  2857. string = string.replace(trimRegex, "");
  2858. }
  2859. return string || '';
  2860. },
  2861. capitalize: function(string) {
  2862. if (string) {
  2863. string = string.charAt(0).toUpperCase() + string.substr(1);
  2864. }
  2865. return string || '';
  2866. },
  2867. uncapitalize: function(string) {
  2868. if (string) {
  2869. string = string.charAt(0).toLowerCase() + string.substr(1);
  2870. }
  2871. return string || '';
  2872. },
  2873. ellipsis: function(value, length, word) {
  2874. var vs, index;
  2875. if (value && value.length > length) {
  2876. if (word) {
  2877. vs = value.substr(0, length - 2);
  2878. index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
  2879. if (index !== -1 && index >= (length - 15)) {
  2880. return vs.substr(0, index) + "...";
  2881. }
  2882. }
  2883. return value.substr(0, length - 3) + "...";
  2884. }
  2885. return value;
  2886. },
  2887. escapeRegex: function(string) {
  2888. return string.replace(escapeRegexRe, "\\$1");
  2889. },
  2890. createRegex: function(value, startsWith, endsWith, ignoreCase) {
  2891. var ret = value;
  2892. if (value != null && !value.exec) {
  2893. ret = ExtString.escapeRegex(String(value));
  2894. if (startsWith !== false) {
  2895. ret = '^' + ret;
  2896. }
  2897. if (endsWith !== false) {
  2898. ret += '$';
  2899. }
  2900. ret = new RegExp(ret, (ignoreCase !== false) ? 'i' : '');
  2901. }
  2902. return ret;
  2903. },
  2904. escape: function(string) {
  2905. return string.replace(escapeRe, "\\$1");
  2906. },
  2907. toggle: function(string, value, other) {
  2908. return string === value ? other : value;
  2909. },
  2910. leftPad: function(string, size, character) {
  2911. var result = String(string);
  2912. character = character || " ";
  2913. while (result.length < size) {
  2914. result = character + result;
  2915. }
  2916. return result;
  2917. },
  2918. repeat: function(pattern, count, sep) {
  2919. var buf = [],
  2920. i;
  2921. if (count < 1) {
  2922. count = 0;
  2923. }
  2924. for (i = count; i--; ) {
  2925. buf.push(pattern);
  2926. }
  2927. return buf.join(sep || '');
  2928. },
  2929. splitWords: function(words) {
  2930. if (words && typeof words === 'string') {
  2931. return words.replace(basicTrimRe, '').split(whitespaceRe);
  2932. }
  2933. return words || [];
  2934. }
  2935. };
  2936. }());
  2937. Ext.String.resetCharacterEntities();
  2938. Ext.htmlEncode = Ext.String.htmlEncode;
  2939. Ext.htmlDecode = Ext.String.htmlDecode;
  2940. Ext.urlAppend = Ext.String.urlAppend;
  2941. Ext.Date = (function() {
  2942. var utilDate,
  2943. nativeDate = Date,
  2944. stripEscapeRe = /(\\.)/g,
  2945. hourInfoRe = /([gGhHisucUOPZ]|MS)/,
  2946. dateInfoRe = /([djzmnYycU]|MS)/,
  2947. slashRe = /\\/gi,
  2948. numberTokenRe = /\{(\d+)\}/g,
  2949. MSFormatRe = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/'),
  2950. datePartsRe = /^(?:(\d{1,4})|(\w{3,}))[/\-.\\\s](?:(\d{1,2})|(\w{3,}))[/\-.\\\s](\d{1,4})$/,
  2951. pad = Ext.String.leftPad,
  2952. dayInfo = {
  2953. d: true,
  2954. j: true
  2955. },
  2956. monthInfo = {
  2957. F: true,
  2958. m: true,
  2959. M: true,
  2960. n: true
  2961. },
  2962. yearInfo = {
  2963. o: true,
  2964. Y: true,
  2965. y: true
  2966. },
  2967. code = [
  2968. "var me = this, dt, y, m, d, h, i, s, ms, o, O, z, zz, u, v, W, year, jan4, week1monday, daysInMonth, dayMatched,",
  2969. "def = me.defaults,",
  2970. "from = Ext.Number.from,",
  2971. "results = String(input).match(me.parseRegexes[{0}]);",
  2972. "if(results){",
  2973. "{1}",
  2974. "if(u != null){",
  2975. "v = new Date(u * 1000);",
  2976. "}else{",
  2977. "dt = me.clearTime(new Date);",
  2978. "y = from(y, from(def.y, dt.getFullYear()));",
  2979. "m = from(m, from(def.m - 1, dt.getMonth()));",
  2980. "dayMatched = d !== undefined;",
  2981. "d = from(d, from(def.d, dt.getDate()));",
  2982. "if (!dayMatched) {",
  2983. "dt.setDate(1);",
  2984. "dt.setMonth(m);",
  2985. "dt.setFullYear(y);",
  2986. "daysInMonth = me.getDaysInMonth(dt);",
  2987. "if (d > daysInMonth) {",
  2988. "d = daysInMonth;",
  2989. "}",
  2990. "}",
  2991. "h = from(h, from(def.h, dt.getHours()));",
  2992. "i = from(i, from(def.i, dt.getMinutes()));",
  2993. "s = from(s, from(def.s, dt.getSeconds()));",
  2994. "ms = from(ms, from(def.ms, dt.getMilliseconds()));",
  2995. "if(z >= 0 && y >= 0){",
  2996. "v = me.add(new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms), me.YEAR, y < 100 ? y - 100 : 0);",
  2997. "v = !strict? v : (strict === true && (z <= 364 || (me.isLeapYear(v) && z <= 365))? me.add(v, me.DAY, z) : null);",
  2998. "}else if(strict === true && !me.isValid(y, m + 1, d, h, i, s, ms)){",
  2999. "v = null;",
  3000. "}else{",
  3001. "if (W) {",
  3002. "year = y || (new Date()).getFullYear();",
  3003. "jan4 = new Date(year, 0, 4, 0, 0, 0);",
  3004. "d = jan4.getDay();",
  3005. "week1monday = new Date(jan4.getTime() - ((d === 0 ? 6 : d - 1) * 86400000));",
  3006. "v = Ext.Date.clearTime(new Date(week1monday.getTime() + ((W - 1) * 604800000 + 43200000)));",
  3007. "} else {",
  3008. "v = me.add(new Date(y < 100 ? 100 : y, m, d, h, i, s, ms), me.YEAR, y < 100 ? y - 100 : 0);",
  3009. "}",
  3010. "}",
  3011. "}",
  3012. "}",
  3013. "if(v){",
  3014. "if(zz != null){",
  3015. "v = me.add(v, me.SECOND, -v.getTimezoneOffset() * 60 - zz);",
  3016. "}else if(o){",
  3017. "v = me.add(v, me.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
  3018. "}",
  3019. "}",
  3020. "return (v != null) ? v : null;"
  3021. ].join('\n');
  3022. if (!Date.prototype.toISOString) {
  3023. Date.prototype.toISOString = function() {
  3024. var me = this;
  3025. return pad(me.getUTCFullYear(), 4, '0') + '-' + pad(me.getUTCMonth() + 1, 2, '0') + '-' + pad(me.getUTCDate(), 2, '0') + 'T' + pad(me.getUTCHours(), 2, '0') + ':' + pad(me.getUTCMinutes(), 2, '0') + ':' + pad(me.getUTCSeconds(), 2, '0') + '.' + pad(me.getUTCMilliseconds(), 3, '0') + 'Z';
  3026. };
  3027. }
  3028. function xf(format) {
  3029. var args = Array.prototype.slice.call(arguments, 1);
  3030. return format.replace(numberTokenRe, function(m, i) {
  3031. return args[i];
  3032. });
  3033. }
  3034. utilDate = {
  3035. now: nativeDate.now,
  3036. toString: function(date) {
  3037. if (!date) {
  3038. date = new nativeDate();
  3039. }
  3040. return date.getFullYear() + "-" + pad(date.getMonth() + 1, 2, '0') + "-" + pad(date.getDate(), 2, '0') + "T" + pad(date.getHours(), 2, '0') + ":" + pad(date.getMinutes(), 2, '0') + ":" + pad(date.getSeconds(), 2, '0');
  3041. },
  3042. getElapsed: function(dateA, dateB) {
  3043. return Math.abs(dateA - (dateB || utilDate.now()));
  3044. },
  3045. useStrict: false,
  3046. formatCodeToRegex: function(character, currentGroup) {
  3047. var p = utilDate.parseCodes[character];
  3048. if (p) {
  3049. p = typeof p === 'function' ? p() : p;
  3050. utilDate.parseCodes[character] = p;
  3051. }
  3052. return p ? Ext.applyIf({
  3053. c: p.c ? xf(p.c, currentGroup || "{0}") : p.c
  3054. }, p) : {
  3055. g: 0,
  3056. c: null,
  3057. s: Ext.String.escapeRegex(character)
  3058. };
  3059. },
  3060. parseFunctions: {
  3061. "MS": function(input, strict) {
  3062. var r = (input || '').match(MSFormatRe);
  3063. return r ? new nativeDate(((r[1] || '') + r[2]) * 1) : null;
  3064. },
  3065. "time": function(input, strict) {
  3066. var num = parseInt(input, 10);
  3067. if (num || num === 0) {
  3068. return new nativeDate(num);
  3069. }
  3070. return null;
  3071. },
  3072. "timestamp": function(input, strict) {
  3073. var num = parseInt(input, 10);
  3074. if (num || num === 0) {
  3075. return new nativeDate(num * 1000);
  3076. }
  3077. return null;
  3078. }
  3079. },
  3080. parseRegexes: [],
  3081. formatFunctions: {
  3082. "MS": function() {
  3083. return '\\/Date(' + this.getTime() + ')\\/';
  3084. },
  3085. "time": function() {
  3086. return this.getTime().toString();
  3087. },
  3088. "timestamp": function() {
  3089. return utilDate.format(this, 'U');
  3090. }
  3091. },
  3092. y2kYear: 50,
  3093. MILLI: "ms",
  3094. SECOND: "s",
  3095. MINUTE: "mi",
  3096. HOUR: "h",
  3097. DAY: "d",
  3098. MONTH: "mo",
  3099. YEAR: "y",
  3100. DAYS_IN_WEEK: 7,
  3101. MONTHS_IN_YEAR: 12,
  3102. MAX_DAYS_IN_MONTH: 31,
  3103. SUNDAY: 0,
  3104. MONDAY: 1,
  3105. TUESDAY: 2,
  3106. WEDNESDAY: 3,
  3107. THURSDAY: 4,
  3108. FRIDAY: 5,
  3109. SATURDAY: 6,
  3110. defaults: {},
  3111. dayNames: [
  3112. "Sunday",
  3113. "Monday",
  3114. "Tuesday",
  3115. "Wednesday",
  3116. "Thursday",
  3117. "Friday",
  3118. "Saturday"
  3119. ],
  3120. monthNames: [
  3121. "January",
  3122. "February",
  3123. "March",
  3124. "April",
  3125. "May",
  3126. "June",
  3127. "July",
  3128. "August",
  3129. "September",
  3130. "October",
  3131. "November",
  3132. "December"
  3133. ],
  3134. monthNumbers: {
  3135. January: 0,
  3136. Jan: 0,
  3137. February: 1,
  3138. Feb: 1,
  3139. March: 2,
  3140. Mar: 2,
  3141. April: 3,
  3142. Apr: 3,
  3143. May: 4,
  3144. June: 5,
  3145. Jun: 5,
  3146. July: 6,
  3147. Jul: 6,
  3148. August: 7,
  3149. Aug: 7,
  3150. September: 8,
  3151. Sep: 8,
  3152. October: 9,
  3153. Oct: 9,
  3154. November: 10,
  3155. Nov: 10,
  3156. December: 11,
  3157. Dec: 11
  3158. },
  3159. defaultFormat: 'm/d/Y',
  3160. defaultTimeFormat: 'h:i A',
  3161. firstDayOfWeek: 0,
  3162. weekendDays: [
  3163. 0,
  3164. 6
  3165. ],
  3166. getShortMonthName: function(month) {
  3167. return utilDate.monthNames[month].substring(0, 3);
  3168. },
  3169. getShortDayName: function(day) {
  3170. return utilDate.dayNames[day].substring(0, 3);
  3171. },
  3172. getMonthNumber: function(name) {
  3173. return utilDate.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
  3174. },
  3175. formatContainsHourInfo: function(format) {
  3176. return hourInfoRe.test(format.replace(stripEscapeRe, ''));
  3177. },
  3178. formatContainsDateInfo: function(format) {
  3179. return dateInfoRe.test(format.replace(stripEscapeRe, ''));
  3180. },
  3181. isMonthFormat: function(format) {
  3182. return !!monthInfo[format];
  3183. },
  3184. isYearFormat: function(format) {
  3185. return !!yearInfo[format];
  3186. },
  3187. unescapeFormat: function(format) {
  3188. return format.replace(slashRe, '');
  3189. },
  3190. formatCodes: {
  3191. d: "Ext.String.leftPad(m.getDate(), 2, '0')",
  3192. D: "Ext.Date.getShortDayName(m.getDay())",
  3193. j: "m.getDate()",
  3194. l: "Ext.Date.dayNames[m.getDay()]",
  3195. N: "(m.getDay() ? m.getDay() : 7)",
  3196. S: "Ext.Date.getSuffix(m)",
  3197. w: "m.getDay()",
  3198. z: "Ext.Date.getDayOfYear(m)",
  3199. W: "Ext.String.leftPad(Ext.Date.getWeekOfYear(m), 2, '0')",
  3200. F: "Ext.Date.monthNames[m.getMonth()]",
  3201. m: "Ext.String.leftPad(m.getMonth() + 1, 2, '0')",
  3202. M: "Ext.Date.getShortMonthName(m.getMonth())",
  3203. n: "(m.getMonth() + 1)",
  3204. t: "Ext.Date.getDaysInMonth(m)",
  3205. L: "(Ext.Date.isLeapYear(m) ? 1 : 0)",
  3206. o: "(m.getFullYear() + (Ext.Date.getWeekOfYear(m) == 1 && m.getMonth() > 0 ? +1 : (Ext.Date.getWeekOfYear(m) >= 52 && m.getMonth() < 11 ? -1 : 0)))",
  3207. Y: "Ext.String.leftPad(m.getFullYear(), 4, '0')",
  3208. y: "('' + m.getFullYear()).substring(2, 4)",
  3209. a: "(m.getHours() < 12 ? 'am' : 'pm')",
  3210. A: "(m.getHours() < 12 ? 'AM' : 'PM')",
  3211. g: "((m.getHours() % 12) ? m.getHours() % 12 : 12)",
  3212. G: "m.getHours()",
  3213. h: "Ext.String.leftPad((m.getHours() % 12) ? m.getHours() % 12 : 12, 2, '0')",
  3214. H: "Ext.String.leftPad(m.getHours(), 2, '0')",
  3215. i: "Ext.String.leftPad(m.getMinutes(), 2, '0')",
  3216. s: "Ext.String.leftPad(m.getSeconds(), 2, '0')",
  3217. u: "Ext.String.leftPad(m.getMilliseconds(), 3, '0')",
  3218. O: "Ext.Date.getGMTOffset(m)",
  3219. P: "Ext.Date.getGMTOffset(m, true)",
  3220. T: "Ext.Date.getTimezone(m)",
  3221. Z: "(m.getTimezoneOffset() * -60)",
  3222. c: function() {
  3223. var c = "Y-m-dTH:i:sP",
  3224. code = [],
  3225. l = c.length,
  3226. i, e;
  3227. for (i = 0; i < l; ++i) {
  3228. e = c.charAt(i);
  3229. code.push(e === "T" ? "'T'" : utilDate.getFormatCode(e));
  3230. }
  3231. return code.join(" + ");
  3232. },
  3233. C: function() {
  3234. return 'm.toISOString()';
  3235. },
  3236. U: "Math.round(m.getTime() / 1000)"
  3237. },
  3238. isValid: function(year, month, day, hour, minute, second, millisecond) {
  3239. var dt;
  3240. hour = hour || 0;
  3241. minute = minute || 0;
  3242. second = second || 0;
  3243. millisecond = millisecond || 0;
  3244. dt = utilDate.add(new nativeDate(year < 100 ? 100 : year, month - 1, day, hour, minute, second, millisecond), utilDate.YEAR, year < 100 ? year - 100 : 0);
  3245. return year === dt.getFullYear() && month === dt.getMonth() + 1 && day === dt.getDate() && hour === dt.getHours() && minute === dt.getMinutes() && second === dt.getSeconds() && millisecond === dt.getMilliseconds();
  3246. },
  3247. parse: function(input, format, strict) {
  3248. var p;
  3249. if (!format) {
  3250. return utilDate.flexParse(input);
  3251. }
  3252. p = utilDate.parseFunctions;
  3253. if (p[format] == null) {
  3254. utilDate.createParser(format);
  3255. }
  3256. return p[format].call(utilDate, input, Ext.isDefined(strict) ? strict : utilDate.useStrict);
  3257. },
  3258. parseDate: function(input, format, strict) {
  3259. return utilDate.parse(input, format, strict);
  3260. },
  3261. getFormatCode: function(character) {
  3262. var f = utilDate.formatCodes[character];
  3263. if (f) {
  3264. f = typeof f === 'function' ? f() : f;
  3265. utilDate.formatCodes[character] = f;
  3266. }
  3267. return f || ("'" + Ext.String.escape(character) + "'");
  3268. },
  3269. createFormat: function(format) {
  3270. var code = [],
  3271. special = false,
  3272. ch = '',
  3273. i;
  3274. for (i = 0; i < format.length; ++i) {
  3275. ch = format.charAt(i);
  3276. if (!special && ch === "\\") {
  3277. special = true;
  3278. } else if (special) {
  3279. special = false;
  3280. code.push("'" + Ext.String.escape(ch) + "'");
  3281. } else {
  3282. if (ch === '\n') {
  3283. code.push("'\\n'");
  3284. } else {
  3285. code.push(utilDate.getFormatCode(ch));
  3286. }
  3287. }
  3288. }
  3289. utilDate.formatFunctions[format] = Ext.functionFactory("var m = this; return " + code.join('+'));
  3290. },
  3291. createParser: function(format) {
  3292. var regexNum = utilDate.parseRegexes.length,
  3293. currentGroup = 1,
  3294. calc = [],
  3295. regex = [],
  3296. special = false,
  3297. ch = "",
  3298. i = 0,
  3299. len = format.length,
  3300. atEnd = [],
  3301. obj;
  3302. for (; i < len; ++i) {
  3303. ch = format.charAt(i);
  3304. if (!special && ch === "\\") {
  3305. special = true;
  3306. } else if (special) {
  3307. special = false;
  3308. regex.push(Ext.String.escape(ch));
  3309. } else {
  3310. obj = utilDate.formatCodeToRegex(ch, currentGroup);
  3311. currentGroup += obj.g;
  3312. regex.push(obj.s);
  3313. if (obj.g && obj.c) {
  3314. if (obj.calcAtEnd) {
  3315. atEnd.push(obj.c);
  3316. } else {
  3317. calc.push(obj.c);
  3318. }
  3319. }
  3320. }
  3321. }
  3322. calc = calc.concat(atEnd);
  3323. utilDate.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
  3324. utilDate.parseFunctions[format] = Ext.functionFactory("input", "strict", xf(code, regexNum, calc.join('')));
  3325. },
  3326. parseCodes: {
  3327. d: {
  3328. g: 1,
  3329. c: "d = parseInt(results[{0}], 10);\n",
  3330. s: "(3[0-1]|[1-2][0-9]|0[1-9])"
  3331. },
  3332. j: {
  3333. g: 1,
  3334. c: "d = parseInt(results[{0}], 10);\n",
  3335. s: "(3[0-1]|[1-2][0-9]|[1-9])"
  3336. },
  3337. D: function() {
  3338. var a = [],
  3339. i;
  3340. for (i = 0; i < 7; i++) {
  3341. a.push(utilDate.getShortDayName(i));
  3342. }
  3343. return {
  3344. g: 0,
  3345. c: null,
  3346. s: "(?:" + a.join("|") + ")"
  3347. };
  3348. },
  3349. l: function() {
  3350. return {
  3351. g: 0,
  3352. c: null,
  3353. s: "(?:" + utilDate.dayNames.join("|") + ")"
  3354. };
  3355. },
  3356. N: {
  3357. g: 0,
  3358. c: null,
  3359. s: "[1-7]"
  3360. },
  3361. S: {
  3362. g: 0,
  3363. c: null,
  3364. s: "(?:st|nd|rd|th)"
  3365. },
  3366. w: {
  3367. g: 0,
  3368. c: null,
  3369. s: "[0-6]"
  3370. },
  3371. z: {
  3372. g: 1,
  3373. c: "z = parseInt(results[{0}], 10);\n",
  3374. s: "(\\d{1,3})"
  3375. },
  3376. W: {
  3377. g: 1,
  3378. c: "W = parseInt(results[{0}], 10);\n",
  3379. s: "(\\d{2})"
  3380. },
  3381. F: function() {
  3382. return {
  3383. g: 1,
  3384. c: "m = parseInt(me.getMonthNumber(results[{0}]), 10);\n",
  3385. s: "(" + utilDate.monthNames.join("|") + ")"
  3386. };
  3387. },
  3388. M: function() {
  3389. var a = [],
  3390. i;
  3391. for (i = 0; i < 12; i++) {
  3392. a.push(utilDate.getShortMonthName(i));
  3393. }
  3394. return Ext.applyIf({
  3395. s: "(" + a.join("|") + ")"
  3396. }, utilDate.formatCodeToRegex("F"));
  3397. },
  3398. m: {
  3399. g: 1,
  3400. c: "m = parseInt(results[{0}], 10) - 1;\n",
  3401. s: "(1[0-2]|0[1-9])"
  3402. },
  3403. n: {
  3404. g: 1,
  3405. c: "m = parseInt(results[{0}], 10) - 1;\n",
  3406. s: "(1[0-2]|[1-9])"
  3407. },
  3408. t: {
  3409. g: 0,
  3410. c: null,
  3411. s: "(?:\\d{2})"
  3412. },
  3413. L: {
  3414. g: 0,
  3415. c: null,
  3416. s: "(?:1|0)"
  3417. },
  3418. o: {
  3419. g: 1,
  3420. c: "y = parseInt(results[{0}], 10);\n",
  3421. s: "(\\d{4})"
  3422. },
  3423. Y: {
  3424. g: 1,
  3425. c: "y = parseInt(results[{0}], 10);\n",
  3426. s: "(\\d{4})"
  3427. },
  3428. y: {
  3429. g: 1,
  3430. c: "var ty = parseInt(results[{0}], 10);\n" + "y = ty > me.y2kYear ? 1900 + ty : 2000 + ty;\n",
  3431. s: "(\\d{2})"
  3432. },
  3433. a: {
  3434. g: 1,
  3435. c: "if (/(am)/i.test(results[{0}])) {\n" + "if (!h || h == 12) { h = 0; }\n" + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
  3436. s: "(am|pm|AM|PM)",
  3437. calcAtEnd: true
  3438. },
  3439. A: {
  3440. g: 1,
  3441. c: "if (/(am)/i.test(results[{0}])) {\n" + "if (!h || h == 12) { h = 0; }\n" + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
  3442. s: "(AM|PM|am|pm)",
  3443. calcAtEnd: true
  3444. },
  3445. g: {
  3446. g: 1,
  3447. c: "h = parseInt(results[{0}], 10);\n",
  3448. s: "(1[0-2]|[1-9])"
  3449. },
  3450. G: {
  3451. g: 1,
  3452. c: "h = parseInt(results[{0}], 10);\n",
  3453. s: "(2[0-3]|1[0-9]|[0-9])"
  3454. },
  3455. h: {
  3456. g: 1,
  3457. c: "h = parseInt(results[{0}], 10);\n",
  3458. s: "(1[0-2]|0[1-9])"
  3459. },
  3460. H: {
  3461. g: 1,
  3462. c: "h = parseInt(results[{0}], 10);\n",
  3463. s: "(2[0-3]|[0-1][0-9])"
  3464. },
  3465. i: {
  3466. g: 1,
  3467. c: "i = parseInt(results[{0}], 10);\n",
  3468. s: "([0-5][0-9])"
  3469. },
  3470. s: {
  3471. g: 1,
  3472. c: "s = parseInt(results[{0}], 10);\n",
  3473. s: "([0-5][0-9])"
  3474. },
  3475. u: {
  3476. g: 1,
  3477. c: "ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",
  3478. s: "(\\d+)"
  3479. },
  3480. O: {
  3481. g: 1,
  3482. c: [
  3483. "o = results[{0}];",
  3484. "var sn = o.substring(0,1),",
  3485. "hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),",
  3486. "mn = o.substring(3,5) % 60;",
  3487. "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\n"
  3488. ].
  3489. join("\n"),
  3490. s: "([+-]\\d{4})"
  3491. },
  3492. P: {
  3493. g: 1,
  3494. c: [
  3495. "o = results[{0}];",
  3496. "var sn = o.substring(0,1),",
  3497. "hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),",
  3498. "mn = o.substring(4,6) % 60;",
  3499. "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\n"
  3500. ].
  3501. join("\n"),
  3502. s: "([+-]\\d{2}:\\d{2})"
  3503. },
  3504. T: {
  3505. g: 0,
  3506. c: null,
  3507. s: "[A-Z]{1,5}"
  3508. },
  3509. Z: {
  3510. g: 1,
  3511. c: "zz = results[{0}] * 1;\n" +
  3512. "zz = (-43200 <= zz && zz <= 50400)? zz : null;\n",
  3513. s: "([+-]?\\d{1,5})"
  3514. },
  3515. c: function() {
  3516. var calc = [],
  3517. arr = [
  3518. utilDate.formatCodeToRegex("Y", 1),
  3519. utilDate.formatCodeToRegex("m", 2),
  3520. utilDate.formatCodeToRegex("d", 3),
  3521. utilDate.formatCodeToRegex("H", 4),
  3522. utilDate.formatCodeToRegex("i", 5),
  3523. utilDate.formatCodeToRegex("s", 6),
  3524. {
  3525. c: "ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"
  3526. },
  3527. {
  3528. c: [
  3529. "if (results[8]) {",
  3530. "if (results[8] == 'Z') {",
  3531. "zz = 0;",
  3532. "}",
  3533. "else if (results[8].indexOf(':') > -1) {",
  3534. utilDate.formatCodeToRegex("P", 8).c,
  3535. "}",
  3536. "else {",
  3537. utilDate.formatCodeToRegex("O", 8).c,
  3538. "}",
  3539. "}"
  3540. ].join('\n')
  3541. }
  3542. ],
  3543. i, l;
  3544. for (i = 0 , l = arr.length; i < l; ++i) {
  3545. calc.push(arr[i].c);
  3546. }
  3547. return {
  3548. g: 1,
  3549. c: calc.join(""),
  3550. s: [
  3551. arr[0].s,
  3552. "(?:",
  3553. "-",
  3554. arr[1].s,
  3555. "(?:",
  3556. "-",
  3557. arr[2].s,
  3558. "(?:",
  3559. "(?:T| )?",
  3560. arr[3].s,
  3561. ":",
  3562. arr[4].s,
  3563. "(?::",
  3564. arr[5].s,
  3565. ")?",
  3566. "(?:(?:\\.|,)(\\d+))?",
  3567. "(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?",
  3568. ")?",
  3569. ")?",
  3570. ")?"
  3571. ].join("")
  3572. };
  3573. },
  3574. U: {
  3575. g: 1,
  3576. c: "u = parseInt(results[{0}], 10);\n",
  3577. s: "(-?\\d+)"
  3578. }
  3579. },
  3580. compare: function(d1, d2, includeTime) {
  3581. var s1, s2;
  3582. if (typeof d1 === 'string') {
  3583. d1 = Ext.Date.parse(d1);
  3584. }
  3585. if (typeof d2 === 'string') {
  3586. d2 = Ext.Date.parse(d2);
  3587. }
  3588. s1 = Ext.Date.format(d1, 'C');
  3589. s2 = Ext.Date.format(d2, 'C');
  3590. if (!includeTime) {
  3591. s1 = s1.substr(0, 10);
  3592. s2 = s2.substr(0, 10);
  3593. }
  3594. return (s1 < s2) ? -1 : ((s2 < s1) ? 1 : 0);
  3595. },
  3596. dateFormat: function(date, format) {
  3597. return utilDate.format(date, format);
  3598. },
  3599. isEqual: function(date1, date2) {
  3600. if (date1 && date2) {
  3601. return +date1 === +date2;
  3602. }
  3603. return !(date1 || date2);
  3604. },
  3605. format: function(date, format) {
  3606. var formatFunctions = utilDate.formatFunctions;
  3607. if (!Ext.isDate(date)) {
  3608. return '';
  3609. }
  3610. if (formatFunctions[format] == null) {
  3611. utilDate.createFormat(format);
  3612. }
  3613. return formatFunctions[format].call(date) + '';
  3614. },
  3615. getTimezone: function(date) {
  3616. return date.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,5})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
  3617. },
  3618. getGMTOffset: function(date, colon) {
  3619. var offset = date.getTimezoneOffset();
  3620. return (offset > 0 ? "-" : "+") + Ext.String.leftPad(Math.floor(Math.abs(offset) / 60), 2, "0") + (colon ? ":" : "") + Ext.String.leftPad(Math.abs(offset % 60), 2, "0");
  3621. },
  3622. getDayOfYear: function(date) {
  3623. var num = 0,
  3624. d = utilDate.clone(date),
  3625. m = date.getMonth(),
  3626. i;
  3627. for (i = 0 , d.setDate(1) , d.setMonth(0); i < m; d.setMonth(++i)) {
  3628. num += utilDate.getDaysInMonth(d);
  3629. }
  3630. return num + date.getDate() - 1;
  3631. },
  3632. getWeekOfYear: (function() {
  3633. var ms1d = 86400000,
  3634. ms7d = 7 * ms1d;
  3635. return function(date) {
  3636. var DC3 = nativeDate.UTC(date.getFullYear(), date.getMonth(), date.getDate() + 3) / ms1d,
  3637. AWN = Math.floor(DC3 / 7),
  3638. Wyr = new nativeDate(AWN * ms7d).getUTCFullYear();
  3639. return AWN - Math.floor(nativeDate.UTC(Wyr, 0, 7) / ms7d) + 1;
  3640. };
  3641. }()),
  3642. isLeapYear: function(date) {
  3643. var year = date.getFullYear();
  3644. return !!((year & 3) === 0 && (year % 100 || (year % 400 === 0 && year)));
  3645. },
  3646. getFirstDayOfMonth: function(date) {
  3647. var day = (date.getDay() - (date.getDate() - 1)) % 7;
  3648. return (day < 0) ? (day + 7) : day;
  3649. },
  3650. getLastDayOfMonth: function(date) {
  3651. return utilDate.getLastDateOfMonth(date).getDay();
  3652. },
  3653. getFirstDateOfMonth: function(date) {
  3654. return new nativeDate(date.getFullYear(), date.getMonth(), 1);
  3655. },
  3656. getLastDateOfMonth: function(date) {
  3657. return new nativeDate(date.getFullYear(), date.getMonth(), utilDate.getDaysInMonth(date));
  3658. },
  3659. getDaysInMonth: (function() {
  3660. var daysInMonth = [
  3661. 31,
  3662. 28,
  3663. 31,
  3664. 30,
  3665. 31,
  3666. 30,
  3667. 31,
  3668. 31,
  3669. 30,
  3670. 31,
  3671. 30,
  3672. 31
  3673. ];
  3674. return function(date) {
  3675. var m = date.getMonth();
  3676. return m === 1 && utilDate.isLeapYear(date) ? 29 : daysInMonth[m];
  3677. };
  3678. }()),
  3679. getSuffix: function(date) {
  3680. switch (date.getDate()) {
  3681. case 1:
  3682. case 21:
  3683. case 31:
  3684. return "st";
  3685. case 2:
  3686. case 22:
  3687. return "nd";
  3688. case 3:
  3689. case 23:
  3690. return "rd";
  3691. default:
  3692. return "th";
  3693. }
  3694. },
  3695. clone: function(date) {
  3696. return new nativeDate(date.getTime());
  3697. },
  3698. isDST: function(date) {
  3699. return new nativeDate(date.getFullYear(), 0, 1).getTimezoneOffset() !== date.getTimezoneOffset();
  3700. },
  3701. clearTime: function(date, clone) {
  3702. var d, hr, c;
  3703. if (isNaN(date.getTime())) {
  3704. return date;
  3705. }
  3706. if (clone) {
  3707. return utilDate.clearTime(utilDate.clone(date));
  3708. }
  3709. d = date.getDate();
  3710. date.setHours(0);
  3711. date.setMinutes(0);
  3712. date.setSeconds(0);
  3713. date.setMilliseconds(0);
  3714. if (date.getDate() !== d) {
  3715. for (hr = 1 , c = utilDate.add(date, utilDate.HOUR, hr); c.getDate() !== d; hr++ , c = utilDate.add(date, utilDate.HOUR, hr)){}
  3716. date.setDate(d);
  3717. date.setHours(c.getHours());
  3718. }
  3719. return date;
  3720. },
  3721. add: function(date, interval, value, preventDstAdjust) {
  3722. var d = utilDate.clone(date),
  3723. base = 0,
  3724. day, decimalValue;
  3725. if (!interval || value === 0) {
  3726. return d;
  3727. }
  3728. decimalValue = value - parseInt(value, 10);
  3729. value = parseInt(value, 10);
  3730. if (value) {
  3731. switch (interval.toLowerCase()) {
  3732. case utilDate.MILLI:
  3733. if (preventDstAdjust) {
  3734. d.setMilliseconds(d.getMilliseconds() + value);
  3735. } else {
  3736. d.setTime(d.getTime() + value);
  3737. };
  3738. break;
  3739. case utilDate.SECOND:
  3740. if (preventDstAdjust) {
  3741. d.setSeconds(d.getSeconds() + value);
  3742. } else {
  3743. d.setTime(d.getTime() + value * 1000);
  3744. };
  3745. break;
  3746. case utilDate.MINUTE:
  3747. if (preventDstAdjust) {
  3748. d.setMinutes(d.getMinutes() + value);
  3749. } else {
  3750. d.setTime(d.getTime() + value * 60 * 1000);
  3751. };
  3752. break;
  3753. case utilDate.HOUR:
  3754. if (preventDstAdjust) {
  3755. d.setHours(d.getHours() + value);
  3756. } else {
  3757. d.setTime(d.getTime() + value * 60 * 60 * 1000);
  3758. };
  3759. break;
  3760. case utilDate.DAY:
  3761. if (preventDstAdjust === false) {
  3762. d.setTime(d.getTime() + value * 24 * 60 * 60 * 1000);
  3763. } else {
  3764. d.setDate(d.getDate() + value);
  3765. };
  3766. break;
  3767. case utilDate.MONTH:
  3768. day = date.getDate();
  3769. if (day > 28) {
  3770. day = Math.min(day, utilDate.getLastDateOfMonth(utilDate.add(utilDate.getFirstDateOfMonth(date), utilDate.MONTH, value)).getDate());
  3771. };
  3772. d.setDate(day);
  3773. d.setMonth(date.getMonth() + value);
  3774. break;
  3775. case utilDate.YEAR:
  3776. day = date.getDate();
  3777. if (day > 28) {
  3778. day = Math.min(day, utilDate.getLastDateOfMonth(utilDate.add(utilDate.getFirstDateOfMonth(date), utilDate.YEAR, value)).getDate());
  3779. };
  3780. d.setDate(day);
  3781. d.setFullYear(date.getFullYear() + value);
  3782. break;
  3783. }
  3784. }
  3785. if (decimalValue) {
  3786. switch (interval.toLowerCase()) {
  3787. case utilDate.MILLI:
  3788. base = 1;
  3789. break;
  3790. case utilDate.SECOND:
  3791. base = 1000;
  3792. break;
  3793. case utilDate.MINUTE:
  3794. base = 1000 * 60;
  3795. break;
  3796. case utilDate.HOUR:
  3797. base = 1000 * 60 * 60;
  3798. break;
  3799. case utilDate.DAY:
  3800. base = 1000 * 60 * 60 * 24;
  3801. break;
  3802. case utilDate.MONTH:
  3803. day = utilDate.getDaysInMonth(d);
  3804. base = 1000 * 60 * 60 * 24 * day;
  3805. break;
  3806. case utilDate.YEAR:
  3807. day = (utilDate.isLeapYear(d) ? 366 : 365);
  3808. base = 1000 * 60 * 60 * 24 * day;
  3809. break;
  3810. }
  3811. if (base) {
  3812. d.setTime(d.getTime() + base * decimalValue);
  3813. }
  3814. }
  3815. return d;
  3816. },
  3817. subtract: function(date, interval, value, preventDstAdjust) {
  3818. return utilDate.add(date, interval, -value, preventDstAdjust);
  3819. },
  3820. between: function(date, start, end) {
  3821. var t = date.getTime();
  3822. return start.getTime() <= t && t <= end.getTime();
  3823. },
  3824. isWeekend: function(date) {
  3825. return Ext.Array.indexOf(this.weekendDays, date.getDay()) > -1;
  3826. },
  3827. utcToLocal: function(d) {
  3828. return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
  3829. },
  3830. localToUtc: function(d) {
  3831. return utilDate.utc(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
  3832. },
  3833. utc: function(year, month, day, hour, min, s, ms) {
  3834. return new Date(Date.UTC(year, month, day, hour || 0, min || 0, s || 0, ms || 0));
  3835. },
  3836. compat: function() {
  3837. var p,
  3838. statics = [
  3839. 'useStrict',
  3840. 'formatCodeToRegex',
  3841. 'parseFunctions',
  3842. 'parseRegexes',
  3843. 'formatFunctions',
  3844. 'y2kYear',
  3845. 'MILLI',
  3846. 'SECOND',
  3847. 'MINUTE',
  3848. 'HOUR',
  3849. 'DAY',
  3850. 'MONTH',
  3851. 'YEAR',
  3852. 'defaults',
  3853. 'dayNames',
  3854. 'monthNames',
  3855. 'monthNumbers',
  3856. 'getShortMonthName',
  3857. 'getShortDayName',
  3858. 'getMonthNumber',
  3859. 'formatCodes',
  3860. 'isValid',
  3861. 'parseDate',
  3862. 'getFormatCode',
  3863. 'createFormat',
  3864. 'createParser',
  3865. 'parseCodes'
  3866. ],
  3867. proto = [
  3868. 'dateFormat',
  3869. 'format',
  3870. 'getTimezone',
  3871. 'getGMTOffset',
  3872. 'getDayOfYear',
  3873. 'getWeekOfYear',
  3874. 'isLeapYear',
  3875. 'getFirstDayOfMonth',
  3876. 'getLastDayOfMonth',
  3877. 'getDaysInMonth',
  3878. 'getSuffix',
  3879. 'clone',
  3880. 'isDST',
  3881. 'clearTime',
  3882. 'add',
  3883. 'between'
  3884. ],
  3885. sLen = statics.length,
  3886. pLen = proto.length,
  3887. stat, prot, s;
  3888. for (s = 0; s < sLen; s++) {
  3889. stat = statics[s];
  3890. nativeDate[stat] = utilDate[stat];
  3891. }
  3892. for (p = 0; p < pLen; p++) {
  3893. prot = proto[p];
  3894. nativeDate.prototype[prot] = function() {
  3895. var args = Array.prototype.slice.call(arguments);
  3896. args.unshift(this);
  3897. return utilDate[prot].apply(utilDate, args);
  3898. };
  3899. }
  3900. },
  3901. diff: function(min, max, unit) {
  3902. var diff = +max - min,
  3903. est;
  3904. switch (unit) {
  3905. case utilDate.MILLI:
  3906. return diff;
  3907. case utilDate.SECOND:
  3908. return Math.floor(diff / 1000);
  3909. case utilDate.MINUTE:
  3910. return Math.floor(diff / 60000);
  3911. case utilDate.HOUR:
  3912. return Math.floor(diff / 3600000);
  3913. case utilDate.DAY:
  3914. return Math.floor(diff / 86400000);
  3915. case 'w':
  3916. return Math.floor(diff / 604800000);
  3917. case utilDate.MONTH:
  3918. est = (max.getFullYear() * 12 + max.getMonth()) - (min.getFullYear() * 12 + min.getMonth());
  3919. if (utilDate.add(min, unit, est) > max) {
  3920. return est - 1;
  3921. };
  3922. return est;
  3923. case utilDate.YEAR:
  3924. est = max.getFullYear() - min.getFullYear();
  3925. if (utilDate.add(min, unit, est) > max) {
  3926. return est - 1;
  3927. } else {
  3928. return est;
  3929. };
  3930. }
  3931. },
  3932. align: function(date, unit, step) {
  3933. var num = new nativeDate(+date);
  3934. switch (unit.toLowerCase()) {
  3935. case utilDate.MILLI:
  3936. return num;
  3937. case utilDate.SECOND:
  3938. num.setUTCSeconds(num.getUTCSeconds() - num.getUTCSeconds() % step);
  3939. num.setUTCMilliseconds(0);
  3940. return num;
  3941. case utilDate.MINUTE:
  3942. num.setUTCMinutes(num.getUTCMinutes() - num.getUTCMinutes() % step);
  3943. num.setUTCSeconds(0);
  3944. num.setUTCMilliseconds(0);
  3945. return num;
  3946. case utilDate.HOUR:
  3947. num.setUTCHours(num.getUTCHours() - num.getUTCHours() % step);
  3948. num.setUTCMinutes(0);
  3949. num.setUTCSeconds(0);
  3950. num.setUTCMilliseconds(0);
  3951. return num;
  3952. case utilDate.DAY:
  3953. if (step === 7 || step === 14) {
  3954. num.setUTCDate(num.getUTCDate() - num.getUTCDay() + 1);
  3955. };
  3956. num.setUTCHours(0);
  3957. num.setUTCMinutes(0);
  3958. num.setUTCSeconds(0);
  3959. num.setUTCMilliseconds(0);
  3960. return num;
  3961. case utilDate.MONTH:
  3962. num.setUTCMonth(num.getUTCMonth() - (num.getUTCMonth() - 1) % step, 1);
  3963. num.setUTCHours(0);
  3964. num.setUTCMinutes(0);
  3965. num.setUTCSeconds(0);
  3966. num.setUTCMilliseconds(0);
  3967. return num;
  3968. case utilDate.YEAR:
  3969. num.setUTCFullYear(num.getUTCFullYear() - num.getUTCFullYear() % step, 1, 1);
  3970. num.setUTCHours(0);
  3971. num.setUTCMinutes(0);
  3972. num.setUTCSeconds(0);
  3973. num.setUTCMilliseconds(0);
  3974. return date;
  3975. }
  3976. },
  3977. flexParse: function(inDate, defaultFormat) {
  3978. var parts = datePartsRe.exec(inDate),
  3979. firstFormatToken, day, month, year, result;
  3980. if (!parts) {
  3981. return Ext.Date.parse(inDate, 'C');
  3982. }
  3983. if (!defaultFormat) {
  3984. defaultFormat = Ext.Date.defaultFormat;
  3985. }
  3986. if (!(parts[2] || parts[4])) {
  3987. firstFormatToken = defaultFormat[0];
  3988. if (!yearInfo[firstFormatToken] && (dayInfo[firstFormatToken] || (parts[1] > 12 && parts[3] < 13))) {
  3989. day = parseInt(parts[1]);
  3990. month = parseInt(parts[3]) - 1;
  3991. year = parseInt(parts[5]);
  3992. } else if (!yearInfo[firstFormatToken] && (monthInfo[firstFormatToken] || (parts[3] > 12 && parts[1] < 13))) {
  3993. month = parseInt(parts[1]) - 1;
  3994. day = parseInt(parts[3]);
  3995. year = parseInt(parts[5]);
  3996. } else {
  3997. year = parseInt(parts[1]);
  3998. month = parseInt(parts[3]) - 1;
  3999. day = parseInt(parts[5]);
  4000. }
  4001. } else {
  4002. if (parts[2] && parts[4]) {
  4003. return null;
  4004. }
  4005. if (parts[2]) {
  4006. month = utilDate.monthNumbers[Ext.String.capitalize(parts[2].substr(0, 3))];
  4007. day = parseInt(parts[3]);
  4008. year = parseInt(parts[5]);
  4009. } else {
  4010. day = parseInt(parts[1]);
  4011. month = utilDate.monthNumbers[Ext.String.capitalize(parts[4].substr(0, 3))];
  4012. year = parseInt(parts[5]);
  4013. }
  4014. }
  4015. if (isNaN(month) || (month < 0 || month > 11)) {
  4016. return null;
  4017. }
  4018. if (year < utilDate.y2kYear) {
  4019. year += 2000;
  4020. }
  4021. result = new Date(year, month, 1, 0, 0, 0);
  4022. if (day < 1 || day > Ext.Date.getDaysInMonth(result)) {
  4023. return null;
  4024. }
  4025. result.setDate(day);
  4026. return result;
  4027. }
  4028. };
  4029. utilDate.parseCodes.C = utilDate.parseCodes.c;
  4030. return utilDate;
  4031. }());
  4032. Ext.Function = (function() {
  4033. var lastTime = 0,
  4034. animFrameId,
  4035. animFrameHandlers = [],
  4036. animFrameNoArgs = [],
  4037. idSource = 0,
  4038. animFrameMap = {},
  4039. slice = Array.prototype.slice,
  4040. win = window,
  4041. global = Ext.global,
  4042. hasImmediate = !Ext.disableImmediate && !!(global.setImmediate && global.clearImmediate),
  4043. requestAnimFrame = win.requestAnimationFrame || win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame || win.oRequestAnimationFrame || function(callback) {
  4044. var currTime = Ext.now(),
  4045. timeToCall = Math.max(0, 16 - (currTime - lastTime)),
  4046. timerFn = function() {
  4047. callback(currTime + timeToCall);
  4048. },
  4049. id;
  4050. timerFn.$origFn = callback.$origFn || callback;
  4051. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4052. id = win.setTimeout(timerFn, timeToCall);
  4053. lastTime = currTime + timeToCall;
  4054. return id;
  4055. },
  4056. fireHandlers = function() {
  4057. var len = animFrameHandlers.length,
  4058. id, i, handler;
  4059. animFrameId = null;
  4060. var timer;
  4061. for (i = 0; i < len; i++) {
  4062. handler = animFrameHandlers[i];
  4063. id = handler[3];
  4064. if (animFrameMap[id]) {
  4065. delete animFrameMap[id];
  4066. timer = Ext.Timer.get(id, 'raf');
  4067. if (timer) {
  4068. timer.tick();
  4069. }
  4070. handler[0].apply(handler[1] || global, handler[2] || animFrameNoArgs);
  4071. if (timer) {
  4072. timer.tock();
  4073. }
  4074. }
  4075. }
  4076. animFrameHandlers = animFrameHandlers.slice(len);
  4077. },
  4078. fireElevatedHandlers = function() {
  4079. Ext.elevate(fireHandlers);
  4080. },
  4081. ExtFunction = {
  4082. flexSetter: function(setter) {
  4083. return function(name, value) {
  4084. var k, i;
  4085. if (name !== null) {
  4086. if (typeof name !== 'string') {
  4087. for (k in name) {
  4088. if (name.hasOwnProperty(k)) {
  4089. setter.call(this, k, name[k]);
  4090. }
  4091. }
  4092. if (Ext.enumerables) {
  4093. for (i = Ext.enumerables.length; i--; ) {
  4094. k = Ext.enumerables[i];
  4095. if (name.hasOwnProperty(k)) {
  4096. setter.call(this, k, name[k]);
  4097. }
  4098. }
  4099. }
  4100. } else {
  4101. setter.call(this, name, value);
  4102. }
  4103. }
  4104. return this;
  4105. };
  4106. },
  4107. bind: function(fn, scope, args, appendArgs) {
  4108. if (arguments.length <= 2) {
  4109. return fn.bind(scope);
  4110. }
  4111. var method = fn;
  4112. return function() {
  4113. var callArgs = args || arguments;
  4114. if (appendArgs === true) {
  4115. callArgs = slice.call(arguments, 0);
  4116. callArgs = callArgs.concat(args);
  4117. } else if (typeof appendArgs === 'number') {
  4118. callArgs = slice.call(arguments, 0);
  4119. Ext.Array.insert(callArgs, appendArgs, args);
  4120. }
  4121. return method.apply(scope || global, callArgs);
  4122. };
  4123. },
  4124. bindCallback: function(callback, scope, args, delay, caller) {
  4125. return function() {
  4126. var a = slice.call(arguments);
  4127. return Ext.callback(callback, scope, args ? args.concat(a) : a, delay, caller);
  4128. };
  4129. },
  4130. pass: function(fn, args, scope) {
  4131. if (!Ext.isArray(args)) {
  4132. if (Ext.isIterable(args)) {
  4133. args = Ext.Array.clone(args);
  4134. } else {
  4135. args = args !== undefined ? [
  4136. args
  4137. ] : [];
  4138. }
  4139. }
  4140. return function() {
  4141. var fnArgs = args.slice();
  4142. fnArgs.push.apply(fnArgs, arguments);
  4143. return fn.apply(scope || this, fnArgs);
  4144. };
  4145. },
  4146. alias: function(object, methodName) {
  4147. return function() {
  4148. return object[methodName].apply(object, arguments);
  4149. };
  4150. },
  4151. clone: function(method) {
  4152. var newMethod, prop;
  4153. newMethod = function() {
  4154. return method.apply(this, arguments);
  4155. };
  4156. for (prop in method) {
  4157. if (method.hasOwnProperty(prop)) {
  4158. newMethod[prop] = method[prop];
  4159. }
  4160. }
  4161. return newMethod;
  4162. },
  4163. createInterceptor: function(origFn, newFn, scope, returnValue) {
  4164. if (!Ext.isFunction(newFn)) {
  4165. return origFn;
  4166. } else {
  4167. returnValue = Ext.isDefined(returnValue) ? returnValue : null;
  4168. return function() {
  4169. var me = this,
  4170. args = arguments;
  4171. return (newFn.apply(scope || me || global, args) !== false) ? origFn.apply(me || global, args) : returnValue;
  4172. };
  4173. }
  4174. },
  4175. createDelayed: function(fn, delay, scope, args, appendArgs) {
  4176. var boundFn = fn;
  4177. if (scope || args) {
  4178. boundFn = Ext.Function.bind(fn, scope, args, appendArgs);
  4179. }
  4180. return function() {
  4181. var me = this,
  4182. args = slice.call(arguments),
  4183. timerFn, timerId;
  4184. var timer;
  4185. timerFn = function() {
  4186. Ext.elevate(boundFn, me, args,
  4187. timer);
  4188. };
  4189. timerId = setTimeout(timerFn, delay);
  4190. timerFn.$origFn = fn.$origFn || fn;
  4191. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4192. timer = Ext.Timer.created('timeout', timerId, {
  4193. type: 'createDelayed',
  4194. fn: fn,
  4195. timerFn: timerFn
  4196. });
  4197. };
  4198. },
  4199. defer: function(fn, millis, scope, args, appendArgs) {
  4200. var timerId = 0,
  4201. timerFn, boundFn;
  4202. var timer;
  4203. if (!scope && !args && !appendArgs) {
  4204. boundFn = fn;
  4205. } else {
  4206. boundFn = Ext.Function.bind(fn, scope, args, appendArgs);
  4207. }
  4208. if (millis > 0) {
  4209. timerFn = function() {
  4210. Ext.elevate(boundFn,
  4211. null, null, timer);
  4212. };
  4213. timerId = setTimeout(timerFn, millis);
  4214. timerFn.$origFn = fn.$origFn || fn;
  4215. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4216. timer = Ext.Timer.created('timeout', timerId, {
  4217. type: 'defer',
  4218. fn: fn,
  4219. timerFn: timerFn
  4220. });
  4221. } else
  4222. {
  4223. boundFn();
  4224. }
  4225. return timerId;
  4226. },
  4227. interval: function(fn, millis, scope, args, appendArgs) {
  4228. var timerFn, timerId, boundFn;
  4229. var timer;
  4230. boundFn = Ext.Function.bind(fn, scope, args, appendArgs);
  4231. timerFn = function() {
  4232. Ext.elevate(boundFn,
  4233. null, null, timer);
  4234. };
  4235. timerId = setInterval(timerFn, millis);
  4236. timerFn.$origFn = boundFn.$origFn || fn;
  4237. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4238. timer = Ext.Timer.created('interval', timerId, {
  4239. type: 'interval',
  4240. fn: fn,
  4241. timerFn: timerFn
  4242. });
  4243. return timerId;
  4244. },
  4245. createSequence: function(originalFn, newFn, scope) {
  4246. if (!newFn) {
  4247. return originalFn;
  4248. } else {
  4249. return function() {
  4250. var result = originalFn.apply(this, arguments);
  4251. newFn.apply(scope || this, arguments);
  4252. return result;
  4253. };
  4254. }
  4255. },
  4256. createBuffered: function(fn, buffer, scope, args) {
  4257. var timerId,
  4258. result = function() {
  4259. var callArgs = args || slice.call(arguments, 0),
  4260. me = scope || this,
  4261. timerFn;
  4262. var timer;
  4263. if (timerId) {
  4264. Ext.undefer(timerId);
  4265. }
  4266. timerFn = function() {
  4267. Ext.elevate(fn, me, callArgs,
  4268. timer);
  4269. };
  4270. result.timer = timerId = setTimeout(timerFn, buffer);
  4271. timerFn.$origFn = fn.$origFn || fn;
  4272. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4273. timer = Ext.Timer.created('timeout', timerId, {
  4274. type: 'createBuffered',
  4275. fn: fn,
  4276. timerFn: timerFn
  4277. });
  4278. };
  4279. return result;
  4280. },
  4281. createAnimationFrame: function(fn, scope, args, queueStrategy) {
  4282. var boundFn, timerId;
  4283. queueStrategy = queueStrategy || 3;
  4284. boundFn = function() {
  4285. var timerFn,
  4286. callArgs = args || slice.call(arguments, 0);
  4287. scope = scope || this;
  4288. if (queueStrategy === 3 && timerId) {
  4289. ExtFunction.cancelAnimationFrame(timerId);
  4290. }
  4291. if ((queueStrategy & 1) || !timerId) {
  4292. timerFn = function() {
  4293. timerId = boundFn.timerId = null;
  4294. fn.apply(scope, callArgs);
  4295. };
  4296. timerFn.$origFn = fn.$origFn || fn;
  4297. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4298. timerId = boundFn.timerId = ExtFunction.requestAnimationFrame(timerFn);
  4299. }
  4300. };
  4301. return boundFn;
  4302. },
  4303. requestAnimationFrame: function(fn, scope, args) {
  4304. var id = ++idSource,
  4305. handler = slice.call(arguments, 0);
  4306. handler[3] = id;
  4307. animFrameMap[id] = 1;
  4308. Ext.Timer.created('raf', id, {
  4309. type: 'raf',
  4310. fn: fn
  4311. });
  4312. animFrameHandlers.push(handler);
  4313. if (!animFrameId) {
  4314. animFrameId = requestAnimFrame(fireElevatedHandlers);
  4315. }
  4316. return id;
  4317. },
  4318. cancelAnimationFrame: function(id) {
  4319. delete animFrameMap[id];
  4320. Ext.Timer.cancel('raf', id);
  4321. },
  4322. createThrottled: function(fn, interval, scope) {
  4323. var lastCallTime = 0,
  4324. elapsed, lastArgs, timerId,
  4325. execute = function() {
  4326. fn.apply(scope, lastArgs);
  4327. lastCallTime = Ext.now();
  4328. lastArgs = timerId = null;
  4329. };
  4330. execute.$origFn = fn.$origFn || fn;
  4331. execute.$skipTimerCheck = execute.$origFn.$skipTimerCheck;
  4332. return function() {
  4333. if (!scope) {
  4334. scope = this;
  4335. }
  4336. elapsed = Ext.now() - lastCallTime;
  4337. lastArgs = Ext.Array.slice(arguments);
  4338. if (elapsed >= interval) {
  4339. Ext.undefer(timerId);
  4340. execute();
  4341. }
  4342. else if (!timerId) {
  4343. timerId = Ext.defer(execute, interval - elapsed);
  4344. }
  4345. };
  4346. },
  4347. createBarrier: function(count, fn, scope) {
  4348. var barrierFn = function() {
  4349. if (!--count) {
  4350. fn.apply(scope, arguments);
  4351. }
  4352. };
  4353. barrierFn.$origFn = fn.$origFn || fn;
  4354. barrierFn.$skipTimerCheck = barrierFn.$origFn.$skipTimerCheck;
  4355. return barrierFn;
  4356. },
  4357. interceptBefore: function(object, methodName, fn, scope) {
  4358. var method = object[methodName] || Ext.emptyFn;
  4359. return (object[methodName] = function() {
  4360. var ret = fn.apply(scope || this, arguments);
  4361. method.apply(this, arguments);
  4362. return ret;
  4363. });
  4364. },
  4365. interceptAfter: function(object, methodName, fn, scope) {
  4366. var method = object[methodName] || Ext.emptyFn;
  4367. return (object[methodName] = function() {
  4368. method.apply(this, arguments);
  4369. return fn.apply(scope || this, arguments);
  4370. });
  4371. },
  4372. interceptAfterOnce: function(object, methodName, fn, scope) {
  4373. var origMethod = object[methodName],
  4374. newMethod;
  4375. newMethod = function() {
  4376. var ret;
  4377. if (origMethod) {
  4378. origMethod.apply(this, arguments);
  4379. }
  4380. ret = fn.apply(scope || this, arguments);
  4381. object[methodName] = origMethod;
  4382. object = methodName = fn = scope = origMethod = newMethod = null;
  4383. return ret;
  4384. };
  4385. object[methodName] = newMethod;
  4386. return newMethod;
  4387. },
  4388. makeCallback: function(callback, scope) {
  4389. if (!scope[callback]) {
  4390. if (scope.$className) {
  4391. Ext.raise('No method "' + callback + '" on ' + scope.$className);
  4392. }
  4393. Ext.raise('No method "' + callback + '"');
  4394. }
  4395. return function() {
  4396. return scope[callback].apply(scope, arguments);
  4397. };
  4398. },
  4399. memoize: function(fn, scope, hashFn) {
  4400. var memo = {},
  4401. isFunc = hashFn && Ext.isFunction(hashFn);
  4402. return function(value) {
  4403. var key = isFunc ? hashFn.apply(scope, arguments) : value;
  4404. if (!(key in memo)) {
  4405. memo[key] = fn.apply(scope, arguments);
  4406. }
  4407. return memo[key];
  4408. };
  4409. },
  4410. _stripCommentRe: /(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(\/\/.*)/g,
  4411. toCode: function(fn) {
  4412. var s = fn ? fn.toString() : '';
  4413. s = s.replace(ExtFunction._stripCommentRe, '');
  4414. return s;
  4415. },
  4416. fireElevatedHandlers: function() {
  4417. fireElevatedHandlers();
  4418. }
  4419. };
  4420. Ext.asap = hasImmediate ? function(fn, scope, parameters) {
  4421. var boundFn = fn,
  4422. timerFn, timerId;
  4423. var timer;
  4424. if (scope != null || parameters != null) {
  4425. boundFn = ExtFunction.bind(fn, scope, parameters);
  4426. }
  4427. timerFn = function() {
  4428. Ext.elevate(boundFn,
  4429. null, null, timer);
  4430. };
  4431. timerId = setImmediate(timerFn);
  4432. timerFn.$origFn = fn.$origFn || fn;
  4433. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4434. timer = Ext.Timer.created('asap', timerId, {
  4435. type: 'asap',
  4436. fn: fn,
  4437. timerFn: timerFn
  4438. });
  4439. return timerId;
  4440. } : function(fn, scope, parameters) {
  4441. var boundFn = fn,
  4442. timerFn, timerId;
  4443. var timer;
  4444. if (scope != null || parameters != null) {
  4445. boundFn = ExtFunction.bind(fn, scope, parameters);
  4446. }
  4447. timerFn = function() {
  4448. Ext.elevate(boundFn,
  4449. null, null, timer);
  4450. };
  4451. timerId = setTimeout(timerFn, 0, true);
  4452. timerFn.$origFn = fn.$origFn || fn;
  4453. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4454. timer = Ext.Timer.created('timeout', timerId, {
  4455. type: 'asap',
  4456. fn: fn,
  4457. timerFn: timerFn
  4458. });
  4459. return timerId;
  4460. };
  4461. Ext.unasap = hasImmediate ? function(id) {
  4462. if (id) {
  4463. clearImmediate(id);
  4464. Ext.Timer.cancel('asap', id);
  4465. }
  4466. return null;
  4467. } : function(id) {
  4468. return Ext.undefer(id);
  4469. };
  4470. Ext.asapCancel = function(id) {
  4471. return Ext.unasap(id);
  4472. };
  4473. Ext.defer = ExtFunction.defer;
  4474. Ext.undefer = function(id) {
  4475. if (id) {
  4476. clearTimeout(id);
  4477. Ext.Timer.cancel('timeout', id);
  4478. }
  4479. return null;
  4480. };
  4481. Ext.interval = ExtFunction.interval;
  4482. Ext.uninterval = function(id) {
  4483. if (id) {
  4484. clearInterval(id);
  4485. Ext.Timer.cancel('interval', id);
  4486. }
  4487. return null;
  4488. };
  4489. Ext.pass = ExtFunction.pass;
  4490. Ext.bind = ExtFunction.bind;
  4491. Ext.raf = function() {
  4492. return ExtFunction.requestAnimationFrame.apply(ExtFunction, arguments);
  4493. };
  4494. Ext.unraf = function(id) {
  4495. ExtFunction.cancelAnimationFrame(id);
  4496. };
  4497. return ExtFunction;
  4498. })();
  4499. Ext.Number = (new function() {
  4500. var ExtNumber = this,
  4501. isToFixedBroken = (0.9).toFixed() !== '1',
  4502. math = Math,
  4503. ClipDefault = {
  4504. count: false,
  4505. inclusive: false,
  4506. wrap: true
  4507. };
  4508. Number.MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -(math.pow(2, 53) - 1);
  4509. Number.MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || math.pow(2, 53) - 1;
  4510. Ext.apply(ExtNumber, {
  4511. MIN_SAFE_INTEGER: Number.MIN_SAFE_INTEGER,
  4512. MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER,
  4513. floatRe: /^[-+]?(?:\d+|\d*\.\d*)(?:[Ee][+-]?\d+)?$/,
  4514. intRe: /^[-+]?\d+(?:[Ee]\+?\d+)?$/,
  4515. Clip: {
  4516. DEFAULT: ClipDefault,
  4517. COUNT: Ext.applyIf({
  4518. count: true
  4519. }, ClipDefault),
  4520. INCLUSIVE: Ext.applyIf({
  4521. inclusive: true
  4522. }, ClipDefault),
  4523. NOWRAP: Ext.applyIf({
  4524. wrap: false
  4525. }, ClipDefault)
  4526. },
  4527. parseFloat: function(value) {
  4528. if (value === undefined) {
  4529. value = null;
  4530. }
  4531. if (value !== null && typeof value !== 'number') {
  4532. value = String(value);
  4533. value = ExtNumber.floatRe.test(value) ? +value : null;
  4534. if (isNaN(value)) {
  4535. value = null;
  4536. }
  4537. }
  4538. return value;
  4539. },
  4540. parseInt: function(value) {
  4541. if (value === undefined) {
  4542. value = null;
  4543. }
  4544. if (typeof value === 'number') {
  4545. value = Math.floor(value);
  4546. } else if (value !== null) {
  4547. value = String(value);
  4548. value = ExtNumber.intRe.test(value) ? +value : null;
  4549. }
  4550. return value;
  4551. },
  4552. binarySearch: function(array, value, begin, end) {
  4553. var middle, midVal;
  4554. if (begin === undefined) {
  4555. begin = 0;
  4556. }
  4557. if (end === undefined) {
  4558. end = array.length;
  4559. }
  4560. --end;
  4561. while (begin <= end) {
  4562. middle = (begin + end) >>> 1;
  4563. midVal = array[middle];
  4564. if (value === midVal) {
  4565. return middle;
  4566. }
  4567. if (midVal < value) {
  4568. begin = middle + 1;
  4569. } else {
  4570. end = middle - 1;
  4571. }
  4572. }
  4573. return begin;
  4574. },
  4575. bisectTuples: function(array, value, index, begin, end) {
  4576. var middle, midVal;
  4577. if (begin === undefined) {
  4578. begin = 0;
  4579. }
  4580. if (end === undefined) {
  4581. end = array.length;
  4582. }
  4583. --end;
  4584. while (begin <= end) {
  4585. middle = (begin + end) >>> 1;
  4586. midVal = array[middle][index];
  4587. if (value === midVal) {
  4588. return middle;
  4589. }
  4590. if (midVal < value) {
  4591. begin = middle + 1;
  4592. } else {
  4593. end = middle - 1;
  4594. }
  4595. }
  4596. return begin;
  4597. },
  4598. clipIndices: function(length, indices, options) {
  4599. var defaultValue = 0,
  4600. wrap, begin, end, i;
  4601. options = options || ClipDefault;
  4602. wrap = options.wrap;
  4603. indices = indices || [];
  4604. for (i = 0; i < 2; ++i) {
  4605. begin = end;
  4606. end = indices[i];
  4607. if (end == null) {
  4608. end = defaultValue;
  4609. } else if (i && options.count) {
  4610. end += begin;
  4611. end = (end > length) ? length : end;
  4612. } else {
  4613. if (wrap) {
  4614. end = (end < 0) ? (length + end) : end;
  4615. }
  4616. if (i && options.inclusive) {
  4617. ++end;
  4618. }
  4619. end = (end < 0) ? 0 : ((end > length) ? length : end);
  4620. }
  4621. defaultValue = length;
  4622. }
  4623. indices[0] = begin;
  4624. indices[1] = (end < begin) ? begin : end;
  4625. return indices;
  4626. },
  4627. constrain: function(number, min, max) {
  4628. var x = parseFloat(number);
  4629. if (min === null) {
  4630. min = number;
  4631. }
  4632. if (max === null) {
  4633. max = number;
  4634. }
  4635. return (x < min) ? min : ((x > max) ? max : x);
  4636. },
  4637. snap: function(value, increment, minValue, maxValue) {
  4638. var m;
  4639. if (value === undefined || value < minValue) {
  4640. return minValue || 0;
  4641. }
  4642. if (increment) {
  4643. m = value % increment;
  4644. if (m !== 0) {
  4645. value -= m;
  4646. if (m * 2 >= increment) {
  4647. value += increment;
  4648. } else if (m * 2 < -increment) {
  4649. value -= increment;
  4650. }
  4651. }
  4652. }
  4653. return ExtNumber.constrain(value, minValue, maxValue);
  4654. },
  4655. snapInRange: function(value, increment, minValue, maxValue) {
  4656. var tween;
  4657. minValue = (minValue || 0);
  4658. if (value === undefined || value < minValue) {
  4659. return minValue;
  4660. }
  4661. if (increment && (tween = ((value - minValue) % increment))) {
  4662. value -= tween;
  4663. tween *= 2;
  4664. if (tween >= increment) {
  4665. value += increment;
  4666. }
  4667. }
  4668. if (maxValue !== undefined) {
  4669. if (value > (maxValue = ExtNumber.snapInRange(maxValue, increment, minValue))) {
  4670. value = maxValue;
  4671. }
  4672. }
  4673. return value;
  4674. },
  4675. roundToNearest: function(value, interval) {
  4676. interval = interval || 1;
  4677. return interval * math.round(value / interval);
  4678. },
  4679. roundToPrecision: function(value, precision) {
  4680. var factor = math.pow(10, precision || 1);
  4681. return math.round(value * factor) / factor;
  4682. },
  4683. truncateToPrecision: function(value, precision) {
  4684. var factor = math.pow(10, precision || 1);
  4685. return parseInt(value * factor, 10) / factor;
  4686. },
  4687. sign: math.sign || function(x) {
  4688. x = +x;
  4689. if (x === 0 || isNaN(x)) {
  4690. return x;
  4691. }
  4692. return (x > 0) ? 1 : -1;
  4693. },
  4694. log10: math.log10 || function(x) {
  4695. return math.log(x) * math.LOG10E;
  4696. },
  4697. isEqual: function(n1, n2, epsilon) {
  4698. if (!(typeof n1 === 'number' && typeof n2 === 'number' && typeof epsilon === 'number')) {
  4699. Ext.raise("All parameters should be valid numbers.");
  4700. }
  4701. return math.abs(n1 - n2) < epsilon;
  4702. },
  4703. isFinite: Number.isFinite || function(value) {
  4704. return typeof value === 'number' && isFinite(value);
  4705. },
  4706. isInteger: Number.isInteger || function(value) {
  4707. return ~~(value + 0) === value;
  4708. },
  4709. toFixed: isToFixedBroken ? function(value, precision) {
  4710. var pow;
  4711. precision = precision || 0;
  4712. pow = math.pow(10, precision);
  4713. return (math.round(value * pow) / pow).toFixed(precision);
  4714. } : function(value, precision) {
  4715. return value.toFixed(precision);
  4716. },
  4717. from: function(value, defaultValue) {
  4718. if (isFinite(value)) {
  4719. value = parseFloat(value);
  4720. }
  4721. return !isNaN(value) ? value : defaultValue;
  4722. },
  4723. randomInt: function(from, to) {
  4724. return math.floor(math.random() * (to - from + 1) + from);
  4725. },
  4726. correctFloat: function(n) {
  4727. return parseFloat(n.toPrecision(14));
  4728. }
  4729. });
  4730. Ext.num = function() {
  4731. return ExtNumber.from.apply(this, arguments);
  4732. };
  4733. }());
  4734. (function() {
  4735. var TemplateClass = function() {},
  4736. queryRe = /^\?/,
  4737. keyRe = /(\[):?([^\]]*)\]/g,
  4738. nameRe = /^([^\[]+)/,
  4739. plusRe = /\+/g,
  4740. ExtObject;
  4741. ExtObject = Ext.Object = {
  4742. chain: Object.create || function(object) {
  4743. var result;
  4744. TemplateClass.prototype = object;
  4745. result = new TemplateClass();
  4746. TemplateClass.prototype = null;
  4747. return result;
  4748. },
  4749. clear: function(object) {
  4750. var key;
  4751. for (key in object) {
  4752. delete object[key];
  4753. }
  4754. return object;
  4755. },
  4756. freeze: Object.freeze ? function(obj, deep) {
  4757. var name;
  4758. if (obj && typeof obj === 'object' && !Object.isFrozen(obj)) {
  4759. Object.freeze(obj);
  4760. if (deep) {
  4761. for (name in obj) {
  4762. ExtObject.freeze(obj[name], deep);
  4763. }
  4764. }
  4765. }
  4766. return obj;
  4767. } : Ext.identityFn,
  4768. toQueryObjects: function(name, value, recursive) {
  4769. var self = ExtObject.toQueryObjects,
  4770. objects = [],
  4771. i, ln;
  4772. if (Ext.isArray(value)) {
  4773. for (i = 0 , ln = value.length; i < ln; i++) {
  4774. if (recursive) {
  4775. objects = objects.concat(self(name + '[' + i + ']', value[i], true));
  4776. } else {
  4777. objects.push({
  4778. name: name,
  4779. value: value[i]
  4780. });
  4781. }
  4782. }
  4783. } else if (Ext.isObject(value)) {
  4784. for (i in value) {
  4785. if (value.hasOwnProperty(i)) {
  4786. if (recursive) {
  4787. objects = objects.concat(self(name + '[' + i + ']', value[i], true));
  4788. } else {
  4789. objects.push({
  4790. name: name,
  4791. value: value[i]
  4792. });
  4793. }
  4794. }
  4795. }
  4796. } else {
  4797. objects.push({
  4798. name: name,
  4799. value: value
  4800. });
  4801. }
  4802. return objects;
  4803. },
  4804. toQueryString: function(object, recursive) {
  4805. var paramObjects = [],
  4806. params = [],
  4807. i, j, ln, paramObject, value;
  4808. for (i in object) {
  4809. if (object.hasOwnProperty(i)) {
  4810. paramObjects = paramObjects.concat(ExtObject.toQueryObjects(i, object[i], recursive));
  4811. }
  4812. }
  4813. for (j = 0 , ln = paramObjects.length; j < ln; j++) {
  4814. paramObject = paramObjects[j];
  4815. value = paramObject.value;
  4816. if (Ext.isEmpty(value)) {
  4817. value = '';
  4818. } else if (Ext.isDate(value)) {
  4819. value = Ext.Date.toString(value);
  4820. }
  4821. params.push(encodeURIComponent(paramObject.name) + '=' + encodeURIComponent(String(value)));
  4822. }
  4823. return params.join('&');
  4824. },
  4825. fromQueryString: function(queryString, recursive) {
  4826. var parts = queryString.replace(queryRe, '').split('&'),
  4827. object = {},
  4828. temp, components, name, value, i, ln, part, j, subLn, matchedKeys, matchedName, keys, key, nextKey;
  4829. for (i = 0 , ln = parts.length; i < ln; i++) {
  4830. part = parts[i];
  4831. if (part.length > 0) {
  4832. components = part.split('=');
  4833. name = components[0];
  4834. name = name.replace(plusRe, '%20');
  4835. name = decodeURIComponent(name);
  4836. value = components[1];
  4837. if (value !== undefined) {
  4838. value = value.replace(plusRe, '%20');
  4839. value = decodeURIComponent(value);
  4840. } else {
  4841. value = '';
  4842. }
  4843. if (!recursive) {
  4844. if (object.hasOwnProperty(name)) {
  4845. if (!Ext.isArray(object[name])) {
  4846. object[name] = [
  4847. object[name]
  4848. ];
  4849. }
  4850. object[name].push(value);
  4851. } else {
  4852. object[name] = value;
  4853. }
  4854. } else {
  4855. matchedKeys = name.match(keyRe);
  4856. matchedName = name.match(nameRe);
  4857. if (!matchedName) {
  4858. throw new Error('[Ext.Object.fromQueryString] Malformed query string given, failed parsing name from "' + part + '"');
  4859. }
  4860. name = matchedName[0];
  4861. keys = [];
  4862. if (matchedKeys === null) {
  4863. object[name] = value;
  4864. continue;
  4865. }
  4866. for (j = 0 , subLn = matchedKeys.length; j < subLn; j++) {
  4867. key = matchedKeys[j];
  4868. key = (key.length === 2) ? '' : key.substring(1, key.length - 1);
  4869. keys.push(key);
  4870. }
  4871. keys.unshift(name);
  4872. temp = object;
  4873. for (j = 0 , subLn = keys.length; j < subLn; j++) {
  4874. key = keys[j];
  4875. if (j === subLn - 1) {
  4876. if (Ext.isArray(temp) && key === '') {
  4877. temp.push(value);
  4878. } else {
  4879. temp[key] = value;
  4880. }
  4881. } else {
  4882. if (temp[key] === undefined || typeof temp[key] === 'string') {
  4883. nextKey = keys[j + 1];
  4884. temp[key] = (Ext.isNumeric(nextKey) || nextKey === '') ? [] : {};
  4885. }
  4886. temp = temp[key];
  4887. }
  4888. }
  4889. }
  4890. }
  4891. }
  4892. return object;
  4893. },
  4894. each: function(object, fn, scope) {
  4895. var enumerables = Ext.enumerables,
  4896. i, property;
  4897. if (object) {
  4898. scope = scope || object;
  4899. for (property in object) {
  4900. if (object.hasOwnProperty(property)) {
  4901. if (fn.call(scope, property, object[property], object) === false) {
  4902. return;
  4903. }
  4904. }
  4905. }
  4906. if (enumerables) {
  4907. for (i = enumerables.length; i--; ) {
  4908. if (object.hasOwnProperty(property = enumerables[i])) {
  4909. if (fn.call(scope, property, object[property], object) === false) {
  4910. return;
  4911. }
  4912. }
  4913. }
  4914. }
  4915. }
  4916. },
  4917. eachValue: function(object, fn, scope) {
  4918. var enumerables = Ext.enumerables,
  4919. i, property;
  4920. scope = scope || object;
  4921. for (property in object) {
  4922. if (object.hasOwnProperty(property)) {
  4923. if (fn.call(scope, object[property]) === false) {
  4924. return;
  4925. }
  4926. }
  4927. }
  4928. if (enumerables) {
  4929. for (i = enumerables.length; i--; ) {
  4930. if (object.hasOwnProperty(property = enumerables[i])) {
  4931. if (fn.call(scope, object[property]) === false) {
  4932. return;
  4933. }
  4934. }
  4935. }
  4936. }
  4937. },
  4938. merge: function(destination) {
  4939. var i = 1,
  4940. args = arguments,
  4941. ln = args.length,
  4942. mergeFn = ExtObject.merge,
  4943. cloneFn = Ext.clone,
  4944. object, key, value, sourceKey;
  4945. for (; i < ln; i++) {
  4946. object = args[i];
  4947. for (key in object) {
  4948. value = object[key];
  4949. if (value && value.constructor === Object) {
  4950. sourceKey = destination[key];
  4951. if (sourceKey && sourceKey.constructor === Object) {
  4952. mergeFn(sourceKey, value);
  4953. } else {
  4954. destination[key] = cloneFn(value);
  4955. }
  4956. } else {
  4957. destination[key] = value;
  4958. }
  4959. }
  4960. }
  4961. return destination;
  4962. },
  4963. mergeIf: function(destination) {
  4964. var i = 1,
  4965. ln = arguments.length,
  4966. cloneFn = Ext.clone,
  4967. object, key, value;
  4968. for (; i < ln; i++) {
  4969. object = arguments[i];
  4970. for (key in object) {
  4971. if (!(key in destination)) {
  4972. value = object[key];
  4973. if (value && value.constructor === Object) {
  4974. destination[key] = cloneFn(value);
  4975. } else {
  4976. destination[key] = value;
  4977. }
  4978. }
  4979. }
  4980. }
  4981. return destination;
  4982. },
  4983. getAllKeys: function(object) {
  4984. var keys = [],
  4985. property;
  4986. for (property in object) {
  4987. keys.push(property);
  4988. }
  4989. return keys;
  4990. },
  4991. getKey: function(object, value) {
  4992. var property;
  4993. for (property in object) {
  4994. if (object.hasOwnProperty(property) && object[property] === value) {
  4995. return property;
  4996. }
  4997. }
  4998. return null;
  4999. },
  5000. getValues: function(object) {
  5001. var values = [],
  5002. property;
  5003. for (property in object) {
  5004. if (object.hasOwnProperty(property)) {
  5005. values.push(object[property]);
  5006. }
  5007. }
  5008. return values;
  5009. },
  5010. getKeys: (typeof Object.keys === 'function') ? function(object) {
  5011. if (!object) {
  5012. return [];
  5013. }
  5014. return Object.keys(object);
  5015. } : function(object) {
  5016. var keys = [],
  5017. property;
  5018. for (property in object) {
  5019. if (object.hasOwnProperty(property)) {
  5020. keys.push(property);
  5021. }
  5022. }
  5023. return keys;
  5024. },
  5025. getSize: function(object) {
  5026. var size = 0,
  5027. property;
  5028. for (property in object) {
  5029. if (object.hasOwnProperty(property)) {
  5030. size++;
  5031. }
  5032. }
  5033. return size;
  5034. },
  5035. isEmpty: function(object) {
  5036. var key;
  5037. for (key in object) {
  5038. if (object.hasOwnProperty(key)) {
  5039. return false;
  5040. }
  5041. }
  5042. return true;
  5043. },
  5044. equals: (function() {
  5045. var check = function(o1, o2) {
  5046. var key;
  5047. for (key in o1) {
  5048. if (o1.hasOwnProperty(key)) {
  5049. if (o1[key] !== o2[key]) {
  5050. return false;
  5051. }
  5052. }
  5053. }
  5054. return true;
  5055. };
  5056. return function(object1, object2) {
  5057. if (object1 === object2) {
  5058. return true;
  5059. }
  5060. if (object1 && object2) {
  5061. return check(object1, object2) && check(object2, object1);
  5062. } else if (!object1 && !object2) {
  5063. return object1 === object2;
  5064. } else {
  5065. return false;
  5066. }
  5067. };
  5068. })(),
  5069. fork: function(obj) {
  5070. var ret, key, value;
  5071. if (obj && obj.constructor === Object) {
  5072. ret = ExtObject.chain(obj);
  5073. for (key in obj) {
  5074. value = obj[key];
  5075. if (value) {
  5076. if (value.constructor === Object) {
  5077. ret[key] = ExtObject.fork(value);
  5078. } else if (value instanceof Array) {
  5079. ret[key] = Ext.Array.clone(value);
  5080. }
  5081. }
  5082. }
  5083. } else {
  5084. ret = obj;
  5085. }
  5086. return ret;
  5087. },
  5088. defineProperty: ('defineProperty' in Object) ? Object.defineProperty : function(object, name, descriptor) {
  5089. if (!Object.prototype.__defineGetter__) {
  5090. return;
  5091. }
  5092. if (descriptor.get) {
  5093. object.__defineGetter__(name, descriptor.get);
  5094. }
  5095. if (descriptor.set) {
  5096. object.__defineSetter__(name, descriptor.set);
  5097. }
  5098. },
  5099. classify: function(object) {
  5100. var prototype = object,
  5101. objectProperties = [],
  5102. propertyClassesMap = {},
  5103. objectClass, key, value;
  5104. objectClass = function() {
  5105. var property, i, ln;
  5106. for (i = 0 , ln = objectProperties.length; i < ln; i++) {
  5107. property = objectProperties[i];
  5108. this[property] = new propertyClassesMap[property]();
  5109. }
  5110. };
  5111. for (key in object) {
  5112. if (object.hasOwnProperty(key)) {
  5113. value = object[key];
  5114. if (value && value.constructor === Object) {
  5115. objectProperties.push(key);
  5116. propertyClassesMap[key] = ExtObject.classify(value);
  5117. }
  5118. }
  5119. }
  5120. objectClass.prototype = prototype;
  5121. return objectClass;
  5122. }
  5123. };
  5124. Ext.merge = Ext.Object.merge;
  5125. Ext.mergeIf = Ext.Object.mergeIf;
  5126. }());
  5127. Ext.apply(Ext, {
  5128. _namedScopes: {
  5129. 'this': {
  5130. isThis: 1
  5131. },
  5132. controller: {
  5133. isController: 1
  5134. },
  5135. owner: {
  5136. isOwner: 1
  5137. },
  5138. up: {
  5139. isUp: 1
  5140. },
  5141. self: {
  5142. isSelf: 1
  5143. },
  5144. 'self.controller': {
  5145. isSelf: 1,
  5146. isController: 1
  5147. }
  5148. },
  5149. scrollbar: {
  5150. _size: null,
  5151. size: function(force) {
  5152. var scrollbar = Ext.scrollbar,
  5153. size = scrollbar._size;
  5154. if (!Ext.isDomReady) {
  5155. Ext.raise("Ext.scrollbar.size() called before DomReady");
  5156. }
  5157. if (force || !size) {
  5158. var db = document.body,
  5159. div = document.createElement('div'),
  5160. h, w;
  5161. div.style.width = div.style.height = '100px';
  5162. div.style.overflow = 'scroll';
  5163. div.style.position = 'absolute';
  5164. db.appendChild(div);
  5165. scrollbar._size = size = {
  5166. width: w = div.offsetWidth - div.clientWidth,
  5167. height: h = div.offsetHeight - div.clientHeight
  5168. };
  5169. size.reservedWidth = w ? 'calc(100% - ' + w + 'px)' : '';
  5170. size.reservedHeight = h ? 'calc(100% - ' + h + 'px)' : '';
  5171. db.removeChild(div);
  5172. }
  5173. return size;
  5174. },
  5175. height: function(force) {
  5176. return Ext.scrollbar.size(force).height;
  5177. },
  5178. width: function(force) {
  5179. return Ext.scrollbar.size(force).width;
  5180. }
  5181. },
  5182. escapeId: (function() {
  5183. var validIdRe = /^[a-zA-Z_][a-zA-Z0-9_\-]*$/i,
  5184. escapeRx = /([\W]{1})/g,
  5185. leadingNumRx = /^(\d)/g,
  5186. escapeFn = function(match, capture) {
  5187. return "\\" + capture;
  5188. },
  5189. numEscapeFn = function(match, capture) {
  5190. return '\\00' + capture.charCodeAt(0).toString(16) + ' ';
  5191. };
  5192. return function(id) {
  5193. return validIdRe.test(id) ? id :
  5194. id.replace(escapeRx, escapeFn).replace(leadingNumRx, numEscapeFn);
  5195. };
  5196. }()),
  5197. lookUpFn: function(from, fn) {
  5198. if (!from || !Ext.isFunction(from.up)) {
  5199. Ext.raise('Callback "up" syntax requires a caller with "up" method');
  5200. }
  5201. var controller, scope;
  5202. for (scope = from.up(); scope && !scope[fn]; scope = scope.up()) {
  5203. controller = scope.controller;
  5204. if (controller && controller[fn]) {
  5205. scope = controller;
  5206. break;
  5207. }
  5208. }
  5209. if (!scope || !Ext.isFunction(scope[fn])) {
  5210. Ext.raise('No such method "' + fn + '" found up() from ' + (from.getId ? from.getId() : from.id));
  5211. }
  5212. return scope;
  5213. },
  5214. callback: function(callback, scope, args, delay, caller, defaultScope) {
  5215. if (!callback) {
  5216. return;
  5217. }
  5218. var namedScope = (scope in Ext._namedScopes),
  5219. ret;
  5220. if (callback.charAt) {
  5221. if (callback[2] === '.') {
  5222. if (callback.substr(0, 2) !== 'up') {
  5223. Ext.raise('Invalid callback method name "' + callback + '"');
  5224. }
  5225. if (scope) {
  5226. Ext.raise('Callback "up" syntax is incompatible with scopes');
  5227. }
  5228. scope = Ext.lookUpFn(caller, callback = callback.substr(3));
  5229. } else if (caller) {
  5230. if (namedScope && namedScope.isUp) {
  5231. scope = Ext.lookUpFn(caller, callback);
  5232. } else if (!scope || namedScope) {
  5233. scope = caller.resolveListenerScope(namedScope ? scope : defaultScope);
  5234. }
  5235. }
  5236. if (!scope || !Ext.isObject(scope)) {
  5237. Ext.raise('Named method "' + callback + '" requires a scope object');
  5238. }
  5239. if (!Ext.isFunction(scope[callback])) {
  5240. Ext.raise('No method named "' + callback + '" on ' + (scope.$className || 'scope object'));
  5241. }
  5242. callback = scope[callback];
  5243. } else if (namedScope) {
  5244. scope = defaultScope || caller;
  5245. } else if (!scope) {
  5246. scope = caller;
  5247. }
  5248. if (callback && Ext.isFunction(callback)) {
  5249. scope = scope || Ext.global;
  5250. if (delay) {
  5251. Ext.defer(callback, delay, scope, args);
  5252. } else {
  5253. ret = args ? callback.apply(scope, args) : callback.call(scope);
  5254. }
  5255. }
  5256. return ret;
  5257. },
  5258. coerce: function(from, to) {
  5259. var fromType = Ext.typeOf(from),
  5260. toType = Ext.typeOf(to),
  5261. isString = typeof from === 'string';
  5262. if (fromType !== toType) {
  5263. switch (toType) {
  5264. case 'string':
  5265. return String(from);
  5266. case 'number':
  5267. return Number(from);
  5268. case 'boolean':
  5269. return isString && (!from || from === 'false' || from === '0') ? false : Boolean(from);
  5270. case 'null':
  5271. return isString && (!from || from === 'null') ? null : false;
  5272. case 'undefined':
  5273. return isString && (!from || from === 'undefined') ? undefined : false;
  5274. case 'date':
  5275. return isString && isNaN(from) ? Ext.Date.parse(from, Ext.Date.defaultFormat) : Date(Number(from));
  5276. }
  5277. }
  5278. return from;
  5279. },
  5280. copyTo: function(dest, source, names, usePrototypeKeys) {
  5281. var name, i, n;
  5282. if (typeof names === 'string') {
  5283. names = names.split(Ext.propertyNameSplitRe);
  5284. }
  5285. for (i = 0 , n = names ? names.length : 0; i < n; i++) {
  5286. name = names[i];
  5287. if (usePrototypeKeys || source.hasOwnProperty(name)) {
  5288. dest[name] = source[name];
  5289. }
  5290. }
  5291. return dest;
  5292. },
  5293. copy: function(dest, source, names, usePrototypeKeys) {
  5294. var name, i, n;
  5295. if (typeof names === 'string') {
  5296. names = names.split(Ext.propertyNameSplitRe);
  5297. }
  5298. for (i = 0 , n = names ? names.length : 0; i < n; i++) {
  5299. name = names[i];
  5300. if (source.hasOwnProperty(name) || (usePrototypeKeys && name in source)) {
  5301. dest[name] = source[name];
  5302. }
  5303. }
  5304. return dest;
  5305. },
  5306. propertyNameSplitRe: /[,;\s]+/,
  5307. copyToIf: function(destination, source, names) {
  5308. var name, i, n;
  5309. if (typeof names === 'string') {
  5310. names = names.split(Ext.propertyNameSplitRe);
  5311. }
  5312. for (i = 0 , n = names ? names.length : 0; i < n; i++) {
  5313. name = names[i];
  5314. if (destination[name] === undefined) {
  5315. destination[name] = source[name];
  5316. }
  5317. }
  5318. return destination;
  5319. },
  5320. copyIf: function(destination, source, names) {
  5321. var name, i, n;
  5322. if (typeof names === 'string') {
  5323. names = names.split(Ext.propertyNameSplitRe);
  5324. }
  5325. for (i = 0 , n = names ? names.length : 0; i < n; i++) {
  5326. name = names[i];
  5327. if (!(name in destination) && (name in source)) {
  5328. destination[name] = source[name];
  5329. }
  5330. }
  5331. return destination;
  5332. },
  5333. extend: (function() {
  5334. var objectConstructor = Object.prototype.constructor,
  5335. inlineOverrides = function(o) {
  5336. var m;
  5337. for (m in o) {
  5338. if (!o.hasOwnProperty(m)) {
  5339. continue;
  5340. }
  5341. this[m] = o[m];
  5342. }
  5343. };
  5344. return function(subclass, superclass, overrides) {
  5345. if (Ext.isObject(superclass)) {
  5346. overrides = superclass;
  5347. superclass = subclass;
  5348. subclass = overrides.constructor !== objectConstructor ? overrides.constructor : function() {
  5349. superclass.apply(this, arguments);
  5350. };
  5351. }
  5352. if (!superclass) {
  5353. Ext.raise({
  5354. sourceClass: 'Ext',
  5355. sourceMethod: 'extend',
  5356. msg: 'Attempting to extend from a class which has not been loaded on the page.'
  5357. });
  5358. }
  5359. var F = function() {},
  5360. superclassProto = superclass.prototype,
  5361. subclassProto;
  5362. F.prototype = superclassProto;
  5363. subclassProto = subclass.prototype = new F();
  5364. subclassProto.constructor = subclass;
  5365. subclass.superclass = superclassProto;
  5366. if (superclassProto.constructor === objectConstructor) {
  5367. superclassProto.constructor = superclass;
  5368. }
  5369. subclass.override = function(overrides) {
  5370. Ext.override(subclass, overrides);
  5371. };
  5372. subclassProto.override = inlineOverrides;
  5373. subclassProto.proto = subclassProto;
  5374. subclass.override(overrides);
  5375. subclass.extend = function(o) {
  5376. return Ext.extend(subclass, o);
  5377. };
  5378. return subclass;
  5379. };
  5380. }()),
  5381. isOnline: function() {
  5382. return Ext.global.navigator.onLine;
  5383. },
  5384. iterate: function(object, fn, scope) {
  5385. if (Ext.isEmpty(object)) {
  5386. return;
  5387. }
  5388. if (scope === undefined) {
  5389. scope = object;
  5390. }
  5391. if (Ext.isIterable(object)) {
  5392. Ext.Array.each.call(Ext.Array, object, fn, scope);
  5393. } else {
  5394. Ext.Object.each.call(Ext.Object, object, fn, scope);
  5395. }
  5396. },
  5397. _resourcePoolRe: /^[<]([^<>@:]*)(?:[@]([^<>@:]+))?[>](.+)$/,
  5398. resolveResource: function(url) {
  5399. var ret = url,
  5400. m;
  5401. if (url && url.charAt(0) === '<') {
  5402. m = Ext._resourcePoolRe.exec(url);
  5403. if (m) {
  5404. ret = Ext.getResourcePath(m[3], m[1], m[2]);
  5405. }
  5406. }
  5407. return ret;
  5408. },
  5409. urlEncode: function() {
  5410. var args = Ext.Array.from(arguments),
  5411. prefix = '';
  5412. if (Ext.isString(args[1])) {
  5413. prefix = args[1] + '&';
  5414. args[1] = false;
  5415. }
  5416. return prefix + Ext.Object.toQueryString.apply(Ext.Object, args);
  5417. },
  5418. urlDecode: function() {
  5419. return Ext.Object.fromQueryString.apply(Ext.Object, arguments);
  5420. },
  5421. getScrollbarSize: function(force) {
  5422. return Ext.scrollbar.size(force);
  5423. },
  5424. typeOf: (function() {
  5425. var nonWhitespaceRe = /\S/,
  5426. toString = Object.prototype.toString,
  5427. typeofTypes = {
  5428. number: 1,
  5429. string: 1,
  5430. 'boolean': 1,
  5431. 'undefined': 1
  5432. },
  5433. toStringTypes = {
  5434. '[object Array]': 'array',
  5435. '[object Date]': 'date',
  5436. '[object Boolean]': 'boolean',
  5437. '[object Number]': 'number',
  5438. '[object RegExp]': 'regexp'
  5439. };
  5440. return function(value) {
  5441. if (value === null) {
  5442. return 'null';
  5443. }
  5444. var type = typeof value,
  5445. ret, typeToString;
  5446. if (typeofTypes[type]) {
  5447. return type;
  5448. }
  5449. ret = toStringTypes[typeToString = toString.call(value)];
  5450. if (ret) {
  5451. return ret;
  5452. }
  5453. if (type === 'function') {
  5454. return 'function';
  5455. }
  5456. if (type === 'object') {
  5457. if (value.nodeType !== undefined) {
  5458. if (value.nodeType === 3) {
  5459. return nonWhitespaceRe.test(value.nodeValue) ? 'textnode' : 'whitespace';
  5460. } else {
  5461. return 'element';
  5462. }
  5463. }
  5464. return 'object';
  5465. }
  5466. Ext.raise({
  5467. sourceClass: 'Ext',
  5468. sourceMethod: 'typeOf',
  5469. msg: 'Failed to determine the type of "' + value + '".'
  5470. });
  5471. return typeToString;
  5472. };
  5473. }()),
  5474. factory: function(config, classReference, instance, aliasNamespace) {
  5475. var manager = Ext.ClassManager,
  5476. newInstance;
  5477. if (!config || config.isInstance) {
  5478. if (instance && instance !== config) {
  5479. instance.destroy();
  5480. }
  5481. return config;
  5482. }
  5483. if (aliasNamespace) {
  5484. if (typeof config === 'string') {
  5485. return manager.instantiateByAlias(aliasNamespace + '.' + config);
  5486. }
  5487. else if (Ext.isObject(config) && 'type' in config) {
  5488. return manager.instantiateByAlias(aliasNamespace + '.' + config.type, config);
  5489. }
  5490. }
  5491. if (config === true) {
  5492. if (!instance && !classReference) {
  5493. Ext.raise('[Ext.factory] Cannot determine type of class to create');
  5494. }
  5495. return instance || Ext.create(classReference);
  5496. }
  5497. if (!Ext.isObject(config)) {
  5498. Ext.raise("Invalid config, must be a valid config object");
  5499. }
  5500. if ('xtype' in config) {
  5501. newInstance = manager.instantiateByAlias('widget.' + config.xtype, config);
  5502. } else if ('xclass' in config) {
  5503. newInstance = Ext.create(config.xclass, config);
  5504. }
  5505. if (newInstance) {
  5506. if (instance) {
  5507. instance.destroy();
  5508. }
  5509. return newInstance;
  5510. }
  5511. if (instance) {
  5512. return instance.setConfig(config);
  5513. }
  5514. return Ext.create(classReference, config);
  5515. },
  5516. convertKeyedItems: function(items, defaultProperty, functionProperty) {
  5517. if (items && !items.isInstance && Ext.isObject(items)) {
  5518. var obj = items,
  5519. item, itemId, value;
  5520. items = [];
  5521. if (obj.xtype || obj.xclass || obj.itemId || obj.id) {
  5522. items.push(obj);
  5523. } else {
  5524. for (itemId in obj) {
  5525. item = obj[itemId];
  5526. if (item) {
  5527. if (item === true) {
  5528. item = {};
  5529. } else if (typeof item === 'function') {
  5530. if (!functionProperty) {
  5531. Ext.raise('Function not expected here');
  5532. }
  5533. value = item;
  5534. item = {};
  5535. item[functionProperty] = value;
  5536. } else if (typeof item === 'string') {
  5537. value = item;
  5538. item = {};
  5539. item[defaultProperty || 'xtype'] = value;
  5540. } else {
  5541. item = Ext.apply({}, item);
  5542. }
  5543. item.itemId = itemId;
  5544. items.push(item);
  5545. }
  5546. }
  5547. }
  5548. }
  5549. return items;
  5550. },
  5551. sortByWeight: function(items) {
  5552. if (items) {
  5553. Ext.Array.sort(items, Ext.weightSortFn);
  5554. }
  5555. },
  5556. weightSortFn: function(lhs, rhs) {
  5557. return (lhs.weight || 0) - (rhs.weight || 0);
  5558. },
  5559. concat: function(a, b) {
  5560. var noB = b == null,
  5561. E = Ext.emptyArray;
  5562. return (a == null) ? (noB ? a : E.concat(b)) : (noB ? E.concat(a) : E.concat(a, b));
  5563. },
  5564. log:
  5565. (function() {
  5566. var primitiveRe = /string|number|boolean/;
  5567. function dumpObject(object, level, maxLevel, withFunctions) {
  5568. var member, type, value, name, prefix, suffix,
  5569. members = [];
  5570. if (Ext.isArray(object)) {
  5571. prefix = '[';
  5572. suffix = ']';
  5573. } else if (Ext.isObject(object)) {
  5574. prefix = '{';
  5575. suffix = '}';
  5576. }
  5577. if (!maxLevel) {
  5578. maxLevel = 3;
  5579. }
  5580. if (level > maxLevel) {
  5581. return prefix + '...' + suffix;
  5582. }
  5583. level = level || 1;
  5584. var spacer = (new Array(level)).join(' ');
  5585. for (name in object) {
  5586. if (object.hasOwnProperty(name)) {
  5587. value = object[name];
  5588. type = typeof value;
  5589. if (type === 'function') {
  5590. if (!withFunctions) {
  5591. continue;
  5592. }
  5593. member = type;
  5594. } else if (type === 'undefined') {
  5595. member = type;
  5596. } else if (value === null || primitiveRe.test(type) || Ext.isDate(value)) {
  5597. member = Ext.encode(value);
  5598. } else if (Ext.isArray(value)) {
  5599. member = dumpObject(value, level + 1, maxLevel, withFunctions);
  5600. } else if (Ext.isObject(value)) {
  5601. member = dumpObject(value, level + 1, maxLevel, withFunctions);
  5602. } else {
  5603. member = type;
  5604. }
  5605. members.push(spacer + name + ': ' + member);
  5606. }
  5607. }
  5608. if (members.length) {
  5609. return prefix + '\n ' + members.join(',\n ') + '\n' + spacer + suffix;
  5610. }
  5611. return prefix + suffix;
  5612. }
  5613. function log(message) {
  5614. var options, dump,
  5615. con = Ext.global.console,
  5616. level = 'log',
  5617. indent = log.indent || 0,
  5618. prefix, stack, fn, out, max;
  5619. log.indent = indent;
  5620. if (typeof message !== 'string') {
  5621. options = message;
  5622. message = options.msg || '';
  5623. level = options.level || level;
  5624. dump = options.dump;
  5625. stack = options.stack;
  5626. prefix = options.prefix;
  5627. fn = options.fn;
  5628. if (options.indent) {
  5629. ++log.indent;
  5630. } else if (options.outdent) {
  5631. log.indent = indent = Math.max(indent - 1, 0);
  5632. }
  5633. if (dump && !(con && con.dir)) {
  5634. message += dumpObject(dump);
  5635. dump = null;
  5636. }
  5637. }
  5638. if (arguments.length > 1) {
  5639. message += Array.prototype.slice.call(arguments, 1).join('');
  5640. }
  5641. if (prefix) {
  5642. message = prefix + ' - ' + message;
  5643. }
  5644. message = indent ? Ext.String.repeat(' ', log.indentSize * indent) + message : message;
  5645. if (level !== 'log') {
  5646. message = '[' + level.charAt(0).toUpperCase() + '] ' + message;
  5647. }
  5648. if (fn) {
  5649. message += '\nCaller: ' + fn.toString();
  5650. }
  5651. if (con) {
  5652. if (con[level]) {
  5653. con[level](message);
  5654. } else {
  5655. con.log(message);
  5656. }
  5657. if (dump) {
  5658. con.dir(dump);
  5659. }
  5660. if (stack && con.trace) {
  5661. if (!con.firebug || level !== 'error') {
  5662. con.trace();
  5663. }
  5664. }
  5665. } else if (Ext.isOpera) {
  5666. opera.postError(message);
  5667. } else {
  5668. out = log.out;
  5669. max = log.max;
  5670. if (out.length >= max) {
  5671. Ext.Array.erase(out, 0, out.length - 3 * Math.floor(max / 4));
  5672. }
  5673. out.push(message);
  5674. }
  5675. ++log.count;
  5676. ++log.counters[level];
  5677. }
  5678. function logx(level, args) {
  5679. if (typeof args[0] === 'string') {
  5680. args.unshift({});
  5681. }
  5682. args[0].level = level;
  5683. log.apply(this, args);
  5684. }
  5685. log.error = function() {
  5686. logx('error', Array.prototype.slice.call(arguments));
  5687. };
  5688. log.info = function() {
  5689. logx('info', Array.prototype.slice.call(arguments));
  5690. };
  5691. log.warn = function() {
  5692. logx('warn', Array.prototype.slice.call(arguments));
  5693. };
  5694. log.count = 0;
  5695. log.counters = {
  5696. error: 0,
  5697. warn: 0,
  5698. info: 0,
  5699. log: 0
  5700. };
  5701. log.indentSize = 2;
  5702. log.out = [];
  5703. log.max = 750;
  5704. return log;
  5705. }()) || (
  5706. function() {
  5707. var nullLog = function() {};
  5708. nullLog.info = nullLog.warn = nullLog.error = Ext.emptyFn;
  5709. return nullLog;
  5710. }())
  5711. });
  5712. (function() {
  5713. var
  5714. checkVerTemp = [
  5715. ''
  5716. ],
  5717. endOfVersionRe = /([^\d.])/,
  5718. notDigitsRe = /[^\d]/g,
  5719. plusMinusRe = /[-+]/g,
  5720. stripRe = /\s/g,
  5721. underscoreRe = /_/g,
  5722. toolkitNames = {
  5723. classic: 1,
  5724. modern: 1
  5725. },
  5726. Version;
  5727. Ext.Version = Version = function(version, defaultMode) {
  5728. var me = this,
  5729. padModes = me.padModes,
  5730. ch, i, pad, parts, release, releaseStartIndex, ver;
  5731. if (version.isVersion) {
  5732. version = version.version;
  5733. }
  5734. me.version = ver = String(version).toLowerCase().replace(underscoreRe, '.').replace(plusMinusRe, '');
  5735. ch = ver.charAt(0);
  5736. if (ch in padModes) {
  5737. ver = ver.substring(1);
  5738. pad = padModes[ch];
  5739. } else {
  5740. pad = defaultMode ? padModes[defaultMode] : 0;
  5741. }
  5742. me.pad = pad;
  5743. releaseStartIndex = ver.search(endOfVersionRe);
  5744. me.shortVersion = ver;
  5745. if (releaseStartIndex !== -1) {
  5746. me.release = release = ver.substr(releaseStartIndex, version.length);
  5747. me.shortVersion = ver.substr(0, releaseStartIndex);
  5748. release = Version.releaseValueMap[release] || release;
  5749. }
  5750. me.releaseValue = release || pad;
  5751. me.shortVersion = me.shortVersion.replace(notDigitsRe, '');
  5752. me.parts = parts = ver.split('.');
  5753. for (i = parts.length; i--; ) {
  5754. parts[i] = parseInt(parts[i], 10);
  5755. }
  5756. if (pad === Infinity) {
  5757. parts.push(pad);
  5758. }
  5759. me.major = parts[0] || pad;
  5760. me.minor = parts[1] || pad;
  5761. me.patch = parts[2] || pad;
  5762. me.build = parts[3] || pad;
  5763. return me;
  5764. };
  5765. Version.prototype = {
  5766. isVersion: true,
  5767. padModes: {
  5768. '~': NaN,
  5769. '^': Infinity
  5770. },
  5771. release: '',
  5772. compareTo: function(other) {
  5773. var me = this,
  5774. lhsPad = me.pad,
  5775. lhsParts = me.parts,
  5776. lhsLength = lhsParts.length,
  5777. rhsVersion = other.isVersion ? other : new Version(other),
  5778. rhsPad = rhsVersion.pad,
  5779. rhsParts = rhsVersion.parts,
  5780. rhsLength = rhsParts.length,
  5781. length = Math.max(lhsLength, rhsLength),
  5782. i, lhs, rhs;
  5783. for (i = 0; i < length; i++) {
  5784. lhs = (i < lhsLength) ? lhsParts[i] : lhsPad;
  5785. rhs = (i < rhsLength) ? rhsParts[i] : rhsPad;
  5786. if (lhs < rhs) {
  5787. return -1;
  5788. }
  5789. if (lhs > rhs) {
  5790. return 1;
  5791. }
  5792. }
  5793. lhs = me.releaseValue;
  5794. rhs = rhsVersion.releaseValue;
  5795. if (lhs < rhs) {
  5796. return -1;
  5797. }
  5798. if (lhs > rhs) {
  5799. return 1;
  5800. }
  5801. return 0;
  5802. },
  5803. toString: function() {
  5804. return this.version;
  5805. },
  5806. valueOf: function() {
  5807. return this.version;
  5808. },
  5809. getMajor: function() {
  5810. return this.major;
  5811. },
  5812. getMinor: function() {
  5813. return this.minor;
  5814. },
  5815. getPatch: function() {
  5816. return this.patch;
  5817. },
  5818. getBuild: function() {
  5819. return this.build;
  5820. },
  5821. getRelease: function() {
  5822. return this.release;
  5823. },
  5824. getReleaseValue: function() {
  5825. return this.releaseValue;
  5826. },
  5827. isGreaterThan: function(target) {
  5828. return this.compareTo(target) > 0;
  5829. },
  5830. isGreaterThanOrEqual: function(target) {
  5831. return this.compareTo(target) >= 0;
  5832. },
  5833. isLessThan: function(target) {
  5834. return this.compareTo(target) < 0;
  5835. },
  5836. isLessThanOrEqual: function(target) {
  5837. return this.compareTo(target) <= 0;
  5838. },
  5839. equals: function(target) {
  5840. return this.compareTo(target) === 0;
  5841. },
  5842. match: function(target) {
  5843. target = String(target);
  5844. return this.version.substr(0, target.length) === target;
  5845. },
  5846. toArray: function() {
  5847. var me = this;
  5848. return [
  5849. me.getMajor(),
  5850. me.getMinor(),
  5851. me.getPatch(),
  5852. me.getBuild(),
  5853. me.getRelease()
  5854. ];
  5855. },
  5856. getShortVersion: function() {
  5857. return this.shortVersion;
  5858. },
  5859. gt: function(target) {
  5860. return this.compareTo(target) > 0;
  5861. },
  5862. lt: function(target) {
  5863. return this.compareTo(target) < 0;
  5864. },
  5865. gtEq: function(target) {
  5866. return this.compareTo(target) >= 0;
  5867. },
  5868. ltEq: function(target) {
  5869. return this.compareTo(target) <= 0;
  5870. }
  5871. };
  5872. Ext.apply(Version, {
  5873. aliases: {
  5874. from: {
  5875. extjs: 'ext',
  5876. core: 'core',
  5877. touch: 'modern'
  5878. },
  5879. to: {
  5880. ext: [
  5881. 'extjs'
  5882. ],
  5883. 'core': [
  5884. 'core'
  5885. ],
  5886. modern: [
  5887. 'touch'
  5888. ]
  5889. }
  5890. },
  5891. releaseValueMap: {
  5892. dev: -6,
  5893. alpha: -5,
  5894. a: -5,
  5895. beta: -4,
  5896. b: -4,
  5897. rc: -3,
  5898. '#': -2,
  5899. p: -1,
  5900. pl: -1
  5901. },
  5902. getComponentValue: function(value) {
  5903. return !value ? 0 : (isNaN(value) ? this.releaseValueMap[value] || value : parseInt(value, 10));
  5904. },
  5905. compare: function(current, target) {
  5906. var ver = current.isVersion ? current : new Version(current);
  5907. return ver.compareTo(target);
  5908. },
  5909. set: function(collection, packageName, version) {
  5910. var aliases = Version.aliases.to[packageName],
  5911. ver = version.isVersion ? version : new Version(version),
  5912. i;
  5913. collection[packageName] = ver;
  5914. if (aliases) {
  5915. for (i = aliases.length; i-- > 0; ) {
  5916. collection[aliases[i]] = ver;
  5917. }
  5918. }
  5919. return ver;
  5920. }
  5921. });
  5922. Ext.apply(Ext, {
  5923. compatVersions: {},
  5924. versions: {},
  5925. lastRegisteredVersion: null,
  5926. getCompatVersion: function(packageName) {
  5927. var versions = Ext.compatVersions,
  5928. compat;
  5929. if (!packageName) {
  5930. compat = versions.ext || versions.touch || versions.core;
  5931. } else {
  5932. compat = versions[Version.aliases.from[packageName] || packageName];
  5933. }
  5934. return compat || Ext.getVersion(packageName);
  5935. },
  5936. setCompatVersion: function(packageName, version) {
  5937. Version.set(Ext.compatVersions, packageName, version);
  5938. },
  5939. setVersion: function(packageName, version) {
  5940. if (packageName in toolkitNames) {
  5941. Ext.toolkit = packageName;
  5942. }
  5943. Ext.lastRegisteredVersion = Version.set(Ext.versions, packageName, version);
  5944. return this;
  5945. },
  5946. getVersion: function(packageName) {
  5947. var versions = Ext.versions;
  5948. if (!packageName) {
  5949. return versions.ext || versions.touch || versions.core;
  5950. }
  5951. return versions[Version.aliases.from[packageName] || packageName];
  5952. },
  5953. checkVersion: function(specs, matchAll) {
  5954. var isArray = Ext.isArray(specs),
  5955. aliases = Version.aliases.from,
  5956. compat = isArray ? specs : checkVerTemp,
  5957. length = compat.length,
  5958. versions = Ext.versions,
  5959. frameworkVer = versions.ext || versions.touch,
  5960. i, index, matches, minVer, maxVer, packageName, spec, range, ver;
  5961. if (!isArray) {
  5962. checkVerTemp[0] = specs;
  5963. }
  5964. for (i = 0; i < length; ++i) {
  5965. if (!Ext.isString(spec = compat[i])) {
  5966. matches = Ext.checkVersion(spec.and || spec.or, !spec.or);
  5967. if (spec.not) {
  5968. matches = !matches;
  5969. }
  5970. } else {
  5971. if (spec.indexOf(' ') >= 0) {
  5972. spec = spec.replace(stripRe, '');
  5973. }
  5974. index = spec.indexOf('@');
  5975. if (index < 0) {
  5976. range = spec;
  5977. ver = frameworkVer;
  5978. } else {
  5979. packageName = spec.substring(0, index);
  5980. if (!(ver = versions[aliases[packageName] || packageName])) {
  5981. if (matchAll) {
  5982. return false;
  5983. }
  5984. continue;
  5985. }
  5986. range = spec.substring(index + 1);
  5987. }
  5988. index = range.indexOf('-');
  5989. if (index < 0) {
  5990. if (range.charAt(index = range.length - 1) === '+') {
  5991. minVer = range.substring(0, index);
  5992. maxVer = null;
  5993. } else {
  5994. minVer = maxVer = range;
  5995. }
  5996. } else if (index > 0) {
  5997. minVer = range.substring(0, index);
  5998. maxVer = range.substring(index + 1);
  5999. } else
  6000. {
  6001. minVer = null;
  6002. maxVer = range.substring(index + 1);
  6003. }
  6004. matches = true;
  6005. if (minVer) {
  6006. minVer = new Version(minVer, '~');
  6007. matches = minVer.ltEq(ver);
  6008. }
  6009. if (matches && maxVer) {
  6010. maxVer = new Version(maxVer, '~');
  6011. matches = maxVer.gtEq(ver);
  6012. }
  6013. }
  6014. if (matches) {
  6015. if (!matchAll) {
  6016. return true;
  6017. }
  6018. } else if (matchAll) {
  6019. return false;
  6020. }
  6021. }
  6022. return !!matchAll;
  6023. },
  6024. deprecate: function(packageName, since, closure, scope) {
  6025. if (Version.compare(Ext.getVersion(packageName), since) < 1) {
  6026. closure.call(scope);
  6027. }
  6028. }
  6029. });
  6030. }());
  6031. (function(manifest) {
  6032. var packages = (manifest && manifest.packages) || {},
  6033. compat = manifest && manifest.compatibility,
  6034. name, pkg;
  6035. for (name in packages) {
  6036. pkg = packages[name];
  6037. if (pkg && pkg.version) {
  6038. Ext.setVersion(name, pkg.version);
  6039. }
  6040. }
  6041. if (compat) {
  6042. if (Ext.isString(compat)) {
  6043. Ext.setCompatVersion('core', compat);
  6044. } else {
  6045. for (name in compat) {
  6046. Ext.setCompatVersion(name, compat[name]);
  6047. }
  6048. }
  6049. }
  6050. if (!packages.ext && !packages.touch) {
  6051. Ext.setVersion('ext', '7.0.0.168');
  6052. Ext.setVersion('core', '7.0.0.168');
  6053. }
  6054. })(Ext.manifest);
  6055. Ext.Config = function(name) {
  6056. var me = this,
  6057. capitalizedName = name.charAt(0).toUpperCase() + name.substr(1);
  6058. me.name = name;
  6059. me.names = {
  6060. internal: '_' + name,
  6061. initializing: 'is' + capitalizedName + 'Initializing',
  6062. apply: 'apply' + capitalizedName,
  6063. update: 'update' + capitalizedName,
  6064. get: 'get' + capitalizedName,
  6065. set: 'set' + capitalizedName,
  6066. initGet: 'initGet' + capitalizedName,
  6067. changeEvent: name.toLowerCase() + 'change'
  6068. };
  6069. me.root = me;
  6070. };
  6071. Ext.Config.map = {};
  6072. Ext.Config.get = function(name) {
  6073. var map = Ext.Config.map,
  6074. ret = map[name] || (map[name] = new Ext.Config(name));
  6075. return ret;
  6076. };
  6077. Ext.Config.prototype = {
  6078. self: Ext.Config,
  6079. isConfig: true,
  6080. combine: function(value, baseValue, instance, clone) {
  6081. var cfg = this;
  6082. if (cfg.merge) {
  6083. value = cfg.merge(clone ? Ext.clone(value) : value, baseValue, instance);
  6084. } else if (value && value.constructor === Object && baseValue && baseValue.constructor === Object) {
  6085. value = Ext.merge({}, baseValue, value);
  6086. } else if (clone && value) {
  6087. value = Ext.clone(value);
  6088. }
  6089. return value;
  6090. },
  6091. equals: function(value1, value2) {
  6092. return value1 === value2;
  6093. },
  6094. getGetter: function() {
  6095. return this.getter || (this.root.getter = this.makeGetter());
  6096. },
  6097. getInitGetter: function() {
  6098. return this.initGetter || (this.root.initGetter = this.makeInitGetter());
  6099. },
  6100. getSetter: function() {
  6101. return this.setter || (this.root.setter = this.makeSetter());
  6102. },
  6103. getEventedSetter: function() {
  6104. return this.eventedSetter || (this.root.eventedSetter = this.makeEventedSetter());
  6105. },
  6106. getInternalName: function(target) {
  6107. return target.$configPrefixed ? this.names.internal : this.name;
  6108. },
  6109. mergeNew: function(newValue, oldValue, target, mixinClass) {
  6110. var ret, key;
  6111. if (!oldValue) {
  6112. ret = newValue;
  6113. } else if (!newValue) {
  6114. ret = oldValue;
  6115. } else {
  6116. ret = Ext.Object.chain(oldValue);
  6117. for (key in newValue) {
  6118. if (!mixinClass || !(key in ret)) {
  6119. ret[key] = newValue[key];
  6120. }
  6121. }
  6122. }
  6123. return ret;
  6124. },
  6125. mergeSets: function(newValue, oldValue, preserveExisting) {
  6126. var ret = oldValue ? Ext.Object.chain(oldValue) : {},
  6127. i, val;
  6128. if (newValue instanceof Array) {
  6129. for (i = newValue.length; i--; ) {
  6130. val = newValue[i];
  6131. if (!preserveExisting || !(val in ret)) {
  6132. ret[val] = true;
  6133. }
  6134. }
  6135. } else if (newValue) {
  6136. if (newValue.constructor === Object) {
  6137. for (i in newValue) {
  6138. val = newValue[i];
  6139. if (!preserveExisting || !(i in ret)) {
  6140. ret[i] = val;
  6141. }
  6142. }
  6143. } else if (!preserveExisting || !(newValue in ret)) {
  6144. ret[newValue] = true;
  6145. }
  6146. }
  6147. return ret;
  6148. },
  6149. makeGetter: function() {
  6150. var name = this.name,
  6151. prefixedName = this.names.internal;
  6152. return function() {
  6153. var internalName = this.$configPrefixed ? prefixedName : name;
  6154. return this[internalName];
  6155. };
  6156. },
  6157. makeInitGetter: function() {
  6158. var name = this.name,
  6159. names = this.names,
  6160. setName = names.set,
  6161. getName = names.get,
  6162. initializingName = names.initializing;
  6163. return function() {
  6164. var me = this;
  6165. me[initializingName] = true;
  6166. delete me[getName];
  6167. me[setName](me.config[name]);
  6168. delete me[initializingName];
  6169. return me[getName].apply(me, arguments);
  6170. };
  6171. },
  6172. makeSetter: function() {
  6173. var name = this.name,
  6174. names = this.names,
  6175. prefixedName = names.internal,
  6176. getName = names.get,
  6177. applyName = names.apply,
  6178. updateName = names.update,
  6179. setter;
  6180. setter = function(value) {
  6181. var me = this,
  6182. internalName = me.$configPrefixed ? prefixedName : name,
  6183. oldValue = me[internalName],
  6184. watch;
  6185. delete me[getName];
  6186. if (!me[applyName] || (value = me[applyName](value, oldValue)) !== undefined) {
  6187. if (value !== (oldValue = me[internalName])) {
  6188. me[internalName] = value;
  6189. if (me[updateName]) {
  6190. me[updateName](value, oldValue);
  6191. }
  6192. watch = me.$configWatch;
  6193. if (watch && !me.isConfiguring) {
  6194. watch.fire(name, [
  6195. me,
  6196. name,
  6197. me[internalName],
  6198. oldValue
  6199. ]);
  6200. }
  6201. }
  6202. }
  6203. return me;
  6204. };
  6205. setter.$isDefault = true;
  6206. return setter;
  6207. },
  6208. makeEventedSetter: function() {
  6209. var name = this.name,
  6210. names = this.names,
  6211. prefixedName = names.internal,
  6212. getName = names.get,
  6213. applyName = names.apply,
  6214. updateName = names.update,
  6215. changeEventName = names.changeEvent,
  6216. updateFn = function(me, value, oldValue, internalName) {
  6217. me[internalName] = value;
  6218. if (me[updateName]) {
  6219. me[updateName](value, oldValue);
  6220. }
  6221. var watch = me.$configWatch;
  6222. if (watch) {
  6223. watch.fire(name, [
  6224. me,
  6225. name,
  6226. value,
  6227. oldValue
  6228. ]);
  6229. }
  6230. },
  6231. setter;
  6232. setter = function(value) {
  6233. var me = this,
  6234. internalName = me.$configPrefixed ? prefixedName : name,
  6235. oldValue = me[internalName];
  6236. delete me[getName];
  6237. if (!me[applyName] || (value = me[applyName](value, oldValue)) !== undefined) {
  6238. if (value !== (oldValue = me[internalName])) {
  6239. if (me.isConfiguring) {
  6240. me[internalName] = value;
  6241. if (me[updateName]) {
  6242. me[updateName](value, oldValue);
  6243. }
  6244. } else {
  6245. me.fireEventedAction(changeEventName, [
  6246. me,
  6247. value,
  6248. oldValue
  6249. ], updateFn, me, [
  6250. me,
  6251. value,
  6252. oldValue,
  6253. internalName
  6254. ]);
  6255. }
  6256. }
  6257. }
  6258. return me;
  6259. };
  6260. setter.$isDefault = true;
  6261. return setter;
  6262. }
  6263. };
  6264. (function() {
  6265. var ExtConfig = Ext.Config,
  6266. configPropMap = ExtConfig.map,
  6267. ExtObject = Ext.Object;
  6268. Ext.Configurator = function(cls) {
  6269. var me = this,
  6270. prototype = cls.prototype,
  6271. superCfg = cls.superclass ? cls.superclass.self.$config : null;
  6272. me.cls = cls;
  6273. me.superCfg = superCfg;
  6274. if (superCfg) {
  6275. me.configs = ExtObject.chain(superCfg.configs);
  6276. me.cachedConfigs = ExtObject.chain(superCfg.cachedConfigs);
  6277. me.initMap = ExtObject.chain(superCfg.initMap);
  6278. me.values = ExtObject.chain(superCfg.values);
  6279. me.needsFork = superCfg.needsFork;
  6280. me.deprecations = ExtObject.chain(superCfg.deprecations);
  6281. } else
  6282. {
  6283. me.configs = {};
  6284. me.cachedConfigs = {};
  6285. me.initMap = {};
  6286. me.values = {};
  6287. me.deprecations = {};
  6288. }
  6289. prototype.config = prototype.defaultConfig = me.values;
  6290. cls.$config = me;
  6291. };
  6292. Ext.Configurator.prototype = {
  6293. self: Ext.Configurator,
  6294. needsFork: false,
  6295. initList: null,
  6296. add: function(config, mixinClass) {
  6297. var me = this,
  6298. Cls = me.cls,
  6299. configs = me.configs,
  6300. cachedConfigs = me.cachedConfigs,
  6301. initMap = me.initMap,
  6302. prototype = Cls.prototype,
  6303. mixinConfigs = mixinClass && mixinClass.$config.configs,
  6304. values = me.values,
  6305. isObject, meta, isCached, merge, cfg, currentValue, name, names, s, value;
  6306. for (name in config) {
  6307. value = config[name];
  6308. isObject = value && value.constructor === Object;
  6309. meta = isObject && '$value' in value ? value : null;
  6310. isCached = false;
  6311. if (meta) {
  6312. isCached = !!meta.cached;
  6313. value = meta.$value;
  6314. isObject = value && value.constructor === Object;
  6315. }
  6316. merge = meta && meta.merge;
  6317. cfg = configs[name];
  6318. if (cfg) {
  6319. if (mixinClass) {
  6320. merge = cfg.merge;
  6321. if (!merge) {
  6322. continue;
  6323. }
  6324. meta = null;
  6325. } else {
  6326. merge = merge || cfg.merge;
  6327. }
  6328. if (!mixinClass && isCached && !cachedConfigs[name]) {
  6329. Ext.raise('Redefining config as cached: ' + name + ' in class: ' + Cls.$className);
  6330. }
  6331. currentValue = values[name];
  6332. if (merge) {
  6333. value = merge.call(cfg, value, currentValue, Cls, mixinClass);
  6334. } else if (isObject) {
  6335. if (currentValue && currentValue.constructor === Object) {
  6336. value = Ext.merge({}, currentValue, value);
  6337. }
  6338. }
  6339. } else
  6340. {
  6341. if (mixinConfigs) {
  6342. cfg = mixinConfigs[name];
  6343. meta = null;
  6344. } else {
  6345. cfg = ExtConfig.get(name);
  6346. }
  6347. configs[name] = cfg;
  6348. if (cfg.cached || isCached) {
  6349. cachedConfigs[name] = true;
  6350. }
  6351. names = cfg.names;
  6352. if (!prototype[s = names.get]) {
  6353. prototype[s] = cfg.getter || cfg.getGetter();
  6354. }
  6355. if (!prototype[s = names.set]) {
  6356. prototype[s] = (meta && meta.evented) ? (cfg.eventedSetter || cfg.getEventedSetter()) : (cfg.setter || cfg.getSetter());
  6357. }
  6358. }
  6359. if (meta) {
  6360. if (cfg.owner !== Cls) {
  6361. configs[name] = cfg = Ext.Object.chain(cfg);
  6362. cfg.owner = Cls;
  6363. }
  6364. Ext.apply(cfg, meta);
  6365. delete cfg.$value;
  6366. }
  6367. if (!me.needsFork && value && (value.constructor === Object || value instanceof Array)) {
  6368. me.needsFork = true;
  6369. }
  6370. if (value !== null) {
  6371. initMap[name] = true;
  6372. } else {
  6373. if (prototype.$configPrefixed) {
  6374. prototype[configs[name].names.internal] = null;
  6375. } else {
  6376. prototype[configs[name].name] = null;
  6377. }
  6378. if (name in initMap) {
  6379. initMap[name] = false;
  6380. }
  6381. }
  6382. values[name] = value;
  6383. }
  6384. },
  6385. addDeprecations: function(configs) {
  6386. var me = this,
  6387. deprecations = me.deprecations,
  6388. className = (me.cls.$className || '') + '#',
  6389. message, newName, oldName;
  6390. for (oldName in configs) {
  6391. newName = configs[oldName];
  6392. if (!newName) {
  6393. message = 'This config has been removed.';
  6394. } else if (!(message = newName.message)) {
  6395. message = 'This config has been renamed to "' + newName + '"';
  6396. }
  6397. deprecations[oldName] = className + oldName + ': ' + message;
  6398. }
  6399. },
  6400. configure: function(instance, instanceConfig) {
  6401. var me = this,
  6402. configs = me.configs,
  6403. deprecations = me.deprecations,
  6404. initMap = me.initMap,
  6405. initListMap = me.initListMap,
  6406. initList = me.initList,
  6407. prototype = me.cls.prototype,
  6408. values = me.values,
  6409. remaining = 0,
  6410. firstInstance = !initList,
  6411. cachedInitList, cfg, getter, i, internalName, ln, names, name, value, isCached, valuesKey, field, transforms;
  6412. values = me.needsFork ? ExtObject.fork(values) : ExtObject.chain(values);
  6413. instance.isConfiguring = true;
  6414. if (firstInstance) {
  6415. me.initList = initList = [];
  6416. me.initListMap = initListMap = {};
  6417. instance.isFirstInstance = true;
  6418. for (name in initMap) {
  6419. cfg = configs[name];
  6420. isCached = cfg.cached;
  6421. if (initMap[name]) {
  6422. names = cfg.names;
  6423. value = values[name];
  6424. if (!prototype[names.set].$isDefault || prototype[names.apply] || prototype[names.update] || typeof value === 'object') {
  6425. if (isCached) {
  6426. (cachedInitList || (cachedInitList = [])).push(cfg);
  6427. } else {
  6428. initList.push(cfg);
  6429. initListMap[name] = true;
  6430. }
  6431. instance[names.get] = cfg.initGetter || cfg.getInitGetter();
  6432. } else {
  6433. prototype[cfg.getInternalName(prototype)] = value;
  6434. }
  6435. } else if (isCached) {
  6436. prototype[cfg.getInternalName(prototype)] = undefined;
  6437. }
  6438. }
  6439. }
  6440. ln = cachedInitList && cachedInitList.length;
  6441. if (ln) {
  6442. for (i = 0; i < ln; ++i) {
  6443. internalName = cachedInitList[i].getInternalName(prototype);
  6444. instance[internalName] = null;
  6445. }
  6446. for (i = 0; i < ln; ++i) {
  6447. names = (cfg = cachedInitList[i]).names;
  6448. getter = names.get;
  6449. if (instance.hasOwnProperty(getter)) {
  6450. instance[names.set](values[cfg.name]);
  6451. delete instance[getter];
  6452. }
  6453. }
  6454. for (i = 0; i < ln; ++i) {
  6455. internalName = cachedInitList[i].getInternalName(prototype);
  6456. prototype[internalName] = instance[internalName];
  6457. delete instance[internalName];
  6458. }
  6459. }
  6460. if (instanceConfig && instanceConfig.platformConfig) {
  6461. instanceConfig = me.resolvePlatformConfig(instance, instanceConfig);
  6462. }
  6463. if (firstInstance) {
  6464. if (instance.afterCachedConfig && !instance.afterCachedConfig.$nullFn) {
  6465. instance.afterCachedConfig(instanceConfig);
  6466. }
  6467. }
  6468. instance.config = values;
  6469. for (i = 0 , ln = initList.length; i < ln; ++i) {
  6470. cfg = initList[i];
  6471. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6472. }
  6473. if (!(transforms = instance.self.$configTransforms)) {
  6474. instance.self.$configTransforms = transforms = [];
  6475. ln = instance.$configTransforms;
  6476. for (name in ln) {
  6477. transforms.push([
  6478. name,
  6479. ln[name]
  6480. ]);
  6481. }
  6482. ln = transforms.length;
  6483. if (ln > 1) {
  6484. transforms.sort(me.transformSorter);
  6485. for (i = 0; i < ln; ++i) {
  6486. transforms[i] = transforms[i][0];
  6487. }
  6488. } else if (ln) {
  6489. transforms[0] = transforms[0][0];
  6490. }
  6491. }
  6492. for (i = 0; i < transforms.length; ++i) {
  6493. name = transforms[i];
  6494. if (instance[name]) {
  6495. instanceConfig = instance[name](instanceConfig, me);
  6496. }
  6497. }
  6498. if (instanceConfig) {
  6499. for (name in instanceConfig) {
  6500. value = instanceConfig[name];
  6501. cfg = configs[name];
  6502. if (deprecations[name]) {
  6503. Ext.log.warn(deprecations[name]);
  6504. if (!cfg) {
  6505. continue;
  6506. }
  6507. }
  6508. if (!cfg) {
  6509. field = instance.self.prototype[name];
  6510. if (instance.$configStrict && (typeof field === 'function') && !field.$nullFn) {
  6511. Ext.raise('Cannot override method ' + name + ' on ' + instance.$className + ' instance.');
  6512. }
  6513. instance[name] = value;
  6514. } else {
  6515. if (!cfg.lazy) {
  6516. ++remaining;
  6517. }
  6518. if (!initListMap[name]) {
  6519. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6520. }
  6521. valuesKey = values[name];
  6522. if (cfg.merge) {
  6523. value = cfg.merge(value, valuesKey, instance);
  6524. } else if (value && value.constructor === Object) {
  6525. if (valuesKey && valuesKey.constructor === Object) {
  6526. value = Ext.merge(values[name], value);
  6527. } else {
  6528. value = Ext.clone(value, false);
  6529. }
  6530. }
  6531. }
  6532. values[name] = value;
  6533. }
  6534. }
  6535. if (instance.beforeInitConfig && !instance.beforeInitConfig.$nullFn) {
  6536. if (instance.beforeInitConfig(instanceConfig) === false) {
  6537. return;
  6538. }
  6539. }
  6540. if (instanceConfig) {
  6541. for (name in instanceConfig) {
  6542. if (!remaining) {
  6543. break;
  6544. }
  6545. cfg = configs[name];
  6546. if (cfg && !cfg.lazy) {
  6547. --remaining;
  6548. names = cfg.names;
  6549. getter = names.get;
  6550. if (instance.hasOwnProperty(getter)) {
  6551. instance[names.set](values[name]);
  6552. delete instance[names.get];
  6553. }
  6554. }
  6555. }
  6556. }
  6557. for (i = 0 , ln = initList.length; i < ln; ++i) {
  6558. cfg = initList[i];
  6559. names = cfg.names;
  6560. getter = names.get;
  6561. if (!cfg.lazy && instance.hasOwnProperty(getter)) {
  6562. instance[names.set](values[cfg.name]);
  6563. delete instance[getter];
  6564. }
  6565. }
  6566. delete instance.isConfiguring;
  6567. },
  6568. getCurrentConfig: function(instance) {
  6569. var defaultConfig = instance.defaultConfig,
  6570. config = {},
  6571. name;
  6572. for (name in defaultConfig) {
  6573. config[name] = instance[configPropMap[name].names.get]();
  6574. }
  6575. return config;
  6576. },
  6577. hoistConfigs: function(instance, instanceConfig, names) {
  6578. var config = instance.config,
  6579. configs = this.configs,
  6580. initListMap = this.initListMap,
  6581. ret = false,
  6582. cfg, i, name;
  6583. for (i = 0; i < names.length; ++i) {
  6584. name = names[i];
  6585. if (instanceConfig && name in instanceConfig) {
  6586. cfg = configs[name];
  6587. config[name] = cfg.combine(instanceConfig[name], config[name], instance);
  6588. if (!initListMap[name]) {
  6589. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6590. }
  6591. }
  6592. if (config[name] != null) {
  6593. ret = true;
  6594. }
  6595. }
  6596. return ret;
  6597. },
  6598. merge: function(instance, baseConfig, config, clone) {
  6599. var configs = this.configs,
  6600. name, value, baseValue, cfg;
  6601. if (clone) {
  6602. baseConfig = Ext.clone(baseConfig,
  6603. false);
  6604. }
  6605. for (name in config) {
  6606. value = config[name];
  6607. cfg = configs[name];
  6608. if (cfg) {
  6609. baseValue = baseConfig[name];
  6610. if (cfg.merge) {
  6611. value = cfg.merge(value, baseValue, instance);
  6612. } else if (value && value.constructor === Object) {
  6613. if (baseValue && baseValue.constructor === Object) {
  6614. value = Ext.merge(baseValue, value);
  6615. } else {
  6616. value = Ext.clone(value, false);
  6617. }
  6618. }
  6619. }
  6620. baseConfig[name] = value;
  6621. }
  6622. return baseConfig;
  6623. },
  6624. reconfigure: function(instance, instanceConfig, options) {
  6625. var currentConfig = instance.config,
  6626. configList = [],
  6627. strict = instance.$configStrict && !(options && options.strict === false),
  6628. configs = this.configs,
  6629. defaults = options && options.defaults,
  6630. cfg, getter, i, len, name, names, prop;
  6631. for (name in instanceConfig) {
  6632. cfg = configs[name];
  6633. if (defaults && instance.hasOwnProperty(cfg && instance.$configPrefixed ? cfg.names.internal : name)) {
  6634. continue;
  6635. }
  6636. currentConfig[name] = instanceConfig[name];
  6637. if (this.deprecations[name]) {
  6638. Ext.log.warn(this.deprecations[name]);
  6639. if (!cfg) {
  6640. continue;
  6641. }
  6642. }
  6643. if (cfg) {
  6644. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6645. } else {
  6646. prop = instance.self.prototype[name];
  6647. if (strict) {
  6648. if ((typeof prop === 'function') && !prop.$nullFn) {
  6649. Ext.Error.raise("Cannot override method " + name + " on " + instance.$className + " instance.");
  6650. continue;
  6651. } else
  6652. {
  6653. if (name !== 'type') {
  6654. Ext.log.warn('No such config "' + name + '" for class ' + instance.$className);
  6655. }
  6656. }
  6657. }
  6658. }
  6659. configList.push(name);
  6660. }
  6661. for (i = 0 , len = configList.length; i < len; i++) {
  6662. name = configList[i];
  6663. cfg = configs[name];
  6664. if (cfg) {
  6665. names = cfg.names;
  6666. getter = names.get;
  6667. if (instance.hasOwnProperty(getter)) {
  6668. instance[names.set](instanceConfig[name]);
  6669. delete instance[getter];
  6670. }
  6671. } else {
  6672. cfg = configPropMap[name] || Ext.Config.get(name);
  6673. names = cfg.names;
  6674. if (instance[names.set]) {
  6675. instance[names.set](instanceConfig[name]);
  6676. } else {
  6677. instance[name] = instanceConfig[name];
  6678. }
  6679. }
  6680. }
  6681. },
  6682. resolvePlatformConfig: function(instance, instanceConfig) {
  6683. var platformConfig = instanceConfig && instanceConfig.platformConfig,
  6684. ret = instanceConfig,
  6685. i, keys, n;
  6686. if (platformConfig) {
  6687. keys = Ext.getPlatformConfigKeys(platformConfig);
  6688. n = keys.length;
  6689. if (n) {
  6690. ret = Ext.merge({}, ret);
  6691. for (i = 0 , n = keys.length; i < n; ++i) {
  6692. this.merge(instance, ret, platformConfig[keys[i]]);
  6693. }
  6694. }
  6695. }
  6696. return ret;
  6697. },
  6698. transformSorter: function(a, b) {
  6699. return a[1] - b[1];
  6700. }
  6701. };
  6702. }());
  6703. Ext.Base = (function(flexSetter) {
  6704. var noArgs = [],
  6705. baseStaticMember,
  6706. baseStaticMembers = [],
  6707. makeDeprecatedMethod = function(oldName, newName, msg) {
  6708. var message = '"' + oldName + '" is deprecated.';
  6709. if (msg) {
  6710. message += ' ' + msg;
  6711. } else if (newName) {
  6712. message += ' Please use "' + newName + '" instead.';
  6713. }
  6714. return function() {
  6715. Ext.raise(message);
  6716. };
  6717. },
  6718. addDeprecatedProperty = function(object, oldName, newName, message) {
  6719. if (!message) {
  6720. message = '"' + oldName + '" is deprecated.';
  6721. }
  6722. if (newName) {
  6723. message += ' Please use "' + newName + '" instead.';
  6724. }
  6725. if (message) {
  6726. Ext.Object.defineProperty(object, oldName, {
  6727. get: function() {
  6728. Ext.raise(message);
  6729. },
  6730. set: function(value) {
  6731. Ext.raise(message);
  6732. },
  6733. configurable: true
  6734. });
  6735. }
  6736. },
  6737. getOwnObject = function(proto, name) {
  6738. if (!proto.hasOwnProperty(name)) {
  6739. proto[name] = Ext.Object.chain(getOwnObject(proto.superclass, name));
  6740. }
  6741. return proto[name];
  6742. },
  6743. makeAliasFn = function(name) {
  6744. return function() {
  6745. return this[name].apply(this, arguments);
  6746. };
  6747. },
  6748. Version = Ext.Version,
  6749. leadingDigitRe = /^\d/,
  6750. oneMember = {},
  6751. aliasOneMember = {},
  6752. Base = function() {},
  6753. BasePrototype = Base.prototype,
  6754. Reaper;
  6755. Ext.Reaper = Reaper = {
  6756. delay: 100,
  6757. queue: [],
  6758. timer: null,
  6759. add: function(obj) {
  6760. if (!Reaper.timer) {
  6761. Reaper.timer = Ext.defer(Reaper.tick, Reaper.delay);
  6762. }
  6763. Reaper.queue.push(obj);
  6764. },
  6765. flush: function() {
  6766. if (Reaper.timer) {
  6767. Ext.undefer(Reaper.timer);
  6768. Reaper.timer = null;
  6769. }
  6770. var queue = Reaper.queue,
  6771. n = queue.length,
  6772. i, obj;
  6773. Reaper.queue = [];
  6774. for (i = 0; i < n; ++i) {
  6775. obj = queue[i];
  6776. if (obj && obj.$reap) {
  6777. obj.$reap();
  6778. }
  6779. }
  6780. },
  6781. tick: function() {
  6782. Reaper.timer = null;
  6783. Reaper.flush();
  6784. }
  6785. };
  6786. Ext.apply(Base, {
  6787. $className: 'Ext.Base',
  6788. $isClass: true,
  6789. create: function() {
  6790. return Ext.create.apply(Ext, [
  6791. this
  6792. ].concat(Array.prototype.slice.call(arguments, 0)));
  6793. },
  6794. addConfigTransform: function(methodName, priority) {
  6795. var transforms = getOwnObject(this.prototype, '$configTransforms');
  6796. if (this.$configTransforms) {
  6797. Ext.raise('Config transforms cannot be added after instances are created');
  6798. }
  6799. transforms[methodName] = priority;
  6800. },
  6801. addDeprecations: function(deprecations) {
  6802. var me = this,
  6803. all = [],
  6804. compatVersion = Ext.getCompatVersion(deprecations.name),
  6805. configurator = me.getConfigurator(),
  6806. displayName = (me.$className || '') + '#',
  6807. deprecate, versionSpec, index, message, target, enabled, existing, fn, names, oldName, newName, member, statics, version;
  6808. for (versionSpec in deprecations) {
  6809. if (leadingDigitRe.test(versionSpec)) {
  6810. version = new Ext.Version(versionSpec);
  6811. version.deprecations = deprecations[versionSpec];
  6812. all.push(version);
  6813. }
  6814. }
  6815. all.sort(Version.compare);
  6816. for (index = all.length; index--; ) {
  6817. deprecate = (version = all[index]).deprecations;
  6818. target = me.prototype;
  6819. statics = deprecate.statics;
  6820. enabled = compatVersion && compatVersion.lt(version);
  6821. if (!enabled) {}
  6822. else if (!enabled) {
  6823. break;
  6824. }
  6825. while (deprecate) {
  6826. names = deprecate.methods;
  6827. if (names) {
  6828. for (oldName in names) {
  6829. member = names[oldName];
  6830. fn = null;
  6831. if (!member) {
  6832. Ext.Assert.isNotDefinedProp(target, oldName);
  6833. fn = makeDeprecatedMethod(displayName + oldName);
  6834. }
  6835. else if (Ext.isString(member)) {
  6836. Ext.Assert.isNotDefinedProp(target, oldName);
  6837. Ext.Assert.isDefinedProp(target, member);
  6838. if (enabled) {
  6839. fn = makeAliasFn(member);
  6840. } else
  6841. {
  6842. fn = makeDeprecatedMethod(displayName + oldName, member);
  6843. }
  6844. } else
  6845. {
  6846. message = '';
  6847. if (member.message || member.fn) {
  6848. message = member.message;
  6849. member = member.fn;
  6850. }
  6851. existing = target.hasOwnProperty(oldName) && target[oldName];
  6852. if (enabled && member) {
  6853. member.$owner = me;
  6854. member.$name = oldName;
  6855. member.name = displayName + oldName;
  6856. if (existing) {
  6857. member.$previous = existing;
  6858. }
  6859. fn = member;
  6860. }
  6861. else if (!existing) {
  6862. fn = makeDeprecatedMethod(displayName + oldName, null, message);
  6863. }
  6864. }
  6865. if (fn) {
  6866. target[oldName] = fn;
  6867. }
  6868. }
  6869. }
  6870. names = deprecate.configs;
  6871. if (names) {
  6872. configurator.addDeprecations(names);
  6873. }
  6874. names = deprecate.properties;
  6875. if (names && !enabled) {
  6876. for (oldName in names) {
  6877. newName = names[oldName];
  6878. if (Ext.isString(newName)) {
  6879. addDeprecatedProperty(target, displayName + oldName, newName);
  6880. } else if (newName && newName.message) {
  6881. addDeprecatedProperty(target, displayName + oldName, null, newName.message);
  6882. } else {
  6883. addDeprecatedProperty(target, displayName + oldName);
  6884. }
  6885. }
  6886. }
  6887. deprecate = statics;
  6888. statics = null;
  6889. target = me;
  6890. }
  6891. }
  6892. },
  6893. extend: function(parentClass) {
  6894. var me = this,
  6895. parentPrototype = parentClass.prototype,
  6896. prototype, name, statics;
  6897. prototype = me.prototype = Ext.Object.chain(parentPrototype);
  6898. prototype.self = me;
  6899. me.superclass = prototype.superclass = parentPrototype;
  6900. if (!parentClass.$isClass) {
  6901. for (name in BasePrototype) {
  6902. if (name in prototype) {
  6903. prototype[name] = BasePrototype[name];
  6904. }
  6905. }
  6906. }
  6907. statics = parentPrototype.$inheritableStatics;
  6908. if (statics) {
  6909. for (name in statics) {
  6910. if (!me.hasOwnProperty(name)) {
  6911. me[name] = parentClass[name];
  6912. }
  6913. }
  6914. }
  6915. if (parentClass.$onExtended) {
  6916. me.$onExtended = parentClass.$onExtended.slice();
  6917. }
  6918. me.getConfigurator();
  6919. },
  6920. $onExtended: [],
  6921. triggerExtended: function() {
  6922. if (Ext.classSystemMonitor) {
  6923. Ext.classSystemMonitor(this, 'Ext.Base#triggerExtended', arguments);
  6924. }
  6925. var callbacks = this.$onExtended,
  6926. ln = callbacks.length,
  6927. i, callback;
  6928. if (ln > 0) {
  6929. for (i = 0; i < ln; i++) {
  6930. callback = callbacks[i];
  6931. callback.fn.apply(callback.scope || this, arguments);
  6932. }
  6933. }
  6934. },
  6935. onExtended: function(fn, scope) {
  6936. this.$onExtended.push({
  6937. fn: fn,
  6938. scope: scope
  6939. });
  6940. return this;
  6941. },
  6942. addStatics: function(members) {
  6943. this.addMembers(members, true);
  6944. return this;
  6945. },
  6946. addInheritableStatics: function(members) {
  6947. var me = this,
  6948. proto = me.prototype,
  6949. inheritableStatics = me.$inheritableStatics,
  6950. name, member, current;
  6951. if (!inheritableStatics) {
  6952. inheritableStatics = Ext.apply({}, proto.$inheritableStatics);
  6953. me.$inheritableStatics = proto.$inheritableStatics = inheritableStatics;
  6954. }
  6955. var className = Ext.getClassName(me) + '.';
  6956. for (name in members) {
  6957. if (members.hasOwnProperty(name)) {
  6958. member = members[name];
  6959. current = me[name];
  6960. if (typeof member === 'function') {
  6961. member.name = className + name;
  6962. }
  6963. if (typeof current === 'function' && !current.$isClass && !current.$nullFn) {
  6964. member.$previous = current;
  6965. }
  6966. me[name] = member;
  6967. inheritableStatics[name] = true;
  6968. }
  6969. }
  6970. return me;
  6971. },
  6972. addMembers: function(members, isStatic, privacy) {
  6973. var me = this,
  6974. cloneFunction = Ext.Function.clone,
  6975. target = isStatic ? me : me.prototype,
  6976. defaultConfig = !isStatic && target.defaultConfig,
  6977. enumerables = Ext.enumerables,
  6978. privates = members.privates,
  6979. configs, i, ln, member, name, subPrivacy, privateStatics;
  6980. var displayName = (me.$className || '') + '#';
  6981. if (privates) {
  6982. delete members.privates;
  6983. if (!isStatic) {
  6984. privateStatics = privates.statics;
  6985. delete privates.statics;
  6986. }
  6987. subPrivacy = privates.privacy || privacy || 'framework';
  6988. me.addMembers(privates, isStatic, subPrivacy);
  6989. if (privateStatics) {
  6990. me.addMembers(privateStatics, true, subPrivacy);
  6991. }
  6992. }
  6993. for (name in members) {
  6994. if (members.hasOwnProperty(name)) {
  6995. member = members[name];
  6996. if (privacy === true) {
  6997. privacy = 'framework';
  6998. }
  6999. if (member && member.$nullFn && privacy !== member.$privacy) {
  7000. Ext.raise('Cannot use stock function for private method ' + (me.$className ? me.$className + '#' : '') + name);
  7001. }
  7002. if (typeof member === 'function' && !member.$isClass && !member.$nullFn) {
  7003. if (member.$owner) {
  7004. member = cloneFunction(member);
  7005. }
  7006. if (target.hasOwnProperty(name)) {
  7007. member.$previous = target[name];
  7008. }
  7009. member.$owner = me;
  7010. member.$name = name;
  7011. member.name = displayName + name;
  7012. var existing = target[name];
  7013. if (privacy) {
  7014. member.$privacy = privacy;
  7015. if (existing && existing.$privacy && existing.$privacy !== privacy) {
  7016. Ext.privacyViolation(me, existing, member, isStatic);
  7017. }
  7018. } else if (existing && existing.$privacy) {
  7019. Ext.privacyViolation(me, existing, member, isStatic);
  7020. }
  7021. }
  7022. else if (defaultConfig && (name in defaultConfig) && !target.config.hasOwnProperty(name)) {
  7023. (configs || (configs = {}))[name] = member;
  7024. continue;
  7025. }
  7026. target[name] = member;
  7027. }
  7028. }
  7029. if (configs) {
  7030. me.addConfig(configs);
  7031. }
  7032. if (enumerables) {
  7033. for (i = 0 , ln = enumerables.length; i < ln; ++i) {
  7034. if (members.hasOwnProperty(name = enumerables[i])) {
  7035. member = members[name];
  7036. if (member && !member.$nullFn) {
  7037. if (member.$owner) {
  7038. member = cloneFunction(member);
  7039. }
  7040. member.$owner = me;
  7041. member.$name = name;
  7042. member.name = displayName + name;
  7043. if (target.hasOwnProperty(name)) {
  7044. member.$previous = target[name];
  7045. }
  7046. }
  7047. target[name] = member;
  7048. }
  7049. }
  7050. }
  7051. return this;
  7052. },
  7053. addMember: function(name, member, privacy) {
  7054. oneMember[name] = member;
  7055. this.addMembers(oneMember, false, privacy);
  7056. delete oneMember[name];
  7057. return this;
  7058. },
  7059. hookMember: function(name, member) {
  7060. var existing = this.prototype[name];
  7061. return this.addMember(name, member, existing && existing.$privacy);
  7062. },
  7063. borrow: function(fromClass, members) {
  7064. if (Ext.classSystemMonitor) {
  7065. Ext.classSystemMonitor(this, 'Ext.Base#borrow', arguments);
  7066. }
  7067. var prototype = fromClass.prototype,
  7068. membersObj = {},
  7069. i, ln, name;
  7070. members = Ext.Array.from(members);
  7071. for (i = 0 , ln = members.length; i < ln; i++) {
  7072. name = members[i];
  7073. membersObj[name] = prototype[name];
  7074. }
  7075. return this.addMembers(membersObj);
  7076. },
  7077. override: function(members) {
  7078. var me = this,
  7079. statics = members.statics,
  7080. inheritableStatics = members.inheritableStatics,
  7081. config = members.config,
  7082. mixins = members.mixins,
  7083. cachedConfig = members.cachedConfig;
  7084. if (statics || inheritableStatics || config) {
  7085. members = Ext.apply({}, members);
  7086. }
  7087. if (statics) {
  7088. me.addMembers(statics, true);
  7089. delete members.statics;
  7090. }
  7091. if (inheritableStatics) {
  7092. me.addInheritableStatics(inheritableStatics);
  7093. delete members.inheritableStatics;
  7094. }
  7095. if (members.platformConfig) {
  7096. me.addPlatformConfig(members);
  7097. }
  7098. if (config) {
  7099. me.addConfig(config);
  7100. delete members.config;
  7101. }
  7102. if (cachedConfig) {
  7103. me.addCachedConfig(cachedConfig);
  7104. delete members.cachedConfig;
  7105. }
  7106. delete members.mixins;
  7107. me.addMembers(members);
  7108. if (mixins) {
  7109. me.mixin(mixins);
  7110. }
  7111. return me;
  7112. },
  7113. addPlatformConfig: function(data) {
  7114. var me = this,
  7115. prototype = me.prototype,
  7116. platformConfigs = data.platformConfig,
  7117. added, classConfigs, configs, configurator, keys, name, value, i, ln;
  7118. delete prototype.platformConfig;
  7119. if (platformConfigs instanceof Array) {
  7120. throw new Error('platformConfigs must be specified as an object.');
  7121. }
  7122. configurator = me.getConfigurator();
  7123. classConfigs = configurator.configs;
  7124. keys = Ext.getPlatformConfigKeys(platformConfigs);
  7125. for (i = 0 , ln = keys.length; i < ln; ++i) {
  7126. configs = platformConfigs[keys[i]];
  7127. added = null;
  7128. for (name in configs) {
  7129. value = configs[name];
  7130. if (name in classConfigs) {
  7131. (added || (added = {}))[name] = value;
  7132. } else {
  7133. prototype[name] = value;
  7134. }
  7135. }
  7136. if (added) {
  7137. configurator.add(added);
  7138. }
  7139. }
  7140. },
  7141. callParent: function(args) {
  7142. var method;
  7143. return (method = this.callParent.caller) && (method.$previous || ((method = method.$owner ? method : method.caller) && method.$owner.superclass.self[method.$name])).apply(this, args || noArgs);
  7144. },
  7145. callSuper: function(args) {
  7146. var method;
  7147. return (method = this.callSuper.caller) && ((method = method.$owner ? method : method.caller) && method.$owner.superclass.self[method.$name]).apply(this, args || noArgs);
  7148. },
  7149. mixin: function(name, mixinClass) {
  7150. var me = this,
  7151. mixin, prototype, key, statics, i, ln, mixinName, mixinValue, mixins, mixinStatics, staticName;
  7152. if (typeof name !== 'string') {
  7153. mixins = name;
  7154. if (mixins instanceof Array) {
  7155. for (i = 0 , ln = mixins.length; i < ln; i++) {
  7156. mixin = mixins[i];
  7157. me.mixin(mixin.prototype.mixinId || mixin.$className, mixin);
  7158. }
  7159. } else {
  7160. for (mixinName in mixins) {
  7161. me.mixin(mixinName, mixins[mixinName]);
  7162. }
  7163. }
  7164. return;
  7165. }
  7166. mixin = mixinClass.prototype;
  7167. prototype = me.prototype;
  7168. if (mixin.onClassMixedIn) {
  7169. mixin.onClassMixedIn.call(mixinClass, me);
  7170. }
  7171. if (!prototype.hasOwnProperty('mixins')) {
  7172. if ('mixins' in prototype) {
  7173. prototype.mixins = Ext.Object.chain(prototype.mixins);
  7174. } else {
  7175. prototype.mixins = {};
  7176. }
  7177. }
  7178. for (key in mixin) {
  7179. mixinValue = mixin[key];
  7180. if (key === 'mixins') {
  7181. Ext.applyIf(prototype.mixins, mixinValue);
  7182. }
  7183. else if (!(key === 'mixinId' || key === 'config' || key === '$inheritableStatics') && (prototype[key] === undefined)) {
  7184. prototype[key] = mixinValue;
  7185. }
  7186. }
  7187. statics = mixin.$inheritableStatics;
  7188. if (statics) {
  7189. mixinStatics = {};
  7190. for (staticName in statics) {
  7191. if (!me.hasOwnProperty(staticName)) {
  7192. mixinStatics[staticName] = mixinClass[staticName];
  7193. }
  7194. }
  7195. me.addInheritableStatics(mixinStatics);
  7196. }
  7197. if ('config' in mixin) {
  7198. me.addConfig(mixin.config, mixinClass);
  7199. }
  7200. prototype.mixins[name] = mixin;
  7201. if (mixin.afterClassMixedIn) {
  7202. mixin.afterClassMixedIn.call(mixinClass, me);
  7203. }
  7204. return me;
  7205. },
  7206. addConfig: function(config, mixinClass) {
  7207. var cfg = this.$config || this.getConfigurator();
  7208. cfg.add(config, mixinClass);
  7209. },
  7210. addCachedConfig: function(config, isMixin) {
  7211. var cached = {},
  7212. key;
  7213. for (key in config) {
  7214. cached[key] = {
  7215. cached: true,
  7216. $value: config[key]
  7217. };
  7218. }
  7219. this.addConfig(cached, isMixin);
  7220. },
  7221. getConfigurator: function() {
  7222. return this.$config || new Ext.Configurator(this);
  7223. },
  7224. getName: function() {
  7225. return Ext.getClassName(this);
  7226. },
  7227. createAlias: flexSetter(function(alias, origin) {
  7228. aliasOneMember[alias] = function() {
  7229. return this[origin].apply(this, arguments);
  7230. };
  7231. this.override(aliasOneMember);
  7232. delete aliasOneMember[alias];
  7233. })
  7234. });
  7235. for (baseStaticMember in Base) {
  7236. if (Base.hasOwnProperty(baseStaticMember)) {
  7237. baseStaticMembers.push(baseStaticMember);
  7238. }
  7239. }
  7240. Base.$staticMembers = baseStaticMembers;
  7241. Base.getConfigurator();
  7242. Base.addMembers({
  7243. $className: 'Ext.Base',
  7244. $configTransforms: {},
  7245. isInstance: true,
  7246. $configPrefixed: true,
  7247. $configStrict: true,
  7248. isConfiguring: false,
  7249. isFirstInstance: false,
  7250. destroyed: false,
  7251. clearPropertiesOnDestroy: true,
  7252. clearPrototypeOnDestroy: false,
  7253. statics: function() {
  7254. var method = this.statics.caller,
  7255. self = this.self;
  7256. if (!method) {
  7257. return self;
  7258. }
  7259. return method.$owner;
  7260. },
  7261. callParent: function(args) {
  7262. var method,
  7263. superMethod = (method = this.callParent.caller) && (method.$previous || ((method = method.$owner ? method : method.caller) && method.$owner.superclass[method.$name]));
  7264. if (!superMethod) {
  7265. method = this.callParent.caller;
  7266. var parentClass, methodName;
  7267. if (!method.$owner) {
  7268. if (!method.caller) {
  7269. throw new Error("Attempting to call a protected method from the " + "public scope, which is not allowed");
  7270. }
  7271. method = method.caller;
  7272. }
  7273. parentClass = method.$owner.superclass;
  7274. methodName = method.$name;
  7275. if (!(methodName in parentClass)) {
  7276. throw new Error("this.callParent() was called but there's no such method (" + methodName + ") found in the parent class (" + (Ext.getClassName(parentClass) || 'Object') + ")");
  7277. }
  7278. }
  7279. return superMethod.apply(this, args || noArgs);
  7280. },
  7281. callSuper: function(args) {
  7282. var method,
  7283. superMethod = (method = this.callSuper.caller) && ((method = method.$owner ? method : method.caller) && method.$owner.superclass[method.$name]);
  7284. if (!superMethod) {
  7285. method = this.callSuper.caller;
  7286. var parentClass, methodName;
  7287. if (!method.$owner) {
  7288. if (!method.caller) {
  7289. throw new Error("Attempting to call a protected method from the " + "public scope, which is not allowed");
  7290. }
  7291. method = method.caller;
  7292. }
  7293. parentClass = method.$owner.superclass;
  7294. methodName = method.$name;
  7295. if (!(methodName in parentClass)) {
  7296. throw new Error("this.callSuper() was called but there's no such method (" + methodName + ") found in the parent class (" + (Ext.getClassName(parentClass) || 'Object') + ")");
  7297. }
  7298. }
  7299. return superMethod.apply(this, args || noArgs);
  7300. },
  7301. self: Base,
  7302. constructor: function() {
  7303. return this;
  7304. },
  7305. initConfig: function(instanceConfig) {
  7306. var me = this,
  7307. cfg = me.self.getConfigurator();
  7308. me.initConfig = Ext.emptyFn;
  7309. me.initialConfig = instanceConfig || {};
  7310. cfg.configure(me, instanceConfig);
  7311. return me;
  7312. },
  7313. beforeInitConfig: Ext.emptyFn,
  7314. getConfig: function(name, peek, ifInitialized) {
  7315. var me = this,
  7316. ret, cfg, propName;
  7317. if (name) {
  7318. cfg = me.self.$config.configs[name];
  7319. if (cfg) {
  7320. propName = me.$configPrefixed ? cfg.names.internal : name;
  7321. if (ifInitialized) {
  7322. ret = me.hasOwnProperty(propName) ? me[propName] : null;
  7323. } else if (peek) {
  7324. ret = me.hasOwnProperty(propName) ? me[propName] : me.config[name];
  7325. } else {
  7326. ret = me[cfg.names.get]();
  7327. }
  7328. } else {
  7329. ret = me[name];
  7330. }
  7331. } else {
  7332. ret = me.getCurrentConfig();
  7333. }
  7334. return ret;
  7335. },
  7336. destroyMembers: function() {
  7337. var me = this,
  7338. configs = me.self.$config.configs,
  7339. len = arguments.length,
  7340. cfg, name, value, i;
  7341. for (i = 0; i < len; i++) {
  7342. name = arguments[i];
  7343. cfg = configs[name];
  7344. name = cfg && me.$configPrefixed ? cfg.names.internal : name;
  7345. value = me.hasOwnProperty(name) && me[name];
  7346. if (value) {
  7347. Ext.destroy(value);
  7348. me[name] = null;
  7349. }
  7350. }
  7351. },
  7352. freezeConfig: function(name) {
  7353. var me = this,
  7354. config = Ext.Config.get(name),
  7355. names = config.names,
  7356. value = me[names.get]();
  7357. me[names.set] = function(v) {
  7358. if (v !== value) {
  7359. Ext.raise('Cannot change frozen config "' + name + '"');
  7360. }
  7361. return me;
  7362. };
  7363. if (!Ext.isIE8) {
  7364. Object.defineProperty(me, me.$configPrefixed ? names.internal : name, {
  7365. get: function() {
  7366. return value;
  7367. },
  7368. set: function(v) {
  7369. if (v !== value) {
  7370. Ext.raise('Cannot change frozen config "' + name + '"');
  7371. }
  7372. }
  7373. });
  7374. }
  7375. },
  7376. setConfig: function(name, value, options) {
  7377. var me = this,
  7378. configurator, config, prop;
  7379. if (name) {
  7380. configurator = me.self.getConfigurator();
  7381. if (typeof name === 'string') {
  7382. config = configurator.configs[name];
  7383. if (!config) {
  7384. if (me.$configStrict) {
  7385. prop = me.self.prototype[name];
  7386. if ((typeof prop === 'function') && !prop.$nullFn) {
  7387. Ext.Error.raise("Cannot override method " + name + " on " + me.$className + " instance.");
  7388. return me;
  7389. } else
  7390. {
  7391. if (name !== 'type') {
  7392. Ext.log.warn('No such config "' + name + '" for class ' + me.$className);
  7393. }
  7394. }
  7395. }
  7396. config = Ext.Config.map[name] || Ext.Config.get(name);
  7397. }
  7398. if (me[config.names.set]) {
  7399. me[config.names.set](value);
  7400. } else {
  7401. me[name] = value;
  7402. }
  7403. } else {
  7404. configurator.reconfigure(me, name, options || value);
  7405. }
  7406. }
  7407. return me;
  7408. },
  7409. getConfigWatcher: function() {
  7410. return this.$configWatch || (this.$configWatch = new Ext.mixin.Watchable());
  7411. },
  7412. watchConfig: function(name, fn, scope) {
  7413. var watcher = this.getConfigWatcher();
  7414. return watcher.on.apply(watcher, arguments);
  7415. },
  7416. $configWatch: null,
  7417. getCurrentConfig: function() {
  7418. var cfg = this.self.getConfigurator();
  7419. return cfg.getCurrentConfig(this);
  7420. },
  7421. hasConfig: function(name) {
  7422. return name in this.defaultConfig;
  7423. },
  7424. getInitialConfig: function(name) {
  7425. var config = this.config;
  7426. if (!name) {
  7427. return config;
  7428. }
  7429. return config[name];
  7430. },
  7431. $links: null,
  7432. link: function(name, value) {
  7433. var me = this,
  7434. links = me.$links || (me.$links = {});
  7435. links[name] = true;
  7436. me[name] = value;
  7437. return value;
  7438. },
  7439. unlink: function(names) {
  7440. var me = this,
  7441. i, ln, link, value;
  7442. if (!Ext.isArray(names)) {
  7443. Ext.raise('Invalid argument - expected array of strings');
  7444. }
  7445. for (i = 0 , ln = names.length; i < ln; i++) {
  7446. link = names[i];
  7447. value = me[link];
  7448. if (value) {
  7449. if (value.isInstance && !value.destroyed) {
  7450. value.destroy();
  7451. } else if (value.parentNode && 'nodeType' in value) {
  7452. value.parentNode.removeChild(value);
  7453. }
  7454. }
  7455. me[link] = null;
  7456. }
  7457. return me;
  7458. },
  7459. $reap: function() {
  7460. var me = this,
  7461. keepers = me.$noClearOnDestroy,
  7462. props, prop, val, t, i, len;
  7463. props = Ext.Object.getKeys(me);
  7464. for (i = 0 , len = props.length; i < len; i++) {
  7465. prop = props[i];
  7466. val = me[prop];
  7467. if (val && !(keepers && keepers[prop])) {
  7468. t = typeof val;
  7469. if (t === 'object' || (t === 'function' && !val.$noClearOnDestroy)) {
  7470. me[prop] = null;
  7471. }
  7472. }
  7473. }
  7474. me.$nulled = true;
  7475. if (Object.setPrototypeOf) {
  7476. if (me.clearPrototypeOnDestroy && !me.$vetoClearingPrototypeOnDestroy) {
  7477. props = me.$preservePrototypeProperties;
  7478. if (props) {
  7479. for (i = 0 , len = props.length; i < len; i++) {
  7480. prop = props[i];
  7481. if (!me.hasOwnProperty(prop)) {
  7482. me[prop] = me[prop];
  7483. }
  7484. }
  7485. }
  7486. Object.setPrototypeOf(me, null);
  7487. }
  7488. }
  7489. },
  7490. destroy: function() {
  7491. var me = this,
  7492. links = me.$links,
  7493. clearPropertiesOnDestroy = me.clearPropertiesOnDestroy;
  7494. if (links) {
  7495. me.$links = null;
  7496. me.unlink(Ext.Object.getKeys(links));
  7497. }
  7498. me.destroy = Ext.emptyFn;
  7499. me.isDestroyed = me.destroyed = true;
  7500. if (clearPropertiesOnDestroy === true) {
  7501. if (!me.isObservable) {
  7502. me.$reap();
  7503. }
  7504. } else if (clearPropertiesOnDestroy) {
  7505. if (clearPropertiesOnDestroy !== 'async') {
  7506. Ext.raise('Invalid value for clearPropertiesOnDestroy');
  7507. }
  7508. Reaper.add(me);
  7509. }
  7510. }
  7511. });
  7512. BasePrototype.callOverridden = BasePrototype.callParent;
  7513. Ext.privacyViolation = function(cls, existing, member, isStatic) {
  7514. var name = member.$name,
  7515. conflictCls = existing.$owner && existing.$owner.$className,
  7516. s = isStatic ? 'static ' : '',
  7517. msg = member.$privacy ? 'Private ' + s + member.$privacy + ' method "' + name + '"' : 'Public ' + s + 'method "' + name + '"';
  7518. if (cls.$className) {
  7519. msg = cls.$className + ': ' + msg;
  7520. }
  7521. if (!existing.$privacy) {
  7522. msg += conflictCls ? ' hides public method inherited from ' + conflictCls : ' hides inherited public method.';
  7523. } else {
  7524. msg += conflictCls ? ' conflicts with private ' + existing.$privacy + ' method declared by ' + conflictCls : ' conflicts with inherited private ' + existing.$privacy + ' method.';
  7525. }
  7526. var compat = Ext.getCompatVersion(),
  7527. ver = Ext.getVersion();
  7528. if (ver && compat && compat.lt(ver)) {
  7529. Ext.log.error(msg);
  7530. } else {
  7531. Ext.raise(msg);
  7532. }
  7533. };
  7534. Ext.Reaper.tick.$skipTimerCheck = true;
  7535. return Base;
  7536. }(Ext.Function.flexSetter));
  7537. (function(LRU, prototype) {
  7538. (Ext.util || (Ext.util = {})).LRU = LRU = function(config) {
  7539. var me = this,
  7540. head;
  7541. if (config) {
  7542. Ext.apply(me, config);
  7543. }
  7544. me.head = head = {
  7545. id: (me.seed = 0),
  7546. key: null,
  7547. value: null
  7548. };
  7549. me.map = {};
  7550. head.next = head.prev = head;
  7551. };
  7552. LRU.prototype = prototype = {
  7553. count: 0,
  7554. add: function(key, value) {
  7555. var me = this,
  7556. map = me.map,
  7557. entry = map[key];
  7558. if (entry) {
  7559. me.unlink(entry);
  7560. --me.count;
  7561. }
  7562. map[key] = entry = {
  7563. id: ++me.seed,
  7564. key: key,
  7565. value: value
  7566. };
  7567. me.link(entry);
  7568. ++me.count;
  7569. return entry;
  7570. },
  7571. clear: function(fn, scope) {
  7572. var me = this,
  7573. head = me.head,
  7574. entry = head.next;
  7575. head.next = head.prev = head;
  7576. me.count = 0;
  7577. if (fn && !fn.$nullFn) {
  7578. for (; entry !== head; entry = entry.next) {
  7579. fn.call(scope || me, entry.key, entry.value);
  7580. }
  7581. }
  7582. },
  7583. each: function(fn, scope) {
  7584. var head, ent;
  7585. scope = scope || this;
  7586. for (head = this.head , ent = head.next; ent !== head; ent = ent.next) {
  7587. if (fn.call(scope, ent.key, ent.value)) {
  7588. break;
  7589. }
  7590. }
  7591. },
  7592. prune: function(fn, scope) {
  7593. var me = this,
  7594. entry = me.head.prev,
  7595. ret;
  7596. if (me.count) {
  7597. ret = entry.value;
  7598. me.unlink(entry);
  7599. --me.count;
  7600. if (fn) {
  7601. fn.call(scope || me, entry.key, ret);
  7602. }
  7603. }
  7604. return ret;
  7605. },
  7606. remove: function(key) {
  7607. var me = this,
  7608. map = me.map,
  7609. entry = map[key],
  7610. value;
  7611. if (entry) {
  7612. me.unlink(entry);
  7613. value = entry.value;
  7614. delete map[key];
  7615. --me.count;
  7616. }
  7617. return value;
  7618. },
  7619. touch: function(key) {
  7620. var me = this,
  7621. head = me.head,
  7622. entry = me.map[key];
  7623. if (entry && entry.prev !== head) {
  7624. me.unlink(entry);
  7625. me.link(entry);
  7626. }
  7627. },
  7628. trim: function(size, fn, scope) {
  7629. while (this.count > size) {
  7630. this.prune(fn, scope);
  7631. }
  7632. },
  7633. link: function(entry) {
  7634. var head = this.head,
  7635. first = head.next;
  7636. entry.next = first;
  7637. entry.prev = head;
  7638. head.next = entry;
  7639. first.prev = entry;
  7640. },
  7641. unlink: function(entry) {
  7642. var next = entry.next,
  7643. prev = entry.prev;
  7644. prev.next = next;
  7645. next.prev = prev;
  7646. }
  7647. };
  7648. prototype.destroy = function() {
  7649. this.clear.apply(this, arguments);
  7650. };
  7651. }());
  7652. (function(LRU, fn, Cache) {
  7653. Ext.util.Cache = Cache = function(config) {
  7654. LRU.call(this, config);
  7655. };
  7656. fn.prototype = LRU.prototype;
  7657. Cache.prototype = Ext.apply(new fn(), {
  7658. maxSize: 100,
  7659. clear: function() {
  7660. LRU.prototype.clear.call(this, this.evict);
  7661. },
  7662. get: function(key) {
  7663. var me = this,
  7664. entry = me.map[key],
  7665. value;
  7666. if (entry) {
  7667. value = entry.value;
  7668. me.touch(key);
  7669. } else {
  7670. value = me.miss.apply(me, arguments);
  7671. me.add(key, value);
  7672. me.trim(me.maxSize, me.evict);
  7673. }
  7674. return value;
  7675. },
  7676. evict: Ext.emptyFn
  7677. });
  7678. }(Ext.util.LRU, function() {}));
  7679. (function() {
  7680. var ExtClass,
  7681. Base = Ext.Base,
  7682. baseStaticMembers = Base.$staticMembers,
  7683. ruleKeySortFn = function(a, b) {
  7684. return (a.length - b.length) || ((a < b) ? -1 : ((a > b) ? 1 : 0));
  7685. };
  7686. function makeCtor(className) {
  7687. function constructor() {
  7688. return this.constructor.apply(this, arguments) || null;
  7689. }
  7690. if (className) {
  7691. constructor.name = className;
  7692. }
  7693. return constructor;
  7694. }
  7695. Ext.Class = ExtClass = function(Class, data, onCreated) {
  7696. if (typeof Class !== 'function') {
  7697. onCreated = data;
  7698. data = Class;
  7699. Class = null;
  7700. }
  7701. if (!data) {
  7702. data = {};
  7703. }
  7704. Class = ExtClass.create(Class, data);
  7705. ExtClass.process(Class, data, onCreated);
  7706. return Class;
  7707. };
  7708. Ext.apply(ExtClass, {
  7709. makeCtor: makeCtor,
  7710. onBeforeCreated: function(Class, data, hooks) {
  7711. if (Ext.classSystemMonitor) {
  7712. Ext.classSystemMonitor(Class, '>> Ext.Class#onBeforeCreated', arguments);
  7713. }
  7714. Class.addMembers(data);
  7715. hooks.onCreated.call(Class, Class);
  7716. if (Ext.classSystemMonitor) {
  7717. Ext.classSystemMonitor(Class, '<< Ext.Class#onBeforeCreated', arguments);
  7718. }
  7719. },
  7720. create: function(Class, data) {
  7721. var i = baseStaticMembers.length,
  7722. name;
  7723. if (!Class) {
  7724. Class = makeCtor(
  7725. data.$className);
  7726. }
  7727. while (i--) {
  7728. name = baseStaticMembers[i];
  7729. Class[name] = Base[name];
  7730. }
  7731. return Class;
  7732. },
  7733. process: function(Class, data, onCreated) {
  7734. var preprocessorStack = data.preprocessors || ExtClass.defaultPreprocessors,
  7735. registeredPreprocessors = this.preprocessors,
  7736. hooks = {
  7737. onBeforeCreated: this.onBeforeCreated
  7738. },
  7739. preprocessors = [],
  7740. preprocessor, preprocessorsProperties, i, ln, j, subLn, preprocessorProperty;
  7741. delete data.preprocessors;
  7742. Class._classHooks = hooks;
  7743. for (i = 0 , ln = preprocessorStack.length; i < ln; i++) {
  7744. preprocessor = preprocessorStack[i];
  7745. if (typeof preprocessor === 'string') {
  7746. preprocessor = registeredPreprocessors[preprocessor];
  7747. preprocessorsProperties = preprocessor.properties;
  7748. if (preprocessorsProperties === true) {
  7749. preprocessors.push(preprocessor.fn);
  7750. } else if (preprocessorsProperties) {
  7751. for (j = 0 , subLn = preprocessorsProperties.length; j < subLn; j++) {
  7752. preprocessorProperty = preprocessorsProperties[j];
  7753. if (data.hasOwnProperty(preprocessorProperty)) {
  7754. preprocessors.push(preprocessor.fn);
  7755. break;
  7756. }
  7757. }
  7758. }
  7759. } else {
  7760. preprocessors.push(preprocessor);
  7761. }
  7762. }
  7763. hooks.onCreated = onCreated ? onCreated : Ext.emptyFn;
  7764. hooks.preprocessors = preprocessors;
  7765. this.doProcess(Class, data, hooks);
  7766. },
  7767. doProcess: function(Class, data, hooks) {
  7768. var me = this,
  7769. preprocessors = hooks.preprocessors,
  7770. preprocessor = preprocessors.shift(),
  7771. doProcess = me.doProcess;
  7772. for (; preprocessor; preprocessor = preprocessors.shift()) {
  7773. if (preprocessor.call(me, Class, data, hooks, doProcess) === false) {
  7774. return;
  7775. }
  7776. }
  7777. hooks.onBeforeCreated.apply(me, arguments);
  7778. },
  7779. preprocessors: {},
  7780. registerPreprocessor: function(name, fn, properties, position, relativeTo) {
  7781. if (!position) {
  7782. position = 'last';
  7783. }
  7784. if (!properties) {
  7785. properties = [
  7786. name
  7787. ];
  7788. }
  7789. this.preprocessors[name] = {
  7790. name: name,
  7791. properties: properties || false,
  7792. fn: fn
  7793. };
  7794. this.setDefaultPreprocessorPosition(name, position, relativeTo);
  7795. return this;
  7796. },
  7797. getPreprocessor: function(name) {
  7798. return this.preprocessors[name];
  7799. },
  7800. getPreprocessors: function() {
  7801. return this.preprocessors;
  7802. },
  7803. defaultPreprocessors: [],
  7804. getDefaultPreprocessors: function() {
  7805. return this.defaultPreprocessors;
  7806. },
  7807. setDefaultPreprocessors: function(preprocessors) {
  7808. this.defaultPreprocessors = Ext.Array.from(preprocessors);
  7809. return this;
  7810. },
  7811. setDefaultPreprocessorPosition: function(name, offset, relativeName) {
  7812. var defaultPreprocessors = this.defaultPreprocessors,
  7813. index;
  7814. if (typeof offset === 'string') {
  7815. if (offset === 'first') {
  7816. defaultPreprocessors.unshift(name);
  7817. return this;
  7818. } else if (offset === 'last') {
  7819. defaultPreprocessors.push(name);
  7820. return this;
  7821. }
  7822. offset = (offset === 'after') ? 1 : -1;
  7823. }
  7824. index = Ext.Array.indexOf(defaultPreprocessors, relativeName);
  7825. if (index !== -1) {
  7826. Ext.Array.splice(defaultPreprocessors, Math.max(0, index + offset), 0, name);
  7827. }
  7828. return this;
  7829. }
  7830. });
  7831. ExtClass.registerPreprocessor('extend', function(Class, data, hooks) {
  7832. var Base = Ext.Base,
  7833. basePrototype = Base.prototype,
  7834. extend = data.extend,
  7835. Parent, parentPrototype, i;
  7836. if (Ext.classSystemMonitor) {
  7837. Ext.classSystemMonitor(Class, 'Ext.Class#extendPreProcessor', arguments);
  7838. }
  7839. delete data.extend;
  7840. if (extend && extend !== Object) {
  7841. Parent = extend;
  7842. } else {
  7843. Parent = Base;
  7844. }
  7845. parentPrototype = Parent.prototype;
  7846. if (!Parent.$isClass) {
  7847. for (i in basePrototype) {
  7848. if (!parentPrototype[i]) {
  7849. parentPrototype[i] = basePrototype[i];
  7850. }
  7851. }
  7852. }
  7853. Class.extend(Parent);
  7854. Class.triggerExtended.apply(Class, arguments);
  7855. if (data.onClassExtended) {
  7856. Class.onExtended(data.onClassExtended, Class);
  7857. delete data.onClassExtended;
  7858. }
  7859. }, true);
  7860. ExtClass.registerPreprocessor('privates', function(Class, data) {
  7861. var privates = data.privates,
  7862. statics = privates.statics,
  7863. privacy = privates.privacy || true;
  7864. if (Ext.classSystemMonitor) {
  7865. Ext.classSystemMonitor(Class, 'Ext.Class#privatePreprocessor', arguments);
  7866. }
  7867. delete data.privates;
  7868. delete privates.statics;
  7869. Class.addMembers(privates, false, privacy);
  7870. if (statics) {
  7871. Class.addMembers(statics, true, privacy);
  7872. }
  7873. });
  7874. ExtClass.registerPreprocessor('statics', function(Class, data) {
  7875. if (Ext.classSystemMonitor) {
  7876. Ext.classSystemMonitor(Class, 'Ext.Class#staticsPreprocessor', arguments);
  7877. }
  7878. Class.addStatics(data.statics);
  7879. delete data.statics;
  7880. });
  7881. ExtClass.registerPreprocessor('inheritableStatics', function(Class, data) {
  7882. if (Ext.classSystemMonitor) {
  7883. Ext.classSystemMonitor(Class, 'Ext.Class#inheritableStaticsPreprocessor', arguments);
  7884. }
  7885. Class.addInheritableStatics(data.inheritableStatics);
  7886. delete data.inheritableStatics;
  7887. });
  7888. Ext.createRuleFn = function(code) {
  7889. return new Function('$c', 'with($c) { try { return (' + code + '); } catch(e) { return false;}}');
  7890. };
  7891. Ext.expressionCache = new Ext.util.Cache({
  7892. miss: Ext.createRuleFn
  7893. });
  7894. Ext.ruleKeySortFn = ruleKeySortFn;
  7895. Ext.getPlatformConfigKeys = function(platformConfig) {
  7896. var ret = [],
  7897. platform, rule;
  7898. for (platform in platformConfig) {
  7899. rule = Ext.expressionCache.get(platform);
  7900. if (rule(Ext.platformTags)) {
  7901. ret.push(platform);
  7902. }
  7903. }
  7904. ret.sort(ruleKeySortFn);
  7905. return ret;
  7906. };
  7907. ExtClass.registerPreprocessor('config', function(Class, data) {
  7908. if (data.hasOwnProperty('$configPrefixed')) {
  7909. Class.prototype.$configPrefixed = data.$configPrefixed;
  7910. }
  7911. Class.addConfig(data.config);
  7912. delete data.config;
  7913. });
  7914. ExtClass.registerPreprocessor('cachedConfig', function(Class, data) {
  7915. if (data.hasOwnProperty('$configPrefixed')) {
  7916. Class.prototype.$configPrefixed = data.$configPrefixed;
  7917. }
  7918. Class.addCachedConfig(data.cachedConfig);
  7919. delete data.cachedConfig;
  7920. });
  7921. ExtClass.registerPreprocessor('mixins', function(Class, data, hooks) {
  7922. var mixins = data.mixins,
  7923. onCreated = hooks.onCreated;
  7924. if (Ext.classSystemMonitor) {
  7925. Ext.classSystemMonitor(Class, 'Ext.Class#mixinsPreprocessor', arguments);
  7926. }
  7927. delete data.mixins;
  7928. hooks.onCreated = function() {
  7929. if (Ext.classSystemMonitor) {
  7930. Ext.classSystemMonitor(Class, 'Ext.Class#mixinsPreprocessor#beforeCreated', arguments);
  7931. }
  7932. hooks.onCreated = onCreated;
  7933. Class.mixin(mixins);
  7934. return hooks.onCreated.apply(this, arguments);
  7935. };
  7936. });
  7937. Ext.extend = function(Class, Parent, members) {
  7938. var cls, m;
  7939. if (Ext.classSystemMonitor) {
  7940. Ext.classSystemMonitor(Class, 'Ext.Class#extend-backwards-compatible', arguments);
  7941. }
  7942. if (arguments.length === 2 && Ext.isObject(Parent)) {
  7943. members = Parent;
  7944. Parent = Class;
  7945. Class = null;
  7946. }
  7947. if (!Parent) {
  7948. throw new Error("[Ext.extend] Attempting to extend from a class which has not " + "been loaded on the page.");
  7949. }
  7950. members.extend = Parent;
  7951. members.preprocessors = [
  7952. 'extend',
  7953. 'statics',
  7954. 'inheritableStatics',
  7955. 'mixins',
  7956. 'config'
  7957. ];
  7958. if (Class) {
  7959. cls = new ExtClass(Class, members);
  7960. cls.prototype.constructor = Class;
  7961. } else {
  7962. cls = new ExtClass(members);
  7963. }
  7964. cls.prototype.override = function(o) {
  7965. for (m in o) {
  7966. if (o.hasOwnProperty(m)) {
  7967. this[m] = o[m];
  7968. }
  7969. }
  7970. };
  7971. return cls;
  7972. };
  7973. }());
  7974. Ext.Inventory = function() {
  7975. var me = this;
  7976. me.names = [];
  7977. me.paths = {};
  7978. me.alternateToName = {};
  7979. me.aliasToName = {};
  7980. me.nameToAliases = {};
  7981. me.nameToAlternates = {};
  7982. me.nameToPrefix = {};
  7983. };
  7984. Ext.Inventory.prototype = {
  7985. _array1: [
  7986. 0
  7987. ],
  7988. prefixes: null,
  7989. dotRe: /\./g,
  7990. wildcardRe: /\*/g,
  7991. addAlias: function(className, alias, update) {
  7992. return this.addMapping(className, alias, this.aliasToName, this.nameToAliases, update);
  7993. },
  7994. addAlternate: function(className, alternate) {
  7995. return this.addMapping(className, alternate, this.alternateToName, this.nameToAlternates);
  7996. },
  7997. addMapping: function(className, alternate, toName, nameTo, update) {
  7998. var name = className.$className || className,
  7999. mappings = name,
  8000. array = this._array1,
  8001. a, aliases, cls, i, length, nameMapping;
  8002. if (Ext.isString(name)) {
  8003. mappings = {};
  8004. mappings[name] = alternate;
  8005. }
  8006. for (cls in mappings) {
  8007. aliases = mappings[cls];
  8008. if (Ext.isString(aliases)) {
  8009. array[0] = aliases;
  8010. aliases = array;
  8011. }
  8012. length = aliases.length;
  8013. nameMapping = nameTo[cls] || (nameTo[cls] = []);
  8014. for (i = 0; i < length; ++i) {
  8015. if (!(a = aliases[i])) {
  8016. continue;
  8017. }
  8018. if (toName[a] !== cls) {
  8019. if (!update && toName[a] && ('Ext.Gadget' !== a)) {
  8020. Ext.log.warn("Overriding existing mapping: '" + a + "' From '" + toName[a] + "' to '" + cls + "'. Is this intentional?");
  8021. }
  8022. toName[a] = cls;
  8023. nameMapping.push(a);
  8024. }
  8025. }
  8026. }
  8027. },
  8028. getAliasesByName: function(name) {
  8029. return this.nameToAliases[name] || null;
  8030. },
  8031. getAlternatesByName: function(name) {
  8032. return this.nameToAlternates[name] || null;
  8033. },
  8034. getNameByAlias: function(alias) {
  8035. return this.aliasToName[alias] || '';
  8036. },
  8037. getNameByAlternate: function(alternate) {
  8038. return this.alternateToName[alternate] || '';
  8039. },
  8040. getNamesByExpression: function(expression, exclude, accumulate) {
  8041. var me = this,
  8042. aliasToName = me.aliasToName,
  8043. alternateToName = me.alternateToName,
  8044. nameToAliases = me.nameToAliases,
  8045. nameToAlternates = me.nameToAlternates,
  8046. map = accumulate ? exclude : {},
  8047. names = [],
  8048. expressions = Ext.isString(expression) ? [
  8049. expression
  8050. ] : expression,
  8051. length = expressions.length,
  8052. wildcardRe = me.wildcardRe,
  8053. expr, i, list, match, n, name, regex;
  8054. for (i = 0; i < length; ++i) {
  8055. if ((expr = expressions[i]).indexOf('*') < 0) {
  8056. if (!(name = aliasToName[expr])) {
  8057. if (!(name = alternateToName[expr])) {
  8058. name = expr;
  8059. }
  8060. }
  8061. if (!(name in map) && !(exclude && (name in exclude))) {
  8062. map[name] = 1;
  8063. names.push(name);
  8064. }
  8065. } else {
  8066. regex = new RegExp('^' + expr.replace(wildcardRe, '(.*?)') + '$');
  8067. for (name in nameToAliases) {
  8068. if (!(name in map) && !(exclude && (name in exclude))) {
  8069. if (!(match = regex.test(name))) {
  8070. n = (list = nameToAliases[name]).length;
  8071. while (!match && n-- > 0) {
  8072. match = regex.test(list[n]);
  8073. }
  8074. list = nameToAlternates[name];
  8075. if (list && !match) {
  8076. n = list.length;
  8077. while (!match && n-- > 0) {
  8078. match = regex.test(list[n]);
  8079. }
  8080. }
  8081. }
  8082. if (match) {
  8083. map[name] = 1;
  8084. names.push(name);
  8085. }
  8086. }
  8087. }
  8088. }
  8089. }
  8090. return names;
  8091. },
  8092. getPath: function(className) {
  8093. var me = this,
  8094. paths = me.paths,
  8095. ret = '',
  8096. prefix;
  8097. if (className in paths) {
  8098. ret = paths[className];
  8099. } else {
  8100. prefix = me.nameToPrefix[className] || (me.nameToPrefix[className] = me.getPrefix(className));
  8101. if (prefix) {
  8102. className = className.substring(prefix.length + 1);
  8103. ret = paths[prefix];
  8104. if (ret) {
  8105. ret += '/';
  8106. }
  8107. }
  8108. ret += className.replace(me.dotRe, '/') + '.js';
  8109. }
  8110. return ret;
  8111. },
  8112. getPrefix: function(className) {
  8113. if (className in this.paths) {
  8114. return className;
  8115. } else if (className in this.nameToPrefix) {
  8116. return this.nameToPrefix[className];
  8117. }
  8118. var prefixes = this.getPrefixes(),
  8119. length = className.length,
  8120. items, currChar, prefix, j, jlen;
  8121. while (length-- > 0) {
  8122. items = prefixes[length];
  8123. if (items) {
  8124. currChar = className.charAt(length);
  8125. if (currChar !== '.') {
  8126. continue;
  8127. }
  8128. for (j = 0 , jlen = items.length; j < jlen; j++) {
  8129. prefix = items[j];
  8130. if (prefix === className.substring(0, length)) {
  8131. return prefix;
  8132. }
  8133. }
  8134. }
  8135. }
  8136. return '';
  8137. },
  8138. getPrefixes: function() {
  8139. var me = this,
  8140. prefixes = me.prefixes,
  8141. names, name, nameLength, items, i, len;
  8142. if (!prefixes) {
  8143. names = me.names.slice(0);
  8144. me.prefixes = prefixes = [];
  8145. for (i = 0 , len = names.length; i < len; i++) {
  8146. name = names[i];
  8147. nameLength = name.length;
  8148. items = prefixes[nameLength] || (prefixes[nameLength] = []);
  8149. items.push(name);
  8150. }
  8151. }
  8152. return prefixes;
  8153. },
  8154. removeName: function(name) {
  8155. var me = this,
  8156. aliasToName = me.aliasToName,
  8157. alternateToName = me.alternateToName,
  8158. nameToAliases = me.nameToAliases,
  8159. nameToAlternates = me.nameToAlternates,
  8160. aliases = nameToAliases[name],
  8161. alternates = nameToAlternates[name],
  8162. i, a;
  8163. delete nameToAliases[name];
  8164. delete nameToAlternates[name];
  8165. delete me.nameToPrefix[name];
  8166. if (aliases) {
  8167. for (i = aliases.length; i--; ) {
  8168. if (name === aliasToName[a = aliases[i]]) {
  8169. delete aliasToName[a];
  8170. }
  8171. }
  8172. }
  8173. if (alternates) {
  8174. for (i = alternates.length; i--; ) {
  8175. if (name === alternateToName[a = alternates[i]]) {
  8176. delete alternateToName[a];
  8177. }
  8178. }
  8179. }
  8180. },
  8181. resolveName: function(name) {
  8182. var me = this,
  8183. trueName;
  8184. if (!(name in me.nameToAliases)) {
  8185. if (!(trueName = me.aliasToName[name])) {
  8186. trueName = me.alternateToName[name];
  8187. }
  8188. }
  8189. return trueName || name;
  8190. },
  8191. select: function(receiver, scope) {
  8192. var me = this,
  8193. excludes = {},
  8194. ret = {
  8195. excludes: excludes,
  8196. exclude: function() {
  8197. me.getNamesByExpression(arguments[0], excludes, true);
  8198. return this;
  8199. }
  8200. },
  8201. name;
  8202. for (name in receiver) {
  8203. ret[name] = me.selectMethod(excludes, receiver[name], scope || receiver);
  8204. }
  8205. return ret;
  8206. },
  8207. selectMethod: function(excludes, fn, scope) {
  8208. var me = this;
  8209. return function(include) {
  8210. var args = Ext.Array.slice(arguments, 1);
  8211. args.unshift(me.getNamesByExpression(include, excludes));
  8212. return fn.apply(scope, args);
  8213. };
  8214. },
  8215. setPath: Ext.Function.flexSetter(function(name, path) {
  8216. var me = this;
  8217. me.paths[name] = path;
  8218. me.names.push(name);
  8219. me.prefixes = null;
  8220. me.nameToPrefix = {};
  8221. return me;
  8222. })
  8223. };
  8224. Ext.ClassManager = (function(Class, alias, arraySlice, arrayFrom, global) {
  8225. var makeCtor = Ext.Class.makeCtor,
  8226. nameLookupStack = [],
  8227. namespaceCache = {
  8228. Ext: {
  8229. name: 'Ext',
  8230. value: Ext
  8231. }
  8232. },
  8233. Manager = Ext.apply(new Ext.Inventory(), {
  8234. classes: {},
  8235. classCount: 0,
  8236. classState: {},
  8237. existCache: {},
  8238. instantiators: [],
  8239. isCreated: function(className) {
  8240. if (typeof className !== 'string' || className.length < 1) {
  8241. throw new Error("[Ext.ClassManager] Invalid classname, must be a string and " + "must not be empty");
  8242. }
  8243. if (Manager.classes[className] || Manager.existCache[className]) {
  8244. return true;
  8245. }
  8246. if (!Manager.lookupName(className, false)) {
  8247. return false;
  8248. }
  8249. Manager.triggerCreated(className);
  8250. return true;
  8251. },
  8252. createdListeners: [],
  8253. nameCreatedListeners: {},
  8254. existsListeners: [],
  8255. nameExistsListeners: {},
  8256. overrideMap: {},
  8257. triggerCreated: function(className, state) {
  8258. Manager.existCache[className] = state || 1;
  8259. Manager.classState[className] += 40;
  8260. Manager.notify(className, Manager.createdListeners, Manager.nameCreatedListeners);
  8261. },
  8262. onCreated: function(fn, scope, className) {
  8263. Manager.addListener(fn, scope, className, Manager.createdListeners, Manager.nameCreatedListeners);
  8264. },
  8265. notify: function(className, listeners, nameListeners) {
  8266. var alternateNames = Manager.getAlternatesByName(className),
  8267. names = [
  8268. className
  8269. ],
  8270. i, ln, j, subLn, listener, name;
  8271. for (i = 0 , ln = listeners.length; i < ln; i++) {
  8272. listener = listeners[i];
  8273. listener.fn.call(listener.scope, className);
  8274. }
  8275. while (names) {
  8276. for (i = 0 , ln = names.length; i < ln; i++) {
  8277. name = names[i];
  8278. listeners = nameListeners[name];
  8279. if (listeners) {
  8280. for (j = 0 , subLn = listeners.length; j < subLn; j++) {
  8281. listener = listeners[j];
  8282. listener.fn.call(listener.scope, name);
  8283. }
  8284. delete nameListeners[name];
  8285. }
  8286. }
  8287. names = alternateNames;
  8288. alternateNames = null;
  8289. }
  8290. },
  8291. addListener: function(fn, scope, className, listeners, nameListeners) {
  8292. var i;
  8293. if (Ext.isArray(className)) {
  8294. fn = Ext.Function.createBarrier(className.length, fn, scope);
  8295. for (i = 0; i < className.length; i++) {
  8296. this.addListener(fn, null, className[i], listeners, nameListeners);
  8297. }
  8298. return;
  8299. }
  8300. var listener = {
  8301. fn: fn,
  8302. scope: scope
  8303. };
  8304. if (className) {
  8305. if (this.isCreated(className)) {
  8306. fn.call(scope, className);
  8307. return;
  8308. }
  8309. if (!nameListeners[className]) {
  8310. nameListeners[className] = [];
  8311. }
  8312. nameListeners[className].push(listener);
  8313. } else {
  8314. listeners.push(listener);
  8315. }
  8316. },
  8317. $namespaceCache: namespaceCache,
  8318. addRootNamespaces: function(namespaces) {
  8319. var name;
  8320. for (name in namespaces) {
  8321. namespaceCache[name] = {
  8322. name: name,
  8323. value: namespaces[name]
  8324. };
  8325. }
  8326. },
  8327. clearNamespaceCache: function() {
  8328. var name;
  8329. nameLookupStack.length = 0;
  8330. for (name in namespaceCache) {
  8331. if (!namespaceCache[name].value) {
  8332. delete namespaceCache[name];
  8333. }
  8334. }
  8335. },
  8336. getNamespaceEntry: function(namespace) {
  8337. var entry, i;
  8338. if (typeof namespace !== 'string') {
  8339. return namespace;
  8340. }
  8341. entry = namespaceCache[namespace];
  8342. if (!entry) {
  8343. i = namespace.lastIndexOf('.');
  8344. if (i < 0) {
  8345. entry = {
  8346. name: namespace
  8347. };
  8348. } else {
  8349. entry = {
  8350. name: namespace.substring(i + 1),
  8351. parent: Manager.getNamespaceEntry(namespace.substring(0, i))
  8352. };
  8353. }
  8354. namespaceCache[namespace] = entry;
  8355. }
  8356. return entry;
  8357. },
  8358. lookupName: function(namespace, autoCreate) {
  8359. var entry = Manager.getNamespaceEntry(namespace),
  8360. scope = Ext.global,
  8361. i = 0,
  8362. e, parent;
  8363. for (e = entry; e; e = e.parent) {
  8364. nameLookupStack[i++] = e;
  8365. }
  8366. while (scope && i-- > 0) {
  8367. e = nameLookupStack[i];
  8368. parent = scope;
  8369. scope = e.value || scope[e.name];
  8370. if (!scope && autoCreate) {
  8371. parent[e.name] = scope = {};
  8372. }
  8373. }
  8374. return scope;
  8375. },
  8376. setNamespace: function(namespace, value) {
  8377. var entry = Manager.getNamespaceEntry(namespace),
  8378. scope = Ext.global;
  8379. if (entry.parent) {
  8380. scope = Manager.lookupName(entry.parent, true);
  8381. }
  8382. scope[entry.name] = value;
  8383. return value;
  8384. },
  8385. setXType: function(cls, xtype) {
  8386. var className = cls.$className,
  8387. C = className ? cls : Manager.get(className = cls),
  8388. proto = C.prototype,
  8389. xtypes = proto.xtypes,
  8390. xtypesChain = proto.xtypesChain,
  8391. xtypesMap = proto.xtypesMap;
  8392. if (!proto.hasOwnProperty('xtypes')) {
  8393. proto.xtypes = xtypes = [];
  8394. proto.xtypesChain = xtypesChain = xtypesChain ? xtypesChain.slice(0) : [];
  8395. proto.xtypesMap = xtypesMap = Ext.apply({}, xtypesMap);
  8396. }
  8397. Manager.addAlias(className, 'widget.' + xtype, true);
  8398. xtypes.push(xtype);
  8399. xtypesChain.push(xtype);
  8400. xtypesMap[xtype] = true;
  8401. },
  8402. set: function(name, value) {
  8403. var targetName = Manager.getName(value);
  8404. Manager.classes[name] = Manager.setNamespace(name, value);
  8405. Manager.classCount++;
  8406. if (targetName && targetName !== name) {
  8407. Manager.addAlternate(targetName, name);
  8408. }
  8409. return Manager;
  8410. },
  8411. get: function(name) {
  8412. return Manager.classes[name] || Manager.lookupName(name, false);
  8413. },
  8414. addNameAliasMappings: function(aliases) {
  8415. Manager.addAlias(aliases);
  8416. },
  8417. addNameAlternateMappings: function(alternates) {
  8418. Manager.addAlternate(alternates);
  8419. },
  8420. getByAlias: function(alias) {
  8421. return Manager.get(Manager.getNameByAlias(alias));
  8422. },
  8423. getByConfig: function(config, aliasPrefix) {
  8424. var xclass = config.xclass,
  8425. name;
  8426. if (xclass) {
  8427. name = xclass;
  8428. } else {
  8429. name = config.xtype;
  8430. if (name) {
  8431. aliasPrefix = 'widget.';
  8432. } else {
  8433. name = config.type;
  8434. }
  8435. name = Manager.getNameByAlias(aliasPrefix + name);
  8436. }
  8437. return Manager.get(name);
  8438. },
  8439. getName: function(object) {
  8440. return object && object.$className || '';
  8441. },
  8442. getClass: function(object) {
  8443. return object && object.self || null;
  8444. },
  8445. create: function(className, data, createdFn) {
  8446. var ctor;
  8447. if (className != null && typeof className !== 'string') {
  8448. throw new Error("[Ext.define] Invalid class name '" + className + "' specified, must be a non-empty string");
  8449. }
  8450. ctor = makeCtor(className);
  8451. if (typeof data === 'function') {
  8452. data = data(ctor);
  8453. }
  8454. if (className) {
  8455. if (Manager.classes[className]) {
  8456. Ext.log.warn("[Ext.define] Duplicate class name '" + className + "' specified, must be a non-empty string");
  8457. }
  8458. ctor.name = className;
  8459. }
  8460. data.$className = className;
  8461. return new Class(ctor, data, function() {
  8462. var postprocessorStack = data.postprocessors || Manager.defaultPostprocessors,
  8463. registeredPostprocessors = Manager.postprocessors,
  8464. postprocessors = [],
  8465. postprocessor, i, ln, j, subLn, postprocessorProperties, postprocessorProperty;
  8466. delete data.postprocessors;
  8467. for (i = 0 , ln = postprocessorStack.length; i < ln; i++) {
  8468. postprocessor = postprocessorStack[i];
  8469. if (typeof postprocessor === 'string') {
  8470. postprocessor = registeredPostprocessors[postprocessor];
  8471. postprocessorProperties = postprocessor.properties;
  8472. if (postprocessorProperties === true) {
  8473. postprocessors.push(postprocessor.fn);
  8474. } else if (postprocessorProperties) {
  8475. for (j = 0 , subLn = postprocessorProperties.length; j < subLn; j++) {
  8476. postprocessorProperty = postprocessorProperties[j];
  8477. if (data.hasOwnProperty(postprocessorProperty)) {
  8478. postprocessors.push(postprocessor.fn);
  8479. break;
  8480. }
  8481. }
  8482. }
  8483. } else {
  8484. postprocessors.push(postprocessor);
  8485. }
  8486. }
  8487. data.postprocessors = postprocessors;
  8488. data.createdFn = createdFn;
  8489. Manager.processCreate(className, this, data);
  8490. });
  8491. },
  8492. processCreate: function(className, cls, clsData) {
  8493. var me = this,
  8494. postprocessor = clsData.postprocessors.shift(),
  8495. createdFn = clsData.createdFn;
  8496. if (!postprocessor) {
  8497. if (Ext.classSystemMonitor) {
  8498. Ext.classSystemMonitor(className, 'Ext.ClassManager#classCreated', arguments);
  8499. }
  8500. if (className) {
  8501. me.set(className, cls);
  8502. }
  8503. delete cls._classHooks;
  8504. if (createdFn) {
  8505. createdFn.call(cls, cls);
  8506. }
  8507. if (className) {
  8508. me.triggerCreated(className);
  8509. }
  8510. return;
  8511. }
  8512. if (postprocessor.call(me, className, cls, clsData, me.processCreate) !== false) {
  8513. me.processCreate(className, cls, clsData);
  8514. }
  8515. },
  8516. createOverride: function(className, data, createdFn) {
  8517. var me = this,
  8518. overriddenClassName = data.override,
  8519. requires = data.requires,
  8520. uses = data.uses,
  8521. mixins = data.mixins,
  8522. mixinsIsArray,
  8523. compat = 1,
  8524. dependenciesLoaded, classReady;
  8525. classReady = function() {
  8526. var cls, dependencies, i, key, temp;
  8527. if (!dependenciesLoaded) {
  8528. dependencies = requires ? requires.slice(0) : [];
  8529. if (mixins) {
  8530. if (!(mixinsIsArray = mixins instanceof Array)) {
  8531. for (key in mixins) {
  8532. if (Ext.isString(cls = mixins[key])) {
  8533. dependencies.push(cls);
  8534. }
  8535. }
  8536. } else {
  8537. for (i = 0 , temp = mixins.length; i < temp; ++i) {
  8538. if (Ext.isString(cls = mixins[i])) {
  8539. dependencies.push(cls);
  8540. }
  8541. }
  8542. }
  8543. }
  8544. dependenciesLoaded = true;
  8545. if (dependencies.length) {
  8546. Ext.require(dependencies, classReady);
  8547. return;
  8548. }
  8549. }
  8550. if (mixinsIsArray) {
  8551. for (i = 0 , temp = mixins.length; i < temp; ++i) {
  8552. if (Ext.isString(cls = mixins[i])) {
  8553. mixins[i] = Ext.ClassManager.get(cls);
  8554. }
  8555. }
  8556. } else if (mixins) {
  8557. for (key in mixins) {
  8558. if (Ext.isString(cls = mixins[key])) {
  8559. mixins[key] = Ext.ClassManager.get(cls);
  8560. }
  8561. }
  8562. }
  8563. cls = overriddenClassName.$isClass ? overriddenClassName : me.get(overriddenClassName);
  8564. delete data.override;
  8565. delete data.compatibility;
  8566. delete data.requires;
  8567. delete data.uses;
  8568. Ext.override(cls, data);
  8569. Ext.Loader.history.push(className);
  8570. if (uses) {
  8571. Ext['Loader'].addUsedClasses(uses);
  8572. }
  8573. if (createdFn) {
  8574. createdFn.call(cls, cls);
  8575. }
  8576. };
  8577. if (className) {
  8578. Manager.overrideMap[className] = true;
  8579. }
  8580. if ('compatibility' in data) {
  8581. compat = data.compatibility;
  8582. if (!compat) {
  8583. compat = false;
  8584. } else if (typeof compat === 'number') {
  8585. compat = true;
  8586. } else if (typeof compat !== 'boolean') {
  8587. compat = Ext.checkVersion(compat);
  8588. }
  8589. }
  8590. if (compat) {
  8591. if (overriddenClassName.$isClass) {
  8592. classReady();
  8593. } else {
  8594. me.onCreated(classReady, me, overriddenClassName);
  8595. }
  8596. }
  8597. me.triggerCreated(className, 2);
  8598. return me;
  8599. },
  8600. instantiateByAlias: function() {
  8601. var alias = arguments[0],
  8602. args = arraySlice.call(arguments),
  8603. className = this.getNameByAlias(alias);
  8604. if (!className) {
  8605. throw new Error("[Ext.createByAlias] Unrecognized alias: " + alias);
  8606. }
  8607. args[0] = className;
  8608. return Ext.create.apply(Ext, args);
  8609. },
  8610. dynInstantiate: function(name, args) {
  8611. args = arrayFrom(args, true);
  8612. args.unshift(name);
  8613. return Ext.create.apply(Ext, args);
  8614. },
  8615. getInstantiator: function(length) {
  8616. var instantiators = this.instantiators,
  8617. instantiator, args, i;
  8618. instantiator = instantiators[length];
  8619. if (!instantiator) {
  8620. i = length;
  8621. args = [];
  8622. for (i = 0; i < length; i++) {
  8623. args.push('a[' + i + ']');
  8624. }
  8625. instantiator = instantiators[length] = new Function('c', 'a', 'return new c(' + args.join(',') + ')');
  8626. instantiator.name = "Ext.create" + length;
  8627. }
  8628. return instantiator;
  8629. },
  8630. postprocessors: {},
  8631. defaultPostprocessors: [],
  8632. registerPostprocessor: function(name, fn, properties, position, relativeTo) {
  8633. if (!position) {
  8634. position = 'last';
  8635. }
  8636. if (!properties) {
  8637. properties = [
  8638. name
  8639. ];
  8640. }
  8641. this.postprocessors[name] = {
  8642. name: name,
  8643. properties: properties || false,
  8644. fn: fn
  8645. };
  8646. this.setDefaultPostprocessorPosition(name, position, relativeTo);
  8647. return this;
  8648. },
  8649. setDefaultPostprocessors: function(postprocessors) {
  8650. this.defaultPostprocessors = arrayFrom(postprocessors);
  8651. return this;
  8652. },
  8653. setDefaultPostprocessorPosition: function(name, offset, relativeName) {
  8654. var defaultPostprocessors = this.defaultPostprocessors,
  8655. index;
  8656. if (typeof offset === 'string') {
  8657. if (offset === 'first') {
  8658. defaultPostprocessors.unshift(name);
  8659. return this;
  8660. } else if (offset === 'last') {
  8661. defaultPostprocessors.push(name);
  8662. return this;
  8663. }
  8664. offset = (offset === 'after') ? 1 : -1;
  8665. }
  8666. index = Ext.Array.indexOf(defaultPostprocessors, relativeName);
  8667. if (index !== -1) {
  8668. Ext.Array.splice(defaultPostprocessors, Math.max(0, index + offset), 0, name);
  8669. }
  8670. return this;
  8671. }
  8672. });
  8673. Manager.registerPostprocessor('platformConfig', function(name, Class, data) {
  8674. Class.addPlatformConfig(data);
  8675. });
  8676. Manager.registerPostprocessor('alias', function(name, cls, data) {
  8677. if (Ext.classSystemMonitor) {
  8678. Ext.classSystemMonitor(name, 'Ext.ClassManager#aliasPostProcessor', arguments);
  8679. }
  8680. var aliases = Ext.Array.from(data.alias),
  8681. i, ln;
  8682. for (i = 0 , ln = aliases.length; i < ln; i++) {
  8683. alias = aliases[i];
  8684. this.addAlias(cls, alias);
  8685. }
  8686. }, [
  8687. 'xtype',
  8688. 'alias'
  8689. ]);
  8690. Manager.registerPostprocessor('singleton', function(name, cls, data, fn) {
  8691. if (Ext.classSystemMonitor) {
  8692. Ext.classSystemMonitor(name, 'Ext.ClassManager#singletonPostProcessor', arguments);
  8693. }
  8694. if (data.singleton) {
  8695. fn.call(this, name, new cls(), data);
  8696. } else {
  8697. return true;
  8698. }
  8699. return false;
  8700. });
  8701. Manager.registerPostprocessor('alternateClassName', function(name, cls, data) {
  8702. var alternates = data.alternateClassName,
  8703. i, ln, alternate;
  8704. if (Ext.classSystemMonitor) {
  8705. Ext.classSystemMonitor(name, 'Ext.ClassManager#alternateClassNamePostprocessor', arguments);
  8706. }
  8707. if (!(alternates instanceof Array)) {
  8708. alternates = [
  8709. alternates
  8710. ];
  8711. }
  8712. for (i = 0 , ln = alternates.length; i < ln; i++) {
  8713. alternate = alternates[i];
  8714. if (typeof alternate !== 'string') {
  8715. throw new Error("[Ext.define] Invalid alternate of: '" + alternate + "' for class: '" + name + "'; must be a valid string");
  8716. }
  8717. this.set(alternate, cls);
  8718. }
  8719. });
  8720. Manager.registerPostprocessor('debugHooks', function(name, Class, data) {
  8721. var target;
  8722. if (Ext.classSystemMonitor) {
  8723. Ext.classSystemMonitor(Class, 'Ext.Class#debugHooks', arguments);
  8724. }
  8725. if (Ext.isDebugEnabled(Class.$className, data.debugHooks.$enabled)) {
  8726. delete data.debugHooks.$enabled;
  8727. Ext.override(Class, data.debugHooks);
  8728. }
  8729. target = Class.isInstance ? Class.self : Class;
  8730. delete target.prototype.debugHooks;
  8731. });
  8732. Manager.registerPostprocessor('deprecated', function(name, Class, data) {
  8733. var target;
  8734. if (Ext.classSystemMonitor) {
  8735. Ext.classSystemMonitor(Class, 'Ext.Class#deprecated', arguments);
  8736. }
  8737. target = Class.isInstance ? Class.self : Class;
  8738. target.addDeprecations(data.deprecated);
  8739. delete target.prototype.deprecated;
  8740. });
  8741. Ext.apply(Ext, {
  8742. create: function() {
  8743. var name = arguments[0],
  8744. nameType = typeof name,
  8745. args = arraySlice.call(arguments, 1),
  8746. cls;
  8747. if (nameType === 'function') {
  8748. cls = name;
  8749. } else {
  8750. if (nameType !== 'string' && args.length === 0) {
  8751. args = [
  8752. name
  8753. ];
  8754. if (!(name = name.xclass)) {
  8755. name = args[0].xtype;
  8756. if (name) {
  8757. name = 'widget.' + name;
  8758. }
  8759. }
  8760. }
  8761. if (typeof name !== 'string' || name.length < 1) {
  8762. throw new Error("[Ext.create] Invalid class name or alias '" + name + "' specified, must be a non-empty string");
  8763. }
  8764. name = Manager.resolveName(name);
  8765. cls = Manager.get(name);
  8766. }
  8767. if (!cls) {
  8768. Ext.syncRequire(name);
  8769. cls = Manager.get(name);
  8770. }
  8771. if (!cls) {
  8772. throw new Error("[Ext.create] Unrecognized class name / alias: " + name);
  8773. }
  8774. if (typeof cls !== 'function') {
  8775. throw new Error("[Ext.create] Singleton '" + name + "' cannot be instantiated.");
  8776. }
  8777. return Manager.getInstantiator(args.length)(cls, args);
  8778. },
  8779. widget: function(name, config) {
  8780. var xtype = name,
  8781. alias, className, T;
  8782. if (typeof xtype !== 'string') {
  8783. config = name;
  8784. xtype = config.xtype;
  8785. className = config.xclass;
  8786. } else {
  8787. config = config || {};
  8788. }
  8789. if (config.isComponent) {
  8790. return config;
  8791. }
  8792. if (!className) {
  8793. alias = 'widget.' + xtype;
  8794. className = Manager.getNameByAlias(alias);
  8795. }
  8796. if (className) {
  8797. T = Manager.get(className);
  8798. }
  8799. if (!T) {
  8800. return Ext.create(className || alias, config);
  8801. }
  8802. return new T(config);
  8803. },
  8804. createByAlias: alias(Manager, 'instantiateByAlias'),
  8805. define: function(className, data, createdFn) {
  8806. if (Ext.classSystemMonitor) {
  8807. Ext.classSystemMonitor(className, 'ClassManager#define', arguments);
  8808. }
  8809. if (data.override) {
  8810. Manager.classState[className] = 20;
  8811. return Manager.createOverride.apply(Manager, arguments);
  8812. }
  8813. Manager.classState[className] = 10;
  8814. return Manager.create.apply(Manager, arguments);
  8815. },
  8816. undefine: function(className) {
  8817. var classes = Manager.classes;
  8818. if (Ext.classSystemMonitor) {
  8819. Ext.classSystemMonitor(className, 'Ext.ClassManager#undefine', arguments);
  8820. }
  8821. if (classes[className]) {
  8822. Manager.classCount--;
  8823. }
  8824. delete classes[className];
  8825. delete Manager.existCache[className];
  8826. delete Manager.classState[className];
  8827. Manager.removeName(className);
  8828. Ext.Factory.clearCaches();
  8829. var entry = Manager.getNamespaceEntry(className),
  8830. scope = entry.parent ? Manager.lookupName(entry.parent, false) : Ext.global,
  8831. entryName;
  8832. if (scope) {
  8833. entryName = entry.name;
  8834. try {
  8835. delete scope[entryName];
  8836. } catch (e) {
  8837. scope[entryName] = undefined;
  8838. }
  8839. }
  8840. return entryName;
  8841. },
  8842. getClassName: alias(Manager, 'getName'),
  8843. getDisplayName: function(object) {
  8844. if (object) {
  8845. if (object.displayName) {
  8846. return object.displayName;
  8847. }
  8848. if (object.$name && object.$class) {
  8849. return Ext.getClassName(object.$class) + '#' + object.$name;
  8850. }
  8851. if (object.$className) {
  8852. return object.$className;
  8853. }
  8854. }
  8855. return 'Anonymous';
  8856. },
  8857. getClass: alias(Manager, 'getClass'),
  8858. namespace: function() {
  8859. var root = global,
  8860. i;
  8861. for (i = arguments.length; i-- > 0; ) {
  8862. root = Manager.lookupName(arguments[i], true);
  8863. }
  8864. return root;
  8865. }
  8866. });
  8867. Ext.addRootNamespaces = Manager.addRootNamespaces;
  8868. Ext.createWidget = Ext.widget;
  8869. Ext.ns = Ext.namespace;
  8870. Class.registerPreprocessor('className', function(cls, data) {
  8871. if ('$className' in data) {
  8872. cls.$className = data.$className;
  8873. cls.displayName = cls.$className;
  8874. }
  8875. if (Ext.classSystemMonitor) {
  8876. Ext.classSystemMonitor(cls, 'Ext.ClassManager#classNamePreprocessor', arguments);
  8877. }
  8878. },
  8879. true, 'first');
  8880. Class.registerPreprocessor('alias', function(cls, data) {
  8881. if (Ext.classSystemMonitor) {
  8882. Ext.classSystemMonitor(cls, 'Ext.ClassManager#aliasPreprocessor', arguments);
  8883. }
  8884. var prototype = cls.prototype,
  8885. xtypes = arrayFrom(data.xtype),
  8886. aliases = arrayFrom(data.alias),
  8887. widgetPrefix = 'widget.',
  8888. widgetPrefixLength = widgetPrefix.length,
  8889. xtypesChain = Array.prototype.slice.call(prototype.xtypesChain || []),
  8890. xtypesMap = Ext.merge({}, prototype.xtypesMap || {}),
  8891. i, ln, alias, xtype;
  8892. for (i = 0 , ln = aliases.length; i < ln; i++) {
  8893. alias = aliases[i];
  8894. if (typeof alias !== 'string' || alias.length < 1) {
  8895. throw new Error("[Ext.define] Invalid alias of: '" + alias + "' for class: '" + name + "'; must be a valid string");
  8896. }
  8897. if (alias.substring(0, widgetPrefixLength) === widgetPrefix) {
  8898. xtype = alias.substring(widgetPrefixLength);
  8899. Ext.Array.include(xtypes, xtype);
  8900. }
  8901. }
  8902. cls.xtype = data.xtype = xtypes[0];
  8903. data.xtypes = xtypes;
  8904. for (i = 0 , ln = xtypes.length; i < ln; i++) {
  8905. xtype = xtypes[i];
  8906. if (!xtypesMap[xtype]) {
  8907. xtypesMap[xtype] = true;
  8908. xtypesChain.push(xtype);
  8909. }
  8910. }
  8911. data.xtypesChain = xtypesChain;
  8912. data.xtypesMap = xtypesMap;
  8913. Ext.Function.interceptAfterOnce(cls, 'onClassCreated', function() {
  8914. var cls = this,
  8915. prototype = cls.prototype,
  8916. mixins = prototype.mixins,
  8917. key, mixin;
  8918. if (Ext.classSystemMonitor) {
  8919. Ext.classSystemMonitor(cls, 'Ext.ClassManager#aliasPreprocessor#afterClassCreated', arguments);
  8920. }
  8921. for (key in mixins) {
  8922. if (mixins.hasOwnProperty(key)) {
  8923. mixin = mixins[key];
  8924. xtypes = mixin.xtypes;
  8925. if (xtypes) {
  8926. for (i = 0 , ln = xtypes.length; i < ln; i++) {
  8927. xtype = xtypes[i];
  8928. if (!xtypesMap[xtype]) {
  8929. xtypesMap[xtype] = true;
  8930. xtypesChain.push(xtype);
  8931. }
  8932. }
  8933. }
  8934. }
  8935. }
  8936. });
  8937. for (i = 0 , ln = xtypes.length; i < ln; i++) {
  8938. xtype = xtypes[i];
  8939. if (typeof xtype !== 'string' || xtype.length < 1) {
  8940. throw new Error("[Ext.define] Invalid xtype of: '" + xtype + "' for class: '" + name + "'; must be a valid non-empty string");
  8941. }
  8942. Ext.Array.include(aliases, widgetPrefix + xtype);
  8943. }
  8944. data.alias = aliases;
  8945. }, [
  8946. 'xtype',
  8947. 'alias'
  8948. ]);
  8949. if (Ext.manifest) {
  8950. var manifest = Ext.manifest,
  8951. classes = manifest.classes,
  8952. paths = manifest.paths,
  8953. aliases = {},
  8954. alternates = {},
  8955. className, obj, name, path, baseUrl;
  8956. if (paths) {
  8957. if (manifest.bootRelative) {
  8958. baseUrl = Ext.Boot.baseUrl;
  8959. for (path in paths) {
  8960. if (paths.hasOwnProperty(path)) {
  8961. paths[path] = baseUrl + paths[path];
  8962. }
  8963. }
  8964. }
  8965. Manager.setPath(paths);
  8966. }
  8967. if (classes) {
  8968. for (className in classes) {
  8969. alternates[className] = [];
  8970. aliases[className] = [];
  8971. obj = classes[className];
  8972. if (obj.alias) {
  8973. aliases[className] = obj.alias;
  8974. }
  8975. if (obj.alternates) {
  8976. alternates[className] = obj.alternates;
  8977. }
  8978. }
  8979. }
  8980. Manager.addAlias(aliases);
  8981. Manager.addAlternate(alternates);
  8982. }
  8983. return Manager;
  8984. }(Ext.Class, Ext.Function.alias, Array.prototype.slice, Ext.Array.from, Ext.global));
  8985. Ext.define('Ext.mixin.Watchable', {
  8986. on: function(name, fn, scope) {
  8987. return this._watchUpdate(false, '_watchAdd', name, fn, scope);
  8988. },
  8989. fire: function(event, args) {
  8990. var me = this,
  8991. watching = me.watching,
  8992. watchers = watching && watching[event],
  8993. fn, i, r, scope;
  8994. if (watchers) {
  8995. ++watchers.$firing;
  8996. for (i = 0; i < watchers.length; ++i) {
  8997. scope = watchers[i][0];
  8998. fn = watchers[i][1];
  8999. if (fn.charAt) {
  9000. r = args ? scope[fn].apply(scope, args) : scope[fn]();
  9001. } else {
  9002. r = args ? fn.apply(scope, args) : fn.call(scope);
  9003. }
  9004. if (r === false) {
  9005. return r;
  9006. }
  9007. }
  9008. --watchers.$firing;
  9009. }
  9010. },
  9011. fireEvent: function() {
  9012. var args = Ext.Array.slice(arguments),
  9013. event = args.shift();
  9014. return this.fire(event, args);
  9015. },
  9016. un: function(name, fn, scope) {
  9017. return this._watchUpdate(true, '_watchRemove', name, fn, scope);
  9018. },
  9019. privates: {
  9020. watching: null,
  9021. $watchOptions: {
  9022. destroyable: 1,
  9023. scope: 1
  9024. },
  9025. _watchAdd: function(watching, name, fn, scope, destroyable) {
  9026. if (typeof fn === 'string' && !scope[fn]) {
  9027. Ext.raise('No such method "' + fn + '" on ' + scope.$className);
  9028. }
  9029. var watchers = watching[name],
  9030. entry = [
  9031. scope,
  9032. fn
  9033. ],
  9034. i, ent;
  9035. if (!watchers) {
  9036. watching[name] = watchers = [];
  9037. watchers.$firing = 0;
  9038. } else {
  9039. for (i = watchers.length; i-- > 0; )
  9040. {
  9041. ent = watchers[i];
  9042. if (fn === ent[1]) {
  9043. if (scope ? ent[0] === scope : !ent[0]) {
  9044. return;
  9045. }
  9046. }
  9047. }
  9048. if (watchers.$firing) {
  9049. watching[name] = watchers = watchers.slice();
  9050. watchers.$firing = 0;
  9051. }
  9052. }
  9053. watchers.push(entry);
  9054. if (destroyable) {
  9055. entry.push(name);
  9056. destroyable.items.push(entry);
  9057. }
  9058. },
  9059. _watchRemove: function(watching, name, fn, scope) {
  9060. var watchers = watching[name],
  9061. i;
  9062. if (watchers) {
  9063. if (watchers.$firing) {
  9064. watching[name] = watchers = watchers.slice();
  9065. watchers.$firing = 0;
  9066. }
  9067. for (i = watchers.length; i-- > 0; )
  9068. {
  9069. if (watchers[i][0] === scope && watchers[i][1] === fn) {
  9070. watchers.splice(i, 1);
  9071. }
  9072. }
  9073. }
  9074. },
  9075. _watchUpdate: function(remove, process, name, fn, scope) {
  9076. var me = this,
  9077. watch = name,
  9078. watching = me.watching,
  9079. destroyable;
  9080. if (!watching) {
  9081. if (remove) {
  9082. return;
  9083. }
  9084. me.watching = watching = {};
  9085. }
  9086. if (typeof name === 'string') {
  9087. me[process](watching, name, fn, scope);
  9088. } else {
  9089. destroyable = watch.destroyable ? {
  9090. owner: me,
  9091. items: [],
  9092. destroy: me._watcherDestroyer
  9093. } : null;
  9094. scope = watch.scope;
  9095. for (name in watch) {
  9096. if (!me.$watchOptions[name]) {
  9097. me[process](watching, name, watch[name], scope, destroyable);
  9098. }
  9099. }
  9100. }
  9101. return destroyable;
  9102. },
  9103. _watcherDestroyer: function() {
  9104. var me = this.owner,
  9105. watching = me.watching,
  9106. items = this.items,
  9107. entry, i;
  9108. for (i = 0; i < items.length; ++i) {
  9109. entry = items[i];
  9110. me._watchRemove(watching, entry[2], entry[1], entry[0]);
  9111. }
  9112. }
  9113. }
  9114. });
  9115. (Ext.env || (Ext.env = {})).Browser = function(userAgent, publish) {
  9116. var me = this,
  9117. browserPrefixes = Ext.Boot.browserPrefixes,
  9118. browserNames = Ext.Boot.browserNames,
  9119. enginePrefixes = me.enginePrefixes,
  9120. engineNames = me.engineNames,
  9121. browserMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(browserPrefixes).join(')|(?:') + '))([\\w\\._]+)')),
  9122. engineMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(enginePrefixes).join(')|(?:') + '))([\\w\\._]+)')),
  9123. browserName = browserNames.other,
  9124. engineName = engineNames.other,
  9125. browserVersion = '',
  9126. engineVersion = '',
  9127. majorVer = '',
  9128. isWebView = false,
  9129. edgeRE = /(Edge\/)([\w.]+)/,
  9130. ripple = '',
  9131. i, prefix, name;
  9132. me.userAgent = userAgent;
  9133. this.is = function(name) {
  9134. return !!this.is[name];
  9135. };
  9136. if (/Edge\//.test(userAgent)) {
  9137. browserMatch = userAgent.match(edgeRE);
  9138. engineMatch = userAgent.match(edgeRE);
  9139. }
  9140. if (browserMatch) {
  9141. browserName = browserNames[Ext.Object.getKey(browserPrefixes, browserMatch[1])];
  9142. if (browserName === 'Safari' && /^Opera/.test(userAgent)) {
  9143. browserName = 'Opera';
  9144. }
  9145. browserVersion = new Ext.Version(browserMatch[2]);
  9146. }
  9147. if (engineMatch) {
  9148. engineName = engineNames[Ext.Object.getKey(enginePrefixes, engineMatch[1])];
  9149. engineVersion = new Ext.Version(engineMatch[2]);
  9150. }
  9151. if (engineName === 'Trident' && browserName !== 'IE') {
  9152. browserName = 'IE';
  9153. var version = userAgent.match(/.*rv:(\d+.\d+)/);
  9154. if (version && version.length) {
  9155. version = version[1];
  9156. browserVersion = new Ext.Version(version);
  9157. }
  9158. }
  9159. if (browserName && browserVersion) {
  9160. Ext.setVersion(browserName, browserVersion);
  9161. }
  9162. if (userAgent.match(/FB/) && browserName === 'Other') {
  9163. browserName = browserNames.safari;
  9164. engineName = engineNames.webkit;
  9165. }
  9166. else if (userAgent.match(/Android.*Chrome/g)) {
  9167. browserName = 'ChromeMobile';
  9168. } else {
  9169. browserMatch = userAgent.match(/OPR\/(\d+.\d+)/);
  9170. if (browserMatch) {
  9171. browserName = 'Opera';
  9172. browserVersion = new Ext.Version(browserMatch[1]);
  9173. }
  9174. }
  9175. Ext.apply(this, {
  9176. engineName: engineName,
  9177. engineVersion: engineVersion,
  9178. name: browserName,
  9179. version: browserVersion
  9180. });
  9181. this.setFlag(browserName, true, publish);
  9182. if (browserVersion) {
  9183. majorVer = browserVersion.getMajor() || '';
  9184. if (me.is.IE) {
  9185. majorVer = document.documentMode || parseInt(majorVer, 10);
  9186. for (i = 7; i <= 11; ++i) {
  9187. prefix = 'isIE' + i;
  9188. Ext[prefix] = majorVer === i;
  9189. Ext[prefix + 'm'] = majorVer <= i;
  9190. Ext[prefix + 'p'] = majorVer >= i;
  9191. }
  9192. }
  9193. if (me.is.Opera && parseInt(majorVer, 10) <= 12) {
  9194. Ext.isOpera12m = true;
  9195. }
  9196. Ext.chromeVersion = Ext.isChrome ? majorVer : 0;
  9197. Ext.firefoxVersion = Ext.isFirefox ? majorVer : 0;
  9198. Ext.ieVersion = Ext.isIE ? majorVer : 0;
  9199. Ext.operaVersion = Ext.isOpera ? majorVer : 0;
  9200. Ext.safariVersion = Ext.isSafari ? majorVer : 0;
  9201. Ext.webKitVersion = Ext.isWebKit ? majorVer : 0;
  9202. this.setFlag(browserName + majorVer, true, publish);
  9203. this.setFlag(browserName + browserVersion.getShortVersion());
  9204. }
  9205. for (i in browserNames) {
  9206. if (browserNames.hasOwnProperty(i)) {
  9207. name = browserNames[i];
  9208. this.setFlag(name, browserName === name);
  9209. }
  9210. }
  9211. this.setFlag(name);
  9212. if (engineVersion) {
  9213. this.setFlag(engineName + (engineVersion.getMajor() || ''));
  9214. this.setFlag(engineName + engineVersion.getShortVersion());
  9215. }
  9216. for (i in engineNames) {
  9217. if (engineNames.hasOwnProperty(i)) {
  9218. name = engineNames[i];
  9219. this.setFlag(name, engineName === name, publish);
  9220. }
  9221. }
  9222. this.setFlag('Standalone', !!navigator.standalone);
  9223. try {
  9224. ripple = window.top.ripple;
  9225. } catch (e) {}
  9226. this.setFlag('Ripple', !!document.getElementById("tinyhippos-injected") && !Ext.isEmpty(ripple));
  9227. this.setFlag('WebWorks', !!window.blackberry);
  9228. if (window.PhoneGap !== undefined || window.Cordova !== undefined || window.cordova !== undefined) {
  9229. isWebView = true;
  9230. this.setFlag('PhoneGap');
  9231. this.setFlag('Cordova');
  9232. }
  9233. if (/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)(?!.*FBAN)/i.test(userAgent)) {
  9234. isWebView = true;
  9235. }
  9236. this.setFlag('WebView', isWebView);
  9237. this.isStrict = Ext.isStrict = document.compatMode === "CSS1Compat";
  9238. this.isSecure = Ext.isSecure;
  9239. this.identity = browserName + majorVer + (this.isStrict ? 'Strict' : 'Quirks');
  9240. };
  9241. Ext.env.Browser.prototype = {
  9242. constructor: Ext.env.Browser,
  9243. engineNames: {
  9244. edge: 'Edge',
  9245. webkit: 'WebKit',
  9246. gecko: 'Gecko',
  9247. presto: 'Presto',
  9248. trident: 'Trident',
  9249. other: 'Other'
  9250. },
  9251. enginePrefixes: {
  9252. edge: 'Edge/',
  9253. webkit: 'AppleWebKit/',
  9254. gecko: 'Gecko/',
  9255. presto: 'Presto/',
  9256. trident: 'Trident/'
  9257. },
  9258. styleDashPrefixes: {
  9259. WebKit: '-webkit-',
  9260. Gecko: '-moz-',
  9261. Trident: '-ms-',
  9262. Presto: '-o-',
  9263. Other: ''
  9264. },
  9265. stylePrefixes: {
  9266. WebKit: 'Webkit',
  9267. Gecko: 'Moz',
  9268. Trident: 'ms',
  9269. Presto: 'O',
  9270. Other: ''
  9271. },
  9272. propertyPrefixes: {
  9273. WebKit: 'webkit',
  9274. Gecko: 'moz',
  9275. Trident: 'ms',
  9276. Presto: 'o',
  9277. Other: ''
  9278. },
  9279. name: null,
  9280. version: null,
  9281. engineName: null,
  9282. engineVersion: null,
  9283. setFlag: function(name, value, publish) {
  9284. if (value === undefined) {
  9285. value = true;
  9286. }
  9287. this.is[name] = value;
  9288. this.is[name.toLowerCase()] = value;
  9289. if (publish) {
  9290. Ext['is' + name] = value;
  9291. }
  9292. return this;
  9293. },
  9294. getStyleDashPrefix: function() {
  9295. return this.styleDashPrefixes[this.engineName];
  9296. },
  9297. getStylePrefix: function() {
  9298. return this.stylePrefixes[this.engineName];
  9299. },
  9300. getVendorProperyName: function(name) {
  9301. var prefix = this.propertyPrefixes[this.engineName];
  9302. if (prefix.length > 0) {
  9303. return prefix + Ext.String.capitalize(name);
  9304. }
  9305. return name;
  9306. }
  9307. };
  9308. (function(userAgent) {
  9309. Ext.browser = new Ext.env.Browser(userAgent, true);
  9310. Ext.userAgent = userAgent.toLowerCase();
  9311. Ext.SSL_SECURE_URL = Ext.isSecure && Ext.isIE ? 'javascript:\'\'' : 'about:blank';
  9312. }(Ext.global.navigator.userAgent));
  9313. Ext.env.OS = function(userAgent, platform, browserScope) {
  9314. var me = this,
  9315. names = Ext.Boot.osNames,
  9316. prefixes = Ext.Boot.osPrefixes,
  9317. name,
  9318. version = '',
  9319. is = me.is,
  9320. i, prefix, match, item, match1;
  9321. browserScope = browserScope || Ext.browser;
  9322. for (i in prefixes) {
  9323. if (prefixes.hasOwnProperty(i)) {
  9324. prefix = prefixes[i];
  9325. match = userAgent.match(new RegExp('(?:' + prefix + ')([^\\s;]+)'));
  9326. if (match) {
  9327. name = names[i];
  9328. match1 = match[1];
  9329. if (match1 && match1 === "HTC_") {
  9330. version = new Ext.Version("2.3");
  9331. } else if (match1 && match1 === "Silk/") {
  9332. version = new Ext.Version("2.3");
  9333. } else {
  9334. version = new Ext.Version(match[match.length - 1]);
  9335. }
  9336. break;
  9337. }
  9338. }
  9339. }
  9340. if (!name) {
  9341. name = names[(userAgent.toLowerCase().match(/mac|win|linux/) || [
  9342. 'other'
  9343. ])[0]];
  9344. version = new Ext.Version('');
  9345. }
  9346. this.name = name;
  9347. this.version = version;
  9348. if (userAgent.match(/ipad/i)) {
  9349. platform = 'iPad';
  9350. }
  9351. if (platform) {
  9352. this.setFlag(platform.replace(/ simulator$/i, ''));
  9353. }
  9354. this.setFlag(name);
  9355. if (version) {
  9356. this.setFlag(name + (version.getMajor() || ''));
  9357. this.setFlag(name + version.getShortVersion());
  9358. }
  9359. for (i in names) {
  9360. if (names.hasOwnProperty(i)) {
  9361. item = names[i];
  9362. if (!is.hasOwnProperty(name)) {
  9363. this.setFlag(item, (name === item));
  9364. }
  9365. }
  9366. }
  9367. if (this.name === "iOS" && window.screen.height === 568) {
  9368. this.setFlag('iPhone5');
  9369. }
  9370. if (browserScope.is.Safari || browserScope.is.Silk) {
  9371. if (this.is.Android2 || this.is.Android3 || browserScope.version.shortVersion === 501) {
  9372. browserScope.setFlag("AndroidStock");
  9373. }
  9374. if (this.is.Android4) {
  9375. browserScope.setFlag("AndroidStock");
  9376. browserScope.setFlag("AndroidStock4");
  9377. }
  9378. }
  9379. };
  9380. Ext.env.OS.prototype = {
  9381. constructor: Ext.env.OS,
  9382. is: function(name) {
  9383. return !!this[name];
  9384. },
  9385. name: null,
  9386. version: null,
  9387. setFlag: function(name, value) {
  9388. if (value === undefined) {
  9389. value = true;
  9390. }
  9391. if (this.flags) {
  9392. this.flags[name] = value;
  9393. }
  9394. this.is[name] = value;
  9395. this.is[name.toLowerCase()] = value;
  9396. return this;
  9397. }
  9398. };
  9399. (function() {
  9400. var navigation = Ext.global.navigator,
  9401. userAgent = navigation.userAgent,
  9402. OS = Ext.env.OS,
  9403. is = (Ext.is || (Ext.is = {})),
  9404. osEnv, osName, deviceType;
  9405. OS.prototype.flags = is;
  9406. Ext.os = osEnv = new OS(userAgent, navigation.platform);
  9407. osName = osEnv.name;
  9408. Ext['is' + osName] = true;
  9409. Ext.isMac = is.Mac = is.MacOS;
  9410. Ext.isApple = Ext.isMac || Ext.isiOS;
  9411. var search = window.location.search.match(/deviceType=(Tablet|Phone)/),
  9412. nativeDeviceType = window.deviceType;
  9413. if (search && search[1]) {
  9414. deviceType = search[1];
  9415. } else if (nativeDeviceType === 'iPhone') {
  9416. deviceType = 'Phone';
  9417. } else if (nativeDeviceType === 'iPad') {
  9418. deviceType = 'Tablet';
  9419. } else {
  9420. if (!osEnv.is.Android && !osEnv.is.iOS && !osEnv.is.WindowsPhone && /Windows|Linux|MacOS|ChromeOS/.test(osName)) {
  9421. deviceType = 'Desktop';
  9422. Ext.browser.is.WebView = !!Ext.browser.is.Ripple;
  9423. } else if (osEnv.is.iPad || osEnv.is.RIMTablet || osEnv.is.Android3 || Ext.browser.is.Silk || (osEnv.is.Android && userAgent.search(/mobile/i) === -1)) {
  9424. deviceType = 'Tablet';
  9425. } else {
  9426. deviceType = 'Phone';
  9427. }
  9428. }
  9429. osEnv.setFlag(deviceType, true);
  9430. osEnv.deviceType = deviceType;
  9431. delete OS.prototype.flags;
  9432. }());
  9433. Ext.feature = {
  9434. has: function(name) {
  9435. return !!this.has[name];
  9436. },
  9437. testElements: {},
  9438. getTestElement: function(tag, createNew) {
  9439. if (tag === undefined) {
  9440. tag = 'div';
  9441. } else if (typeof tag !== 'string') {
  9442. return tag;
  9443. }
  9444. if (createNew) {
  9445. return document.createElement(tag);
  9446. }
  9447. if (!this.testElements[tag]) {
  9448. this.testElements[tag] = document.createElement(tag);
  9449. }
  9450. return this.testElements[tag];
  9451. },
  9452. isStyleSupported: function(name, tag) {
  9453. var elementStyle = this.getTestElement(tag).style,
  9454. cName = Ext.String.capitalize(name);
  9455. if (typeof elementStyle[name] !== 'undefined' || typeof elementStyle[Ext.browser.getStylePrefix(name) + cName] !== 'undefined') {
  9456. return true;
  9457. }
  9458. return false;
  9459. },
  9460. isStyleSupportedWithoutPrefix: function(name, tag) {
  9461. var elementStyle = this.getTestElement(tag).style;
  9462. if (typeof elementStyle[name] !== 'undefined') {
  9463. return true;
  9464. }
  9465. return false;
  9466. },
  9467. isEventSupported: function(name, tag) {
  9468. if (tag === undefined) {
  9469. tag = window;
  9470. }
  9471. var element = this.getTestElement(tag),
  9472. eventName = 'on' + name.toLowerCase(),
  9473. isSupported = (eventName in element);
  9474. if (!isSupported) {
  9475. if (element.setAttribute && element.removeAttribute) {
  9476. element.setAttribute(eventName, '');
  9477. isSupported = typeof element[eventName] === 'function';
  9478. if (typeof element[eventName] !== 'undefined') {
  9479. element[eventName] = undefined;
  9480. }
  9481. element.removeAttribute(eventName);
  9482. }
  9483. }
  9484. return isSupported;
  9485. },
  9486. getStyle: function(element, styleName) {
  9487. var view = element.ownerDocument.defaultView,
  9488. style = (view ? view.getComputedStyle(element, null) : element.currentStyle);
  9489. return (style || element.style)[styleName];
  9490. },
  9491. getSupportedPropertyName: function(object, name) {
  9492. var vendorName = Ext.browser.getVendorProperyName(name);
  9493. if (vendorName in object) {
  9494. return vendorName;
  9495. } else if (name in object) {
  9496. return name;
  9497. }
  9498. return null;
  9499. },
  9500. detect: function(isReady) {
  9501. var me = this,
  9502. doc = document,
  9503. toRun = me.toRun || me.tests,
  9504. n = toRun.length,
  9505. div = doc.createElement('div'),
  9506. notRun = [],
  9507. supports = Ext.supports,
  9508. has = me.has,
  9509. name, names, test, vector, value;
  9510. div.innerHTML = '<div style="height:30px;width:50px;">' + '<div style="height:20px;width:20px;"></div>' + '</div>' + '<div style="width: 200px; height: 200px; position: relative; padding: 5px;">' + '<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>' +
  9511. '</div>' + '<div style="position: absolute; left: 10%; top: 10%;"></div>' + '<div style="float:left; background-color:transparent;"></div>';
  9512. if (isReady) {
  9513. doc.body.appendChild(div);
  9514. }
  9515. vector = me.preDetected[Ext.browser.identity] || [];
  9516. while (n--) {
  9517. test = toRun[n];
  9518. value = vector[n];
  9519. name = test.name;
  9520. names = test.names;
  9521. if (value === undefined) {
  9522. if (!isReady && test.ready) {
  9523. notRun.push(test);
  9524. continue;
  9525. }
  9526. value = test.fn.call(me, doc, div);
  9527. }
  9528. if (name) {
  9529. supports[name] = has[name] = value;
  9530. } else if (names) {
  9531. while (names.length) {
  9532. name = names.pop();
  9533. supports[name] = has[name] = value;
  9534. }
  9535. }
  9536. }
  9537. if (isReady) {
  9538. doc.body.removeChild(div);
  9539. }
  9540. me.toRun = notRun;
  9541. },
  9542. report: function() {
  9543. var values = [],
  9544. len = this.tests.length,
  9545. i;
  9546. for (i = 0; i < len; ++i) {
  9547. values.push(this.has[this.tests[i].name] ? 1 : 0);
  9548. }
  9549. Ext.log(Ext.browser.identity + ': [' + values.join(',') + ']');
  9550. },
  9551. preDetected: {},
  9552. tests: [
  9553. {
  9554. name: 'CloneNodeCopiesExpando',
  9555. fn: function() {
  9556. var el = document.createElement('div');
  9557. el.expandoProp = {};
  9558. return el.cloneNode().expandoProp === el.expandoProp;
  9559. }
  9560. },
  9561. {
  9562. name: 'CSSPointerEvents',
  9563. fn: function(doc) {
  9564. return 'pointerEvents' in doc.documentElement.style;
  9565. }
  9566. },
  9567. {
  9568. name: 'CSS3BoxShadow',
  9569. fn: function(doc) {
  9570. return 'boxShadow' in doc.documentElement.style || 'WebkitBoxShadow' in doc.documentElement.style || 'MozBoxShadow' in doc.documentElement.style;
  9571. }
  9572. },
  9573. {
  9574. name: 'CSS3NegationSelector',
  9575. fn: function(doc) {
  9576. try {
  9577. doc.querySelectorAll("foo:not(bar)");
  9578. } catch (e) {
  9579. return false;
  9580. }
  9581. return true;
  9582. }
  9583. },
  9584. {
  9585. name: 'ClassList',
  9586. fn: function(doc) {
  9587. return !!doc.documentElement.classList;
  9588. }
  9589. },
  9590. {
  9591. name: 'Canvas',
  9592. fn: function() {
  9593. var element = this.getTestElement('canvas');
  9594. return !!(element && element.getContext && element.getContext('2d'));
  9595. }
  9596. },
  9597. {
  9598. name: 'Svg',
  9599. fn: function(doc) {
  9600. return !!(doc.createElementNS && !!doc.createElementNS("http:/" + "/www.w3.org/2000/svg", "svg").createSVGRect);
  9601. }
  9602. },
  9603. {
  9604. name: 'Vml',
  9605. fn: function() {
  9606. var element = this.getTestElement(),
  9607. ret = false;
  9608. element.innerHTML = "<!--[if vml]><br><![endif]-->";
  9609. ret = (element.childNodes.length === 1);
  9610. element.innerHTML = "";
  9611. return ret;
  9612. }
  9613. },
  9614. {
  9615. name: 'Touch',
  9616. fn: function() {
  9617. var maxTouchPoints = navigator.msMaxTouchPoints || navigator.maxTouchPoints;
  9618. if (Ext.browser.is.Chrome && Ext.browser.version.isLessThanOrEqual(39)) {
  9619. return (Ext.supports.TouchEvents && maxTouchPoints !== 1) || maxTouchPoints > 1;
  9620. } else {
  9621. return Ext.supports.TouchEvents || maxTouchPoints > 0;
  9622. }
  9623. }
  9624. },
  9625. {
  9626. name: 'PointerEvents',
  9627. fn: function() {
  9628. var pointerEvent = window.PointerEvent,
  9629. nav = window.navigator,
  9630. pointerEnabled = !!(pointerEvent && (nav.pointerEnabled || !Ext.isIE));
  9631. return pointerEnabled && !Ext.supports.TouchEvents;
  9632. }
  9633. },
  9634. {
  9635. name: 'MSPointerEvents',
  9636. fn: function() {
  9637. return Ext.isIE10;
  9638. }
  9639. },
  9640. {
  9641. name: 'TouchEvents',
  9642. fn: function() {
  9643. return this.isEventSupported('touchend');
  9644. }
  9645. },
  9646. {
  9647. name: 'TouchAction',
  9648. ready: true,
  9649. fn: function(doc, div) {
  9650. if (!window.getComputedStyle) {
  9651. return 0;
  9652. }
  9653. var values = [
  9654. 'pan-x',
  9655. 'pan-y',
  9656. 'pinch-zoom',
  9657. 'double-tap-zoom'
  9658. ],
  9659. flags = [
  9660. 1,
  9661. 2,
  9662. 4,
  9663. 8
  9664. ],
  9665. ln = values.length,
  9666. flag = 0,
  9667. i, value;
  9668. for (i = 0; i < ln; i++) {
  9669. value = values[i];
  9670. div.style.touchAction = value;
  9671. if (getComputedStyle(div).touchAction === value) {
  9672. flag |= flags[i];
  9673. }
  9674. }
  9675. return flag;
  9676. }
  9677. },
  9678. {
  9679. name: 'Orientation',
  9680. fn: function() {
  9681. return ('orientation' in window) && this.isEventSupported('orientationchange');
  9682. }
  9683. },
  9684. {
  9685. name: 'OrientationChange',
  9686. fn: function() {
  9687. return this.isEventSupported('orientationchange');
  9688. }
  9689. },
  9690. {
  9691. name: 'DeviceMotion',
  9692. fn: function() {
  9693. return this.isEventSupported('devicemotion');
  9694. }
  9695. },
  9696. {
  9697. names: [
  9698. 'Geolocation',
  9699. 'GeoLocation'
  9700. ],
  9701. fn: function() {
  9702. return 'geolocation' in window.navigator;
  9703. }
  9704. },
  9705. {
  9706. name: 'SqlDatabase',
  9707. fn: function() {
  9708. return 'openDatabase' in window;
  9709. }
  9710. },
  9711. {
  9712. name: 'WebSockets',
  9713. fn: function() {
  9714. return 'WebSocket' in window;
  9715. }
  9716. },
  9717. {
  9718. name: 'Range',
  9719. fn: function() {
  9720. return !!document.createRange;
  9721. }
  9722. },
  9723. {
  9724. name: 'CreateContextualFragment',
  9725. fn: function() {
  9726. var range = !!document.createRange ? document.createRange() : false;
  9727. return range && !!range.createContextualFragment;
  9728. }
  9729. },
  9730. {
  9731. name: 'History',
  9732. fn: function() {
  9733. return ('history' in window && 'pushState' in window.history);
  9734. }
  9735. },
  9736. {
  9737. name: 'Css3dTransforms',
  9738. fn: function() {
  9739. return this.has('CssTransforms') && this.isStyleSupported('perspective');
  9740. }
  9741. },
  9742. {
  9743. name: 'CssTransforms',
  9744. fn: function() {
  9745. return this.isStyleSupported('transform');
  9746. }
  9747. },
  9748. {
  9749. name: 'CssTransformNoPrefix',
  9750. fn: function() {
  9751. return this.isStyleSupportedWithoutPrefix('transform');
  9752. }
  9753. },
  9754. {
  9755. name: 'CssAnimations',
  9756. fn: function() {
  9757. return this.isStyleSupported('animationName');
  9758. }
  9759. },
  9760. {
  9761. names: [
  9762. 'CssTransitions',
  9763. 'Transitions'
  9764. ],
  9765. fn: function() {
  9766. return this.isStyleSupported('transitionProperty');
  9767. }
  9768. },
  9769. {
  9770. names: [
  9771. 'Audio',
  9772. 'AudioTag'
  9773. ],
  9774. fn: function() {
  9775. return !!this.getTestElement('audio').canPlayType;
  9776. }
  9777. },
  9778. {
  9779. name: 'Video',
  9780. fn: function() {
  9781. return !!this.getTestElement('video').canPlayType;
  9782. }
  9783. },
  9784. {
  9785. name: 'LocalStorage',
  9786. fn: function() {
  9787. try {
  9788. if ('localStorage' in window && window['localStorage'] !== null) {
  9789. localStorage.setItem('sencha-localstorage-test', 'test success');
  9790. localStorage.removeItem('sencha-localstorage-test');
  9791. return true;
  9792. }
  9793. } catch (e) {}
  9794. return false;
  9795. }
  9796. },
  9797. {
  9798. name: 'XmlQuerySelector',
  9799. fn: function() {
  9800. var xmlString = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><root></root>',
  9801. xmlDoc;
  9802. if (window.ActiveXObject) {
  9803. xmlDoc = new ActiveXObject("Microsoft.xmlDOM");
  9804. xmlDoc.async = false;
  9805. xmlDoc.loadXML(xmlString);
  9806. } else if (window.DOMParser) {
  9807. var parser = new DOMParser();
  9808. xmlDoc = parser.parseFromString(xmlString, 'text/xml');
  9809. }
  9810. return xmlDoc ? !!xmlDoc.lastChild.querySelector : false;
  9811. }
  9812. },
  9813. {
  9814. name: 'XHR2',
  9815. fn: function() {
  9816. return window.ProgressEvent && window.FormData && window.XMLHttpRequest && ('withCredentials' in new XMLHttpRequest());
  9817. }
  9818. },
  9819. {
  9820. name: 'XHRUploadProgress',
  9821. fn: function() {
  9822. var xhr;
  9823. if (window.XMLHttpRequest && !Ext.browser.is.AndroidStock) {
  9824. xhr = new XMLHttpRequest();
  9825. return xhr && ('upload' in xhr) && ('onprogress' in xhr.upload);
  9826. }
  9827. return false;
  9828. }
  9829. },
  9830. {
  9831. name: 'NumericInputPlaceHolder',
  9832. fn: function() {
  9833. return !(Ext.browser.is.AndroidStock4 && Ext.os.version.getMinor() < 2);
  9834. }
  9835. },
  9836. {
  9837. name: 'matchesSelector',
  9838. fn: function() {
  9839. var el = document.documentElement,
  9840. w3 = 'matches',
  9841. wk = 'webkitMatchesSelector',
  9842. ms = 'msMatchesSelector',
  9843. mz = 'mozMatchesSelector';
  9844. return el[w3] ? w3 : el[wk] ? wk : el[ms] ? ms : el[mz] ? mz : null;
  9845. }
  9846. },
  9847. {
  9848. name: 'RightMargin',
  9849. ready: true,
  9850. fn: function(doc, div) {
  9851. var view = doc.defaultView;
  9852. return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight !== '0px');
  9853. }
  9854. },
  9855. {
  9856. name: 'DisplayChangeInputSelectionBug',
  9857. fn: function() {
  9858. var webKitVersion = Ext.webKitVersion;
  9859. return 0 < webKitVersion && webKitVersion < 533;
  9860. }
  9861. },
  9862. {
  9863. name: 'DisplayChangeTextAreaSelectionBug',
  9864. fn: function() {
  9865. var webKitVersion = Ext.webKitVersion;
  9866. return 0 < webKitVersion && webKitVersion < 534.24;
  9867. }
  9868. },
  9869. {
  9870. name: 'TransparentColor',
  9871. ready: true,
  9872. fn: function(doc, div, view) {
  9873. view = doc.defaultView;
  9874. return !(view && view.getComputedStyle(div.lastChild, null).backgroundColor !== 'transparent');
  9875. }
  9876. },
  9877. {
  9878. name: 'ComputedStyle',
  9879. ready: true,
  9880. fn: function(doc, div, view) {
  9881. view = doc.defaultView;
  9882. return !!(view && view.getComputedStyle);
  9883. }
  9884. },
  9885. {
  9886. name: 'Float',
  9887. fn: function(doc) {
  9888. return 'cssFloat' in doc.documentElement.style;
  9889. }
  9890. },
  9891. {
  9892. name: 'CSS3BorderRadius',
  9893. ready: true,
  9894. fn: function(doc) {
  9895. var domPrefixes = [
  9896. 'borderRadius',
  9897. 'BorderRadius',
  9898. 'MozBorderRadius',
  9899. 'WebkitBorderRadius',
  9900. 'OBorderRadius',
  9901. 'KhtmlBorderRadius'
  9902. ],
  9903. pass = false,
  9904. i;
  9905. for (i = 0; i < domPrefixes.length; i++) {
  9906. if (doc.documentElement.style[domPrefixes[i]] !== undefined) {
  9907. pass = true;
  9908. }
  9909. }
  9910. return pass && !Ext.isIE9;
  9911. }
  9912. },
  9913. {
  9914. name: 'CSS3LinearGradient',
  9915. fn: function(doc, div) {
  9916. var property = 'background-image:',
  9917. webkit = '-webkit-gradient(linear, left top, right bottom, from(black), to(white))',
  9918. w3c = 'linear-gradient(left top, black, white)',
  9919. moz = '-moz-' + w3c,
  9920. ms = '-ms-' + w3c,
  9921. opera = '-o-' + w3c,
  9922. options = [
  9923. property + webkit,
  9924. property + w3c,
  9925. property + moz,
  9926. property + ms,
  9927. property + opera
  9928. ];
  9929. div.style.cssText = options.join(';');
  9930. return (("" + div.style.backgroundImage).indexOf('gradient') !== -1) && !Ext.isIE9;
  9931. }
  9932. },
  9933. {
  9934. name: 'MouseEnterLeave',
  9935. fn: function(doc) {
  9936. return ('onmouseenter' in doc.documentElement && 'onmouseleave' in doc.documentElement);
  9937. }
  9938. },
  9939. {
  9940. name: 'MouseWheel',
  9941. fn: function(doc) {
  9942. return ('onmousewheel' in doc.documentElement);
  9943. }
  9944. },
  9945. {
  9946. name: 'Opacity',
  9947. fn: function(doc, div) {
  9948. if (Ext.isIE8) {
  9949. return false;
  9950. }
  9951. div.firstChild.style.cssText = 'opacity:0.73';
  9952. return div.firstChild.style.opacity == '0.73';
  9953. }
  9954. },
  9955. {
  9956. name: 'Placeholder',
  9957. fn: function(doc) {
  9958. return 'placeholder' in doc.createElement('input');
  9959. }
  9960. },
  9961. {
  9962. name: 'Direct2DBug',
  9963. fn: function(doc) {
  9964. return Ext.isString(doc.documentElement.style.msTransformOrigin) && Ext.isIE9m;
  9965. }
  9966. },
  9967. {
  9968. name: 'BoundingClientRect',
  9969. fn: function(doc) {
  9970. return 'getBoundingClientRect' in doc.documentElement;
  9971. }
  9972. },
  9973. {
  9974. name: 'RotatedBoundingClientRect',
  9975. ready: true,
  9976. fn: function(doc) {
  9977. var body = doc.body,
  9978. supports = false,
  9979. el = doc.createElement('div'),
  9980. style = el.style;
  9981. if (el.getBoundingClientRect) {
  9982. style.position = 'absolute';
  9983. style.top = "0";
  9984. style.WebkitTransform = style.MozTransform = style.msTransform = style.OTransform = style.transform = 'rotate(90deg)';
  9985. style.width = '100px';
  9986. style.height = '30px';
  9987. body.appendChild(el);
  9988. supports = el.getBoundingClientRect().height !== 100;
  9989. body.removeChild(el);
  9990. }
  9991. return supports;
  9992. }
  9993. },
  9994. {
  9995. name: 'ChildContentClearedWhenSettingInnerHTML',
  9996. ready: true,
  9997. fn: function() {
  9998. var el = this.getTestElement(),
  9999. child;
  10000. el.innerHTML = '<div>a</div>';
  10001. child = el.firstChild;
  10002. el.innerHTML = '<div>b</div>';
  10003. return child.innerHTML !== 'a';
  10004. }
  10005. },
  10006. {
  10007. name: 'IncludePaddingInWidthCalculation',
  10008. ready: true,
  10009. fn: function(doc, div) {
  10010. return div.childNodes[1].firstChild.offsetWidth === 210;
  10011. }
  10012. },
  10013. {
  10014. name: 'IncludePaddingInHeightCalculation',
  10015. ready: true,
  10016. fn: function(doc, div) {
  10017. return div.childNodes[1].firstChild.offsetHeight === 210;
  10018. }
  10019. },
  10020. {
  10021. name: 'TextAreaMaxLength',
  10022. fn: function(doc) {
  10023. return ('maxlength' in doc.createElement('textarea'));
  10024. }
  10025. },
  10026. {
  10027. name: 'GetPositionPercentage',
  10028. ready: true,
  10029. fn: function(doc, div) {
  10030. return Ext.feature.getStyle(div.childNodes[2], 'left') === '10%';
  10031. }
  10032. },
  10033. {
  10034. name: 'PercentageHeightOverflowBug',
  10035. ready: true,
  10036. fn: function(doc) {
  10037. var hasBug = false,
  10038. style, el;
  10039. if (Ext.getScrollbarSize().height) {
  10040. el = this.getTestElement('div', true);
  10041. style = el.style;
  10042. style.height = '50px';
  10043. style.width = '50px';
  10044. style.overflow = 'auto';
  10045. style.position = 'absolute';
  10046. el.innerHTML = [
  10047. '<div style="display:table;height:100%;">',
  10048. '<div style="width:51px;"></div>',
  10049. '</div>'
  10050. ].join('');
  10051. doc.body.appendChild(el);
  10052. if (el.firstChild.offsetHeight === 50) {
  10053. hasBug = true;
  10054. }
  10055. doc.body.removeChild(el);
  10056. }
  10057. return hasBug;
  10058. }
  10059. },
  10060. {
  10061. name: 'xOriginBug',
  10062. ready: true,
  10063. fn: function(doc, div) {
  10064. div.innerHTML = '<div id="b1" style="height:100px;width:100px;direction:rtl;position:relative;overflow:scroll">' + '<div id="b2" style="position:relative;width:100%;height:20px;"></div>' + '<div id="b3" style="position:absolute;width:20px;height:20px;top:0px;right:0px"></div>' + '</div>';
  10065. var outerBox = document.getElementById('b1').getBoundingClientRect(),
  10066. b2 = document.getElementById('b2').getBoundingClientRect(),
  10067. b3 = document.getElementById('b3').getBoundingClientRect();
  10068. return (b2.left !== outerBox.left && b3.right !== outerBox.right);
  10069. }
  10070. },
  10071. {
  10072. name: 'ScrollWidthInlinePaddingBug',
  10073. ready: true,
  10074. fn: function(doc) {
  10075. var hasBug = false,
  10076. style, el;
  10077. el = doc.createElement('div');
  10078. style = el.style;
  10079. style.height = '50px';
  10080. style.width = '50px';
  10081. style.padding = '10px';
  10082. style.overflow = 'hidden';
  10083. style.position = 'absolute';
  10084. el.innerHTML = '<span style="display:inline-block;zoom:1;height:60px;width:60px;"></span>';
  10085. doc.body.appendChild(el);
  10086. if (el.scrollWidth === 70) {
  10087. hasBug = true;
  10088. }
  10089. doc.body.removeChild(el);
  10090. return hasBug;
  10091. }
  10092. },
  10093. {
  10094. name: 'rtlVertScrollbarOnRight',
  10095. ready: true,
  10096. fn: function(doc, div) {
  10097. div.innerHTML = '<div style="height:100px;width:100px;direction:rtl;overflow:scroll">' + '<div style="width:20px;height:200px;"></div>' + '</div>';
  10098. var outerBox = div.firstChild,
  10099. innerBox = outerBox.firstChild;
  10100. return (innerBox.offsetLeft + innerBox.offsetWidth !== outerBox.offsetLeft + outerBox.offsetWidth);
  10101. }
  10102. },
  10103. {
  10104. name: 'rtlVertScrollbarOverflowBug',
  10105. ready: true,
  10106. fn: function(doc, div) {
  10107. div.innerHTML = '<div style="height:100px;width:100px;direction:rtl;overflow:auto">' + '<div style="width:95px;height:200px;"></div>' + '</div>';
  10108. var outerBox = div.firstChild,
  10109. style = div.style,
  10110. pos = style.position;
  10111. style.position = 'absolute';
  10112. outerBox.offsetHeight;
  10113. style.position = pos;
  10114. return outerBox.clientHeight === outerBox.offsetHeight;
  10115. }
  10116. },
  10117. {
  10118. identity: 'defineProperty',
  10119. fn: function() {
  10120. if (Ext.isIE8m) {
  10121. Ext.Object.defineProperty = Ext.emptyFn;
  10122. return false;
  10123. }
  10124. return true;
  10125. }
  10126. },
  10127. {
  10128. identify: 'nativeXhr',
  10129. fn: function() {
  10130. if (typeof XMLHttpRequest !== 'undefined') {
  10131. return true;
  10132. }
  10133. XMLHttpRequest = function() {
  10134. try {
  10135. return new ActiveXObject('MSXML2.XMLHTTP.3.0');
  10136. } catch (ex) {
  10137. return null;
  10138. }
  10139. };
  10140. return false;
  10141. }
  10142. },
  10143. {
  10144. name: 'SpecialKeyDownRepeat',
  10145. fn: function() {
  10146. return Ext.isWebKit ? parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 : !(!(Ext.isGecko || Ext.isIE || Ext.isEdge) || (Ext.isOpera && Ext.operaVersion < 12));
  10147. }
  10148. },
  10149. {
  10150. name: 'EmulatedMouseOver',
  10151. fn: function() {
  10152. return Ext.os.is.iOS;
  10153. }
  10154. },
  10155. {
  10156. name: 'Hashchange',
  10157. fn: function() {
  10158. var docMode = document.documentMode;
  10159. return 'onhashchange' in window && (docMode === undefined || docMode > 7);
  10160. }
  10161. },
  10162. {
  10163. name: 'FixedTableWidthBug',
  10164. ready: true,
  10165. fn: function() {
  10166. if (Ext.isIE8) {
  10167. return false;
  10168. }
  10169. var outer = document.createElement('div'),
  10170. inner = document.createElement('div'),
  10171. width;
  10172. outer.setAttribute('style', 'display:table;table-layout:fixed;');
  10173. inner.setAttribute('style', 'display:table-cell;min-width:50px;');
  10174. outer.appendChild(inner);
  10175. document.body.appendChild(outer);
  10176. outer.offsetWidth;
  10177. outer.style.width = '25px';
  10178. width = outer.offsetWidth;
  10179. document.body.removeChild(outer);
  10180. return width === 50;
  10181. }
  10182. },
  10183. {
  10184. name: 'FocusinFocusoutEvents',
  10185. fn: function() {
  10186. return !(Ext.isGecko && Ext.firefoxVersion < 52);
  10187. }
  10188. },
  10189. {
  10190. name: 'AsyncFocusEvents',
  10191. fn: function() {
  10192. return Ext.asyncFocus = !!Ext.isIE;
  10193. }
  10194. },
  10195. {
  10196. name: 'accessibility',
  10197. ready: true,
  10198. fn: function(doc) {
  10199. var body = doc.body,
  10200. div, img, style, supports, bgImg;
  10201. function getColor(colorTxt) {
  10202. var values = [],
  10203. colorValue = 0,
  10204. regex, match;
  10205. if (colorTxt.indexOf('rgb(') !== -1) {
  10206. values = colorTxt.replace('rgb(', '').replace(')', '').split(', ');
  10207. } else if (colorTxt.indexOf('#') !== -1) {
  10208. regex = colorTxt.length === 7 ? /^#(\S\S)(\S\S)(\S\S)$/ : /^#(\S)(\S)(\S)$/;
  10209. match = colorTxt.match(regex);
  10210. if (match) {
  10211. values = [
  10212. '0x' + match[1],
  10213. '0x' + match[2],
  10214. '0x' + match[3]
  10215. ];
  10216. }
  10217. }
  10218. for (var i = 0; i < values.length; i++) {
  10219. colorValue += parseInt(values[i]);
  10220. }
  10221. return colorValue;
  10222. }
  10223. div = doc.createElement('div');
  10224. img = doc.createElement('img');
  10225. style = div.style;
  10226. Ext.apply(style, {
  10227. width: '2px',
  10228. position: 'absolute',
  10229. clip: 'rect(1px,1px,1px,1px)',
  10230. borderWidth: '1px',
  10231. borderStyle: 'solid',
  10232. borderTopTolor: '#f00',
  10233. borderRightColor: '#ff0',
  10234. backgroundColor: '#fff',
  10235. backgroundImage: 'url(' + Ext.BLANK_IMAGE_URL + ')'
  10236. });
  10237. img.alt = '';
  10238. img.src = Ext.BLANK_IMAGE_URL;
  10239. div.appendChild(img);
  10240. body.appendChild(div);
  10241. style = div.currentStyle || div.style;
  10242. bgImg = style.backgroundImage;
  10243. supports = {
  10244. Images: img.offsetWidth === 1 && img.readyState !== 'uninitialized',
  10245. BackgroundImages: !(bgImg !== null && (bgImg === "none" || bgImg === "url(invalid-url:)")),
  10246. BorderColors: style.borderTopColor !== style.borderRightColor,
  10247. LightOnDark: getColor(style.color) - getColor(style.backgroundColor) > 0
  10248. };
  10249. Ext.supports.HighContrastMode = !supports.BackgroundImages;
  10250. body.removeChild(div);
  10251. div = img = null;
  10252. return supports;
  10253. }
  10254. },
  10255. {
  10256. name: 'ViewportUnits',
  10257. ready: true,
  10258. fn: function(doc) {
  10259. if (Ext.isIE8) {
  10260. return false;
  10261. }
  10262. var body = doc.body,
  10263. div = document.createElement('div'),
  10264. style = div.currentStyle || div.style,
  10265. width, divWidth;
  10266. body.appendChild(div);
  10267. Ext.apply(style, {
  10268. width: '50vw'
  10269. });
  10270. width = parseInt(window.innerWidth / 2, 10);
  10271. divWidth = parseInt((window.getComputedStyle ? getComputedStyle(div, null) : div.currentStyle).width, 10);
  10272. body.removeChild(div);
  10273. div = null;
  10274. return width === divWidth;
  10275. }
  10276. },
  10277. {
  10278. name: 'CSSVariables',
  10279. ready: false,
  10280. fn: function() {
  10281. if (!window.getComputedStyle) {
  10282. return false;
  10283. }
  10284. return window.CSS && window.CSS.supports && window.CSS.supports('--test-var', 0);
  10285. }
  10286. },
  10287. {
  10288. name: 'Selectors2',
  10289. ready: false,
  10290. fn: function(doc) {
  10291. try {
  10292. return !!doc.querySelectorAll(':scope');
  10293. } catch (e) {
  10294. return false;
  10295. }
  10296. }
  10297. },
  10298. {
  10299. name: 'CSSScrollSnap',
  10300. ready: false,
  10301. fn: function(doc) {
  10302. var style = doc.documentElement.style;
  10303. return 'scrollSnapType' in style || 'webkitScrollSnapType' in style || 'msScrollSnapType' in style;
  10304. }
  10305. },
  10306. {
  10307. name: 'TranslateYCausesHorizontalScroll',
  10308. ready: true,
  10309. fn: function(doc, div) {
  10310. div.innerHTML = '<div style="position: relative; overflow: auto; height: 200px; width: 200px;">' +
  10311. '<div>' + '<div style="transform: translateY(260px); width: 50px;">a</div>' + '</div>' + '</div>';
  10312. return div.firstChild.scrollWidth > div.firstChild.clientWidth;
  10313. }
  10314. },
  10315. {
  10316. name: 'FlexBoxBasisBug',
  10317. ready: true,
  10318. fn: function() {
  10319. if (Ext.isIE11 || (Ext.os.is.iOS && Ext.os.version.major <= 10) || (Ext.isSafari && Ext.browser.version.isLessThan(11)) || (Ext.os.is.Android && Ext.os.version.isLessThan(6))) {
  10320. return true;
  10321. }
  10322. return false;
  10323. }
  10324. },
  10325. {
  10326. name: 'PercentageSizeFlexBug',
  10327. ready: true,
  10328. fn: function(doc, div) {
  10329. if (Ext.isIE9m) {
  10330. return false;
  10331. }
  10332. var style = div.style;
  10333. style.display = 'flex';
  10334. style.flexDirection = 'column';
  10335. style.height = style.width = '100px';
  10336. div.innerHTML = '<div style="flex: 1 1;"><div style="height:50%"></div></div>';
  10337. return div.firstChild.firstChild.offsetHeight !== 50;
  10338. }
  10339. },
  10340. {
  10341. name: 'CannotScrollExactHeight',
  10342. fn: function() {
  10343. return Ext.isIE10p;
  10344. }
  10345. },
  10346. {
  10347. name: 'WebKitInputTableBoxModelBug',
  10348. ready: true,
  10349. fn: function(doc, div) {
  10350. var table = document.createElement('div'),
  10351. cell = document.createElement('div'),
  10352. input = document.createElement('input'),
  10353. tableStyle = table.style,
  10354. cellStyle = cell.style,
  10355. inputStyle = input.style,
  10356. body = doc.body,
  10357. hasBug;
  10358. input.type = 'text';
  10359. tableStyle.display = 'table';
  10360. tableStyle.height = '100px';
  10361. cellStyle.display = 'table-cell';
  10362. inputStyle.border = '0';
  10363. inputStyle.padding = '10px';
  10364. inputStyle.boxSizing = 'border-box';
  10365. inputStyle.height = '100%';
  10366. cell.appendChild(input);
  10367. table.appendChild(cell);
  10368. body.appendChild(table);
  10369. hasBug = input.offsetHeight === 80;
  10370. body.removeChild(table);
  10371. return hasBug;
  10372. }
  10373. },
  10374. {
  10375. name: 'PassiveEventListener',
  10376. fn: function(doc, div) {
  10377. var supportsPassive = false,
  10378. options;
  10379. try {
  10380. options = Object.defineProperty({}, 'passive', {
  10381. get: function() {
  10382. supportsPassive = true;
  10383. }
  10384. });
  10385. window.addEventListener('e', null, options);
  10386. window.removeEventListener('e', null, options);
  10387. } catch (e) {}
  10388. return supportsPassive;
  10389. }
  10390. },
  10391. {
  10392. name: 'CSSMinContent',
  10393. ready: true,
  10394. fn: function(doc, div) {
  10395. div.innerHTML = '<div style="height:4px;width:4px;min-height:-webkit-min-content;min-height:-moz-min-content;min-height:min-content"><div style="height:8px;width:8px"></div></div>';
  10396. return div.firstChild.offsetHeight === 8;
  10397. }
  10398. },
  10399. {
  10400. name: 'ComputedSizeIncludesPadding',
  10401. ready: true,
  10402. fn: function(doc, div) {
  10403. var ret = false,
  10404. bd = document.body,
  10405. el, w;
  10406. if (window.getComputedStyle) {
  10407. el = document.createElement('div');
  10408. el.style.cssText = 'width:10px;padding:2px;' + '-webkit-box-sizing:border-box;box-sizing:border-box;';
  10409. bd.appendChild(el);
  10410. w = window.getComputedStyle(el, null).width;
  10411. ret = w === '10px';
  10412. bd.removeChild(el);
  10413. }
  10414. return ret;
  10415. }
  10416. },
  10417. {
  10418. name: 'inputEventData',
  10419. ready: false,
  10420. fn: function() {
  10421. return !!(window.InputEvent && 'data' in new InputEvent('input'));
  10422. }
  10423. },
  10424. 0
  10425. ]
  10426. };
  10427. Ext.feature.tests.pop();
  10428. Ext.supports = {};
  10429. Ext.feature.detect();
  10430. Ext.env.Ready = {
  10431. blocks: (location.search || '').indexOf('ext-pauseReadyFire') > 0 ? 1 : 0,
  10432. bound: 0,
  10433. delay: 1,
  10434. events: [],
  10435. firing: false,
  10436. generation: 0,
  10437. listeners: [],
  10438. nextId: 0,
  10439. sortGeneration: 0,
  10440. state: 0,
  10441. timer: null,
  10442. bind: function() {
  10443. var me = Ext.env.Ready,
  10444. doc = document;
  10445. if (!me.bound) {
  10446. if (doc.readyState === 'complete') {
  10447. me.onReadyEvent({
  10448. type: doc.readyState || 'body'
  10449. });
  10450. } else {
  10451. me.bound = 1;
  10452. if (Ext.browser.is.PhoneGap && !Ext.os.is.Desktop) {
  10453. me.bound = 2;
  10454. doc.addEventListener('deviceready', me.onReadyEvent, false);
  10455. }
  10456. doc.addEventListener('DOMContentLoaded', me.onReadyEvent, false);
  10457. window.addEventListener('load', me.onReadyEvent, false);
  10458. }
  10459. }
  10460. },
  10461. block: function() {
  10462. ++this.blocks;
  10463. Ext.isReady = false;
  10464. },
  10465. fireReady: function() {
  10466. var me = Ext.env.Ready;
  10467. if (!me.state) {
  10468. Ext._readyTime = Ext.ticks();
  10469. Ext.isDomReady = true;
  10470. me.state = 1;
  10471. Ext.feature.detect(true);
  10472. if (!me.delay) {
  10473. me.handleReady();
  10474. } else if (navigator.standalone) {
  10475. me.timer = Ext.defer(function() {
  10476. me.timer = null;
  10477. me.handleReadySoon();
  10478. }, 1);
  10479. } else {
  10480. me.handleReadySoon();
  10481. }
  10482. }
  10483. },
  10484. handleReady: function() {
  10485. var me = this;
  10486. if (me.state === 1) {
  10487. me.state = 2;
  10488. Ext._beforeReadyTime = Ext.ticks();
  10489. me.invokeAll();
  10490. Ext._afterReadyTime = Ext.ticks();
  10491. }
  10492. },
  10493. handleReadySoon: function(delay) {
  10494. var me = this;
  10495. if (!me.timer) {
  10496. me.timer = Ext.defer(function() {
  10497. me.timer = null;
  10498. me.handleReady();
  10499. }, delay || me.delay);
  10500. }
  10501. },
  10502. invoke: function(listener) {
  10503. var delay = listener.delay;
  10504. if (delay) {
  10505. Ext.defer(listener.fn, delay, listener.scope);
  10506. } else {
  10507. if (Ext.elevateFunction) {
  10508. Ext.elevateFunction(listener.fn, listener.scope);
  10509. } else {
  10510. listener.fn.call(listener.scope);
  10511. }
  10512. }
  10513. },
  10514. invokeAll: function() {
  10515. if (Ext.elevateFunction) {
  10516. Ext.elevateFunction(this.doInvokeAll, this);
  10517. } else {
  10518. this.doInvokeAll();
  10519. }
  10520. },
  10521. doInvokeAll: function() {
  10522. var me = this,
  10523. listeners = me.listeners,
  10524. listener;
  10525. if (!me.blocks) {
  10526. Ext.isReady = true;
  10527. }
  10528. me.firing = true;
  10529. while (listeners.length) {
  10530. if (me.sortGeneration !== me.generation) {
  10531. me.sortGeneration = me.generation;
  10532. listeners.sort(me.sortFn);
  10533. }
  10534. listener = listeners.pop();
  10535. if (me.blocks && !listener.dom) {
  10536. listeners.push(listener);
  10537. break;
  10538. }
  10539. me.invoke(listener);
  10540. }
  10541. me.firing = false;
  10542. },
  10543. makeListener: function(fn, scope, options) {
  10544. var ret = {
  10545. fn: fn,
  10546. id: ++this.nextId,
  10547. scope: scope,
  10548. dom: false,
  10549. priority: 0
  10550. };
  10551. if (options) {
  10552. Ext.apply(ret, options);
  10553. }
  10554. ret.phase = ret.dom ? 0 : 1;
  10555. return ret;
  10556. },
  10557. on: function(fn, scope, options) {
  10558. var me = Ext.env.Ready,
  10559. listener = me.makeListener(fn, scope, options);
  10560. if (me.state === 2 && !me.firing && (listener.dom || !me.blocks)) {
  10561. me.invoke(listener);
  10562. } else {
  10563. me.listeners.push(listener);
  10564. ++me.generation;
  10565. if (!me.bound) {
  10566. me.bind();
  10567. }
  10568. }
  10569. },
  10570. onReadyEvent: function(ev) {
  10571. var me = Ext.env.Ready;
  10572. if (Ext.elevateFunction) {
  10573. Ext.elevateFunction(me.doReadyEvent, me, arguments);
  10574. } else {
  10575. me.doReadyEvent(ev);
  10576. }
  10577. },
  10578. doReadyEvent: function(ev) {
  10579. var me = this;
  10580. if (ev && ev.type) {
  10581. me.events.push(ev);
  10582. }
  10583. if (me.bound > 0) {
  10584. me.unbind();
  10585. me.bound = -1;
  10586. }
  10587. if (!me.state) {
  10588. me.fireReady();
  10589. }
  10590. },
  10591. sortFn: function(a, b) {
  10592. return -((a.phase - b.phase) || (b.priority - a.priority) || (a.id - b.id));
  10593. },
  10594. unblock: function() {
  10595. var me = this;
  10596. if (me.blocks) {
  10597. if (!--me.blocks) {
  10598. if (me.state === 2 && !me.firing) {
  10599. me.invokeAll();
  10600. }
  10601. }
  10602. }
  10603. },
  10604. unbind: function() {
  10605. var me = this,
  10606. doc = document;
  10607. if (me.bound > 1) {
  10608. doc.removeEventListener('deviceready', me.onReadyEvent, false);
  10609. }
  10610. doc.removeEventListener('DOMContentLoaded', me.onReadyEvent, false);
  10611. window.removeEventListener('load', me.onReadyEvent, false);
  10612. }
  10613. };
  10614. (function() {
  10615. var Ready = Ext.env.Ready;
  10616. if (Ext.isIE9m) {
  10617. Ext.apply(Ready, {
  10618. scrollTimer: null,
  10619. readyStatesRe: /complete/i,
  10620. pollScroll: function() {
  10621. var scrollable = true;
  10622. try {
  10623. document.documentElement.doScroll('left');
  10624. } catch (e) {
  10625. scrollable = false;
  10626. }
  10627. if (scrollable && document.body) {
  10628. Ready.onReadyEvent({
  10629. type: 'doScroll'
  10630. });
  10631. } else {
  10632. Ready.scrollTimer = Ext.defer(Ready.pollScroll, 20);
  10633. }
  10634. return scrollable;
  10635. },
  10636. bind: function() {
  10637. var doc = document,
  10638. topContext;
  10639. if (Ready.bound) {
  10640. return;
  10641. }
  10642. try {
  10643. topContext = window.frameElement === undefined;
  10644. } catch (e) {}
  10645. if (!topContext || !doc.documentElement.doScroll) {
  10646. Ready.pollScroll = Ext.emptyFn;
  10647. }
  10648. else if (Ready.pollScroll()) {
  10649. return;
  10650. }
  10651. if (doc.readyState === 'complete') {
  10652. Ready.onReadyEvent({
  10653. type: 'already ' + (doc.readyState || 'body')
  10654. });
  10655. } else {
  10656. doc.attachEvent('onreadystatechange', Ready.onReadyStateChange);
  10657. window.attachEvent('onload', Ready.onReadyEvent);
  10658. Ready.bound = 1;
  10659. }
  10660. },
  10661. unbind: function() {
  10662. document.detachEvent('onreadystatechange', Ready.onReadyStateChange);
  10663. window.detachEvent('onload', Ready.onReadyEvent);
  10664. if (Ext.isNumber(Ready.scrollTimer)) {
  10665. Ext.undefer(Ready.scrollTimer);
  10666. Ready.scrollTimer = null;
  10667. }
  10668. },
  10669. onReadyStateChange: function() {
  10670. var state = document.readyState;
  10671. if (Ready.readyStatesRe.test(state)) {
  10672. Ready.onReadyEvent({
  10673. type: state
  10674. });
  10675. }
  10676. }
  10677. });
  10678. }
  10679. Ext.onDocumentReady = function(fn, scope, options) {
  10680. var opt = {
  10681. dom: true
  10682. };
  10683. if (options) {
  10684. Ext.apply(opt, options);
  10685. }
  10686. Ready.on(fn, scope, opt);
  10687. };
  10688. Ext.onReady = function(fn, scope, options) {
  10689. Ready.on(fn, scope, options);
  10690. };
  10691. Ext.onInternalReady = function(fn, scope, options) {
  10692. Ready.on(fn, scope, Ext.apply({
  10693. priority: 1000
  10694. }, options));
  10695. };
  10696. Ready.bind();
  10697. }());
  10698. Ext.Loader = (new function() {
  10699. var Loader = this,
  10700. Manager = Ext.ClassManager,
  10701. Boot = Ext.Boot,
  10702. Class = Ext.Class,
  10703. Ready = Ext.env.Ready,
  10704. alias = Ext.Function.alias,
  10705. dependencyProperties = [
  10706. 'extend',
  10707. 'mixins',
  10708. 'requires'
  10709. ],
  10710. isInHistory = {},
  10711. history = [],
  10712. readyListeners = [],
  10713. usedClasses = [],
  10714. _requiresMap = {},
  10715. _config = {
  10716. enabled: true,
  10717. scriptChainDelay: false,
  10718. disableCaching: true,
  10719. disableCachingParam: '_dc',
  10720. paths: Manager.paths,
  10721. preserveScripts: true,
  10722. scriptCharset: undefined
  10723. },
  10724. delegatedConfigs = {
  10725. disableCaching: true,
  10726. disableCachingParam: true,
  10727. preserveScripts: true,
  10728. scriptChainDelay: 'loadDelay'
  10729. };
  10730. Ext.apply(Loader, {
  10731. isInHistory: isInHistory,
  10732. isLoading: false,
  10733. history: history,
  10734. config: _config,
  10735. readyListeners: readyListeners,
  10736. optionalRequires: usedClasses,
  10737. requiresMap: _requiresMap,
  10738. hasFileLoadError: false,
  10739. scriptsLoading: 0,
  10740. classesLoading: {},
  10741. missingCount: 0,
  10742. missingQueue: {},
  10743. syncModeEnabled: false,
  10744. init: function() {
  10745. var scripts = document.getElementsByTagName('script'),
  10746. src = scripts[scripts.length - 1].src,
  10747. path = src.substring(0, src.lastIndexOf('/') + 1),
  10748. meta = Ext._classPathMetadata,
  10749. microloader = Ext.Microloader,
  10750. manifest = Ext.manifest,
  10751. loadOrder, baseUrl, loadlen, l, loadItem;
  10752. if (src.indexOf("packages/core/src/") !== -1) {
  10753. path = path + "../../";
  10754. } else if (src.indexOf("/core/src/class/") !== -1) {
  10755. path = path + "../../../";
  10756. }
  10757. if (!Manager.getPath("Ext")) {
  10758. Manager.setPath('Ext', path + 'src');
  10759. }
  10760. if (meta) {
  10761. Ext._classPathMetadata = null;
  10762. Loader.addClassPathMappings(meta);
  10763. }
  10764. if (manifest) {
  10765. loadOrder = manifest.loadOrder;
  10766. baseUrl = Ext.Boot.baseUrl;
  10767. if (loadOrder && manifest.bootRelative) {
  10768. for (loadlen = loadOrder.length , l = 0; l < loadlen; l++) {
  10769. loadItem = loadOrder[l];
  10770. loadItem.path = baseUrl + loadItem.path;
  10771. loadItem.canonicalPath = true;
  10772. }
  10773. }
  10774. }
  10775. if (microloader) {
  10776. Ready.block();
  10777. microloader.onMicroloaderReady(function() {
  10778. Ready.unblock();
  10779. });
  10780. }
  10781. },
  10782. setConfig: Ext.Function.flexSetter(function(name, value) {
  10783. var delegated = delegatedConfigs[name];
  10784. if (name === 'paths') {
  10785. Loader.setPath(value);
  10786. } else {
  10787. _config[name] = value;
  10788. if (delegated) {
  10789. Boot.setConfig((delegated === true) ? name : delegated, value);
  10790. }
  10791. }
  10792. return Loader;
  10793. }),
  10794. getConfig: function(name) {
  10795. return name ? _config[name] : _config;
  10796. },
  10797. setPath: function() {
  10798. Manager.setPath.apply(Manager, arguments);
  10799. return Loader;
  10800. },
  10801. addClassPathMappings: function(paths) {
  10802. Manager.setPath(paths);
  10803. return Loader;
  10804. },
  10805. addBaseUrlClassPathMappings: function(pathConfig) {
  10806. var name;
  10807. for (name in pathConfig) {
  10808. pathConfig[name] = Boot.baseUrl + pathConfig[name];
  10809. }
  10810. Ext.Loader.addClassPathMappings(pathConfig);
  10811. },
  10812. getPath: function(className) {
  10813. return Manager.getPath(className);
  10814. },
  10815. require: function(expressions, fn, scope, excludes) {
  10816. var classNames;
  10817. if (excludes) {
  10818. return Loader.exclude(excludes).require(expressions, fn, scope);
  10819. }
  10820. classNames = Manager.getNamesByExpression(expressions);
  10821. return Loader.load(classNames, fn, scope);
  10822. },
  10823. syncRequire: function() {
  10824. var wasEnabled = Loader.syncModeEnabled,
  10825. ret;
  10826. Loader.syncModeEnabled = true;
  10827. ret = Loader.require.apply(Loader, arguments);
  10828. Loader.syncModeEnabled = wasEnabled;
  10829. return ret;
  10830. },
  10831. exclude: function(excludes) {
  10832. var selector = Manager.select({
  10833. require: function(classNames, fn, scope) {
  10834. return Loader.load(classNames, fn, scope);
  10835. },
  10836. syncRequire: function(classNames, fn, scope) {
  10837. var wasEnabled = Loader.syncModeEnabled,
  10838. ret;
  10839. Loader.syncModeEnabled = true;
  10840. ret = Loader.load(classNames, fn, scope);
  10841. Loader.syncModeEnabled = wasEnabled;
  10842. return ret;
  10843. }
  10844. });
  10845. selector.exclude(excludes);
  10846. return selector;
  10847. },
  10848. load: function(classNames, callback, scope) {
  10849. if (callback) {
  10850. if (callback.length) {
  10851. callback = Loader.makeLoadCallback(classNames, callback);
  10852. }
  10853. callback = callback.bind(scope || Ext.global);
  10854. }
  10855. var state = Manager.classState,
  10856. missingClassNames = [],
  10857. urls = [],
  10858. urlByClass = {},
  10859. numClasses = classNames.length,
  10860. className, i, numMissing;
  10861. for (i = 0; i < numClasses; ++i) {
  10862. className = Manager.resolveName(classNames[i]);
  10863. if (!Manager.isCreated(className)) {
  10864. missingClassNames.push(className);
  10865. if (!state[className]) {
  10866. urlByClass[className] = Loader.getPath(className);
  10867. urls.push(urlByClass[className]);
  10868. }
  10869. }
  10870. }
  10871. numMissing = missingClassNames.length;
  10872. if (numMissing) {
  10873. Loader.missingCount += numMissing;
  10874. Manager.onCreated(function() {
  10875. if (callback) {
  10876. Ext.callback(callback, scope, arguments);
  10877. }
  10878. Loader.checkReady();
  10879. }, Loader, missingClassNames);
  10880. if (!_config.enabled) {
  10881. Ext.raise("Ext.Loader is not enabled, so dependencies cannot be resolved " + "dynamically. Missing required class" + ((missingClassNames.length > 1) ? "es" : "") + ": " + missingClassNames.join(', '));
  10882. }
  10883. if (urls.length) {
  10884. Loader.loadScripts({
  10885. url: urls,
  10886. _classNames: missingClassNames,
  10887. _urlByClass: urlByClass
  10888. });
  10889. } else {
  10890. Loader.checkReady();
  10891. }
  10892. } else {
  10893. if (callback) {
  10894. callback.call(scope);
  10895. }
  10896. Loader.checkReady();
  10897. }
  10898. if (Loader.syncModeEnabled) {
  10899. if (numClasses === 1) {
  10900. return Manager.get(classNames[0]);
  10901. }
  10902. }
  10903. return Loader;
  10904. },
  10905. makeLoadCallback: function(classNames, callback) {
  10906. return function() {
  10907. var classes = [],
  10908. i = classNames.length;
  10909. while (i-- > 0) {
  10910. classes[i] = Manager.get(classNames[i]);
  10911. }
  10912. return callback.apply(this, classes);
  10913. };
  10914. },
  10915. onLoadFailure: function(request) {
  10916. var options = this,
  10917. entries = request.entries || [],
  10918. onError = options.onError,
  10919. error, entry, i;
  10920. Loader.hasFileLoadError = true;
  10921. --Loader.scriptsLoading;
  10922. if (onError) {
  10923. for (i = 0; i < entries.length; i++) {
  10924. entry = entries[i];
  10925. if (entry.error) {
  10926. error = new Error('Failed to load: ' + entry.url);
  10927. break;
  10928. }
  10929. }
  10930. error = error || new Error('Failed to load');
  10931. onError.call(options.userScope, options, error, request);
  10932. } else
  10933. {
  10934. Ext.log.error("[Ext.Loader] Some requested files failed to load.");
  10935. }
  10936. Loader.checkReady();
  10937. },
  10938. onLoadSuccess: function() {
  10939. var options = this,
  10940. onLoad = options.onLoad,
  10941. classNames = options._classNames,
  10942. urlByClass = options._urlByClass,
  10943. state = Manager.classState,
  10944. missingQueue = Loader.missingQueue,
  10945. className, i, len;
  10946. --Loader.scriptsLoading;
  10947. if (onLoad) {
  10948. onLoad.call(options.userScope, options);
  10949. }
  10950. for (i = 0 , len = classNames.length; i < len; i++) {
  10951. className = classNames[i];
  10952. if (!state[className]) {
  10953. missingQueue[className] = urlByClass[className];
  10954. }
  10955. }
  10956. Loader.checkReady();
  10957. },
  10958. reportMissingClasses: function() {
  10959. var missingQueue = Loader.missingQueue,
  10960. missingClasses = [],
  10961. missingPaths = [],
  10962. missingClassName;
  10963. if (!Loader.syncModeEnabled && !Loader.scriptsLoading && Loader.isLoading && !Loader.hasFileLoadError) {
  10964. for (missingClassName in missingQueue) {
  10965. missingClasses.push(missingClassName);
  10966. missingPaths.push(missingQueue[missingClassName]);
  10967. }
  10968. if (missingClasses.length) {
  10969. throw new Error("The following classes are not declared even if their files " + "have been loaded: '" + missingClasses.join("', '") + "'. Please check the source code of their " + "corresponding files for possible typos: '" + missingPaths.join("', '"));
  10970. }
  10971. }
  10972. },
  10973. onReady: function(fn, scope, withDomReady, options) {
  10974. var listener;
  10975. if (withDomReady) {
  10976. Ready.on(fn, scope, options);
  10977. } else {
  10978. listener = Ready.makeListener(fn, scope, options);
  10979. if (Loader.isLoading) {
  10980. readyListeners.push(listener);
  10981. } else {
  10982. Ready.invoke(listener);
  10983. }
  10984. }
  10985. },
  10986. addUsedClasses: function(classes) {
  10987. var cls, i, ln;
  10988. if (classes) {
  10989. classes = (typeof classes === 'string') ? [
  10990. classes
  10991. ] : classes;
  10992. for (i = 0 , ln = classes.length; i < ln; i++) {
  10993. cls = classes[i];
  10994. if (typeof cls === 'string' && !Ext.Array.contains(usedClasses, cls)) {
  10995. usedClasses.push(cls);
  10996. }
  10997. }
  10998. }
  10999. return Loader;
  11000. },
  11001. triggerReady: function() {
  11002. var listener,
  11003. refClasses = usedClasses;
  11004. if (Loader.isLoading && refClasses.length) {
  11005. usedClasses = [];
  11006. Loader.require(refClasses);
  11007. } else {
  11008. Loader.isLoading = false;
  11009. readyListeners.sort(Ready.sortFn);
  11010. while (readyListeners.length && !Loader.isLoading) {
  11011. listener = readyListeners.pop();
  11012. Ready.invoke(listener);
  11013. }
  11014. Ready.unblock();
  11015. }
  11016. },
  11017. historyPush: function(className) {
  11018. if (className && !isInHistory[className] && !Manager.overrideMap[className]) {
  11019. isInHistory[className] = true;
  11020. history.push(className);
  11021. }
  11022. return Loader;
  11023. },
  11024. loadScripts: function(params) {
  11025. var manifest = Ext.manifest,
  11026. loadOrder = manifest && manifest.loadOrder,
  11027. loadOrderMap = manifest && manifest.loadOrderMap,
  11028. options;
  11029. ++Loader.scriptsLoading;
  11030. if (loadOrder && !loadOrderMap) {
  11031. manifest.loadOrderMap = loadOrderMap = Boot.createLoadOrderMap(loadOrder);
  11032. }
  11033. Loader.checkReady();
  11034. options = Ext.apply({
  11035. loadOrder: loadOrder,
  11036. loadOrderMap: loadOrderMap,
  11037. charset: _config.scriptCharset,
  11038. success: Loader.onLoadSuccess,
  11039. failure: Loader.onLoadFailure,
  11040. sync: Loader.syncModeEnabled,
  11041. _classNames: []
  11042. }, params);
  11043. options.userScope = options.scope;
  11044. options.scope = options;
  11045. Boot.load(options);
  11046. },
  11047. loadScriptsSync: function(urls) {
  11048. var syncwas = Loader.syncModeEnabled;
  11049. Loader.syncModeEnabled = true;
  11050. Loader.loadScripts({
  11051. url: urls
  11052. });
  11053. Loader.syncModeEnabled = syncwas;
  11054. },
  11055. loadScriptsSyncBasePrefix: function(urls) {
  11056. var syncwas = Loader.syncModeEnabled;
  11057. Loader.syncModeEnabled = true;
  11058. Loader.loadScripts({
  11059. url: urls,
  11060. prependBaseUrl: true
  11061. });
  11062. Loader.syncModeEnabled = syncwas;
  11063. },
  11064. loadScript: function(options) {
  11065. var isString = typeof options === 'string',
  11066. isArray = options instanceof Array,
  11067. isObject = !isArray && !isString,
  11068. url = isObject ? options.url : options,
  11069. onError = isObject && options.onError,
  11070. onLoad = isObject && options.onLoad,
  11071. scope = isObject && options.scope,
  11072. request = {
  11073. url: url,
  11074. scope: scope,
  11075. onLoad: onLoad,
  11076. onError: onError,
  11077. _classNames: []
  11078. };
  11079. Loader.loadScripts(request);
  11080. },
  11081. checkMissingQueue: function() {
  11082. var missingQueue = Loader.missingQueue,
  11083. newQueue = {},
  11084. missing = 0,
  11085. name;
  11086. for (name in missingQueue) {
  11087. if (!(Manager.classState[name] || Manager.isCreated(name))) {
  11088. newQueue[name] = missingQueue[name];
  11089. missing++;
  11090. }
  11091. }
  11092. Loader.missingCount = missing;
  11093. Loader.missingQueue = newQueue;
  11094. },
  11095. checkReady: function() {
  11096. var wasLoading = Loader.isLoading,
  11097. isLoading;
  11098. Loader.checkMissingQueue();
  11099. isLoading = Loader.missingCount + Loader.scriptsLoading;
  11100. if (isLoading && !wasLoading) {
  11101. Ready.block();
  11102. Loader.isLoading = !!isLoading;
  11103. } else if (!isLoading && wasLoading) {
  11104. Loader.triggerReady();
  11105. }
  11106. if (!Loader.scriptsLoading && Loader.missingCount) {
  11107. Ext.defer(function() {
  11108. var name;
  11109. if (!Loader.scriptsLoading && Loader.missingCount) {
  11110. Ext.log.error('[Loader] The following classes failed to load:');
  11111. for (name in Loader.missingQueue) {
  11112. Ext.log.error('[Loader] ' + name + ' from ' + Loader.missingQueue[name]);
  11113. }
  11114. }
  11115. }, 1000);
  11116. }
  11117. }
  11118. });
  11119. Ext.require = alias(Loader, 'require');
  11120. Ext.syncRequire = alias(Loader, 'syncRequire');
  11121. Ext.exclude = alias(Loader, 'exclude');
  11122. Class.registerPreprocessor('loader', function(cls, data, hooks, continueFn) {
  11123. if (Ext.classSystemMonitor) {
  11124. Ext.classSystemMonitor(cls, 'Ext.Loader#loaderPreprocessor', arguments);
  11125. }
  11126. var me = this,
  11127. dependencies = [],
  11128. dependency,
  11129. className = Manager.getName(cls),
  11130. i, j, ln, subLn, value, propertyName, propertyValue, requiredMap;
  11131. for (i = 0 , ln = dependencyProperties.length; i < ln; i++) {
  11132. propertyName = dependencyProperties[i];
  11133. if (data.hasOwnProperty(propertyName)) {
  11134. propertyValue = data[propertyName];
  11135. if (typeof propertyValue === 'string') {
  11136. dependencies.push(propertyValue);
  11137. } else if (propertyValue instanceof Array) {
  11138. for (j = 0 , subLn = propertyValue.length; j < subLn; j++) {
  11139. value = propertyValue[j];
  11140. if (typeof value === 'string') {
  11141. dependencies.push(value);
  11142. }
  11143. }
  11144. } else if (typeof propertyValue !== 'function') {
  11145. for (j in propertyValue) {
  11146. if (propertyValue.hasOwnProperty(j)) {
  11147. value = propertyValue[j];
  11148. if (typeof value === 'string') {
  11149. dependencies.push(value);
  11150. }
  11151. }
  11152. }
  11153. }
  11154. }
  11155. }
  11156. if (dependencies.length === 0) {
  11157. return;
  11158. }
  11159. if (className) {
  11160. _requiresMap[className] = dependencies;
  11161. }
  11162. var manifestClasses = Ext.manifest && Ext.manifest.classes,
  11163. deadlockPath = [],
  11164. detectDeadlock;
  11165. if (className && (!manifestClasses || !manifestClasses[className])) {
  11166. requiredMap = Loader.requiredByMap || (Loader.requiredByMap = {});
  11167. for (i = 0 , ln = dependencies.length; i < ln; i++) {
  11168. dependency = dependencies[i];
  11169. (requiredMap[dependency] || (requiredMap[dependency] = [])).push(className);
  11170. }
  11171. detectDeadlock = function(cls) {
  11172. var requires = _requiresMap[cls],
  11173. dep, i, ln;
  11174. deadlockPath.push(cls);
  11175. if (requires) {
  11176. if (Ext.Array.contains(requires, className)) {
  11177. Ext.Error.raise("Circular requirement detected! '" + className + "' and '" + deadlockPath[1] + "' mutually require each other. " + "Path: " + deadlockPath.join(' -> ') + " -> " + deadlockPath[0]);
  11178. }
  11179. for (i = 0 , ln = requires.length; i < ln; i++) {
  11180. dep = requires[i];
  11181. if (!isInHistory[dep]) {
  11182. detectDeadlock(requires[i]);
  11183. }
  11184. }
  11185. }
  11186. };
  11187. detectDeadlock(className);
  11188. }
  11189. (className ? Loader.exclude(className) : Loader).require(dependencies, function() {
  11190. var i, ln, j, subLn, k;
  11191. for (i = 0 , ln = dependencyProperties.length; i < ln; i++) {
  11192. propertyName = dependencyProperties[i];
  11193. if (data.hasOwnProperty(propertyName)) {
  11194. propertyValue = data[propertyName];
  11195. if (typeof propertyValue === 'string') {
  11196. data[propertyName] = Manager.get(propertyValue);
  11197. } else if (propertyValue instanceof Array) {
  11198. for (j = 0 , subLn = propertyValue.length; j < subLn; j++) {
  11199. value = propertyValue[j];
  11200. if (typeof value === 'string') {
  11201. data[propertyName][j] = Manager.get(value);
  11202. }
  11203. }
  11204. } else if (typeof propertyValue !== 'function') {
  11205. for (k in propertyValue) {
  11206. if (propertyValue.hasOwnProperty(k)) {
  11207. value = propertyValue[k];
  11208. if (typeof value === 'string') {
  11209. data[propertyName][k] = Manager.get(value);
  11210. }
  11211. }
  11212. }
  11213. }
  11214. }
  11215. }
  11216. continueFn.call(me, cls, data, hooks);
  11217. });
  11218. return false;
  11219. }, true, 'after', 'className');
  11220. Manager.registerPostprocessor('uses', function(name, cls, data) {
  11221. var uses = data.uses,
  11222. classNames;
  11223. if (Ext.classSystemMonitor) {
  11224. Ext.classSystemMonitor(cls, 'Ext.Loader#usesPostprocessor', arguments);
  11225. }
  11226. if (uses) {
  11227. classNames = Manager.getNamesByExpression(data.uses);
  11228. Loader.addUsedClasses(classNames);
  11229. }
  11230. });
  11231. Manager.onCreated(Loader.historyPush);
  11232. Loader.init();
  11233. }());
  11234. Ext._endTime = Ext.ticks();
  11235. if (Ext._beforereadyhandler) {
  11236. Ext._beforereadyhandler();
  11237. }
  11238. Ext.define('Ext.Mixin', function(Mixin) {
  11239. return {
  11240. statics: {
  11241. addHook: function(hookFn, targetClass, methodName, mixinClassPrototype) {
  11242. var isFunc = Ext.isFunction(hookFn),
  11243. hook = function() {
  11244. var a = arguments,
  11245. fn = isFunc ? hookFn : mixinClassPrototype[hookFn],
  11246. result = this.callParent(a);
  11247. fn.apply(this, a);
  11248. return result;
  11249. },
  11250. existingFn = targetClass.hasOwnProperty(methodName) && targetClass[methodName];
  11251. if (isFunc) {
  11252. hookFn.$previous = Ext.emptyFn;
  11253. }
  11254. hook.$name = methodName;
  11255. hook.$owner = targetClass.self;
  11256. if (existingFn) {
  11257. hook.$previous = existingFn.$previous;
  11258. existingFn.$previous = hook;
  11259. } else {
  11260. targetClass[methodName] = hook;
  11261. }
  11262. }
  11263. },
  11264. onClassExtended: function(cls, data) {
  11265. var mixinConfig = data.mixinConfig,
  11266. hooks = data.xhooks,
  11267. superclass = cls.superclass,
  11268. onClassMixedIn = data.onClassMixedIn,
  11269. afterClassMixedIn = data.afterClassMixedIn,
  11270. afters, befores, configs, extended, mixed, parentMixinConfig;
  11271. if (hooks) {
  11272. delete data.xhooks;
  11273. (mixinConfig || (data.mixinConfig = mixinConfig = {})).on = hooks;
  11274. }
  11275. if (mixinConfig) {
  11276. parentMixinConfig = superclass.mixinConfig;
  11277. if (parentMixinConfig) {
  11278. data.mixinConfig = mixinConfig = Ext.merge({}, parentMixinConfig, mixinConfig);
  11279. }
  11280. data.mixinId = mixinConfig.id;
  11281. if (mixinConfig.beforeHooks) {
  11282. Ext.raise('Use of "beforeHooks" is deprecated - use "before" instead');
  11283. }
  11284. if (mixinConfig.hooks) {
  11285. Ext.raise('Use of "hooks" is deprecated - use "after" instead');
  11286. }
  11287. if (mixinConfig.afterHooks) {
  11288. Ext.raise('Use of "afterHooks" is deprecated - use "after" instead');
  11289. }
  11290. afters = mixinConfig.after;
  11291. befores = mixinConfig.before;
  11292. configs = mixinConfig.configs;
  11293. extended = mixinConfig.extended;
  11294. hooks = mixinConfig.on;
  11295. mixed = mixinConfig.mixed;
  11296. }
  11297. if (afters || befores || hooks || extended) {
  11298. data.onClassMixedIn = function(targetClass) {
  11299. var mixin = this.prototype,
  11300. targetProto = targetClass.prototype,
  11301. key;
  11302. if (befores) {
  11303. Ext.Object.each(befores, function(key, value) {
  11304. targetClass.hookMember(key, function() {
  11305. if (mixin[value].apply(this, arguments) !== false) {
  11306. return this.callParent(arguments);
  11307. }
  11308. });
  11309. });
  11310. }
  11311. if (afters) {
  11312. Ext.Object.each(afters, function(key, value) {
  11313. targetClass.hookMember(key, function() {
  11314. var ret = this.callParent(arguments);
  11315. mixin[value].apply(this, arguments);
  11316. return ret;
  11317. });
  11318. });
  11319. }
  11320. if (hooks) {
  11321. for (key in hooks) {
  11322. Mixin.addHook(hooks[key], targetProto, key, mixin);
  11323. }
  11324. }
  11325. if (extended) {
  11326. targetClass.onExtended(function() {
  11327. var args = Ext.Array.slice(arguments, 0);
  11328. args.unshift(targetClass);
  11329. return extended.apply(this, args);
  11330. }, this);
  11331. }
  11332. if (onClassMixedIn) {
  11333. onClassMixedIn.apply(this, arguments);
  11334. }
  11335. };
  11336. }
  11337. if (configs || mixed) {
  11338. data.afterClassMixedIn = function(targetClass) {
  11339. if (configs) {
  11340. var proto = targetClass.prototype,
  11341. hoistable = this.$config.configs,
  11342. cfg, name, hoist;
  11343. for (name in proto) {
  11344. cfg = hoistable[name];
  11345. if (cfg && cfg.isConfig && proto.hasOwnProperty(name)) {
  11346. (hoist || (hoist = {}))[name] = proto[name];
  11347. delete proto[name];
  11348. }
  11349. }
  11350. if (hoist) {
  11351. targetClass.$config.add(hoist);
  11352. }
  11353. }
  11354. if (afterClassMixedIn) {
  11355. afterClassMixedIn.apply(this, arguments);
  11356. }
  11357. if (mixed) {
  11358. mixed.apply(this, arguments);
  11359. }
  11360. };
  11361. }
  11362. }
  11363. };
  11364. });
  11365. Ext.util = Ext.util || {};
  11366. Ext.util.DelayedTask = function(fn, scope, args, cancelOnDelay, fireIdleEvent) {
  11367. var me = this,
  11368. delay,
  11369. call = function() {
  11370. me.id = null;
  11371. if (!(scope && scope.destroyed)) {
  11372. if (args) {
  11373. fn.apply(scope, args);
  11374. } else {
  11375. fn.call(scope);
  11376. }
  11377. }
  11378. if (fireIdleEvent === false) {
  11379. Ext._suppressIdle = true;
  11380. }
  11381. };
  11382. if (fn) {
  11383. call.$origFn = fn.$origFn || fn;
  11384. call.$skipTimerCheck = call.$origFn.$skipTimerCheck;
  11385. }
  11386. cancelOnDelay = typeof cancelOnDelay === 'boolean' ? cancelOnDelay : true;
  11387. me.id = null;
  11388. me.delay = function(newDelay, newFn, newScope, newArgs) {
  11389. if (cancelOnDelay) {
  11390. me.cancel();
  11391. }
  11392. if (typeof newDelay === 'number') {
  11393. delay = newDelay;
  11394. }
  11395. fn = newFn || fn;
  11396. scope = newScope || scope;
  11397. args = newArgs || args;
  11398. me.delayTime = delay;
  11399. if (fn) {
  11400. call.$origFn = fn.$origFn || fn;
  11401. call.$skipTimerCheck = call.$origFn.$skipTimerCheck;
  11402. }
  11403. if (!me.id) {
  11404. if (delay === -1) {
  11405. me.id = Ext.raf(call);
  11406. } else {
  11407. me.id = Ext.defer(call, delay || 1);
  11408. }
  11409. }
  11410. return me.id;
  11411. };
  11412. me.cancel = function() {
  11413. if (me.id) {
  11414. if (me.delayTime === -1) {
  11415. Ext.unraf(me.id);
  11416. } else {
  11417. Ext.undefer(me.id);
  11418. }
  11419. me.id = null;
  11420. }
  11421. };
  11422. me.flush = function() {
  11423. var was;
  11424. if (me.id) {
  11425. me.cancel();
  11426. was = fireIdleEvent;
  11427. fireIdleEvent = true;
  11428. call();
  11429. fireIdleEvent = was;
  11430. }
  11431. };
  11432. me.stop = function(stopFn, stopScope) {
  11433. if (stopFn && stopFn === fn && (!stopScope || stopScope === scope)) {
  11434. me.cancel();
  11435. }
  11436. };
  11437. };
  11438. Ext.define('Ext.util.Event', function() {
  11439. var arraySlice = Array.prototype.slice,
  11440. arrayInsert = Ext.Array.insert,
  11441. toArray = Ext.Array.toArray,
  11442. fireArgs = {};
  11443. return {
  11444. isEvent: true,
  11445. suspended: 0,
  11446. noOptions: {},
  11447. constructor: function(observable, name) {
  11448. this.name = name;
  11449. this.observable = observable;
  11450. this.listeners = [];
  11451. },
  11452. addListener: function(fn, scope, options, caller, manager) {
  11453. var me = this,
  11454. added = false,
  11455. observable = me.observable,
  11456. eventName = me.name,
  11457. listeners, listener, priority, isNegativePriority, highestNegativePriorityIndex, hasNegativePriorityIndex, length, index, i, listenerPriority, managedListeners;
  11458. if (scope && !Ext._namedScopes[scope] && (typeof fn === 'string') && (typeof scope[fn] !== 'function')) {
  11459. Ext.raise("No method named '" + fn + "' found on scope object");
  11460. }
  11461. if (me.findListener(fn, scope) === -1) {
  11462. listener = me.createListener(fn, scope, options, caller, manager);
  11463. if (me.firing) {
  11464. me.listeners = me.listeners.slice(0);
  11465. }
  11466. listeners = me.listeners;
  11467. index = length = listeners.length;
  11468. priority = options && options.priority;
  11469. highestNegativePriorityIndex = me._highestNegativePriorityIndex;
  11470. hasNegativePriorityIndex = highestNegativePriorityIndex !== undefined;
  11471. if (priority) {
  11472. isNegativePriority = (priority < 0);
  11473. if (!isNegativePriority || hasNegativePriorityIndex) {
  11474. for (i = (isNegativePriority ? highestNegativePriorityIndex : 0); i < length; i++) {
  11475. listenerPriority = listeners[i].o ? listeners[i].o.priority || 0 : 0;
  11476. if (listenerPriority < priority) {
  11477. index = i;
  11478. break;
  11479. }
  11480. }
  11481. } else {
  11482. me._highestNegativePriorityIndex = index;
  11483. }
  11484. } else if (hasNegativePriorityIndex) {
  11485. index = highestNegativePriorityIndex;
  11486. }
  11487. if (!isNegativePriority && index <= highestNegativePriorityIndex) {
  11488. me._highestNegativePriorityIndex++;
  11489. }
  11490. if (index === length) {
  11491. listeners[length] = listener;
  11492. } else {
  11493. arrayInsert(listeners, index, [
  11494. listener
  11495. ]);
  11496. }
  11497. if (observable.isElement) {
  11498. observable._getPublisher(eventName, options.translate === false).subscribe(observable, eventName, options.delegated !== false, options.capture);
  11499. }
  11500. if (manager) {
  11501. managedListeners = manager.managedListeners || (manager.managedListeners = []);
  11502. managedListeners.push({
  11503. item: me.observable,
  11504. ename: (options && options.managedName) || me.name,
  11505. fn: fn,
  11506. scope: scope,
  11507. options: options
  11508. });
  11509. }
  11510. added = true;
  11511. }
  11512. return added;
  11513. },
  11514. createListener: function(fn, scope, o, caller, manager) {
  11515. var me = this,
  11516. namedScopes = Ext._namedScopes,
  11517. namedScope = namedScopes[scope],
  11518. listener = {
  11519. fn: fn,
  11520. scope: scope,
  11521. ev: me,
  11522. caller: caller,
  11523. manager: manager,
  11524. namedScope: namedScope,
  11525. defaultScope: namedScope ? (scope || me.observable) : undefined,
  11526. lateBound: typeof fn === 'string'
  11527. },
  11528. handler = fn,
  11529. wrapped = false,
  11530. type;
  11531. if (listener.lateBound && fn[2] === '.') {
  11532. if (fn.substr(0, 2) !== 'up') {
  11533. Ext.raise('Invalid listener method: ' + fn);
  11534. }
  11535. listener.defaultScope = null;
  11536. listener.namedScope = namedScopes[listener.scope = scope = 'up'];
  11537. listener.fn = handler = fn.substr(3);
  11538. }
  11539. if (o) {
  11540. listener.o = o;
  11541. if (o.single) {
  11542. handler = me.createSingle(handler, listener, o, scope);
  11543. wrapped = true;
  11544. }
  11545. if (o.target) {
  11546. handler = me.createTargeted(handler, listener, o, scope, wrapped);
  11547. wrapped = true;
  11548. }
  11549. if (o.onFrame) {
  11550. handler = me.createAnimFrame(handler, listener, o, scope, wrapped);
  11551. wrapped = true;
  11552. }
  11553. if (o.delay) {
  11554. handler = me.createDelayed(handler, listener, o, scope, wrapped);
  11555. wrapped = true;
  11556. }
  11557. if (o.buffer) {
  11558. handler = me.createBuffered(handler, listener, o, scope, wrapped);
  11559. wrapped = true;
  11560. }
  11561. if (me.observable.isElement) {
  11562. type = o.type;
  11563. if (type) {
  11564. listener.type = type;
  11565. }
  11566. }
  11567. }
  11568. listener.fireFn = handler;
  11569. listener.wrapped = wrapped;
  11570. return listener;
  11571. },
  11572. findListener: function(fn, scope) {
  11573. var listeners = this.listeners,
  11574. i = listeners.length,
  11575. listener;
  11576. while (i--) {
  11577. listener = listeners[i];
  11578. if (listener) {
  11579. if (listener.fn === fn && listener.scope == scope) {
  11580. return i;
  11581. }
  11582. }
  11583. }
  11584. return -1;
  11585. },
  11586. removeListener: function(fn, scope, index) {
  11587. var me = this,
  11588. removed = false,
  11589. observable = me.observable,
  11590. eventName = me.name,
  11591. listener, options, manager, managedListeners, managedListener, i;
  11592. index = index != null ? index : me.findListener(fn, scope);
  11593. if (index !== -1) {
  11594. listener = me.listeners[index];
  11595. if (me.firing) {
  11596. me.listeners = me.listeners.slice(0);
  11597. }
  11598. me.listeners.splice(index, 1);
  11599. if (me._highestNegativePriorityIndex) {
  11600. if (index < me._highestNegativePriorityIndex) {
  11601. me._highestNegativePriorityIndex--;
  11602. } else if (index === me._highestNegativePriorityIndex && index === me.listeners.length) {
  11603. delete me._highestNegativePriorityIndex;
  11604. }
  11605. }
  11606. if (listener) {
  11607. options = listener.o;
  11608. if (listener.task) {
  11609. listener.task.cancel();
  11610. delete listener.task;
  11611. }
  11612. i = listener.tasks && listener.tasks.length;
  11613. if (i) {
  11614. while (i--) {
  11615. listener.tasks[i].cancel();
  11616. }
  11617. delete listener.tasks;
  11618. }
  11619. listener.fireFn.timerId = Ext.undefer(listener.fireFn.timerId);
  11620. manager = listener.manager;
  11621. if (manager) {
  11622. managedListeners = manager.managedListeners;
  11623. if (managedListeners) {
  11624. for (i = managedListeners.length; i--; ) {
  11625. managedListener = managedListeners[i];
  11626. if (managedListener.item === me.observable && managedListener.ename === eventName && managedListener.fn === fn && managedListener.scope === scope) {
  11627. managedListeners.splice(i, 1);
  11628. }
  11629. }
  11630. }
  11631. }
  11632. if (observable.isElement) {
  11633. observable._getPublisher(eventName, options.translate === false).unsubscribe(observable, eventName, options.delegated !== false, options.capture);
  11634. }
  11635. }
  11636. removed = true;
  11637. }
  11638. return removed;
  11639. },
  11640. clearListeners: function() {
  11641. var listeners = this.listeners,
  11642. i = listeners.length,
  11643. listener;
  11644. while (i--) {
  11645. listener = listeners[i];
  11646. this.removeListener(listener.fn, listener.scope);
  11647. }
  11648. },
  11649. suspend: function() {
  11650. ++this.suspended;
  11651. },
  11652. resume: function() {
  11653. if (this.suspended) {
  11654. --this.suspended;
  11655. }
  11656. },
  11657. isSuspended: function() {
  11658. return this.suspended > 0;
  11659. },
  11660. fireDelegated: function(firingObservable, args) {
  11661. this.firingObservable = firingObservable;
  11662. return this.fire.apply(this, args);
  11663. },
  11664. fire: function() {
  11665. var me = this,
  11666. CQ = Ext.ComponentQuery,
  11667. listeners = me.listeners,
  11668. count = listeners.length,
  11669. observable = me.observable,
  11670. isElement = observable.isElement,
  11671. isComponent = observable.isComponent,
  11672. firingObservable = me.firingObservable,
  11673. options, delegate, fireInfo, i, args, listener, len, delegateEl, currentTarget, type, chained, firingArgs, e, fireFn, fireScope;
  11674. if (!me.suspended && count > 0) {
  11675. me.firing = true;
  11676. args = arguments.length ? arraySlice.call(arguments, 0) : [];
  11677. len = args.length;
  11678. if (isElement) {
  11679. e = args[0];
  11680. }
  11681. for (i = 0; i < count; i++) {
  11682. listener = listeners[i];
  11683. if (!listener) {
  11684. continue;
  11685. }
  11686. options = listener.o;
  11687. if (isElement) {
  11688. if (currentTarget) {
  11689. e.setCurrentTarget(currentTarget);
  11690. }
  11691. type = listener.type;
  11692. if (type) {
  11693. chained = e;
  11694. e = args[0] = chained.chain({
  11695. type: type,
  11696. isGesture: false
  11697. });
  11698. }
  11699. Ext.EventObject = e;
  11700. }
  11701. firingArgs = args;
  11702. if (options) {
  11703. delegate = options.delegate;
  11704. if (delegate) {
  11705. if (isElement) {
  11706. delegateEl = e.getTarget(typeof delegate === 'function' ? delegate : '#' + e.currentTarget.id + ' ' + delegate);
  11707. if (delegateEl) {
  11708. args[1] = delegateEl;
  11709. currentTarget = e.currentTarget;
  11710. e.setCurrentTarget(delegateEl);
  11711. } else {
  11712. continue;
  11713. }
  11714. }
  11715. else if (isComponent && !CQ.is(firingObservable, delegate, observable)) {
  11716. continue;
  11717. }
  11718. }
  11719. if (isElement) {
  11720. if (options.preventDefault) {
  11721. e.preventDefault();
  11722. }
  11723. if (options.stopPropagation) {
  11724. e.stopPropagation();
  11725. }
  11726. if (options.stopEvent) {
  11727. e.stopEvent();
  11728. }
  11729. }
  11730. args[len] = options;
  11731. if (options.args) {
  11732. firingArgs = options.args.concat(args);
  11733. }
  11734. }
  11735. fireInfo = me.getFireInfo(listener);
  11736. fireFn = fireInfo.fn;
  11737. fireScope = fireInfo.scope;
  11738. fireInfo.fn = fireInfo.scope = null;
  11739. if (fireScope && fireScope.destroyed) {
  11740. me.removeListener(fireFn, fireScope, i);
  11741. fireFn = null;
  11742. if (fireScope.$className !== 'Ext.container.Monitor') {
  11743. (Ext.raiseOnDestroyed ? Ext.raise : Ext.log.warn)({
  11744. msg: 'Attempting to fire "' + me.name + '" event on destroyed ' + (fireScope.$className || 'object') + ' instance with id: ' + (fireScope.id || 'unknown'),
  11745. instance: fireScope
  11746. });
  11747. }
  11748. }
  11749. if (fireFn && fireFn.apply(fireScope, firingArgs) === false) {
  11750. Ext.EventObject = null;
  11751. return (me.firing = false);
  11752. }
  11753. if (options) {
  11754. args.length--;
  11755. }
  11756. if (chained) {
  11757. e = args[0] = chained;
  11758. chained = null;
  11759. }
  11760. Ext.EventObject = null;
  11761. }
  11762. }
  11763. me.firing = false;
  11764. return true;
  11765. },
  11766. getFireInfo: function(listener, fromWrapped) {
  11767. var observable = this.observable,
  11768. fireFn = listener.fireFn,
  11769. scope = listener.scope,
  11770. namedScope = listener.namedScope,
  11771. fn, origin;
  11772. if (!fromWrapped && listener.wrapped) {
  11773. fireArgs.fn = fireFn;
  11774. return fireArgs;
  11775. }
  11776. fn = fromWrapped ? listener.fn : fireFn;
  11777. var name = fn;
  11778. if (listener.lateBound) {
  11779. origin = listener.caller || observable;
  11780. if (namedScope && namedScope.isUp) {
  11781. scope = Ext.lookUpFn(origin, fn);
  11782. } else if (!scope || namedScope) {
  11783. scope = origin.resolveListenerScope(listener.defaultScope);
  11784. }
  11785. if (!scope) {
  11786. Ext.raise('Unable to dynamically resolve scope for "' + listener.ev.name + '" listener on ' + this.observable.id);
  11787. }
  11788. if (!Ext.isFunction(scope[fn])) {
  11789. Ext.raise('No method named "' + fn + '" on ' + (scope.$className || 'scope object.'));
  11790. }
  11791. fn = scope[fn];
  11792. } else if (namedScope && namedScope.isController) {
  11793. scope = (listener.caller || observable).resolveListenerScope(listener.defaultScope);
  11794. if (!scope) {
  11795. Ext.raise('Unable to dynamically resolve scope for "' + listener.ev.name + '" listener on ' + this.observable.id);
  11796. }
  11797. }
  11798. else if (!scope || namedScope) {
  11799. scope = observable;
  11800. }
  11801. fireArgs.fn = fn;
  11802. fireArgs.scope = scope;
  11803. if (!fn) {
  11804. Ext.raise('Unable to dynamically resolve method "' + name + '" on ' + this.observable.$className);
  11805. }
  11806. return fireArgs;
  11807. },
  11808. createAnimFrame: function(handler, listener, o, scope, wrapped) {
  11809. var fireInfo;
  11810. if (!wrapped) {
  11811. fireInfo = listener.ev.getFireInfo(listener, true);
  11812. handler = fireInfo.fn;
  11813. scope = fireInfo.scope;
  11814. fireInfo.fn = fireInfo.scope = null;
  11815. }
  11816. return Ext.Function.createAnimationFrame(handler, scope, o.args);
  11817. },
  11818. createTargeted: function(handler, listener, o, scope, wrapped) {
  11819. return function() {
  11820. var fireInfo;
  11821. if (o.target === arguments[0]) {
  11822. if (!wrapped) {
  11823. fireInfo = listener.ev.getFireInfo(listener, true);
  11824. handler = fireInfo.fn;
  11825. scope = fireInfo.scope;
  11826. fireInfo.fn = fireInfo.scope = null;
  11827. }
  11828. return handler.apply(scope, arguments);
  11829. }
  11830. };
  11831. },
  11832. createBuffered: function(handler, listener, o, scope, wrapped) {
  11833. listener.task = new Ext.util.DelayedTask();
  11834. return function() {
  11835. var fireInfo;
  11836. if (listener.task) {
  11837. if (Ext._unitTesting) {
  11838. o.$delayedTask = listener.task;
  11839. }
  11840. if (!wrapped) {
  11841. fireInfo = listener.ev.getFireInfo(listener, true);
  11842. handler = fireInfo.fn;
  11843. scope = fireInfo.scope;
  11844. fireInfo.fn = fireInfo.scope = null;
  11845. }
  11846. listener.task.delay(o.buffer, handler, scope, toArray(arguments));
  11847. }
  11848. };
  11849. },
  11850. createDelayed: function(handler, listener, o, scope, wrapped) {
  11851. return function() {
  11852. var task = new Ext.util.DelayedTask(),
  11853. fireInfo;
  11854. if (!wrapped) {
  11855. fireInfo = listener.ev.getFireInfo(listener, true);
  11856. handler = fireInfo.fn;
  11857. scope = fireInfo.scope;
  11858. fireInfo.fn = fireInfo.scope = null;
  11859. }
  11860. if (!listener.tasks) {
  11861. listener.tasks = [];
  11862. }
  11863. listener.tasks.push(task);
  11864. if (Ext._unitTesting) {
  11865. o.$delayedTask = task;
  11866. }
  11867. task.delay(o.delay || 10, handler, scope, toArray(arguments));
  11868. };
  11869. },
  11870. createSingle: function(handler, listener, o, scope, wrapped) {
  11871. return function() {
  11872. var event = listener.ev,
  11873. observable = event.observable,
  11874. fn = listener.fn,
  11875. fireInfo;
  11876. if (observable) {
  11877. if (!observable.destroyed) {
  11878. observable.removeListener(event.name, fn, scope);
  11879. }
  11880. } else {
  11881. event.removeListener(fn, scope);
  11882. }
  11883. if (!wrapped) {
  11884. fireInfo = event.getFireInfo(listener, true);
  11885. handler = fireInfo.fn;
  11886. scope = fireInfo.scope;
  11887. fireInfo.fn = fireInfo.scope = null;
  11888. }
  11889. return handler.apply(scope, arguments);
  11890. };
  11891. }
  11892. };
  11893. });
  11894. Ext.define('Ext.mixin.Identifiable', function(Identifiable) {
  11895. return {
  11896. isIdentifiable: true,
  11897. mixinId: 'identifiable',
  11898. getId: function() {
  11899. var me = this,
  11900. id = me.id,
  11901. cfg;
  11902. if (!(id || id === 0)) {
  11903. cfg = me.initialConfig;
  11904. if (cfg && cfg.id) {
  11905. id = cfg.id;
  11906. } else {
  11907. id = me.generateAutoId();
  11908. me.autoGenId = true;
  11909. }
  11910. me.setId(id);
  11911. }
  11912. me.getId = Identifiable._getId;
  11913. return id;
  11914. },
  11915. setId: function(id) {
  11916. this.id = this.id = id;
  11917. },
  11918. privates: {
  11919. statics: {
  11920. _idCleanRe: /\.|[^\w-]/g,
  11921. uniqueIds: {},
  11922. _getId: function() {
  11923. return this.id;
  11924. }
  11925. },
  11926. defaultIdPrefix: 'ext-',
  11927. defaultIdSeparator: '-',
  11928. id: null,
  11929. autoGenId: false,
  11930. generateAutoId: function() {
  11931. var me = this,
  11932. prototype = me.self.prototype,
  11933. sep = me.defaultIdSeparator,
  11934. uniqueIds = Identifiable.uniqueIds,
  11935. cleanRe, defaultIdPrefix, prefix, xtype;
  11936. if (!prototype.hasOwnProperty('identifiablePrefix')) {
  11937. cleanRe = Identifiable._idCleanRe;
  11938. defaultIdPrefix = me.defaultIdPrefix;
  11939. xtype = me.xtype;
  11940. if (xtype) {
  11941. prefix = defaultIdPrefix + xtype.replace(cleanRe, sep) + sep;
  11942. } else if (!(prefix = prototype.$className)) {
  11943. prefix = defaultIdPrefix + 'anonymous' + sep;
  11944. } else {
  11945. prefix = prefix.replace(cleanRe, sep).toLowerCase() + sep;
  11946. }
  11947. prototype.identifiablePrefix = prefix;
  11948. }
  11949. prefix = me.identifiablePrefix;
  11950. if (!uniqueIds.hasOwnProperty(prefix)) {
  11951. uniqueIds[prefix] = 0;
  11952. }
  11953. return prefix + (++uniqueIds[prefix]);
  11954. }
  11955. }
  11956. };
  11957. });
  11958. Ext.define('Ext.mixin.Observable', function(Observable) {
  11959. var emptyFn = Ext.emptyFn,
  11960. emptyArray = [],
  11961. arrayProto = Array.prototype,
  11962. arraySlice = arrayProto.slice,
  11963. ListenerRemover = function(observable) {
  11964. if (observable instanceof ListenerRemover) {
  11965. return observable;
  11966. }
  11967. this.observable = observable;
  11968. if (arguments[1].isObservable) {
  11969. this.managedListeners = true;
  11970. }
  11971. this.args = arraySlice.call(arguments, 1);
  11972. },
  11973. protectedProps = [
  11974. 'events',
  11975. 'hasListeners',
  11976. 'managedListeners',
  11977. 'eventedBeforeEventNames'
  11978. ];
  11979. ListenerRemover.prototype.destroy = function() {
  11980. var me = this,
  11981. args = me.args,
  11982. observable = me.observable,
  11983. elementName = args[0].element || (args[3] && args[3].element);
  11984. if (elementName) {
  11985. if (Ext.Array.indexOf(observable.referenceList, elementName) === -1) {
  11986. Ext.Logger.error("Destroying event listener with an invalid element reference " + "of '" + elementName + "' for this component. Available values are: '" + observable.referenceList.join("', '") + "'", observable);
  11987. }
  11988. observable = observable[elementName];
  11989. }
  11990. if (!observable.destroyed) {
  11991. observable[me.managedListeners ? 'mun' : 'un'].apply(observable, me.args);
  11992. }
  11993. me.destroy = Ext.emptyFn;
  11994. };
  11995. return {
  11996. extend: Ext.Mixin,
  11997. mixinConfig: {
  11998. id: 'observable',
  11999. after: {
  12000. destroy: 'destroyObservable'
  12001. }
  12002. },
  12003. mixins: [
  12004. Ext.mixin.Identifiable
  12005. ],
  12006. statics: {
  12007. releaseCapture: function(o) {
  12008. o.fireEventArgs = this.prototype.fireEventArgs;
  12009. },
  12010. capture: function(o, fn, scope) {
  12011. var newFn = function(eventName, args) {
  12012. return fn.apply(scope, [
  12013. eventName
  12014. ].concat(args));
  12015. };
  12016. this.captureArgs(o, newFn, scope);
  12017. },
  12018. captureArgs: function(o, fn, scope) {
  12019. o.fireEventArgs = Ext.Function.createInterceptor(o.fireEventArgs, fn, scope);
  12020. },
  12021. observe: function(cls, listeners) {
  12022. if (cls) {
  12023. if (!cls.isObservable) {
  12024. Ext.applyIf(cls, new this());
  12025. this.captureArgs(cls.prototype, cls.fireEventArgs, cls);
  12026. }
  12027. if (Ext.isObject(listeners)) {
  12028. cls.on(listeners);
  12029. }
  12030. }
  12031. return cls;
  12032. },
  12033. prepareClass: function(T, mixin, data) {
  12034. var listeners = T.listeners = [],
  12035. target = data || T.prototype,
  12036. targetListeners = target.listeners,
  12037. superListeners = mixin ? mixin.listeners : T.superclass.self.listeners,
  12038. scope, namedScope, i, len;
  12039. if (superListeners) {
  12040. listeners.push(superListeners);
  12041. }
  12042. if (targetListeners) {
  12043. scope = targetListeners.scope;
  12044. if (!scope) {
  12045. targetListeners.scope = 'self';
  12046. } else {
  12047. namedScope = Ext._namedScopes[scope];
  12048. if (namedScope && namedScope.isController) {
  12049. targetListeners.scope = 'self.controller';
  12050. }
  12051. }
  12052. listeners.push(targetListeners);
  12053. target.listeners = null;
  12054. }
  12055. if (!T.HasListeners) {
  12056. var HasListeners = function() {},
  12057. SuperHL = T.superclass.HasListeners || (mixin && mixin.HasListeners) || Observable.HasListeners;
  12058. T.prototype.HasListeners = T.HasListeners = HasListeners;
  12059. HasListeners.prototype = T.hasListeners = new SuperHL();
  12060. }
  12061. scope = T.prototype.$noClearOnDestroy || {};
  12062. for (i = 0 , len = protectedProps.length; i < len; i++) {
  12063. scope[protectedProps[i]] = true;
  12064. }
  12065. T.prototype.$noClearOnDestroy = scope;
  12066. }
  12067. },
  12068. isObservable: true,
  12069. $vetoClearingPrototypeOnDestroy: true,
  12070. eventsSuspended: 0,
  12071. constructor: function(config) {
  12072. var me = this,
  12073. self = me.self,
  12074. declaredListeners, listeners, bubbleEvents, len, i;
  12075. if (me.$observableInitialized) {
  12076. return;
  12077. }
  12078. me.$observableInitialized = true;
  12079. me.hasListeners = me.hasListeners = new me.HasListeners();
  12080. me.eventedBeforeEventNames = {};
  12081. me.events = me.events || {};
  12082. declaredListeners = self.listeners;
  12083. if (declaredListeners && !me._addDeclaredListeners(declaredListeners)) {
  12084. self.listeners = null;
  12085. }
  12086. listeners = (config && config.listeners) || me.listeners;
  12087. if (listeners) {
  12088. if (listeners instanceof Array) {
  12089. for (i = 0 , len = listeners.length; i < len; ++i) {
  12090. me.addListener(listeners[i]);
  12091. }
  12092. } else {
  12093. me.addListener(listeners);
  12094. }
  12095. }
  12096. bubbleEvents = (config && config.bubbleEvents) || me.bubbleEvents;
  12097. if (bubbleEvents) {
  12098. me.enableBubble(bubbleEvents);
  12099. }
  12100. if (me.$applyConfigs) {
  12101. if (config) {
  12102. Ext.apply(me, config);
  12103. }
  12104. } else {
  12105. me.initConfig(config);
  12106. }
  12107. if (listeners) {
  12108. me.listeners = null;
  12109. }
  12110. },
  12111. onClassExtended: function(T, data) {
  12112. if (!T.HasListeners) {
  12113. Observable.prepareClass(T, T.prototype.$observableMixedIn ? undefined : data);
  12114. }
  12115. },
  12116. $eventOptions: {
  12117. scope: 1,
  12118. delay: 1,
  12119. buffer: 1,
  12120. onFrame: 1,
  12121. single: 1,
  12122. args: 1,
  12123. destroyable: 1,
  12124. priority: 1,
  12125. order: 1
  12126. },
  12127. $orderToPriority: {
  12128. before: 100,
  12129. current: 0,
  12130. after: -100
  12131. },
  12132. _addDeclaredListeners: function(listeners) {
  12133. var me = this;
  12134. if (listeners instanceof Array) {
  12135. Ext.each(listeners, me._addDeclaredListeners, me);
  12136. } else {
  12137. me._addedDeclaredListeners = true;
  12138. me.addListener(listeners);
  12139. }
  12140. return me._addedDeclaredListeners;
  12141. },
  12142. addManagedListener: function(item, ename, fn, scope, options, noDestroy) {
  12143. var me = this,
  12144. config, passedOptions;
  12145. me.managedListeners = me.managedListeners || [];
  12146. if (typeof ename !== 'string') {
  12147. passedOptions = arguments.length > 4 ? options : ename;
  12148. options = ename;
  12149. for (ename in options) {
  12150. if (options.hasOwnProperty(ename)) {
  12151. config = options[ename];
  12152. if (!item.$eventOptions[ename]) {
  12153. me.addManagedListener(item, ename, config.fn || config, config.scope || options.scope || scope, config.fn ? config : passedOptions, true);
  12154. }
  12155. }
  12156. }
  12157. if (options && options.destroyable) {
  12158. return new ListenerRemover(me, item, options);
  12159. }
  12160. } else {
  12161. if (fn !== emptyFn) {
  12162. item.doAddListener(ename, fn, scope, options, null, me, me);
  12163. if (!noDestroy && options && options.destroyable) {
  12164. return new ListenerRemover(me, item, ename, fn, scope);
  12165. }
  12166. }
  12167. }
  12168. },
  12169. removeManagedListener: function(item, ename, fn, scope) {
  12170. var me = this,
  12171. options, config, managedListeners, length, i;
  12172. if (item.$observableDestroyed) {
  12173. return;
  12174. }
  12175. if (typeof ename !== 'string') {
  12176. options = ename;
  12177. for (ename in options) {
  12178. if (options.hasOwnProperty(ename)) {
  12179. config = options[ename];
  12180. if (!item.$eventOptions[ename]) {
  12181. me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope || scope);
  12182. }
  12183. }
  12184. }
  12185. } else {
  12186. managedListeners = me.managedListeners ? me.managedListeners.slice() : [];
  12187. ename = Ext.canonicalEventName(ename);
  12188. for (i = 0 , length = managedListeners.length; i < length; i++) {
  12189. me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope);
  12190. }
  12191. }
  12192. },
  12193. fireEvent: function(eventName) {
  12194. return this.fireEventArgs(eventName, arraySlice.call(arguments, 1));
  12195. },
  12196. resolveListenerScope: function(defaultScope) {
  12197. var namedScope = Ext._namedScopes[defaultScope];
  12198. if (namedScope) {
  12199. if (namedScope.isController) {
  12200. Ext.raise('scope: "controller" can only be specified on classes ' + 'that derive from Ext.Component or Ext.Widget');
  12201. }
  12202. if (namedScope.isSelf || namedScope.isThis) {
  12203. defaultScope = null;
  12204. }
  12205. }
  12206. return defaultScope || this;
  12207. },
  12208. fireEventArgs: function(eventName, args) {
  12209. var me = this,
  12210. events = me.events,
  12211. ret = true,
  12212. event;
  12213. eventName = Ext.canonicalEventName(eventName);
  12214. event = events && events[eventName];
  12215. if (me.hasListeners[eventName]) {
  12216. ret = me.doFireEvent(eventName, args || emptyArray, event ? event.bubble : false);
  12217. }
  12218. return ret;
  12219. },
  12220. fireAction: function(eventName, args, fn, scope, options, order) {
  12221. if (typeof fn === 'string' && !scope) {
  12222. fn = this[fn];
  12223. }
  12224. options = options ? Ext.Object.chain(options) : {};
  12225. options.single = true;
  12226. options.priority = ((order === 'after') ? -99.5 : 99.5);
  12227. this.doAddListener(eventName, fn, scope, options);
  12228. this.fireEventArgs(eventName, args);
  12229. },
  12230. $eventedController: {
  12231. _paused: 1,
  12232. pause: function() {
  12233. ++this._paused;
  12234. },
  12235. resume: function() {
  12236. var me = this,
  12237. fn = me.fn,
  12238. scope = me.scope,
  12239. fnArgs = me.fnArgs,
  12240. args, ret;
  12241. if (!--me._paused) {
  12242. if (fn) {
  12243. args = Ext.Array.slice(fnArgs || me.args);
  12244. if (fnArgs === false) {
  12245. args.shift();
  12246. }
  12247. me.fn = null;
  12248. args.push(me);
  12249. if (Ext.isFunction(fn)) {
  12250. ret = fn.apply(scope, args);
  12251. } else if (scope && Ext.isString(fn) && Ext.isFunction(scope[fn])) {
  12252. ret = scope[fn].apply(scope, args);
  12253. }
  12254. if (ret === false) {
  12255. return false;
  12256. }
  12257. }
  12258. if (!me._paused) {
  12259. return me.owner.fireEventArgs(me.eventName, me.args);
  12260. }
  12261. }
  12262. }
  12263. },
  12264. fireEventedAction: function(eventName, args, fn, scope, fnArgs) {
  12265. var me = this,
  12266. eventedBeforeEventNames = me.eventedBeforeEventNames,
  12267. beforeEventName = eventedBeforeEventNames[eventName] || (eventedBeforeEventNames[eventName] = 'before' + eventName),
  12268. controller = Ext.apply({
  12269. owner: me,
  12270. eventName: eventName,
  12271. fn: fn,
  12272. scope: scope,
  12273. fnArgs: fnArgs,
  12274. args: args
  12275. }, me.$eventedController),
  12276. value;
  12277. args.push(controller);
  12278. value = me.fireEventArgs(beforeEventName, args);
  12279. args.pop();
  12280. if (value === false) {
  12281. return false;
  12282. }
  12283. return controller.resume();
  12284. },
  12285. doFireEvent: function(eventName, args, bubbles) {
  12286. var target = this,
  12287. queue, event,
  12288. ret = true;
  12289. do {
  12290. if (target.eventsSuspended) {
  12291. if ((queue = target.eventQueue)) {
  12292. queue.push([
  12293. eventName,
  12294. args
  12295. ]);
  12296. }
  12297. return ret;
  12298. } else {
  12299. event = target.events && target.events[eventName];
  12300. if (event && event !== true) {
  12301. if ((ret = event.fire.apply(event, args)) === false) {
  12302. break;
  12303. }
  12304. }
  12305. }
  12306. } while (
  12307. bubbles && (target = target.getBubbleParent()));
  12308. return ret;
  12309. },
  12310. getBubbleParent: function() {
  12311. var me = this,
  12312. parent = me.getBubbleTarget && me.getBubbleTarget();
  12313. if (parent && parent.isObservable) {
  12314. return parent;
  12315. }
  12316. return null;
  12317. },
  12318. addListener: function(eventName, fn, scope, options, order, caller) {
  12319. var me = this,
  12320. namedScopes = Ext._namedScopes,
  12321. config, namedScope, isClassListener, innerScope, eventOptions;
  12322. if (typeof eventName !== 'string') {
  12323. options = eventName;
  12324. scope = options.scope;
  12325. namedScope = scope && namedScopes[scope];
  12326. isClassListener = namedScope && namedScope.isSelf;
  12327. eventOptions = ((me.isComponent || me.isWidget) && options.element) ? me.$elementEventOptions : me.$eventOptions;
  12328. for (eventName in options) {
  12329. config = options[eventName];
  12330. if (!eventOptions[eventName]) {
  12331. innerScope = config.scope;
  12332. if (innerScope && isClassListener) {
  12333. namedScope = namedScopes[innerScope];
  12334. if (namedScope && namedScope.isController) {
  12335. innerScope = 'self.controller';
  12336. }
  12337. }
  12338. me.doAddListener(eventName, config.fn || config, innerScope || scope, config.fn ? config : options, order, caller);
  12339. }
  12340. }
  12341. if (options && options.destroyable) {
  12342. return new ListenerRemover(me, options);
  12343. }
  12344. } else {
  12345. me.doAddListener(eventName, fn, scope, options, order, caller);
  12346. if (options && options.destroyable) {
  12347. return new ListenerRemover(me, eventName, fn, scope, options);
  12348. }
  12349. }
  12350. return me;
  12351. },
  12352. removeListener: function(eventName, fn, scope, eventOptions) {
  12353. var me = this,
  12354. config, options;
  12355. if (typeof eventName !== 'string') {
  12356. options = eventName;
  12357. eventOptions = eventOptions || me.$eventOptions;
  12358. for (eventName in options) {
  12359. if (options.hasOwnProperty(eventName)) {
  12360. config = options[eventName];
  12361. if (!me.$eventOptions[eventName]) {
  12362. me.doRemoveListener(eventName, config.fn || config, config.scope || options.scope);
  12363. }
  12364. }
  12365. }
  12366. } else {
  12367. me.doRemoveListener(eventName, fn, scope);
  12368. }
  12369. return me;
  12370. },
  12371. onBefore: function(eventName, fn, scope, options) {
  12372. return this.addListener(eventName, fn, scope, options, 'before');
  12373. },
  12374. onAfter: function(eventName, fn, scope, options) {
  12375. return this.addListener(eventName, fn, scope, options, 'after');
  12376. },
  12377. unBefore: function(eventName, fn, scope, options) {
  12378. return this.removeListener(eventName, fn, scope, options, 'before');
  12379. },
  12380. unAfter: function(eventName, fn, scope, options) {
  12381. return this.removeListener(eventName, fn, scope, options, 'after');
  12382. },
  12383. addBeforeListener: function() {
  12384. return this.onBefore.apply(this, arguments);
  12385. },
  12386. addAfterListener: function() {
  12387. return this.onAfter.apply(this, arguments);
  12388. },
  12389. removeBeforeListener: function() {
  12390. return this.unBefore.apply(this, arguments);
  12391. },
  12392. removeAfterListener: function() {
  12393. return this.unAfter.apply(this, arguments);
  12394. },
  12395. clearListeners: function() {
  12396. var me = this,
  12397. events = me.events,
  12398. hasListeners = me.hasListeners,
  12399. event, key;
  12400. if (events) {
  12401. for (key in events) {
  12402. if (events.hasOwnProperty(key)) {
  12403. event = events[key];
  12404. if (event.isEvent) {
  12405. delete hasListeners[key];
  12406. event.clearListeners();
  12407. }
  12408. }
  12409. }
  12410. me.events = null;
  12411. }
  12412. me.clearManagedListeners();
  12413. },
  12414. purgeListeners: function() {
  12415. if (Ext.global.console) {
  12416. Ext.global.console.warn('Observable: purgeListeners has been deprecated. ' + 'Please use clearListeners.');
  12417. }
  12418. return this.clearListeners.apply(this, arguments);
  12419. },
  12420. clearManagedListeners: function() {
  12421. var me = this,
  12422. managedListeners = me.managedListeners,
  12423. i, len;
  12424. if (managedListeners) {
  12425. me.managedListeners = null;
  12426. for (i = 0 , len = managedListeners.length; i < len; i++) {
  12427. me.removeManagedListenerItem(true, managedListeners[i]);
  12428. }
  12429. managedListeners.length = 0;
  12430. }
  12431. me.managedListeners = managedListeners;
  12432. },
  12433. removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope) {
  12434. if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {
  12435. if (!managedListener.item.destroyed) {
  12436. managedListener.item.doRemoveListener(managedListener.ename, managedListener.fn, managedListener.scope, managedListener.options);
  12437. }
  12438. if (!isClear) {
  12439. Ext.Array.remove(this.managedListeners, managedListener);
  12440. }
  12441. }
  12442. },
  12443. purgeManagedListeners: function() {
  12444. if (Ext.global.console) {
  12445. Ext.global.console.warn('Observable: purgeManagedListeners has been deprecated. ' + 'Please use clearManagedListeners.');
  12446. }
  12447. return this.clearManagedListeners.apply(this, arguments);
  12448. },
  12449. hasListener: function(eventName) {
  12450. eventName = Ext.canonicalEventName(eventName);
  12451. return !!this.hasListeners[eventName];
  12452. },
  12453. isSuspended: function(event) {
  12454. var suspended = this.eventsSuspended > 0,
  12455. events = this.events;
  12456. if (!suspended && event && events) {
  12457. event = events[event];
  12458. if (event && event.isEvent) {
  12459. return event.isSuspended();
  12460. }
  12461. }
  12462. return suspended;
  12463. },
  12464. suspendEvents: function(queueSuspended) {
  12465. ++this.eventsSuspended;
  12466. if (queueSuspended && !this.eventQueue) {
  12467. this.eventQueue = [];
  12468. }
  12469. },
  12470. suspendEvent: function() {
  12471. var me = this,
  12472. events = me.events,
  12473. len = arguments.length,
  12474. i, event, ename;
  12475. for (i = 0; i < len; i++) {
  12476. ename = arguments[i];
  12477. ename = Ext.canonicalEventName(ename);
  12478. event = events[ename];
  12479. if (!event || !event.isEvent) {
  12480. event = me._initEvent(ename);
  12481. }
  12482. event.suspend();
  12483. }
  12484. },
  12485. resumeEvent: function() {
  12486. var events = this.events || 0,
  12487. len = events && arguments.length,
  12488. i, event, ename;
  12489. for (i = 0; i < len; i++) {
  12490. ename = Ext.canonicalEventName(arguments[i]);
  12491. event = events[ename];
  12492. if (event && event.resume) {
  12493. event.resume();
  12494. }
  12495. }
  12496. },
  12497. resumeEvents: function(discardQueue) {
  12498. var me = this,
  12499. queued = me.eventQueue,
  12500. qLen, q;
  12501. if (me.eventsSuspended && !--me.eventsSuspended) {
  12502. delete me.eventQueue;
  12503. if (!discardQueue && queued) {
  12504. qLen = queued.length;
  12505. for (q = 0; q < qLen; q++) {
  12506. me.fireEventArgs.apply(me, queued[q]);
  12507. }
  12508. }
  12509. }
  12510. },
  12511. relayEvents: function(origin, events, prefix) {
  12512. var me = this,
  12513. len = events.length,
  12514. i = 0,
  12515. oldName, newName,
  12516. relayers = {};
  12517. if (Ext.isObject(events)) {
  12518. for (i in events) {
  12519. newName = events[i];
  12520. relayers[i] = me.createRelayer(newName);
  12521. }
  12522. } else {
  12523. for (; i < len; i++) {
  12524. oldName = events[i];
  12525. relayers[oldName] = me.createRelayer(prefix ? prefix + oldName : oldName);
  12526. }
  12527. }
  12528. me.mon(origin, relayers, null, null, undefined);
  12529. return new ListenerRemover(me, origin, relayers);
  12530. },
  12531. createRelayer: function(newName, beginEnd) {
  12532. var me = this;
  12533. return function() {
  12534. return me.fireEventArgs.call(me, newName, beginEnd ? arraySlice.apply(arguments, beginEnd) : arguments);
  12535. };
  12536. },
  12537. enableBubble: function(eventNames) {
  12538. if (eventNames) {
  12539. var me = this,
  12540. names = (typeof eventNames === 'string') ? arguments : eventNames,
  12541. events = me.events,
  12542. length = events && names.length,
  12543. ename, event, i;
  12544. for (i = 0; i < length; ++i) {
  12545. ename = names[i];
  12546. ename = Ext.canonicalEventName(ename);
  12547. event = events[ename];
  12548. if (!event || !event.isEvent) {
  12549. event = me._initEvent(ename);
  12550. }
  12551. me.hasListeners._incr_(ename);
  12552. event.bubble = true;
  12553. }
  12554. }
  12555. },
  12556. destroy: function() {
  12557. this.clearListeners();
  12558. this.callParent();
  12559. this.destroyObservable(true);
  12560. },
  12561. destroyObservable: function(skipClearListeners) {
  12562. var me = this,
  12563. clearPropertiesOnDestroy = me.clearPropertiesOnDestroy;
  12564. if (me.$observableDestroyed) {
  12565. return;
  12566. }
  12567. if (!skipClearListeners) {
  12568. me.clearListeners();
  12569. }
  12570. if (me.destroyed) {
  12571. if (clearPropertiesOnDestroy) {
  12572. if (clearPropertiesOnDestroy === true && !me.$nulled) {
  12573. me.$reap();
  12574. }
  12575. if (!me.clearPrototypeOnDestroy) {
  12576. me.fireEvent = me.fireEventArgs = me.fireAction = me.fireEventedAction = Ext.emptyFn;
  12577. }
  12578. me.events = me.managedListeners = me.eventedBeforeEventNames = null;
  12579. me.$observableDestroyed = true;
  12580. }
  12581. if (me.clearPrototypeOnDestroy && Object.setPrototypeOf && !me.$alreadyNulled) {
  12582. Object.setPrototypeOf(me, null);
  12583. me.$alreadyNulled = true;
  12584. }
  12585. }
  12586. },
  12587. privates: {
  12588. doAddListener: function(ename, fn, scope, options, order, caller, manager) {
  12589. var me = this,
  12590. ret = false,
  12591. event, priority;
  12592. order = order || (options && options.order);
  12593. if (order) {
  12594. priority = (options && options.priority);
  12595. if (!priority) {
  12596. options = options ? Ext.Object.chain(options) : {};
  12597. options.priority = me.$orderToPriority[order];
  12598. }
  12599. }
  12600. ename = Ext.canonicalEventName(ename);
  12601. if (!fn) {
  12602. Ext.raise("Cannot add '" + ename + "' listener to " + me.$className + " instance. No function specified.");
  12603. }
  12604. event = (me.events || (me.events = {}))[ename];
  12605. if (!event || !event.isEvent) {
  12606. event = me._initEvent(ename);
  12607. }
  12608. if (fn !== emptyFn) {
  12609. if (!manager && (scope && scope.isObservable && (scope !== me))) {
  12610. manager = scope;
  12611. }
  12612. if (event.addListener(fn, scope, options, caller, manager)) {
  12613. me.hasListeners._incr_(ename);
  12614. ret = true;
  12615. }
  12616. }
  12617. return ret;
  12618. },
  12619. doRemoveListener: function(ename, fn, scope) {
  12620. var me = this,
  12621. ret = false,
  12622. events = me.events,
  12623. event;
  12624. ename = Ext.canonicalEventName(ename);
  12625. event = events && events[ename];
  12626. if (!fn) {
  12627. Ext.raise("Cannot remove '" + ename + "' listener to " + me.$className + " instance. No function specified.");
  12628. }
  12629. if (event && event.isEvent) {
  12630. if (event.removeListener(fn, scope)) {
  12631. me.hasListeners._decr_(ename);
  12632. ret = true;
  12633. }
  12634. }
  12635. return ret;
  12636. },
  12637. _initEvent: function(eventName) {
  12638. return (this.events[eventName] = new Ext.util.Event(this, eventName));
  12639. }
  12640. },
  12641. deprecated: {
  12642. '5.0': {
  12643. methods: {
  12644. addEvents: null
  12645. }
  12646. }
  12647. }
  12648. };
  12649. }, function() {
  12650. var Observable = this,
  12651. proto = Observable.prototype,
  12652. HasListeners = function() {},
  12653. prepareMixin = function(T) {
  12654. var proto = T.prototype;
  12655. if (!T.HasListeners) {
  12656. proto.$observableMixedIn = 1;
  12657. Observable.prepareClass(T, this);
  12658. T.onExtended(function(U, data) {
  12659. if (Ext.classSystemMonitor) {
  12660. Ext.classSystemMonitor('extend mixin', arguments);
  12661. }
  12662. Observable.prepareClass(U, null, data);
  12663. });
  12664. if (proto.onClassMixedIn) {
  12665. Ext.override(T, {
  12666. onClassMixedIn: function(U) {
  12667. prepareMixin.call(this, U);
  12668. this.callParent(arguments);
  12669. }
  12670. });
  12671. } else {
  12672. proto.onClassMixedIn = function(U) {
  12673. prepareMixin.call(this, U);
  12674. };
  12675. }
  12676. }
  12677. superOnClassMixedIn.call(this, T);
  12678. },
  12679. superOnClassMixedIn = proto.onClassMixedIn;
  12680. HasListeners.prototype = {
  12681. _decr_: function(ev, count) {
  12682. if (count == null) {
  12683. count = 1;
  12684. }
  12685. if (!(this[ev] -= count)) {
  12686. delete this[ev];
  12687. }
  12688. },
  12689. _incr_: function(ev) {
  12690. if (this.hasOwnProperty(ev)) {
  12691. ++this[ev];
  12692. } else {
  12693. this[ev] = 1;
  12694. }
  12695. }
  12696. };
  12697. proto.HasListeners = Observable.HasListeners = HasListeners;
  12698. Observable.createAlias({
  12699. on: 'addListener',
  12700. un: 'removeListener',
  12701. mon: 'addManagedListener',
  12702. mun: 'removeManagedListener',
  12703. setListeners: 'addListener'
  12704. });
  12705. Observable.observeClass = Observable.observe;
  12706. function getMethodEvent(method) {
  12707. var event = (this.methodEvents = this.methodEvents || {})[method],
  12708. returnValue, v, cancel,
  12709. me = this,
  12710. makeCall;
  12711. if (!event) {
  12712. me.methodEvents[method] = event = {};
  12713. event.originalFn = me[method];
  12714. event.methodName = method;
  12715. event.before = [];
  12716. event.after = [];
  12717. makeCall = function(fn, scope, args) {
  12718. scope = scope || me;
  12719. if (typeof fn === 'string') {
  12720. fn = scope[fn];
  12721. }
  12722. if ((v = fn.apply(scope, args)) !== undefined) {
  12723. if (typeof v === 'object') {
  12724. if (v.returnValue !== undefined) {
  12725. returnValue = v.returnValue;
  12726. } else {
  12727. returnValue = v;
  12728. }
  12729. cancel = !!v.cancel;
  12730. } else if (v === false) {
  12731. cancel = true;
  12732. } else {
  12733. returnValue = v;
  12734. }
  12735. }
  12736. };
  12737. me[method] = function() {
  12738. var args = Array.prototype.slice.call(arguments, 0),
  12739. argsLen = args.length,
  12740. b, i, len;
  12741. returnValue = v = undefined;
  12742. cancel = false;
  12743. for (i = 0 , len = event.before.length; i < len; i++) {
  12744. b = event.before[i];
  12745. if (b.extraArgs) {
  12746. args.push.apply(args, b.extraArgs);
  12747. }
  12748. makeCall(b.fn, b.scope, args);
  12749. args.length = argsLen;
  12750. if (cancel || b.preventDefault) {
  12751. return returnValue;
  12752. }
  12753. }
  12754. if ((v = event.originalFn.apply(me, args)) !== undefined) {
  12755. returnValue = v;
  12756. }
  12757. for (i = 0 , len = event.after.length; i < len; i++) {
  12758. b = event.after[i];
  12759. if (b.extraArgs) {
  12760. args.push.apply(args, b.extraArgs);
  12761. }
  12762. makeCall(b.fn, b.scope, args);
  12763. args.length = argsLen;
  12764. if (cancel || b.preventDefault) {
  12765. return returnValue;
  12766. }
  12767. }
  12768. return returnValue;
  12769. };
  12770. }
  12771. return event;
  12772. }
  12773. Ext.apply(proto, {
  12774. onClassMixedIn: prepareMixin,
  12775. beforeMethod: function(method, fn, scope, preventDefault, extraArgs) {
  12776. getMethodEvent.call(this, method).before.push({
  12777. fn: fn,
  12778. scope: scope,
  12779. extraArgs: extraArgs,
  12780. preventDefault: preventDefault
  12781. });
  12782. },
  12783. afterMethod: function(method, fn, scope, preventDefault, extraArgs) {
  12784. getMethodEvent.call(this, method).after.push({
  12785. fn: fn,
  12786. scope: scope,
  12787. extraArgs: extraArgs,
  12788. preventDefault: preventDefault
  12789. });
  12790. },
  12791. removeMethodListener: function(method, fn, scope) {
  12792. var e = getMethodEvent.call(this, method),
  12793. i, len;
  12794. for (i = 0 , len = e.before.length; i < len; i++) {
  12795. if (e.before[i].fn == fn && e.before[i].scope == scope) {
  12796. Ext.Array.erase(e.before, i, 1);
  12797. return;
  12798. }
  12799. }
  12800. for (i = 0 , len = e.after.length; i < len; i++) {
  12801. if (e.after[i].fn == fn && e.after[i].scope == scope) {
  12802. Ext.Array.erase(e.after, i, 1);
  12803. return;
  12804. }
  12805. }
  12806. },
  12807. toggleEventLogging: function(toggle) {
  12808. Ext.util.Observable[toggle ? 'capture' : 'releaseCapture'](this, function(en) {
  12809. if (Ext.isDefined(Ext.global.console)) {
  12810. Ext.global.console.log(en, arguments);
  12811. }
  12812. });
  12813. }
  12814. });
  12815. });
  12816. Ext.define('Ext.util.HashMap', {
  12817. mixins: [
  12818. Ext.mixin.Observable
  12819. ],
  12820. generation: 0,
  12821. config: {
  12822. keyFn: null
  12823. },
  12824. constructor: function(config) {
  12825. var me = this,
  12826. fn;
  12827. me.mixins.observable.constructor.call(me, config);
  12828. me.clear(true);
  12829. fn = me.getKeyFn();
  12830. if (fn) {
  12831. me.getKey = fn;
  12832. }
  12833. },
  12834. getCount: function() {
  12835. return this.length;
  12836. },
  12837. getData: function(key, value) {
  12838. if (value === undefined) {
  12839. value = key;
  12840. key = this.getKey(value);
  12841. }
  12842. return [
  12843. key,
  12844. value
  12845. ];
  12846. },
  12847. getKey: function(o) {
  12848. return o.id;
  12849. },
  12850. add: function(key, value) {
  12851. var me = this;
  12852. if (arguments.length === 1) {
  12853. value = key;
  12854. key = me.getKey(value);
  12855. }
  12856. if (me.containsKey(key)) {
  12857. return me.replace(key, value);
  12858. }
  12859. me.map[key] = value;
  12860. ++me.length;
  12861. me.generation++;
  12862. if (me.hasListeners.add) {
  12863. me.fireEvent('add', me, key, value);
  12864. }
  12865. return value;
  12866. },
  12867. replace: function(key, value) {
  12868. var me = this,
  12869. map = me.map,
  12870. old;
  12871. if (arguments.length === 1) {
  12872. value = key;
  12873. key = me.getKey(value);
  12874. }
  12875. if (!me.containsKey(key)) {
  12876. me.add(key, value);
  12877. }
  12878. old = map[key];
  12879. map[key] = value;
  12880. me.generation++;
  12881. if (me.hasListeners.replace) {
  12882. me.fireEvent('replace', me, key, value, old);
  12883. }
  12884. return value;
  12885. },
  12886. remove: function(o) {
  12887. var key = this.findKey(o);
  12888. if (key !== undefined) {
  12889. return this.removeAtKey(key);
  12890. }
  12891. return false;
  12892. },
  12893. removeAtKey: function(key) {
  12894. var me = this,
  12895. value;
  12896. if (me.containsKey(key)) {
  12897. value = me.map[key];
  12898. delete me.map[key];
  12899. --me.length;
  12900. me.generation++;
  12901. if (me.hasListeners.remove) {
  12902. me.fireEvent('remove', me, key, value);
  12903. }
  12904. return true;
  12905. }
  12906. return false;
  12907. },
  12908. get: function(key) {
  12909. var map = this.map;
  12910. return map.hasOwnProperty(key) ? map[key] : undefined;
  12911. },
  12912. clear: function(initial) {
  12913. var me = this;
  12914. if (initial || me.generation) {
  12915. me.map = {};
  12916. me.length = 0;
  12917. me.generation = initial ? 0 : me.generation + 1;
  12918. }
  12919. if (initial !== true && me.hasListeners.clear) {
  12920. me.fireEvent('clear', me);
  12921. }
  12922. return me;
  12923. },
  12924. containsKey: function(key) {
  12925. var map = this.map;
  12926. return map.hasOwnProperty(key) && map[key] !== undefined;
  12927. },
  12928. contains: function(value) {
  12929. return this.containsKey(this.findKey(value));
  12930. },
  12931. getKeys: function() {
  12932. return this.getArray(true);
  12933. },
  12934. getValues: function() {
  12935. return this.getArray(false);
  12936. },
  12937. getArray: function(isKey) {
  12938. var arr = [],
  12939. key,
  12940. map = this.map;
  12941. for (key in map) {
  12942. if (map.hasOwnProperty(key)) {
  12943. arr.push(isKey ? key : map[key]);
  12944. }
  12945. }
  12946. return arr;
  12947. },
  12948. each: function(fn, scope) {
  12949. var items = Ext.apply({}, this.map),
  12950. key,
  12951. length = this.length;
  12952. scope = scope || this;
  12953. for (key in items) {
  12954. if (items.hasOwnProperty(key)) {
  12955. if (fn.call(scope, key, items[key], length) === false) {
  12956. break;
  12957. }
  12958. }
  12959. }
  12960. return this;
  12961. },
  12962. clone: function() {
  12963. var hash = new this.self(this.initialConfig),
  12964. map = this.map,
  12965. key;
  12966. hash.suspendEvents();
  12967. for (key in map) {
  12968. if (map.hasOwnProperty(key)) {
  12969. hash.add(key, map[key]);
  12970. }
  12971. }
  12972. hash.resumeEvents();
  12973. return hash;
  12974. },
  12975. findKey: function(value) {
  12976. var key,
  12977. map = this.map;
  12978. for (key in map) {
  12979. if (map.hasOwnProperty(key) && map[key] === value) {
  12980. return key;
  12981. }
  12982. }
  12983. return undefined;
  12984. }
  12985. }, function(HashMap) {
  12986. var prototype = HashMap.prototype;
  12987. prototype.removeByKey = prototype.removeAtKey;
  12988. });
  12989. Ext.define('Ext.AbstractManager', {
  12990. typeName: 'type',
  12991. constructor: function(config) {
  12992. Ext.apply(this, config || {});
  12993. this.all = new Ext.util.HashMap();
  12994. this.types = {};
  12995. },
  12996. get: function(id) {
  12997. return this.all.get(id);
  12998. },
  12999. register: function(item) {
  13000. var key = this.all.getKey(item);
  13001. if (key === undefined) {
  13002. Ext.raise('Key is undefined. Please ensure the item has a key ' + 'before registering the item.');
  13003. }
  13004. if (this.all.containsKey(key)) {
  13005. Ext.raise('Registering duplicate id "' + key + '" with ' + this.$className);
  13006. }
  13007. this.all.add(item);
  13008. },
  13009. unregister: function(item) {
  13010. this.all.remove(item);
  13011. },
  13012. registerType: function(type, cls) {
  13013. this.types[type] = cls;
  13014. cls[this.typeName] = type;
  13015. },
  13016. isRegistered: function(type) {
  13017. return this.types[type] !== undefined;
  13018. },
  13019. create: function(config, defaultType) {
  13020. var type = config[this.typeName] || config.type || defaultType,
  13021. Constructor = this.types[type];
  13022. if (Constructor === undefined) {
  13023. Ext.raise("The '" + type + "' type has not been registered with this manager");
  13024. }
  13025. return new Constructor(config);
  13026. },
  13027. onAvailable: function(id, fn, scope) {
  13028. var all = this.all,
  13029. item, callback;
  13030. if (all.containsKey(id)) {
  13031. item = all.get(id);
  13032. fn.call(scope || item, item);
  13033. } else {
  13034. callback = function(map, key, item) {
  13035. if (key === id) {
  13036. fn.call(scope || item, item);
  13037. all.un('add', callback);
  13038. }
  13039. };
  13040. all.on('add', callback);
  13041. }
  13042. },
  13043. each: function(fn, scope) {
  13044. this.all.each(fn, scope || this);
  13045. },
  13046. getCount: function() {
  13047. return this.all.getCount();
  13048. }
  13049. });
  13050. Ext.define('Ext.promise.Consequence', function(Consequence) {
  13051. return {
  13052. promise: null,
  13053. deferred: null,
  13054. onFulfilled: null,
  13055. onRejected: null,
  13056. onProgress: null,
  13057. constructor: function(onFulfilled, onRejected, onProgress) {
  13058. var me = this;
  13059. me.onFulfilled = onFulfilled;
  13060. me.onRejected = onRejected;
  13061. me.onProgress = onProgress;
  13062. me.deferred = new Ext.promise.Deferred();
  13063. me.promise = me.deferred.promise;
  13064. },
  13065. trigger: function(action, value) {
  13066. var me = this,
  13067. deferred = me.deferred;
  13068. switch (action) {
  13069. case 'fulfill':
  13070. me.propagate(value, me.onFulfilled, deferred, deferred.resolve);
  13071. break;
  13072. case 'reject':
  13073. me.propagate(value, me.onRejected, deferred, deferred.reject);
  13074. break;
  13075. }
  13076. },
  13077. update: function(progress) {
  13078. if (Ext.isFunction(this.onProgress)) {
  13079. progress = this.onProgress(progress);
  13080. }
  13081. this.deferred.update(progress);
  13082. },
  13083. propagate: function(value, callback, deferred, deferredMethod) {
  13084. if (Ext.isFunction(callback)) {
  13085. this.schedule(function() {
  13086. try {
  13087. deferred.resolve(callback(value));
  13088. } catch (e) {
  13089. deferred.reject(e);
  13090. }
  13091. });
  13092. } else {
  13093. deferredMethod.call(this.deferred, value);
  13094. }
  13095. },
  13096. schedule: function(callback) {
  13097. var n = Consequence.queueSize++;
  13098. Consequence.queue[n] = callback;
  13099. if (!n) {
  13100. Ext.asap(Consequence.dispatch);
  13101. }
  13102. },
  13103. statics: {
  13104. queue: new Array(10000),
  13105. queueSize: 0,
  13106. dispatch: function() {
  13107. var queue = Consequence.queue,
  13108. fn, i;
  13109. for (i = 0; i < Consequence.queueSize; ++i) {
  13110. fn = queue[i];
  13111. queue[i] = null;
  13112. fn();
  13113. }
  13114. Consequence.queueSize = 0;
  13115. }
  13116. }
  13117. };
  13118. },
  13119. function(Consequence) {
  13120. Consequence.dispatch.$skipTimerCheck = true;
  13121. });
  13122. Ext.define('Ext.promise.Deferred', {
  13123. promise: null,
  13124. consequences: [],
  13125. completed: false,
  13126. completionAction: null,
  13127. completionValue: null,
  13128. constructor: function() {
  13129. var me = this;
  13130. me.promise = new Ext.promise.Promise(me);
  13131. me.consequences = [];
  13132. me.completed = false;
  13133. me.completionAction = null;
  13134. me.completionValue = null;
  13135. },
  13136. then: function(onFulfilled, onRejected, onProgress) {
  13137. var me = this,
  13138. consequence = new Ext.promise.Consequence(onFulfilled, onRejected, onProgress);
  13139. if (me.completed) {
  13140. consequence.trigger(me.completionAction, me.completionValue);
  13141. } else {
  13142. me.consequences.push(consequence);
  13143. }
  13144. return consequence.promise;
  13145. },
  13146. resolve: function(value) {
  13147. var me = this,
  13148. isHandled, thenFn;
  13149. if (me.completed) {
  13150. return;
  13151. }
  13152. try {
  13153. if (value === me.promise) {
  13154. throw new TypeError('A Promise cannot be resolved with itself.');
  13155. }
  13156. if (value != null && (typeof value === 'object' || Ext.isFunction(value)) && Ext.isFunction(thenFn = value.then)) {
  13157. isHandled = false;
  13158. try {
  13159. thenFn.call(value, function(value) {
  13160. if (!isHandled) {
  13161. isHandled = true;
  13162. me.resolve(value);
  13163. }
  13164. }, function(error) {
  13165. if (!isHandled) {
  13166. isHandled = true;
  13167. me.reject(error);
  13168. }
  13169. });
  13170. } catch (e1) {
  13171. if (!isHandled) {
  13172. me.reject(e1);
  13173. }
  13174. }
  13175. } else {
  13176. me.complete('fulfill', value);
  13177. }
  13178. } catch (e2) {
  13179. me.reject(e2);
  13180. }
  13181. },
  13182. reject: function(reason) {
  13183. if (this.completed) {
  13184. return;
  13185. }
  13186. this.complete('reject', reason);
  13187. },
  13188. update: function(progress) {
  13189. var consequences = this.consequences,
  13190. consequence, i, len;
  13191. if (this.completed) {
  13192. return;
  13193. }
  13194. for (i = 0 , len = consequences.length; i < len; i++) {
  13195. consequence = consequences[i];
  13196. consequence.update(progress);
  13197. }
  13198. },
  13199. complete: function(action, value) {
  13200. var me = this,
  13201. consequences = me.consequences,
  13202. consequence, i, len;
  13203. me.completionAction = action;
  13204. me.completionValue = value;
  13205. me.completed = true;
  13206. for (i = 0 , len = consequences.length; i < len; i++) {
  13207. consequence = consequences[i];
  13208. consequence.trigger(me.completionAction, me.completionValue);
  13209. }
  13210. me.consequences = null;
  13211. }
  13212. });
  13213. Ext.define('Ext.promise.Promise', function(ExtPromise) {
  13214. var Deferred;
  13215. return {
  13216. statics: {
  13217. CancellationError: Ext.global.CancellationError || Error,
  13218. _ready: function() {
  13219. Deferred = Ext.promise.Deferred;
  13220. },
  13221. all: function(promisesOrValues) {
  13222. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  13223. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13224. }
  13225. return ExtPromise.when(promisesOrValues).then(function(promisesOrValues) {
  13226. var deferred = new Deferred(),
  13227. remainingToResolve = promisesOrValues.length,
  13228. results = new Array(remainingToResolve),
  13229. index, promiseOrValue, resolve, i, len;
  13230. if (!remainingToResolve) {
  13231. deferred.resolve(results);
  13232. } else {
  13233. resolve = function(item, index) {
  13234. return ExtPromise.when(item).then(function(value) {
  13235. results[index] = value;
  13236. if (!--remainingToResolve) {
  13237. deferred.resolve(results);
  13238. }
  13239. return value;
  13240. }, function(reason) {
  13241. return deferred.reject(reason);
  13242. });
  13243. };
  13244. for (index = i = 0 , len = promisesOrValues.length; i < len; index = ++i) {
  13245. promiseOrValue = promisesOrValues[index];
  13246. if (index in promisesOrValues) {
  13247. resolve(promiseOrValue, index);
  13248. } else {
  13249. remainingToResolve--;
  13250. }
  13251. }
  13252. }
  13253. return deferred.promise;
  13254. });
  13255. },
  13256. is: function(value) {
  13257. return value != null && (typeof value === 'object' || Ext.isFunction(value)) && Ext.isFunction(value.then);
  13258. },
  13259. race: function(promises) {
  13260. var deferred = new Deferred(),
  13261. len = promises.length,
  13262. i;
  13263. if (!Ext.isArray(promises)) {
  13264. Ext.raise('Invalid parameter: expected an Array.');
  13265. }
  13266. for (i = 0; i < len; ++i) {
  13267. deferred.resolve(promises[i]);
  13268. }
  13269. return deferred.promise;
  13270. },
  13271. rethrowError: function(error) {
  13272. Ext.asap(function() {
  13273. throw error;
  13274. });
  13275. },
  13276. when: function(value) {
  13277. var deferred = new Deferred();
  13278. deferred.resolve(value);
  13279. return deferred.promise;
  13280. }
  13281. },
  13282. owner: null,
  13283. constructor: function(owner) {
  13284. this.owner = owner;
  13285. },
  13286. then: function(onFulfilled, onRejected, onProgress, scope) {
  13287. var ref;
  13288. if (arguments.length === 1 && Ext.isObject(arguments[0])) {
  13289. ref = arguments[0];
  13290. onFulfilled = ref.success;
  13291. onRejected = ref.failure;
  13292. onProgress = ref.progress;
  13293. scope = ref.scope;
  13294. }
  13295. if (scope) {
  13296. if (onFulfilled) {
  13297. onFulfilled = onFulfilled.bind(scope);
  13298. }
  13299. if (onRejected) {
  13300. onRejected = onRejected.bind(scope);
  13301. }
  13302. if (onProgress) {
  13303. onProgress = onProgress.bind(scope);
  13304. }
  13305. }
  13306. return this.owner.then(onFulfilled, onRejected, onProgress);
  13307. },
  13308. 'catch': function(onRejected, scope) {
  13309. var ref;
  13310. if (arguments.length === 1 && Ext.isObject(arguments[0])) {
  13311. ref = arguments[0];
  13312. onRejected = ref.fn;
  13313. scope = ref.scope;
  13314. }
  13315. if (scope != null) {
  13316. onRejected = onRejected.bind(scope);
  13317. }
  13318. return this.owner.then(null, onRejected);
  13319. },
  13320. otherwise: function(onRejected, scope) {
  13321. return this['catch'].apply(this, arguments);
  13322. },
  13323. always: function(onCompleted, scope) {
  13324. var ref;
  13325. if (arguments.length === 1 && Ext.isObject(arguments[0])) {
  13326. ref = arguments[0];
  13327. onCompleted = ref.fn;
  13328. scope = ref.scope;
  13329. }
  13330. if (scope != null) {
  13331. onCompleted = onCompleted.bind(scope);
  13332. }
  13333. return this.owner.then(function(value) {
  13334. try {
  13335. onCompleted();
  13336. } catch (e) {
  13337. ExtPromise.rethrowError(e);
  13338. }
  13339. return value;
  13340. }, function(reason) {
  13341. try {
  13342. onCompleted();
  13343. } catch (e) {
  13344. ExtPromise.rethrowError(e);
  13345. }
  13346. throw reason;
  13347. });
  13348. },
  13349. done: function() {
  13350. this.owner.then(null, ExtPromise.rethrowError);
  13351. },
  13352. cancel: function(reason) {
  13353. if (reason == null) {
  13354. reason = null;
  13355. }
  13356. this.owner.reject(new this.self.CancellationError(reason));
  13357. },
  13358. log: function(identifier) {
  13359. if (identifier == null) {
  13360. identifier = '';
  13361. }
  13362. return this.owner.then(function(value) {
  13363. Ext.log("" + (identifier || 'Promise') + " resolved with value: " + value);
  13364. return value;
  13365. }, function(reason) {
  13366. Ext.log("" + (identifier || 'Promise') + " rejected with reason: " + reason);
  13367. throw reason;
  13368. });
  13369. }
  13370. };
  13371. }, function(ExtPromise) {
  13372. ExtPromise._ready();
  13373. });
  13374. Ext.define('Ext.Promise', function() {
  13375. var Polyfiller;
  13376. return {
  13377. statics: {
  13378. _ready: function() {
  13379. Polyfiller = Ext.promise.Promise;
  13380. },
  13381. all: function() {
  13382. return Polyfiller.all.apply(Polyfiller, arguments);
  13383. },
  13384. race: function() {
  13385. return Polyfiller.race.apply(Polyfiller, arguments);
  13386. },
  13387. reject: function(reason) {
  13388. var deferred = new Ext.promise.Deferred();
  13389. deferred.reject(reason);
  13390. return deferred.promise;
  13391. },
  13392. resolve: function(value) {
  13393. var deferred = new Ext.promise.Deferred();
  13394. deferred.resolve(value);
  13395. return deferred.promise;
  13396. }
  13397. },
  13398. constructor: function(action) {
  13399. var deferred = new Ext.promise.Deferred();
  13400. action(deferred.resolve.bind(deferred), deferred.reject.bind(deferred));
  13401. return deferred.promise;
  13402. }
  13403. };
  13404. }, function(ExtPromise) {
  13405. var P = Ext.global.Promise;
  13406. if (P && P.resolve && !Ext.useExtPromises) {
  13407. Ext.Promise = P;
  13408. } else {
  13409. ExtPromise._ready();
  13410. }
  13411. });
  13412. Ext.define('Ext.Deferred', function(Deferred) {
  13413. var ExtPromise, rejected, resolved, when;
  13414. return {
  13415. extend: Ext.promise.Deferred,
  13416. statics: {
  13417. _ready: function() {
  13418. ExtPromise = Ext.promise.Promise;
  13419. when = Ext.Promise.resolve;
  13420. },
  13421. all: function() {
  13422. return ExtPromise.all.apply(ExtPromise, arguments);
  13423. },
  13424. any: function(promisesOrValues) {
  13425. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  13426. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13427. }
  13428. return Deferred.some(promisesOrValues, 1).then(function(array) {
  13429. return array[0];
  13430. }, function(error) {
  13431. if (error instanceof Error && error.message === 'Too few Promises were resolved.') {
  13432. Ext.raise('No Promises were resolved.');
  13433. } else {
  13434. throw error;
  13435. }
  13436. });
  13437. },
  13438. delay: function(promiseOrValue, milliseconds) {
  13439. var deferred;
  13440. if (arguments.length === 1) {
  13441. milliseconds = promiseOrValue;
  13442. promiseOrValue = undefined;
  13443. }
  13444. milliseconds = Math.max(milliseconds, 1);
  13445. deferred = new Deferred();
  13446. deferred.timeoutId = Ext.defer(function() {
  13447. delete deferred.timeoutId;
  13448. deferred.resolve(promiseOrValue);
  13449. }, milliseconds);
  13450. return deferred.promise;
  13451. },
  13452. getCachedRejected: function() {
  13453. if (!rejected) {
  13454. rejected = Ext.Promise.reject();
  13455. }
  13456. return rejected;
  13457. },
  13458. getCachedResolved: function() {
  13459. if (!resolved) {
  13460. resolved = Ext.Promise.resolve();
  13461. }
  13462. return resolved;
  13463. },
  13464. map: function(promisesOrValues, mapFn) {
  13465. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  13466. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13467. }
  13468. if (!Ext.isFunction(mapFn)) {
  13469. Ext.raise('Invalid parameter: expected a function.');
  13470. }
  13471. return Deferred.resolved(promisesOrValues).then(function(promisesOrValues) {
  13472. var deferred, index, promiseOrValue, remainingToResolve, resolve, results, i, len;
  13473. remainingToResolve = promisesOrValues.length;
  13474. results = new Array(promisesOrValues.length);
  13475. deferred = new Deferred();
  13476. if (!remainingToResolve) {
  13477. deferred.resolve(results);
  13478. } else {
  13479. resolve = function(item, index) {
  13480. return Deferred.resolved(item).then(function(value) {
  13481. return mapFn(value, index, results);
  13482. }).then(function(value) {
  13483. results[index] = value;
  13484. if (!--remainingToResolve) {
  13485. deferred.resolve(results);
  13486. }
  13487. return value;
  13488. }, function(reason) {
  13489. return deferred.reject(reason);
  13490. });
  13491. };
  13492. for (index = i = 0 , len = promisesOrValues.length; i < len; index = ++i) {
  13493. promiseOrValue = promisesOrValues[index];
  13494. if (index in promisesOrValues) {
  13495. resolve(promiseOrValue, index);
  13496. } else {
  13497. remainingToResolve--;
  13498. }
  13499. }
  13500. }
  13501. return deferred.promise;
  13502. });
  13503. },
  13504. memoize: function(fn, scope, hashFn) {
  13505. var memoizedFn = Ext.Function.memoize(fn, scope, hashFn);
  13506. return function() {
  13507. return Deferred.all(Ext.Array.slice(arguments)).then(function(values) {
  13508. return memoizedFn.apply(scope, values);
  13509. });
  13510. };
  13511. },
  13512. parallel: function(fns, scope) {
  13513. var args;
  13514. if (scope == null) {
  13515. scope = null;
  13516. }
  13517. args = Ext.Array.slice(arguments, 2);
  13518. return Deferred.map(fns, function(fn) {
  13519. if (!Ext.isFunction(fn)) {
  13520. throw new Error('Invalid parameter: expected a function.');
  13521. }
  13522. return fn.apply(scope, args);
  13523. });
  13524. },
  13525. pipeline: function(fns, initialValue, scope) {
  13526. if (scope == null) {
  13527. scope = null;
  13528. }
  13529. return Deferred.reduce(fns, function(value, fn) {
  13530. if (!Ext.isFunction(fn)) {
  13531. throw new Error('Invalid parameter: expected a function.');
  13532. }
  13533. return fn.call(scope, value);
  13534. }, initialValue);
  13535. },
  13536. race: function() {
  13537. return ExtPromise.race.apply(ExtPromise, arguments);
  13538. },
  13539. reduce: function(values, reduceFn, initialValue) {
  13540. var initialValueSpecified;
  13541. if (!(Ext.isArray(values) || ExtPromise.is(values))) {
  13542. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13543. }
  13544. if (!Ext.isFunction(reduceFn)) {
  13545. Ext.raise('Invalid parameter: expected a function.');
  13546. }
  13547. initialValueSpecified = arguments.length === 3;
  13548. return Deferred.resolved(values).then(function(promisesOrValues) {
  13549. var reduceArguments = [
  13550. promisesOrValues,
  13551. function(previousValueOrPromise, currentValueOrPromise, currentIndex) {
  13552. return Deferred.resolved(previousValueOrPromise).then(function(previousValue) {
  13553. return Deferred.resolved(currentValueOrPromise).then(function(currentValue) {
  13554. return reduceFn(previousValue, currentValue, currentIndex, promisesOrValues);
  13555. });
  13556. });
  13557. }
  13558. ];
  13559. if (initialValueSpecified) {
  13560. reduceArguments.push(initialValue);
  13561. }
  13562. return Ext.Array.reduce.apply(Ext.Array, reduceArguments);
  13563. });
  13564. },
  13565. rejected: function(reason) {
  13566. var deferred = new Ext.Deferred();
  13567. deferred.reject(reason);
  13568. return deferred.promise;
  13569. },
  13570. resolved: function(promiseOrValue) {
  13571. var deferred = new Ext.Deferred();
  13572. deferred.resolve(promiseOrValue);
  13573. return deferred.promise;
  13574. },
  13575. sequence: function(fns, scope) {
  13576. var args;
  13577. if (scope == null) {
  13578. scope = null;
  13579. }
  13580. args = Ext.Array.slice(arguments, 2);
  13581. return Deferred.reduce(fns, function(results, fn) {
  13582. if (!Ext.isFunction(fn)) {
  13583. throw new Error('Invalid parameter: expected a function.');
  13584. }
  13585. return Deferred.resolved(fn.apply(scope, args)).then(function(result) {
  13586. results.push(result);
  13587. return results;
  13588. });
  13589. }, []);
  13590. },
  13591. some: function(promisesOrValues, howMany) {
  13592. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  13593. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13594. }
  13595. if (!Ext.isNumeric(howMany) || howMany <= 0) {
  13596. Ext.raise('Invalid parameter: expected a positive integer.');
  13597. }
  13598. return Deferred.resolved(promisesOrValues).then(function(promisesOrValues) {
  13599. var deferred, index, onReject, onResolve, promiseOrValue, remainingToReject, remainingToResolve, values, i, len;
  13600. values = [];
  13601. remainingToResolve = howMany;
  13602. remainingToReject = (promisesOrValues.length - remainingToResolve) + 1;
  13603. deferred = new Deferred();
  13604. if (promisesOrValues.length < howMany) {
  13605. deferred.reject(new Error('Too few Promises were resolved.'));
  13606. } else {
  13607. onResolve = function(value) {
  13608. if (remainingToResolve > 0) {
  13609. values.push(value);
  13610. }
  13611. remainingToResolve--;
  13612. if (remainingToResolve === 0) {
  13613. deferred.resolve(values);
  13614. }
  13615. return value;
  13616. };
  13617. onReject = function(reason) {
  13618. remainingToReject--;
  13619. if (remainingToReject === 0) {
  13620. deferred.reject(new Error('Too few Promises were resolved.'));
  13621. }
  13622. return reason;
  13623. };
  13624. for (index = i = 0 , len = promisesOrValues.length; i < len; index = ++i) {
  13625. promiseOrValue = promisesOrValues[index];
  13626. if (index in promisesOrValues) {
  13627. Deferred.resolved(promiseOrValue).then(onResolve, onReject);
  13628. }
  13629. }
  13630. }
  13631. return deferred.promise;
  13632. });
  13633. },
  13634. timeout: function(promiseOrValue, milliseconds) {
  13635. var deferred = new Deferred(),
  13636. timeoutId;
  13637. timeoutId = Ext.defer(function() {
  13638. if (timeoutId) {
  13639. deferred.reject(new Error('Promise timed out.'));
  13640. }
  13641. }, milliseconds);
  13642. Deferred.resolved(promiseOrValue).then(function(value) {
  13643. Ext.undefer(timeoutId);
  13644. timeoutId = null;
  13645. deferred.resolve(value);
  13646. }, function(reason) {
  13647. Ext.undefer(timeoutId);
  13648. timeoutId = null;
  13649. deferred.reject(reason);
  13650. });
  13651. return deferred.promise;
  13652. }
  13653. }
  13654. };
  13655. }, function(Deferred) {
  13656. Deferred._ready();
  13657. });
  13658. Ext.Factory = function(type) {
  13659. var me = this;
  13660. me.aliasPrefix = type + '.';
  13661. me.cache = {};
  13662. me.name = type.replace(me.fixNameRe, me.fixNameFn);
  13663. me.type = type;
  13664. me.creator = 'create' + Ext.String.capitalize(me.name);
  13665. };
  13666. Ext.Factory.prototype = {
  13667. defaultProperty: 'type',
  13668. instanceProp: 'isInstance',
  13669. typeProperty: 'type',
  13670. create: function(config, defaultType) {
  13671. var me = this,
  13672. Manager = Ext.ClassManager,
  13673. cache = me.cache,
  13674. typeProperty = me.typeProperty,
  13675. alias, className, klass, suffix;
  13676. if (config) {
  13677. if (config[me.instanceProp]) {
  13678. return config;
  13679. }
  13680. if (typeof config === 'string') {
  13681. suffix = config;
  13682. config = {};
  13683. config[me.defaultProperty] = suffix;
  13684. }
  13685. className = config.xclass;
  13686. suffix = config[typeProperty];
  13687. }
  13688. if (defaultType && defaultType.constructor === Object) {
  13689. config = Ext.apply({}, config, defaultType);
  13690. defaultType = defaultType[typeProperty];
  13691. }
  13692. if (className) {
  13693. if (!(klass = Manager.get(className))) {
  13694. return Manager.instantiate(className, config);
  13695. }
  13696. } else {
  13697. if (!(suffix = suffix || defaultType || me.defaultType)) {
  13698. klass = me.defaultClass;
  13699. }
  13700. if (!suffix && !klass) {
  13701. Ext.raise('No type specified for ' + me.type + '.create');
  13702. }
  13703. if (!klass && !(klass = cache[suffix])) {
  13704. alias = me.aliasPrefix + suffix;
  13705. className = Manager.getNameByAlias(alias);
  13706. if (!(klass = className && Manager.get(className))) {
  13707. return Manager.instantiateByAlias(alias, config);
  13708. }
  13709. cache[suffix] = klass;
  13710. }
  13711. }
  13712. return klass.isInstance ? klass : new klass(config);
  13713. },
  13714. fixNameRe: /\.[a-z]/ig,
  13715. fixNameFn: function(match) {
  13716. return match.substring(1).toUpperCase();
  13717. },
  13718. clearCache: function() {
  13719. this.cache = {};
  13720. this.instanceCache = {};
  13721. },
  13722. hook: function(fn) {
  13723. var me = this,
  13724. original = me.create;
  13725. me.create = function(config, defaultType) {
  13726. var ret = fn.call(me, original, config, defaultType);
  13727. if (ret === undefined) {
  13728. ret = original.call(me, config, defaultType);
  13729. }
  13730. return ret;
  13731. };
  13732. },
  13733. update: function(instance, config, creator, creatorMethod, defaultsConfig) {
  13734. var me = this,
  13735. aliases, defaults, reuse, type;
  13736. if (!config || config.isInstance) {
  13737. if (config && !config[me.instanceProp]) {
  13738. Ext.raise('Config instance failed ' + me.instanceProp + ' requirement');
  13739. }
  13740. if (instance && instance !== config) {
  13741. instance.destroy();
  13742. }
  13743. return config;
  13744. }
  13745. if (typeof config === 'string') {
  13746. type = config;
  13747. config = {};
  13748. config[me.defaultProperty] = type;
  13749. }
  13750. if (instance) {
  13751. if (config === true) {
  13752. return instance;
  13753. }
  13754. if (!(type = config.xclass)) {
  13755. if (!(type = config.xtype)) {
  13756. type = config[me.typeProperty];
  13757. if (type) {
  13758. type = me.aliasPrefix + type;
  13759. aliases = instance.self.prototype;
  13760. if (aliases.hasOwnProperty('alias')) {
  13761. aliases = aliases.alias;
  13762. if (aliases) {
  13763. reuse = aliases === type || aliases.indexOf(type) > -1;
  13764. }
  13765. }
  13766. }
  13767. } else {
  13768. reuse = instance.isXType(type,
  13769. true);
  13770. }
  13771. } else {
  13772. reuse = instance.$className === type;
  13773. }
  13774. if (reuse) {
  13775. instance.setConfig(config);
  13776. return instance;
  13777. }
  13778. instance.destroy();
  13779. }
  13780. if (config === true) {
  13781. config = {};
  13782. }
  13783. if (creator) {
  13784. if (defaultsConfig) {
  13785. defaults = Ext.Config.map[defaultsConfig];
  13786. defaults = creator[defaults.names.get]();
  13787. if (defaults) {
  13788. config = Ext.merge(Ext.clone(defaults), config);
  13789. }
  13790. }
  13791. creatorMethod = creatorMethod || me.creator;
  13792. if (creator[creatorMethod]) {
  13793. config = creator[creatorMethod](config);
  13794. if (!config) {
  13795. Ext.raise('Missing return value from ' + creatorMethod + ' on class ' + creator.$className);
  13796. }
  13797. }
  13798. }
  13799. return me.create(config);
  13800. }
  13801. };
  13802. Ext.Factory.define = function(type, config) {
  13803. var Factory = Ext.Factory,
  13804. cacheable = config && config.cacheable,
  13805. defaultClass, factory, fn;
  13806. if (type.constructor === Object) {
  13807. Ext.Object.each(type, Factory.define, Factory);
  13808. } else {
  13809. factory = new Ext.Factory(type);
  13810. if (config) {
  13811. if (config.constructor === Object) {
  13812. Ext.apply(factory, config);
  13813. if (typeof (defaultClass = factory.xclass) === 'string') {
  13814. factory.defaultClass = Ext.ClassManager.get(defaultClass);
  13815. }
  13816. } else {
  13817. factory.defaultType = config;
  13818. }
  13819. }
  13820. Factory[factory.name] = fn = function(config, defaultType) {
  13821. return factory.create(config, defaultType);
  13822. };
  13823. if (cacheable) {
  13824. factory.instanceCache = {};
  13825. factory.hook(function(original, config, defaultType) {
  13826. var cache = this.instanceCache,
  13827. v;
  13828. if (typeof config === 'string' && !(v = cache[config])) {
  13829. v = original.call(this, config, defaultType);
  13830. if (v.cacheable !== false) {
  13831. cache[config] = v;
  13832. Ext.Object.freeze(v);
  13833. }
  13834. }
  13835. return v;
  13836. });
  13837. }
  13838. fn.instance = factory;
  13839. fn.update = function(instance, config, creator, creatorMethod, defaultsConfig) {
  13840. return factory.update(instance, config, creator, creatorMethod, defaultsConfig);
  13841. };
  13842. }
  13843. return fn;
  13844. };
  13845. Ext.Factory.clearCaches = function() {
  13846. var Factory = Ext.Factory,
  13847. key, item;
  13848. for (key in Factory) {
  13849. item = Factory[key];
  13850. item = item.instance;
  13851. if (item) {
  13852. item.clearCache();
  13853. }
  13854. }
  13855. };
  13856. Ext.Factory.on = function(name, fn) {
  13857. Ext.Factory[name].instance.hook(fn);
  13858. };
  13859. Ext.define('Ext.mixin.Factoryable', {
  13860. mixinId: 'factoryable',
  13861. onClassMixedIn: function(targetClass) {
  13862. var proto = targetClass.prototype,
  13863. factoryConfig = proto.factoryConfig,
  13864. alias = proto.alias,
  13865. config = {},
  13866. dot, createFn;
  13867. alias = alias && alias.length && alias[0];
  13868. if (alias && (dot = alias.lastIndexOf('.')) > 0) {
  13869. config.type = alias.substring(0, dot);
  13870. config.defaultType = alias.substring(dot + 1);
  13871. }
  13872. if (factoryConfig) {
  13873. delete proto.factoryConfig;
  13874. Ext.apply(config, factoryConfig);
  13875. }
  13876. createFn = Ext.Factory.define(config.type, config);
  13877. if (targetClass.create === Ext.Base.create) {
  13878. targetClass.create = createFn;
  13879. }
  13880. }
  13881. });
  13882. Ext.define('Ext.data.request.Base', {
  13883. mixins: [
  13884. Ext.mixin.Factoryable
  13885. ],
  13886. factoryConfig: {
  13887. type: 'request',
  13888. defaultType: 'ajax'
  13889. },
  13890. result: null,
  13891. success: null,
  13892. timer: null,
  13893. constructor: function(config) {
  13894. var me = this;
  13895. Ext.apply(me, config.options || {}, config.ownerConfig);
  13896. me.id = ++Ext.data.Connection.requestId;
  13897. me.owner = config.owner;
  13898. me.options = config.options;
  13899. me.requestOptions = config.requestOptions;
  13900. },
  13901. start: function() {
  13902. var me = this,
  13903. timeout = me.getTimeout();
  13904. if (timeout && me.async) {
  13905. me.timer = Ext.defer(me.onTimeout, timeout, me);
  13906. }
  13907. },
  13908. abort: function() {
  13909. var me = this;
  13910. me.clearTimer();
  13911. if (!me.timedout) {
  13912. me.aborted = true;
  13913. }
  13914. me.abort = Ext.emptyFn;
  13915. },
  13916. createDeferred: function() {
  13917. var me = this,
  13918. result = me.result,
  13919. d = new Ext.Deferred();
  13920. if (me.completed) {
  13921. if (me.success) {
  13922. d.resolve(result);
  13923. } else {
  13924. d.reject(result);
  13925. }
  13926. }
  13927. me.deferred = d;
  13928. return d;
  13929. },
  13930. getDeferred: function() {
  13931. return this.deferred || this.createDeferred();
  13932. },
  13933. getPromise: function() {
  13934. return this.getDeferred().promise;
  13935. },
  13936. then: function() {
  13937. var promise = this.getPromise();
  13938. return promise.then.apply(promise, arguments);
  13939. },
  13940. onComplete: function() {
  13941. var me = this,
  13942. deferred = me.deferred,
  13943. result = me.result;
  13944. me.clearTimer();
  13945. if (deferred) {
  13946. if (me.success) {
  13947. deferred.resolve(result);
  13948. } else {
  13949. deferred.reject(result);
  13950. }
  13951. }
  13952. me.completed = true;
  13953. },
  13954. onTimeout: function() {
  13955. var me = this;
  13956. me.timedout = true;
  13957. me.timer = null;
  13958. me.abort(true);
  13959. },
  13960. getTimeout: function() {
  13961. return this.timeout;
  13962. },
  13963. clearTimer: function() {
  13964. this.timer = Ext.undefer(this.timer);
  13965. },
  13966. destroy: function() {
  13967. var me = this;
  13968. me.abort();
  13969. me.owner = me.options = me.requestOptions = me.result = null;
  13970. me.callParent();
  13971. },
  13972. privates: {
  13973. createException: function() {
  13974. var me = this,
  13975. result;
  13976. result = {
  13977. request: me,
  13978. requestId: me.id,
  13979. status: me.aborted ? -1 : 0,
  13980. statusText: me.aborted ? 'transaction aborted' : 'communication failure',
  13981. getResponseHeader: me._getHeader,
  13982. getAllResponseHeaders: me._getHeaders
  13983. };
  13984. if (me.aborted) {
  13985. result.aborted = true;
  13986. }
  13987. if (me.timedout) {
  13988. result.timedout = true;
  13989. }
  13990. return result;
  13991. },
  13992. _getHeader: function(name) {
  13993. var headers = this.headers;
  13994. return headers && headers[name.toLowerCase()];
  13995. },
  13996. _getHeaders: function() {
  13997. return this.headers;
  13998. }
  13999. }
  14000. });
  14001. Ext.define('Ext.data.flash.BinaryXhr', {
  14002. statics: {
  14003. flashPluginActivated: function() {
  14004. Ext.data.flash.BinaryXhr.flashPluginActive = true;
  14005. Ext.data.flash.BinaryXhr.flashPlugin = document.getElementById("ext-flash-polyfill");
  14006. Ext.GlobalEvents.fireEvent("flashready");
  14007. },
  14008. flashPluginActive: false,
  14009. flashPluginInjected: false,
  14010. connectionIndex: 1,
  14011. liveConnections: {},
  14012. flashPlugin: null,
  14013. onFlashStateChange: function(javascriptId, state, data) {
  14014. var connection;
  14015. connection = this.liveConnections[Number(javascriptId)];
  14016. if (connection) {
  14017. connection.onFlashStateChange(state, data);
  14018. } else
  14019. {
  14020. Ext.warn.log("onFlashStateChange for unknown connection ID: " + javascriptId);
  14021. }
  14022. },
  14023. registerConnection: function(conn) {
  14024. var i = this.connectionIndex;
  14025. this.conectionIndex = this.connectionIndex + 1;
  14026. this.liveConnections[i] = conn;
  14027. return i;
  14028. },
  14029. injectFlashPlugin: function() {
  14030. var me = this,
  14031. flashLoaderPath, flashObjectPath;
  14032. me.flashPolyfillEl = Ext.getBody().appendChild({
  14033. id: 'ext-flash-polyfill',
  14034. cn: [
  14035. {
  14036. tag: 'p',
  14037. html: 'To view this page ensure that Adobe Flash Player version 11.1.0 or greater is installed.'
  14038. },
  14039. {
  14040. tag: 'a',
  14041. href: 'http://www.adobe.com/go/getflashplayer',
  14042. cn: [
  14043. {
  14044. tag: 'img',
  14045. src: window.location.protocol + '//www.adobe.com/images/shared/download_buttons/get_flash_player.gif',
  14046. alt: 'Get Adobe Flash player'
  14047. }
  14048. ]
  14049. }
  14050. ]
  14051. });
  14052. flashLoaderPath = [
  14053. Ext.Loader.getPath('Ext.data.Connection'),
  14054. '../../../plugins/flash/swfobject.js'
  14055. ].join('/');
  14056. flashObjectPath = "/plugins/flash/FlashPlugin.swf";
  14057. flashObjectPath = [
  14058. Ext.Loader.getPath('Ext.data.Connection'),
  14059. '../../plugins/flash/FlashPlugin.swf'
  14060. ].join('/');
  14061. if (Ext.flashPluginPath) {
  14062. flashObjectPath = Ext.flashPluginPath;
  14063. }
  14064. Ext.Loader.loadScript({
  14065. url: flashLoaderPath,
  14066. onLoad: function() {
  14067. var swfVersionStr = "11.4.0",
  14068. xiSwfUrlStr = "playerProductInstall.swf",
  14069. flashvars = {},
  14070. params = {},
  14071. attributes = {};
  14072. params.quality = "high";
  14073. params.bgcolor = "#ffffff";
  14074. params.allowscriptaccess = "sameDomain";
  14075. params.allowfullscreen = "true";
  14076. attributes.id = "ext-flash-polyfill";
  14077. attributes.name = "polyfill";
  14078. attributes.align = "middle";
  14079. swfobject.embedSWF(flashObjectPath, "ext-flash-polyfill", "0", "0",
  14080. swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
  14081. },
  14082. onError: function() {
  14083. Ext.raise("Could not load flash-loader file swfobject.js from " + flashLoader);
  14084. },
  14085. scope: me
  14086. });
  14087. Ext.data.flash.BinaryXhr.flashPluginInjected = true;
  14088. }
  14089. },
  14090. readyState: 0,
  14091. status: 0,
  14092. statusText: "",
  14093. responseBytes: null,
  14094. javascriptId: null,
  14095. constructor: function(config) {
  14096. var me = this;
  14097. if (!Ext.data.flash.BinaryXhr.flashPluginInjected) {
  14098. Ext.data.flash.BinaryXhr.injectFlashPlugin();
  14099. }
  14100. Ext.apply(me, config);
  14101. me.requestHeaders = {};
  14102. },
  14103. abort: function() {
  14104. var me = this;
  14105. if (me.readyState === 4) {
  14106. Ext.warn.log("Aborting a connection that's completed its transfer: " + this.url);
  14107. return;
  14108. }
  14109. me.aborted = true;
  14110. if (!Ext.data.flash.BinaryXhr.flashPluginActive) {
  14111. Ext.GlobalEvents.removeListener("flashready", me.onFlashReady, me);
  14112. return;
  14113. }
  14114. Ext.data.flash.BinaryXhr.flashPlugin.abortRequest(me.javascriptId);
  14115. delete Ext.data.flash.BinaryXhr.liveConnections[me.javascriptId];
  14116. },
  14117. getAllResponseHeaders: function() {
  14118. var headers = [];
  14119. Ext.Object.each(this.responseHeaders, function(name, value) {
  14120. headers.push(name + ': ' + value);
  14121. });
  14122. return headers.join('\r\n');
  14123. },
  14124. getResponseHeader: function(header) {
  14125. var headers = this.responseHeaders;
  14126. return (headers && headers[header]) || null;
  14127. },
  14128. open: function(method, url, isAsync, user, password) {
  14129. var me = this;
  14130. me.method = method;
  14131. me.url = url;
  14132. me.async = isAsync !== false;
  14133. me.user = user;
  14134. me.password = password;
  14135. if (!me.async) {
  14136. Ext.raise("Binary posts are only supported in async mode: " + url);
  14137. }
  14138. if (me.method !== "POST") {
  14139. Ext.log.warn("Binary data can only be sent as a POST request: " + url);
  14140. }
  14141. },
  14142. overrideMimeType: function(mimeType) {
  14143. this.mimeType = mimeType;
  14144. },
  14145. send: function(body) {
  14146. var me = this;
  14147. me.body = body;
  14148. if (!Ext.data.flash.BinaryXhr.flashPluginActive) {
  14149. Ext.GlobalEvents.addListener("flashready", me.onFlashReady, me);
  14150. } else {
  14151. this.onFlashReady();
  14152. }
  14153. },
  14154. onFlashReady: function() {
  14155. var me = this,
  14156. req;
  14157. me.javascriptId = Ext.data.flash.BinaryXhr.registerConnection(me);
  14158. req = {
  14159. method: me.method,
  14160. url: me.url,
  14161. user: me.user,
  14162. password: me.password,
  14163. mimeType: me.mimeType,
  14164. requestHeaders: me.requestHeaders,
  14165. body: me.body,
  14166. javascriptId: me.javascriptId
  14167. };
  14168. Ext.data.flash.BinaryXhr.flashPlugin.postBinary(req);
  14169. },
  14170. setReadyState: function(state) {
  14171. var me = this;
  14172. if (me.readyState !== state) {
  14173. me.readyState = state;
  14174. me.onreadystatechange();
  14175. }
  14176. },
  14177. setRequestHeader: function(header, value) {
  14178. this.requestHeaders[header] = value;
  14179. },
  14180. onreadystatechange: Ext.emptyFn,
  14181. parseData: function(data) {
  14182. var me = this;
  14183. this.status = data.status || 0;
  14184. me.responseHeaders = {};
  14185. if (me.mimeType) {
  14186. me.responseHeaders["content-type"] = me.mimeType;
  14187. }
  14188. if (data.reason === "complete") {
  14189. this.responseBytes = data.data;
  14190. me.responseHeaders["content-length"] = data.data.length;
  14191. } else if (data.reason === "error" || data.reason === "securityError") {
  14192. this.statusText = data.text;
  14193. me.responseHeaders["content-length"] = 0;
  14194. } else
  14195. {
  14196. Ext.raise("Unkown reason code in data: " + data.reason);
  14197. }
  14198. },
  14199. onFlashStateChange: function(state, data) {
  14200. var me = this;
  14201. if (state === 4) {
  14202. me.parseData(data);
  14203. delete Ext.data.flash.BinaryXhr.liveConnections[me.javascriptId];
  14204. }
  14205. me.setReadyState(state);
  14206. }
  14207. });
  14208. Ext.define('Ext.data.request.Ajax', {
  14209. extend: Ext.data.request.Base,
  14210. alias: 'request.ajax',
  14211. statics: {
  14212. parseStatus: function(status, response) {
  14213. var type, len, success, isException;
  14214. if (response) {
  14215. type = response.responseType;
  14216. if (type === 'arraybuffer') {
  14217. len = response.byteLength;
  14218. } else if (type === 'blob') {
  14219. len = response.response.size;
  14220. } else if ((type === 'json' || type === 'document') && response.response) {
  14221. len = 0;
  14222. } else if ((type === 'text' || type === '' || !type) && response.responseText) {
  14223. len = response.responseText.length;
  14224. }
  14225. }
  14226. status = status === 1223 ? 204 : status;
  14227. isException = false;
  14228. success = (status >= 200 && status < 300) || status === 304 || (status === 0 && Ext.isNumber(len));
  14229. if (!success) {
  14230. switch (status) {
  14231. case 12002:
  14232. case 12029:
  14233. case 12030:
  14234. case 12031:
  14235. case 12152:
  14236. case 13030:
  14237. isException = true;
  14238. break;
  14239. }
  14240. }
  14241. return {
  14242. success: success,
  14243. isException: isException
  14244. };
  14245. }
  14246. },
  14247. start: function(data) {
  14248. var me = this,
  14249. options = me.options,
  14250. requestOptions = me.requestOptions,
  14251. isXdr = me.isXdr,
  14252. xhr;
  14253. xhr = me.xhr = me.openRequest(options, requestOptions, me.async, me.username, me.password);
  14254. if (!isXdr) {
  14255. me.setupHeaders(xhr, options, requestOptions.data, requestOptions.params);
  14256. }
  14257. if (me.async) {
  14258. if (!isXdr) {
  14259. xhr.onreadystatechange = me.bindStateChange();
  14260. }
  14261. }
  14262. if (isXdr) {
  14263. me.processXdrRequest(me, xhr);
  14264. }
  14265. me.callParent([
  14266. data
  14267. ]);
  14268. xhr.send(data);
  14269. if (!me.async) {
  14270. return me.onComplete();
  14271. }
  14272. return me;
  14273. },
  14274. abort: function(force) {
  14275. var me = this,
  14276. xhr = me.xhr;
  14277. if (force || me.isLoading()) {
  14278. try {
  14279. xhr.onreadystatechange = null;
  14280. } catch (e) {
  14281. xhr.onreadystatechange = Ext.emptyFn;
  14282. }
  14283. xhr.abort();
  14284. me.callParent([
  14285. force
  14286. ]);
  14287. me.onComplete();
  14288. me.cleanup();
  14289. }
  14290. },
  14291. cleanup: function() {
  14292. this.xhr = null;
  14293. delete this.xhr;
  14294. },
  14295. isLoading: function() {
  14296. var me = this,
  14297. xhr = me.xhr,
  14298. state = xhr && xhr.readyState,
  14299. C = Ext.data.flash && Ext.data.flash.BinaryXhr;
  14300. if (!xhr || me.aborted || me.timedout) {
  14301. return false;
  14302. }
  14303. if (C && xhr instanceof C) {
  14304. return state !== 4;
  14305. }
  14306. return state !== 0 && state !== 4;
  14307. },
  14308. openRequest: function(options, requestOptions, isAsync, username, password) {
  14309. var me = this,
  14310. xhr = me.newRequest(options);
  14311. if (username) {
  14312. xhr.open(requestOptions.method, requestOptions.url, isAsync, username, password);
  14313. } else {
  14314. if (me.isXdr) {
  14315. xhr.open(requestOptions.method, requestOptions.url);
  14316. } else {
  14317. xhr.open(requestOptions.method, requestOptions.url, isAsync);
  14318. }
  14319. }
  14320. if (options.binary || me.binary) {
  14321. if (window.Uint8Array) {
  14322. xhr.responseType = 'arraybuffer';
  14323. } else if (xhr.overrideMimeType) {
  14324. xhr.overrideMimeType('text/plain; charset=x-user-defined');
  14325. }
  14326. else if (!Ext.isIE) {
  14327. Ext.log.warn("Your browser does not support loading binary data using Ajax.");
  14328. }
  14329. }
  14330. if (options.responseType) {
  14331. xhr.responseType = options.responseType;
  14332. }
  14333. if (options.withCredentials || me.withCredentials) {
  14334. xhr.withCredentials = true;
  14335. }
  14336. return xhr;
  14337. },
  14338. newRequest: function(options) {
  14339. var me = this,
  14340. xhr;
  14341. if (options.binaryData) {
  14342. if (window.Uint8Array) {
  14343. xhr = me.getXhrInstance();
  14344. } else {
  14345. xhr = new Ext.data.flash.BinaryXhr();
  14346. }
  14347. } else if (me.cors && Ext.isIE9m) {
  14348. xhr = me.getXdrInstance();
  14349. me.isXdr = true;
  14350. } else {
  14351. xhr = me.getXhrInstance();
  14352. me.isXdr = false;
  14353. }
  14354. return xhr;
  14355. },
  14356. setupHeaders: function(xhr, options, data, params) {
  14357. var me = this,
  14358. headers = Ext.apply({}, options.headers || {}, me.defaultHeaders),
  14359. contentType = me.defaultPostHeader,
  14360. jsonData = options.jsonData,
  14361. xmlData = options.xmlData,
  14362. type = 'Content-Type',
  14363. useHeader = me.useDefaultXhrHeader,
  14364. key, header;
  14365. if (!headers.hasOwnProperty(type) && (data || params)) {
  14366. if (data) {
  14367. if (options.rawData) {
  14368. contentType = 'text/plain';
  14369. } else {
  14370. if (xmlData && Ext.isDefined(xmlData)) {
  14371. contentType = 'text/xml';
  14372. } else if (jsonData && Ext.isDefined(jsonData)) {
  14373. contentType = 'application/json';
  14374. }
  14375. }
  14376. }
  14377. headers[type] = contentType;
  14378. }
  14379. if (useHeader && !headers['X-Requested-With']) {
  14380. headers['X-Requested-With'] = me.defaultXhrHeader;
  14381. }
  14382. if (headers[type] === undefined || headers[type] === null) {
  14383. delete headers[type];
  14384. }
  14385. try {
  14386. for (key in headers) {
  14387. if (headers.hasOwnProperty(key)) {
  14388. header = headers[key];
  14389. xhr.setRequestHeader(key, header);
  14390. }
  14391. }
  14392. } catch (e) {
  14393. me.owner.fireEvent('exception', key, header);
  14394. }
  14395. return headers;
  14396. },
  14397. getXdrInstance: function() {
  14398. var xdr;
  14399. if (Ext.ieVersion >= 8) {
  14400. xdr = new XDomainRequest();
  14401. } else
  14402. {
  14403. Ext.raise({
  14404. msg: 'Your browser does not support CORS'
  14405. });
  14406. }
  14407. return xdr;
  14408. },
  14409. getXhrInstance: function() {
  14410. return new XMLHttpRequest();
  14411. },
  14412. processXdrRequest: function(request, xhr) {
  14413. var me = this;
  14414. delete request.headers;
  14415. request.contentType = request.options.contentType || me.defaultXdrContentType;
  14416. xhr.onload = me.bindStateChange(true);
  14417. xhr.onerror = xhr.ontimeout = me.bindStateChange(false);
  14418. },
  14419. processXdrResponse: function(response, xhr) {
  14420. response.getAllResponseHeaders = function() {
  14421. return [];
  14422. };
  14423. response.getResponseHeader = function() {
  14424. return '';
  14425. };
  14426. response.contentType = xhr.contentType || this.defaultXdrContentType;
  14427. },
  14428. bindStateChange: function(xdrResult) {
  14429. var me = this;
  14430. return function() {
  14431. Ext.elevate(function() {
  14432. me.onStateChange(xdrResult);
  14433. });
  14434. };
  14435. },
  14436. onStateChange: function(xdrResult) {
  14437. var me = this,
  14438. xhr = me.xhr;
  14439. if ((xhr && xhr.readyState === 4) || me.isXdr) {
  14440. me.clearTimer();
  14441. me.onComplete(xdrResult);
  14442. me.cleanup();
  14443. }
  14444. },
  14445. onComplete: function(xdrResult) {
  14446. var me = this,
  14447. owner = me.owner,
  14448. options = me.options,
  14449. xhr = me.xhr,
  14450. failure = {
  14451. success: false,
  14452. isException: false
  14453. },
  14454. result, success, response;
  14455. if (!xhr || me.destroyed) {
  14456. return me.result = failure;
  14457. }
  14458. try {
  14459. result = Ext.data.request.Ajax.parseStatus(xhr.status, xhr);
  14460. if (result.success) {
  14461. result.success = xhr.readyState === 4;
  14462. }
  14463. } catch (e) {
  14464. result = failure;
  14465. }
  14466. success = me.success = me.isXdr ? xdrResult : result.success;
  14467. if (success) {
  14468. response = me.createResponse(xhr);
  14469. if (owner.hasListeners.requestcomplete) {
  14470. owner.fireEvent('requestcomplete', owner, response, options);
  14471. }
  14472. if (options.success) {
  14473. Ext.callback(options.success, options.scope, [
  14474. response,
  14475. options
  14476. ]);
  14477. }
  14478. } else {
  14479. if (result.isException || me.aborted || me.timedout) {
  14480. response = me.createException(xhr);
  14481. } else {
  14482. response = me.createResponse(xhr);
  14483. }
  14484. if (owner.hasListeners.requestexception) {
  14485. owner.fireEvent('requestexception', owner, response, options);
  14486. }
  14487. if (options.failure) {
  14488. Ext.callback(options.failure, options.scope, [
  14489. response,
  14490. options
  14491. ]);
  14492. }
  14493. }
  14494. me.result = response;
  14495. if (options.callback) {
  14496. Ext.callback(options.callback, options.scope, [
  14497. options,
  14498. success,
  14499. response
  14500. ]);
  14501. }
  14502. owner.onRequestComplete(me);
  14503. me.callParent([
  14504. xdrResult
  14505. ]);
  14506. return response;
  14507. },
  14508. createResponse: function(xhr) {
  14509. var me = this,
  14510. isXdr = me.isXdr,
  14511. headers = {},
  14512. lines = isXdr ? [] : xhr.getAllResponseHeaders().replace(/\r\n/g, '\n').split('\n'),
  14513. count = lines.length,
  14514. line, index, key, response;
  14515. while (count--) {
  14516. line = lines[count];
  14517. index = line.indexOf(':');
  14518. if (index >= 0) {
  14519. key = line.substr(0, index).toLowerCase();
  14520. if (line.charAt(index + 1) === ' ') {
  14521. ++index;
  14522. }
  14523. headers[key] = line.substr(index + 1);
  14524. }
  14525. }
  14526. response = {
  14527. request: me,
  14528. requestId: me.id,
  14529. status: xhr.status,
  14530. statusText: xhr.statusText,
  14531. getResponseHeader: function(header) {
  14532. return headers[header.toLowerCase()];
  14533. },
  14534. getAllResponseHeaders: function() {
  14535. return headers;
  14536. }
  14537. };
  14538. if (isXdr) {
  14539. me.processXdrResponse(response, xhr);
  14540. }
  14541. if (me.binary) {
  14542. response.responseBytes = me.getByteArray(xhr);
  14543. } else {
  14544. if (xhr.responseType) {
  14545. response.responseType = xhr.responseType;
  14546. }
  14547. if (xhr.responseType === 'blob') {
  14548. response.responseBlob = xhr.response;
  14549. } else if (xhr.responseType === 'json') {
  14550. response.responseJson = xhr.response;
  14551. } else if (xhr.responseType === 'document') {
  14552. response.responseXML = xhr.response;
  14553. } else {
  14554. response.responseText = xhr.responseText;
  14555. response.responseXML = xhr.responseXML;
  14556. }
  14557. }
  14558. return response;
  14559. },
  14560. destroy: function() {
  14561. this.xhr = null;
  14562. this.callParent();
  14563. },
  14564. privates: {
  14565. getByteArray: function(xhr) {
  14566. var response = xhr.response,
  14567. responseBody = xhr.responseBody,
  14568. Cls = Ext.data.flash && Ext.data.flash.BinaryXhr,
  14569. byteArray, responseText, len, i;
  14570. if (xhr instanceof Cls) {
  14571. byteArray = xhr.responseBytes;
  14572. } else if (window.Uint8Array) {
  14573. byteArray = response ? new Uint8Array(response) : [];
  14574. } else if (Ext.isIE9p) {
  14575. try {
  14576. byteArray = new VBArray(responseBody).toArray();
  14577. } catch (e) {
  14578. byteArray = [];
  14579. }
  14580. } else if (Ext.isIE) {
  14581. if (!this.self.vbScriptInjected) {
  14582. this.injectVBScript();
  14583. }
  14584. getIEByteArray(xhr.responseBody, byteArray = []);
  14585. } else {
  14586. byteArray = [];
  14587. responseText = xhr.responseText;
  14588. len = responseText.length;
  14589. for (i = 0; i < len; i++) {
  14590. byteArray.push(responseText.charCodeAt(i) & 255);
  14591. }
  14592. }
  14593. return byteArray;
  14594. },
  14595. injectVBScript: function() {
  14596. var scriptTag = document.createElement('script');
  14597. scriptTag.type = 'text/vbscript';
  14598. scriptTag.text = [
  14599. 'Function getIEByteArray(byteArray, out)',
  14600. 'Dim len, i',
  14601. 'len = LenB(byteArray)',
  14602. 'For i = 1 to len',
  14603. 'out.push(AscB(MidB(byteArray, i, 1)))',
  14604. 'Next',
  14605. 'End Function'
  14606. ].join('\n');
  14607. Ext.getHead().dom.appendChild(scriptTag);
  14608. this.self.vbScriptInjected = true;
  14609. }
  14610. }
  14611. });
  14612. Ext.define('Ext.data.request.Form', {
  14613. extend: Ext.data.request.Base,
  14614. alias: 'request.form',
  14615. start: function(data) {
  14616. var me = this,
  14617. options = me.options,
  14618. requestOptions = me.requestOptions;
  14619. me.callParent([
  14620. data
  14621. ]);
  14622. me.form = me.upload(options.form, requestOptions.url, requestOptions.data, options);
  14623. return me;
  14624. },
  14625. abort: function(force) {
  14626. var me = this,
  14627. frame;
  14628. if (me.isLoading()) {
  14629. try {
  14630. frame = me.frame.dom;
  14631. if (frame.stop) {
  14632. frame.stop();
  14633. } else {
  14634. frame.document.execCommand('Stop');
  14635. }
  14636. } catch (e) {}
  14637. }
  14638. me.callParent([
  14639. force
  14640. ]);
  14641. me.onComplete();
  14642. me.cleanup();
  14643. },
  14644. cleanup: function() {
  14645. var me = this,
  14646. frame = me.frame;
  14647. if (frame) {
  14648. frame.un('load', me.onComplete, me);
  14649. Ext.removeNode(frame);
  14650. }
  14651. me.frame = me.form = null;
  14652. },
  14653. isLoading: function() {
  14654. return !!this.frame;
  14655. },
  14656. upload: function(form, url, params, options) {
  14657. form = Ext.getDom(form);
  14658. options = options || {};
  14659. var frameDom = document.createElement('iframe'),
  14660. frame = Ext.get(frameDom),
  14661. id = frame.id,
  14662. hiddens = [],
  14663. encoding = 'multipart/form-data',
  14664. buf = {
  14665. target: form.target,
  14666. method: form.method,
  14667. encoding: form.encoding,
  14668. enctype: form.enctype,
  14669. action: form.action
  14670. },
  14671. addField = function(name, value) {
  14672. hiddenItem = document.createElement('input');
  14673. Ext.fly(hiddenItem).set({
  14674. type: 'hidden',
  14675. value: value,
  14676. name: name
  14677. });
  14678. form.appendChild(hiddenItem);
  14679. hiddens.push(hiddenItem);
  14680. },
  14681. hiddenItem, obj, value, name, vLen, v, hLen, h;
  14682. frame.set({
  14683. name: id,
  14684. cls: Ext.baseCSSPrefix + 'hidden-display',
  14685. src: Ext.SSL_SECURE_URL,
  14686. tabIndex: -1
  14687. });
  14688. document.body.appendChild(frameDom);
  14689. document.body.appendChild(form);
  14690. if (document.frames) {
  14691. document.frames[id].name = id;
  14692. }
  14693. Ext.fly(form).set({
  14694. target: id,
  14695. method: 'POST',
  14696. enctype: encoding,
  14697. encoding: encoding,
  14698. action: url || buf.action
  14699. });
  14700. if (params) {
  14701. obj = Ext.Object.fromQueryString(params) || {};
  14702. for (name in obj) {
  14703. if (obj.hasOwnProperty(name)) {
  14704. value = obj[name];
  14705. if (Ext.isArray(value)) {
  14706. vLen = value.length;
  14707. for (v = 0; v < vLen; v++) {
  14708. addField(name, value[v]);
  14709. }
  14710. } else {
  14711. addField(name, value);
  14712. }
  14713. }
  14714. }
  14715. }
  14716. this.frame = frame;
  14717. frame.on({
  14718. load: this.onComplete,
  14719. scope: this,
  14720. single: !Ext.isOpera
  14721. });
  14722. form.submit();
  14723. document.body.removeChild(form);
  14724. Ext.fly(form).set(buf);
  14725. for (hLen = hiddens.length , h = 0; h < hLen; h++) {
  14726. Ext.removeNode(hiddens[h]);
  14727. }
  14728. return form;
  14729. },
  14730. getDoc: function() {
  14731. var frame = this.frame.dom;
  14732. return (frame && (frame.contentWindow.document || frame.contentDocument)) || (window.frames[frame.id] || {}).document;
  14733. },
  14734. getTimeout: function() {
  14735. return this.options.timeout;
  14736. },
  14737. onComplete: function() {
  14738. var me = this,
  14739. frame = me.frame,
  14740. owner = me.owner,
  14741. options = me.options,
  14742. callback, doc, success, contentNode, response;
  14743. if (!frame) {
  14744. return;
  14745. }
  14746. if (me.aborted || me.timedout) {
  14747. me.result = response = me.createException();
  14748. response.responseXML = null;
  14749. response.responseText = Ext.encode({
  14750. success: false,
  14751. message: Ext.String.trim(response.statusText)
  14752. });
  14753. response.request = me;
  14754. callback = options.failure;
  14755. success = false;
  14756. } else {
  14757. try {
  14758. doc = me.getDoc();
  14759. me.result = response = {
  14760. responseText: '',
  14761. responseXML: null,
  14762. request: me
  14763. };
  14764. if (doc) {
  14765. if (Ext.isOpera && doc.location === Ext.SSL_SECURE_URL) {
  14766. return;
  14767. }
  14768. if (doc.body) {
  14769. if ((contentNode = doc.body.firstChild) && /pre/i.test(contentNode.tagName)) {
  14770. response.responseText = contentNode.textContent || contentNode.innerText;
  14771. }
  14772. else if ((contentNode = doc.getElementsByTagName('textarea')[0])) {
  14773. response.responseText = contentNode.value;
  14774. } else
  14775. {
  14776. response.responseText = doc.body.textContent || doc.body.innerText;
  14777. }
  14778. }
  14779. response.responseXML = doc.XMLDocument || doc;
  14780. callback = options.success;
  14781. success = true;
  14782. response.status = 200;
  14783. } else {
  14784. Ext.raise("Could not acquire a suitable connection for the " + "file upload service.");
  14785. }
  14786. } catch (e) {
  14787. me.result = response = me.createException();
  14788. response.status = 400;
  14789. response.statusText = (e.message || e.description) + '';
  14790. response.responseText = Ext.encode({
  14791. success: false,
  14792. message: Ext.String.trim(response.statusText)
  14793. });
  14794. response.responseXML = null;
  14795. callback = options.failure;
  14796. success = false;
  14797. }
  14798. }
  14799. me.frame = null;
  14800. me.success = success;
  14801. owner.fireEvent(success ? 'requestcomplete' : 'requestexception', owner, response, options);
  14802. Ext.callback(callback, options.scope, [
  14803. response,
  14804. options
  14805. ]);
  14806. Ext.callback(options.callback, options.scope, [
  14807. options,
  14808. success,
  14809. response
  14810. ]);
  14811. owner.onRequestComplete(me);
  14812. Ext.asap(frame.destroy, frame);
  14813. me.callParent();
  14814. },
  14815. destroy: function() {
  14816. this.cleanup();
  14817. this.callParent();
  14818. }
  14819. });
  14820. Ext.define('Ext.data.Connection', {
  14821. mixins: {
  14822. observable: Ext.mixin.Observable
  14823. },
  14824. statics: {
  14825. requestId: 0
  14826. },
  14827. enctypeRe: /multipart\/form-data/i,
  14828. config: {
  14829. url: null,
  14830. async: true,
  14831. username: '',
  14832. password: '',
  14833. disableCaching: true,
  14834. withCredentials: false,
  14835. binary: false,
  14836. cors: false,
  14837. isXdr: false,
  14838. defaultXdrContentType: 'text/plain',
  14839. disableCachingParam: '_dc',
  14840. timeout: 30000,
  14841. extraParams: null,
  14842. autoAbort: false,
  14843. method: null,
  14844. defaultHeaders: null,
  14845. defaultPostHeader: 'application/x-www-form-urlencoded; charset=UTF-8',
  14846. useDefaultXhrHeader: true,
  14847. defaultXhrHeader: 'XMLHttpRequest'
  14848. },
  14849. constructor: function(config) {
  14850. this.mixins.observable.constructor.call(this, config);
  14851. this.requests = {};
  14852. },
  14853. request: function(options) {
  14854. var me = this,
  14855. requestOptions, request;
  14856. options = options || {};
  14857. if (me.fireEvent('beforerequest', me, options) !== false) {
  14858. requestOptions = me.setOptions(options, options.scope || Ext.global);
  14859. request = me.createRequest(options, requestOptions);
  14860. return request.start(requestOptions.data);
  14861. }
  14862. request = {
  14863. status: -1,
  14864. statusText: 'Request cancelled in beforerequest event handler'
  14865. };
  14866. Ext.callback(options.callback, options.scope, [
  14867. options,
  14868. false,
  14869. request
  14870. ]);
  14871. return Ext.Deferred.rejected([
  14872. options,
  14873. false,
  14874. request
  14875. ]);
  14876. },
  14877. createRequest: function(options, requestOptions) {
  14878. var me = this,
  14879. type = options.type || requestOptions.type,
  14880. request;
  14881. if (!type) {
  14882. type = me.isFormUpload(options) ? 'form' : 'ajax';
  14883. }
  14884. if (options.autoAbort || me.getAutoAbort()) {
  14885. me.abort();
  14886. }
  14887. request = Ext.Factory.request({
  14888. type: type,
  14889. owner: me,
  14890. options: options,
  14891. requestOptions: requestOptions,
  14892. ownerConfig: me.getConfig()
  14893. });
  14894. me.requests[request.id] = request;
  14895. me.latestId = request.id;
  14896. return request;
  14897. },
  14898. isFormUpload: function(options) {
  14899. var form = this.getForm(options);
  14900. if (form) {
  14901. return options.isUpload || this.enctypeRe.test(form.getAttribute('enctype'));
  14902. }
  14903. return false;
  14904. },
  14905. getForm: function(options) {
  14906. return Ext.getDom(options.form);
  14907. },
  14908. setOptions: function(options, scope) {
  14909. var me = this,
  14910. params = options.params || {},
  14911. extraParams = me.getExtraParams(),
  14912. urlParams = options.urlParams,
  14913. url = options.url || me.getUrl(),
  14914. cors = options.cors,
  14915. jsonData = options.jsonData,
  14916. method, disableCache, data;
  14917. if (cors !== undefined) {
  14918. me.setCors(cors);
  14919. }
  14920. if (Ext.isFunction(params)) {
  14921. params = params.call(scope, options);
  14922. }
  14923. if (Ext.isFunction(url)) {
  14924. url = url.call(scope, options);
  14925. }
  14926. url = this.setupUrl(options, url);
  14927. if (!url) {
  14928. Ext.raise({
  14929. options: options,
  14930. msg: 'No URL specified'
  14931. });
  14932. }
  14933. data = options.rawData || options.binaryData || options.xmlData || jsonData || null;
  14934. if (jsonData && !Ext.isPrimitive(jsonData)) {
  14935. data = Ext.encode(data);
  14936. }
  14937. if (options.binaryData) {
  14938. if (!Ext.isArray(options.binaryData)) {
  14939. Ext.log.warn("Binary submission data must be an array of byte values! " + "Instead got " + typeof (options.binaryData));
  14940. }
  14941. if (me.nativeBinaryPostSupport()) {
  14942. data = (new Uint8Array(options.binaryData));
  14943. if ((Ext.isChrome && Ext.chromeVersion < 22) || Ext.isSafari || Ext.isGecko) {
  14944. data = data.buffer;
  14945. }
  14946. }
  14947. }
  14948. if (Ext.isObject(params)) {
  14949. params = Ext.Object.toQueryString(params);
  14950. }
  14951. if (Ext.isObject(extraParams)) {
  14952. extraParams = Ext.Object.toQueryString(extraParams);
  14953. }
  14954. params = params + ((extraParams) ? ((params) ? '&' : '') + extraParams : '');
  14955. urlParams = Ext.isObject(urlParams) ? Ext.Object.toQueryString(urlParams) : urlParams;
  14956. params = this.setupParams(options, params);
  14957. method = (options.method || me.getMethod() || ((params || data) ? 'POST' : 'GET')).toUpperCase();
  14958. this.setupMethod(options, method);
  14959. disableCache = options.disableCaching !== false ? (options.disableCaching || me.getDisableCaching()) : false;
  14960. if (method === 'GET' && disableCache) {
  14961. url = Ext.urlAppend(url, (options.disableCachingParam || me.getDisableCachingParam()) + '=' + (new Date().getTime()));
  14962. }
  14963. if ((method === 'GET' || data) && params) {
  14964. url = Ext.urlAppend(url, params);
  14965. params = null;
  14966. }
  14967. if (urlParams) {
  14968. url = Ext.urlAppend(url, urlParams);
  14969. }
  14970. return {
  14971. url: url,
  14972. method: method,
  14973. data: data || params || null
  14974. };
  14975. },
  14976. setupUrl: function(options, url) {
  14977. var form = this.getForm(options);
  14978. if (form) {
  14979. url = url || form.action;
  14980. }
  14981. return url;
  14982. },
  14983. setupParams: function(options, params) {
  14984. var form = this.getForm(options),
  14985. serializedForm;
  14986. if (form && !this.isFormUpload(options)) {
  14987. serializedForm = Ext.Element.serializeForm(form);
  14988. params = params ? (params + '&' + serializedForm) : serializedForm;
  14989. }
  14990. return params;
  14991. },
  14992. setupMethod: function(options, method) {
  14993. if (this.isFormUpload(options)) {
  14994. return 'POST';
  14995. }
  14996. return method;
  14997. },
  14998. isLoading: function(request) {
  14999. if (!request) {
  15000. request = this.getLatest();
  15001. }
  15002. return request ? request.isLoading() : false;
  15003. },
  15004. abort: function(request) {
  15005. if (!request) {
  15006. request = this.getLatest();
  15007. }
  15008. if (request && request.isLoading()) {
  15009. request.abort();
  15010. }
  15011. },
  15012. abortAll: function() {
  15013. var requests = this.requests,
  15014. id;
  15015. for (id in requests) {
  15016. this.abort(requests[id]);
  15017. }
  15018. },
  15019. getLatest: function() {
  15020. var id = this.latestId,
  15021. request;
  15022. if (id) {
  15023. request = this.requests[id];
  15024. }
  15025. return request || null;
  15026. },
  15027. clearTimeout: function(request) {
  15028. if (!request) {
  15029. request = this.getLatest();
  15030. }
  15031. if (request) {
  15032. request.clearTimer();
  15033. }
  15034. },
  15035. onRequestComplete: function(request) {
  15036. delete this.requests[request.id];
  15037. },
  15038. nativeBinaryPostSupport: function() {
  15039. return Ext.isChrome || (Ext.isSafari && Ext.isDefined(window.Uint8Array)) || (Ext.isGecko && Ext.isDefined(window.Uint8Array));
  15040. }
  15041. });
  15042. Ext.define('Ext.Ajax', {
  15043. extend: Ext.data.Connection,
  15044. singleton: true,
  15045. autoAbort: false
  15046. });
  15047. Ext.define('Ext.AnimationQueue', {
  15048. singleton: true,
  15049. constructor: function() {
  15050. var me = this;
  15051. me.queue = [];
  15052. me.taskQueue = [];
  15053. me.runningQueue = [];
  15054. me.idleQueue = [];
  15055. me.isRunning = false;
  15056. me.isIdle = true;
  15057. me.run = me.run.bind(me);
  15058. if (Ext.os.is.iOS) {
  15059. me.watch.$skipTimerCheck = true;
  15060. me.watchdogTimer = Ext.interval(me.watch, 500, me);
  15061. }
  15062. },
  15063. start: function(fn, scope, args) {
  15064. var me = this;
  15065. me.queue.push(arguments);
  15066. if (!me.isRunning) {
  15067. if (me.hasOwnProperty('idleTimer')) {
  15068. Ext.undefer(me.idleTimer);
  15069. delete me.idleTimer;
  15070. }
  15071. if (me.hasOwnProperty('idleQueueTimer')) {
  15072. Ext.undefer(me.idleQueueTimer);
  15073. delete me.idleQueueTimer;
  15074. }
  15075. me.isIdle = false;
  15076. me.isRunning = true;
  15077. me.startCountTime = Ext.now();
  15078. me.count = 0;
  15079. me.doStart();
  15080. }
  15081. },
  15082. clear: function() {
  15083. var me = this;
  15084. Ext.undefer(me.idleTimer);
  15085. Ext.undefer(me.idleQueueTimer);
  15086. Ext.unraf(me.animationFrameId);
  15087. me.idleTimer = me.idleQueueTimer = me.animationFrameId = null;
  15088. me.queue.length = me.taskQueue.length = me.runningQueue.length = me.idleQueue.length = 0;
  15089. me.isRunning = false;
  15090. me.isIdle = true;
  15091. me.startCountTime = Ext.now();
  15092. me.count = 0;
  15093. },
  15094. watch: function() {
  15095. if (this.isRunning && Ext.now() - this.lastRunTime >= 500) {
  15096. this.run();
  15097. }
  15098. },
  15099. run: function() {
  15100. var me = this,
  15101. queue = me.runningQueue,
  15102. now, item, element, i, ln;
  15103. me.animationFrameId = null;
  15104. if (!me.isRunning) {
  15105. return;
  15106. }
  15107. now = Ext.now();
  15108. me.lastRunTime = now;
  15109. me.frameStartTime = now;
  15110. i = me.queue.length;
  15111. while (i--) {
  15112. item = me.queue[i];
  15113. element = item[1] && item[1].getElement && item[1].getElement();
  15114. if (element && element.destroyed) {
  15115. me.queue.splice(i, 1);
  15116. }
  15117. }
  15118. queue.push.apply(queue, me.queue);
  15119. for (i = 0 , ln = queue.length; i < ln; i++) {
  15120. me.invoke(queue[i]);
  15121. }
  15122. queue.length = 0;
  15123. var elapse = me.frameStartTime - me.startCountTime,
  15124. count = ++me.count;
  15125. if (elapse >= 200) {
  15126. me.onFpsChanged(count * 1000 / elapse, count, elapse);
  15127. me.startCountTime = me.frameStartTime;
  15128. me.count = 0;
  15129. }
  15130. if (!me.queue.length) {
  15131. me.stop();
  15132. }
  15133. if (me.isRunning) {
  15134. me.doIterate();
  15135. }
  15136. },
  15137. onFpsChanged: Ext.emptyFn,
  15138. onStop: Ext.emptyFn,
  15139. doStart: function() {
  15140. if (!this.animationFrameId) {
  15141. this.animationFrameId = Ext.raf(this.run);
  15142. }
  15143. this.lastRunTime = Ext.now();
  15144. },
  15145. doIterate: function() {
  15146. if (!this.animationFrameId) {
  15147. this.animationFrameId = Ext.raf(this.run);
  15148. }
  15149. },
  15150. doStop: function() {
  15151. if (this.animationFrameId) {
  15152. Ext.unraf(this.animationFrameId);
  15153. }
  15154. this.animationFrameId = null;
  15155. },
  15156. stop: function(fn, scope, args) {
  15157. var me = this,
  15158. queue = me.queue,
  15159. ln = queue.length,
  15160. i, item;
  15161. if (!me.isRunning) {
  15162. return;
  15163. }
  15164. for (i = 0; i < ln; i++) {
  15165. item = queue[i];
  15166. if (item[0] === fn && item[1] === scope && item[2] === args) {
  15167. queue.splice(i, 1);
  15168. i--;
  15169. ln--;
  15170. }
  15171. }
  15172. if (ln === 0) {
  15173. me.doStop();
  15174. me.onStop();
  15175. me.isRunning = false;
  15176. if (me.idleQueue.length && !me.idleTimer) {
  15177. me.idleTimer = Ext.defer(me.whenIdle, 100, me);
  15178. }
  15179. }
  15180. },
  15181. onIdle: function(fn, scope, args) {
  15182. var me = this,
  15183. listeners = me.idleQueue,
  15184. i, ln, listener;
  15185. for (i = 0 , ln = listeners.length; i < ln; i++) {
  15186. listener = listeners[i];
  15187. if (fn === listener[0] && scope === listener[1] && args === listener[2]) {
  15188. return;
  15189. }
  15190. }
  15191. listeners.push(arguments);
  15192. if (me.isIdle) {
  15193. me.processIdleQueue();
  15194. } else if (!me.idleTimer) {
  15195. me.idleTimer = Ext.defer(me.whenIdle, 100, me);
  15196. }
  15197. },
  15198. unIdle: function(fn, scope, args) {
  15199. var me = this,
  15200. listeners = me.idleQueue,
  15201. i, ln, listener;
  15202. for (i = 0 , ln = listeners.length; i < ln; i++) {
  15203. listener = listeners[i];
  15204. if (fn === listener[0] && scope === listener[1] && args === listener[2]) {
  15205. listeners.splice(i, 1);
  15206. return true;
  15207. }
  15208. }
  15209. if (!listeners.length && me.idleTimer) {
  15210. Ext.undefer(me.idleTimer);
  15211. delete me.idleTimer;
  15212. }
  15213. if (!listeners.length && me.idleQueueTimer) {
  15214. Ext.undefer(me.idleQueueTimer);
  15215. delete me.idleQueueTimer;
  15216. }
  15217. return false;
  15218. },
  15219. queueTask: function(fn, scope, args) {
  15220. this.taskQueue.push(arguments);
  15221. this.processTaskQueue();
  15222. },
  15223. dequeueTask: function(fn, scope, args) {
  15224. var listeners = this.taskQueue,
  15225. i, ln, listener;
  15226. for (i = 0 , ln = listeners.length; i < ln; i++) {
  15227. listener = listeners[i];
  15228. if (fn === listener[0] && scope === listener[1] && args === listener[2]) {
  15229. listeners.splice(i, 1);
  15230. i--;
  15231. ln--;
  15232. }
  15233. }
  15234. },
  15235. invoke: function(listener) {
  15236. var fn = listener[0],
  15237. scope = listener[1],
  15238. args = listener[2];
  15239. fn = (typeof fn === 'string' ? scope[fn] : fn);
  15240. if (Ext.isArray(args)) {
  15241. fn.apply(scope, args);
  15242. } else {
  15243. fn.call(scope, args);
  15244. }
  15245. },
  15246. whenIdle: function() {
  15247. delete this.idleTimer;
  15248. this.isIdle = true;
  15249. this.processIdleQueue();
  15250. },
  15251. processIdleQueue: function() {
  15252. if (!this.hasOwnProperty('idleQueueTimer')) {
  15253. this.idleQueueTimer = Ext.defer(this.processIdleQueueItem, 1, this);
  15254. }
  15255. },
  15256. processIdleQueueItem: function() {
  15257. var listeners = this.idleQueue,
  15258. listener;
  15259. delete this.idleQueueTimer;
  15260. if (!this.isIdle) {
  15261. return;
  15262. }
  15263. if (listeners.length > 0) {
  15264. listener = listeners.shift();
  15265. this.invoke(listener);
  15266. this.processIdleQueue();
  15267. }
  15268. },
  15269. processTaskQueue: function() {
  15270. if (!this.hasOwnProperty('taskQueueTimer')) {
  15271. this.taskQueueTimer = Ext.defer(this.processTaskQueueItem, 15, this);
  15272. }
  15273. },
  15274. processTaskQueueItem: function() {
  15275. var listeners = this.taskQueue,
  15276. listener;
  15277. delete this.taskQueueTimer;
  15278. if (listeners.length > 0) {
  15279. listener = listeners.shift();
  15280. this.invoke(listener);
  15281. this.processTaskQueue();
  15282. }
  15283. },
  15284. showFps: function() {
  15285. var styleTpl = {
  15286. color: 'white',
  15287. 'background-color': 'black',
  15288. 'text-align': 'center',
  15289. 'font-family': 'sans-serif',
  15290. 'font-size': '8px',
  15291. 'font-weight': 'normal',
  15292. 'font-style': 'normal',
  15293. 'line-height': '20px',
  15294. '-webkit-font-smoothing': 'antialiased',
  15295. 'zIndex': 100000,
  15296. position: 'absolute'
  15297. };
  15298. Ext.getBody().append([
  15299. {
  15300. style: Ext.applyIf({
  15301. bottom: '50px',
  15302. left: 0,
  15303. width: '50px',
  15304. height: '20px'
  15305. }, styleTpl),
  15306. html: 'Average'
  15307. },
  15308. {
  15309. style: Ext.applyIf({
  15310. 'background-color': 'red',
  15311. 'font-size': '18px',
  15312. 'line-height': '50px',
  15313. bottom: 0,
  15314. left: 0,
  15315. width: '50px',
  15316. height: '50px'
  15317. }, styleTpl),
  15318. id: '__averageFps',
  15319. html: '0'
  15320. },
  15321. {
  15322. style: Ext.applyIf({
  15323. bottom: '50px',
  15324. left: '50px',
  15325. width: '50px',
  15326. height: '20px'
  15327. }, styleTpl),
  15328. html: 'Min (Last 1k)'
  15329. },
  15330. {
  15331. style: Ext.applyIf({
  15332. 'background-color': 'orange',
  15333. 'font-size': '18px',
  15334. 'line-height': '50px',
  15335. bottom: 0,
  15336. left: '50px',
  15337. width: '50px',
  15338. height: '50px'
  15339. }, styleTpl),
  15340. id: '__minFps',
  15341. html: '0'
  15342. },
  15343. {
  15344. style: Ext.applyIf({
  15345. bottom: '50px',
  15346. left: '100px',
  15347. width: '50px',
  15348. height: '20px'
  15349. }, styleTpl),
  15350. html: 'Max (Last 1k)'
  15351. },
  15352. {
  15353. style: Ext.applyIf({
  15354. 'background-color': 'maroon',
  15355. 'font-size': '18px',
  15356. 'line-height': '50px',
  15357. bottom: 0,
  15358. left: '100px',
  15359. width: '50px',
  15360. height: '50px'
  15361. }, styleTpl),
  15362. id: '__maxFps',
  15363. html: '0'
  15364. },
  15365. {
  15366. style: Ext.applyIf({
  15367. bottom: '50px',
  15368. left: '150px',
  15369. width: '50px',
  15370. height: '20px'
  15371. }, styleTpl),
  15372. html: 'Current'
  15373. },
  15374. {
  15375. style: Ext.applyIf({
  15376. 'background-color': 'green',
  15377. 'font-size': '18px',
  15378. 'line-height': '50px',
  15379. bottom: 0,
  15380. left: '150px',
  15381. width: '50px',
  15382. height: '50px'
  15383. }, styleTpl),
  15384. id: '__currentFps',
  15385. html: '0'
  15386. }
  15387. ]);
  15388. Ext.AnimationQueue.resetFps();
  15389. },
  15390. resetFps: function() {
  15391. var currentFps = Ext.get('__currentFps'),
  15392. averageFps = Ext.get('__averageFps'),
  15393. minFps = Ext.get('__minFps'),
  15394. maxFps = Ext.get('__maxFps'),
  15395. min = 1000,
  15396. max = 0,
  15397. count = 0,
  15398. sum = 0;
  15399. if (!currentFps) {
  15400. return;
  15401. }
  15402. Ext.AnimationQueue.onFpsChanged = function(fps) {
  15403. count++;
  15404. if (!(count % 10)) {
  15405. min = 1000;
  15406. max = 0;
  15407. }
  15408. sum += fps;
  15409. min = Math.min(min, fps);
  15410. max = Math.max(max, fps);
  15411. currentFps.setHtml(Math.round(fps));
  15412. averageFps.setHtml(Math.round(sum / count));
  15413. minFps.setHtml(Math.round(min));
  15414. maxFps.setHtml(Math.round(max));
  15415. };
  15416. }
  15417. }, function() {
  15418. var paramsString = window.location.search.substr(1),
  15419. paramsArray = paramsString.split("&");
  15420. if (Ext.Array.contains(paramsArray, "showfps")) {
  15421. Ext.onReady(this.showFps.bind(this));
  15422. }
  15423. });
  15424. Ext.define('Ext.mixin.Bufferable', function(Bufferable) {
  15425. return {
  15426. extend: Ext.Mixin,
  15427. mixinConfig: {
  15428. id: 'bufferable',
  15429. after: {
  15430. destroy: 'cancelAllCalls'
  15431. },
  15432. before: {
  15433. $reap: 'cancelAllCalls'
  15434. },
  15435. extended: function(baseClass, derivedClass, classBody) {
  15436. var bufferableMethods = classBody.bufferableMethods;
  15437. if (bufferableMethods) {
  15438. delete classBody.bufferableMethods;
  15439. Bufferable.processClass(derivedClass, bufferableMethods);
  15440. }
  15441. }
  15442. },
  15443. afterClassMixedIn: function(targetClass) {
  15444. Bufferable.processClass(targetClass);
  15445. },
  15446. privates: {
  15447. cancelAllCalls: function() {
  15448. var bufferables = this.bufferables,
  15449. name;
  15450. if (bufferables) {
  15451. for (name in bufferables) {
  15452. bufferables[name].cancel();
  15453. delete bufferables[name];
  15454. }
  15455. }
  15456. },
  15457. cancelBufferedCall: function(name, invoke) {
  15458. var bufferables = this.bufferables,
  15459. timer = bufferables && bufferables[name];
  15460. if (timer) {
  15461. timer[invoke ? 'invoke' : 'cancel']();
  15462. }
  15463. return !!timer;
  15464. },
  15465. flushBufferedCall: function(name) {
  15466. return this.cancelBufferedCall(name, true);
  15467. },
  15468. initBufferables: function() {
  15469. var me = this,
  15470. methods = me.hasOwnProperty('bufferableMethods') && me.bufferableMethods,
  15471. classMethods;
  15472. if (methods) {
  15473. Bufferable._canonicalize(methods);
  15474. classMethods = me.self.prototype.bufferableMethods;
  15475. me.bufferableMethods = Ext.merge(Ext.clone(classMethods), methods);
  15476. }
  15477. return (me.bufferables = {});
  15478. },
  15479. isCallPending: function(name) {
  15480. var bufferables = this.bufferables,
  15481. timer = bufferables && bufferables[name];
  15482. return !!timer;
  15483. },
  15484. statics: {
  15485. SINGLE: {
  15486. single: true
  15487. },
  15488. _canonicalize: function(methods) {
  15489. var t, def, s, name;
  15490. for (name in methods) {
  15491. s = Ext.String.capitalize(name);
  15492. def = methods[name];
  15493. t = typeof def;
  15494. if (t === 'number' || t === 'string') {
  15495. methods[name] = def = {
  15496. delay: def
  15497. };
  15498. }
  15499. if (typeof (t = def.delay) === 'string') {
  15500. def[t] = true;
  15501. delete def.delay;
  15502. }
  15503. def.capitalized = s;
  15504. def.name = name;
  15505. if (!def.fn) {
  15506. def.fn = 'do' + s;
  15507. }
  15508. if (!def.flag) {
  15509. def.flag = 'is' + s + 'Pending';
  15510. }
  15511. }
  15512. },
  15513. _canceller: function() {
  15514. var timer = this,
  15515. id = timer.id;
  15516. if (id) {
  15517. if (timer.delay) {
  15518. Ext.undefer(id);
  15519. } else if (timer.asap) {
  15520. Ext.unasap(id);
  15521. } else if (timer.idle) {
  15522. Ext.un('idle', id, null, Bufferable.SINGLE);
  15523. } else if (timer.raf) {
  15524. Ext.unraf(id);
  15525. }
  15526. timer.id = null;
  15527. }
  15528. timer.args = null;
  15529. timer.target[timer.flag] = false;
  15530. },
  15531. _invoker: function() {
  15532. var timer = this,
  15533. args = timer.args || Ext.emptyArray,
  15534. target = timer.target;
  15535. ++timer.invokes;
  15536. timer.cancel();
  15537. target[timer.fn].apply(target, args);
  15538. },
  15539. delayCall: function(target, def, args) {
  15540. if (target.destroying) {
  15541. return;
  15542. }
  15543. var bufferables = target.bufferables || target.initBufferables(),
  15544. name = def.name,
  15545. timer = bufferables[name] || (bufferables[name] = Ext.apply({
  15546. calls: 0,
  15547. invokes: 0,
  15548. args: null,
  15549. cancel: Bufferable._canceller,
  15550. id: null,
  15551. target: target,
  15552. invoke: Bufferable._invoker
  15553. }, def)),
  15554. delay = def.delay,
  15555. exec = function() {
  15556. if (timer.id) {
  15557. timer.id = null;
  15558. timer.invoke();
  15559. }
  15560. };
  15561. if (timer.id) {
  15562. timer.cancel();
  15563. }
  15564. timer.args = args;
  15565. ++timer.calls;
  15566. target[timer.flag] = true;
  15567. if (delay) {
  15568. timer.id = Ext.defer(exec, delay);
  15569. } else if (def.asap) {
  15570. timer.id = Ext.asap(exec);
  15571. } else if (def.idle) {
  15572. timer.id = exec;
  15573. Ext.on('idle', exec, null, Bufferable.SINGLE);
  15574. } else if (def.raf) {
  15575. timer.id = Ext.raf(exec);
  15576. } else {
  15577. timer.invoke();
  15578. }
  15579. },
  15580. processClass: function(cls, bufferableMethods) {
  15581. var proto = cls.prototype,
  15582. inherited = proto.bufferableMethods,
  15583. def, name;
  15584. if (bufferableMethods) {
  15585. Bufferable._canonicalize(bufferableMethods);
  15586. if (inherited) {
  15587. inherited = Ext.merge(Ext.clone(inherited), bufferableMethods);
  15588. }
  15589. proto.bufferableMethods = inherited || bufferableMethods;
  15590. } else {
  15591. bufferableMethods = inherited;
  15592. Bufferable._canonicalize(bufferableMethods);
  15593. proto.bufferables = null;
  15594. }
  15595. if (bufferableMethods) {
  15596. for (name in bufferableMethods) {
  15597. if (!proto[name]) {
  15598. def = bufferableMethods[name];
  15599. Bufferable.processMethod(proto, def, Array.prototype.slice);
  15600. }
  15601. }
  15602. }
  15603. },
  15604. processMethod: function(proto, def, slice) {
  15605. var name = def.name,
  15606. cap = def.capitalized;
  15607. proto[name] = function() {
  15608. return Bufferable.delayCall(this, def, slice.call(arguments));
  15609. };
  15610. proto['cancel' + cap] = function() {
  15611. return this.cancelBufferedCall(name);
  15612. };
  15613. proto['flush' + cap] = function() {
  15614. return this.flushBufferedCall(name);
  15615. };
  15616. }
  15617. }
  15618. }
  15619. };
  15620. });
  15621. Ext.define('Ext.ComponentManager', {
  15622. alternateClassName: 'Ext.ComponentMgr',
  15623. singleton: true,
  15624. mixins: [
  15625. Ext.mixin.Bufferable
  15626. ],
  15627. count: 0,
  15628. fixReferencesTimer: null,
  15629. referenceRepairs: 0,
  15630. typeName: 'xtype',
  15631. bufferableMethods: {
  15632. handleDocumentMouseDown: 'asap'
  15633. },
  15634. constructor: function(config) {
  15635. var me = this;
  15636. Ext.apply(me, config);
  15637. me.all = {};
  15638. me.byInstanceId = {};
  15639. me.holders = {};
  15640. me.onAvailableCallbacks = {};
  15641. },
  15642. create: function(config, defaultType) {
  15643. if (typeof config === 'string') {
  15644. return Ext.widget(config);
  15645. }
  15646. if (config.isComponent) {
  15647. return config;
  15648. }
  15649. if ('xclass' in config) {
  15650. return Ext.create(config.xclass, config);
  15651. }
  15652. return Ext.widget(config.xtype || defaultType, config);
  15653. },
  15654. get: function(id) {
  15655. return this.all[id];
  15656. },
  15657. register: function(component) {
  15658. var me = this,
  15659. id = component.getId(),
  15660. onAvailableCallbacks = me.onAvailableCallbacks;
  15661. if (id === undefined) {
  15662. Ext.raise('Component id is undefined. Please ensure the component has an id.');
  15663. }
  15664. if (id in me.all) {
  15665. Ext.raise('Duplicate component id "' + id + '"');
  15666. }
  15667. if (component.$iid in me.byInstanceId) {
  15668. Ext.raise('Duplicate component instance id "' + component.$iid + '"');
  15669. }
  15670. me.all[id] = component;
  15671. me.byInstanceId[component.$iid] = component;
  15672. if (component.nameHolder || component.referenceHolder) {
  15673. me.holders[id] = component;
  15674. }
  15675. ++me.count;
  15676. if (!me.hasFocusListener) {
  15677. me.installFocusListener();
  15678. }
  15679. onAvailableCallbacks = onAvailableCallbacks && onAvailableCallbacks[id];
  15680. if (onAvailableCallbacks && onAvailableCallbacks.length) {
  15681. me.notifyAvailable(component);
  15682. }
  15683. },
  15684. unregister: function(component) {
  15685. var me = this,
  15686. all = me.all,
  15687. byInstanceId = me.byInstanceId,
  15688. holders = me.holders,
  15689. id = component.getId();
  15690. if (id in holders) {
  15691. holders[id] = null;
  15692. delete holders[id];
  15693. }
  15694. all[id] = null;
  15695. delete all[id];
  15696. id = component.$iid;
  15697. byInstanceId[id] = null;
  15698. delete byInstanceId[id];
  15699. --me.count;
  15700. },
  15701. markReferencesDirty: function() {
  15702. var me = this,
  15703. holders = me.holders,
  15704. holder, id;
  15705. if (!Ext.referencesDirty) {
  15706. for (id in holders) {
  15707. holder = holders[id];
  15708. holder.refs = holder.nameRefs = null;
  15709. if (holder.invalidateChildDirty) {
  15710. holder.invalidateChildDirty();
  15711. }
  15712. }
  15713. Ext.referencesDirty = true;
  15714. me.fixReferencesTimer = Ext.asap(function() {
  15715. me.fixReferencesTimer = null;
  15716. me.fixReferences();
  15717. });
  15718. }
  15719. },
  15720. fixReferences: function() {
  15721. var me = this,
  15722. all = me.all,
  15723. holders = me.holders,
  15724. holder, id;
  15725. if (Ext.referencesDirty) {
  15726. me.fixReferencesTimer = Ext.unasap(me.fixReferencesTimer);
  15727. Ext.referencesDirty = 0;
  15728. ++me.referenceRepairs;
  15729. for (id in holders) {
  15730. holder = holders[id];
  15731. if (holder.beginSyncChildDirty) {
  15732. holder.beginSyncChildDirty();
  15733. }
  15734. }
  15735. for (id in all) {
  15736. all[id]._fixReference();
  15737. }
  15738. for (id in holders) {
  15739. holder = holders[id];
  15740. if (holder.finishSyncChildDirty) {
  15741. holder.finishSyncChildDirty();
  15742. }
  15743. }
  15744. Ext.referencesDirty = false;
  15745. }
  15746. },
  15747. onAvailable: function(id, fn, scope) {
  15748. var me = this,
  15749. callbacks = me.onAvailableCallbacks,
  15750. all = me.all,
  15751. item;
  15752. if (id in all) {
  15753. item = all[id];
  15754. fn.call(scope || item, item);
  15755. } else if (id) {
  15756. if (!Ext.isArray(callbacks[id])) {
  15757. callbacks[id] = [];
  15758. }
  15759. callbacks[id].push(function(item) {
  15760. fn.call(scope || item, item);
  15761. });
  15762. }
  15763. },
  15764. notifyAvailable: function(item) {
  15765. var callbacks = this.onAvailableCallbacks[item && item.getId()] || [];
  15766. while (callbacks.length) {
  15767. (callbacks.shift())(item);
  15768. }
  15769. },
  15770. each: function(fn, scope) {
  15771. Ext.Object.each(this.all, fn, scope);
  15772. },
  15773. getCount: function() {
  15774. return this.count;
  15775. },
  15776. getAll: function() {
  15777. return Ext.Object.getValues(this.all);
  15778. },
  15779. getActiveComponent: function() {
  15780. return Ext.Component.from(Ext.dom.Element.getActiveElement());
  15781. },
  15782. onGlobalFocus: function(info) {
  15783. var me = this,
  15784. event = info.event.chain(),
  15785. infoCopy = Ext.applyIf({
  15786. event: event
  15787. }, info),
  15788. to, from, ancestor, target;
  15789. to = event.toComponent = infoCopy.toComponent = Ext.Component.from(info.toElement);
  15790. from = event.fromComponent = infoCopy.fromComponent = Ext.Component.from(info.fromElement);
  15791. ancestor = me.getCommonAncestor(from, to);
  15792. if (to !== from) {
  15793. if (from && !from.destroyed && !from.isDestructing()) {
  15794. if (from.handleBlurEvent) {
  15795. from.handleBlurEvent(infoCopy);
  15796. }
  15797. for (target = from; target && target !== ancestor; target = target.getRefOwner()) {
  15798. if (!(target.destroyed || target.destroying)) {
  15799. event.type = 'focusleave';
  15800. target.onFocusLeave(event);
  15801. }
  15802. }
  15803. }
  15804. if (to && !to.destroyed && !to.isDestructing()) {
  15805. if (to.handleFocusEvent) {
  15806. to.handleFocusEvent(infoCopy);
  15807. }
  15808. for (target = to; target && target !== ancestor; target = target.getRefOwner()) {
  15809. event.type = 'focusenter';
  15810. target.onFocusEnter(event);
  15811. }
  15812. }
  15813. }
  15814. for (target = ancestor; target; target = target.getRefOwner()) {
  15815. if (!(target.destroying || target.destroyed)) {
  15816. target.onFocusMove(infoCopy);
  15817. }
  15818. }
  15819. },
  15820. getCommonAncestor: function(compA, compB) {
  15821. if (compA === compB) {
  15822. return compA;
  15823. }
  15824. while (compA && !(compA.isAncestor(compB) || compA === compB)) {
  15825. compA = compA.getRefOwner();
  15826. }
  15827. return compA;
  15828. },
  15829. privates: {
  15830. doHandleDocumentMouseDown: function(e) {
  15831. var floatedSelector = Ext.Widget.prototype.floatedSelector,
  15832. targetFloated;
  15833. if (floatedSelector) {
  15834. targetFloated = Ext.Component.from(e.getTarget(floatedSelector, Ext.getBody()));
  15835. if (targetFloated) {
  15836. targetFloated.toFront(true);
  15837. }
  15838. }
  15839. },
  15840. installFocusListener: function() {
  15841. var me = this;
  15842. Ext.on('focus', me.onGlobalFocus, me);
  15843. me.hasFocusListener = true;
  15844. },
  15845. clearAll: function() {
  15846. var me = this;
  15847. me.all = {};
  15848. me.byInstanceId = {};
  15849. me.holders = {};
  15850. me.onAvailableCallbacks = {};
  15851. },
  15852. from: function(el, limit, selector) {
  15853. var cache = this.all,
  15854. depth = 0,
  15855. target, topmost, cmpId, cmp;
  15856. if (el && el.isEvent) {
  15857. el = el.target;
  15858. }
  15859. target = Ext.getDom(el);
  15860. if (typeof limit !== 'number') {
  15861. topmost = Ext.getDom(limit);
  15862. limit = Number.MAX_VALUE;
  15863. }
  15864. while (target && target.nodeType === 1 && depth < limit && target !== topmost) {
  15865. cmpId = target.getAttribute('data-componentid') || target.id;
  15866. if (cmpId) {
  15867. cmp = cache[cmpId];
  15868. if (cmp && (!selector || Ext.ComponentQuery.is(cmp, selector))) {
  15869. return cmp;
  15870. }
  15871. depth++;
  15872. }
  15873. target = target.parentNode;
  15874. }
  15875. return null;
  15876. }
  15877. }
  15878. }, function(ComponentManager) {
  15879. ComponentManager.fromElement = ComponentManager.from;
  15880. Ext.referencesDirty = false;
  15881. Ext.fixReferences = function() {
  15882. ComponentManager.fixReferences();
  15883. };
  15884. Ext.markReferencesDirty = function() {
  15885. ComponentManager.markReferencesDirty();
  15886. };
  15887. Ext.getCmp = function(id) {
  15888. return ComponentManager.get(id);
  15889. };
  15890. Ext.iidToCmp = function(iid) {
  15891. return ComponentManager.byInstanceId[iid] || null;
  15892. };
  15893. Ext.doEv = function(node, e) {
  15894. var cmp, method, event;
  15895. cmp = Ext.Component.from(e.target);
  15896. if (cmp && !cmp.destroying && !cmp.destroyed && cmp.getEventHandlers) {
  15897. method = cmp.getEventHandlers()[e.type];
  15898. if (method && cmp[method]) {
  15899. event = new Ext.event.Event(e);
  15900. return cmp[method](event);
  15901. }
  15902. }
  15903. return true;
  15904. };
  15905. });
  15906. Ext.ns('Ext.util').Operators = {
  15907. "=": function(a, v) {
  15908. return a == v;
  15909. },
  15910. "!=": function(a, v) {
  15911. return a != v;
  15912. },
  15913. "^=": function(a, v) {
  15914. return a && a.substr(0, v.length) == v;
  15915. },
  15916. "$=": function(a, v) {
  15917. return a && a.substr(a.length - v.length) == v;
  15918. },
  15919. "*=": function(a, v) {
  15920. return a && a.indexOf(v) !== -1;
  15921. },
  15922. "%=": function(a, v) {
  15923. return (a % v) === 0;
  15924. },
  15925. "|=": function(a, v) {
  15926. return a && (a == v || a.substr(0, v.length + 1) == v + '-');
  15927. },
  15928. "~=": function(a, v) {
  15929. return a && (' ' + a + ' ').indexOf(' ' + v + ' ') != -1;
  15930. }
  15931. };
  15932. Ext.define('Ext.util.LruCache', {
  15933. extend: Ext.util.HashMap,
  15934. config: {
  15935. maxSize: null
  15936. },
  15937. add: function(key, newValue) {
  15938. var me = this,
  15939. entry, last;
  15940. me.removeAtKey(key);
  15941. last = me.last;
  15942. entry = {
  15943. prev: last,
  15944. next: null,
  15945. key: key,
  15946. value: newValue
  15947. };
  15948. if (last) {
  15949. last.next = entry;
  15950. } else {
  15951. me.first = entry;
  15952. }
  15953. me.last = entry;
  15954. me.callParent([
  15955. key,
  15956. entry
  15957. ]);
  15958. me.prune();
  15959. return newValue;
  15960. },
  15961. insertBefore: function(key, newValue, sibling) {
  15962. var me = this,
  15963. existingKey, entry;
  15964. if (sibling = this.map[this.findKey(sibling)]) {
  15965. existingKey = me.findKey(newValue);
  15966. if (existingKey) {
  15967. me.unlinkEntry(entry = me.map[existingKey]);
  15968. } else
  15969. {
  15970. entry = {
  15971. prev: sibling.prev,
  15972. next: sibling,
  15973. key: key,
  15974. value: newValue
  15975. };
  15976. }
  15977. if (sibling.prev) {
  15978. entry.prev.next = entry;
  15979. } else {
  15980. me.first = entry;
  15981. }
  15982. entry.next = sibling;
  15983. sibling.prev = entry;
  15984. me.prune();
  15985. return newValue;
  15986. } else
  15987. {
  15988. return me.add(key, newValue);
  15989. }
  15990. },
  15991. get: function(key) {
  15992. var entry = this.map[key];
  15993. if (entry) {
  15994. if (entry.next) {
  15995. this.moveToEnd(entry);
  15996. }
  15997. return entry.value;
  15998. }
  15999. },
  16000. removeAtKey: function(key) {
  16001. this.unlinkEntry(this.map[key]);
  16002. return this.callParent(arguments);
  16003. },
  16004. clear: function(initial) {
  16005. this.first = this.last = null;
  16006. return this.callParent([
  16007. initial
  16008. ]);
  16009. },
  16010. unlinkEntry: function(entry) {
  16011. if (entry) {
  16012. if (entry.next) {
  16013. entry.next.prev = entry.prev;
  16014. } else {
  16015. this.last = entry.prev;
  16016. }
  16017. if (entry.prev) {
  16018. entry.prev.next = entry.next;
  16019. } else {
  16020. this.first = entry.next;
  16021. }
  16022. entry.prev = entry.next = null;
  16023. }
  16024. },
  16025. moveToEnd: function(entry) {
  16026. this.unlinkEntry(entry);
  16027. if (entry.prev = this.last) {
  16028. this.last.next = entry;
  16029. } else
  16030. {
  16031. this.first = entry;
  16032. }
  16033. this.last = entry;
  16034. },
  16035. getArray: function(isKey) {
  16036. var arr = [],
  16037. entry = this.first;
  16038. while (entry) {
  16039. arr.push(isKey ? entry.key : entry.value);
  16040. entry = entry.next;
  16041. }
  16042. return arr;
  16043. },
  16044. each: function(fn, scope, reverse) {
  16045. var me = this,
  16046. entry = reverse ? me.last : me.first,
  16047. length = me.length;
  16048. scope = scope || me;
  16049. while (entry) {
  16050. if (fn.call(scope, entry.key, entry.value, length) === false) {
  16051. break;
  16052. }
  16053. entry = reverse ? entry.prev : entry.next;
  16054. }
  16055. return me;
  16056. },
  16057. findKey: function(value) {
  16058. var key,
  16059. map = this.map;
  16060. for (key in map) {
  16061. if (map.hasOwnProperty(key) && map[key].value === value) {
  16062. return key;
  16063. }
  16064. }
  16065. return undefined;
  16066. },
  16067. clone: function() {
  16068. var newCache = new this.self(this.initialConfig),
  16069. map = this.map,
  16070. key;
  16071. newCache.suspendEvents();
  16072. for (key in map) {
  16073. if (map.hasOwnProperty(key)) {
  16074. newCache.add(key, map[key].value);
  16075. }
  16076. }
  16077. newCache.resumeEvents();
  16078. return newCache;
  16079. },
  16080. prune: function() {
  16081. var me = this,
  16082. max = me.getMaxSize(),
  16083. purgeCount = max ? (me.length - max) : 0;
  16084. if (purgeCount > 0) {
  16085. for (; me.first && purgeCount; purgeCount--) {
  16086. me.removeAtKey(me.first.key);
  16087. }
  16088. }
  16089. }
  16090. });
  16091. Ext.define('Ext.ComponentQuery', {
  16092. singleton: true
  16093. }, function() {
  16094. var cq = this,
  16095. queryOperators = Ext.util.Operators,
  16096. nthRe = /(\d*)n\+?(\d*)/,
  16097. nthRe2 = /\D/,
  16098. stripLeadingSpaceRe = /^(\s)+/,
  16099. unescapeRe = /\\(.)/g,
  16100. regexCache = new Ext.util.LruCache({
  16101. maxSize: 100
  16102. }),
  16103. filterFnPattern = [
  16104. 'var r = [],',
  16105. 'i = 0,',
  16106. 'it = items,',
  16107. 'l = it.length,',
  16108. 'c;',
  16109. 'for (; i < l; i++) {',
  16110. 'c = it[i];',
  16111. 'if (c.{0}) {',
  16112. 'r.push(c);',
  16113. '}',
  16114. '}',
  16115. 'return r;'
  16116. ].join(''),
  16117. filterItems = function(items, operation) {
  16118. return operation.method.apply(this, [
  16119. items
  16120. ].concat(operation.args));
  16121. },
  16122. getItems = function(items, mode) {
  16123. var result = [],
  16124. i = 0,
  16125. length = items.length,
  16126. candidate,
  16127. deep = mode !== '>';
  16128. for (; i < length; i++) {
  16129. candidate = items[i];
  16130. if (candidate.getRefItems) {
  16131. result = result.concat(candidate.getRefItems(deep));
  16132. }
  16133. }
  16134. return result;
  16135. },
  16136. getAncestors = function(items) {
  16137. var result = [],
  16138. i = 0,
  16139. length = items.length,
  16140. candidate;
  16141. for (; i < length; i++) {
  16142. candidate = items[i];
  16143. while (!!(candidate = candidate.getRefOwner())) {
  16144. result.push(candidate);
  16145. }
  16146. }
  16147. return result;
  16148. },
  16149. filterByXType = function(items, xtype, shallow) {
  16150. if (xtype === '*') {
  16151. return items.slice();
  16152. } else {
  16153. var result = [],
  16154. i = 0,
  16155. length = items.length,
  16156. candidate;
  16157. for (; i < length; i++) {
  16158. candidate = items[i];
  16159. if (!candidate.destroyed && candidate.isXType(xtype, shallow)) {
  16160. result.push(candidate);
  16161. }
  16162. }
  16163. return result;
  16164. }
  16165. },
  16166. filterByAttribute = function(items, property, operator, compareTo) {
  16167. var result = [],
  16168. length = items.length,
  16169. mustBeOwnProperty, presenceOnly, candidate, propValue, config, i, j, propLen;
  16170. if (property.charAt(0) === '@') {
  16171. mustBeOwnProperty = true;
  16172. property = property.substr(1);
  16173. }
  16174. if (property.charAt(0) === '?') {
  16175. mustBeOwnProperty = true;
  16176. presenceOnly = true;
  16177. property = property.substr(1);
  16178. }
  16179. for (i = 0; i < length; i++) {
  16180. candidate = items[i];
  16181. config = candidate.self && candidate.self.getConfigurator && candidate.self.$config.configs[property];
  16182. if (config) {
  16183. propValue = candidate[config.names.get]();
  16184. } else if (mustBeOwnProperty && !candidate.hasOwnProperty(property)) {
  16185. continue;
  16186. } else {
  16187. propValue = candidate[property];
  16188. }
  16189. if (presenceOnly) {
  16190. result.push(candidate);
  16191. }
  16192. else if (operator === '~=') {
  16193. if (propValue) {
  16194. if (!Ext.isArray(propValue)) {
  16195. propValue = propValue.split(' ');
  16196. }
  16197. for (j = 0 , propLen = propValue.length; j < propLen; j++) {
  16198. if (queryOperators[operator](Ext.coerce(propValue[j], compareTo), compareTo)) {
  16199. result.push(candidate);
  16200. break;
  16201. }
  16202. }
  16203. }
  16204. } else if (operator === '/=') {
  16205. if (propValue != null && compareTo.test(propValue)) {
  16206. result.push(candidate);
  16207. }
  16208. }
  16209. else if (!compareTo ? !!propValue : queryOperators[operator](Ext.coerce(propValue, compareTo), compareTo)) {
  16210. result.push(candidate);
  16211. }
  16212. }
  16213. return result;
  16214. },
  16215. filterById = function(items, id, idOnly) {
  16216. var result = [],
  16217. i = 0,
  16218. length = items.length,
  16219. candidate, check;
  16220. for (; i < length; i++) {
  16221. candidate = items[i];
  16222. check = idOnly ? candidate.id : candidate.getItemId();
  16223. if (check === id) {
  16224. result.push(candidate);
  16225. }
  16226. }
  16227. return result;
  16228. },
  16229. filterByPseudo = function(items, name, value) {
  16230. return cq.pseudos[name](items, value);
  16231. },
  16232. modeRe = /^(\s?([>\^])\s?|\s|$)/,
  16233. tokenRe = /^(#)?((?:\\\.|[\w\-])+|\*)(?:\((true|false)\))?/,
  16234. matchers = [
  16235. {
  16236. re: /^\.((?:\\\.|[\w\-])+)(?:\((true|false)\))?/,
  16237. method: filterByXType,
  16238. argTransform: function(args) {
  16239. var selector = args[0];
  16240. Ext.log.warn('"' + selector + '" ComponentQuery selector style is deprecated,' + ' use "' + selector.replace(/^\./, '') + '" without the leading dot instead');
  16241. if (args[1] !== undefined) {
  16242. args[1] = args[1].replace(unescapeRe, '$1');
  16243. }
  16244. return args.slice(1);
  16245. }
  16246. },
  16247. {
  16248. re: /^(?:\[((?:[@?$])?[\w\-]*)\s*(?:([\^$*~%!\/]?=)\s*(['"])?((?:\\\]|.)*?)\3)?(?!\\)\])/,
  16249. method: filterByAttribute,
  16250. argTransform: function(args) {
  16251. var selector = args[0],
  16252. property = args[1],
  16253. operator = args[2],
  16254. compareTo = args[4],
  16255. compareRe;
  16256. if (compareTo !== undefined) {
  16257. compareTo = compareTo.replace(unescapeRe, '$1');
  16258. var format = Ext.String.format,
  16259. msg = "ComponentQuery selector '{0}' has an unescaped ({1}) character " + "at the {2} of the attribute value pattern. Usually that indicates " + "an error where the opening quote is not followed by the closing " + "quote. If you need to match a ({1}) character at the {2} of the " + "attribute value, escape the quote character in your pattern: " + "(\\{1})",
  16260. match;
  16261. if (match = /^(['"]).*?[^'"]$/.exec(compareTo)) {
  16262. Ext.log.warn(format(msg, selector, match[1], 'beginning'));
  16263. }
  16264. else if (match = /^[^'"].*?(['"])$/.exec(compareTo)) {
  16265. Ext.log.warn(format(msg, selector, match[1], 'end'));
  16266. }
  16267. }
  16268. if (operator === '/=') {
  16269. compareRe = regexCache.get(compareTo);
  16270. if (compareRe) {
  16271. compareTo = compareRe;
  16272. } else {
  16273. compareTo = regexCache.add(compareTo, new RegExp(compareTo));
  16274. }
  16275. }
  16276. return [
  16277. property,
  16278. operator,
  16279. compareTo
  16280. ];
  16281. }
  16282. },
  16283. {
  16284. re: /^#((?:\\\.|[\w\-])+)/,
  16285. method: filterById
  16286. },
  16287. {
  16288. re: /^\:([\w\-]+)(?:\(((?:\{[^\}]+\})|(?:(?!\{)[^\s>\/]*?(?!\})))\))?/,
  16289. method: filterByPseudo,
  16290. argTransform: function(args) {
  16291. if (args[2] !== undefined) {
  16292. args[2] = args[2].replace(unescapeRe, '$1');
  16293. }
  16294. return args.slice(1);
  16295. }
  16296. },
  16297. {
  16298. re: /^(?:\{([^\}]+)\})/,
  16299. method: filterFnPattern
  16300. }
  16301. ];
  16302. cq.Query = Ext.extend(Object, {
  16303. constructor: function(cfg) {
  16304. cfg = cfg || {};
  16305. Ext.apply(this, cfg);
  16306. },
  16307. execute: function(root) {
  16308. var operations = this.operations,
  16309. result = [],
  16310. op, i, len;
  16311. for (i = 0 , len = operations.length; i < len; i++) {
  16312. op = operations[i];
  16313. result = result.concat(this._execute(root, op));
  16314. }
  16315. return result;
  16316. },
  16317. _execute: function(root, operations) {
  16318. var i = 0,
  16319. length = operations.length,
  16320. operation, workingItems;
  16321. if (!root) {
  16322. workingItems = Ext.ComponentManager.getAll();
  16323. }
  16324. else if (Ext.isIterable(root)) {
  16325. workingItems = root;
  16326. }
  16327. else if (root.isMixedCollection) {
  16328. workingItems = root.items;
  16329. }
  16330. for (; i < length; i++) {
  16331. operation = operations[i];
  16332. if (operation.mode === '^') {
  16333. workingItems = getAncestors(workingItems || [
  16334. root
  16335. ]);
  16336. } else if (operation.mode) {
  16337. workingItems = getItems(workingItems || [
  16338. root
  16339. ], operation.mode);
  16340. } else {
  16341. workingItems = filterItems(workingItems || getItems([
  16342. root
  16343. ]), operation);
  16344. }
  16345. if (i === length - 1) {
  16346. return workingItems;
  16347. }
  16348. }
  16349. return [];
  16350. },
  16351. is: function(component, root) {
  16352. var operations = this.operations,
  16353. result = false,
  16354. len = operations.length,
  16355. op, i;
  16356. if (len === 0) {
  16357. return true;
  16358. }
  16359. for (i = 0; i < len; i++) {
  16360. op = operations[i];
  16361. result = this._is(component, root, op);
  16362. if (result) {
  16363. return result;
  16364. }
  16365. }
  16366. return false;
  16367. },
  16368. _is: function(component, root, operations) {
  16369. var len = operations.length,
  16370. active = [
  16371. component
  16372. ],
  16373. operation, i, j, mode, items, item;
  16374. for (i = len - 1; i >= 0; --i) {
  16375. operation = operations[i];
  16376. mode = operation.mode;
  16377. if (mode) {
  16378. if (mode === '^') {
  16379. active = getItems(active, ' ');
  16380. } else if (mode === '>') {
  16381. items = [];
  16382. for (j = 0 , len = active.length; j < len; ++j) {
  16383. item = active[j].getRefOwner();
  16384. if (item) {
  16385. items.push(item);
  16386. }
  16387. }
  16388. active = items;
  16389. } else {
  16390. active = getAncestors(active);
  16391. }
  16392. } else {
  16393. active = filterItems(active, operation);
  16394. }
  16395. if (active.length === 0) {
  16396. return false;
  16397. }
  16398. }
  16399. if (root) {
  16400. if (!mode) {
  16401. active = getAncestors(active);
  16402. }
  16403. if (active.length > 0) {
  16404. active = filterItems(active, {
  16405. method: filterById,
  16406. args: [
  16407. root.id,
  16408. true
  16409. ]
  16410. });
  16411. }
  16412. if (active.length === 0) {
  16413. return false;
  16414. }
  16415. }
  16416. return true;
  16417. },
  16418. getMatches: function(components, operations) {
  16419. var len = operations.length,
  16420. i;
  16421. for (i = 0; i < len; ++i) {
  16422. components = filterItems(components, operations[i]);
  16423. if (components.length === 0) {
  16424. break;
  16425. }
  16426. }
  16427. return components;
  16428. },
  16429. isMultiMatch: function() {
  16430. return this.operations.length > 1;
  16431. }
  16432. });
  16433. Ext.apply(cq, {
  16434. cache: new Ext.util.LruCache({
  16435. maxSize: 100
  16436. }),
  16437. pseudos: {
  16438. not: function(components, selector) {
  16439. var i = 0,
  16440. length = components.length,
  16441. results = [],
  16442. index = -1,
  16443. component;
  16444. for (; i < length; ++i) {
  16445. component = components[i];
  16446. if (!cq.is(component, selector)) {
  16447. results[++index] = component;
  16448. }
  16449. }
  16450. return results;
  16451. },
  16452. first: function(components) {
  16453. var ret = [];
  16454. if (components.length > 0) {
  16455. ret.push(components[0]);
  16456. }
  16457. return ret;
  16458. },
  16459. last: function(components) {
  16460. var len = components.length,
  16461. ret = [];
  16462. if (len > 0) {
  16463. ret.push(components[len - 1]);
  16464. }
  16465. return ret;
  16466. },
  16467. focusable: function(cmps) {
  16468. var len = cmps.length,
  16469. results = [],
  16470. i = 0,
  16471. c;
  16472. for (; i < len; i++) {
  16473. c = cmps[i];
  16474. if (c.isFocusable && c.isFocusable()) {
  16475. results.push(c);
  16476. }
  16477. }
  16478. return results;
  16479. },
  16480. canfocus: function(cmps, value) {
  16481. var len = cmps.length,
  16482. results = [],
  16483. i = 0,
  16484. c;
  16485. for (; i < len; i++) {
  16486. c = cmps[i];
  16487. if (c.canFocus && c.canFocus(false, value)) {
  16488. results.push(c);
  16489. }
  16490. }
  16491. return results;
  16492. },
  16493. "nth-child": function(c, a) {
  16494. var result = [],
  16495. m, f, i, len, n, nodeIndex;
  16496. m = nthRe.exec(a === "even" && "2n" || a === "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);
  16497. f = (m[1] || 1) - 0;
  16498. len = m[2] - 0;
  16499. for (i = 0; n = c[i]; i++) {
  16500. nodeIndex = i + 1;
  16501. if (f === 1) {
  16502. if (len === 0 || nodeIndex === len) {
  16503. result.push(n);
  16504. }
  16505. } else if ((nodeIndex + len) % f === 0) {
  16506. result.push(n);
  16507. }
  16508. }
  16509. return result;
  16510. },
  16511. scrollable: function(cmps) {
  16512. var len = cmps.length,
  16513. results = [],
  16514. i = 0,
  16515. c;
  16516. for (; i < len; i++) {
  16517. c = cmps[i];
  16518. if (c.scrollable || c._scrollable) {
  16519. results.push(c);
  16520. }
  16521. }
  16522. return results;
  16523. },
  16524. visible: function(cmps, deep) {
  16525. var len = cmps.length,
  16526. results = [],
  16527. i = 0,
  16528. c;
  16529. deep = deep === 'true';
  16530. for (; i < len; i++) {
  16531. c = cmps[i];
  16532. if (c.isVisible(deep)) {
  16533. results.push(c);
  16534. }
  16535. }
  16536. return results;
  16537. }
  16538. },
  16539. query: function(selector, root) {
  16540. if (!selector) {
  16541. return Ext.ComponentManager.getAll();
  16542. }
  16543. var results = [],
  16544. noDupResults = [],
  16545. dupMatcher = {},
  16546. query = cq.cache.get(selector),
  16547. resultsLn, cmp, i;
  16548. if (!query) {
  16549. query = cq.cache.add(selector, cq.parse(selector));
  16550. }
  16551. results = query.execute(root);
  16552. if (query.isMultiMatch()) {
  16553. resultsLn = results.length;
  16554. for (i = 0; i < resultsLn; i++) {
  16555. cmp = results[i];
  16556. if (!dupMatcher[cmp.id]) {
  16557. noDupResults.push(cmp);
  16558. dupMatcher[cmp.id] = true;
  16559. }
  16560. }
  16561. results = noDupResults;
  16562. }
  16563. return results;
  16564. },
  16565. visitPreOrder: function(selector, root, fn, scope, extraArgs) {
  16566. cq._visit(true, selector, root, fn, scope, extraArgs);
  16567. },
  16568. visitPostOrder: function(selector, root, fn, scope, extraArgs) {
  16569. cq._visit(false, selector, root, fn, scope, extraArgs);
  16570. },
  16571. _visit: function(preOrder, selector, root, fn, scope, extraArgs) {
  16572. var query = cq.cache.get(selector),
  16573. callArgs = [
  16574. root
  16575. ],
  16576. children,
  16577. len = 0,
  16578. i, rootMatch;
  16579. if (!query) {
  16580. query = cq.cache.add(selector, cq.parse(selector));
  16581. }
  16582. rootMatch = query.is(root);
  16583. if (root.getRefItems) {
  16584. children = root.getRefItems();
  16585. len = children.length;
  16586. }
  16587. if (extraArgs) {
  16588. Ext.Array.push(callArgs, extraArgs);
  16589. }
  16590. if (preOrder) {
  16591. if (rootMatch) {
  16592. if (fn.apply(scope || root, callArgs) === false) {
  16593. return false;
  16594. }
  16595. }
  16596. }
  16597. for (i = 0; i < len; i++) {
  16598. if (cq._visit.call(cq, preOrder, selector, children[i], fn, scope, extraArgs) === false) {
  16599. return false;
  16600. }
  16601. }
  16602. if (!preOrder) {
  16603. if (rootMatch) {
  16604. if (fn.apply(scope || root, callArgs) === false) {
  16605. return false;
  16606. }
  16607. }
  16608. }
  16609. },
  16610. is: function(component, selector, root) {
  16611. var query;
  16612. if (!selector) {
  16613. return true;
  16614. }
  16615. if (typeof selector === 'function') {
  16616. return selector(component);
  16617. } else {
  16618. query = cq.cache.get(selector);
  16619. if (!query) {
  16620. query = cq.cache.add(selector, cq.parse(selector));
  16621. }
  16622. return query.is(component, root);
  16623. }
  16624. },
  16625. parse: function(selector) {
  16626. var operations = [],
  16627. selectors, sel, i, len;
  16628. selectors = Ext.splitAndUnescape(selector, ',');
  16629. for (i = 0 , len = selectors.length; i < len; i++) {
  16630. sel = Ext.String.trim(selectors[i]);
  16631. if (sel === '') {
  16632. Ext.raise('Invalid ComponentQuery selector: ""');
  16633. }
  16634. operations.push(cq._parse(sel));
  16635. }
  16636. return new cq.Query({
  16637. operations: operations
  16638. });
  16639. },
  16640. _parse: function(selector) {
  16641. var operations = [],
  16642. trim = Ext.String.trim,
  16643. length = matchers.length,
  16644. lastSelector, tokenMatch, token, matchedChar, modeMatch, selectorMatch, transform, i, matcher, method, args;
  16645. while (selector && lastSelector !== selector) {
  16646. lastSelector = selector;
  16647. tokenMatch = selector.match(tokenRe);
  16648. if (tokenMatch) {
  16649. matchedChar = tokenMatch[1];
  16650. token = trim(tokenMatch[2]).replace(unescapeRe, '$1');
  16651. if (matchedChar === '#') {
  16652. operations.push({
  16653. method: filterById,
  16654. args: [
  16655. token
  16656. ]
  16657. });
  16658. } else
  16659. {
  16660. operations.push({
  16661. method: filterByXType,
  16662. args: [
  16663. token,
  16664. Boolean(tokenMatch[3])
  16665. ]
  16666. });
  16667. }
  16668. selector = selector.replace(tokenMatch[0], '').replace(stripLeadingSpaceRe, '$1');
  16669. }
  16670. while (!(modeMatch = selector.match(modeRe))) {
  16671. for (i = 0; selector && i < length; i++) {
  16672. matcher = matchers[i];
  16673. selectorMatch = selector.match(matcher.re);
  16674. method = matcher.method;
  16675. transform = matcher.argTransform;
  16676. if (selectorMatch) {
  16677. if (transform) {
  16678. args = transform(selectorMatch);
  16679. } else {
  16680. args = selectorMatch.slice(1);
  16681. }
  16682. operations.push({
  16683. method: Ext.isString(matcher.method) ?
  16684. Ext.functionFactory('items', Ext.String.format.apply(Ext.String, [
  16685. method
  16686. ].concat(selectorMatch.slice(1)))) : matcher.method,
  16687. args: args
  16688. });
  16689. selector = selector.replace(selectorMatch[0], '').replace(stripLeadingSpaceRe, '$1');
  16690. break;
  16691. }
  16692. if (i === (length - 1)) {
  16693. Ext.raise('Invalid ComponentQuery selector: "' + arguments[0] + '"');
  16694. }
  16695. }
  16696. }
  16697. if (modeMatch[1]) {
  16698. operations.push({
  16699. mode: modeMatch[2] || modeMatch[1]
  16700. });
  16701. selector = selector.replace(modeMatch[0], '').replace(stripLeadingSpaceRe, '');
  16702. }
  16703. }
  16704. return operations;
  16705. }
  16706. });
  16707. Ext.all = function() {
  16708. return cq.query.apply(cq, arguments);
  16709. };
  16710. Ext.first = function() {
  16711. var matches = cq.query.apply(cq, arguments);
  16712. return (matches && matches[0]) || null;
  16713. };
  16714. });
  16715. Ext.define('Ext.Evented', {
  16716. alternateClassName: 'Ext.EventedBase',
  16717. mixins: [
  16718. Ext.mixin.Observable
  16719. ],
  16720. initialized: false,
  16721. constructor: function(config) {
  16722. this.callParent();
  16723. this.mixins.observable.constructor.call(this, config);
  16724. this.initialized = true;
  16725. },
  16726. onClassExtended: function(cls, data) {
  16727. if (!data.hasOwnProperty('eventedConfig')) {
  16728. return;
  16729. }
  16730. var config = data.config,
  16731. eventedConfig = data.eventedConfig,
  16732. name, cfg;
  16733. if (config) {
  16734. Ext.applyIf(config, eventedConfig);
  16735. } else {
  16736. cls.addConfig(eventedConfig);
  16737. }
  16738. for (name in eventedConfig) {
  16739. if (eventedConfig.hasOwnProperty(name)) {
  16740. cfg = Ext.Config.get(name);
  16741. data[cfg.names.set] = cfg.eventedSetter || cfg.getEventedSetter();
  16742. }
  16743. }
  16744. }
  16745. });
  16746. Ext.define('Ext.util.Positionable', {
  16747. mixinId: 'positionable',
  16748. _positionTopLeft: [
  16749. 'position',
  16750. 'top',
  16751. 'left'
  16752. ],
  16753. clippedCls: Ext.baseCSSPrefix + 'clipped',
  16754. afterSetPosition: Ext.emptyFn,
  16755. getAnchorToXY: function() {
  16756. Ext.raise("getAnchorToXY is not implemented in " + this.$className);
  16757. },
  16758. getBorderPadding: function() {
  16759. Ext.raise("getBorderPadding is not implemented in " + this.$className);
  16760. },
  16761. getLocalX: function() {
  16762. Ext.raise("getLocalX is not implemented in " + this.$className);
  16763. },
  16764. getLocalXY: function() {
  16765. Ext.raise("getLocalXY is not implemented in " + this.$className);
  16766. },
  16767. getLocalY: function() {
  16768. Ext.raise("getLocalY is not implemented in " + this.$className);
  16769. },
  16770. getX: function() {
  16771. Ext.raise("getX is not implemented in " + this.$className);
  16772. },
  16773. getXY: function() {
  16774. Ext.raise("getXY is not implemented in " + this.$className);
  16775. },
  16776. getY: function() {
  16777. Ext.raise("getY is not implemented in " + this.$className);
  16778. },
  16779. setLocalX: function() {
  16780. Ext.raise("setLocalX is not implemented in " + this.$className);
  16781. },
  16782. setLocalXY: function() {
  16783. Ext.raise("setLocalXY is not implemented in " + this.$className);
  16784. },
  16785. setLocalY: function() {
  16786. Ext.raise("setLocalY is not implemented in " + this.$className);
  16787. },
  16788. setX: function() {
  16789. Ext.raise("setX is not implemented in " + this.$className);
  16790. },
  16791. setXY: function() {
  16792. Ext.raise("setXY is not implemented in " + this.$className);
  16793. },
  16794. setY: function() {
  16795. Ext.raise("setY is not implemented in " + this.$className);
  16796. },
  16797. adjustForConstraints: function(xy, parent) {
  16798. var vector = this.getConstrainVector(parent, xy);
  16799. if (vector) {
  16800. xy[0] += vector[0];
  16801. xy[1] += vector[1];
  16802. }
  16803. return xy;
  16804. },
  16805. alignTo: function(element, position, offsets, animate) {
  16806. var me = this,
  16807. el = me.el;
  16808. return me.setXY(me.getAlignToXY(element, position, offsets), el.anim && !!animate ? el.anim(animate) : false);
  16809. },
  16810. calculateAnchorXY: function(anchor, extraX, extraY, size) {
  16811. var region = this.getRegion();
  16812. region.setPosition(0, 0);
  16813. region.translateBy(extraX || 0, extraY || 0);
  16814. if (size) {
  16815. region.setWidth(size.width);
  16816. region.setHeight(size.height);
  16817. }
  16818. return region.getAnchorPoint(anchor);
  16819. },
  16820. convertPositionSpec: function(posSpec) {
  16821. return Ext.util.Region.getAlignInfo(posSpec);
  16822. },
  16823. getAlignToXY: function(alignToEl, position, offsets) {
  16824. var newRegion = this.getAlignToRegion(alignToEl, position, offsets);
  16825. return [
  16826. newRegion.x,
  16827. newRegion.y
  16828. ];
  16829. },
  16830. getAlignToRegion: function(alignToEl, posSpec, offset, minHeight) {
  16831. var me = this,
  16832. inside, newRegion, bodyScroll;
  16833. alignToEl = Ext.fly(alignToEl.el || alignToEl);
  16834. if (!alignToEl || !alignToEl.dom) {
  16835. Ext.raise({
  16836. sourceClass: 'Ext.util.Positionable',
  16837. sourceMethod: 'getAlignToXY',
  16838. msg: 'Attempted to align an element that doesn\'t exist'
  16839. });
  16840. }
  16841. posSpec = me.convertPositionSpec(posSpec);
  16842. if (posSpec.constrain) {
  16843. if (posSpec.constrain === '!') {
  16844. inside = alignToEl;
  16845. } else {
  16846. inside = me.constrainTo || me.container || me.el.parent();
  16847. }
  16848. inside = Ext.fly(inside.el || inside).getConstrainRegion();
  16849. }
  16850. if (alignToEl === Ext.getBody()) {
  16851. bodyScroll = alignToEl.getScroll();
  16852. offset = [
  16853. bodyScroll.left,
  16854. bodyScroll.top
  16855. ];
  16856. }
  16857. newRegion = me.getRegion().alignTo({
  16858. target: alignToEl.getRegion(),
  16859. inside: inside,
  16860. minHeight: minHeight,
  16861. offset: offset,
  16862. align: posSpec,
  16863. axisLock: true
  16864. });
  16865. return newRegion;
  16866. },
  16867. getAnchorXY: function(anchor, local, size) {
  16868. var me = this,
  16869. region = me.getRegion(),
  16870. el = me.el,
  16871. isViewport = el.dom.nodeName === 'BODY' || el.dom.nodeType === 9,
  16872. scroll = el.getScroll();
  16873. if (local) {
  16874. region.setPosition(0, 0);
  16875. } else if (isViewport) {
  16876. region.setPosition(scroll.left, scroll.top);
  16877. }
  16878. if (size) {
  16879. region.setWidth(size.width);
  16880. region.setHeight(size.height);
  16881. }
  16882. return region.getAnchorPoint(anchor);
  16883. },
  16884. getBox: function(contentBox, local) {
  16885. var me = this,
  16886. xy = local ? me.getLocalXY() : me.getXY(),
  16887. x = xy[0],
  16888. y = xy[1],
  16889. w, h, borderPadding, beforeX, beforeY;
  16890. if (me.el.dom.nodeName === 'BODY' || me.el.dom.nodeType === 9) {
  16891. w = Ext.Element.getViewportWidth();
  16892. h = Ext.Element.getViewportHeight();
  16893. } else {
  16894. w = me.getWidth();
  16895. h = me.getHeight();
  16896. }
  16897. if (contentBox) {
  16898. borderPadding = me.getBorderPadding();
  16899. beforeX = borderPadding.beforeX;
  16900. beforeY = borderPadding.beforeY;
  16901. x += beforeX;
  16902. y += beforeY;
  16903. w -= (beforeX + borderPadding.afterX);
  16904. h -= (beforeY + borderPadding.afterY);
  16905. }
  16906. return {
  16907. x: x,
  16908. left: x,
  16909. 0: x,
  16910. y: y,
  16911. top: y,
  16912. 1: y,
  16913. width: w,
  16914. height: h,
  16915. right: x + w,
  16916. bottom: y + h
  16917. };
  16918. },
  16919. calculateConstrainedPosition: function(constrainTo, proposedPosition, local, proposedSize) {
  16920. var me = this,
  16921. vector,
  16922. fp = me.floatParent,
  16923. parentNode = fp ? fp.getTargetEl() : null,
  16924. parentOffset, borderPadding, proposedConstrainPosition,
  16925. xy = false;
  16926. if (local && fp) {
  16927. parentOffset = parentNode.getXY();
  16928. borderPadding = parentNode.getBorderPadding();
  16929. parentOffset[0] += borderPadding.beforeX;
  16930. parentOffset[1] += borderPadding.beforeY;
  16931. if (proposedPosition) {
  16932. proposedConstrainPosition = [
  16933. proposedPosition[0] + parentOffset[0],
  16934. proposedPosition[1] + parentOffset[1]
  16935. ];
  16936. }
  16937. } else {
  16938. proposedConstrainPosition = proposedPosition;
  16939. }
  16940. constrainTo = constrainTo || me.constrainTo || parentNode || me.container || me.el.parent();
  16941. if (local && proposedConstrainPosition) {
  16942. proposedConstrainPosition = me.reverseTranslateXY(proposedConstrainPosition);
  16943. }
  16944. vector = ((me.constrainHeader && me.header.rendered) ? me.header : me).getConstrainVector(constrainTo, proposedConstrainPosition, proposedSize);
  16945. if (vector) {
  16946. xy = proposedPosition || me.getPosition(local);
  16947. xy[0] += vector[0];
  16948. xy[1] += vector[1];
  16949. }
  16950. return xy;
  16951. },
  16952. getConstrainRegion: function() {
  16953. var me = this,
  16954. el = me.el,
  16955. isBody = el.dom.nodeName === 'BODY',
  16956. dom = el.dom,
  16957. borders = el.getBorders(),
  16958. pos = el.getXY(),
  16959. left = pos[0] + borders.beforeX,
  16960. top = pos[1] + borders.beforeY,
  16961. scroll, width, height;
  16962. if (isBody) {
  16963. scroll = el.getScroll();
  16964. left = scroll.left;
  16965. top = scroll.top;
  16966. width = Ext.Element.getViewportWidth();
  16967. height = Ext.Element.getViewportHeight();
  16968. } else {
  16969. width = dom.clientWidth;
  16970. height = dom.clientHeight;
  16971. }
  16972. return new Ext.util.Region(top, left + width, top + height, left);
  16973. },
  16974. getConstrainVector: function(constrainTo, proposedPosition, proposedSize) {
  16975. var me = this,
  16976. thisRegion = me.getRegion(),
  16977. vector = [
  16978. 0,
  16979. 0
  16980. ],
  16981. shadowSize = (me.shadow && me.constrainShadow && !me.shadowDisabled) ? me.el.shadow.getShadowSize() : undefined,
  16982. overflowed = false,
  16983. constraintInsets = me.constraintInsets;
  16984. if (!(constrainTo instanceof Ext.util.Region)) {
  16985. constrainTo = Ext.get(constrainTo.el || constrainTo);
  16986. constrainTo = constrainTo.getConstrainRegion();
  16987. }
  16988. if (constraintInsets) {
  16989. constraintInsets = Ext.isObject(constraintInsets) ? constraintInsets : Ext.Element.parseBox(constraintInsets);
  16990. constrainTo.adjust(constraintInsets.top, constraintInsets.right, constraintInsets.bottom, constraintInsets.left);
  16991. }
  16992. if (proposedPosition) {
  16993. thisRegion.translateBy(proposedPosition[0] - thisRegion.x, proposedPosition[1] - thisRegion.y);
  16994. }
  16995. if (proposedSize) {
  16996. thisRegion.right = thisRegion.left + proposedSize[0];
  16997. thisRegion.bottom = thisRegion.top + proposedSize[1];
  16998. }
  16999. if (shadowSize) {
  17000. constrainTo.adjust(shadowSize[0], -shadowSize[1], -shadowSize[2], shadowSize[3]);
  17001. }
  17002. if (thisRegion.right > constrainTo.right) {
  17003. overflowed = true;
  17004. vector[0] = (constrainTo.right - thisRegion.right);
  17005. }
  17006. if (thisRegion.left + vector[0] < constrainTo.left) {
  17007. overflowed = true;
  17008. vector[0] = (constrainTo.left - thisRegion.left);
  17009. }
  17010. if (thisRegion.bottom > constrainTo.bottom) {
  17011. overflowed = true;
  17012. vector[1] = (constrainTo.bottom - thisRegion.bottom);
  17013. }
  17014. if (thisRegion.top + vector[1] < constrainTo.top) {
  17015. overflowed = true;
  17016. vector[1] = (constrainTo.top - thisRegion.top);
  17017. }
  17018. return overflowed ? vector : false;
  17019. },
  17020. getOffsetsTo: function(offsetsTo) {
  17021. var o = this.getXY(),
  17022. e = offsetsTo.isRegion ? [
  17023. offsetsTo.x,
  17024. offsetsTo.y
  17025. ] : Ext.fly(offsetsTo.el || offsetsTo).getXY();
  17026. return [
  17027. o[0] - e[0],
  17028. o[1] - e[1]
  17029. ];
  17030. },
  17031. getRegion: function(contentBox, local) {
  17032. var box = this.getBox(contentBox, local);
  17033. return new Ext.util.Region(box.top, box.right, box.bottom, box.left);
  17034. },
  17035. getClientRegion: function() {
  17036. var me = this,
  17037. el = me.el,
  17038. dom = el.dom,
  17039. viewContentBox = me.getBox(true),
  17040. scrollbarHeight = dom.offsetHeight > dom.clientHeight,
  17041. scrollbarWidth = dom.offsetWidth > dom.clientWidth,
  17042. padding, scrollSize, isRTL;
  17043. if (scrollbarHeight || scrollbarWidth) {
  17044. scrollSize = Ext.getScrollbarSize();
  17045. if (scrollbarWidth) {
  17046. scrollbarWidth = scrollSize.width;
  17047. isRTL = el.getStyle('direction') === 'rtl' && !Ext.supports.rtlVertScrollbarOnRight;
  17048. if (isRTL) {
  17049. padding = el.getPadding('l');
  17050. viewContentBox.left -= padding + Math.max(padding, scrollbarWidth);
  17051. } else {
  17052. padding = el.getPadding('r');
  17053. viewContentBox.right += padding - Math.max(padding, scrollbarWidth);
  17054. }
  17055. }
  17056. if (scrollbarHeight) {
  17057. scrollbarHeight = scrollSize.height;
  17058. padding = el.getPadding('b');
  17059. viewContentBox.bottom += padding - Math.max(padding, scrollbarHeight);
  17060. }
  17061. }
  17062. return new Ext.util.Region(viewContentBox.top, viewContentBox.right, viewContentBox.bottom, viewContentBox.left);
  17063. },
  17064. getViewRegion: function() {
  17065. var me = this,
  17066. el = me.el,
  17067. isBody = el.dom.nodeName === 'BODY',
  17068. borderPadding, scroll, pos, top, left, width, height;
  17069. if (isBody) {
  17070. scroll = el.getScroll();
  17071. left = scroll.left;
  17072. top = scroll.top;
  17073. width = Ext.Element.getViewportWidth();
  17074. height = Ext.Element.getViewportHeight();
  17075. } else {
  17076. borderPadding = me.getBorderPadding();
  17077. pos = me.getXY();
  17078. left = pos[0] + borderPadding.beforeX;
  17079. top = pos[1] + borderPadding.beforeY;
  17080. width = me.getWidth(true);
  17081. height = me.getHeight(true);
  17082. }
  17083. return new Ext.util.Region(top, left + width, top + height, left);
  17084. },
  17085. move: function(direction, distance, animate) {
  17086. var me = this,
  17087. xy = me.getXY(),
  17088. x = xy[0],
  17089. y = xy[1],
  17090. left = [
  17091. x - distance,
  17092. y
  17093. ],
  17094. right = [
  17095. x + distance,
  17096. y
  17097. ],
  17098. top = [
  17099. x,
  17100. y - distance
  17101. ],
  17102. bottom = [
  17103. x,
  17104. y + distance
  17105. ],
  17106. hash = {
  17107. l: left,
  17108. left: left,
  17109. r: right,
  17110. right: right,
  17111. t: top,
  17112. top: top,
  17113. up: top,
  17114. b: bottom,
  17115. bottom: bottom,
  17116. down: bottom
  17117. };
  17118. direction = direction.toLowerCase();
  17119. me.setXY([
  17120. hash[direction][0],
  17121. hash[direction][1]
  17122. ], animate);
  17123. },
  17124. setBox: function(box) {
  17125. var me = this,
  17126. x, y;
  17127. if (box.isRegion) {
  17128. box = {
  17129. x: box.left,
  17130. y: box.top,
  17131. width: box.right - box.left,
  17132. height: box.bottom - box.top
  17133. };
  17134. }
  17135. me.constrainBox(box);
  17136. x = box.x;
  17137. y = box.y;
  17138. me.setXY([
  17139. x,
  17140. y
  17141. ]);
  17142. me.setSize(box.width, box.height);
  17143. me.afterSetPosition(x, y);
  17144. return me;
  17145. },
  17146. constrainBox: function(box) {
  17147. var me = this,
  17148. constrainedPos, x, y;
  17149. if (me.constrain || me.constrainHeader) {
  17150. x = ('x' in box) ? box.x : box.left;
  17151. y = ('y' in box) ? box.y : box.top;
  17152. constrainedPos = me.calculateConstrainedPosition(null, [
  17153. x,
  17154. y
  17155. ], false, [
  17156. box.width,
  17157. box.height
  17158. ]);
  17159. if (constrainedPos) {
  17160. box.x = constrainedPos[0];
  17161. box.y = constrainedPos[1];
  17162. }
  17163. }
  17164. },
  17165. translatePoints: function(x, y) {
  17166. var pos = this.translateXY(x, y);
  17167. return {
  17168. left: pos.x,
  17169. top: pos.y
  17170. };
  17171. },
  17172. translateXY: function(x, y) {
  17173. var me = this,
  17174. el = me.el,
  17175. styles = el.getStyle(me._positionTopLeft),
  17176. relative = styles.position === 'relative',
  17177. left = parseFloat(styles.left),
  17178. top = parseFloat(styles.top),
  17179. xy = me.getXY();
  17180. if (Ext.isArray(x)) {
  17181. y = x[1];
  17182. x = x[0];
  17183. }
  17184. if (isNaN(left)) {
  17185. left = relative ? 0 : el.dom.offsetLeft;
  17186. }
  17187. if (isNaN(top)) {
  17188. top = relative ? 0 : el.dom.offsetTop;
  17189. }
  17190. left = (typeof x === 'number') ? x - xy[0] + left : undefined;
  17191. top = (typeof y === 'number') ? y - xy[1] + top : undefined;
  17192. return {
  17193. x: left,
  17194. y: top
  17195. };
  17196. },
  17197. reverseTranslateXY: function(xy) {
  17198. var coords = xy,
  17199. el = this.el,
  17200. dom = el.dom,
  17201. offsetParent = dom.offsetParent,
  17202. relative, offsetParentXY, x, y;
  17203. if (offsetParent) {
  17204. relative = el.isStyle('position', 'relative');
  17205. offsetParentXY = Ext.fly(offsetParent).getXY();
  17206. x = xy[0] + offsetParentXY[0] + offsetParent.clientLeft;
  17207. y = xy[1] + offsetParentXY[1] + offsetParent.clientTop;
  17208. if (relative) {
  17209. x += el.getPadding('l');
  17210. y += el.getPadding('t');
  17211. }
  17212. coords = [
  17213. x,
  17214. y
  17215. ];
  17216. }
  17217. return coords;
  17218. },
  17219. privates: {
  17220. clipTo: function(clippingEl, sides) {
  17221. var clippingRegion,
  17222. el = this.el,
  17223. floaterRegion = el.getRegion(),
  17224. overflow, i,
  17225. clipValues = [],
  17226. clippedCls = this.clippedCls,
  17227. clipStyle, clipped, shadow;
  17228. if (clippingEl.isRegion) {
  17229. clippingRegion = clippingEl;
  17230. } else {
  17231. clippingRegion = (clippingEl.isComponent ? clippingEl.el : Ext.fly(clippingEl)).getConstrainRegion();
  17232. }
  17233. if (!sides) {
  17234. sides = 15;
  17235. }
  17236. if (sides & 1 && (overflow = clippingRegion.top - floaterRegion.top) > 0) {
  17237. clipValues[0] = overflow;
  17238. clipped = true;
  17239. } else {
  17240. clipValues[0] = -10000;
  17241. }
  17242. if (sides & 2 && (overflow = floaterRegion.right - clippingRegion.right) > 0) {
  17243. clipValues[1] = Math.max(0, el.getWidth() - overflow);
  17244. clipped = true;
  17245. } else {
  17246. clipValues[1] = 10000;
  17247. }
  17248. if (sides & 4 && (overflow = floaterRegion.bottom - clippingRegion.bottom) > 0) {
  17249. clipValues[2] = Math.max(0, el.getHeight() - overflow);
  17250. clipped = true;
  17251. } else {
  17252. clipValues[2] = 10000;
  17253. }
  17254. if (sides & 8 && (overflow = clippingRegion.left - floaterRegion.left) > 0) {
  17255. clipValues[3] = overflow;
  17256. clipped = true;
  17257. } else {
  17258. clipValues[3] = -10000;
  17259. }
  17260. clipStyle = 'rect(';
  17261. for (i = 0; i < 4; ++i) {
  17262. clipStyle += Ext.Element.addUnits(clipValues[i], 'px');
  17263. clipStyle += (i === 3) ? ')' : ',';
  17264. }
  17265. el.dom.style.clip = clipStyle;
  17266. el.addCls(clippedCls);
  17267. if ((shadow = el.shadow) && (el = shadow.el) && el.dom) {
  17268. clipValues[2] -= shadow.offsets.y;
  17269. clipValues[3] -= shadow.offsets.x;
  17270. clipStyle = 'rect(';
  17271. for (i = 0; i < 4; ++i) {
  17272. clipStyle += Ext.Element.addUnits(clipValues[i], 'px');
  17273. clipStyle += (i === 3) ? ')' : ',';
  17274. }
  17275. el.dom.style.clip = clipStyle;
  17276. if (clipped && !Ext.supports.CSS3BoxShadow) {
  17277. el.dom.style.display = 'none';
  17278. } else {
  17279. el.dom.style.display = '';
  17280. el.addCls(clippedCls);
  17281. }
  17282. }
  17283. },
  17284. clearClip: function() {
  17285. var el = this.el,
  17286. clippedCls = this.clippedCls;
  17287. el.dom.style.clip = Ext.isIE8 ? 'auto' : '';
  17288. el.removeCls(clippedCls);
  17289. if (el.shadow && el.shadow.el && el.shadow.el.dom) {
  17290. el.shadow.el.dom.style.clip = Ext.isIE8 ? 'auto' : '';
  17291. if (!Ext.supports.CSS3BoxShadow) {
  17292. el.dom.style.display = '';
  17293. el.removeCls(clippedCls);
  17294. }
  17295. }
  17296. }
  17297. }
  17298. });
  17299. Ext.define('Ext.dom.UnderlayPool', {
  17300. constructor: function(elementConfig) {
  17301. this.elementConfig = elementConfig;
  17302. this.cache = [];
  17303. },
  17304. checkOut: function() {
  17305. var el = this.cache.shift();
  17306. if (!el) {
  17307. el = Ext.Element.create(this.elementConfig);
  17308. el.setVisibilityMode(2);
  17309. el.dom.setAttribute('data-sticky', true);
  17310. }
  17311. return el;
  17312. },
  17313. checkIn: function(el) {
  17314. this.cache.push(el);
  17315. Ext.getDetachedBody().dom.appendChild(el.dom);
  17316. },
  17317. reset: function() {
  17318. var cache = this.cache,
  17319. i = cache.length;
  17320. while (i--) {
  17321. cache[i].destroy();
  17322. }
  17323. this.cache = [];
  17324. }
  17325. });
  17326. Ext.define('Ext.dom.Underlay', {
  17327. constructor: function(config) {
  17328. Ext.apply(this, config);
  17329. },
  17330. beforeShow: Ext.emptyFn,
  17331. getInsertionTarget: function() {
  17332. return this.target;
  17333. },
  17334. getPool: function() {
  17335. return this.pool || (this.self.prototype.pool = new Ext.dom.UnderlayPool(this.elementConfig));
  17336. },
  17337. hide: function() {
  17338. var me = this,
  17339. el = me.el;
  17340. if (el) {
  17341. if (el.dom) {
  17342. el.hide();
  17343. me.getPool().checkIn(el);
  17344. }
  17345. me.el = null;
  17346. }
  17347. me.hidden = true;
  17348. },
  17349. realign: function(x, y, width, height) {
  17350. var me = this,
  17351. el = me.el,
  17352. target = me.target,
  17353. offsets = me.offsets,
  17354. max = Math.max;
  17355. if (el) {
  17356. if (x == null) {
  17357. x = target.getX();
  17358. }
  17359. if (y == null) {
  17360. y = target.getY();
  17361. }
  17362. if (width == null) {
  17363. width = target.getWidth();
  17364. }
  17365. if (height == null) {
  17366. height = target.getHeight();
  17367. }
  17368. if (offsets) {
  17369. x = x + offsets.x;
  17370. y = y + offsets.y;
  17371. width = max(width + offsets.w, 0);
  17372. height = max(height + offsets.h, 0);
  17373. }
  17374. el.setXY([
  17375. x,
  17376. y
  17377. ]);
  17378. el.setSize(width, height);
  17379. }
  17380. },
  17381. setZIndex: function(zIndex) {
  17382. this.zIndex = zIndex;
  17383. if (this.el) {
  17384. this.el.setStyle("z-index", zIndex);
  17385. }
  17386. },
  17387. show: function() {
  17388. var me = this,
  17389. target = me.target,
  17390. zIndex = me.zIndex,
  17391. el = me.el,
  17392. insertionTarget = me.getInsertionTarget().dom,
  17393. dom;
  17394. if (!el) {
  17395. el = me.el = me.getPool().checkOut();
  17396. }
  17397. me.beforeShow();
  17398. if (zIndex == null) {
  17399. zIndex = (parseInt(target.getStyle("z-index"), 10));
  17400. }
  17401. if (zIndex) {
  17402. el.setStyle("z-index", zIndex);
  17403. }
  17404. el.setStyle('position', me.fixed ? 'fixed' : '');
  17405. dom = el.dom;
  17406. if (dom.nextSibling !== insertionTarget) {
  17407. target.dom.parentNode.insertBefore(dom, insertionTarget);
  17408. }
  17409. el.show();
  17410. me.realign();
  17411. me.hidden = false;
  17412. }
  17413. });
  17414. Ext.define('Ext.dom.Shadow', {
  17415. extend: Ext.dom.Underlay,
  17416. alternateClassName: 'Ext.Shadow',
  17417. mode: 'drop',
  17418. offset: 4,
  17419. cls: Ext.baseCSSPrefix + (!Ext.supports.CSS3BoxShadow ? 'ie' : 'css') + '-shadow',
  17420. constructor: function(config) {
  17421. var me = this,
  17422. outerOffsets, offsets, offset, rad;
  17423. me.callParent([
  17424. config
  17425. ]);
  17426. me.elementConfig = {
  17427. cls: me.cls,
  17428. role: 'presentation'
  17429. };
  17430. offset = me.offset;
  17431. rad = Math.floor(offset / 2);
  17432. me.opacity = 50;
  17433. switch (me.mode.toLowerCase()) {
  17434. case "drop":
  17435. outerOffsets = {
  17436. x: 0,
  17437. y: 0,
  17438. w: offset,
  17439. h: offset
  17440. };
  17441. if (Ext.supports.CSS3BoxShadow) {
  17442. offsets = {
  17443. x: offset,
  17444. y: offset,
  17445. h: -offset,
  17446. w: -offset
  17447. };
  17448. } else {
  17449. offsets = {
  17450. x: -rad,
  17451. y: -rad,
  17452. h: -rad,
  17453. w: -rad
  17454. };
  17455. };
  17456. break;
  17457. case "sides":
  17458. outerOffsets = {
  17459. x: -offset,
  17460. y: 0,
  17461. w: offset * 2,
  17462. h: offset
  17463. };
  17464. if (Ext.supports.CSS3BoxShadow) {
  17465. offsets = {
  17466. x: 0,
  17467. y: offset,
  17468. h: -offset,
  17469. w: 0
  17470. };
  17471. } else {
  17472. offsets = {
  17473. x: 1 + rad - 2 * offset,
  17474. y: -(1 + rad),
  17475. h: -1,
  17476. w: rad - 1
  17477. };
  17478. };
  17479. break;
  17480. case "frame":
  17481. outerOffsets = {
  17482. x: -offset,
  17483. y: -offset,
  17484. w: offset * 2,
  17485. h: offset * 2
  17486. };
  17487. if (Ext.supports.CSS3BoxShadow) {
  17488. offsets = {
  17489. x: 0,
  17490. y: 0,
  17491. h: 0,
  17492. w: 0
  17493. };
  17494. } else {
  17495. offsets = {
  17496. x: 1 + rad - 2 * offset,
  17497. y: 1 + rad - 2 * offset,
  17498. h: offset - rad - 1,
  17499. w: offset - rad - 1
  17500. };
  17501. };
  17502. break;
  17503. case "bottom":
  17504. outerOffsets = {
  17505. x: -offset,
  17506. y: 0,
  17507. w: offset * 2,
  17508. h: offset
  17509. };
  17510. if (Ext.supports.CSS3BoxShadow) {
  17511. offsets = {
  17512. x: 0,
  17513. y: offset,
  17514. h: -offset,
  17515. w: 0
  17516. };
  17517. } else {
  17518. offsets = {
  17519. x: 0,
  17520. y: offset,
  17521. h: 0,
  17522. w: 0
  17523. };
  17524. };
  17525. break;
  17526. }
  17527. me.offsets = offsets;
  17528. me.outerOffsets = outerOffsets;
  17529. },
  17530. getShadowSize: function() {
  17531. var me = this,
  17532. offset = me.el ? me.offset : 0,
  17533. result = [
  17534. offset,
  17535. offset,
  17536. offset,
  17537. offset
  17538. ],
  17539. mode = me.mode.toLowerCase();
  17540. if (me.el && mode !== 'frame') {
  17541. result[0] = 0;
  17542. if (mode === 'drop') {
  17543. result[3] = 0;
  17544. }
  17545. }
  17546. return result;
  17547. },
  17548. boxShadowProperty: (function() {
  17549. var property = 'boxShadow',
  17550. style = document.documentElement.style;
  17551. if (!('boxShadow' in style)) {
  17552. if ('WebkitBoxShadow' in style) {
  17553. property = 'WebkitBoxShadow';
  17554. } else if ('MozBoxShadow' in style) {
  17555. property = 'MozBoxShadow';
  17556. }
  17557. }
  17558. return property;
  17559. }()),
  17560. beforeShow: function() {
  17561. var me = this,
  17562. style = me.el.dom.style,
  17563. shim = me.shim;
  17564. if (Ext.supports.CSS3BoxShadow) {
  17565. style[me.boxShadowProperty] = '0 0 ' + (me.offset + 2) + 'px #888';
  17566. } else {
  17567. style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=" + me.opacity + ") progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (me.offset) + ")";
  17568. }
  17569. if (shim) {
  17570. shim.realign();
  17571. }
  17572. },
  17573. setOpacity: function(opacity) {
  17574. var el = this.el;
  17575. if (el) {
  17576. if (Ext.isIE && !Ext.supports.CSS3BoxShadow) {
  17577. opacity = Math.floor(opacity * 100 / 2) / 100;
  17578. }
  17579. this.opacity = opacity;
  17580. el.setOpacity(opacity);
  17581. }
  17582. }
  17583. });
  17584. Ext.define('Ext.dom.Shim', {
  17585. extend: Ext.dom.Underlay,
  17586. cls: Ext.baseCSSPrefix + 'shim',
  17587. constructor: function(config) {
  17588. this.callParent([
  17589. config
  17590. ]);
  17591. this.elementConfig = {
  17592. tag: 'iframe',
  17593. cls: this.cls,
  17594. role: 'presentation',
  17595. frameBorder: '0',
  17596. src: Ext.SSL_SECURE_URL,
  17597. tabindex: '-1'
  17598. };
  17599. },
  17600. getInsertionTarget: function() {
  17601. var shadow = this.shadow;
  17602. return (shadow && shadow.el) || this.target;
  17603. }
  17604. });
  17605. Ext.define('Ext.dom.ElementEvent', {
  17606. extend: Ext.util.Event,
  17607. addListener: function(fn, scope, options, caller, manager) {
  17608. var me = this,
  17609. added = false,
  17610. name = me.name,
  17611. isDirectEvent = Ext.event.publisher.Dom.instance.directEvents[name],
  17612. captures, directs, directCaptures;
  17613. options = options || {};
  17614. if (options.delegated === false || isDirectEvent) {
  17615. if (isDirectEvent && options.delegate) {
  17616. options.capture = true;
  17617. }
  17618. if (options.capture) {
  17619. directCaptures = me.directCaptures || (me.directCaptures = new Ext.util.Event(me.observable, name));
  17620. added = directCaptures.addListener(fn, scope, options, caller, manager);
  17621. } else {
  17622. directs = me.directs || (me.directs = new Ext.util.Event(me.observable, name));
  17623. added = directs.addListener(fn, scope, options, caller, manager);
  17624. }
  17625. } else if (options.capture) {
  17626. captures = me.captures || (me.captures = new Ext.util.Event(me.observable, name));
  17627. added = captures.addListener(fn, scope, options, caller, manager);
  17628. } else {
  17629. added = me.callParent([
  17630. fn,
  17631. scope,
  17632. options,
  17633. caller,
  17634. manager
  17635. ]);
  17636. }
  17637. return added;
  17638. },
  17639. removeListener: function(fn, scope) {
  17640. var me = this,
  17641. captures = me.captures,
  17642. directs = me.directs,
  17643. directCaptures = me.directCaptures,
  17644. removed = false,
  17645. index = me.findListener(fn, scope);
  17646. if (index !== -1) {
  17647. removed = me.callParent([
  17648. fn,
  17649. scope,
  17650. index
  17651. ]);
  17652. } else {
  17653. if (directs) {
  17654. index = directs.findListener(fn, scope);
  17655. }
  17656. if (index !== -1) {
  17657. removed = directs.removeListener(fn, scope, index);
  17658. } else {
  17659. if (captures) {
  17660. index = captures.findListener(fn, scope);
  17661. }
  17662. if (index !== -1) {
  17663. removed = captures.removeListener(fn, scope, index);
  17664. } else if (directCaptures) {
  17665. index = directCaptures.findListener(fn, scope);
  17666. if (index !== -1) {
  17667. removed = directCaptures.removeListener(fn, scope, index);
  17668. }
  17669. }
  17670. }
  17671. }
  17672. return removed;
  17673. },
  17674. clearListeners: function() {
  17675. var me = this,
  17676. directCaptures = me.directCaptures,
  17677. directs = me.directs,
  17678. captures = me.captures;
  17679. if (directCaptures) {
  17680. directCaptures.clearListeners();
  17681. }
  17682. if (directs) {
  17683. directs.clearListeners();
  17684. }
  17685. if (captures) {
  17686. captures.clearListeners();
  17687. }
  17688. me.callParent();
  17689. },
  17690. suspend: function() {
  17691. var me = this,
  17692. directCaptures = me.directCaptures,
  17693. directs = me.directs,
  17694. captures = me.captures;
  17695. if (directCaptures) {
  17696. directCaptures.suspend();
  17697. }
  17698. if (directs) {
  17699. directs.suspend();
  17700. }
  17701. if (captures) {
  17702. captures.suspend();
  17703. }
  17704. me.callParent();
  17705. },
  17706. resume: function() {
  17707. var me = this,
  17708. directCaptures = me.directCaptures,
  17709. directs = me.directs,
  17710. captures = me.captures;
  17711. if (directCaptures) {
  17712. directCaptures.resume();
  17713. }
  17714. if (directs) {
  17715. directs.resume();
  17716. }
  17717. if (captures) {
  17718. captures.resume();
  17719. }
  17720. me.callParent();
  17721. }
  17722. });
  17723. Ext.define('Ext.event.publisher.Publisher', {
  17724. isEventPublisher: true,
  17725. $vetoClearingPrototypeOnDestroy: true,
  17726. handledEvents: [],
  17727. statics: {
  17728. publishers: {},
  17729. publishersByEvent: {}
  17730. },
  17731. constructor: function() {
  17732. var me = this,
  17733. type = me.type;
  17734. me.handles = {};
  17735. if (!type) {
  17736. Ext.raise("Event publisher '" + me.$className + "' defined without a 'type' property.");
  17737. }
  17738. if (me.self.instance) {
  17739. Ext.raise("Cannot create multiple instances of '" + me.$className + "'. " + "Use '" + me.$className + ".instance' to retrieve the singleton instance.");
  17740. }
  17741. me.registerEvents();
  17742. Ext.event.publisher.Publisher.publishers[type] = me;
  17743. },
  17744. registerEvents: function(events) {
  17745. var me = this,
  17746. publishersByEvent = Ext.event.publisher.Publisher.publishersByEvent,
  17747. handledEvents = events || me.handledEvents,
  17748. ln = handledEvents.length,
  17749. eventName, i;
  17750. for (i = 0; i < ln; i++) {
  17751. eventName = handledEvents[i];
  17752. me.handles[eventName] = 1;
  17753. publishersByEvent[eventName] = me;
  17754. }
  17755. },
  17756. subscribe: function() {
  17757. Ext.raise("Ext.event.publisher.Publisher subclass '" + this.$className + '" has no subscribe method.');
  17758. },
  17759. unsubscribe: function() {
  17760. Ext.raise("Ext.event.publisher.Publisher subclass '" + this.$className + '" has no unsubscribe method.');
  17761. },
  17762. fire: function(element, eventName, args) {
  17763. var event;
  17764. if (element.hasListeners[eventName]) {
  17765. event = element.events[eventName];
  17766. if (event) {
  17767. event.fire.apply(event, args);
  17768. }
  17769. }
  17770. }
  17771. });
  17772. Ext.define('Ext.util.Offset', {
  17773. statics: {
  17774. fromObject: function(obj) {
  17775. if (obj instanceof this) {
  17776. return obj;
  17777. }
  17778. if (typeof obj === 'number') {
  17779. return new this(obj, obj);
  17780. }
  17781. if (obj.length) {
  17782. return new this(obj[0], obj[1]);
  17783. }
  17784. return new this(obj.x, obj.y);
  17785. }
  17786. },
  17787. constructor: function(x, y) {
  17788. this.x = (x != null && !isNaN(x)) ? x : 0;
  17789. this.y = (y != null && !isNaN(y)) ? y : 0;
  17790. return this;
  17791. },
  17792. copy: function() {
  17793. return new Ext.util.Offset(this.x, this.y);
  17794. },
  17795. copyFrom: function(p) {
  17796. this.x = p.x;
  17797. this.y = p.y;
  17798. },
  17799. toString: function() {
  17800. return "Offset[" + this.x + "," + this.y + "]";
  17801. },
  17802. equals: function(offset) {
  17803. if (!(offset instanceof this.statics())) {
  17804. Ext.raise('Offset must be an instance of Ext.util.Offset');
  17805. }
  17806. return (this.x === offset.x && this.y === offset.y);
  17807. },
  17808. add: function(offset) {
  17809. if (!(offset instanceof this.statics())) {
  17810. Ext.raise('Offset must be an instance of Ext.util.Offset');
  17811. }
  17812. this.x += offset.x;
  17813. this.y += offset.y;
  17814. },
  17815. round: function(to) {
  17816. var factor;
  17817. if (!isNaN(to)) {
  17818. factor = Math.pow(10, to);
  17819. this.x = Math.round(this.x * factor) / factor;
  17820. this.y = Math.round(this.y * factor) / factor;
  17821. } else {
  17822. this.x = Math.round(this.x);
  17823. this.y = Math.round(this.y);
  17824. }
  17825. },
  17826. isZero: function() {
  17827. return this.x === 0 && this.y === 0;
  17828. }
  17829. });
  17830. Ext.define('Ext.util.Region', function() {
  17831. var ExtUtil = Ext.util,
  17832. constrainRe = /([^\?!]*)(!|\?)?$/,
  17833. alignRe = /^(?:(?:([trbl])(\d+))|(tl|t|tc|tr|l|c|r|bl|b|bc|br))(?:-(?:(?:([trbl])(\d+))|(tl|t|tc|tr|l|c|r|bl|b|bc|br)))?$/i,
  17834. LTROffsetFactors = {
  17835. l: 0,
  17836. r: 100,
  17837. t: 0,
  17838. b: 100,
  17839. c: 50
  17840. },
  17841. RTLOffsetFactors = {
  17842. l: 100,
  17843. r: 0,
  17844. t: 0,
  17845. b: 100,
  17846. c: 50
  17847. },
  17848. relativePositions = {
  17849. b: 0,
  17850. l: 1,
  17851. t: 2,
  17852. r: 3
  17853. },
  17854. alignMap = {
  17855. "tl-tr": "l0-r0",
  17856. "tl-r": "l0-r50",
  17857. "bl-r": "l100-r50",
  17858. "bl-br": "l100-r100",
  17859. "tr-tl": "r0-l0",
  17860. "tr-l": "r0-l50",
  17861. "br-l": "r100-l50",
  17862. "br-bl": "r100-l100"
  17863. },
  17864. rtlAlignMap = {
  17865. "tl-tr": "r0-l0",
  17866. "tl-r": "r0-l50",
  17867. "bl-r": "r100-l50",
  17868. "bl-br": "r100-l100",
  17869. "tr-tl": "l0-r0",
  17870. "tr-l": "l0-r50",
  17871. "br-l": "l100-r50",
  17872. "br-bl": "l100-r100"
  17873. },
  17874. adjustParams = [],
  17875. zeroOffset = new ExtUtil.Offset(0, 0),
  17876. parseRegion = function(box) {
  17877. var Region = ExtUtil.Region,
  17878. type = typeof box,
  17879. top, right, bottom, left;
  17880. if (box == null) {
  17881. return Region.EMPTY;
  17882. }
  17883. if (box.isRegion) {
  17884. return box;
  17885. }
  17886. if (box.isElement || box.nodeType === 1) {
  17887. return this.getRegion(box);
  17888. }
  17889. if (type === 'string') {
  17890. box = box.split(' ');
  17891. switch (box.length) {
  17892. case 1:
  17893. box[1] = box[2] = box[3] = box[0];
  17894. break;
  17895. case 2:
  17896. box[2] = box[0];
  17897. box[3] = box[1];
  17898. break;
  17899. case 3:
  17900. box[3] = box[1];
  17901. }
  17902. top = parseInt(box[0], 10) || 0;
  17903. right = parseInt(box[1], 10) || 0;
  17904. bottom = parseInt(box[2], 10) || 0;
  17905. left = parseInt(box[3], 10) || 0;
  17906. } else if (type === 'number') {
  17907. top = right = bottom = left = box;
  17908. } else if (typeof box.x === 'number') {
  17909. top = box.y;
  17910. left = box.x;
  17911. if (typeof box.right === 'number') {
  17912. right = box.right;
  17913. bottom = box.bottom;
  17914. } else {
  17915. right = left + box.width;
  17916. bottom = top + box.height;
  17917. }
  17918. } else
  17919. {
  17920. Ext.raise('Not convertible to a Region: ' + box);
  17921. }
  17922. return new Region(top, right, bottom, left);
  17923. },
  17924. magnitude = [
  17925. -1,
  17926. 1,
  17927. 1,
  17928. -1
  17929. ],
  17930. addAnchorOffset = function(target, anchorSize, relativePosition) {
  17931. if (relativePosition != null && anchorSize) {
  17932. adjustParams[0] = adjustParams[1] = adjustParams[2] = adjustParams[3] = 0;
  17933. adjustParams[relativePosition] = anchorSize.y * magnitude[relativePosition];
  17934. target = ExtUtil.Region.from(target);
  17935. target.adjust.apply(target, adjustParams);
  17936. }
  17937. return target;
  17938. },
  17939. calculateAnchorPosition = function(target, result, relativePosition, anchorSize, inside) {
  17940. var anchorWidth = Math.ceil(anchorSize.x),
  17941. minOverlap = Math.ceil(anchorWidth / 2) + 3,
  17942. min, max, anchorPos, isBefore, overlapLine, x, y;
  17943. if (inside && !inside.intersect(target)) {
  17944. return;
  17945. }
  17946. if (relativePosition != null) {
  17947. if (relativePosition & 1) {
  17948. if (result.getHeight() < anchorWidth + 4) {
  17949. return;
  17950. }
  17951. min = target.top + minOverlap - result.height;
  17952. max = target.bottom - minOverlap - 1;
  17953. result.setPosition(result.x, Math.min(Math.max(result.y, min), max));
  17954. min = result.top + 2;
  17955. max = result.bottom - (anchorWidth + 2);
  17956. isBefore = relativePosition === 3;
  17957. x = isBefore ? result.right : result.left;
  17958. overlapLine = new ExtUtil.Region(Math.max(result.top, target.top), x, Math.min(result.bottom, target.bottom), x);
  17959. anchorPos = new ExtUtil.Region(0, 0, 0, 0).setWidth(anchorSize.y).setHeight(anchorWidth).alignTo({
  17960. target: overlapLine,
  17961. align: isBefore ? 'l-r' : 'r-l',
  17962. overlap: true
  17963. });
  17964. anchorPos.setPosition(anchorPos.x, Math.min(Math.max(anchorPos.y, min), max));
  17965. anchorPos.position = isBefore ? 'right' : 'left';
  17966. } else
  17967. {
  17968. if (result.getWidth() < anchorWidth + 4) {
  17969. return;
  17970. }
  17971. min = target.left + minOverlap - result.width;
  17972. max = target.right - minOverlap - 1;
  17973. result.setPosition(Math.min(Math.max(result.x, min), max), result.y);
  17974. min = result.left + 2;
  17975. max = result.right - (anchorWidth + 2);
  17976. isBefore = relativePosition === 0;
  17977. y = isBefore ? result.bottom : result.top;
  17978. overlapLine = new ExtUtil.Region(y, Math.min(result.right, target.right), y, Math.max(result.left, target.left));
  17979. anchorPos = new ExtUtil.Region(0, 0, 0, 0).setWidth(anchorWidth).setHeight(anchorSize.y).alignTo({
  17980. target: overlapLine,
  17981. align: isBefore ? 't-b' : 'b-t',
  17982. overlap: true
  17983. });
  17984. anchorPos.setPosition(Math.min(Math.max(anchorPos.x, min), max), anchorPos.y);
  17985. anchorPos.position = isBefore ? 'bottom' : 'top';
  17986. }
  17987. if (inside && !inside.contains(anchorPos)) {
  17988. return;
  17989. }
  17990. result.anchor = anchorPos;
  17991. result.anchor.align = relativePosition;
  17992. }
  17993. },
  17994. checkMinHeight = function(minHeight, result, target, inside) {
  17995. var newHeight;
  17996. if (minHeight && inside) {
  17997. if (result.top >= target.bottom && result.bottom > inside.bottom) {
  17998. result.setHeight(Math.max(result.getHeight() + inside.bottom - result.bottom, minHeight));
  17999. result.constrainHeight = true;
  18000. }
  18001. else if (result.bottom <= target.top && result.top < inside.top) {
  18002. newHeight = Math.max(result.getHeight() + result.top - inside.top, minHeight);
  18003. result.adjust(result.getHeight() - newHeight);
  18004. result.constrainHeight = true;
  18005. }
  18006. else if (result.getHeight() > inside.getHeight()) {
  18007. result.setHeight(Math.max(minHeight, inside.getHeight()));
  18008. result.setPosition(result.x, 0);
  18009. result.constrainHeight = true;
  18010. }
  18011. }
  18012. },
  18013. checkMinWidth = function(minWidth, result, target, inside) {
  18014. var newWidth;
  18015. if (minWidth && inside) {
  18016. if (result.left >= target.right && result.right > inside.right) {
  18017. result.setWidth(Math.max(result.getWidth() + inside.right - result.right, minWidth));
  18018. result.constrainWidth = true;
  18019. }
  18020. else if (result.right <= target.left && result.left < inside.left) {
  18021. newWidth = Math.max(result.getWidth() + result.left - inside.left, minWidth);
  18022. result.adjust(0, 0, 0, result.getWidth() - newWidth);
  18023. result.constrainWidth = true;
  18024. }
  18025. else if (result.getWidth() > inside.getWidth()) {
  18026. result.setWidth(Math.max(minWidth, inside.getWidth()));
  18027. result.setPosition(0, result.y);
  18028. result.constrainWidth = true;
  18029. }
  18030. }
  18031. };
  18032. return {
  18033. isRegion: true,
  18034. statics: {
  18035. getRegion: function(el) {
  18036. return Ext.fly(el).getRegion();
  18037. },
  18038. from: function(o) {
  18039. return new this(o.top, o.right, o.bottom, o.left);
  18040. },
  18041. getAlignInfo: function(align, rtl) {
  18042. if (typeof align === 'object') {
  18043. return align;
  18044. }
  18045. align = align ? ((align.indexOf('-') < 0) ? 'tl-' + align : align) : 'tl-bl';
  18046. constrain = constrainRe.exec(align);
  18047. align = constrain[1];
  18048. align = (rtl ? rtlAlignMap : alignMap)[align] || align;
  18049. var offsetFactors = rtl ? RTLOffsetFactors : LTROffsetFactors,
  18050. constrain,
  18051. parts = alignRe.exec(align),
  18052. result;
  18053. if (!parts) {
  18054. Ext.raise({
  18055. sourceClass: 'Ext.util.Region',
  18056. sourceMethod: 'getAlignInfo',
  18057. position: align,
  18058. msg: 'Attempted to align an element with an invalid position: "' + align + '"'
  18059. });
  18060. }
  18061. result = {
  18062. myEdge: parts[1],
  18063. myOffset: parts[2],
  18064. otherEdge: parts[4],
  18065. otherOffset: parts[5],
  18066. constrain: constrain[2]
  18067. };
  18068. if (parts[3]) {
  18069. result.myEdge = parts[3][0];
  18070. result.myOffset = offsetFactors[parts[3][1]];
  18071. if (result.myOffset == null) {
  18072. result.myOffset = 50;
  18073. }
  18074. }
  18075. if (parts[6]) {
  18076. result.otherEdge = parts[6][0];
  18077. result.otherOffset = offsetFactors[parts[6][1]];
  18078. if (result.otherOffset == null) {
  18079. result.otherOffset = 50;
  18080. }
  18081. }
  18082. result.position = relativePositions[result.myEdge];
  18083. return result;
  18084. }
  18085. },
  18086. constructor: function(top, right, bottom, left) {
  18087. var me = this;
  18088. me.y = me.top = me[1] = top;
  18089. me.right = right;
  18090. me.bottom = bottom;
  18091. me.x = me.left = me[0] = left;
  18092. me.height = me.bottom - me.top;
  18093. me.width = me.right - me.left;
  18094. },
  18095. setPosition: function(x, y) {
  18096. if (arguments.length === 1) {
  18097. y = x[1];
  18098. x = x[0];
  18099. }
  18100. return this.translateBy(x - this.x, y - this.y);
  18101. },
  18102. contains: function(region) {
  18103. var me = this;
  18104. return (region.x >= me.x && (region.right || region.x) <= me.right && region.y >= me.y && (region.bottom || region.y) <= me.bottom);
  18105. },
  18106. intersect: function(region) {
  18107. var me = this,
  18108. t = Math.max(me.y, region.y),
  18109. r = Math.min(me.right, region.right),
  18110. b = Math.min(me.bottom, region.bottom),
  18111. l = Math.max(me.x, region.x);
  18112. if (b > t && r > l) {
  18113. return new this.self(t, r, b, l);
  18114. } else {
  18115. return false;
  18116. }
  18117. },
  18118. union: function(region) {
  18119. var me = this,
  18120. t = Math.min(me.y, region.y),
  18121. r = Math.max(me.right, region.right),
  18122. b = Math.max(me.bottom, region.bottom),
  18123. l = Math.min(me.x, region.x);
  18124. return new this.self(t, r, b, l);
  18125. },
  18126. constrainTo: function(targetRegion) {
  18127. var me = this,
  18128. constrain = Ext.Number.constrain;
  18129. me.top = me.y = constrain(me.top, targetRegion.y, targetRegion.bottom);
  18130. me.bottom = constrain(me.bottom, targetRegion.y, targetRegion.bottom);
  18131. me.left = me.x = constrain(me.left, targetRegion.x, targetRegion.right);
  18132. me.right = constrain(me.right, targetRegion.x, targetRegion.right);
  18133. me.height = me.bottom - me.top;
  18134. me.width = me.right - me.left;
  18135. return me;
  18136. },
  18137. adjust: function(top, right, bottom, left) {
  18138. var me = this;
  18139. me.top = me.y += top || 0;
  18140. me.left = me.x += left || 0;
  18141. me.right += right || 0;
  18142. me.bottom += bottom || 0;
  18143. me.height = me.bottom - me.top;
  18144. me.width = me.right - me.left;
  18145. return me;
  18146. },
  18147. getOutOfBoundOffset: function(axis, p) {
  18148. var d;
  18149. if (!Ext.isObject(axis)) {
  18150. if (axis === 'x') {
  18151. return this.getOutOfBoundOffsetX(p);
  18152. } else {
  18153. return this.getOutOfBoundOffsetY(p);
  18154. }
  18155. } else {
  18156. p = axis;
  18157. d = new ExtUtil.Offset();
  18158. d.x = this.getOutOfBoundOffsetX(p.x);
  18159. d.y = this.getOutOfBoundOffsetY(p.y);
  18160. return d;
  18161. }
  18162. },
  18163. getOutOfBoundOffsetX: function(p) {
  18164. if (p <= this.x) {
  18165. return this.x - p;
  18166. } else if (p >= this.right) {
  18167. return this.right - p;
  18168. }
  18169. return 0;
  18170. },
  18171. getOutOfBoundOffsetY: function(p) {
  18172. if (p <= this.y) {
  18173. return this.y - p;
  18174. } else if (p >= this.bottom) {
  18175. return this.bottom - p;
  18176. }
  18177. return 0;
  18178. },
  18179. isOutOfBound: function(axis, p) {
  18180. if (!Ext.isObject(axis)) {
  18181. if (axis === 'x') {
  18182. return this.isOutOfBoundX(p);
  18183. } else {
  18184. return this.isOutOfBoundY(p);
  18185. }
  18186. } else {
  18187. p = axis;
  18188. return (this.isOutOfBoundX(p.x) || this.isOutOfBoundY(p.y));
  18189. }
  18190. },
  18191. isOutOfBoundX: function(p) {
  18192. return (p < this.x || p > this.right);
  18193. },
  18194. isOutOfBoundY: function(p) {
  18195. return (p < this.y || p > this.bottom);
  18196. },
  18197. restrict: function(axis, p, factor) {
  18198. var newP;
  18199. if (Ext.isObject(axis)) {
  18200. factor = p;
  18201. p = axis;
  18202. if (p.copy) {
  18203. newP = p.copy();
  18204. } else {
  18205. newP = {
  18206. x: p.x,
  18207. y: p.y
  18208. };
  18209. }
  18210. newP.x = this.restrictX(p.x, factor);
  18211. newP.y = this.restrictY(p.y, factor);
  18212. return newP;
  18213. } else {
  18214. if (axis === 'x') {
  18215. return this.restrictX(p, factor);
  18216. } else {
  18217. return this.restrictY(p, factor);
  18218. }
  18219. }
  18220. },
  18221. restrictX: function(p, factor) {
  18222. if (!factor) {
  18223. factor = 1;
  18224. }
  18225. if (p <= this.x) {
  18226. p -= (p - this.x) * factor;
  18227. } else if (p >= this.right) {
  18228. p -= (p - this.right) * factor;
  18229. }
  18230. return p;
  18231. },
  18232. restrictY: function(p, factor) {
  18233. if (!factor) {
  18234. factor = 1;
  18235. }
  18236. if (p <= this.y) {
  18237. p -= (p - this.y) * factor;
  18238. } else if (p >= this.bottom) {
  18239. p -= (p - this.bottom) * factor;
  18240. }
  18241. return p;
  18242. },
  18243. alignTo: function(options) {
  18244. var me = this,
  18245. Region = me.self,
  18246. Offset = ExtUtil.Offset,
  18247. Element = Ext.Element,
  18248. target = parseRegion(options.target),
  18249. targetPlusAnchorOffset,
  18250. rtl = options.rtl,
  18251. overlap = options.overlap,
  18252. align = options.align,
  18253. anchorSize = options.anchorSize,
  18254. offset = options.offset,
  18255. inside = options.inside,
  18256. position = options.position,
  18257. allowXTranslate = options.allowXTranslate,
  18258. allowYTranslate = options.allowYTranslate,
  18259. wasConstrained, result, initialPosition, constrainedPosition;
  18260. if (offset) {
  18261. offset = Offset.fromObject(offset);
  18262. if (!(offset instanceof Offset)) {
  18263. Ext.raise('offset option must be an Ext.util.Offset');
  18264. }
  18265. }
  18266. if (anchorSize) {
  18267. anchorSize = Offset.fromObject(anchorSize);
  18268. if (!(anchorSize instanceof Offset)) {
  18269. Ext.raise('anchorSize option must be an Ext.util.Offset');
  18270. }
  18271. }
  18272. if (inside && !inside.isRegion) {
  18273. if (Ext.getDom(inside) === document.body) {
  18274. inside = new Region(0, Element.getDocumentWidth(), Element.getDocumentHeight(), 0);
  18275. } else {
  18276. inside = Ext.fly(inside).getRegion();
  18277. }
  18278. }
  18279. if (position) {
  18280. if (position.length === 2) {
  18281. position = new ExtUtil.Point(position[0], position[1]);
  18282. }
  18283. result = new Region().copyFrom(me).setPosition(position.x, position.y);
  18284. } else {
  18285. align = me.getAlignInfo(align, rtl);
  18286. if (inside) {
  18287. if (target.x >= inside.right) {
  18288. target.setPosition(inside.right - 1, target.y);
  18289. if (align.position !== 3) {
  18290. align = me.getAlignInfo('r-l', rtl);
  18291. }
  18292. } else if (target.right < inside.x) {
  18293. target.setPosition(inside.x - target.getWidth() + 1, target.y);
  18294. if (align.position !== 1) {
  18295. align = me.getAlignInfo('l-r', rtl);
  18296. }
  18297. }
  18298. if (target.y >= inside.bottom) {
  18299. target.setPosition(target.x, inside.bottom - 1);
  18300. if (align.position !== 0) {
  18301. align = me.getAlignInfo('b-t', rtl);
  18302. }
  18303. } else if (target.bottom < inside.y) {
  18304. target.setPosition(target.x, inside.y - target.getHeight() + 1);
  18305. if (align.position !== 2) {
  18306. align = me.getAlignInfo('t-b', rtl);
  18307. }
  18308. }
  18309. }
  18310. targetPlusAnchorOffset = anchorSize ? addAnchorOffset(target, anchorSize, align.position) : target;
  18311. result = Region.from(me).translateBy(me.getAlignToVector(targetPlusAnchorOffset, align));
  18312. overlap = !!result.intersect(targetPlusAnchorOffset);
  18313. if (offset && (overlap || !anchorSize)) {
  18314. result.translateBy(offset);
  18315. }
  18316. if (anchorSize) {
  18317. calculateAnchorPosition(target, result, align.position, anchorSize, inside);
  18318. }
  18319. }
  18320. if (inside) {
  18321. initialPosition = result.copy();
  18322. if (result.left < inside.left) {
  18323. result.translateBy(inside.left - result.left, 0);
  18324. wasConstrained = true;
  18325. }
  18326. if (result.right > inside.right && result.left > inside.left) {
  18327. result.translateBy(inside.right - result.right, 0);
  18328. wasConstrained = true;
  18329. }
  18330. if (result.top < inside.top) {
  18331. result.translateBy(0, inside.top - result.top);
  18332. wasConstrained = true;
  18333. }
  18334. if (result.bottom > inside.bottom && result.top > inside.top) {
  18335. result.translateBy(0, inside.bottom - result.bottom);
  18336. wasConstrained = true;
  18337. }
  18338. if (wasConstrained && !overlap) {
  18339. result.anchor = null;
  18340. if (options.axisLock) {
  18341. if (align.position & 1) {
  18342. allowYTranslate = false;
  18343. } else {
  18344. allowXTranslate = false;
  18345. }
  18346. }
  18347. if (position) {
  18348. if (result.contains(position)) {
  18349. position.exclude(result, {
  18350. inside: inside,
  18351. centerOnSideChange: false
  18352. });
  18353. }
  18354. } else
  18355. {
  18356. constrainedPosition = result.copy();
  18357. if (result.intersect(targetPlusAnchorOffset)) {
  18358. align.position = target.exclude(result, {
  18359. initialPosition: initialPosition,
  18360. defaultPosition: align.position,
  18361. inside: inside,
  18362. minHeight: options.minHeight,
  18363. minWidth: options.minWidth,
  18364. allowX: allowXTranslate,
  18365. allowY: allowYTranslate,
  18366. offset: offset,
  18367. anchorHeight: anchorSize ? anchorSize.y : 0,
  18368. centerOnSideChange: !!anchorSize
  18369. });
  18370. } else if (options.minWidth && result.getWidth() > inside.getWidth()) {
  18371. result.setPosition(0, result.y);
  18372. result.setWidth(Math.max(inside.getWidth(), options.minWidth));
  18373. result.constrainWidth = true;
  18374. } else if (options.minHeight && result.getHeight() > inside.getHeight()) {
  18375. result.setPosition(result.x, 0);
  18376. result.setHeight(Math.max(inside.getHeight(), options.minHeight));
  18377. result.constrainHeight = true;
  18378. }
  18379. result.align = align;
  18380. if (inside.contains(result)) {
  18381. if (anchorSize) {
  18382. calculateAnchorPosition(target, result, align.position, anchorSize, inside);
  18383. }
  18384. } else
  18385. {
  18386. result = constrainedPosition;
  18387. }
  18388. }
  18389. }
  18390. }
  18391. return result;
  18392. },
  18393. exclude: function(other, options) {
  18394. options = options || {};
  18395. var me = this,
  18396. initialPosition = options.initialPosition || other,
  18397. inside = options.inside,
  18398. defaultPosition = options.defaultPosition,
  18399. centerOnSideChange = options.centerOnSideChange,
  18400. minHeight = options.minHeight,
  18401. minWidth = options.minWidth,
  18402. allowX = options.allowX !== false,
  18403. allowY = options.allowY !== false,
  18404. anchorHeight = options.anchorHeight,
  18405. offset = options.offset,
  18406. translations = [],
  18407. testRegion, t, i, sizeConstrainedSolution, leastBadSolution, intersection, result;
  18408. if (!offset) {
  18409. offset = zeroOffset;
  18410. }
  18411. if (allowY) {
  18412. translations.push([
  18413. 0,
  18414. me.top - other.bottom - anchorHeight + offset.y,
  18415. 'b-t',
  18416. 0,
  18417. Math.abs(me.top - initialPosition.bottom - anchorHeight + offset.y)
  18418. ]);
  18419. translations.push([
  18420. 0,
  18421. me.bottom - other.top + anchorHeight + offset.y,
  18422. 't-b',
  18423. 2,
  18424. Math.abs(me.bottom - initialPosition.top + anchorHeight + offset.y)
  18425. ]);
  18426. } else {
  18427. centerOnSideChange = false;
  18428. }
  18429. if (allowX) {
  18430. translations.push([
  18431. me.left - other.right - anchorHeight + offset.x,
  18432. 0,
  18433. 'r-l',
  18434. 3,
  18435. Math.abs(me.left - initialPosition.right - anchorHeight + offset.x)
  18436. ]);
  18437. translations.push([
  18438. me.right - other.left + anchorHeight + offset.x,
  18439. 0,
  18440. 'l-r',
  18441. 1,
  18442. Math.abs(me.right - initialPosition.left + anchorHeight + offset.x)
  18443. ]);
  18444. } else {
  18445. centerOnSideChange = false;
  18446. }
  18447. Ext.Array.sort(translations, function(l, r) {
  18448. var result = l[4] - r[4];
  18449. if (!result) {
  18450. if (l[3] === defaultPosition) {
  18451. return -1;
  18452. }
  18453. if (r[3] === defaultPosition) {
  18454. return 1;
  18455. }
  18456. }
  18457. return result;
  18458. });
  18459. if (inside) {
  18460. for (i = 0; i < translations.length; i++) {
  18461. t = translations[i];
  18462. testRegion = ExtUtil.Region.from(other);
  18463. testRegion.translateBy.apply(testRegion, t);
  18464. if (inside.contains(testRegion)) {
  18465. other.copyFrom(testRegion);
  18466. result = {
  18467. align: t[2],
  18468. position: t[3],
  18469. distance: t[4]
  18470. };
  18471. break;
  18472. }
  18473. if (minHeight) {
  18474. checkMinHeight(minHeight, testRegion, me, inside);
  18475. if (inside.contains(testRegion)) {
  18476. if (!sizeConstrainedSolution || testRegion.getArea() > sizeConstrainedSolution.region.getArea()) {
  18477. sizeConstrainedSolution = {
  18478. region: testRegion,
  18479. align: t[2],
  18480. position: t[3],
  18481. distance: t[4]
  18482. };
  18483. }
  18484. }
  18485. }
  18486. if (minWidth) {
  18487. checkMinWidth(minWidth, testRegion, me, inside);
  18488. if (inside.contains(testRegion)) {
  18489. if (!sizeConstrainedSolution || testRegion.getArea() > sizeConstrainedSolution.region.getArea()) {
  18490. sizeConstrainedSolution = {
  18491. region: testRegion,
  18492. align: t[2],
  18493. position: t[3],
  18494. distance: t[4]
  18495. };
  18496. }
  18497. }
  18498. }
  18499. intersection = inside.intersect(testRegion);
  18500. if (intersection) {
  18501. intersection = intersection.getArea();
  18502. if (!leastBadSolution || (intersection && leastBadSolution.area < intersection)) {
  18503. leastBadSolution = {
  18504. region: testRegion,
  18505. align: t[2],
  18506. position: t[3],
  18507. distance: t[4],
  18508. area: intersection
  18509. };
  18510. }
  18511. }
  18512. }
  18513. if (!result) {
  18514. if (sizeConstrainedSolution) {
  18515. other.copyFrom(sizeConstrainedSolution.region);
  18516. result = sizeConstrainedSolution;
  18517. other.constrainWidth = sizeConstrainedSolution.region.constrainWidth;
  18518. other.constrainHeight = sizeConstrainedSolution.region.constrainHeight;
  18519. }
  18520. else if (leastBadSolution) {
  18521. other.copyFrom(leastBadSolution.region);
  18522. result = leastBadSolution;
  18523. }
  18524. }
  18525. if (result) {
  18526. if ((result.position & 1) !== (defaultPosition & 1)) {
  18527. if (result.distance && centerOnSideChange) {
  18528. t = other.alignTo({
  18529. align: result.align,
  18530. target: me,
  18531. anchorSize: anchorHeight,
  18532. offset: offset,
  18533. axisLock: true,
  18534. inside: inside,
  18535. minHeight: options.minHeight,
  18536. minWidth: options.minWidth
  18537. });
  18538. if (inside.contains(t)) {
  18539. other.setPosition(t.x, t.y);
  18540. }
  18541. }
  18542. }
  18543. return result.position;
  18544. }
  18545. } else
  18546. {
  18547. other.translateBy.apply(other, translations[0]);
  18548. return translations[0][3];
  18549. }
  18550. return defaultPosition;
  18551. },
  18552. getAlignToXY: function(target, align, rtl) {
  18553. var alignVector = this.getAlignToVector(target, align, rtl);
  18554. return [
  18555. this.x + alignVector[0],
  18556. this.y + alignVector[1]
  18557. ];
  18558. },
  18559. getAnchorPoint: function(align, rtl) {
  18560. align = (typeof align === 'string') ? this.getAlignInfo(align + '-tl', rtl) : align;
  18561. return this['getAnchorPoint_' + align.myEdge](align.myOffset);
  18562. },
  18563. getAlignToVector: function(target, align, rtl) {
  18564. align = (typeof align === 'string') ? this.getAlignInfo(align, rtl) : align;
  18565. var myAnchorPoint = this['getAnchorPoint_' + align.myEdge](align.myOffset),
  18566. targetAnchorPoint = target['getAnchorPoint_' + align.otherEdge](align.otherOffset);
  18567. return [
  18568. targetAnchorPoint[0] - myAnchorPoint[0],
  18569. targetAnchorPoint[1] - myAnchorPoint[1]
  18570. ];
  18571. },
  18572. getAnchorPoint_t: function(offset) {
  18573. return [
  18574. this.x + Math.round(this.getWidth() * (offset / 100)),
  18575. this.y
  18576. ];
  18577. },
  18578. getAnchorPoint_b: function(offset) {
  18579. return [
  18580. this.x + Math.round(this.getWidth() * (offset / 100)),
  18581. this.bottom
  18582. ];
  18583. },
  18584. getAnchorPoint_l: function(offset) {
  18585. return [
  18586. this.x,
  18587. this.y + Math.round(this.getHeight() * (offset / 100))
  18588. ];
  18589. },
  18590. getAnchorPoint_r: function(offset) {
  18591. return [
  18592. this.right,
  18593. this.y + Math.round(this.getHeight() * (offset / 100))
  18594. ];
  18595. },
  18596. getAnchorPoint_c: function() {
  18597. return [
  18598. this.x + Math.round(this.getWidth() / 2),
  18599. this.y + Math.round(this.getHeight() / 2)
  18600. ];
  18601. },
  18602. getCenter: function() {
  18603. return [
  18604. this.x + this.width / 2,
  18605. this.y + this.height / 2
  18606. ];
  18607. },
  18608. getHeight: function() {
  18609. return this.bottom - this.y;
  18610. },
  18611. getWidth: function() {
  18612. return this.right - this.x;
  18613. },
  18614. getArea: function() {
  18615. return this.getHeight() * this.getWidth();
  18616. },
  18617. setHeight: function(h) {
  18618. this.height = h;
  18619. this.bottom = this.top + h;
  18620. return this;
  18621. },
  18622. setWidth: function(w) {
  18623. this.width = w;
  18624. this.right = this.left + w;
  18625. return this;
  18626. },
  18627. getSize: function() {
  18628. return {
  18629. width: this.right - this.x,
  18630. height: this.bottom - this.y
  18631. };
  18632. },
  18633. setSize: function(w, h) {
  18634. if (h === undefined) {
  18635. h = w;
  18636. }
  18637. this.setWidth(w);
  18638. return this.setHeight(h);
  18639. },
  18640. copy: function() {
  18641. return new this.self(this.y, this.right, this.bottom, this.x);
  18642. },
  18643. copyFrom: function(p) {
  18644. var me = this;
  18645. me.top = me.y = me[1] = p.y;
  18646. me.right = p.right;
  18647. me.bottom = p.bottom;
  18648. me.left = me.x = me[0] = p.x;
  18649. return me;
  18650. },
  18651. toString: function() {
  18652. return "Region[" + this.top + "," + this.right + "," + this.bottom + "," + this.left + "]";
  18653. },
  18654. translateBy: function(x, y) {
  18655. var me = this;
  18656. if (x.length) {
  18657. y = x[1];
  18658. x = x[0];
  18659. } else if (arguments.length === 1) {
  18660. y = x.y;
  18661. x = x.x;
  18662. }
  18663. me.top = me.y += y;
  18664. me.right += x;
  18665. me.bottom += y;
  18666. me.left = me.x += x;
  18667. return me;
  18668. },
  18669. round: function() {
  18670. var me = this;
  18671. me.top = me.y = Math.round(me.y);
  18672. me.right = Math.round(me.right);
  18673. me.bottom = Math.round(me.bottom);
  18674. me.left = me.x = Math.round(me.x);
  18675. return me;
  18676. },
  18677. equals: function(region) {
  18678. return (this.top === region.top && this.right === region.right && this.bottom === region.bottom && this.left === region.left);
  18679. },
  18680. getOffsetsTo: function(offsetsTo) {
  18681. return {
  18682. x: this.x - offsetsTo.x,
  18683. y: this.y - offsetsTo.y
  18684. };
  18685. },
  18686. highlight: function() {
  18687. var highlightEl = Ext.getBody().createChild({
  18688. style: 'background-color:#52a0db;opacity:0.4;position:absolute;z-index:9999999'
  18689. });
  18690. highlightEl.setBox(this);
  18691. Ext.defer(function() {
  18692. highlightEl.destroy();
  18693. }, 5000);
  18694. return highlightEl;
  18695. }
  18696. };
  18697. },
  18698. function(Region) {
  18699. Region.prototype.getAlignInfo = Region.getAlignInfo;
  18700. Region.EMPTY = new Region(0, 0, 0, 0);
  18701. if (Object.freeze) {
  18702. Object.freeze(Region.EMPTY);
  18703. }
  18704. });
  18705. Ext.define('Ext.util.Point', {
  18706. extend: Ext.util.Region,
  18707. isPoint: true,
  18708. radianToDegreeConstant: 180 / Math.PI,
  18709. origin: {
  18710. x: 0,
  18711. y: 0
  18712. },
  18713. statics: {
  18714. fromEvent: function(e) {
  18715. var changedTouches = e.changedTouches,
  18716. touch = (changedTouches && changedTouches.length > 0) ? changedTouches[0] : e;
  18717. return this.fromTouch(touch);
  18718. },
  18719. fromTouch: function(touch) {
  18720. return new this(touch.pageX, touch.pageY);
  18721. },
  18722. from: function(object) {
  18723. if (!object) {
  18724. return new this(0, 0);
  18725. }
  18726. if (!(object instanceof this)) {
  18727. return new this(object.x, object.y);
  18728. }
  18729. return object;
  18730. }
  18731. },
  18732. constructor: function(x, y) {
  18733. if (x == null) {
  18734. x = 0;
  18735. }
  18736. if (y == null) {
  18737. y = 0;
  18738. }
  18739. this.callParent([
  18740. y,
  18741. x,
  18742. y,
  18743. x
  18744. ]);
  18745. },
  18746. clone: function() {
  18747. return new this.self(this.x, this.y);
  18748. },
  18749. copy: function() {
  18750. return this.clone.apply(this, arguments);
  18751. },
  18752. copyFrom: function(point) {
  18753. this.x = point.x;
  18754. this.y = point.y;
  18755. return this;
  18756. },
  18757. toString: function() {
  18758. return "Point[" + this.x + "," + this.y + "]";
  18759. },
  18760. equals: function(point) {
  18761. return (this.x === point.x && this.y === point.y);
  18762. },
  18763. isCloseTo: function(point, threshold) {
  18764. if (typeof threshold === 'number') {
  18765. return this.getDistanceTo(point) <= threshold;
  18766. }
  18767. var x = point.x,
  18768. y = point.y,
  18769. thresholdX = threshold.x,
  18770. thresholdY = threshold.y;
  18771. return (this.x <= x + thresholdX && this.x >= x - thresholdX && this.y <= y + thresholdY && this.y >= y - thresholdY);
  18772. },
  18773. isWithin: function() {
  18774. return this.isCloseTo.apply(this, arguments);
  18775. },
  18776. isContainedBy: function(region) {
  18777. if (!(region instanceof Ext.util.Region)) {
  18778. region = Ext.get(region.el || region).getRegion();
  18779. }
  18780. return region.contains(this);
  18781. },
  18782. roundedEquals: function(point) {
  18783. if (!point || typeof point !== 'object') {
  18784. point = this.origin;
  18785. }
  18786. return (Math.round(this.x) === Math.round(point.x) && Math.round(this.y) === Math.round(point.y));
  18787. },
  18788. getDistanceTo: function(point) {
  18789. if (!point || typeof point !== 'object') {
  18790. point = this.origin;
  18791. }
  18792. var deltaX = this.x - point.x,
  18793. deltaY = this.y - point.y;
  18794. return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  18795. },
  18796. getAngleTo: function(point) {
  18797. if (!point || typeof point !== 'object') {
  18798. point = this.origin;
  18799. }
  18800. var deltaX = this.x - point.x,
  18801. deltaY = this.y - point.y;
  18802. return Math.atan2(deltaY, deltaX) * this.radianToDegreeConstant;
  18803. }
  18804. }, function() {
  18805. this.prototype.translate = this.prototype.translateBy;
  18806. });
  18807. Ext.define('Ext.event.Event', {
  18808. alternateClassName: 'Ext.EventObjectImpl',
  18809. stopped: false,
  18810. claimed: false,
  18811. defaultPrevented: false,
  18812. isEvent: true,
  18813. geckoRelatedTargetEvents: {
  18814. blur: 1,
  18815. dragenter: 1,
  18816. dragleave: 1,
  18817. focus: 1
  18818. },
  18819. statics: {
  18820. resolveTextNode: function(node) {
  18821. return (node && node.nodeType === 3) ? node.parentNode : node;
  18822. },
  18823. gestureEvents: {},
  18824. pointerEvents: {
  18825. pointerdown: 1,
  18826. pointermove: 1,
  18827. pointerup: 1,
  18828. pointercancel: 1,
  18829. pointerover: 1,
  18830. pointerout: 1,
  18831. pointerenter: 1,
  18832. pointerleave: 1,
  18833. MSPointerDown: 1,
  18834. MSPointerMove: 1,
  18835. MSPointerUp: 1,
  18836. MSPointerOver: 1,
  18837. MSPointerOut: 1,
  18838. MSPointerCancel: 1,
  18839. MSPointerEnter: 1,
  18840. MSPointerLeave: 1
  18841. },
  18842. mouseEvents: {
  18843. mousedown: 1,
  18844. mousemove: 1,
  18845. mouseup: 1,
  18846. mouseover: 1,
  18847. mouseout: 1,
  18848. mouseenter: 1,
  18849. mouseleave: 1
  18850. },
  18851. clickEvents: {
  18852. click: 1,
  18853. dblclick: 1
  18854. },
  18855. touchEvents: {
  18856. touchstart: 1,
  18857. touchmove: 1,
  18858. touchend: 1,
  18859. touchcancel: 1
  18860. },
  18861. focusEvents: {
  18862. focus: 1,
  18863. focusin: 1,
  18864. focusenter: 1
  18865. },
  18866. blurEvents: {
  18867. blur: 1,
  18868. focusout: 1,
  18869. focusleave: 1
  18870. },
  18871. wheelEvents: {
  18872. wheel: 1,
  18873. mousewheel: 1
  18874. },
  18875. pointerTypeMap: {
  18876. 2: 'touch',
  18877. 3: 'pen',
  18878. 4: 'mouse',
  18879. touch: 'touch',
  18880. pen: 'pen',
  18881. mouse: 'mouse'
  18882. },
  18883. keyEventRe: /^key/,
  18884. keyFlags: {
  18885. CTRL: 'ctrlKey',
  18886. CONTROL: 'ctrlKey',
  18887. ALT: 'altKey',
  18888. SHIFT: 'shiftKey',
  18889. CMD: 'metaKey',
  18890. COMMAND: 'metaKey',
  18891. CMDORCTRL: Ext.isMac ? 'metaKey' : 'ctrlKey',
  18892. COMMANDORCONTROL: Ext.isMac ? 'metaKey' : 'ctrlKey',
  18893. META: 'metaKey'
  18894. },
  18895. modifierGlyphs: {
  18896. ctrlKey: '⌃',
  18897. altKey: '⌥',
  18898. metaKey: Ext.isMac ? '⌘' : '⊞',
  18899. shiftKey: '⇧'
  18900. },
  18901. specialKeyGlyphs: {
  18902. BACKSPACE: '⌫',
  18903. TAB: '⇥',
  18904. ENTER: '⏎',
  18905. RETURN: '⏎',
  18906. SPACE: '␣',
  18907. PAGE_UP: '⇞',
  18908. PAGE_DOWN: '⇟',
  18909. END: '⇲',
  18910. HOME: '⌂',
  18911. LEFT: '←',
  18912. UP: '↑',
  18913. RIGHT: '→',
  18914. DOWN: '↓',
  18915. PRINT_SCREEN: '⎙',
  18916. INSERT: '⎀',
  18917. DELETE: '⌦',
  18918. CONTEXT_MENU: '☰'
  18919. },
  18920. _hyphenRe: /^[a-z]+\-/i,
  18921. getKeyId: function(keyName) {
  18922. if (typeof keyName === 'number') {
  18923. keyName = this.keyCodes[keyName];
  18924. } else {
  18925. keyName = keyName.toUpperCase();
  18926. }
  18927. var me = this,
  18928. delim = me._hyphenRe.test(keyName) ? '-' : '+',
  18929. parts = (keyName === delim) ? [
  18930. delim
  18931. ] : keyName.split(delim),
  18932. numModifiers = parts.length - 1,
  18933. rawKey = parts[numModifiers],
  18934. result = [],
  18935. eventFlag, i;
  18936. if (!Ext.event.Event[rawKey]) {
  18937. Ext.raise('Invalid key name: "' + rawKey + '"');
  18938. }
  18939. for (i = 0; i < numModifiers; i++) {
  18940. eventFlag = me.keyFlags[parts[i]];
  18941. if (!eventFlag) {
  18942. Ext.raise('Invalid key modifier: "' + parts[i] + '"');
  18943. }
  18944. result[eventFlag] = true;
  18945. }
  18946. if (result.ctrlKey) {
  18947. result.push(me.modifierGlyphs.ctrlKey);
  18948. }
  18949. if (result.altKey) {
  18950. result.push(me.modifierGlyphs.altKey);
  18951. }
  18952. if (result.shiftKey) {
  18953. result.push(me.modifierGlyphs.shiftKey);
  18954. }
  18955. if (result.metaKey) {
  18956. result.push(me.modifierGlyphs.metaKey);
  18957. }
  18958. result.push(this.specialKeyGlyphs[rawKey] || rawKey);
  18959. return result.join('');
  18960. },
  18961. globalTabKeyDown: function(e) {
  18962. if (e.keyCode === 9) {
  18963. Ext.event.Event.forwardTab = !e.shiftKey;
  18964. }
  18965. },
  18966. globalTabKeyUp: function(e) {
  18967. if (e.keyCode === 9) {
  18968. delete Ext.event.Event.forwardTab;
  18969. }
  18970. }
  18971. },
  18972. constructor: function(event) {
  18973. var me = this,
  18974. self = me.self,
  18975. resolveTextNode = me.self.resolveTextNode,
  18976. changedTouches = event.changedTouches,
  18977. coordinateOwner = changedTouches ? changedTouches[0] : event,
  18978. type = event.type,
  18979. pointerType, relatedTarget;
  18980. me.timeStamp = me.time = Ext.ticks();
  18981. me.pageX = coordinateOwner.pageX;
  18982. me.pageY = coordinateOwner.pageY;
  18983. me.clientX = coordinateOwner.clientX;
  18984. me.clientY = coordinateOwner.clientY;
  18985. me.target = me.delegatedTarget = resolveTextNode(event.target);
  18986. me.currentTarget = resolveTextNode(event.currentTarget);
  18987. relatedTarget = event.relatedTarget;
  18988. if (relatedTarget) {
  18989. if (Ext.isGecko && me.geckoRelatedTargetEvents[type]) {
  18990. try {
  18991. me.relatedTarget = resolveTextNode(relatedTarget);
  18992. } catch (e) {
  18993. me.relatedTarget = null;
  18994. }
  18995. } else {
  18996. me.relatedTarget = resolveTextNode(relatedTarget);
  18997. }
  18998. }
  18999. me.browserEvent = me.event = event;
  19000. me.type = type;
  19001. me.button = event.button || 0;
  19002. me.shiftKey = event.shiftKey;
  19003. me.ctrlKey = event.ctrlKey || event.metaKey || false;
  19004. me.altKey = event.altKey;
  19005. me.charCode = event.charCode;
  19006. me.keyCode = event.keyCode;
  19007. me.buttons = event.buttons;
  19008. if (me.button === 0 && me.buttons === 0) {
  19009. me.buttons = 1;
  19010. }
  19011. if (self.focusEvents[type] || self.blurEvents[type]) {
  19012. if (self.forwardTab !== undefined) {
  19013. me.forwardTab = self.forwardTab;
  19014. }
  19015. if (self.focusEvents[type]) {
  19016. me.fromElement = event.relatedTarget;
  19017. me.toElement = event.target;
  19018. } else {
  19019. me.fromElement = event.target;
  19020. me.toElement = event.relatedTarget;
  19021. }
  19022. } else if (type !== 'keydown') {
  19023. delete self.forwardTab;
  19024. }
  19025. if (self.mouseEvents[type]) {
  19026. pointerType = 'mouse';
  19027. } else if (self.clickEvents[type]) {
  19028. pointerType = self.pointerTypeMap[event.pointerType] || (((Ext.now() - Ext.event.publisher.Dom.lastTouchEndTime) < 1000) ? 'touch' : 'mouse');
  19029. }
  19030. else if (self.pointerEvents[type]) {
  19031. pointerType = self.pointerTypeMap[event.pointerType] || 'mouse';
  19032. } else if (self.touchEvents[type]) {
  19033. pointerType = 'touch';
  19034. }
  19035. if (pointerType) {
  19036. me.pointerType = pointerType;
  19037. }
  19038. me.isMultitouch = event.isPrimary === false || (event.touches && event.touches.length > 1);
  19039. if (self.wheelEvents[type]) {
  19040. me.getWheelDeltas();
  19041. }
  19042. },
  19043. chain: function(props) {
  19044. var e = Ext.Object.chain(this);
  19045. e.parentEvent = this;
  19046. return Ext.apply(e, props);
  19047. },
  19048. correctWheelDelta: function(delta) {
  19049. var me = this,
  19050. deltaMode = me.browserEvent.deltaMode,
  19051. correctedDelta = delta;
  19052. if (deltaMode === 0) {
  19053. correctedDelta = delta * me.WHEEL_PIXEL_SIZE;
  19054. } else if (deltaMode === 1) {
  19055. correctedDelta = delta * me.WHEEL_LINE_SIZE;
  19056. } else if (deltaMode === 2) {
  19057. correctedDelta = delta * me.WHEEL_PAGE_SIZE;
  19058. }
  19059. return Math.round(correctedDelta);
  19060. },
  19061. getChar: function() {
  19062. var r = this.which();
  19063. return String.fromCharCode(r);
  19064. },
  19065. getCharCode: function() {
  19066. return this.charCode || this.keyCode;
  19067. },
  19068. getKey: function() {
  19069. return this.keyCode || this.charCode;
  19070. },
  19071. getKeyName: function() {
  19072. return this.type === 'keypress' ? String.fromCharCode(this.getCharCode()) : this.keyCodes[this.keyCode];
  19073. },
  19074. key: function() {
  19075. return this.browserEvent.key;
  19076. },
  19077. which: function() {
  19078. var me = this,
  19079. e = me.browserEvent,
  19080. r = e.which;
  19081. if (r == null) {
  19082. if (me.self.keyEventRe.test(e.type)) {
  19083. r = e.charCode || e.keyCode;
  19084. } else if ((r = e.button) !== undefined) {
  19085. r = (r & 1) ? 1 : ((r & 4) ? 2 : ((r & 2) ? 3 : 0));
  19086. }
  19087. }
  19088. return r;
  19089. },
  19090. getClipboardData: function(type) {
  19091. var clipboardData = this.browserEvent.clipboardData,
  19092. clipIE = Ext.global.clipboardData,
  19093. result = null,
  19094. typeIE;
  19095. type = type || 'text/plain';
  19096. if (clipboardData && clipboardData.getData) {
  19097. result = clipboardData.getData(type);
  19098. } else if (clipIE && clipIE.getData) {
  19099. typeIE = this.ieMimeType[type];
  19100. if (typeIE) {
  19101. result = clipIE.getData(typeIE);
  19102. }
  19103. }
  19104. return result;
  19105. },
  19106. getPoint: function() {
  19107. var me = this,
  19108. point = me.point,
  19109. xy;
  19110. if (!point) {
  19111. xy = me.getXY();
  19112. point = me.point = new Ext.util.Point(xy[0], xy[1]);
  19113. }
  19114. return point;
  19115. },
  19116. getRelatedTarget: function(selector, maxDepth, returnEl) {
  19117. var relatedTarget = this.relatedTarget,
  19118. target = null;
  19119. if (relatedTarget && relatedTarget.nodeType) {
  19120. if (selector) {
  19121. target = Ext.fly(relatedTarget).findParent(selector, maxDepth, returnEl);
  19122. } else {
  19123. target = returnEl ? Ext.get(relatedTarget) : relatedTarget;
  19124. }
  19125. }
  19126. return target;
  19127. },
  19128. getTarget: function(selector, maxDepth, returnEl) {
  19129. return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
  19130. },
  19131. getTime: function() {
  19132. return this.time;
  19133. },
  19134. getWheelDelta: function() {
  19135. var deltas = this.getWheelDeltas();
  19136. return deltas.y;
  19137. },
  19138. getWheelDeltas: function() {
  19139. var me = this,
  19140. wheelDeltas = me.wheelDeltas,
  19141. browserEvent, deltaX, deltaY;
  19142. if (!wheelDeltas) {
  19143. browserEvent = me.browserEvent;
  19144. deltaX = me.correctWheelDelta(browserEvent.deltaX || 0);
  19145. deltaY = browserEvent.deltaY;
  19146. deltaY = me.correctWheelDelta(deltaY == null ? -browserEvent.wheelDelta : deltaY);
  19147. me.deltaX = deltaX;
  19148. me.deltaY = deltaY;
  19149. me.wheelDeltas = wheelDeltas = {
  19150. x: deltaX,
  19151. y: deltaY
  19152. };
  19153. }
  19154. return wheelDeltas;
  19155. },
  19156. getX: function() {
  19157. return this.getXY()[0];
  19158. },
  19159. getXY: function() {
  19160. var me = this,
  19161. xy = me.xy;
  19162. if (!xy) {
  19163. xy = me.xy = [
  19164. me.pageX,
  19165. me.pageY
  19166. ];
  19167. var x = xy[0],
  19168. browserEvent, doc, docEl, body;
  19169. if (!x && x !== 0) {
  19170. browserEvent = me.browserEvent;
  19171. doc = document;
  19172. docEl = doc.documentElement;
  19173. body = doc.body;
  19174. xy[0] = browserEvent.clientX + (docEl && docEl.scrollLeft || body && body.scrollLeft || 0) - (docEl && docEl.clientLeft || body && body.clientLeft || 0);
  19175. xy[1] = browserEvent.clientY + (docEl && docEl.scrollTop || body && body.scrollTop || 0) - (docEl && docEl.clientTop || body && body.clientTop || 0);
  19176. }
  19177. }
  19178. return xy;
  19179. },
  19180. getLocalXY: function(clip) {
  19181. var pageXY = this.getXY(),
  19182. targetXY = Ext.fly(this.currentTarget).getXY(),
  19183. localX = pageXY[0] - targetXY[0],
  19184. localY = pageXY[1] - targetXY[1],
  19185. size;
  19186. if (clip) {
  19187. size = Ext.fly(this.currentTarget).getSize();
  19188. localX = Math.max(0, Math.min(localX, size.width));
  19189. localY = Math.max(0, Math.min(localY, size.height));
  19190. }
  19191. return [
  19192. localX,
  19193. localY
  19194. ];
  19195. },
  19196. getY: function() {
  19197. return this.getXY()[1];
  19198. },
  19199. hasModifier: function() {
  19200. var me = this;
  19201. return !!(me.ctrlKey || me.altKey || me.shiftKey || me.metaKey);
  19202. },
  19203. isNavKeyPress: function(scrollableOnly) {
  19204. var me = this,
  19205. k = me.keyCode,
  19206. isKeyPress = me.type === 'keypress';
  19207. return ((!isKeyPress || Ext.isGecko) && k >= 33 && k <= 40) || (!scrollableOnly && (k === me.RETURN || k === me.TAB || k === me.ESC));
  19208. },
  19209. isSpecialKey: function() {
  19210. var me = this,
  19211. k = me.keyCode,
  19212. isGecko = Ext.isGecko,
  19213. isKeyPress = me.type === 'keypress';
  19214. return (isGecko && isKeyPress && me.charCode === 0) || (this.isNavKeyPress()) || (k === me.BACKSPACE) || (k === me.ENTER) || (k >= 16 && k <= 20) || (
  19215. (!isKeyPress || isGecko) && k >= 44 && k <= 46);
  19216. },
  19217. makeUnpreventable: function() {
  19218. this.browserEvent.preventDefault = Ext.emptyFn;
  19219. },
  19220. preventDefault: function() {
  19221. var me = this,
  19222. parentEvent = me.parentEvent;
  19223. me.defaultPrevented = true;
  19224. if (parentEvent) {
  19225. parentEvent.defaultPrevented = true;
  19226. }
  19227. me.browserEvent.preventDefault();
  19228. return me;
  19229. },
  19230. setCurrentTarget: function(target) {
  19231. this.currentTarget = this.delegatedTarget = target;
  19232. },
  19233. stopEvent: function() {
  19234. return this.preventDefault().stopPropagation();
  19235. },
  19236. mousedownEvents: {
  19237. mousedown: 1,
  19238. pointerdown: 1,
  19239. touchstart: 1
  19240. },
  19241. mouseupEvents: {
  19242. mouseup: 1,
  19243. pointerup: 1,
  19244. touchend: 1
  19245. },
  19246. stopPropagation: function() {
  19247. var me = this,
  19248. browserEvent = me.browserEvent,
  19249. parentEvent = me.parentEvent;
  19250. if (me.mousedownEvents[me.type]) {
  19251. Ext.GlobalEvents.fireMouseDown(me);
  19252. }
  19253. if (me.mouseupEvents[me.type]) {
  19254. Ext.GlobalEvents.fireMouseUp(me);
  19255. }
  19256. me.stopped = true;
  19257. if (parentEvent && !me.isGesture) {
  19258. parentEvent.stopped = true;
  19259. }
  19260. if (!browserEvent.stopPropagation) {
  19261. browserEvent.cancelBubble = true;
  19262. return me;
  19263. }
  19264. browserEvent.stopPropagation();
  19265. return me;
  19266. },
  19267. claimGesture: function() {
  19268. var me = this,
  19269. parentEvent = me.parentEvent;
  19270. me.claimed = true;
  19271. if (parentEvent && !me.isGesture) {
  19272. parentEvent.claimGesture();
  19273. } else {
  19274. me.preventDefault();
  19275. }
  19276. return me;
  19277. },
  19278. within: function(el, related, allowEl) {
  19279. var t;
  19280. if (el) {
  19281. t = related ? this.getRelatedTarget() : this.getTarget();
  19282. }
  19283. if (!t || (allowEl === false && t === Ext.getDom(el))) {
  19284. return false;
  19285. }
  19286. return Ext.fly(el).contains(t);
  19287. },
  19288. privates: {
  19289. ieMimeType: {
  19290. "text/plain": 'Text'
  19291. }
  19292. },
  19293. deprecated: {
  19294. '4.0': {
  19295. methods: {
  19296. getPageX: 'getX',
  19297. getPageY: 'getY'
  19298. }
  19299. }
  19300. }
  19301. }, function(Event) {
  19302. var constants = {
  19303. BACKSPACE: 8,
  19304. TAB: 9,
  19305. NUM_CENTER: 12,
  19306. ENTER: 13,
  19307. RETURN: 13,
  19308. SHIFT: 16,
  19309. CTRL: 17,
  19310. ALT: 18,
  19311. PAUSE: 19,
  19312. CAPS_LOCK: 20,
  19313. ESC: 27,
  19314. SPACE: 32,
  19315. PAGE_UP: 33,
  19316. PAGE_DOWN: 34,
  19317. END: 35,
  19318. HOME: 36,
  19319. LEFT: 37,
  19320. UP: 38,
  19321. RIGHT: 39,
  19322. DOWN: 40,
  19323. PRINT_SCREEN: 44,
  19324. INSERT: 45,
  19325. DELETE: 46,
  19326. ZERO: 48,
  19327. ONE: 49,
  19328. TWO: 50,
  19329. THREE: 51,
  19330. FOUR: 52,
  19331. FIVE: 53,
  19332. SIX: 54,
  19333. SEVEN: 55,
  19334. EIGHT: 56,
  19335. NINE: 57,
  19336. A: 65,
  19337. B: 66,
  19338. C: 67,
  19339. D: 68,
  19340. E: 69,
  19341. F: 70,
  19342. G: 71,
  19343. H: 72,
  19344. I: 73,
  19345. J: 74,
  19346. K: 75,
  19347. L: 76,
  19348. M: 77,
  19349. N: 78,
  19350. O: 79,
  19351. P: 80,
  19352. Q: 81,
  19353. R: 82,
  19354. S: 83,
  19355. T: 84,
  19356. U: 85,
  19357. V: 86,
  19358. W: 87,
  19359. X: 88,
  19360. Y: 89,
  19361. Z: 90,
  19362. META: 91,
  19363. CONTEXT_MENU: 93,
  19364. NUM_ZERO: 96,
  19365. NUM_ONE: 97,
  19366. NUM_TWO: 98,
  19367. NUM_THREE: 99,
  19368. NUM_FOUR: 100,
  19369. NUM_FIVE: 101,
  19370. NUM_SIX: 102,
  19371. NUM_SEVEN: 103,
  19372. NUM_EIGHT: 104,
  19373. NUM_NINE: 105,
  19374. NUM_MULTIPLY: 106,
  19375. NUM_PLUS: 107,
  19376. NUM_MINUS: 109,
  19377. NUM_PERIOD: 110,
  19378. NUM_DIVISION: 111,
  19379. F1: 112,
  19380. F2: 113,
  19381. F3: 114,
  19382. F4: 115,
  19383. F5: 116,
  19384. F6: 117,
  19385. F7: 118,
  19386. F8: 119,
  19387. F9: 120,
  19388. F10: 121,
  19389. F11: 122,
  19390. F12: 123,
  19391. WHEEL_PIXEL_SIZE: 1,
  19392. WHEEL_LINE_SIZE: 20,
  19393. WHEEL_PAGE_SIZE: 600
  19394. },
  19395. keyCodes = {},
  19396. gestureEvents = Event.gestureEvents,
  19397. prototype = Event.prototype,
  19398. i, keyName, keyCode, keys;
  19399. Ext.apply(gestureEvents, Event.mouseEvents);
  19400. Ext.apply(gestureEvents, Event.pointerEvents);
  19401. Ext.apply(gestureEvents, Event.touchEvents);
  19402. Ext.apply(Event, constants);
  19403. Ext.apply(prototype, constants);
  19404. delete constants.RETURN;
  19405. for (keyName in constants) {
  19406. keyCode = constants[keyName];
  19407. keyCodes[keyCode] = keyName;
  19408. }
  19409. Event.keyCodes = prototype.keyCodes = keyCodes;
  19410. if (!Ext.isIE9m) {
  19411. document.addEventListener('keydown', Event.globalTabKeyDown, true);
  19412. document.addEventListener('keyup', Event.globalTabKeyUp, true);
  19413. }
  19414. prototype.getTrueXY = prototype.getXY;
  19415. if (typeof KeyboardEvent !== 'undefined' && !('key' in KeyboardEvent.prototype)) {
  19416. prototype._keys = keys = {
  19417. 3: 'Cancel',
  19418. 6: 'Help',
  19419. 8: 'Backspace',
  19420. 9: 'Tab',
  19421. 12: 'Clear',
  19422. 13: 'Enter',
  19423. 16: 'Shift',
  19424. 17: 'Control',
  19425. 18: 'Alt',
  19426. 19: 'Pause',
  19427. 20: 'CapsLock',
  19428. 27: 'Escape',
  19429. 28: 'Convert',
  19430. 29: 'NonConvert',
  19431. 30: 'Accept',
  19432. 31: 'ModeChange',
  19433. 32: ' ',
  19434. 33: 'PageUp',
  19435. 34: 'PageDown',
  19436. 35: 'End',
  19437. 36: 'Home',
  19438. 37: 'ArrowLeft',
  19439. 38: 'ArrowUp',
  19440. 39: 'ArrowRight',
  19441. 40: 'ArrowDown',
  19442. 41: 'Select',
  19443. 42: 'Print',
  19444. 43: 'Execute',
  19445. 44: 'PrintScreen',
  19446. 45: 'Insert',
  19447. 46: 'Delete',
  19448. 48: [
  19449. '0',
  19450. ')'
  19451. ],
  19452. 49: [
  19453. '1',
  19454. '!'
  19455. ],
  19456. 50: [
  19457. '2',
  19458. '@'
  19459. ],
  19460. 51: [
  19461. '3',
  19462. '#'
  19463. ],
  19464. 52: [
  19465. '4',
  19466. '$'
  19467. ],
  19468. 53: [
  19469. '5',
  19470. '%'
  19471. ],
  19472. 54: [
  19473. '6',
  19474. '^'
  19475. ],
  19476. 55: [
  19477. '7',
  19478. '&'
  19479. ],
  19480. 56: [
  19481. '8',
  19482. '*'
  19483. ],
  19484. 57: [
  19485. '9',
  19486. '('
  19487. ],
  19488. 91: 'OS',
  19489. 93: 'ContextMenu',
  19490. 144: 'NumLock',
  19491. 145: 'ScrollLock',
  19492. 181: 'VolumeMute',
  19493. 182: 'VolumeDown',
  19494. 183: 'VolumeUp',
  19495. 186: [
  19496. ';',
  19497. ':'
  19498. ],
  19499. 187: [
  19500. '=',
  19501. '+'
  19502. ],
  19503. 188: [
  19504. ',',
  19505. '<'
  19506. ],
  19507. 189: [
  19508. '-',
  19509. '_'
  19510. ],
  19511. 190: [
  19512. '.',
  19513. '>'
  19514. ],
  19515. 191: [
  19516. '/',
  19517. '?'
  19518. ],
  19519. 192: [
  19520. '`',
  19521. '~'
  19522. ],
  19523. 219: [
  19524. '[',
  19525. '{'
  19526. ],
  19527. 220: [
  19528. '\\',
  19529. '|'
  19530. ],
  19531. 221: [
  19532. ']',
  19533. '}'
  19534. ],
  19535. 222: [
  19536. "'",
  19537. '"'
  19538. ],
  19539. 224: 'Meta',
  19540. 225: 'AltGraph',
  19541. 246: 'Attn',
  19542. 247: 'CrSel',
  19543. 248: 'ExSel',
  19544. 249: 'EraseEof',
  19545. 250: 'Play',
  19546. 251: 'ZoomOut'
  19547. };
  19548. for (i = 1; i < 25; ++i) {
  19549. keys[i + 111] = 'F' + i;
  19550. }
  19551. for (i = 0; i < 26; ++i) {
  19552. keys[i] = [
  19553. String.fromCharCode(i + 97),
  19554. String.fromCharCode(i + 65)
  19555. ];
  19556. }
  19557. prototype.key = function() {
  19558. var k = keys[this.browserEvent.which || this.keyCode];
  19559. if (k && typeof k !== 'string') {
  19560. k = k[+this.shiftKey];
  19561. }
  19562. return k;
  19563. };
  19564. }
  19565. });
  19566. Ext.define('Ext.event.publisher.Dom', {
  19567. extend: Ext.event.publisher.Publisher,
  19568. type: 'dom',
  19569. handledDomEvents: [],
  19570. reEnterCount: 0,
  19571. captureEvents: {
  19572. animationstart: 1,
  19573. animationend: 1,
  19574. resize: 1,
  19575. focus: 1,
  19576. blur: 1
  19577. },
  19578. directEvents: {
  19579. mouseenter: 1,
  19580. mouseleave: 1,
  19581. pointerenter: 1,
  19582. pointerleave: 1,
  19583. MSPointerEnter: 1,
  19584. MSPointerLeave: 1,
  19585. load: 1,
  19586. unload: 1,
  19587. beforeunload: 1,
  19588. error: 1,
  19589. DOMContentLoaded: 1,
  19590. DOMFrameContentLoaded: 1,
  19591. hashchange: 1,
  19592. scroll: 1,
  19593. online: 1,
  19594. offline: 1
  19595. },
  19596. blockedPointerEvents: {
  19597. pointerover: 1,
  19598. pointerout: 1,
  19599. pointerenter: 1,
  19600. pointerleave: 1,
  19601. MSPointerOver: 1,
  19602. MSPointerOut: 1,
  19603. MSPointerEnter: 1,
  19604. MSPointerLeave: 1
  19605. },
  19606. blockedCompatibilityMouseEvents: {
  19607. mouseenter: 1,
  19608. mouseleave: 1
  19609. },
  19610. constructor: function() {
  19611. var me = this,
  19612. supportsPassive = Ext.supports.PassiveEventListener;
  19613. me.listenerOptions = supportsPassive ? {
  19614. passive: false
  19615. } : false;
  19616. me.captureOptions = supportsPassive ? {
  19617. passive: false,
  19618. capture: true
  19619. } : true;
  19620. me.bubbleSubscribers = {};
  19621. me.captureSubscribers = {};
  19622. me.directSubscribers = {};
  19623. me.directCaptureSubscribers = {};
  19624. me.delegatedListeners = {};
  19625. me.initHandlers();
  19626. Ext.onInternalReady(me.onReady, me);
  19627. me.callParent();
  19628. me.registerDomEvents();
  19629. },
  19630. registerDomEvents: function() {
  19631. var me = this,
  19632. publishersByEvent = Ext.event.publisher.Publisher.publishersByEvent,
  19633. domEvents = me.handledDomEvents,
  19634. ln = domEvents.length,
  19635. i, eventName;
  19636. for (i = 0; i < ln; i++) {
  19637. eventName = domEvents[i];
  19638. me.handles[eventName] = 1;
  19639. publishersByEvent[eventName] = me;
  19640. }
  19641. },
  19642. onReady: function() {
  19643. var me = this,
  19644. domEvents = me.handledDomEvents,
  19645. ln, i;
  19646. if (domEvents) {
  19647. for (i = 0 , ln = domEvents.length; i < ln; i++) {
  19648. me.addDelegatedListener(domEvents[i]);
  19649. }
  19650. }
  19651. Ext.getWin().on('unload', me.destroy, me, {
  19652. priority: -10000
  19653. });
  19654. },
  19655. initHandlers: function() {
  19656. var me = this;
  19657. me.onDelegatedEvent = Ext.bind(me.onDelegatedEvent, me);
  19658. me.onDirectEvent = Ext.bind(me.onDirectEvent, me);
  19659. me.onDirectCaptureEvent = Ext.bind(me.onDirectCaptureEvent, me);
  19660. },
  19661. addDelegatedListener: function(eventName) {
  19662. var me = this;
  19663. me.delegatedListeners[eventName] = 1;
  19664. me.target.addEventListener(eventName, me.onDelegatedEvent, me.captureEvents[eventName] ? me.captureOptions : me.listenerOptions);
  19665. },
  19666. removeDelegatedListener: function(eventName) {
  19667. var me = this;
  19668. delete me.delegatedListeners[eventName];
  19669. me.target.removeEventListener(eventName, me.onDelegatedEvent, me.captureEvents[eventName] ? me.captureOptions : me.listenerOptions);
  19670. },
  19671. addDirectListener: function(eventName, element, capture) {
  19672. var me = this;
  19673. element.dom.addEventListener(eventName, capture ? me.onDirectCaptureEvent : me.onDirectEvent, capture ? me.captureOptions : me.listenerOptions);
  19674. },
  19675. removeDirectListener: function(eventName, element, capture) {
  19676. var me = this;
  19677. element.dom.removeEventListener(eventName, capture ? me.onDirectCaptureEvent : me.onDirectEvent, capture ? me.captureOptions : me.listenerOptions);
  19678. },
  19679. subscribe: function(element, eventName, delegated, capture) {
  19680. var me = this,
  19681. subscribers, id;
  19682. if (delegated && !me.directEvents[eventName]) {
  19683. subscribers = capture ? me.captureSubscribers : me.bubbleSubscribers;
  19684. if (!me.handles[eventName] && !me.delegatedListeners[eventName]) {
  19685. me.addDelegatedListener(eventName);
  19686. }
  19687. if (subscribers[eventName]) {
  19688. ++subscribers[eventName];
  19689. } else {
  19690. subscribers[eventName] = 1;
  19691. }
  19692. } else {
  19693. subscribers = capture ? me.directCaptureSubscribers : me.directSubscribers;
  19694. id = element.id;
  19695. subscribers = subscribers[eventName] || (subscribers[eventName] = {});
  19696. if (subscribers[id]) {
  19697. ++subscribers[id];
  19698. } else {
  19699. subscribers[id] = 1;
  19700. me.addDirectListener(eventName, element, capture);
  19701. }
  19702. }
  19703. },
  19704. unsubscribe: function(element, eventName, delegated, capture) {
  19705. var me = this,
  19706. captureSubscribers, bubbleSubscribers, subscribers, id;
  19707. if (delegated && !me.directEvents[eventName]) {
  19708. captureSubscribers = me.captureSubscribers;
  19709. bubbleSubscribers = me.bubbleSubscribers;
  19710. subscribers = capture ? captureSubscribers : bubbleSubscribers;
  19711. if (subscribers[eventName]) {
  19712. --subscribers[eventName];
  19713. }
  19714. if (!me.handles[eventName] && !bubbleSubscribers[eventName] && !captureSubscribers[eventName]) {
  19715. this.removeDelegatedListener(eventName);
  19716. }
  19717. } else {
  19718. subscribers = capture ? me.directCaptureSubscribers : me.directSubscribers;
  19719. id = element.id;
  19720. subscribers = subscribers[eventName];
  19721. if (subscribers[id]) {
  19722. --subscribers[id];
  19723. }
  19724. if (!subscribers[id]) {
  19725. delete subscribers[id];
  19726. me.removeDirectListener(eventName, element, capture);
  19727. }
  19728. }
  19729. },
  19730. getPropagatingTargets: function(target) {
  19731. var currentNode = target,
  19732. targets = [],
  19733. parentNode;
  19734. while (currentNode) {
  19735. targets.push(currentNode);
  19736. parentNode = currentNode.parentNode;
  19737. if (!parentNode) {
  19738. parentNode = currentNode.defaultView;
  19739. }
  19740. currentNode = parentNode;
  19741. }
  19742. return targets;
  19743. },
  19744. publish: function(e, targets, claimed) {
  19745. var me = this,
  19746. hasCaptureSubscribers = false,
  19747. hasBubbleSubscribers = false,
  19748. events, type, target, el, i, ln, j, eLn;
  19749. claimed = claimed || false;
  19750. if (!targets) {
  19751. if (e instanceof Array) {
  19752. Ext.raise("Propagation targets must be supplied when publishing " + "an array of events.");
  19753. }
  19754. target = e.target;
  19755. if (me.captureEvents[e.type]) {
  19756. el = Ext.cache[target.id];
  19757. targets = el ? [
  19758. el
  19759. ] : [];
  19760. } else {
  19761. targets = me.getPropagatingTargets(target);
  19762. }
  19763. }
  19764. events = Ext.Array.from(e);
  19765. ln = targets.length;
  19766. eLn = events.length;
  19767. for (i = 0; i < eLn; i++) {
  19768. type = events[i].type;
  19769. if (!hasCaptureSubscribers && me.captureSubscribers[type]) {
  19770. hasCaptureSubscribers = true;
  19771. }
  19772. if (!hasBubbleSubscribers && me.bubbleSubscribers[type]) {
  19773. hasBubbleSubscribers = true;
  19774. }
  19775. }
  19776. if (hasCaptureSubscribers) {
  19777. for (i = ln; i--; ) {
  19778. el = Ext.cache[targets[i].id];
  19779. if (el) {
  19780. for (j = 0; j < eLn; j++) {
  19781. e = events[j];
  19782. me.fire(el, e.type, e, false, true);
  19783. if (!claimed && e.claimed) {
  19784. claimed = true;
  19785. j = me.filterClaimed(events, e);
  19786. eLn = events.length;
  19787. }
  19788. if (e.stopped) {
  19789. events.splice(j, 1);
  19790. j--;
  19791. eLn--;
  19792. }
  19793. }
  19794. }
  19795. }
  19796. }
  19797. if (hasBubbleSubscribers && !e.stopped) {
  19798. for (i = 0; i < ln; i++) {
  19799. el = Ext.cache[targets[i].id];
  19800. if (el) {
  19801. for (j = 0; j < eLn; j++) {
  19802. e = events[j];
  19803. me.fire(el, e.type, e, false, false);
  19804. if (!claimed && e.claimed && me.filterClaimed) {
  19805. claimed = true;
  19806. j = me.filterClaimed(events, e);
  19807. eLn = events.length;
  19808. }
  19809. if (e.stopped) {
  19810. events.splice(j, 1);
  19811. j--;
  19812. eLn--;
  19813. }
  19814. }
  19815. }
  19816. }
  19817. }
  19818. },
  19819. publishDelegatedDomEvent: function(e) {
  19820. this.publish(e);
  19821. },
  19822. fire: function(element, eventName, e, direct, capture) {
  19823. var event;
  19824. if (element.hasListeners[eventName]) {
  19825. event = element.events[eventName];
  19826. if (event) {
  19827. if (capture && direct) {
  19828. event = event.directCaptures;
  19829. } else if (capture) {
  19830. event = event.captures;
  19831. } else if (direct) {
  19832. event = event.directs;
  19833. }
  19834. if (event) {
  19835. e.setCurrentTarget(element.dom);
  19836. event.fire(e, e.target);
  19837. }
  19838. }
  19839. }
  19840. },
  19841. onDelegatedEvent: function(e) {
  19842. if (Ext.elevateFunction) {
  19843. Ext.elevateFunction(this.doDelegatedEvent, this, [
  19844. e
  19845. ]);
  19846. } else {
  19847. this.doDelegatedEvent(e);
  19848. }
  19849. },
  19850. doDelegatedEvent: function(e) {
  19851. var me = this,
  19852. timeStamp;
  19853. e = new Ext.event.Event(e);
  19854. timeStamp = e.time;
  19855. if (!me.isEventBlocked(e)) {
  19856. me.beforeEvent(e);
  19857. Ext.frameStartTime = timeStamp;
  19858. me.reEnterCountAdjusted = false;
  19859. me.reEnterCount++;
  19860. me.publishDelegatedDomEvent(e);
  19861. if (!me.reEnterCountAdjusted) {
  19862. me.reEnterCount--;
  19863. }
  19864. me.afterEvent(e);
  19865. }
  19866. },
  19867. onDirectEvent: function(e) {
  19868. if (Ext.elevateFunction) {
  19869. Ext.elevateFunction(this.doDirectEvent, this, [
  19870. e,
  19871. false
  19872. ]);
  19873. } else {
  19874. this.doDirectEvent(e, false);
  19875. }
  19876. },
  19877. onDirectCaptureEvent: function(e) {
  19878. if (Ext.elevateFunction) {
  19879. Ext.elevateFunction(this.doDirectEvent, this, [
  19880. e,
  19881. true
  19882. ]);
  19883. } else {
  19884. this.doDirectEvent(e, true);
  19885. }
  19886. },
  19887. doDirectEvent: function(e, capture) {
  19888. var me = this,
  19889. currentTarget = e.currentTarget,
  19890. timeStamp, el;
  19891. e = new Ext.event.Event(e);
  19892. timeStamp = e.time;
  19893. if (me.isEventBlocked(e)) {
  19894. return;
  19895. }
  19896. me.beforeEvent(e);
  19897. Ext.frameStartTime = timeStamp;
  19898. el = Ext.cache[currentTarget.id];
  19899. if (el) {
  19900. me.reEnterCountAdjusted = false;
  19901. me.reEnterCount++;
  19902. me.fire(el, e.type, e, true, capture);
  19903. if (!me.reEnterCountAdjusted) {
  19904. me.reEnterCount--;
  19905. }
  19906. }
  19907. me.afterEvent(e);
  19908. },
  19909. beforeEvent: function(e) {
  19910. var browserEvent = e.browserEvent,
  19911. self = Ext.event.publisher.Dom,
  19912. touches, touch;
  19913. if (browserEvent.type === 'touchstart') {
  19914. touches = browserEvent.touches;
  19915. if (touches.length === 1) {
  19916. touch = touches[0];
  19917. self.lastTouchStartX = touch.pageX;
  19918. self.lastTouchStartY = touch.pageY;
  19919. }
  19920. }
  19921. },
  19922. afterEvent: function(e) {
  19923. var browserEvent = e.browserEvent,
  19924. type = browserEvent.type,
  19925. self = Ext.event.publisher.Dom,
  19926. GlobalEvents = Ext.GlobalEvents;
  19927. if (e.self.pointerEvents[type] && e.pointerType !== 'mouse') {
  19928. self.lastScreenPointerEventTime = Ext.now();
  19929. }
  19930. if (type === 'touchend') {
  19931. self.lastTouchEndTime = Ext.now();
  19932. }
  19933. if (!this.reEnterCount && !GlobalEvents.idleEventMask[type]) {
  19934. Ext.fireIdle();
  19935. }
  19936. },
  19937. isEventBlocked: function(e) {
  19938. var me = this,
  19939. type = e.type,
  19940. self = Ext.event.publisher.Dom,
  19941. now = Ext.now();
  19942. if (Ext.isGecko && e.type === 'click' && e.button === 2) {
  19943. return true;
  19944. }
  19945. return (me.blockedPointerEvents[type] && e.pointerType !== 'mouse') ||
  19946. (me.blockedCompatibilityMouseEvents[type] && (now - self.lastScreenPointerEventTime < 1000)) || (Ext.supports.TouchEvents && e.self.mouseEvents[e.type] &&
  19947. Math.abs(e.pageX - self.lastTouchStartX) < 15 && Math.abs(e.pageY - self.lastTouchStartY) < 15 &&
  19948. (Ext.now() - self.lastTouchEndTime) < 1000);
  19949. },
  19950. destroy: function() {
  19951. var GC = Ext.dom['GarbageCollector'],
  19952. eventName;
  19953. for (eventName in this.delegatedListeners) {
  19954. this.removeDelegatedListener(eventName);
  19955. }
  19956. Ext.Reaper.flush();
  19957. if (GC) {
  19958. GC.collect();
  19959. }
  19960. this.callParent();
  19961. },
  19962. reset: function() {
  19963. var self = Ext.event.publisher.Dom;
  19964. this.reEnterCount = 0;
  19965. self.lastScreenPointerEventTime = self.lastTouchEndTime = self.lastTouchStartX = self.lastTouchStartY = undefined;
  19966. }
  19967. }, function(Dom) {
  19968. var doc = document,
  19969. defaultView = doc.defaultView,
  19970. prototype = Dom.prototype;
  19971. if ((Ext.os.is.iOS && window.self !== window.top) || Ext.browser.is.AndroidStock || !(defaultView && defaultView.addEventListener)) {
  19972. prototype.target = doc;
  19973. } else {
  19974. prototype.target = defaultView;
  19975. }
  19976. Dom.instance = new Dom();
  19977. });
  19978. Ext.define('Ext.event.publisher.Gesture', {
  19979. extend: Ext.event.publisher.Dom,
  19980. type: 'gesture',
  19981. isCancelEvent: {
  19982. touchcancel: 1,
  19983. pointercancel: 1,
  19984. MSPointerCancel: 1
  19985. },
  19986. isEndEvent: {
  19987. mouseup: 1,
  19988. touchend: 1,
  19989. pointerup: 1,
  19990. MSPointerUp: 1
  19991. },
  19992. handledEvents: [],
  19993. handledDomEvents: [],
  19994. constructor: function(config) {
  19995. var me = this,
  19996. handledDomEvents = me.handledDomEvents,
  19997. supports = Ext.supports,
  19998. supportsTouchEvents = supports.TouchEvents,
  19999. onTouchStart = me.onTouchStart,
  20000. onTouchMove = me.onTouchMove,
  20001. onTouchEnd = me.onTouchEnd;
  20002. me.handlers = {
  20003. touchstart: onTouchStart,
  20004. touchmove: onTouchMove,
  20005. touchend: onTouchEnd,
  20006. touchcancel: onTouchEnd,
  20007. pointerdown: onTouchStart,
  20008. pointermove: onTouchMove,
  20009. pointerup: onTouchEnd,
  20010. pointercancel: onTouchEnd,
  20011. MSPointerDown: onTouchStart,
  20012. MSPointerMove: onTouchMove,
  20013. MSPointerUp: onTouchEnd,
  20014. MSPointerCancel: onTouchEnd,
  20015. mousedown: onTouchStart,
  20016. mousemove: onTouchMove,
  20017. mouseup: onTouchEnd
  20018. };
  20019. me.activeTouchesMap = {};
  20020. me.activeTouches = [];
  20021. me.changedTouches = [];
  20022. me.recognizers = [];
  20023. me.eventToRecognizer = {};
  20024. me.cancelEvents = [];
  20025. if (supportsTouchEvents) {
  20026. me.onTargetTouchMove = me.onTargetTouchMove.bind(me);
  20027. me.onTargetTouchEnd = me.onTargetTouchEnd.bind(me);
  20028. }
  20029. if (supports.PointerEvents) {
  20030. handledDomEvents.push('pointerdown', 'pointermove', 'pointerup', 'pointercancel');
  20031. me.mousePointerType = 'mouse';
  20032. } else if (supports.MSPointerEvents) {
  20033. handledDomEvents.push('MSPointerDown', 'MSPointerMove', 'MSPointerUp', 'MSPointerCancel');
  20034. me.mousePointerType = 4;
  20035. } else if (supportsTouchEvents) {
  20036. handledDomEvents.push('touchstart', 'touchmove', 'touchend', 'touchcancel');
  20037. }
  20038. if (!handledDomEvents.length || (supportsTouchEvents && Ext.os.is.Desktop)) {
  20039. handledDomEvents.push('mousedown', 'mousemove', 'mouseup');
  20040. }
  20041. me.initConfig(config);
  20042. return me.callParent();
  20043. },
  20044. onReady: function() {
  20045. this.callParent();
  20046. Ext.Array.sort(this.recognizers, function(recognizerA, recognizerB) {
  20047. var a = recognizerA.priority,
  20048. b = recognizerB.priority;
  20049. return (a > b) ? 1 : (a < b) ? -1 : 0;
  20050. });
  20051. },
  20052. registerRecognizer: function(recognizer) {
  20053. var me = this,
  20054. handledEvents = recognizer.handledEvents,
  20055. ln = handledEvents.length,
  20056. eventName, i;
  20057. recognizer.setOnRecognized(me.onRecognized);
  20058. recognizer.setCallbackScope(me);
  20059. for (i = 0; i < ln; i++) {
  20060. eventName = handledEvents[i];
  20061. me.handledEvents.push(eventName);
  20062. me.eventToRecognizer[eventName] = recognizer;
  20063. }
  20064. me.registerEvents(handledEvents);
  20065. me.recognizers.push(recognizer);
  20066. },
  20067. onRecognized: function(recognizer, eventName, e, info, isCancel) {
  20068. var me = this,
  20069. touches = e.touches,
  20070. changedTouches = e.changedTouches,
  20071. ln = changedTouches.length,
  20072. events = me.events,
  20073. queueWasEmpty = !events.length,
  20074. cancelEvents = me.cancelEvents,
  20075. targetGroups, targets, i, touch;
  20076. info = info || {};
  20077. info.type = eventName;
  20078. info.target = changedTouches[0].target;
  20079. info.stopped = false;
  20080. info.claimed = false;
  20081. info.isGesture = true;
  20082. e = e.chain(info);
  20083. if (!me.gestureTargets) {
  20084. if (ln > 1) {
  20085. targetGroups = [];
  20086. for (i = 0; i < ln; i++) {
  20087. touch = changedTouches[i];
  20088. targetGroups.push(touch.targets);
  20089. }
  20090. targets = me.getCommonTargets(targetGroups);
  20091. } else {
  20092. targets = changedTouches[0].targets;
  20093. }
  20094. me.gestureTargets = targets;
  20095. }
  20096. if (isCancel && recognizer.isSingleTouch && (touches.length > 1)) {
  20097. e.target = touches[0].target;
  20098. cancelEvents.push(e);
  20099. } else {
  20100. events.push(e);
  20101. }
  20102. if (queueWasEmpty) {
  20103. me.publishGestures();
  20104. }
  20105. },
  20106. getCommonTargets: function(targetGroups) {
  20107. var firstTargetGroup = targetGroups[0],
  20108. ln = targetGroups.length,
  20109. commonTargets = [],
  20110. i = 1,
  20111. target, targets, j;
  20112. if (ln === 1) {
  20113. return firstTargetGroup;
  20114. }
  20115. while (true) {
  20116. target = firstTargetGroup[firstTargetGroup.length - i];
  20117. if (!target) {
  20118. return commonTargets;
  20119. }
  20120. for (j = 1; j < ln; j++) {
  20121. targets = targetGroups[j];
  20122. if (targets[targets.length - i] !== target) {
  20123. return commonTargets;
  20124. }
  20125. }
  20126. commonTargets.unshift(target);
  20127. i++;
  20128. }
  20129. return commonTargets;
  20130. },
  20131. invokeRecognizers: function(methodName, e) {
  20132. var recognizers = this.recognizers,
  20133. ln = recognizers.length,
  20134. i, recognizer;
  20135. if (methodName === 'onStart') {
  20136. for (i = 0; i < ln; i++) {
  20137. recognizers[i].isActive = true;
  20138. }
  20139. }
  20140. for (i = 0; i < ln; i++) {
  20141. recognizer = recognizers[i];
  20142. if (recognizer.isActive && recognizer[methodName].call(recognizer, e) === false) {
  20143. recognizer.isActive = false;
  20144. }
  20145. }
  20146. },
  20147. filterClaimed: function(events, claimedEvent) {
  20148. var me = this,
  20149. eventToRecognizer = me.eventToRecognizer,
  20150. claimedEventType = claimedEvent.type,
  20151. claimedRecognizer = eventToRecognizer[claimedEventType],
  20152. claimedEventIndex, recognizer, type, i;
  20153. for (i = events.length; i--; ) {
  20154. type = events[i].type;
  20155. if (type === claimedEventType) {
  20156. claimedEventIndex = i;
  20157. } else {
  20158. recognizer = eventToRecognizer[type];
  20159. if (!claimedRecognizer || (recognizer && (recognizer !== claimedRecognizer))) {
  20160. events.splice(i, 1);
  20161. if (claimedEventIndex) {
  20162. claimedEventIndex--;
  20163. }
  20164. }
  20165. }
  20166. }
  20167. me.claimRecognizer(claimedRecognizer, events[0]);
  20168. return claimedEventIndex;
  20169. },
  20170. claimRecognizer: function(claimedRecognizer, e) {
  20171. var me = this,
  20172. recognizers = me.recognizers,
  20173. i, ln, recognizer;
  20174. for (i = 0 , ln = recognizers.length; i < ln; i++) {
  20175. recognizer = recognizers[i];
  20176. if (recognizer !== claimedRecognizer) {
  20177. recognizer.isActive = false;
  20178. recognizer.cancel(e);
  20179. }
  20180. }
  20181. if (me.events.length) {
  20182. me.publishGestures(true);
  20183. }
  20184. },
  20185. publishGestures: function(claimed) {
  20186. var me = this,
  20187. cancelEvents = me.cancelEvents,
  20188. events = me.events,
  20189. gestureTargets = me.gestureTargets;
  20190. if (cancelEvents.length) {
  20191. me.cancelEvents = [];
  20192. me.publish(cancelEvents, me.getPropagatingTargets(cancelEvents[0].target), true);
  20193. }
  20194. if (events.length) {
  20195. me.events = [];
  20196. me.gestureTargets = null;
  20197. me.publish(events, gestureTargets || me.getPropagatingTargets(events[0].target), claimed);
  20198. }
  20199. },
  20200. updateTouches: function(e) {
  20201. var me = this,
  20202. browserEvent = e.browserEvent,
  20203. type = e.type,
  20204. touchSources = browserEvent.changedTouches || [
  20205. browserEvent
  20206. ],
  20207. activeTouches = me.activeTouches,
  20208. activeTouchesMap = me.activeTouchesMap,
  20209. changedTouches = [],
  20210. touchSource, identifier, touch, target, i, ln, x, y;
  20211. for (i = 0 , ln = touchSources.length; i < ln; i++) {
  20212. touchSource = touchSources[i];
  20213. if ('identifier' in touchSource) {
  20214. identifier = touchSource.identifier;
  20215. } else if ('pointerId' in touchSource) {
  20216. identifier = touchSource.pointerId;
  20217. } else {
  20218. identifier = 1;
  20219. }
  20220. touch = activeTouchesMap[identifier];
  20221. if (!touch) {
  20222. target = Ext.event.Event.resolveTextNode(touchSource.target);
  20223. touch = activeTouchesMap[identifier] = {
  20224. identifier: identifier,
  20225. target: target,
  20226. targets: me.getPropagatingTargets(target)
  20227. };
  20228. activeTouches.push(touch);
  20229. }
  20230. if (me.isEndEvent[type] || me.isCancelEvent[type]) {
  20231. delete activeTouchesMap[identifier];
  20232. Ext.Array.remove(activeTouches, touch);
  20233. }
  20234. x = Math.round(touchSource.pageX);
  20235. y = Math.round(touchSource.pageY);
  20236. touch.pageX = x;
  20237. touch.pageY = y;
  20238. touch.point = new Ext.util.Point(x, y);
  20239. changedTouches.push(touch);
  20240. }
  20241. e.touches = Ext.Array.clone(activeTouches);
  20242. e.changedTouches = changedTouches;
  20243. },
  20244. publishDelegatedDomEvent: function(e) {
  20245. var me = this;
  20246. if (!e.button || e.button < 1) {
  20247. me.events = [
  20248. e
  20249. ];
  20250. e.browserEvent.$extHandled = true;
  20251. me.handlers[e.type].call(me, e);
  20252. } else {
  20253. me.callParent([
  20254. e
  20255. ]);
  20256. }
  20257. },
  20258. onTouchStart: function(e) {
  20259. var me = this,
  20260. target = e.target,
  20261. touches = e.browserEvent.touches;
  20262. if (e.browserEvent.type === 'touchstart') {
  20263. target.addEventListener('touchmove', me.onTargetTouchMove);
  20264. target.addEventListener('touchend', me.onTargetTouchEnd);
  20265. target.addEventListener('touchcancel', me.onTargetTouchEnd);
  20266. }
  20267. if (touches && touches.length <= me.activeTouches.length) {
  20268. me.removeGhostTouches(touches);
  20269. }
  20270. me.updateTouches(e);
  20271. if (!me.isStarted) {
  20272. if (Ext.enableGarbageCollector) {
  20273. Ext.dom.GarbageCollector.pause();
  20274. }
  20275. me.isStarted = true;
  20276. me.invokeRecognizers('onStart', e);
  20277. }
  20278. me.invokeRecognizers('onTouchStart', e);
  20279. me.publishGestures();
  20280. },
  20281. onTouchMove: function(e) {
  20282. var me = this,
  20283. mousePointerType = me.mousePointerType,
  20284. isStarted = me.isStarted;
  20285. if (isStarted || (e.pointerType !== 'mouse')) {
  20286. me.updateTouches(e);
  20287. }
  20288. if (isStarted) {
  20289. if (mousePointerType && e.browserEvent.pointerType === mousePointerType && e.buttons === 0) {
  20290. e.type = Ext.dom.Element.prototype.eventMap.touchend;
  20291. e.button = 0;
  20292. me.onTouchEnd(e);
  20293. return;
  20294. }
  20295. if (e.changedTouches.length > 0) {
  20296. me.invokeRecognizers('onTouchMove', e);
  20297. }
  20298. }
  20299. me.publishGestures();
  20300. },
  20301. onTouchEnd: function(e) {
  20302. var me = this,
  20303. isStarted = me.isStarted,
  20304. touchCount;
  20305. if (isStarted || (e.pointerType !== 'mouse')) {
  20306. me.updateTouches(e);
  20307. }
  20308. if (!isStarted) {
  20309. me.publishGestures();
  20310. return;
  20311. }
  20312. touchCount = me.activeTouches.length;
  20313. try {
  20314. me.invokeRecognizers(me.isCancelEvent[e.type] ? 'onTouchCancel' : 'onTouchEnd', e);
  20315. } finally {
  20316. try {
  20317. if (!touchCount) {
  20318. me.isStarted = false;
  20319. me.invokeRecognizers('onEnd', e);
  20320. }
  20321. } finally {
  20322. try {
  20323. me.publishGestures();
  20324. } finally {
  20325. if (!touchCount) {
  20326. if (Ext.enableGarbageCollector) {
  20327. Ext.dom.GarbageCollector.resume();
  20328. }
  20329. }
  20330. me.reEnterCountAdjusted = true;
  20331. me.reEnterCount--;
  20332. }
  20333. }
  20334. }
  20335. },
  20336. onTargetTouchMove: function(e) {
  20337. if (Ext.elevateFunction) {
  20338. Ext.elevateFunction(this.doTargetTouchMove, this, [
  20339. e
  20340. ]);
  20341. } else {
  20342. this.doTargetTouchMove(e);
  20343. }
  20344. },
  20345. doTargetTouchMove: function(e) {
  20346. var me = this;
  20347. if (!Ext.getBody().contains(e.target)) {
  20348. me.reEnterCountAdjusted = false;
  20349. me.reEnterCount++;
  20350. this.onTouchMove(new Ext.event.Event(e));
  20351. if (!me.reEnterCountAdjusted) {
  20352. me.reEnterCount--;
  20353. }
  20354. }
  20355. },
  20356. onTargetTouchEnd: function(e) {
  20357. if (Ext.elevateFunction) {
  20358. Ext.elevateFunction(this.doTargetTouchEnd, this, [
  20359. e
  20360. ]);
  20361. } else {
  20362. this.doTargetTouchEnd(e);
  20363. }
  20364. },
  20365. doTargetTouchEnd: function(e) {
  20366. var me = this,
  20367. target = e.target;
  20368. target.removeEventListener('touchmove', me.onTargetTouchMove);
  20369. target.removeEventListener('touchend', me.onTargetTouchEnd);
  20370. target.removeEventListener('touchcancel', me.onTargetTouchEnd);
  20371. if (!Ext.getBody().contains(target)) {
  20372. me.reEnterCountAdjusted = false;
  20373. me.reEnterCount++;
  20374. me.onTouchEnd(new Ext.event.Event(e));
  20375. if (!me.reEnterCountAdjusted) {
  20376. me.reEnterCount--;
  20377. }
  20378. }
  20379. },
  20380. reset: function() {
  20381. var me = this,
  20382. recognizers = me.recognizers,
  20383. ln = recognizers.length,
  20384. i, recognizer;
  20385. me.activeTouchesMap = {};
  20386. me.activeTouches = [];
  20387. me.changedTouches = [];
  20388. me.isStarted = false;
  20389. me.gestureTargets = null;
  20390. me.events = [];
  20391. me.cancelEvents = [];
  20392. for (i = 0; i < ln; i++) {
  20393. recognizer = recognizers[i];
  20394. recognizer.reset();
  20395. recognizer.isActive = false;
  20396. }
  20397. this.callParent();
  20398. },
  20399. privates: {
  20400. removeGhostTouches: function(touches) {
  20401. var ids = {},
  20402. len = touches.length,
  20403. activeTouches = this.activeTouches,
  20404. map = this.activeTouchesMap,
  20405. i, id, touch;
  20406. for (i = 0; i < len; ++i) {
  20407. ids[touches[i].identifier] = true;
  20408. }
  20409. i = activeTouches.length;
  20410. while (i--) {
  20411. touch = activeTouches[i];
  20412. id = touch.identifier;
  20413. if (!touches[id]) {
  20414. Ext.Array.remove(activeTouches, touch);
  20415. delete map[id];
  20416. }
  20417. }
  20418. }
  20419. }
  20420. }, function(Gesture) {
  20421. var EventProto = Event.prototype,
  20422. stopPropagation = EventProto.stopPropagation;
  20423. if (stopPropagation) {
  20424. EventProto.stopPropagation = function() {
  20425. var me = this,
  20426. publisher = Gesture.instance,
  20427. type = me.type,
  20428. e;
  20429. if (!me.$extHandled && publisher.handles[type]) {
  20430. e = new Ext.event.Event(me);
  20431. publisher.updateTouches(e);
  20432. publisher.invokeRecognizers('onTouchCancel', e);
  20433. publisher.reset();
  20434. publisher.reEnterCountAdjusted = true;
  20435. }
  20436. stopPropagation.apply(me, arguments);
  20437. };
  20438. }
  20439. Gesture.instance = Ext.$gesturePublisher = new Gesture();
  20440. });
  20441. Ext.define('Ext.mixin.Templatable', {
  20442. extend: Ext.Mixin,
  20443. mixinConfig: {
  20444. id: 'templatable'
  20445. },
  20446. referenceAttributeName: 'reference',
  20447. referenceSelector: '[reference]',
  20448. getElementConfig: function() {
  20449. return {
  20450. reference: 'element'
  20451. };
  20452. },
  20453. getElementTemplate: function() {
  20454. var elementTemplate = document.createDocumentFragment();
  20455. elementTemplate.appendChild(Ext.Element.create(this.getElementConfig(), true));
  20456. return elementTemplate;
  20457. },
  20458. initElement: function() {
  20459. var prototype = this.self.prototype;
  20460. prototype.elementTemplate = this.getElementTemplate();
  20461. prototype.initElement = prototype.doInitElement;
  20462. this.initElement.apply(this, arguments);
  20463. },
  20464. linkElement: function(reference, node) {
  20465. this.link(reference, node);
  20466. },
  20467. doInitElement: function() {
  20468. var referenceAttributeName = this.referenceAttributeName,
  20469. renderElement, referenceNodes, i, ln, referenceNode, reference;
  20470. renderElement = this.elementTemplate.cloneNode(true);
  20471. referenceNodes = renderElement.querySelectorAll(this.referenceSelector);
  20472. for (i = 0 , ln = referenceNodes.length; i < ln; i++) {
  20473. referenceNode = referenceNodes[i];
  20474. reference = referenceNode.getAttribute(referenceAttributeName);
  20475. referenceNode.removeAttribute(referenceAttributeName);
  20476. this.linkElement(reference, referenceNode);
  20477. }
  20478. }
  20479. });
  20480. Ext.define('Ext.TaskQueue', {
  20481. singleton: true,
  20482. pending: false,
  20483. mode: true,
  20484. protectedReadQueue: [],
  20485. protectedWriteQueue: [],
  20486. readQueue: [],
  20487. writeQueue: [],
  20488. readRequestId: 0,
  20489. writeRequestId: 0,
  20490. timer: null,
  20491. constructor: function() {
  20492. var me = this;
  20493. me.run = me.run.bind(me);
  20494. me.runProtected = Ext.Function.bind(me.run, me, [
  20495. me.protectedReadQueue,
  20496. me.protectedWriteQueue,
  20497. 'runProtected'
  20498. ]);
  20499. me.runProtected.$skipTimerCheck = true;
  20500. if (Ext.os.is.iOS) {
  20501. me.watch.$skipTimerCheck = true;
  20502. me.watchdogTimer = Ext.interval(this.watch, 500, this);
  20503. }
  20504. },
  20505. requestRead: function(fn, scope, args) {
  20506. var request = {
  20507. id: ++this.readRequestId,
  20508. fn: fn,
  20509. scope: scope,
  20510. args: args
  20511. };
  20512. if (arguments[3] === true) {
  20513. this.protectedReadQueue.push(request);
  20514. this.request(true, 'runProtected');
  20515. } else {
  20516. this.readQueue.push(request);
  20517. this.request(true);
  20518. }
  20519. return request.id;
  20520. },
  20521. cancelRead: function(id) {
  20522. this.cancelRequest(this.readQueue, id, true);
  20523. },
  20524. requestWrite: function(fn, scope, args) {
  20525. var me = this,
  20526. request = {
  20527. id: ++me.writeRequestId,
  20528. fn: fn,
  20529. scope: scope,
  20530. args: args
  20531. };
  20532. if (arguments[3] === true) {
  20533. me.protectedWriteQueue.push(request);
  20534. me.request(false, 'runProtected');
  20535. } else {
  20536. me.writeQueue.push(request);
  20537. me.request(false);
  20538. }
  20539. return request.id;
  20540. },
  20541. cancelWrite: function(id) {
  20542. this.cancelRequest(this.writeQueue, id, false);
  20543. },
  20544. request: function(mode, method) {
  20545. var me = this;
  20546. var oldMode = me.mode;
  20547. if (!me.pending) {
  20548. me.pendingTime = Date.now();
  20549. me.pending = true;
  20550. me.mode = mode;
  20551. if (mode) {
  20552. me.timer = Ext.defer(me[method] || me.run, 1);
  20553. } else {
  20554. me.timer = Ext.raf(me[method] || me.run);
  20555. }
  20556. }
  20557. if (me.mode === mode && me.timer) {
  20558. if (oldMode) {
  20559. Ext.undefer(me.timer);
  20560. } else {
  20561. Ext.unraf(me.timer);
  20562. }
  20563. if (mode) {
  20564. me.timer = Ext.defer(me[method] || me.run, 1);
  20565. } else {
  20566. me.timer = Ext.raf(me[method] || me.run);
  20567. }
  20568. }
  20569. },
  20570. cancelRequest: function(queue, id, mode) {
  20571. var i;
  20572. for (i = 0; i < queue.length; i++) {
  20573. if (queue[i].id === id) {
  20574. queue.splice(i, 1);
  20575. break;
  20576. }
  20577. }
  20578. if (!queue.length && this.mode === mode && this.timer) {
  20579. Ext.undefer(this.timer);
  20580. }
  20581. },
  20582. watch: function() {
  20583. if (this.pending && Date.now() - this.pendingTime >= 500) {
  20584. this.run();
  20585. }
  20586. },
  20587. run: function(readQueue, writeQueue, method) {
  20588. var me = this,
  20589. mode = null,
  20590. queue, tasks, task, fn, scope, args, i, len;
  20591. readQueue = readQueue || me.readQueue;
  20592. writeQueue = writeQueue || me.writeQueue;
  20593. me.pending = false;
  20594. me.pending = me.timer = false;
  20595. if (me.mode) {
  20596. queue = readQueue;
  20597. if (writeQueue.length > 0) {
  20598. mode = false;
  20599. }
  20600. } else {
  20601. queue = writeQueue;
  20602. if (readQueue.length > 0) {
  20603. mode = true;
  20604. }
  20605. }
  20606. tasks = queue.slice();
  20607. queue.length = 0;
  20608. for (i = 0 , len = tasks.length; i < len; i++) {
  20609. task = tasks[i];
  20610. fn = task.fn;
  20611. scope = task.scope;
  20612. args = task.args;
  20613. if (scope && (scope.destroying || scope.destroyed)) {
  20614. continue;
  20615. }
  20616. if (typeof fn === 'string') {
  20617. fn = scope[fn];
  20618. }
  20619. if (args) {
  20620. fn.apply(scope, args);
  20621. } else {
  20622. fn.call(scope);
  20623. }
  20624. }
  20625. tasks.length = 0;
  20626. if (mode !== null) {
  20627. me.request(mode, method);
  20628. }
  20629. },
  20630. clear: function() {
  20631. var me = this,
  20632. timer = me.timer;
  20633. if (timer) {
  20634. if (me.mode) {
  20635. Ext.undefer(timer);
  20636. } else {
  20637. Ext.unraf(timer);
  20638. }
  20639. }
  20640. me.readQueue.length = me.writeQueue.length = 0;
  20641. me.pending = me.timer = false;
  20642. me.mode = true;
  20643. },
  20644. privates: {
  20645. flush: function() {
  20646. var me = this,
  20647. mode = me.mode;
  20648. while (me.readQueue.length || me.writeQueue.length) {
  20649. if (mode) {
  20650. Ext.undefer(me.timer);
  20651. } else {
  20652. Ext.unraf(me.timer);
  20653. }
  20654. me.run();
  20655. }
  20656. me.mode = true;
  20657. }
  20658. }
  20659. });
  20660. Ext.define('Ext.util.sizemonitor.Abstract', {
  20661. mixins: [
  20662. Ext.mixin.Templatable
  20663. ],
  20664. config: {
  20665. element: null,
  20666. callback: Ext.emptyFn,
  20667. scope: null,
  20668. args: []
  20669. },
  20670. width: null,
  20671. height: null,
  20672. contentWidth: null,
  20673. contentHeight: null,
  20674. constructor: function(config) {
  20675. var me = this;
  20676. me.refresh = me.refresh.bind(me);
  20677. me.info = {
  20678. width: 0,
  20679. height: 0,
  20680. contentWidth: 0,
  20681. contentHeight: 0,
  20682. flag: 0
  20683. };
  20684. me.initElement();
  20685. me.initConfig(config);
  20686. me.bindListeners(true);
  20687. },
  20688. bindListeners: Ext.emptyFn,
  20689. applyElement: function(element) {
  20690. if (element) {
  20691. return Ext.get(element);
  20692. }
  20693. },
  20694. updateElement: function(element) {
  20695. element.append(this.detectorsContainer, true);
  20696. element.addCls(Ext.baseCSSPrefix + 'size-monitored');
  20697. },
  20698. applyArgs: function(args) {
  20699. return args.concat([
  20700. this.info
  20701. ]);
  20702. },
  20703. refreshMonitors: Ext.emptyFn,
  20704. forceRefresh: function() {
  20705. Ext.TaskQueue.requestRead('refresh', this);
  20706. },
  20707. getContentBounds: function() {
  20708. return this.detectorsContainer.getBoundingClientRect();
  20709. },
  20710. getContentWidth: function() {
  20711. return this.detectorsContainer.clientWidth;
  20712. },
  20713. getContentHeight: function() {
  20714. return this.detectorsContainer.clientHeight;
  20715. },
  20716. refreshSize: function() {
  20717. var element = this.getElement();
  20718. if (!element || element.destroyed) {
  20719. return false;
  20720. }
  20721. var me = this,
  20722. size = element.measure(),
  20723. width = size.width,
  20724. height = size.height,
  20725. contentWidth = me.getContentWidth(),
  20726. contentHeight = me.getContentHeight(),
  20727. currentContentWidth = me.contentWidth,
  20728. currentContentHeight = me.contentHeight,
  20729. info = me.info,
  20730. resized = false,
  20731. flag;
  20732. me.width = width;
  20733. me.height = height;
  20734. me.contentWidth = contentWidth;
  20735. me.contentHeight = contentHeight;
  20736. flag = ((currentContentWidth !== contentWidth ? 1 : 0) + (currentContentHeight !== contentHeight ? 2 : 0));
  20737. if (flag > 0) {
  20738. info.width = width;
  20739. info.height = height;
  20740. info.contentWidth = contentWidth;
  20741. info.contentHeight = contentHeight;
  20742. info.flag = flag;
  20743. resized = true;
  20744. me.getCallback().apply(me.getScope(), me.getArgs());
  20745. }
  20746. return resized;
  20747. },
  20748. refresh: function() {
  20749. if (this.destroying || this.destroyed) {
  20750. return;
  20751. }
  20752. this.refreshSize();
  20753. Ext.TaskQueue.requestWrite('refreshMonitors', this);
  20754. },
  20755. destroy: function() {
  20756. var me = this,
  20757. element = me.getElement();
  20758. me.bindListeners(false);
  20759. if (element && !element.destroyed) {
  20760. element.removeCls(Ext.baseCSSPrefix + 'size-monitored');
  20761. }
  20762. delete me._element;
  20763. me.refresh = null;
  20764. me.callParent();
  20765. }
  20766. });
  20767. Ext.define('Ext.util.sizemonitor.Scroll', {
  20768. extend: Ext.util.sizemonitor.Abstract,
  20769. getElementConfig: function() {
  20770. return {
  20771. reference: 'detectorsContainer',
  20772. classList: [
  20773. Ext.baseCSSPrefix + 'size-monitors',
  20774. 'scroll'
  20775. ],
  20776. children: [
  20777. {
  20778. reference: 'expandMonitor',
  20779. className: 'expand'
  20780. },
  20781. {
  20782. reference: 'shrinkMonitor',
  20783. className: 'shrink'
  20784. }
  20785. ]
  20786. };
  20787. },
  20788. constructor: function(config) {
  20789. this.onScroll = this.onScroll.bind(this);
  20790. this.callParent(arguments);
  20791. },
  20792. bindListeners: function(bind) {
  20793. var method = bind ? 'addEventListener' : 'removeEventListener';
  20794. this.expandMonitor[method]('scroll', this.onScroll, true);
  20795. this.shrinkMonitor[method]('scroll', this.onScroll, true);
  20796. },
  20797. onScroll: function() {
  20798. if (!this.destroyed) {
  20799. Ext.TaskQueue.requestRead('refresh', this);
  20800. }
  20801. },
  20802. refreshMonitors: function() {
  20803. var expandMonitor = this.expandMonitor,
  20804. shrinkMonitor = this.shrinkMonitor,
  20805. end = 1000000;
  20806. if (expandMonitor && !expandMonitor.destroyed) {
  20807. expandMonitor.scrollLeft = end;
  20808. expandMonitor.scrollTop = end;
  20809. }
  20810. if (shrinkMonitor && !shrinkMonitor.destroyed) {
  20811. shrinkMonitor.scrollLeft = end;
  20812. shrinkMonitor.scrollTop = end;
  20813. }
  20814. },
  20815. destroy: function() {
  20816. this.onScroll = null;
  20817. this.callParent();
  20818. }
  20819. });
  20820. Ext.define('Ext.util.SizeMonitor', {
  20821. constructor: function(config) {
  20822. return new Ext.util.sizemonitor.Scroll(config);
  20823. }
  20824. });
  20825. Ext.define('Ext.event.publisher.ElementSize', {
  20826. extend: Ext.event.publisher.Publisher,
  20827. type: 'size',
  20828. handledEvents: [
  20829. 'resize'
  20830. ],
  20831. constructor: function() {
  20832. this.monitors = {};
  20833. this.subscribers = {};
  20834. this.callParent(arguments);
  20835. },
  20836. subscribe: function(element) {
  20837. var id = element.id,
  20838. subscribers = this.subscribers,
  20839. monitors = this.monitors;
  20840. if (subscribers[id]) {
  20841. ++subscribers[id];
  20842. } else {
  20843. subscribers[id] = 1;
  20844. monitors[id] = new Ext.util.SizeMonitor({
  20845. element: element,
  20846. callback: this.onElementResize,
  20847. scope: this,
  20848. args: [
  20849. element
  20850. ]
  20851. });
  20852. }
  20853. element.on('painted', 'forceRefresh', monitors[id]);
  20854. return true;
  20855. },
  20856. unsubscribe: function(element) {
  20857. var id = element.id,
  20858. subscribers = this.subscribers,
  20859. monitors = this.monitors,
  20860. sizeMonitor;
  20861. if (subscribers[id] && !--subscribers[id]) {
  20862. delete subscribers[id];
  20863. sizeMonitor = monitors[id];
  20864. element.un('painted', 'forceRefresh', sizeMonitor);
  20865. sizeMonitor.destroy();
  20866. delete monitors[id];
  20867. }
  20868. if (element.activeRead) {
  20869. Ext.TaskQueue.cancelRead(element.activeRead);
  20870. }
  20871. },
  20872. fireElementResize: function(element, info) {
  20873. delete element.activeRead;
  20874. this.fire(element, 'resize', [
  20875. element,
  20876. info
  20877. ]);
  20878. },
  20879. onElementResize: function(element, info) {
  20880. if (!element.activeRead) {
  20881. element.activeRead = Ext.TaskQueue.requestRead('fireElementResize', this, [
  20882. element,
  20883. info
  20884. ],
  20885. !!element.$skipResourceCheck);
  20886. }
  20887. },
  20888. privates: {
  20889. syncRefresh: function(elements) {
  20890. var el, monitor, i, len;
  20891. elements = Ext.Array.from(elements);
  20892. for (i = 0 , len = elements.length; i < len; ++i) {
  20893. el = elements[i];
  20894. if (typeof el !== 'string') {
  20895. el = el.id;
  20896. }
  20897. monitor = this.monitors[el];
  20898. if (monitor) {
  20899. monitor.forceRefresh();
  20900. }
  20901. }
  20902. Ext.TaskQueue.flush();
  20903. Ext.Function.fireElevatedHandlers();
  20904. }
  20905. }
  20906. },
  20907. function(ElementSize) {
  20908. ElementSize.instance = new ElementSize();
  20909. });
  20910. Ext.define('Ext.util.paintmonitor.Abstract', {
  20911. config: {
  20912. element: null,
  20913. callback: Ext.emptyFn,
  20914. scope: null,
  20915. args: []
  20916. },
  20917. eventName: '',
  20918. monitorClass: '',
  20919. constructor: function(config) {
  20920. this.onElementPainted = this.onElementPainted.bind(this);
  20921. this.initConfig(config);
  20922. },
  20923. bindListeners: function(bind) {
  20924. this.monitorElement[bind ? 'addEventListener' : 'removeEventListener'](this.eventName, this.onElementPainted, true);
  20925. },
  20926. applyElement: function(element) {
  20927. if (element) {
  20928. return Ext.get(element);
  20929. }
  20930. },
  20931. updateElement: function(element) {
  20932. this.monitorElement = Ext.Element.create({
  20933. classList: [
  20934. Ext.baseCSSPrefix + 'paint-monitor',
  20935. this.monitorClass
  20936. ]
  20937. }, true);
  20938. element.appendChild(this.monitorElement, true);
  20939. element.addCls(Ext.baseCSSPrefix + 'paint-monitored');
  20940. this.bindListeners(true);
  20941. },
  20942. onElementPainted: function() {},
  20943. destroy: function() {
  20944. var me = this,
  20945. monitorElement = me.monitorElement,
  20946. parentNode = monitorElement.parentNode,
  20947. element = me.getElement();
  20948. me.bindListeners(false);
  20949. delete me.monitorElement;
  20950. if (element && !element.destroyed) {
  20951. element.removeCls(Ext.baseCSSPrefix + 'paint-monitored');
  20952. delete me._element;
  20953. }
  20954. if (parentNode) {
  20955. parentNode.removeChild(monitorElement);
  20956. }
  20957. me.callParent();
  20958. }
  20959. });
  20960. Ext.define('Ext.util.paintmonitor.CssAnimation', {
  20961. extend: Ext.util.paintmonitor.Abstract,
  20962. eventName: Ext.browser.is.WebKit ? 'webkitAnimationEnd' : 'animationend',
  20963. monitorClass: 'cssanimation',
  20964. onElementPainted: function(e) {
  20965. if (e.animationName === Ext.baseCSSPrefix + 'paint-monitor-helper') {
  20966. this.getCallback().apply(this.getScope(), this.getArgs());
  20967. }
  20968. }
  20969. });
  20970. Ext.define('Ext.util.PaintMonitor', {
  20971. constructor: function(config) {
  20972. return new Ext.util.paintmonitor.CssAnimation(config);
  20973. }
  20974. });
  20975. Ext.define('Ext.event.publisher.ElementPaint', {
  20976. extend: Ext.event.publisher.Publisher,
  20977. type: 'paint',
  20978. handledEvents: [
  20979. 'painted'
  20980. ],
  20981. constructor: function() {
  20982. this.monitors = {};
  20983. this.subscribers = {};
  20984. this.callParent(arguments);
  20985. },
  20986. subscribe: function(element) {
  20987. var me = this,
  20988. id = element.id,
  20989. subscribers = me.subscribers;
  20990. if (subscribers[id]) {
  20991. ++subscribers[id];
  20992. } else {
  20993. subscribers[id] = 1;
  20994. me.monitors[id] = new Ext.util.PaintMonitor({
  20995. element: element,
  20996. callback: me.onElementPainted,
  20997. scope: me,
  20998. args: [
  20999. element
  21000. ]
  21001. });
  21002. }
  21003. },
  21004. unsubscribe: function(element) {
  21005. var id = element.id,
  21006. subscribers = this.subscribers,
  21007. monitors = this.monitors;
  21008. if (subscribers[id] && !--subscribers[id]) {
  21009. delete subscribers[id];
  21010. monitors[id].destroy();
  21011. delete monitors[id];
  21012. }
  21013. if (element.activeRead) {
  21014. Ext.TaskQueue.cancelRead(element.activeRead);
  21015. }
  21016. },
  21017. fireElementPainted: function(element) {
  21018. delete element.activeRead;
  21019. this.fire(element, 'painted', [
  21020. element
  21021. ]);
  21022. },
  21023. onElementPainted: function(element) {
  21024. if (!element.activeRead) {
  21025. element.activeRead = Ext.TaskQueue.requestRead('fireElementPainted', this, [
  21026. element
  21027. ],
  21028. !!element.$skipResourceCheck);
  21029. }
  21030. }
  21031. },
  21032. function(ElementPaint) {
  21033. ElementPaint.instance = new ElementPaint();
  21034. });
  21035. Ext.define('Ext.dom.Element', function(Element) {
  21036. var WIN = window,
  21037. DOC = document,
  21038. docEl = DOC.documentElement,
  21039. WIN_TOP = WIN.top,
  21040. EMPTY = [],
  21041. elementIdCounter, windowId, documentId,
  21042. WIDTH = 'width',
  21043. HEIGHT = 'height',
  21044. MIN_WIDTH = 'min-width',
  21045. MIN_HEIGHT = 'min-height',
  21046. MAX_WIDTH = 'max-width',
  21047. MAX_HEIGHT = 'max-height',
  21048. TOP = 'top',
  21049. RIGHT = 'right',
  21050. BOTTOM = 'bottom',
  21051. LEFT = 'left',
  21052. VISIBILITY = 'visibility',
  21053. HIDDEN = 'hidden',
  21054. DISPLAY = "display",
  21055. NONE = "none",
  21056. ZINDEX = "z-index",
  21057. POSITION = "position",
  21058. RELATIVE = "relative",
  21059. STATIC = "static",
  21060. wordsRe = /\w/g,
  21061. spacesRe = /\s+/,
  21062. classNameSplitRegex = /[\s]+/,
  21063. transparentRe = /^(?:transparent|(?:rgba[(](?:\s*\d+\s*[,]){3}\s*0\s*[)]))$/i,
  21064. endsQuestionRe = /\?$/,
  21065. topRe = /top/i,
  21066. empty = {},
  21067. borders = {
  21068. t: 'border-top-width',
  21069. r: 'border-right-width',
  21070. b: 'border-bottom-width',
  21071. l: 'border-left-width'
  21072. },
  21073. paddings = {
  21074. t: 'padding-top',
  21075. r: 'padding-right',
  21076. b: 'padding-bottom',
  21077. l: 'padding-left'
  21078. },
  21079. margins = {
  21080. t: 'margin-top',
  21081. r: 'margin-right',
  21082. b: 'margin-bottom',
  21083. l: 'margin-left'
  21084. },
  21085. selectDir = {
  21086. b: 'backward',
  21087. back: 'backward',
  21088. f: 'forward'
  21089. },
  21090. paddingsTLRB = [
  21091. paddings.l,
  21092. paddings.r,
  21093. paddings.t,
  21094. paddings.b
  21095. ],
  21096. bordersTLRB = [
  21097. borders.l,
  21098. borders.r,
  21099. borders.t,
  21100. borders.b
  21101. ],
  21102. numberRe = /\d+$/,
  21103. unitRe = /\d+(px|r?em|%|vh|vw|vmin|vmax|en|ch|ex|pt|in|cm|mm|pc)$/i,
  21104. defaultUnit = 'px',
  21105. msRe = /^-ms-/,
  21106. camelRe = /(-[a-z])/gi,
  21107. cssRe = /([a-z0-9\-]+)\s*:\s*([^;\s]+(?:\s*[^;\s]+)*);?/gi,
  21108. pxRe = /^\d+(?:\.\d*)?px$/i,
  21109. relativeUnitRe = /(%|r?em|auto|vh|vw|vmin|vmax|ch|ex)$/i,
  21110. propertyCache = {},
  21111. ORIGINALDISPLAY = 'originalDisplay',
  21112. camelReplaceFn = function(m, a) {
  21113. return a.charAt(1).toUpperCase();
  21114. },
  21115. clearData = function(node, deep) {
  21116. var childNodes, i, len;
  21117. if (node.nodeType === 1) {
  21118. node._extData = null;
  21119. if (deep) {
  21120. childNodes = node.childNodes;
  21121. for (i = 0 , len = childNodes.length; i < len; ++i) {
  21122. clearData(childNodes[i], deep);
  21123. }
  21124. }
  21125. }
  21126. },
  21127. toFloat = function(v) {
  21128. return parseFloat(v) || 0;
  21129. },
  21130. opacityCls = Ext.baseCSSPrefix + 'hidden-opacity',
  21131. visibilityCls = Ext.baseCSSPrefix + 'hidden-visibility',
  21132. displayCls = Ext.baseCSSPrefix + 'hidden-display',
  21133. offsetsCls = Ext.baseCSSPrefix + 'hidden-offsets',
  21134. clipCls = Ext.baseCSSPrefix + 'hidden-clip',
  21135. lastFocusChange = 0,
  21136. lastKeyboardClose = 0,
  21137. editableHasFocus = false,
  21138. isVirtualKeyboardOpen = false,
  21139. inputTypeSelectionSupported = /text|password|search|tel|url/i,
  21140. visFly, scrollFly, caFly, wrapFly, grannyFly, activeElFly;
  21141. try {
  21142. elementIdCounter = WIN_TOP.__elementIdCounter__;
  21143. WIN_TOP.__elementIdCounter__ = elementIdCounter;
  21144. } catch (e) {
  21145. WIN_TOP = WIN;
  21146. }
  21147. WIN_TOP.__elementIdCounter__ = elementIdCounter = (WIN_TOP.__elementIdCounter__ || 0) + 1;
  21148. windowId = 'ext-window-' + elementIdCounter;
  21149. documentId = 'ext-document-' + elementIdCounter;
  21150. if (Object.freeze) {
  21151. Object.freeze(EMPTY);
  21152. }
  21153. return {
  21154. alternateClassName: [
  21155. 'Ext.Element'
  21156. ],
  21157. mixins: [
  21158. Ext.util.Positionable,
  21159. Ext.mixin.Observable
  21160. ],
  21161. observableType: 'element',
  21162. isElement: true,
  21163. skipGarbageCollection: true,
  21164. $applyConfigs: true,
  21165. identifiablePrefix: 'ext-element-',
  21166. _selectDir: selectDir,
  21167. styleHooks: {
  21168. transform: {
  21169. set: function(dom, value, el) {
  21170. var result = '',
  21171. prop;
  21172. if (typeof value !== 'string') {
  21173. for (prop in value) {
  21174. if (result) {
  21175. result += ' ';
  21176. }
  21177. if (prop.indexOf('translate') === 0) {
  21178. result += prop + '(' + Element.addUnits(value[prop], 'px') + ')';
  21179. } else {
  21180. result += prop + '(' + value[prop] + ')';
  21181. }
  21182. }
  21183. value = result;
  21184. }
  21185. dom.style.transform = value;
  21186. }
  21187. }
  21188. },
  21189. validIdRe: Ext.validIdRe,
  21190. blockedEvents: Ext.supports.EmulatedMouseOver ? {
  21191. mouseover: 1
  21192. } : {},
  21193. longpressEvents: {
  21194. longpress: 1,
  21195. taphold: 1
  21196. },
  21197. constructor: function(dom) {
  21198. var me = this,
  21199. id;
  21200. if (typeof dom === 'string') {
  21201. dom = DOC.getElementById(dom);
  21202. }
  21203. if (!dom) {
  21204. Ext.raise("Invalid domNode reference or an id of an existing domNode: " + dom);
  21205. return null;
  21206. }
  21207. if (Ext.cache[dom.id]) {
  21208. Ext.raise("Element cache already contains an entry for id '" + dom.id + "'. Use Ext.get() to create or retrieve Element instances.");
  21209. }
  21210. me.dom = dom;
  21211. if (!(id = dom.id)) {
  21212. dom.id = id = me.generateAutoId();
  21213. }
  21214. me.id = id;
  21215. if (!me.validIdRe.test(me.id)) {
  21216. Ext.raise('Invalid Element "id": "' + me.id + '"');
  21217. }
  21218. me.el = me;
  21219. Ext.cache[id] = me;
  21220. me.longpressListenerCount = 0;
  21221. me.mixins.observable.constructor.call(me);
  21222. },
  21223. inheritableStatics: {
  21224. cache: Ext.cache = {},
  21225. editableSelector: 'input,textarea,[contenteditable="true"]',
  21226. VISIBILITY: 1,
  21227. DISPLAY: 2,
  21228. OFFSETS: 3,
  21229. CLIP: 4,
  21230. OPACITY: 5,
  21231. minKeyboardHeight: 100,
  21232. unitRe: unitRe,
  21233. useDelegatedEvents: true,
  21234. validNodeTypes: {
  21235. 1: 1,
  21236. 9: 1
  21237. },
  21238. namespaceURIs: {
  21239. html: 'http://www.w3.org/1999/xhtml',
  21240. svg: 'http://www.w3.org/2000/svg'
  21241. },
  21242. selectableCls: Ext.baseCSSPrefix + 'selectable',
  21243. unselectableCls: Ext.baseCSSPrefix + 'unselectable',
  21244. maxRippleDiameter: 75,
  21245. addUnits: function(size, units) {
  21246. if (typeof size === 'number') {
  21247. return size + (units || defaultUnit);
  21248. }
  21249. if (size === "" || size === "auto" || size == null) {
  21250. return size || '';
  21251. }
  21252. if (numberRe.test(size)) {
  21253. return size + (units || defaultUnit);
  21254. }
  21255. if (!unitRe.test(size)) {
  21256. if (!(Ext.isString(size) && size.indexOf('calc') === 0)) {
  21257. Ext.Logger.warn("Warning, size detected (" + size + ") not a valid property value on Element.addUnits.");
  21258. }
  21259. return size || '';
  21260. }
  21261. return size;
  21262. },
  21263. create: function(attributes, domNode, namespace) {
  21264. var me = this,
  21265. classes, element, elementStyle, tag, value, name, i, ln, tmp, ns;
  21266. attributes = attributes || {};
  21267. if (attributes.isElement) {
  21268. return domNode ? attributes.dom : attributes;
  21269. } else if ('nodeType' in attributes) {
  21270. return domNode ? attributes : Ext.get(attributes);
  21271. }
  21272. if (typeof attributes === 'string') {
  21273. return DOC.createTextNode(attributes);
  21274. }
  21275. tag = attributes.tag;
  21276. if (!tag) {
  21277. tag = 'div';
  21278. }
  21279. ns = attributes.namespace || namespace;
  21280. if (ns) {
  21281. element = DOC.createElementNS(me.namespaceURIs[ns] || ns, tag);
  21282. } else {
  21283. element = DOC.createElement(tag);
  21284. }
  21285. elementStyle = element.style;
  21286. for (name in attributes) {
  21287. if (name !== 'tag' && name !== 'namespace') {
  21288. value = attributes[name];
  21289. switch (name) {
  21290. case 'style':
  21291. if (typeof value === 'string') {
  21292. element.setAttribute(name, value);
  21293. } else {
  21294. for (i in value) {
  21295. elementStyle[i] = value[i];
  21296. }
  21297. };
  21298. break;
  21299. case 'className':
  21300. case 'cls':
  21301. tmp = value.split(spacesRe);
  21302. classes = classes ? classes.concat(tmp) : tmp;
  21303. break;
  21304. case 'classList':
  21305. classes = classes ? classes.concat(value) : value;
  21306. break;
  21307. case 'text':
  21308. element.textContent = value;
  21309. break;
  21310. case 'html':
  21311. element.innerHTML = value;
  21312. break;
  21313. case 'hidden':
  21314. if (classes) {
  21315. classes.push(displayCls);
  21316. } else {
  21317. classes = [
  21318. displayCls
  21319. ];
  21320. };
  21321. break;
  21322. case 'children':
  21323. if (value != null) {
  21324. for (i = 0 , ln = value.length; i < ln; i++) {
  21325. element.appendChild(me.create(value[i], true, ns));
  21326. }
  21327. };
  21328. break;
  21329. default:
  21330. if (value != null) {
  21331. element.setAttribute(name, value);
  21332. };
  21333. }
  21334. }
  21335. }
  21336. if (classes) {
  21337. element.className = classes.join(' ');
  21338. }
  21339. if (domNode) {
  21340. return element;
  21341. } else {
  21342. return me.get(element);
  21343. }
  21344. },
  21345. fly: function(dom, named) {
  21346. return Ext.fly(dom, named);
  21347. },
  21348. fromPoint: (function() {
  21349. var elementFromPointBug;
  21350. if (Ext.isIE || Ext.isEdge) {
  21351. try {
  21352. elementFromPointBug = window.self !== window.top;
  21353. } catch (e) {
  21354. elementFromPointBug = true;
  21355. }
  21356. }
  21357. return function(x, y, asDom) {
  21358. var el = null;
  21359. el = DOC.elementFromPoint(x, y);
  21360. if (!el && elementFromPointBug) {
  21361. el = DOC.elementFromPoint(x, y);
  21362. }
  21363. return asDom ? el : Ext.get(el);
  21364. };
  21365. })(),
  21366. fromPagePoint: function(x, y, asDom) {
  21367. var scroll = Ext.getDoc().getScroll();
  21368. return Element.fromPoint(x - scroll.left, y - scroll.top, asDom);
  21369. },
  21370. get: function(el) {
  21371. var me = this,
  21372. cache = Ext.cache,
  21373. nodeType, dom, id, entry, isDoc, isWin, isValidNodeType;
  21374. if (!el) {
  21375. return null;
  21376. }
  21377. function warnDuplicate(id) {
  21378. Ext.raise("DOM element with id " + id + " in Element cache is not the same as element in the DOM. " + "Make sure to clean up Element instances using destroy()");
  21379. }
  21380. if (el.isFly) {
  21381. el = el.dom;
  21382. }
  21383. if (typeof el === 'string') {
  21384. id = el;
  21385. if (cache.hasOwnProperty(id)) {
  21386. entry = cache[id];
  21387. if (entry.skipGarbageCollection || !Ext.isGarbage(entry.dom)) {
  21388. dom = Ext.getElementById ? Ext.getElementById(id) : DOC.getElementById(id);
  21389. if (dom && (dom !== entry.dom)) {
  21390. warnDuplicate(id);
  21391. }
  21392. return entry;
  21393. } else {
  21394. entry.destroy();
  21395. }
  21396. }
  21397. if (id === windowId) {
  21398. return Element.get(WIN);
  21399. } else if (id === documentId) {
  21400. return Element.get(DOC);
  21401. }
  21402. dom = Ext.getElementById ? Ext.getElementById(id) : DOC.getElementById(id);
  21403. if (dom) {
  21404. return new Element(dom);
  21405. }
  21406. }
  21407. nodeType = el.nodeType;
  21408. if (nodeType) {
  21409. isDoc = (nodeType === 9);
  21410. isValidNodeType = me.validNodeTypes[nodeType];
  21411. } else {
  21412. isWin = (el.window == el);
  21413. }
  21414. if (isValidNodeType || isWin) {
  21415. id = el.id;
  21416. if (el === DOC) {
  21417. el.id = id = documentId;
  21418. }
  21419. else if (el == WIN) {
  21420. el.id = id = windowId;
  21421. }
  21422. if (cache.hasOwnProperty(id)) {
  21423. entry = cache[id];
  21424. if (entry.skipGarbageCollection || el === entry.dom || !Ext.isGarbage(entry.dom)) {
  21425. if (el !== entry.dom) {
  21426. warnDuplicate(id);
  21427. }
  21428. return entry;
  21429. } else {
  21430. entry.destroy();
  21431. }
  21432. }
  21433. el = new Element(el);
  21434. if (isWin || isDoc) {
  21435. el.skipGarbageCollection = true;
  21436. }
  21437. return el;
  21438. }
  21439. if (el.isElement) {
  21440. return el;
  21441. }
  21442. if (el.isComposite) {
  21443. return el;
  21444. }
  21445. if (Ext.isIterable(el)) {
  21446. return me.select(el);
  21447. }
  21448. return null;
  21449. },
  21450. getActiveElement: function(asElement) {
  21451. var active = DOC.activeElement;
  21452. if (!active || !active.focus) {
  21453. active = DOC.body;
  21454. }
  21455. return asElement ? Ext.get(active) : active;
  21456. },
  21457. getDocumentHeight: function() {
  21458. return Math.max(!Ext.isStrict ? DOC.body.scrollHeight : docEl.scrollHeight, this.getViewportHeight());
  21459. },
  21460. getDocumentWidth: function() {
  21461. return Math.max(!Ext.isStrict ? DOC.body.scrollWidth : docEl.scrollWidth, this.getViewportWidth());
  21462. },
  21463. getOrientation: function() {
  21464. if (Ext.supports.OrientationChange) {
  21465. return (WIN.orientation == 0) ? 'portrait' : 'landscape';
  21466. }
  21467. return (WIN.innerHeight > WIN.innerWidth) ? 'portrait' : 'landscape';
  21468. },
  21469. getViewportHeight: function() {
  21470. var viewportHeight = Element._viewportHeight;
  21471. if (Ext.isIE9m) {
  21472. return DOC.documentElement.clientHeight;
  21473. }
  21474. return (viewportHeight != null) ? viewportHeight : docEl.clientHeight;
  21475. },
  21476. getViewportWidth: function() {
  21477. var viewportWidth = Element._viewportWidth;
  21478. if (Ext.isIE9m) {
  21479. return DOC.documentElement.clientWidth;
  21480. }
  21481. return (viewportWidth != null) ? viewportWidth : docEl.clientWidth;
  21482. },
  21483. getViewportScale: function() {
  21484. var top = WIN_TOP;
  21485. return ((Ext.isiOS || Ext.isAndroid) ? 1 : (top.devicePixelRatio ||
  21486. top.screen.deviceXDPI / top.screen.logicalXDPI)) *
  21487. this.getViewportTouchScale();
  21488. },
  21489. getViewportTouchScale: function(forceRead) {
  21490. var scale = 1,
  21491. top = WIN_TOP,
  21492. cachedScale;
  21493. if (!forceRead) {
  21494. cachedScale = this._viewportTouchScale;
  21495. if (cachedScale) {
  21496. return cachedScale;
  21497. }
  21498. }
  21499. if (Ext.isIE10p || Ext.isEdge || Ext.isiOS) {
  21500. scale = docEl.offsetWidth / WIN.innerWidth;
  21501. } else if (Ext.isChromeMobile) {
  21502. scale = top.outerWidth / top.innerWidth;
  21503. }
  21504. return scale;
  21505. },
  21506. getViewSize: function() {
  21507. return {
  21508. width: Element.getViewportWidth(),
  21509. height: Element.getViewportHeight()
  21510. };
  21511. },
  21512. hasUnit: function(size) {
  21513. return !!(size && unitRe.test(size));
  21514. },
  21515. isRelativeUnit: function(size) {
  21516. return !size || relativeUnitRe.test(size);
  21517. },
  21518. maskIframes: function() {
  21519. var iframes = document.getElementsByTagName('iframe'),
  21520. fly = new Ext.dom.Fly();
  21521. Ext.each(iframes, function(iframe) {
  21522. var myMask;
  21523. myMask = fly.attach(iframe.parentNode).mask();
  21524. myMask.setStyle('background-color', 'transparent');
  21525. });
  21526. },
  21527. normalize: function(prop) {
  21528. return propertyCache[prop] || (propertyCache[prop] = prop.replace(msRe, 'ms-').replace(camelRe, camelReplaceFn));
  21529. },
  21530. _onWindowFocusChange: function(e) {
  21531. if (Ext.fly(e.target).is(Element.editableSelector)) {
  21532. lastFocusChange = new Date();
  21533. editableHasFocus = (e.type === 'focusin' || e.type === 'pointerup');
  21534. }
  21535. },
  21536. _onWindowResize: function() {
  21537. var documentWidth = docEl.clientWidth,
  21538. documentHeight = docEl.clientHeight,
  21539. now = new Date(),
  21540. threshold = 1000,
  21541. deltaX, deltaY;
  21542. deltaX = documentWidth - Element._documentWidth;
  21543. deltaY = documentHeight - Element._documentHeight;
  21544. Element._documentWidth = documentWidth;
  21545. Element._documentHeight = documentHeight;
  21546. if (((now - lastFocusChange) < threshold) || ((now - lastKeyboardClose) < threshold)) {
  21547. if (deltaX === 0 && (editableHasFocus && (deltaY <= -Element.minKeyboardHeight))) {
  21548. isVirtualKeyboardOpen = true;
  21549. return;
  21550. }
  21551. }
  21552. if (isVirtualKeyboardOpen && (deltaX === 0) && (deltaY >= Element.minKeyboardHeight)) {
  21553. isVirtualKeyboardOpen = false;
  21554. lastKeyboardClose = new Date();
  21555. }
  21556. if (isVirtualKeyboardOpen) {
  21557. return;
  21558. }
  21559. Element._viewportWidth = documentWidth;
  21560. Element._viewportHeight = documentHeight;
  21561. },
  21562. parseBox: function(box) {
  21563. var type, parts, ln;
  21564. box = box || 0;
  21565. type = typeof box;
  21566. if (type === 'number') {
  21567. return {
  21568. top: box,
  21569. right: box,
  21570. bottom: box,
  21571. left: box
  21572. };
  21573. } else if (type !== 'string') {
  21574. return box;
  21575. }
  21576. parts = box.split(' ');
  21577. ln = parts.length;
  21578. if (ln === 1) {
  21579. parts[1] = parts[2] = parts[3] = parts[0];
  21580. } else if (ln === 2) {
  21581. parts[2] = parts[0];
  21582. parts[3] = parts[1];
  21583. } else if (ln === 3) {
  21584. parts[3] = parts[1];
  21585. }
  21586. return {
  21587. top: parseFloat(parts[0]) || 0,
  21588. right: parseFloat(parts[1]) || 0,
  21589. bottom: parseFloat(parts[2]) || 0,
  21590. left: parseFloat(parts[3]) || 0
  21591. };
  21592. },
  21593. parseStyles: function(styles) {
  21594. var out = {},
  21595. matches;
  21596. if (styles) {
  21597. cssRe.lastIndex = 0;
  21598. while ((matches = cssRe.exec(styles))) {
  21599. out[matches[1]] = matches[2] || '';
  21600. }
  21601. }
  21602. return out;
  21603. },
  21604. select: function(selector, composite, root) {
  21605. return Ext.fly(root || DOC).select(selector, composite);
  21606. },
  21607. query: function(selector, asDom, root) {
  21608. return Ext.fly(root || DOC).query(selector, asDom);
  21609. },
  21610. unitizeBox: function(box, units) {
  21611. var me = this;
  21612. box = me.parseBox(box);
  21613. return me.addUnits(box.top, units) + ' ' + me.addUnits(box.right, units) + ' ' + me.addUnits(box.bottom, units) + ' ' + me.addUnits(box.left, units);
  21614. },
  21615. unmaskIframes: function() {
  21616. var iframes = document.getElementsByTagName('iframe'),
  21617. fly = new Ext.dom.Fly();
  21618. Ext.each(iframes, function(iframe) {
  21619. fly.attach(iframe.parentNode).unmask();
  21620. });
  21621. },
  21622. serializeForm: function(form) {
  21623. var fElements = form.elements || (DOC.forms[form] || Ext.getDom(form)).elements,
  21624. hasSubmit = false,
  21625. encoder = encodeURIComponent,
  21626. data = '',
  21627. eLen = fElements.length,
  21628. element, name, type, options, hasValue, e, o, oLen, opt;
  21629. for (e = 0; e < eLen; e++) {
  21630. element = fElements[e];
  21631. name = element.name;
  21632. type = element.type;
  21633. options = element.options;
  21634. if (!element.disabled && name) {
  21635. if (/select-(one|multiple)/i.test(type)) {
  21636. oLen = options.length;
  21637. for (o = 0; o < oLen; o++) {
  21638. opt = options[o];
  21639. if (opt.selected) {
  21640. hasValue = opt.hasAttribute('value');
  21641. data += Ext.String.format('{0}={1}&', encoder(name), encoder(hasValue ? opt.value : opt.text));
  21642. }
  21643. }
  21644. }
  21645. else if (!(/file|undefined|reset|button/i.test(type))) {
  21646. if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type === 'submit' && hasSubmit)) {
  21647. data += encoder(name) + '=' + encoder(element.value) + '&';
  21648. hasSubmit = /submit/i.test(type);
  21649. }
  21650. }
  21651. }
  21652. }
  21653. return data.substr(0, data.length - 1);
  21654. },
  21655. getCommonAncestor: function(nodeA, nodeB, returnDom) {
  21656. caFly = caFly || new Ext.dom.Fly();
  21657. caFly.attach(Ext.getDom(nodeA));
  21658. while (!caFly.isAncestor(nodeB)) {
  21659. if (caFly.dom.parentNode) {
  21660. caFly.attach(caFly.dom.parentNode);
  21661. } else
  21662. {
  21663. caFly.attach(DOC.body);
  21664. break;
  21665. }
  21666. }
  21667. return returnDom ? caFly.dom : Ext.get(caFly);
  21668. }
  21669. },
  21670. selectable: function() {
  21671. var me = this;
  21672. me.dom.unselectable = '';
  21673. me.removeCls(Element.unselectableCls);
  21674. me.addCls(Element.selectableCls);
  21675. return me;
  21676. },
  21677. unselectable: function() {
  21678. var me = this;
  21679. if (Ext.isOpera) {
  21680. me.dom.unselectable = 'on';
  21681. }
  21682. me.removeCls(Element.selectableCls);
  21683. me.addCls(Element.unselectableCls);
  21684. return me;
  21685. },
  21686. statics: {
  21687. tabbableSelector: Ext.supports.CSS3NegationSelector ? 'a[href],button,iframe,input,select,textarea,[tabindex]:not([tabindex="-1"]),[contenteditable="true"]' :
  21688. 'a[href],button,iframe,input,select,textarea,[tabindex],[contenteditable="true"]',
  21689. naturallyFocusableTags: {
  21690. BUTTON: true,
  21691. IFRAME: true,
  21692. EMBED: true,
  21693. INPUT: true,
  21694. OBJECT: true,
  21695. SELECT: true,
  21696. TEXTAREA: true,
  21697. HTML: Ext.isIE ? true : false,
  21698. BODY: Ext.isIE ? false : true
  21699. },
  21700. naturallyTabbableTags: {
  21701. BUTTON: true,
  21702. IFRAME: true,
  21703. INPUT: true,
  21704. SELECT: true,
  21705. TEXTAREA: true,
  21706. OBJECT: Ext.isIE8m ? true : false
  21707. },
  21708. inputTags: {
  21709. INPUT: true,
  21710. TEXTAREA: true
  21711. },
  21712. tabbableSavedCounterAttribute: 'data-tabindex-counter',
  21713. tabbableSavedValueAttribute: 'data-tabindex-value',
  21714. splitCls: function(cls) {
  21715. if (typeof cls === 'string') {
  21716. cls = cls.split(spacesRe);
  21717. }
  21718. return cls;
  21719. }
  21720. },
  21721. _init: function(E) {
  21722. E.tabbableSelector += ',[' + E.tabbableSavedCounterAttribute + ']';
  21723. },
  21724. addCls: function(names, prefix, suffix) {
  21725. return this.replaceCls(null, names, prefix, suffix);
  21726. },
  21727. addClsOnClick: function(className, testFn, scope) {
  21728. var me = this,
  21729. hasTest = Ext.isFunction(testFn);
  21730. me.on("mousedown", function() {
  21731. if (hasTest && testFn.call(scope || me, me) === false) {
  21732. return false;
  21733. }
  21734. me.addCls(className);
  21735. Ext.getDoc().on({
  21736. mouseup: function() {
  21737. if (me.dom) {
  21738. me.removeCls(className);
  21739. }
  21740. },
  21741. single: true
  21742. });
  21743. });
  21744. return me;
  21745. },
  21746. addClsOnFocus: function(className, testFn, scope) {
  21747. var me = this,
  21748. hasTest = Ext.isFunction(testFn);
  21749. me.on("focus", function() {
  21750. if (hasTest && testFn.call(scope || me, me) === false) {
  21751. return false;
  21752. }
  21753. me.addCls(className);
  21754. });
  21755. me.on("blur", function() {
  21756. if (me.dom) {
  21757. me.removeCls(className);
  21758. }
  21759. });
  21760. return me;
  21761. },
  21762. addClsOnOver: function(className, testFn, scope) {
  21763. var me = this,
  21764. hasTest = Ext.isFunction(testFn);
  21765. me.hover(function() {
  21766. if (hasTest && testFn.call(scope || me, me) === false) {
  21767. return;
  21768. }
  21769. me.addCls(className);
  21770. }, function() {
  21771. me.removeCls(className);
  21772. });
  21773. return me;
  21774. },
  21775. addStyles: function(sides, styles) {
  21776. var totalSize = 0,
  21777. sidesArr = (sides || '').match(wordsRe),
  21778. styleSides = [],
  21779. len = sidesArr.length,
  21780. side, i;
  21781. if (len === 1) {
  21782. totalSize = parseFloat(this.getStyle(styles[sidesArr[0]])) || 0;
  21783. } else if (len) {
  21784. for (i = 0; i < len; i++) {
  21785. side = sidesArr[i];
  21786. styleSides.push(styles[side]);
  21787. }
  21788. styleSides = this.getStyle(styleSides);
  21789. for (i = 0; i < len; i++) {
  21790. side = sidesArr[i];
  21791. totalSize += parseFloat(styleSides[styles[side]]) || 0;
  21792. }
  21793. }
  21794. return totalSize;
  21795. },
  21796. addUnits: function(size, units) {
  21797. return Element.addUnits(size, units);
  21798. },
  21799. animate: function(animation) {
  21800. animation = new Ext.fx.Animation(animation);
  21801. animation.setElement(this);
  21802. this._activeAnimation = animation;
  21803. animation.on({
  21804. animationend: this._onAnimationEnd,
  21805. scope: this
  21806. });
  21807. Ext.Animator.run(animation);
  21808. return animation;
  21809. },
  21810. _onAnimationEnd: function() {
  21811. this._activeAnimation = null;
  21812. },
  21813. getActiveAnimation: function() {
  21814. return this._activeAnimation;
  21815. },
  21816. append: function() {
  21817. return this.appendChild.apply(this, arguments);
  21818. },
  21819. appendChild: function(el, returnDom) {
  21820. var me = this,
  21821. insertEl, eLen, e;
  21822. if (el.nodeType || el.dom || typeof el === 'string') {
  21823. el = Ext.getDom(el);
  21824. me.dom.appendChild(el);
  21825. return !returnDom ? Ext.get(el) : el;
  21826. } else if (el.length) {
  21827. insertEl = Ext.fly(DOC.createDocumentFragment());
  21828. eLen = el.length;
  21829. for (e = 0; e < eLen; e++) {
  21830. insertEl.appendChild(el[e], returnDom);
  21831. }
  21832. el = Ext.Array.toArray(insertEl.dom.childNodes);
  21833. me.dom.appendChild(insertEl.dom);
  21834. return returnDom ? el : new Ext.dom.CompositeElementLite(el);
  21835. } else {
  21836. return me.createChild(el, null, returnDom);
  21837. }
  21838. },
  21839. appendTo: function(el) {
  21840. Ext.getDom(el).appendChild(this.dom);
  21841. return this;
  21842. },
  21843. applyStyles: function(styles) {
  21844. if (styles) {
  21845. if (typeof styles === "function") {
  21846. styles = styles.call();
  21847. }
  21848. if (typeof styles === "string") {
  21849. styles = Element.parseStyles(styles);
  21850. }
  21851. if (typeof styles === "object") {
  21852. this.setStyle(styles);
  21853. }
  21854. }
  21855. return this;
  21856. },
  21857. blur: function() {
  21858. var me = this,
  21859. dom = me.dom;
  21860. if (dom !== DOC.body) {
  21861. try {
  21862. dom.blur();
  21863. } catch (e) {}
  21864. return me;
  21865. } else {
  21866. return me.focus(undefined, dom);
  21867. }
  21868. },
  21869. cacheScrollValues: function() {
  21870. var me = this,
  21871. scrollValues = [],
  21872. scrolledDescendants = [],
  21873. descendants, descendant, i, len;
  21874. scrollFly = scrollFly || new Ext.dom.Fly();
  21875. descendants = me.query('*');
  21876. for (i = 0 , len = descendants.length; i < len; i++) {
  21877. descendant = descendants[i];
  21878. if (descendant.scrollTop > 0 || descendant.scrollLeft !== 0) {
  21879. scrolledDescendants.push(descendant);
  21880. scrollValues.push(scrollFly.attach(descendant).getScroll());
  21881. }
  21882. }
  21883. return function() {
  21884. var scroll, i, len;
  21885. for (i = 0 , len = scrolledDescendants.length; i < len; i++) {
  21886. scroll = scrollValues[i];
  21887. scrollFly.attach(scrolledDescendants[i]);
  21888. scrollFly.setScrollLeft(scroll.left);
  21889. scrollFly.setScrollTop(scroll.top);
  21890. }
  21891. };
  21892. },
  21893. center: function(centerIn) {
  21894. return this.alignTo(centerIn || DOC, 'c-c');
  21895. },
  21896. child: function(selector, returnDom) {
  21897. var me = this,
  21898. id;
  21899. if (Ext.supports.Selectors2) {
  21900. return me.selectNode(':scope>' + selector, !!returnDom);
  21901. } else {
  21902. id = me.id != null ? me.id : Ext.get(me).id;
  21903. return me.selectNode(Ext.makeIdSelector(id) + " > " + selector, !!returnDom);
  21904. }
  21905. },
  21906. clone: function(deep, returnDom) {
  21907. var clone = this.dom.cloneNode(deep);
  21908. if (Ext.supports.CloneNodeCopiesExpando) {
  21909. clearData(clone, deep);
  21910. }
  21911. return returnDom ? clone : Ext.get(clone);
  21912. },
  21913. constrainScrollLeft: function(left) {
  21914. var dom = this.dom;
  21915. return Math.max(Math.min(left, dom.scrollWidth - dom.clientWidth), 0);
  21916. },
  21917. constrainScrollTop: function(top) {
  21918. var dom = this.dom;
  21919. return Math.max(Math.min(top, dom.scrollHeight - dom.clientHeight), 0);
  21920. },
  21921. createChild: function(config, insertBefore, returnDom) {
  21922. config = config || {
  21923. tag: 'div'
  21924. };
  21925. if (insertBefore) {
  21926. return Ext.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
  21927. } else {
  21928. return Ext.DomHelper.append(this.dom, config, returnDom !== true);
  21929. }
  21930. },
  21931. contains: function(element) {
  21932. if (!element) {
  21933. return false;
  21934. }
  21935. var me = this,
  21936. dom = Ext.getDom(element);
  21937. return (dom === me.dom) || me.isAncestor(dom);
  21938. },
  21939. destroy: function() {
  21940. var me = this,
  21941. dom = me.dom;
  21942. if (me.destroyed) {
  21943. Ext.Logger.warn("Cannot destroy Element \"" + me.id + "\". Already destroyed.");
  21944. return;
  21945. }
  21946. if (me.resumeFocusEventsTimer) {
  21947. Ext.unasap(me.resumeFocusEventsTimer);
  21948. me.resumeFocusEventsTimer = null;
  21949. }
  21950. if (me.repaintTimer) {
  21951. me.repaintTimer = Ext.undefer(me.repaintTimer);
  21952. }
  21953. if (me.deferFocusTimer) {
  21954. me.deferFocusTimer = Ext.undefer(me.deferFocusTimer);
  21955. }
  21956. if (dom) {
  21957. if (dom === DOC.body) {
  21958. Ext.raise("Cannot destroy body element.");
  21959. } else if (dom === DOC) {
  21960. Ext.raise("Cannot destroy document object.");
  21961. } else if (dom === WIN) {
  21962. Ext.raise("Cannot destroy window object");
  21963. }
  21964. }
  21965. if (dom && dom.parentNode) {
  21966. dom.parentNode.removeChild(dom);
  21967. }
  21968. if (me.$ripples) {
  21969. me.destroyAllRipples();
  21970. }
  21971. me.collect();
  21972. },
  21973. detach: function() {
  21974. var dom = this.dom,
  21975. component = this.component;
  21976. if (dom && dom.parentNode && dom.tagName !== 'BODY') {
  21977. if (component) {
  21978. component.revertFocus();
  21979. }
  21980. dom.parentNode.removeChild(dom);
  21981. }
  21982. return this;
  21983. },
  21984. disableShadow: function() {
  21985. var shadow = this.shadow;
  21986. if (shadow) {
  21987. shadow.hide();
  21988. shadow.disabled = true;
  21989. }
  21990. },
  21991. disableShim: function() {
  21992. var shim = this.shim;
  21993. if (shim) {
  21994. shim.hide();
  21995. shim.disabled = true;
  21996. }
  21997. },
  21998. doReplaceWith: function(element) {
  21999. var dom = this.dom;
  22000. dom.parentNode.replaceChild(Ext.getDom(element), dom);
  22001. },
  22002. doScrollIntoView: function(container, hscroll, animate, highlight, getScrollX, scrollTo) {
  22003. scrollFly = scrollFly || new Ext.dom.Fly();
  22004. var me = this,
  22005. dom = me.dom,
  22006. scrollX = scrollFly.attach(container)[getScrollX](),
  22007. scrollY = container.scrollTop,
  22008. position = me.getScrollIntoViewXY(container, scrollX, scrollY),
  22009. newScrollX = position.x,
  22010. newScrollY = position.y;
  22011. if (highlight) {
  22012. if (animate) {
  22013. animate = Ext.apply({
  22014. listeners: {
  22015. afteranimate: function() {
  22016. scrollFly.attach(dom).highlight();
  22017. }
  22018. }
  22019. }, animate);
  22020. } else {
  22021. scrollFly.attach(dom).highlight();
  22022. }
  22023. }
  22024. if (newScrollY !== scrollY) {
  22025. scrollFly.attach(container).scrollTo('top', newScrollY, animate);
  22026. }
  22027. if (hscroll !== false && (newScrollX !== scrollX)) {
  22028. scrollFly.attach(container)[scrollTo]('left', newScrollX, animate);
  22029. }
  22030. return me;
  22031. },
  22032. down: function(selector, returnDom) {
  22033. return this.selectNode(selector, !!returnDom);
  22034. },
  22035. enableShadow: function(options, isVisible) {
  22036. var me = this,
  22037. shadow = me.shadow || (me.shadow = new Ext.dom.Shadow(Ext.apply({
  22038. target: me
  22039. }, options))),
  22040. shim = me.shim;
  22041. if (shim) {
  22042. shim.offsets = shadow.outerOffsets;
  22043. shim.shadow = shadow;
  22044. shadow.shim = shim;
  22045. }
  22046. if (isVisible === true || (isVisible !== false && me.isVisible())) {
  22047. shadow.show();
  22048. } else {
  22049. shadow.hide();
  22050. }
  22051. shadow.disabled = false;
  22052. },
  22053. enableShim: function(options, isVisible) {
  22054. var me = this,
  22055. shim = me.shim || (me.shim = new Ext.dom.Shim(Ext.apply({
  22056. target: me
  22057. }, options))),
  22058. shadow = me.shadow;
  22059. if (shadow) {
  22060. shim.offsets = shadow.outerOffsets;
  22061. shim.shadow = shadow;
  22062. shadow.shim = shim;
  22063. }
  22064. if (isVisible === true || (isVisible !== false && me.isVisible())) {
  22065. shim.show();
  22066. } else {
  22067. shim.hide();
  22068. }
  22069. shim.disabled = false;
  22070. return shim;
  22071. },
  22072. findParent: function(simpleSelector, limit, returnEl) {
  22073. var me = this,
  22074. target = me.dom,
  22075. topmost = docEl,
  22076. depth = 0;
  22077. if (limit || limit === 0) {
  22078. if (typeof limit !== 'number') {
  22079. topmost = Ext.getDom(limit);
  22080. limit = Number.MAX_VALUE;
  22081. }
  22082. } else {
  22083. limit = 50;
  22084. }
  22085. while (target && target.nodeType === 1 && depth < limit && target !== topmost) {
  22086. if (Ext.fly(target).is(simpleSelector)) {
  22087. return returnEl ? Ext.get(target) : target;
  22088. }
  22089. depth++;
  22090. target = target.parentNode;
  22091. }
  22092. return null;
  22093. },
  22094. findParentNode: function(simpleSelector, limit, returnEl) {
  22095. var p = Ext.fly(this.dom.parentNode);
  22096. return p ? p.findParent(simpleSelector, limit, returnEl) : null;
  22097. },
  22098. first: function(selector, returnDom) {
  22099. return this.matchNode('nextSibling', 'firstChild', selector, returnDom);
  22100. },
  22101. focus: function(defer, dom) {
  22102. var me = this;
  22103. dom = dom || me.dom;
  22104. if (Number(defer)) {
  22105. Ext.defer(me.focus, defer, me, [
  22106. null,
  22107. dom
  22108. ]);
  22109. } else {
  22110. Ext.fireEvent('beforefocus', dom);
  22111. dom.focus();
  22112. }
  22113. return me;
  22114. },
  22115. collect: function() {
  22116. var me = this,
  22117. dom = me.dom,
  22118. shadow = me.shadow,
  22119. shim = me.shim;
  22120. if (!me.isFly) {
  22121. me.mixins.observable.destroy.call(me);
  22122. delete Ext.cache[me.id];
  22123. me.el = null;
  22124. }
  22125. if (dom) {
  22126. dom._extData = me.dom = null;
  22127. }
  22128. if (shadow) {
  22129. shadow.hide();
  22130. me.shadow = null;
  22131. }
  22132. if (shim) {
  22133. shim.hide();
  22134. me.shim = null;
  22135. }
  22136. },
  22137. getAnchorToXY: function(el, anchor, local, mySize) {
  22138. return el.getAnchorXY(anchor, local, mySize);
  22139. },
  22140. getAttribute: function(name, namespace) {
  22141. var dom = this.dom;
  22142. return namespace ? (dom.getAttributeNS(namespace, name) || dom.getAttribute(namespace + ":" + name)) : (dom.getAttribute(name) || dom[name] || null);
  22143. },
  22144. getAttributes: function() {
  22145. var attributes = this.dom.attributes,
  22146. result = {},
  22147. attr, i, len;
  22148. for (i = 0 , len = attributes.length; i < len; i++) {
  22149. attr = attributes[i];
  22150. result[attr.name] = attr.value;
  22151. }
  22152. return result;
  22153. },
  22154. getBottom: function(local) {
  22155. return (local ? this.getLocalY() : this.getY()) + this.getHeight();
  22156. },
  22157. getById: function(id, asDom) {
  22158. var dom = DOC.getElementById(id) || this.dom.querySelector(Ext.makeIdSelector(id));
  22159. return asDom ? dom : (dom ? Ext.get(dom) : null);
  22160. },
  22161. getBorderPadding: function() {
  22162. var paddingWidth = this.getStyle(paddingsTLRB),
  22163. bordersWidth = this.getStyle(bordersTLRB);
  22164. return {
  22165. beforeX: (parseFloat(bordersWidth[borders.l]) || 0) + (parseFloat(paddingWidth[paddings.l]) || 0),
  22166. afterX: (parseFloat(bordersWidth[borders.r]) || 0) + (parseFloat(paddingWidth[paddings.r]) || 0),
  22167. beforeY: (parseFloat(bordersWidth[borders.t]) || 0) + (parseFloat(paddingWidth[paddings.t]) || 0),
  22168. afterY: (parseFloat(bordersWidth[borders.b]) || 0) + (parseFloat(paddingWidth[paddings.b]) || 0)
  22169. };
  22170. },
  22171. getBorders: function() {
  22172. var bordersWidth = this.getStyle(bordersTLRB);
  22173. return {
  22174. beforeX: (parseFloat(bordersWidth[borders.l]) || 0),
  22175. afterX: (parseFloat(bordersWidth[borders.r]) || 0),
  22176. beforeY: (parseFloat(bordersWidth[borders.t]) || 0),
  22177. afterY: (parseFloat(bordersWidth[borders.b]) || 0)
  22178. };
  22179. },
  22180. getBorderWidth: function(side) {
  22181. return this.addStyles(side, borders);
  22182. },
  22183. getClassMap: function(clone) {
  22184. var data = this.getData();
  22185. if (data) {
  22186. data = data.classMap;
  22187. if (clone !== false) {
  22188. data = Ext.apply({}, data);
  22189. }
  22190. }
  22191. return data;
  22192. },
  22193. getData: function(sync) {
  22194. var dom = this.dom,
  22195. data;
  22196. if (dom) {
  22197. data = dom._extData || (dom._extData = {});
  22198. if (sync !== false && !data.isSynchronized) {
  22199. this.synchronize();
  22200. }
  22201. }
  22202. return data || null;
  22203. },
  22204. getFirstChild: function() {
  22205. return Ext.get(this.dom.firstElementChild);
  22206. },
  22207. getLastChild: function() {
  22208. return Ext.get(this.dom.lastElementChild);
  22209. },
  22210. getHeight: function(contentHeight, preciseHeight) {
  22211. var me = this,
  22212. dom = me.dom,
  22213. hidden = me.isStyle('display', 'none'),
  22214. height, floating;
  22215. if (hidden) {
  22216. return 0;
  22217. }
  22218. if (dom.nodeName === 'BODY') {
  22219. height = Element.getViewportHeight();
  22220. } else {
  22221. if (preciseHeight) {
  22222. height = dom.getBoundingClientRect().height;
  22223. } else {
  22224. height = dom.offsetHeight;
  22225. if (height == null) {
  22226. height = dom.getBoundingClientRect().height;
  22227. }
  22228. }
  22229. }
  22230. if (Ext.supports.Direct2DBug) {
  22231. floating = me.adjustDirect2DDimension(HEIGHT);
  22232. if (preciseHeight) {
  22233. height += floating;
  22234. } else if (floating > 0 && floating < 0.5) {
  22235. height++;
  22236. }
  22237. }
  22238. if (contentHeight) {
  22239. height -= me.getBorderWidth("tb") + me.getPadding("tb");
  22240. }
  22241. return (height < 0) ? 0 : height;
  22242. },
  22243. getHtml: function() {
  22244. return this.dom ? this.dom.innerHTML : '';
  22245. },
  22246. getLeft: function(local) {
  22247. return local ? this.getLocalX() : this.getX();
  22248. },
  22249. getLocalX: function() {
  22250. var me = this,
  22251. offsetParent,
  22252. x = me.getStyle('left');
  22253. if (!x || x === 'auto') {
  22254. x = 0;
  22255. } else if (pxRe.test(x)) {
  22256. x = parseFloat(x);
  22257. } else {
  22258. x = me.getX();
  22259. offsetParent = me.dom.offsetParent;
  22260. if (offsetParent) {
  22261. x -= Ext.fly(offsetParent).getX();
  22262. }
  22263. }
  22264. return x;
  22265. },
  22266. getLocalXY: function() {
  22267. var me = this,
  22268. offsetParent,
  22269. style = me.getStyle([
  22270. 'left',
  22271. 'top'
  22272. ]),
  22273. x = style.left,
  22274. y = style.top;
  22275. if (!x || x === 'auto') {
  22276. x = 0;
  22277. } else if (pxRe.test(x)) {
  22278. x = parseFloat(x);
  22279. } else {
  22280. x = me.getX();
  22281. offsetParent = me.dom.offsetParent;
  22282. if (offsetParent) {
  22283. x -= Ext.fly(offsetParent).getX();
  22284. }
  22285. }
  22286. if (!y || y === 'auto') {
  22287. y = 0;
  22288. } else if (pxRe.test(y)) {
  22289. y = parseFloat(y);
  22290. } else {
  22291. y = me.getY();
  22292. offsetParent = me.dom.offsetParent;
  22293. if (offsetParent) {
  22294. y -= Ext.fly(offsetParent).getY();
  22295. }
  22296. }
  22297. return [
  22298. x,
  22299. y
  22300. ];
  22301. },
  22302. getLocalY: function() {
  22303. var me = this,
  22304. offsetParent,
  22305. y = me.getStyle('top');
  22306. if (!y || y === 'auto') {
  22307. y = 0;
  22308. } else if (pxRe.test(y)) {
  22309. y = parseFloat(y);
  22310. } else {
  22311. y = me.getY();
  22312. offsetParent = me.dom.offsetParent;
  22313. if (offsetParent) {
  22314. y -= Ext.fly(offsetParent).getY();
  22315. }
  22316. }
  22317. return y;
  22318. },
  22319. getMargin: (function() {
  22320. var hash = {
  22321. t: "top",
  22322. l: "left",
  22323. r: "right",
  22324. b: "bottom"
  22325. },
  22326. allMargins = [
  22327. 'margin-top',
  22328. 'margin-left',
  22329. 'margin-right',
  22330. 'margin-bottom'
  22331. ];
  22332. return function(side) {
  22333. var me = this,
  22334. style, key, o;
  22335. if (!side) {
  22336. style = me.getStyle(allMargins);
  22337. o = {};
  22338. if (style && typeof style === 'object') {
  22339. o = {};
  22340. for (key in margins) {
  22341. o[key] = o[hash[key]] = parseFloat(style[margins[key]]) || 0;
  22342. }
  22343. }
  22344. } else {
  22345. o = me.addStyles(side, margins);
  22346. }
  22347. return o;
  22348. };
  22349. })(),
  22350. getPadding: function(side) {
  22351. return this.addStyles(side, paddings);
  22352. },
  22353. getParent: function() {
  22354. return Ext.get(this.dom.parentNode);
  22355. },
  22356. getRight: function(local) {
  22357. return (local ? this.getLocalX() : this.getX()) + this.getWidth();
  22358. },
  22359. getScroll: function() {
  22360. var me = this,
  22361. dom = me.dom,
  22362. docElement = docEl,
  22363. left, top,
  22364. body = DOC.body;
  22365. if (dom === DOC || dom === body) {
  22366. left = docElement.scrollLeft || (body ? body.scrollLeft : 0);
  22367. top = docElement.scrollTop || (body ? body.scrollTop : 0);
  22368. } else {
  22369. left = dom.scrollLeft;
  22370. top = dom.scrollTop;
  22371. }
  22372. return {
  22373. left: left,
  22374. top: top
  22375. };
  22376. },
  22377. getScrollIntoViewXY: function(container, scrollX, scrollY, align) {
  22378. var me = this,
  22379. dom = me.dom,
  22380. offsets, clientWidth, clientHeight;
  22381. align = align || empty;
  22382. if (container.isRegion) {
  22383. clientHeight = container.height;
  22384. clientWidth = container.width;
  22385. } else {
  22386. container = Ext.getDom(container);
  22387. clientHeight = container.clientHeight;
  22388. clientWidth = container.clientWidth;
  22389. }
  22390. offsets = me.getOffsetsTo(container);
  22391. return {
  22392. y: me.calcScrollPos(offsets[1] + scrollY, dom.offsetHeight, scrollY, clientHeight, align.y),
  22393. x: me.calcScrollPos(offsets[0] + scrollX, dom.offsetWidth, scrollX, clientWidth, align.x)
  22394. };
  22395. },
  22396. calcScrollPos: function(start, size, viewStart, viewSize, align) {
  22397. var end = start + size,
  22398. viewEnd = viewStart + viewSize,
  22399. force = align && !endsQuestionRe.test(align),
  22400. ret = viewStart;
  22401. if (!force) {
  22402. if (align) {
  22403. align = align.slice(0, -1);
  22404. }
  22405. if (size > viewSize || start < viewStart) {
  22406. align = align || 'start';
  22407. force = true;
  22408. } else if (end > viewEnd) {
  22409. align = align || 'end';
  22410. force = true;
  22411. }
  22412. }
  22413. if (force) {
  22414. if (align === 'start') {
  22415. ret = start;
  22416. } else if (align === 'center') {
  22417. ret = Math.max(0, start - Math.floor((viewSize / 2)));
  22418. } else if (align === 'end') {
  22419. ret = Math.max(0, end - viewSize);
  22420. }
  22421. }
  22422. return ret;
  22423. },
  22424. getScrollLeft: function() {
  22425. var dom = this.dom;
  22426. if (dom === DOC || dom === DOC.body) {
  22427. return this.getScroll().left;
  22428. } else {
  22429. return dom.scrollLeft;
  22430. }
  22431. },
  22432. getScrollTop: function() {
  22433. var dom = this.dom;
  22434. if (dom === DOC || dom === DOC.body) {
  22435. return this.getScroll().top;
  22436. } else {
  22437. return dom.scrollTop;
  22438. }
  22439. },
  22440. getSize: function(contentSize) {
  22441. return {
  22442. width: this.getWidth(contentSize),
  22443. height: this.getHeight(contentSize)
  22444. };
  22445. },
  22446. getStyle: function(property, inline) {
  22447. var me = this,
  22448. dom = me.dom,
  22449. multiple = typeof property !== 'string',
  22450. hooks = me.styleHooks,
  22451. prop = property,
  22452. props = prop,
  22453. len = 1,
  22454. domStyle, camel, values, hook, out, style, i;
  22455. if (multiple) {
  22456. values = {};
  22457. prop = props[0];
  22458. i = 0;
  22459. if (!(len = props.length)) {
  22460. return values;
  22461. }
  22462. }
  22463. if (!dom || dom.documentElement) {
  22464. return values || '';
  22465. }
  22466. domStyle = dom.style;
  22467. if (inline) {
  22468. style = domStyle;
  22469. } else {
  22470. style = dom.ownerDocument.defaultView.getComputedStyle(dom, null);
  22471. if (!style) {
  22472. inline = true;
  22473. style = domStyle;
  22474. }
  22475. }
  22476. do {
  22477. hook = hooks[prop];
  22478. if (!hook) {
  22479. hooks[prop] = hook = {
  22480. name: Element.normalize(prop)
  22481. };
  22482. }
  22483. if (hook.get) {
  22484. out = hook.get(dom, me, inline, style);
  22485. } else {
  22486. camel = hook.name;
  22487. out = style[camel];
  22488. }
  22489. if (!multiple) {
  22490. return out;
  22491. }
  22492. values[prop] = out;
  22493. prop = props[++i];
  22494. } while (i < len);
  22495. return values;
  22496. },
  22497. getStyleValue: function(name) {
  22498. return this.dom.style.getPropertyValue(name);
  22499. },
  22500. getCaretPos: function() {
  22501. var dom = this.dom,
  22502. pos, selection;
  22503. if (inputTypeSelectionSupported.test(dom.type)) {
  22504. pos = dom.selectionStart;
  22505. selection = (typeof pos !== 'number') && this.getTextSelection();
  22506. if (selection) {
  22507. pos = selection[0];
  22508. }
  22509. } else
  22510. {
  22511. Ext.raise('Input type of "' + dom.type + '" does not support selectionStart');
  22512. }
  22513. return pos;
  22514. },
  22515. setCaretPos: function(pos) {
  22516. this.selectText(pos, pos);
  22517. },
  22518. getTextSelection: function() {
  22519. var dom = this.dom;
  22520. if (inputTypeSelectionSupported.test(dom.type)) {
  22521. return [
  22522. dom.selectionStart,
  22523. dom.selectionEnd,
  22524. dom.selectionDirection
  22525. ];
  22526. } else {
  22527. Ext.raise('Input type of "' + this.dom.type + '" does not support selectionStart, selectionEnd and selectionDirection');
  22528. return [];
  22529. }
  22530. },
  22531. selectText: function(start, end, direction) {
  22532. var me = this,
  22533. range,
  22534. dom = me.dom,
  22535. len;
  22536. if (dom && inputTypeSelectionSupported.test(dom.type)) {
  22537. start = start || 0;
  22538. len = dom.value.length;
  22539. if (end === undefined) {
  22540. end = len;
  22541. }
  22542. direction = selectDir[direction] || direction || 'forward';
  22543. if (dom.setSelectionRange) {
  22544. dom.setSelectionRange(start, end, direction);
  22545. }
  22546. else if (dom.createTextRange) {
  22547. if (start > end) {
  22548. start = end;
  22549. }
  22550. range = dom.createTextRange();
  22551. range.moveStart('character', start);
  22552. range.moveEnd('character', -(len - end));
  22553. range.select();
  22554. }
  22555. }
  22556. else if (!inputTypeSelectionSupported.test(dom.type)) {
  22557. Ext.raise('Input type of "' + dom.type + '" does not support setSelectionRange');
  22558. }
  22559. return me;
  22560. },
  22561. getTop: function(local) {
  22562. return local ? this.getLocalY() : this.getY();
  22563. },
  22564. getTouchAction: function() {
  22565. return Ext.dom.TouchAction.get(this.dom);
  22566. },
  22567. getValue: function(asNumber) {
  22568. var value = this.dom.value;
  22569. return asNumber ? parseInt(value, 10) : value;
  22570. },
  22571. getViewSize: function() {
  22572. var dom = this.dom;
  22573. if (dom === DOC || dom === DOC.body) {
  22574. return {
  22575. width: Element.getViewportWidth(),
  22576. height: Element.getViewportHeight()
  22577. };
  22578. } else {
  22579. return {
  22580. width: dom.clientWidth,
  22581. height: dom.clientHeight
  22582. };
  22583. }
  22584. },
  22585. getVisibilityMode: function() {
  22586. var me = this,
  22587. data = me.getData(),
  22588. mode = data.visibilityMode;
  22589. if (mode === undefined) {
  22590. data.visibilityMode = mode = Element.DISPLAY;
  22591. }
  22592. return mode;
  22593. },
  22594. getWidth: function(contentWidth, preciseWidth) {
  22595. var me = this,
  22596. dom = me.dom,
  22597. hidden = me.isStyle('display', 'none'),
  22598. rect, width, floating;
  22599. if (hidden) {
  22600. return 0;
  22601. }
  22602. if (Ext.supports.BoundingClientRect) {
  22603. rect = dom.getBoundingClientRect();
  22604. width = (me.vertical && !Ext.supports.RotatedBoundingClientRect) ? (rect.bottom - rect.top) : (rect.right - rect.left);
  22605. width = preciseWidth ? width : Math.ceil(width);
  22606. } else {
  22607. width = dom.offsetWidth;
  22608. }
  22609. if (Ext.supports.Direct2DBug && !me.vertical) {
  22610. floating = me.adjustDirect2DDimension(WIDTH);
  22611. if (preciseWidth) {
  22612. width += floating;
  22613. }
  22614. else if (floating > 0 && floating < 0.5) {
  22615. width++;
  22616. }
  22617. }
  22618. if (contentWidth) {
  22619. width -= me.getBorderWidth("lr") + me.getPadding("lr");
  22620. }
  22621. return (width < 0) ? 0 : width;
  22622. },
  22623. getX: function() {
  22624. return this.getXY()[0];
  22625. },
  22626. getXY: function() {
  22627. var round = Math.round,
  22628. dom = this.dom,
  22629. body = DOC.body,
  22630. x = 0,
  22631. y = 0,
  22632. bodyRect, rect;
  22633. if (dom !== DOC && dom !== body) {
  22634. try {
  22635. bodyRect = body.getBoundingClientRect();
  22636. rect = dom.getBoundingClientRect();
  22637. x = rect.left - bodyRect.left;
  22638. y = rect.top - bodyRect.top;
  22639. } catch (ex) {}
  22640. }
  22641. return [
  22642. round(x),
  22643. round(y)
  22644. ];
  22645. },
  22646. getY: function() {
  22647. return this.getXY()[1];
  22648. },
  22649. getZIndex: function() {
  22650. return parseInt(this.getStyle('z-index'), 10);
  22651. },
  22652. hasCls: function(name) {
  22653. var classMap = this.getClassMap();
  22654. return classMap.hasOwnProperty(name);
  22655. },
  22656. hide: function() {
  22657. return this.setVisible(false);
  22658. },
  22659. hover: function(overFn, outFn, scope, options) {
  22660. var me = this;
  22661. me.on('mouseenter', overFn, scope || me.dom, options);
  22662. me.on('mouseleave', outFn, scope || me.dom, options);
  22663. return me;
  22664. },
  22665. indexOf: function(childEl) {
  22666. var children = this.dom,
  22667. c = childEl && Ext.getDom(childEl);
  22668. children = children && children.childNodes;
  22669. return (c && children) ? Array.prototype.indexOf.call(children, c) : -1;
  22670. },
  22671. insertAfter: function(el) {
  22672. el = Ext.getDom(el);
  22673. el.parentNode.insertBefore(this.dom, el.nextSibling);
  22674. return this;
  22675. },
  22676. insertBefore: function(el) {
  22677. el = Ext.getDom(el);
  22678. el.parentNode.insertBefore(this.dom, el);
  22679. return this;
  22680. },
  22681. insertFirst: function(el, returnDom) {
  22682. el = el || {};
  22683. if (el.nodeType || el.dom || typeof el === 'string') {
  22684. el = Ext.getDom(el);
  22685. this.dom.insertBefore(el, this.dom.firstChild);
  22686. return !returnDom ? Ext.get(el) : el;
  22687. } else {
  22688. return this.createChild(el, this.dom.firstChild, returnDom);
  22689. }
  22690. },
  22691. insertHtml: function(where, html, returnEl) {
  22692. var el = Ext.DomHelper.insertHtml(where, this.dom, html);
  22693. return returnEl ? Ext.get(el) : el;
  22694. },
  22695. insertSibling: function(el, where, returnDom) {
  22696. var me = this,
  22697. DomHelper = Ext.DomHelper,
  22698. isAfter = (where || 'before').toLowerCase() === 'after',
  22699. rt, insertEl, eLen, e;
  22700. if (Ext.isIterable(el)) {
  22701. eLen = el.length;
  22702. insertEl = Ext.fly(DOC.createDocumentFragment());
  22703. if (Ext.isArray(el)) {
  22704. for (e = 0; e < eLen; e++) {
  22705. rt = insertEl.appendChild(el[e], returnDom);
  22706. }
  22707. } else
  22708. {
  22709. for (e = 0; e < eLen; e++) {
  22710. insertEl.dom.appendChild(rt = el[0]);
  22711. }
  22712. if (returnDom === false) {
  22713. rt = Ext.get(rt);
  22714. }
  22715. }
  22716. me.dom.parentNode.insertBefore(insertEl.dom, isAfter ? me.dom.nextSibling : me.dom);
  22717. return rt;
  22718. }
  22719. el = el || {};
  22720. if (el.nodeType || el.dom) {
  22721. rt = me.dom.parentNode.insertBefore(Ext.getDom(el), isAfter ? me.dom.nextSibling : me.dom);
  22722. if (!returnDom) {
  22723. rt = Ext.get(rt);
  22724. }
  22725. } else {
  22726. if (isAfter && !me.dom.nextSibling) {
  22727. rt = DomHelper.append(me.dom.parentNode, el, !returnDom);
  22728. } else {
  22729. rt = DomHelper[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
  22730. }
  22731. }
  22732. return rt;
  22733. },
  22734. is: function(selector) {
  22735. var dom = this.dom,
  22736. is;
  22737. if (!selector) {
  22738. is = true;
  22739. } else if (!dom.tagName) {
  22740. is = false;
  22741. } else if (Ext.isFunction(selector)) {
  22742. is = selector(dom);
  22743. } else {
  22744. is = dom[Ext.supports.matchesSelector](selector);
  22745. }
  22746. return is;
  22747. },
  22748. isAncestor: function(el) {
  22749. var ret = false,
  22750. dom = this.dom,
  22751. child = Ext.getDom(el);
  22752. if (dom && child) {
  22753. if (!child.nodeType) {
  22754. return false;
  22755. }
  22756. if (dom.contains) {
  22757. return dom.contains(child);
  22758. } else if (dom.compareDocumentPosition) {
  22759. return !!(dom.compareDocumentPosition(child) & 16);
  22760. } else {
  22761. while ((child = child.parentNode)) {
  22762. ret = child === dom || ret;
  22763. }
  22764. }
  22765. }
  22766. return ret;
  22767. },
  22768. isPainted: (function() {
  22769. return !Ext.browser.is.IE ? function() {
  22770. var dom = this.dom;
  22771. return Boolean(dom && dom.offsetParent);
  22772. } : function() {
  22773. var dom = this.dom;
  22774. return Boolean(dom && (dom.offsetHeight !== 0 || dom.offsetWidth !== 0));
  22775. };
  22776. })(),
  22777. isScrollable: function() {
  22778. var dom = this.dom;
  22779. return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
  22780. },
  22781. isStyle: function(style, val) {
  22782. return this.getStyle(style) === val;
  22783. },
  22784. isVisible: function(deep, mode) {
  22785. var dom = this.dom,
  22786. visible = true,
  22787. end;
  22788. if (!dom) {
  22789. return false;
  22790. }
  22791. mode = mode || 3;
  22792. if (!visFly) {
  22793. visFly = new Ext.dom.Fly();
  22794. }
  22795. for (end = dom.ownerDocument.documentElement; dom !== end; dom = dom.parentNode) {
  22796. if (!dom || dom.nodeType === 11) {
  22797. visible = false;
  22798. }
  22799. if (visible) {
  22800. visFly.attach(dom);
  22801. if (mode & 1) {
  22802. visible = !visFly.isStyle(DISPLAY, NONE);
  22803. }
  22804. if (visible && (mode & 2)) {
  22805. visible = !visFly.isStyle(VISIBILITY, HIDDEN);
  22806. }
  22807. }
  22808. if (!visible || !deep) {
  22809. break;
  22810. }
  22811. }
  22812. return visible;
  22813. },
  22814. last: function(selector, returnDom) {
  22815. return this.matchNode('previousSibling', 'lastChild', selector, returnDom);
  22816. },
  22817. matchNode: function(dir, start, selector, returnDom) {
  22818. var dom = this.dom,
  22819. n;
  22820. if (!dom) {
  22821. return null;
  22822. }
  22823. n = dom[start];
  22824. while (n) {
  22825. if (n.nodeType === 1 && (!selector || Ext.fly(n, '_matchNode').is(selector))) {
  22826. return !returnDom ? Ext.get(n) : n;
  22827. }
  22828. n = n[dir];
  22829. }
  22830. return null;
  22831. },
  22832. measure: function(dimension) {
  22833. var me = this,
  22834. dom = me.dom,
  22835. includeWidth = dimension !== 'h',
  22836. includeHeight = dimension !== 'w',
  22837. width = 0,
  22838. height = 0,
  22839. addPadding = !Ext.supports.ComputedSizeIncludesPadding,
  22840. style, rect, offsetParent;
  22841. if (dom.nodeName === 'BODY') {
  22842. height = includeHeight && Element.getViewportHeight();
  22843. width = includeWidth && Element.getViewportWidth();
  22844. } else {
  22845. offsetParent = dom.offsetParent;
  22846. style = dom.ownerDocument.defaultView.getComputedStyle(dom, null);
  22847. addPadding |= style.boxSizing === 'content-box';
  22848. if (offsetParent !== null || style.position === 'fixed') {
  22849. if (includeHeight) {
  22850. height = toFloat(style.height);
  22851. if (addPadding) {
  22852. height += toFloat(style.paddingTop) + toFloat(style.paddingBottom) + toFloat(style.borderTopWidth) + toFloat(style.borderBottomWidth);
  22853. }
  22854. }
  22855. if (includeWidth) {
  22856. width = toFloat(style.width);
  22857. if (addPadding) {
  22858. width += toFloat(style.paddingLeft) + toFloat(style.paddingRight) + toFloat(style.borderLeftWidth) + toFloat(style.borderRightWidth);
  22859. }
  22860. }
  22861. }
  22862. }
  22863. rect = dimension ? null : {
  22864. width: width,
  22865. height: height
  22866. };
  22867. return dimension ? (includeWidth ? width : height) : rect;
  22868. },
  22869. measureContent: function(dimension) {
  22870. var me = this,
  22871. includeWidth = dimension !== 'h',
  22872. size = me.measure(dimension),
  22873. h = dimension ? size : size.height,
  22874. w = dimension ? size : size.width;
  22875. if (dimension !== 'w') {
  22876. h -= me.getBorderWidth('tb') + me.getPadding('tb');
  22877. }
  22878. if (includeWidth) {
  22879. w -= me.getBorderWidth('lr') + me.getPadding('lr');
  22880. }
  22881. return dimension ? (includeWidth ? w : h) : {
  22882. width: w,
  22883. height: h
  22884. };
  22885. },
  22886. monitorMouseLeave: function(delay, handler, scope) {
  22887. var me = this,
  22888. timer,
  22889. listeners = {
  22890. mouseleave: function(e) {
  22891. if (Ext.isIE9m) {
  22892. e.enableIEAsync();
  22893. }
  22894. timer = Ext.defer(handler, delay, scope || me, [
  22895. e
  22896. ]);
  22897. },
  22898. mouseenter: function() {
  22899. Ext.undefer(timer);
  22900. },
  22901. destroy: function() {
  22902. Ext.undefer(timer);
  22903. if (!me.destroyed) {
  22904. me.un(listeners);
  22905. }
  22906. }
  22907. };
  22908. me.on(listeners);
  22909. return listeners;
  22910. },
  22911. next: function(selector, returnDom) {
  22912. return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);
  22913. },
  22914. parent: function(selector, returnDom) {
  22915. return this.matchNode('parentNode', 'parentNode', selector, returnDom);
  22916. },
  22917. peekData: function() {
  22918. var dom = this.dom;
  22919. return dom && dom._extData || null;
  22920. },
  22921. position: function(pos, zIndex, x, y) {
  22922. var me = this;
  22923. if (me.dom.tagName !== 'BODY') {
  22924. if (!pos && me.isStyle(POSITION, STATIC)) {
  22925. me.setStyle(POSITION, RELATIVE);
  22926. } else if (pos) {
  22927. me.setStyle(POSITION, pos);
  22928. }
  22929. if (zIndex) {
  22930. me.setStyle(ZINDEX, zIndex);
  22931. }
  22932. if (x || y) {
  22933. me.setXY([
  22934. x || false,
  22935. y || false
  22936. ]);
  22937. }
  22938. }
  22939. },
  22940. prev: function(selector, returnDom) {
  22941. return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);
  22942. },
  22943. query: function(selector, asDom, single) {
  22944. var dom = this.dom,
  22945. results, len, nlen, node, nodes, i, j;
  22946. if (!dom) {
  22947. return null;
  22948. }
  22949. asDom = (asDom !== false);
  22950. selector = selector.split(",");
  22951. if (!single) {
  22952. results = [];
  22953. }
  22954. for (i = 0 , len = selector.length; i < len; i++) {
  22955. if (typeof selector[i] === 'string') {
  22956. if (single) {
  22957. node = dom.querySelector(selector[i]);
  22958. return asDom ? node : Ext.get(node);
  22959. }
  22960. nodes = dom.querySelectorAll(selector[i]);
  22961. for (j = 0 , nlen = nodes.length; j < nlen; j++) {
  22962. results.push(asDom ? nodes[j] : Ext.get(nodes[j]));
  22963. }
  22964. }
  22965. }
  22966. return results;
  22967. },
  22968. radioCls: function(className) {
  22969. var cn = this.dom.parentNode.childNodes,
  22970. v, i, len;
  22971. className = Ext.isArray(className) ? className : [
  22972. className
  22973. ];
  22974. for (i = 0 , len = cn.length; i < len; i++) {
  22975. v = cn[i];
  22976. if (v && v.nodeType === 1) {
  22977. Ext.fly(v).removeCls(className);
  22978. }
  22979. }
  22980. return this.addCls(className);
  22981. },
  22982. redraw: function() {
  22983. var dom = this.dom,
  22984. domStyle = dom.style;
  22985. domStyle.display = 'none';
  22986. dom.offsetHeight;
  22987. domStyle.display = '';
  22988. },
  22989. remove: function() {
  22990. this.destroy();
  22991. },
  22992. removeChild: function(element) {
  22993. this.dom.removeChild(Ext.getDom(element));
  22994. return this;
  22995. },
  22996. removeCls: function(names, prefix, suffix) {
  22997. return this.replaceCls(names, null, prefix, suffix);
  22998. },
  22999. repaint: function(cls, state) {
  23000. var me = this,
  23001. off, on;
  23002. if (!cls) {
  23003. cls = Ext.baseCSSPrefix + 'repaint';
  23004. on = !(off = false);
  23005. } else if (state != null) {
  23006. on = state;
  23007. off = !state;
  23008. }
  23009. me.toggleCls(cls, on);
  23010. if (!me.repaintTimer) {
  23011. me.repaintTimer = Ext.defer(function() {
  23012. me.repaintTimer = null;
  23013. if (me.dom) {
  23014. me.toggleCls(cls, off);
  23015. }
  23016. }, 1);
  23017. }
  23018. return me;
  23019. },
  23020. replace: function(el, destroy) {
  23021. el = Ext.getDom(el);
  23022. var parentNode = el.parentNode,
  23023. id = el.id,
  23024. dom = this.dom;
  23025. if (!parentNode) {
  23026. Ext.raise('Cannot replace element "' + id + '". It is not attached to a parent node.');
  23027. }
  23028. if (destroy !== false && id && Ext.cache[id]) {
  23029. parentNode.insertBefore(dom, el);
  23030. Ext.get(el).destroy();
  23031. } else {
  23032. parentNode.replaceChild(dom, el);
  23033. }
  23034. return this;
  23035. },
  23036. replaceCls: function(remove, add, prefix, suffix) {
  23037. var me = this,
  23038. dom = me.dom,
  23039. added = 0,
  23040. removed = 0,
  23041. rem = remove,
  23042. data = (add || remove) && me.getData(),
  23043. list, map, i, n, name;
  23044. if (data) {
  23045. list = data.classList;
  23046. map = data.classMap;
  23047. add = add ? ((typeof add === 'string') ? add.split(spacesRe) : add) : EMPTY;
  23048. rem = rem ? ((typeof rem === 'string') ? rem.split(spacesRe) : rem) : EMPTY;
  23049. prefix = prefix || '';
  23050. if (prefix && prefix[prefix.length - 1] !== '-') {
  23051. prefix += '-';
  23052. }
  23053. suffix = suffix || '';
  23054. if (suffix && suffix[0] !== '-') {
  23055. suffix = '-' + suffix;
  23056. }
  23057. for (i = 0 , n = rem.length; i < n; i++) {
  23058. if (!(name = rem[i])) {
  23059. continue;
  23060. }
  23061. name = prefix + name + suffix;
  23062. if (spacesRe.test(name)) {
  23063. Ext.raise('Class names in arrays must not contain spaces');
  23064. }
  23065. if (map[name]) {
  23066. delete map[name];
  23067. ++removed;
  23068. }
  23069. }
  23070. for (i = 0 , n = add.length; i < n; i++) {
  23071. if (!(name = add[i])) {
  23072. continue;
  23073. }
  23074. name = prefix + name + suffix;
  23075. if (spacesRe.test(name)) {
  23076. Ext.raise('Class names in arrays must not contain spaces');
  23077. }
  23078. if (!map[name]) {
  23079. map[name] = true;
  23080. if (!removed) {
  23081. list.push(name);
  23082. ++added;
  23083. }
  23084. }
  23085. }
  23086. if (removed) {
  23087. me.setClassMap(map,
  23088. true);
  23089. } else if (added) {
  23090. list = list.join(' ');
  23091. if (!Ext.isIE8 && dom instanceof SVGElement) {
  23092. dom.setAttribute('class', list);
  23093. } else {
  23094. dom.className = list;
  23095. }
  23096. }
  23097. }
  23098. return me;
  23099. },
  23100. replaceWith: function(el) {
  23101. var me = this,
  23102. dom = me.dom,
  23103. parent = dom.parentNode,
  23104. cache = Ext.cache,
  23105. newDom;
  23106. me.clearListeners();
  23107. if (el.nodeType || el.dom || typeof el === 'string') {
  23108. el = Ext.get(el);
  23109. newDom = parent.insertBefore(el.dom, dom);
  23110. } else {
  23111. newDom = Ext.DomHelper.insertBefore(dom, el);
  23112. }
  23113. parent.removeChild(dom);
  23114. me.dom = newDom;
  23115. if (!me.isFly) {
  23116. delete cache[me.id];
  23117. cache[me.id = Ext.id(newDom)] = me;
  23118. }
  23119. return me;
  23120. },
  23121. resolveListenerScope: function(defaultScope) {
  23122. var component = this.component;
  23123. return component ? component.resolveListenerScope(defaultScope) : this;
  23124. },
  23125. scroll: function(direction, distance, animate) {
  23126. if (!this.isScrollable()) {
  23127. return false;
  23128. }
  23129. direction = direction.charAt(0);
  23130. var me = this,
  23131. dom = me.dom,
  23132. side = direction === 'r' || direction === 'l' ? 'left' : 'top',
  23133. scrolled = false,
  23134. currentScroll, constrainedScroll;
  23135. if (direction === 'l' || direction === 't' || direction === 'u') {
  23136. distance = -distance;
  23137. }
  23138. if (side === 'left') {
  23139. currentScroll = dom.scrollLeft;
  23140. constrainedScroll = me.constrainScrollLeft(currentScroll + distance);
  23141. } else {
  23142. currentScroll = dom.scrollTop;
  23143. constrainedScroll = me.constrainScrollTop(currentScroll + distance);
  23144. }
  23145. if (constrainedScroll !== currentScroll) {
  23146. this.scrollTo(side, constrainedScroll, animate);
  23147. scrolled = true;
  23148. }
  23149. return scrolled;
  23150. },
  23151. scrollBy: function(deltaX, deltaY, animate) {
  23152. var me = this,
  23153. dom = me.dom;
  23154. if (deltaX.length) {
  23155. animate = deltaY;
  23156. deltaY = deltaX[1];
  23157. deltaX = deltaX[0];
  23158. } else if (typeof deltaX !== 'number') {
  23159. animate = deltaY;
  23160. deltaY = deltaX.y;
  23161. deltaX = deltaX.x;
  23162. }
  23163. if (deltaX) {
  23164. me.scrollTo('left', me.constrainScrollLeft(dom.scrollLeft + deltaX), animate);
  23165. }
  23166. if (deltaY) {
  23167. me.scrollTo('top', me.constrainScrollTop(dom.scrollTop + deltaY), animate);
  23168. }
  23169. return me;
  23170. },
  23171. scrollChildIntoView: function(child, hscroll) {
  23172. Ext.fly(child).scrollIntoView(this, hscroll);
  23173. },
  23174. scrollIntoView: function(container, hscroll, animate, highlight) {
  23175. container = Ext.getDom(container) || Ext.getBody().dom;
  23176. return this.doScrollIntoView(container, hscroll, animate, highlight, 'getScrollLeft', 'scrollTo');
  23177. },
  23178. scrollTo: function(side, value, animate) {
  23179. var top = topRe.test(side),
  23180. me = this,
  23181. prop = top ? 'scrollTop' : 'scrollLeft',
  23182. dom = me.dom,
  23183. animCfg;
  23184. if (!animate || !me.anim) {
  23185. dom[prop] = value;
  23186. dom[prop] = value;
  23187. } else {
  23188. animCfg = {
  23189. to: {}
  23190. };
  23191. animCfg.to[prop] = value;
  23192. if (Ext.isObject(animate)) {
  23193. Ext.applyIf(animCfg, animate);
  23194. }
  23195. me.animate(animCfg);
  23196. }
  23197. return me;
  23198. },
  23199. select: function(selector, composite) {
  23200. var isElementArray, elements;
  23201. if (typeof selector === "string") {
  23202. elements = this.query(selector, !composite);
  23203. }
  23204. else if (selector.length === undefined) {
  23205. Ext.raise("Invalid selector specified: " + selector);
  23206. } else
  23207. {
  23208. elements = selector;
  23209. isElementArray = true;
  23210. }
  23211. return composite ? new Ext.CompositeElement(elements, !isElementArray) : new Ext.CompositeElementLite(elements, true);
  23212. },
  23213. selectNode: function(selector, asDom) {
  23214. return this.query(selector, asDom, true);
  23215. },
  23216. set: function(attributes, useSet) {
  23217. var me = this,
  23218. dom = me.dom,
  23219. attribute, value;
  23220. for (attribute in attributes) {
  23221. if (attributes.hasOwnProperty(attribute)) {
  23222. value = attributes[attribute];
  23223. if (attribute === 'style') {
  23224. me.applyStyles(value);
  23225. } else if (attribute === 'cls') {
  23226. dom.className = value;
  23227. } else if (useSet !== false) {
  23228. if (value === undefined) {
  23229. dom.removeAttribute(attribute);
  23230. } else {
  23231. dom.setAttribute(attribute, value);
  23232. }
  23233. } else {
  23234. dom[attribute] = value;
  23235. }
  23236. }
  23237. }
  23238. return me;
  23239. },
  23240. setBottom: function(bottom) {
  23241. this.dom.style[BOTTOM] = Element.addUnits(bottom);
  23242. return this;
  23243. },
  23244. setClassMap: function(classMap, keep) {
  23245. var data = this.getData(
  23246. false),
  23247. classList;
  23248. if (data) {
  23249. classMap = (keep && classMap) || Ext.apply({}, classMap);
  23250. data.classMap = classMap;
  23251. data.classList = classList = Ext.Object.getKeys(classMap);
  23252. data.isSynchronized = true;
  23253. this.dom.className = classList.join(' ');
  23254. }
  23255. },
  23256. setCls: function(className) {
  23257. var me = this,
  23258. elementData = me.getData(
  23259. false),
  23260. i, ln, map, classList;
  23261. if (typeof className === 'string') {
  23262. className = className.split(spacesRe);
  23263. }
  23264. elementData.classList = classList = className.slice();
  23265. elementData.classMap = map = {};
  23266. for (i = 0 , ln = classList.length; i < ln; i++) {
  23267. map[classList[i]] = true;
  23268. }
  23269. me.dom.className = classList.join(' ');
  23270. },
  23271. setDisplayed: function(value) {
  23272. var me = this;
  23273. if (typeof value === "boolean") {
  23274. value = value ? me._getDisplay() : NONE;
  23275. }
  23276. me.setStyle(DISPLAY, value);
  23277. if (me.shadow || me.shim) {
  23278. me.setUnderlaysVisible(value !== NONE);
  23279. }
  23280. return me;
  23281. },
  23282. setHeight: function(height) {
  23283. var me = this;
  23284. me.dom.style[HEIGHT] = Element.addUnits(height);
  23285. if (me.shadow || me.shim) {
  23286. me.syncUnderlays();
  23287. }
  23288. return me;
  23289. },
  23290. setHtml: function(html) {
  23291. if (this.dom) {
  23292. this.dom.innerHTML = html;
  23293. }
  23294. return this;
  23295. },
  23296. setId: function(id) {
  23297. var me = this,
  23298. currentId = me.id,
  23299. cache = Ext.cache;
  23300. if (currentId) {
  23301. delete cache[currentId];
  23302. }
  23303. me.dom.id = id;
  23304. me.id = id;
  23305. cache[id] = me;
  23306. return me;
  23307. },
  23308. setLeft: function(left) {
  23309. var me = this;
  23310. me.dom.style[LEFT] = Element.addUnits(left);
  23311. if (me.shadow || me.shim) {
  23312. me.syncUnderlays();
  23313. }
  23314. return me;
  23315. },
  23316. setLocalX: function(x) {
  23317. var me = this,
  23318. style = me.dom.style;
  23319. style.right = '';
  23320. style.left = (x === null) ? 'auto' : x + 'px';
  23321. if (me.shadow || me.shim) {
  23322. me.syncUnderlays();
  23323. }
  23324. return me;
  23325. },
  23326. setLocalXY: function(x, y) {
  23327. var me = this,
  23328. style = me.dom.style;
  23329. style.right = '';
  23330. if (x && x.length) {
  23331. y = x[1];
  23332. x = x[0];
  23333. }
  23334. if (x === null) {
  23335. style.left = 'auto';
  23336. } else if (x !== undefined) {
  23337. style.left = x + 'px';
  23338. }
  23339. if (y === null) {
  23340. style.top = 'auto';
  23341. } else if (y !== undefined) {
  23342. style.top = y + 'px';
  23343. }
  23344. if (me.shadow || me.shim) {
  23345. me.syncUnderlays();
  23346. }
  23347. return me;
  23348. },
  23349. setLocalY: function(y) {
  23350. var me = this;
  23351. me.dom.style.top = (y === null) ? 'auto' : y + 'px';
  23352. if (me.shadow || me.shim) {
  23353. me.syncUnderlays();
  23354. }
  23355. return me;
  23356. },
  23357. setMargin: function(margin) {
  23358. var me = this,
  23359. domStyle = me.dom.style;
  23360. if (margin || margin === 0) {
  23361. margin = me.self.unitizeBox((margin === true) ? 5 : margin);
  23362. domStyle.setProperty('margin', margin, 'important');
  23363. } else {
  23364. domStyle.removeProperty('margin-top');
  23365. domStyle.removeProperty('margin-right');
  23366. domStyle.removeProperty('margin-bottom');
  23367. domStyle.removeProperty('margin-left');
  23368. }
  23369. },
  23370. setMaxHeight: function(height) {
  23371. this.dom.style[MAX_HEIGHT] = Element.addUnits(height);
  23372. return this;
  23373. },
  23374. setMaxWidth: function(width) {
  23375. this.dom.style[MAX_WIDTH] = Element.addUnits(width);
  23376. return this;
  23377. },
  23378. setMinHeight: function(height) {
  23379. this.dom.style[MIN_HEIGHT] = Element.addUnits(height);
  23380. return this;
  23381. },
  23382. setMinWidth: function(width) {
  23383. this.dom.style[MIN_WIDTH] = Element.addUnits(width);
  23384. return this;
  23385. },
  23386. setOpacity: function(opacity) {
  23387. var me = this;
  23388. if (me.dom) {
  23389. me.setStyle('opacity', opacity);
  23390. }
  23391. return me;
  23392. },
  23393. setPadding: function(padding) {
  23394. var me = this,
  23395. domStyle = me.dom.style;
  23396. if (padding || padding === 0) {
  23397. padding = me.self.unitizeBox((padding === true) ? 5 : padding);
  23398. domStyle.setProperty('padding', padding, 'important');
  23399. } else {
  23400. domStyle.removeProperty('padding-top');
  23401. domStyle.removeProperty('padding-right');
  23402. domStyle.removeProperty('padding-bottom');
  23403. domStyle.removeProperty('padding-left');
  23404. }
  23405. },
  23406. setRight: function(right) {
  23407. this.dom.style[RIGHT] = Element.addUnits(right);
  23408. return this;
  23409. },
  23410. setScrollLeft: function(left) {
  23411. this.dom.scrollLeft = left;
  23412. return this;
  23413. },
  23414. setScrollTop: function(top) {
  23415. this.dom.scrollTop = top;
  23416. return this;
  23417. },
  23418. setSize: function(width, height) {
  23419. var me = this,
  23420. style = me.dom.style;
  23421. if (Ext.isObject(width)) {
  23422. height = width.height;
  23423. width = width.width;
  23424. }
  23425. if (width !== undefined) {
  23426. style.width = Element.addUnits(width);
  23427. }
  23428. if (height !== undefined) {
  23429. style.height = Element.addUnits(height);
  23430. }
  23431. if (me.shadow || me.shim) {
  23432. me.syncUnderlays();
  23433. }
  23434. return me;
  23435. },
  23436. setStyle: function(prop, value) {
  23437. var me = this,
  23438. dom = me.dom,
  23439. hooks = me.styleHooks,
  23440. style = dom.style,
  23441. name = prop,
  23442. hook;
  23443. if (typeof name === 'string') {
  23444. hook = hooks[name];
  23445. if (!hook) {
  23446. hooks[name] = hook = {
  23447. name: Element.normalize(name)
  23448. };
  23449. }
  23450. value = (value == null) ? '' : value;
  23451. if (hook.set) {
  23452. hook.set(dom, value, me);
  23453. } else {
  23454. style[hook.name] = value;
  23455. }
  23456. if (hook.afterSet) {
  23457. hook.afterSet(dom, value, me);
  23458. }
  23459. } else {
  23460. for (name in prop) {
  23461. hook = hooks[name];
  23462. if (!hook) {
  23463. hooks[name] = hook = {
  23464. name: Element.normalize(name)
  23465. };
  23466. }
  23467. value = prop[name];
  23468. value = (value == null) ? '' : value;
  23469. if (hook.set) {
  23470. hook.set(dom, value, me);
  23471. } else {
  23472. style[hook.name] = value;
  23473. }
  23474. if (hook.afterSet) {
  23475. hook.afterSet(dom, value, me);
  23476. }
  23477. }
  23478. }
  23479. return me;
  23480. },
  23481. setText: function(text) {
  23482. this.dom.textContent = text;
  23483. },
  23484. getText: function() {
  23485. return this.dom.textContent;
  23486. },
  23487. setTop: function(top) {
  23488. var me = this;
  23489. me.dom.style[TOP] = Element.addUnits(top);
  23490. if (me.shadow || me.shim) {
  23491. me.syncUnderlays();
  23492. }
  23493. return me;
  23494. },
  23495. setTouchAction: function(touchAction) {
  23496. Ext.dom.TouchAction.set(this.dom, touchAction);
  23497. },
  23498. setUnderlaysVisible: function(visible) {
  23499. var shadow = this.shadow,
  23500. shim = this.shim;
  23501. if (shadow && !shadow.disabled) {
  23502. if (visible) {
  23503. shadow.show();
  23504. } else {
  23505. shadow.hide();
  23506. }
  23507. }
  23508. if (shim && !shim.disabled) {
  23509. if (visible) {
  23510. shim.show();
  23511. } else {
  23512. shim.hide();
  23513. }
  23514. }
  23515. },
  23516. setVisibility: function(isVisible) {
  23517. var domStyle = this.dom.style;
  23518. if (isVisible) {
  23519. domStyle.removeProperty('visibility');
  23520. } else {
  23521. domStyle.setProperty('visibility', 'hidden', 'important');
  23522. }
  23523. },
  23524. setVisibilityMode: function(mode) {
  23525. if (mode !== 1 && mode !== 2 && mode !== 3 && mode !== 4 && mode !== 5) {
  23526. Ext.raise("visibilityMode must be one of the following: " + "Ext.Element.DISPLAY, Ext.Element.VISIBILITY, Ext.Element.OFFSETS, " + "Ext.Element.CLIP, or Element.OPACITY");
  23527. }
  23528. this.getData().visibilityMode = mode;
  23529. return this;
  23530. },
  23531. setVisible: function(visible) {
  23532. var me = this,
  23533. mode = me.getVisibilityMode(),
  23534. addOrRemove = visible ? 'removeCls' : 'addCls';
  23535. switch (mode) {
  23536. case Element.DISPLAY:
  23537. me.removeCls([
  23538. visibilityCls,
  23539. offsetsCls,
  23540. clipCls,
  23541. opacityCls
  23542. ]);
  23543. me[addOrRemove](displayCls);
  23544. break;
  23545. case Element.VISIBILITY:
  23546. me.removeCls([
  23547. displayCls,
  23548. offsetsCls,
  23549. clipCls,
  23550. opacityCls
  23551. ]);
  23552. me[addOrRemove](visibilityCls);
  23553. break;
  23554. case Element.OFFSETS:
  23555. me.removeCls([
  23556. visibilityCls,
  23557. displayCls,
  23558. clipCls,
  23559. opacityCls
  23560. ]);
  23561. me[addOrRemove](offsetsCls);
  23562. break;
  23563. case Element.CLIP:
  23564. me.removeCls([
  23565. visibilityCls,
  23566. displayCls,
  23567. offsetsCls,
  23568. opacityCls
  23569. ]);
  23570. me[addOrRemove](clipCls);
  23571. break;
  23572. case Element.OPACITY:
  23573. me.removeCls([
  23574. visibilityCls,
  23575. displayCls,
  23576. offsetsCls,
  23577. clipCls
  23578. ]);
  23579. me[addOrRemove](opacityCls);
  23580. break;
  23581. }
  23582. if (me.shadow || me.shim) {
  23583. me.setUnderlaysVisible(visible);
  23584. }
  23585. if (!visible && me.$ripples) {
  23586. me.destroyAllRipples();
  23587. }
  23588. return me;
  23589. },
  23590. setWidth: function(width) {
  23591. var me = this;
  23592. me.dom.style[WIDTH] = Element.addUnits(width);
  23593. if (me.shadow || me.shim) {
  23594. me.syncUnderlays();
  23595. }
  23596. return me;
  23597. },
  23598. setX: function(x) {
  23599. return this.setXY([
  23600. x,
  23601. false
  23602. ]);
  23603. },
  23604. setXY: function(xy) {
  23605. var me = this,
  23606. pts = me.translatePoints(xy),
  23607. style = me.dom.style,
  23608. pos;
  23609. me.position();
  23610. style.right = '';
  23611. for (pos in pts) {
  23612. if (!isNaN(pts[pos])) {
  23613. style[pos] = pts[pos] + 'px';
  23614. }
  23615. }
  23616. if (me.shadow || me.shim) {
  23617. me.syncUnderlays();
  23618. }
  23619. return me;
  23620. },
  23621. setY: function(y) {
  23622. return this.setXY([
  23623. false,
  23624. y
  23625. ]);
  23626. },
  23627. setZIndex: function(zindex) {
  23628. var me = this;
  23629. if (me.shadow) {
  23630. me.shadow.setZIndex(zindex);
  23631. }
  23632. if (me.shim) {
  23633. me.shim.setZIndex(zindex);
  23634. }
  23635. return me.setStyle('z-index', zindex);
  23636. },
  23637. show: function() {
  23638. return this.setVisible(true);
  23639. },
  23640. swallowEvent: function(eventName, preventDefault) {
  23641. var me = this,
  23642. e, eLen,
  23643. listeners = {
  23644. destroyable: true
  23645. },
  23646. fn = function(e) {
  23647. e.stopPropagation();
  23648. if (preventDefault) {
  23649. e.preventDefault();
  23650. }
  23651. };
  23652. if (Ext.isArray(eventName)) {
  23653. eLen = eventName.length;
  23654. for (e = 0; e < eLen; e++) {
  23655. listeners[eventName[e]] = fn;
  23656. }
  23657. } else {
  23658. listeners[eventName] = fn;
  23659. }
  23660. return me.on(listeners);
  23661. },
  23662. swapCls: function(firstClass, secondClass, flag, prefix) {
  23663. if (flag === undefined) {
  23664. flag = true;
  23665. }
  23666. var me = this,
  23667. addedClass = flag ? firstClass : secondClass,
  23668. removedClass = flag ? secondClass : firstClass;
  23669. if (removedClass) {
  23670. me.removeCls(prefix ? prefix + '-' + removedClass : removedClass);
  23671. }
  23672. if (addedClass) {
  23673. me.addCls(prefix ? prefix + '-' + addedClass : addedClass);
  23674. }
  23675. return me;
  23676. },
  23677. synchronize: function() {
  23678. var me = this,
  23679. dom = me.dom,
  23680. hasClassMap = {},
  23681. className = dom.className,
  23682. classList, i, ln, name,
  23683. elementData = me.getData(
  23684. false);
  23685. if (className && className.length > 0) {
  23686. classList = dom.className.split(classNameSplitRegex);
  23687. for (i = 0 , ln = classList.length; i < ln; i++) {
  23688. name = classList[i];
  23689. hasClassMap[name] = true;
  23690. }
  23691. } else {
  23692. classList = [];
  23693. }
  23694. elementData.classList = classList;
  23695. elementData.classMap = hasClassMap;
  23696. elementData.isSynchronized = true;
  23697. return me;
  23698. },
  23699. syncUnderlays: function() {
  23700. var me = this,
  23701. shadow = me.shadow,
  23702. shim = me.shim,
  23703. dom = me.dom,
  23704. xy, x, y, w, h;
  23705. if (me.isVisible()) {
  23706. xy = me.getXY();
  23707. x = xy[0];
  23708. y = xy[1];
  23709. w = dom.offsetWidth;
  23710. h = dom.offsetHeight;
  23711. if (shadow && !shadow.hidden) {
  23712. shadow.realign(x, y, w, h);
  23713. }
  23714. if (shim && !shim.hidden) {
  23715. shim.realign(x, y, w, h);
  23716. }
  23717. }
  23718. },
  23719. toggleCls: function(className, state) {
  23720. if (state == null) {
  23721. state = !this.hasCls(className);
  23722. }
  23723. return state ? this.addCls(className) : this.removeCls(className);
  23724. },
  23725. toggle: function() {
  23726. this.setVisible(!this.isVisible());
  23727. return this;
  23728. },
  23729. translate: function() {
  23730. var transformStyleName = 'webkitTransform' in DOC.createElement('div').style ? 'webkitTransform' : 'transform';
  23731. return function(x, y, z) {
  23732. x = Math.round(x);
  23733. y = Math.round(y);
  23734. z = Math.round(z);
  23735. this.dom.style[transformStyleName] = 'translate3d(' + (x || 0) + 'px, ' + (y || 0) + 'px, ' + (z || 0) + 'px)';
  23736. };
  23737. }(),
  23738. unwrap: function() {
  23739. var dom = this.dom,
  23740. parentNode = dom.parentNode,
  23741. activeElement = (activeElFly || (activeElFly = new Ext.dom.Fly())).attach(Ext.Element.getActiveElement()),
  23742. grandparentNode, cached, resumeFocus, tabIndex;
  23743. grannyFly = grannyFly || new Ext.dom.Fly();
  23744. cached = Ext.cache[activeElement.dom.id];
  23745. if (cached) {
  23746. activeElement = cached;
  23747. }
  23748. if (this.contains(activeElement)) {
  23749. if (cached) {
  23750. cached.suspendFocusEvents();
  23751. }
  23752. resumeFocus = true;
  23753. }
  23754. if (parentNode) {
  23755. grandparentNode = parentNode.parentNode;
  23756. if (resumeFocus) {
  23757. tabIndex = grandparentNode.getAttribute('tabIndex');
  23758. grannyFly.attach(grandparentNode);
  23759. grannyFly.set({
  23760. tabIndex: -1
  23761. });
  23762. grannyFly.suspendFocusEvents();
  23763. grannyFly.focus();
  23764. }
  23765. grandparentNode.insertBefore(dom, parentNode);
  23766. grandparentNode.removeChild(parentNode);
  23767. } else {
  23768. grandparentNode = DOC.createDocumentFragment();
  23769. grandparentNode.appendChild(dom);
  23770. }
  23771. if (resumeFocus) {
  23772. if (cached) {
  23773. cached.focus();
  23774. cached.resumeFocusEvents();
  23775. } else {
  23776. activeElement.focus();
  23777. }
  23778. if (grannyFly) {
  23779. grannyFly.resumeFocusEvents();
  23780. grannyFly.set({
  23781. tabIndex: tabIndex
  23782. });
  23783. }
  23784. }
  23785. return this;
  23786. },
  23787. up: function(simpleSelector, limit, returnDom) {
  23788. return this.findParentNode(simpleSelector, limit, !returnDom);
  23789. },
  23790. update: function(html) {
  23791. return this.setHtml(html);
  23792. },
  23793. wrap: function(config, returnDom, selector) {
  23794. var me = this,
  23795. dom = me.dom,
  23796. result = Ext.DomHelper.insertBefore(dom, config || {
  23797. tag: "div"
  23798. }, !returnDom),
  23799. newEl = (wrapFly || (wrapFly = new Ext.dom.Fly())).attach(Ext.getDom(result)),
  23800. target = newEl,
  23801. activeElement = (activeElFly || (activeElFly = new Ext.dom.Fly())).attach(Ext.Element.getActiveElement()),
  23802. cached, resumeFocus, tabIndex;
  23803. cached = Ext.cache[activeElement.dom.id];
  23804. if (cached) {
  23805. activeElement = cached;
  23806. }
  23807. if (selector) {
  23808. target = newEl.selectNode(selector, returnDom);
  23809. }
  23810. if (me.contains(activeElement)) {
  23811. if (cached) {
  23812. cached.suspendFocusEvents();
  23813. }
  23814. tabIndex = Ext.getDom(newEl).getAttribute('tabIndex');
  23815. newEl.set({
  23816. tabIndex: -1
  23817. });
  23818. newEl.suspendFocusEvents();
  23819. newEl.focus();
  23820. resumeFocus = true;
  23821. }
  23822. (target.dom || target).appendChild(dom);
  23823. if (resumeFocus) {
  23824. if (cached) {
  23825. cached.focus();
  23826. cached.resumeFocusEvents();
  23827. } else {
  23828. activeElement.focus();
  23829. }
  23830. newEl.resumeFocusEvents();
  23831. newEl.set({
  23832. tabIndex: tabIndex
  23833. });
  23834. }
  23835. return result;
  23836. },
  23837. isFocusable: function(skipVisibility) {
  23838. var dom = this.dom,
  23839. focusable = false,
  23840. nodeName;
  23841. if (dom && !dom.disabled) {
  23842. nodeName = dom.nodeName;
  23843. focusable = !!Ext.Element.naturallyFocusableTags[nodeName] || ((nodeName === 'A' || nodeName === 'LINK') && !!dom.href) || dom.getAttribute('tabIndex') != null || dom.contentEditable === 'true';
  23844. if (Ext.isIE8 && nodeName === 'INPUT' && dom.type === 'hidden') {
  23845. focusable = false;
  23846. }
  23847. focusable = focusable && (skipVisibility || this.isVisible(true));
  23848. }
  23849. return focusable;
  23850. },
  23851. isInputField: function() {
  23852. var dom = this.dom,
  23853. contentEditable = dom.contentEditable;
  23854. if ((Ext.Element.inputTags[dom.tagName] && dom.type !== 'button') || (contentEditable === '' || contentEditable === 'true')) {
  23855. return true;
  23856. }
  23857. return false;
  23858. },
  23859. isTabbable: function(includeHidden) {
  23860. var dom = this.dom,
  23861. tabbable = false,
  23862. nodeName, hasIndex, tabIndex;
  23863. if (dom && !dom.disabled) {
  23864. nodeName = dom.nodeName;
  23865. tabIndex = dom.getAttribute('tabIndex');
  23866. hasIndex = tabIndex != null;
  23867. tabIndex -= 0;
  23868. if (nodeName === 'A' || nodeName === 'LINK') {
  23869. if (dom.href) {
  23870. tabbable = hasIndex && tabIndex < 0 ? false : true;
  23871. } else
  23872. {
  23873. if (dom.contentEditable === 'true') {
  23874. tabbable = !hasIndex || (hasIndex && tabIndex >= 0) ? true : false;
  23875. } else {
  23876. tabbable = hasIndex && tabIndex >= 0 ? true : false;
  23877. }
  23878. }
  23879. }
  23880. else if (dom.contentEditable === 'true' || Ext.Element.naturallyTabbableTags[nodeName]) {
  23881. tabbable = hasIndex && tabIndex < 0 ? false : true;
  23882. } else
  23883. {
  23884. if (hasIndex && tabIndex >= 0) {
  23885. tabbable = true;
  23886. }
  23887. }
  23888. if (Ext.isIE8 && nodeName === 'INPUT' && dom.type === 'hidden') {
  23889. tabbable = false;
  23890. }
  23891. tabbable = tabbable && (includeHidden || ((!this.component || this.component.isVisible(true)) && this.isVisible(true)));
  23892. }
  23893. return tabbable;
  23894. },
  23895. ripplingCls: Ext.baseCSSPrefix + 'rippling',
  23896. ripplingTransitionCls: Ext.baseCSSPrefix + 'ripple-transition',
  23897. ripplingUnboundCls: Ext.baseCSSPrefix + 'rippling-unbound',
  23898. rippleBubbleCls: Ext.baseCSSPrefix + 'ripple-bubble',
  23899. rippleContainerCls: Ext.baseCSSPrefix + 'ripple-container',
  23900. rippleWrapperCls: Ext.baseCSSPrefix + 'ripple-wrapper',
  23901. noRippleDisplayMap: {
  23902. table: 1,
  23903. 'table-row': 1,
  23904. 'table-row-group': 1
  23905. },
  23906. noRippleTagMap: {
  23907. TABLE: 1,
  23908. TR: 1,
  23909. TBODY: 1
  23910. },
  23911. ripple: function(event, options) {
  23912. if (options === true || !options) {
  23913. options = {};
  23914. } else if (Ext.isString(options)) {
  23915. options = {
  23916. color: options
  23917. };
  23918. }
  23919. var me = this,
  23920. rippleParent = Ext.isString(options.delegate) ? me.down(options.delegate) : me,
  23921. rippleMeasureEl = Ext.isString(options.measureSelector) ? me.down(options.measureSelector) : null,
  23922. color = window.getComputedStyle(rippleParent.dom).color,
  23923. unbound = options.bound === false,
  23924. position = options.position,
  23925. ripplingCls = me.ripplingCls,
  23926. ripplingTransitionCls = me.ripplingTransitionCls,
  23927. ripplingUnboundCls = me.ripplingUnboundCls,
  23928. rippleBubbleCls = me.rippleBubbleCls,
  23929. rippleContainerCls = me.rippleContainerCls,
  23930. rippleWrapperCls = me.rippleWrapperCls,
  23931. offset, width, height, rippleDiameter, center, measureElWidth, measureElHeight, rippleSize, pos, posX, posY, rippleWrapper, rippleContainer, rippleBubble, rippleDestructor, rippleClearFn, rippleDestructionTimer, rippleBox, unboundEl, unboundElData, timeout;
  23932. if (rippleParent) {
  23933. offset = rippleParent.getXY();
  23934. width = rippleParent.getWidth();
  23935. height = rippleParent.getHeight();
  23936. timeout = rippleParent.$rippleClearTimeout;
  23937. if (timeout) {
  23938. rippleParent.$rippleClearTimeout = Ext.undefer(timeout);
  23939. }
  23940. if (rippleMeasureEl) {
  23941. measureElWidth = rippleMeasureEl.getWidth();
  23942. measureElHeight = rippleMeasureEl.getHeight();
  23943. rippleDiameter = Math.max(measureElWidth, measureElHeight);
  23944. } else {
  23945. rippleDiameter = width > height ? width : height;
  23946. }
  23947. if (options.diameterLimit === undefined || options.diameterLimit === true) {
  23948. rippleDiameter = Math.min(rippleDiameter, Element.maxRippleDiameter);
  23949. } else if (options.diameterLimit && options.diameterLimit !== false && options.diameterLimit !== 0) {
  23950. rippleDiameter = Math.min(rippleDiameter, options.diameterLimit);
  23951. }
  23952. center = [
  23953. offset[0] + width / 2,
  23954. offset[1] + height / 2
  23955. ];
  23956. if (unbound) {
  23957. if (options.fit !== false) {
  23958. rippleSize = rippleDiameter * 2.15;
  23959. rippleBox = rippleParent.getRegion();
  23960. rippleBox.setPosition(rippleBox.getCenter()).setSize(rippleSize).translateBy(-rippleSize / 2, -rippleSize / 2);
  23961. unboundEl = me.up(function(candidate) {
  23962. var fly = Ext.fly(candidate, 'ripple');
  23963. return !(candidate.tagName in me.noRippleTagMap) && !(fly.getStyle('display') in me.noRippleDisplayMap) && (fly.getRegion().contains(rippleBox));
  23964. }) || Ext.getBody();
  23965. } else {
  23966. unboundEl = rippleParent;
  23967. }
  23968. }
  23969. if (Ext.isString(event)) {
  23970. options.color = event;
  23971. event = null;
  23972. } else if (event && !event.isEvent) {
  23973. event = new Ext.event.Event(event);
  23974. }
  23975. if (event && event.isEvent) {
  23976. if (event.browserEvent.$preventRipple) {
  23977. return;
  23978. }
  23979. position = event.getXY();
  23980. event.browserEvent.$preventRipple = true;
  23981. }
  23982. pos = (!unbound && !options.centered && position) || center;
  23983. posX = pos[0] - offset[0] - (rippleDiameter / 2);
  23984. posY = pos[1] - offset[1] - (rippleDiameter / 2);
  23985. rippleParent.addCls(ripplingTransitionCls);
  23986. if (!unbound) {
  23987. rippleParent.addCls(ripplingCls);
  23988. rippleContainer = rippleParent.child('.' + rippleContainerCls);
  23989. } else {
  23990. unboundElData = unboundEl.getData();
  23991. rippleWrapper = unboundElData.rippleWrapper;
  23992. if (!rippleWrapper) {
  23993. unboundElData.rippleWrapper = rippleWrapper = unboundEl.insertFirst({
  23994. style: 'position: absolute; top: 0; left: 0',
  23995. cls: rippleWrapperCls + ' ' + ripplingCls + ' ' + ripplingUnboundCls
  23996. });
  23997. }
  23998. }
  23999. if (!rippleContainer) {
  24000. if (unbound) {
  24001. rippleContainer = rippleWrapper.append({
  24002. cls: rippleContainerCls
  24003. });
  24004. rippleContainer.setXY(offset);
  24005. } else {
  24006. rippleContainer = rippleParent.append({
  24007. cls: rippleContainerCls
  24008. });
  24009. }
  24010. }
  24011. rippleBubble = rippleContainer.append({
  24012. cls: rippleBubbleCls
  24013. });
  24014. if (options.color !== 'default') {
  24015. rippleBubble.setStyle('backgroundColor', options.color || color);
  24016. }
  24017. rippleBubble.setWidth(rippleDiameter);
  24018. rippleBubble.setHeight(rippleDiameter);
  24019. rippleBubble.setTop(posY);
  24020. rippleBubble.setLeft(posX);
  24021. rippleClearFn = function() {
  24022. if (!rippleParent.destroyed) {
  24023. rippleParent.$rippleClearTimeout = Ext.defer(function() {
  24024. rippleParent.removeCls([
  24025. ripplingCls,
  24026. ripplingTransitionCls
  24027. ]);
  24028. rippleParent.$rippleClearTimeout = null;
  24029. }, 50);
  24030. }
  24031. };
  24032. rippleDestructor = function() {
  24033. var ripple, timeout;
  24034. rippleBubble.destroy();
  24035. if (me.$ripples) {
  24036. delete me.$ripples[rippleBubble.id];
  24037. }
  24038. timeout = rippleParent.$rippleClearTimeout;
  24039. if (timeout) {
  24040. rippleParent.$rippleClearTimeout = Ext.undefer(timeout);
  24041. }
  24042. if (unbound) {
  24043. rippleContainer.destroy();
  24044. ripple = rippleWrapper.child('.' + rippleContainerCls);
  24045. if (!ripple) {
  24046. unboundElData.rippleWrapper = null;
  24047. rippleWrapper.destroy();
  24048. rippleClearFn();
  24049. }
  24050. } else {
  24051. ripple = rippleContainer.child('.' + rippleBubbleCls);
  24052. if (!ripple) {
  24053. rippleContainer.destroy();
  24054. rippleClearFn();
  24055. }
  24056. }
  24057. };
  24058. rippleDestructionTimer = Ext.defer(rippleDestructor, options.destroyTime || 1000, me);
  24059. if (!me.$ripples) {
  24060. me.$ripples = {};
  24061. }
  24062. me.$ripples[rippleBubble.id] = {
  24063. timerId: rippleDestructionTimer,
  24064. destructor: rippleDestructor
  24065. };
  24066. rippleBubble.addCls(Ext.baseCSSPrefix + 'ripple');
  24067. }
  24068. },
  24069. destroyAllRipples: function() {
  24070. var me = this,
  24071. rippleEl, ripple;
  24072. for (rippleEl in me.$ripples) {
  24073. ripple = me.$ripples[rippleEl];
  24074. Ext.undefer(ripple.timerId);
  24075. if (ripple.destructor) {
  24076. ripple.destructor();
  24077. }
  24078. }
  24079. me.$ripples = null;
  24080. },
  24081. privates: {
  24082. findTabbableElements: function(options) {
  24083. var skipSelf, skipChildren, excludeRoot, includeSaved, includeHidden,
  24084. dom = this.dom,
  24085. cAttr = Ext.Element.tabbableSavedCounterAttribute,
  24086. selection = [],
  24087. idx = 0,
  24088. nodes, node, fly, i, len, tabIndex;
  24089. if (!dom) {
  24090. return selection;
  24091. }
  24092. if (options) {
  24093. skipSelf = options.skipSelf;
  24094. skipChildren = options.skipChildren;
  24095. excludeRoot = options.excludeRoot;
  24096. includeSaved = options.includeSaved;
  24097. includeHidden = options.includeHidden;
  24098. }
  24099. excludeRoot = excludeRoot && Ext.getDom(excludeRoot);
  24100. if (excludeRoot && excludeRoot.contains(dom)) {
  24101. return selection;
  24102. }
  24103. if (!skipSelf && ((includeSaved && dom.hasAttribute(cAttr)) || this.isTabbable(includeHidden))) {
  24104. selection[idx++] = dom;
  24105. }
  24106. if (skipChildren) {
  24107. return selection;
  24108. }
  24109. nodes = dom.querySelectorAll(Ext.Element.tabbableSelector);
  24110. len = nodes.length;
  24111. if (!len) {
  24112. return selection;
  24113. }
  24114. fly = new Ext.dom.Fly();
  24115. for (i = 0; i < len; i++) {
  24116. node = nodes[i];
  24117. tabIndex = +node.getAttribute('tabIndex');
  24118. if (((includeSaved && node.hasAttribute(cAttr)) || (!(tabIndex < 0) && fly.attach(node).isTabbable(includeHidden))) &&
  24119. !(excludeRoot && (excludeRoot === node || excludeRoot.contains(node)))) {
  24120. selection[idx++] = node;
  24121. }
  24122. }
  24123. return selection;
  24124. },
  24125. saveTabbableState: function(options) {
  24126. var counterAttr = Ext.Element.tabbableSavedCounterAttribute,
  24127. savedAttr = Ext.Element.tabbableSavedValueAttribute,
  24128. counter, nodes, node, i, len;
  24129. if (!options || options.includeSaved == null) {
  24130. options = Ext.Object.chain(options || null);
  24131. options.includeSaved = true;
  24132. }
  24133. nodes = this.findTabbableElements(options);
  24134. for (i = 0 , len = nodes.length; i < len; i++) {
  24135. node = nodes[i];
  24136. counter = +node.getAttribute(counterAttr);
  24137. if (counter > 0) {
  24138. node.setAttribute(counterAttr, ++counter);
  24139. } else {
  24140. if (node.hasAttribute('tabIndex')) {
  24141. node.setAttribute(savedAttr, node.getAttribute('tabIndex'));
  24142. } else
  24143. {
  24144. node.setAttribute(savedAttr, 'none');
  24145. }
  24146. node.setAttribute('tabIndex', '-1');
  24147. node.setAttribute(counterAttr, '1');
  24148. }
  24149. }
  24150. return nodes;
  24151. },
  24152. restoreTabbableState: function(options) {
  24153. var dom = this.dom,
  24154. counterAttr = Ext.Element.tabbableSavedCounterAttribute,
  24155. savedAttr = Ext.Element.tabbableSavedValueAttribute,
  24156. nodes = [],
  24157. skipSelf = options && options.skipSelf,
  24158. skipChildren = options && options.skipChildren,
  24159. reset = options && options.reset,
  24160. idx, counter, node, i, len;
  24161. if (!dom) {
  24162. return this;
  24163. }
  24164. if (!skipChildren) {
  24165. nodes = Ext.Array.from(dom.querySelectorAll('[' + counterAttr + ']'));
  24166. }
  24167. if (!skipSelf) {
  24168. nodes.unshift(dom);
  24169. }
  24170. for (i = 0 , len = nodes.length; i < len; i++) {
  24171. node = nodes[i];
  24172. if (!node.hasAttribute(counterAttr) || !node.hasAttribute(savedAttr)) {
  24173. continue;
  24174. }
  24175. counter = +node.getAttribute(counterAttr);
  24176. if (!reset && counter > 1) {
  24177. node.setAttribute(counterAttr, --counter);
  24178. continue;
  24179. }
  24180. idx = node.getAttribute(savedAttr);
  24181. if (idx === 'none') {
  24182. node.removeAttribute('tabIndex');
  24183. } else {
  24184. node.setAttribute('tabIndex', idx);
  24185. }
  24186. node.removeAttribute(savedAttr);
  24187. node.removeAttribute(counterAttr);
  24188. }
  24189. return nodes;
  24190. },
  24191. setTabIndex: function(tabIndex) {
  24192. var dom = this.dom,
  24193. savedAttr = Ext.Element.tabbableSavedValueAttribute;
  24194. if (dom.hasAttribute(savedAttr)) {
  24195. if (tabIndex == null) {
  24196. dom.setAttribute(savedAttr, 'none');
  24197. dom.removeAttribute('tabIndex');
  24198. } else {
  24199. dom.setAttribute(savedAttr, tabIndex);
  24200. }
  24201. } else {
  24202. if (tabIndex == null) {
  24203. dom.removeAttribute('tabIndex');
  24204. } else {
  24205. dom.setAttribute('tabIndex', tabIndex);
  24206. }
  24207. }
  24208. },
  24209. doAddListener: function(eventName, fn, scope, options, order, caller, manager) {
  24210. var me = this,
  24211. originalName = eventName,
  24212. observableDoAddListener, additiveEventName, translatedEventName;
  24213. eventName = Ext.canonicalEventName(eventName);
  24214. if (!me.blockedEvents[eventName]) {
  24215. observableDoAddListener = me.mixins.observable.doAddListener;
  24216. options = options || {};
  24217. if (Element.useDelegatedEvents === false) {
  24218. options.delegated = options.delegated || false;
  24219. }
  24220. if (options.translate !== false) {
  24221. additiveEventName = me.additiveEvents[eventName];
  24222. if (additiveEventName) {
  24223. options.type = eventName;
  24224. eventName = additiveEventName;
  24225. observableDoAddListener.call(me, eventName, fn, scope, options, order, caller, manager);
  24226. }
  24227. translatedEventName = me.eventMap[eventName];
  24228. if (translatedEventName) {
  24229. options.type = options.type || eventName;
  24230. if (manager) {
  24231. options.managedName = originalName;
  24232. }
  24233. eventName = translatedEventName;
  24234. }
  24235. }
  24236. if (observableDoAddListener.call(me, eventName, fn, scope, options, order, caller, manager)) {
  24237. if (me.longpressEvents[eventName] && (++me.longpressListenerCount === 1)) {
  24238. me.on('MSHoldVisual', 'preventMsHoldVisual', me);
  24239. }
  24240. }
  24241. if (manager && translatedEventName) {
  24242. delete options.managedName;
  24243. }
  24244. delete options.type;
  24245. }
  24246. },
  24247. doRemoveListener: function(eventName, fn, scope) {
  24248. var me = this,
  24249. observableDoRemoveListener, translatedEventName, additiveEventName, removed;
  24250. eventName = Ext.canonicalEventName(eventName);
  24251. if (!me.blockedEvents[eventName]) {
  24252. observableDoRemoveListener = me.mixins.observable.doRemoveListener;
  24253. additiveEventName = me.additiveEvents[eventName];
  24254. if (additiveEventName) {
  24255. eventName = additiveEventName;
  24256. observableDoRemoveListener.call(me, eventName, fn, scope);
  24257. }
  24258. translatedEventName = me.eventMap[eventName];
  24259. if (translatedEventName) {
  24260. removed = observableDoRemoveListener.call(me, translatedEventName, fn, scope);
  24261. }
  24262. removed = observableDoRemoveListener.call(me, eventName, fn, scope) || removed;
  24263. if (removed) {
  24264. if (me.longpressEvents[eventName] && !--me.longpressListenerCount) {
  24265. me.un('MSHoldVisual', 'preventMsHoldVisual', me);
  24266. }
  24267. }
  24268. }
  24269. },
  24270. _initEvent: function(eventName) {
  24271. return (this.events[eventName] = new Ext.dom.ElementEvent(this, eventName));
  24272. },
  24273. _getDisplay: function() {
  24274. var data = this.getData(),
  24275. display = data[ORIGINALDISPLAY];
  24276. if (display === undefined) {
  24277. data[ORIGINALDISPLAY] = display = '';
  24278. }
  24279. return display;
  24280. },
  24281. _getPublisher: function(eventName, noTranslate) {
  24282. var Publisher = Ext.event.publisher.Publisher,
  24283. publisher = Publisher.publishersByEvent[eventName],
  24284. isNative = noTranslate && !Ext.event.Event.gestureEvents[eventName];
  24285. if (isNative || !publisher || (this.dom === window && eventName === 'resize')) {
  24286. publisher = Publisher.publishers.dom;
  24287. }
  24288. return publisher;
  24289. },
  24290. isFocusSuspended: function() {
  24291. var data = this.peekData();
  24292. return data && data.suspendFocusEvents;
  24293. },
  24294. preventMsHoldVisual: function(e) {
  24295. e.preventDefault();
  24296. },
  24297. suspendFocusEvents: function() {
  24298. if (!this.isFly) {
  24299. this.suspendEvent('focus', 'blur');
  24300. }
  24301. this.getData().suspendFocusEvents = true;
  24302. },
  24303. resumeFocusEvents: function() {
  24304. function resumeFn() {
  24305. var data;
  24306. if (!this.destroyed) {
  24307. data = this.getData();
  24308. if (data) {
  24309. data.suspendFocusEvents = false;
  24310. }
  24311. if (!this.isFly) {
  24312. this.resumeEvent('focus', 'blur');
  24313. }
  24314. }
  24315. }
  24316. if (!this.destroyed && this.getData().suspendFocusEvents) {
  24317. if (Ext.isIE && !this.isFly) {
  24318. this.resumeFocusEventsTimer = Ext.asap(resumeFn, this);
  24319. } else {
  24320. resumeFn.call(this);
  24321. }
  24322. }
  24323. }
  24324. },
  24325. deprecated: {
  24326. '5.0': {
  24327. methods: {
  24328. getHTML: 'getHtml',
  24329. getPageBox: function(getRegion) {
  24330. var me = this,
  24331. dom = me.dom,
  24332. isDoc = dom.nodeName === 'BODY',
  24333. w = isDoc ? Element.getViewportWidth() : dom.offsetWidth,
  24334. h = isDoc ? Element.getViewportHeight() : dom.offsetHeight,
  24335. xy = me.getXY(),
  24336. t = xy[1],
  24337. r = xy[0] + w,
  24338. b = xy[1] + h,
  24339. l = xy[0];
  24340. if (getRegion) {
  24341. return new Ext.util.Region(t, r, b, l);
  24342. } else {
  24343. return {
  24344. left: l,
  24345. top: t,
  24346. width: w,
  24347. height: h,
  24348. right: r,
  24349. bottom: b
  24350. };
  24351. }
  24352. },
  24353. isTransparent: function(prop) {
  24354. var value = this.getStyle(prop);
  24355. return value ? transparentRe.test(value) : false;
  24356. },
  24357. purgeAllListeners: 'clearListeners',
  24358. removeAllListeners: 'clearListeners',
  24359. setHTML: 'setHtml'
  24360. }
  24361. }
  24362. }
  24363. };
  24364. }, function(Element) {
  24365. var DOC = document,
  24366. docEl = DOC.documentElement,
  24367. prototype = Element.prototype,
  24368. supports = Ext.supports,
  24369. pointerdown = 'pointerdown',
  24370. pointermove = 'pointermove',
  24371. pointerup = 'pointerup',
  24372. pointercancel = 'pointercancel',
  24373. MSPointerDown = 'MSPointerDown',
  24374. MSPointerMove = 'MSPointerMove',
  24375. MSPointerUp = 'MSPointerUp',
  24376. MSPointerCancel = 'MSPointerCancel',
  24377. mousedown = 'mousedown',
  24378. mousemove = 'mousemove',
  24379. mouseup = 'mouseup',
  24380. mouseover = 'mouseover',
  24381. mouseout = 'mouseout',
  24382. mouseenter = 'mouseenter',
  24383. mouseleave = 'mouseleave',
  24384. touchstart = 'touchstart',
  24385. touchmove = 'touchmove',
  24386. touchend = 'touchend',
  24387. touchcancel = 'touchcancel',
  24388. click = 'click',
  24389. dblclick = 'dblclick',
  24390. tap = 'tap',
  24391. doubletap = 'doubletap',
  24392. eventMap = prototype.eventMap = {},
  24393. additiveEvents = prototype.additiveEvents = {},
  24394. oldId = Ext.id,
  24395. eventOptions;
  24396. prototype._init(Element);
  24397. delete prototype._init;
  24398. Ext.id = function(obj, prefix) {
  24399. var el = obj && Ext.getDom(obj, true),
  24400. sandboxPrefix, id;
  24401. if (!el) {
  24402. id = oldId(obj, prefix);
  24403. } else if (!(id = el.id)) {
  24404. id = oldId(null, prefix || Element.prototype.identifiablePrefix);
  24405. if (Ext.isSandboxed) {
  24406. sandboxPrefix = Ext.sandboxPrefix || (Ext.sandboxPrefix = Ext.sandboxName.toLowerCase() + '-');
  24407. id = sandboxPrefix + id;
  24408. }
  24409. el.id = id;
  24410. }
  24411. return id;
  24412. };
  24413. if (supports.PointerEvents) {
  24414. eventMap[mousedown] = pointerdown;
  24415. eventMap[mousemove] = pointermove;
  24416. eventMap[mouseup] = pointerup;
  24417. eventMap[touchstart] = pointerdown;
  24418. eventMap[touchmove] = pointermove;
  24419. eventMap[touchend] = pointerup;
  24420. eventMap[touchcancel] = pointercancel;
  24421. eventMap[mouseover] = 'pointerover';
  24422. eventMap[mouseout] = 'pointerout';
  24423. eventMap[mouseenter] = 'pointerenter';
  24424. if (!Ext.isIE11) {
  24425. eventMap[mouseleave] = 'pointerleave';
  24426. }
  24427. } else if (supports.MSPointerEvents) {
  24428. eventMap[pointerdown] = MSPointerDown;
  24429. eventMap[pointermove] = MSPointerMove;
  24430. eventMap[pointerup] = MSPointerUp;
  24431. eventMap[pointercancel] = MSPointerCancel;
  24432. eventMap[mousedown] = MSPointerDown;
  24433. eventMap[mousemove] = MSPointerMove;
  24434. eventMap[mouseup] = MSPointerUp;
  24435. eventMap[touchstart] = MSPointerDown;
  24436. eventMap[touchmove] = MSPointerMove;
  24437. eventMap[touchend] = MSPointerUp;
  24438. eventMap[touchcancel] = MSPointerCancel;
  24439. eventMap[mouseover] = 'MSPointerOver';
  24440. eventMap[mouseout] = 'MSPointerOut';
  24441. } else if (supports.TouchEvents) {
  24442. eventMap[pointerdown] = touchstart;
  24443. eventMap[pointermove] = touchmove;
  24444. eventMap[pointerup] = touchend;
  24445. eventMap[pointercancel] = touchcancel;
  24446. eventMap[mousedown] = touchstart;
  24447. eventMap[mousemove] = touchmove;
  24448. eventMap[mouseup] = touchend;
  24449. eventMap[click] = tap;
  24450. eventMap[dblclick] = doubletap;
  24451. if (Ext.os.is.Desktop) {
  24452. eventMap[touchstart] = mousedown;
  24453. eventMap[touchmove] = mousemove;
  24454. eventMap[touchend] = mouseup;
  24455. eventMap[touchcancel] = mouseup;
  24456. additiveEvents[mousedown] = mousedown;
  24457. additiveEvents[mousemove] = mousemove;
  24458. additiveEvents[mouseup] = mouseup;
  24459. additiveEvents[touchstart] = touchstart;
  24460. additiveEvents[touchmove] = touchmove;
  24461. additiveEvents[touchend] = touchend;
  24462. additiveEvents[touchcancel] = touchcancel;
  24463. additiveEvents[pointerdown] = mousedown;
  24464. additiveEvents[pointermove] = mousemove;
  24465. additiveEvents[pointerup] = mouseup;
  24466. additiveEvents[pointercancel] = mouseup;
  24467. }
  24468. } else {
  24469. eventMap[pointerdown] = mousedown;
  24470. eventMap[pointermove] = mousemove;
  24471. eventMap[pointerup] = mouseup;
  24472. eventMap[pointercancel] = mouseup;
  24473. eventMap[touchstart] = mousedown;
  24474. eventMap[touchmove] = mousemove;
  24475. eventMap[touchend] = mouseup;
  24476. eventMap[touchcancel] = mouseup;
  24477. }
  24478. if (Ext.isWebKit) {
  24479. eventMap.transitionend = Ext.browser.getVendorProperyName('transitionEnd');
  24480. eventMap.animationstart = Ext.browser.getVendorProperyName('animationStart');
  24481. eventMap.animationend = Ext.browser.getVendorProperyName('animationEnd');
  24482. }
  24483. if (!Ext.supports.MouseWheel && !Ext.isOpera) {
  24484. eventMap.mousewheel = 'DOMMouseScroll';
  24485. }
  24486. eventOptions = prototype.$eventOptions = Ext.Object.chain(prototype.$eventOptions);
  24487. eventOptions.translate = eventOptions.capture = eventOptions.delegate = eventOptions.delegated = eventOptions.stopEvent = eventOptions.preventDefault = eventOptions.stopPropagation =
  24488. eventOptions.element = 1;
  24489. prototype.styleHooks.opacity = {
  24490. name: 'opacity',
  24491. afterSet: function(dom, value, el) {
  24492. var shadow = el.shadow;
  24493. if (shadow) {
  24494. shadow.setOpacity(value);
  24495. }
  24496. }
  24497. };
  24498. prototype.getTrueXY = prototype.getXY;
  24499. Ext.getViewportHeight = Element.getViewportHeight;
  24500. Ext.getViewportWidth = Element.getViewportWidth;
  24501. Ext.select = Element.select;
  24502. Ext.query = Element.query;
  24503. Ext.apply(Ext, {
  24504. get: function(element) {
  24505. return Element.get(element);
  24506. },
  24507. getDom: function(el) {
  24508. if (!el || !DOC) {
  24509. return null;
  24510. }
  24511. return typeof el === 'string' ? Ext.getElementById(el) : 'dom' in el ? el.dom : el;
  24512. },
  24513. getBody: function() {
  24514. if (!Ext._bodyEl) {
  24515. if (!DOC.body) {
  24516. throw new Error("[Ext.getBody] document.body does not yet exist");
  24517. }
  24518. Ext._bodyEl = Ext.get(DOC.body);
  24519. Ext._bodyEl.skipGarbageCollection = true;
  24520. }
  24521. return Ext._bodyEl;
  24522. },
  24523. getHead: function() {
  24524. if (!Ext._headEl) {
  24525. Ext._headEl = Ext.get(DOC.head || DOC.getElementsByTagName('head')[0]);
  24526. Ext._headEl.skipGarbageCollection = true;
  24527. }
  24528. return Ext._headEl;
  24529. },
  24530. getDoc: function() {
  24531. if (!Ext._docEl) {
  24532. Ext._docEl = Ext.get(DOC);
  24533. Ext._docEl.skipGarbageCollection = true;
  24534. }
  24535. return Ext._docEl;
  24536. },
  24537. getWin: function() {
  24538. if (!Ext._winEl) {
  24539. Ext._winEl = Ext.get(window);
  24540. Ext._winEl.skipGarbageCollection = true;
  24541. }
  24542. return Ext._winEl;
  24543. },
  24544. removeNode: function(node) {
  24545. node = node.dom || node;
  24546. var id = node && node.id,
  24547. el = Ext.cache[id],
  24548. parent;
  24549. if (el) {
  24550. el.destroy();
  24551. } else if (node && (node.nodeType === 3 || node.tagName.toUpperCase() !== 'BODY')) {
  24552. parent = node.parentNode;
  24553. if (parent) {
  24554. parent.removeChild(node);
  24555. }
  24556. }
  24557. }
  24558. });
  24559. Ext.isGarbage = function(dom) {
  24560. return dom &&
  24561. dom.nodeType === 1 && dom.tagName !== 'BODY' && dom.tagName !== 'HTML' && (
  24562. !dom.parentNode || (
  24563. dom.offsetParent === null &&
  24564. ((Ext.isIE8 ? DOC.all[dom.id] : DOC.getElementById(dom.id)) !== dom) &&
  24565. !(Ext.detachedBodyEl && Ext.detachedBodyEl.isAncestor(dom))));
  24566. };
  24567. Ext.onInternalReady(function() {
  24568. var bodyCls = [],
  24569. theme;
  24570. Ext.getDoc().on('selectstart', function(ev, dom) {
  24571. var selectableCls = Element.selectableCls,
  24572. unselectableCls = Element.unselectableCls,
  24573. tagName = dom && dom.tagName,
  24574. el = new Ext.dom.Fly();
  24575. tagName = tagName && tagName.toLowerCase();
  24576. if (tagName === 'input' || tagName === 'textarea') {
  24577. return;
  24578. }
  24579. while (dom && dom.nodeType === 1 && dom !== DOC.documentElement) {
  24580. el.attach(dom);
  24581. if (el.hasCls(selectableCls)) {
  24582. return;
  24583. }
  24584. if (el.hasCls(unselectableCls)) {
  24585. ev.stopEvent();
  24586. return;
  24587. }
  24588. dom = dom.parentNode;
  24589. }
  24590. });
  24591. if (Ext.os.is.Android || (Ext.os.is.Windows && Ext.supports.Touch)) {
  24592. var win = Ext.getWin();
  24593. Element._documentWidth = Element._viewportWidth = docEl.clientWidth;
  24594. Element._documentHeight = Element._viewportHeight = docEl.clientHeight;
  24595. win.on({
  24596. focusin: '_onWindowFocusChange',
  24597. focusout: '_onWindowFocusChange',
  24598. pointerup: '_onWindowFocusChange',
  24599. capture: true,
  24600. delegated: false,
  24601. delay: 1,
  24602. scope: Element
  24603. });
  24604. win.on({
  24605. resize: '_onWindowResize',
  24606. priority: 2000,
  24607. scope: Element
  24608. });
  24609. }
  24610. if (supports.Touch) {
  24611. bodyCls.push(Ext.baseCSSPrefix + 'touch');
  24612. }
  24613. if (Ext.isIE && Ext.isIE9m) {
  24614. bodyCls.push(Ext.baseCSSPrefix + 'ie', Ext.baseCSSPrefix + 'ie9m');
  24615. bodyCls.push(Ext.baseCSSPrefix + 'ie8p');
  24616. if (Ext.isIE8) {
  24617. bodyCls.push(Ext.baseCSSPrefix + 'ie8');
  24618. } else {
  24619. bodyCls.push(Ext.baseCSSPrefix + 'ie9', Ext.baseCSSPrefix + 'ie9p');
  24620. }
  24621. if (Ext.isIE8m) {
  24622. bodyCls.push(Ext.baseCSSPrefix + 'ie8m');
  24623. }
  24624. }
  24625. if (Ext.isIE10) {
  24626. bodyCls.push(Ext.baseCSSPrefix + 'ie10');
  24627. }
  24628. if (Ext.isIE10p) {
  24629. bodyCls.push(Ext.baseCSSPrefix + 'ie10p');
  24630. }
  24631. if (Ext.isIE11) {
  24632. bodyCls.push(Ext.baseCSSPrefix + 'ie11');
  24633. }
  24634. if (Ext.isEdge) {
  24635. bodyCls.push(Ext.baseCSSPrefix + 'edge');
  24636. }
  24637. if (Ext.isGecko) {
  24638. bodyCls.push(Ext.baseCSSPrefix + 'gecko');
  24639. }
  24640. if (Ext.isOpera) {
  24641. bodyCls.push(Ext.baseCSSPrefix + 'opera');
  24642. }
  24643. if (Ext.isOpera12m) {
  24644. bodyCls.push(Ext.baseCSSPrefix + 'opera12m');
  24645. }
  24646. if (Ext.isWebKit) {
  24647. bodyCls.push(Ext.baseCSSPrefix + 'webkit');
  24648. }
  24649. if (Ext.isSafari) {
  24650. bodyCls.push(Ext.baseCSSPrefix + 'safari');
  24651. }
  24652. if (Ext.isSafari9) {
  24653. bodyCls.push(Ext.baseCSSPrefix + 'safari9');
  24654. }
  24655. if (Ext.isSafari10) {
  24656. bodyCls.push(Ext.baseCSSPrefix + 'safari10');
  24657. }
  24658. if (Ext.isSafari) {
  24659. if (Ext.browser.version.isLessThan(11)) {
  24660. bodyCls.push(Ext.baseCSSPrefix + 'safari10m');
  24661. }
  24662. if (Ext.browser.version.isLessThan(9)) {
  24663. bodyCls.push(Ext.baseCSSPrefix + 'safari8m');
  24664. }
  24665. }
  24666. if (Ext.isChrome) {
  24667. bodyCls.push(Ext.baseCSSPrefix + 'chrome');
  24668. }
  24669. if (Ext.isMac) {
  24670. bodyCls.push(Ext.baseCSSPrefix + 'mac');
  24671. }
  24672. if (Ext.isWindows) {
  24673. bodyCls.push(Ext.baseCSSPrefix + 'windows');
  24674. }
  24675. if (Ext.isLinux) {
  24676. bodyCls.push(Ext.baseCSSPrefix + 'linux');
  24677. }
  24678. if (!supports.CSS3BorderRadius) {
  24679. bodyCls.push(Ext.baseCSSPrefix + 'nbr');
  24680. }
  24681. if (!supports.CSS3LinearGradient) {
  24682. bodyCls.push(Ext.baseCSSPrefix + 'nlg');
  24683. }
  24684. if (supports.Touch) {
  24685. bodyCls.push(Ext.baseCSSPrefix + 'touch');
  24686. }
  24687. if (Ext.os.deviceType) {
  24688. bodyCls.push(Ext.baseCSSPrefix + Ext.os.deviceType.toLowerCase());
  24689. }
  24690. if (Ext.os.is.BlackBerry) {
  24691. bodyCls.push(Ext.baseCSSPrefix + 'bb');
  24692. if (Ext.browser.userAgent.match(/Kbd/gi)) {
  24693. bodyCls.push(Ext.baseCSSPrefix + 'bb-keyboard');
  24694. }
  24695. }
  24696. if (Ext.os.is.iOS && Ext.isSafari) {
  24697. bodyCls.push(Ext.baseCSSPrefix + 'mobile-safari');
  24698. }
  24699. if (Ext.os.is.iOS && Ext.browser.is.WebView && !Ext.browser.is.Standalone) {
  24700. bodyCls.push(Ext.baseCSSPrefix + 'ios-native');
  24701. }
  24702. if (Ext.supports.FlexBoxBasisBug) {
  24703. bodyCls.push(Ext.baseCSSPrefix + 'has-flexbasis-bug');
  24704. }
  24705. Ext.getBody().addCls(bodyCls);
  24706. theme = Ext.theme;
  24707. if (theme && theme.getDocCls) {
  24708. Ext.fly(document.documentElement).addCls(theme.getDocCls());
  24709. }
  24710. }, null, {
  24711. priority: 1500
  24712. });
  24713. });
  24714. Ext.define('Ext.GlobalEvents', {
  24715. extend: Ext.mixin.Observable,
  24716. alternateClassName: 'Ext.globalEvents',
  24717. observableType: 'global',
  24718. singleton: true,
  24719. resizeBuffer: 100,
  24720. idleEventMask: {
  24721. mousemove: 1,
  24722. touchmove: 1,
  24723. pointermove: 1,
  24724. MSPointerMove: 1,
  24725. unload: 1
  24726. },
  24727. windowListeners: {
  24728. resize: {
  24729. fn: 'fireResize'
  24730. }
  24731. },
  24732. constructor: function() {
  24733. var me = this;
  24734. me.callParent();
  24735. Ext.onInternalReady(function() {
  24736. me.attachListeners();
  24737. });
  24738. },
  24739. setPressedComponent: function(component, e) {
  24740. var me = this,
  24741. pressedComponent = me.pressedComponent;
  24742. if (pressedComponent && pressedComponent.onRelease) {
  24743. pressedComponent.onRelease(e);
  24744. }
  24745. me.pressedComponent = component;
  24746. if (component) {
  24747. me.pressedScrollStart = Ext.on({
  24748. scrollstart: function() {
  24749. me.setPressedComponent(null, e);
  24750. },
  24751. destroyable: true
  24752. });
  24753. } else {
  24754. me.pressedScrollStart = Ext.destroy(me.pressedScrollStart);
  24755. }
  24756. },
  24757. attachListeners: function() {
  24758. var me = this,
  24759. win = Ext.getWin(),
  24760. winListeners = me.windowListeners;
  24761. me.onlineState = Ext.isOnline();
  24762. me.curHeight = Ext.Element.getViewportHeight();
  24763. me.curWidth = Ext.Element.getViewportWidth();
  24764. win.on({
  24765. scope: me,
  24766. online: 'handleOnlineChange',
  24767. offline: 'handleOnlineChange'
  24768. });
  24769. me.fireResize.$skipTimerCheck = true;
  24770. if (winListeners) {
  24771. winListeners.scope = me;
  24772. if (Ext.isModern) {
  24773. winListeners.resize.onFrame = true;
  24774. } else {
  24775. winListeners.resize.buffer = me.resizeBuffer;
  24776. }
  24777. win.on(winListeners);
  24778. }
  24779. Ext.getDoc().on({
  24780. touchstart: 'fireMouseDown',
  24781. mousedown: 'fireMouseDown',
  24782. mouseup: 'fireMouseUp',
  24783. touchend: 'fireMouseUp',
  24784. drop: 'fireMouseUp',
  24785. dragend: 'fireMouseUp',
  24786. scope: me
  24787. });
  24788. },
  24789. fireMouseDown: function(e) {
  24790. this.fireEvent('mousedown', e);
  24791. Ext.ComponentManager.handleDocumentMouseDown(e);
  24792. },
  24793. fireMouseUp: function(e) {
  24794. this.fireEvent('mouseup', e);
  24795. this.setPressedComponent(null, e);
  24796. },
  24797. fireResize: function() {
  24798. var me = this,
  24799. Element = Ext.Element,
  24800. w = Element.getViewportWidth(),
  24801. h = Element.getViewportHeight();
  24802. if (me.curHeight !== h || me.curWidth !== w) {
  24803. me.curHeight = h;
  24804. me.curWidth = w;
  24805. if (me.hasListeners.resize) {
  24806. me.fireEvent('resize', w, h);
  24807. }
  24808. }
  24809. },
  24810. handleOnlineChange: function() {
  24811. var online = Ext.isOnline();
  24812. if (online !== this.onlineState) {
  24813. this.onlineState = online;
  24814. this.fireEvent('onlinechange', online);
  24815. }
  24816. }
  24817. }, function(GlobalEvents) {
  24818. Ext.hasListeners = GlobalEvents.hasListeners;
  24819. Ext.on = function() {
  24820. return GlobalEvents.addListener.apply(GlobalEvents, arguments);
  24821. };
  24822. Ext.un = function() {
  24823. return GlobalEvents.removeListener.apply(GlobalEvents, arguments);
  24824. };
  24825. Ext.fireEvent = function() {
  24826. return GlobalEvents.fireEvent.apply(GlobalEvents, arguments);
  24827. };
  24828. Ext.fireIdle = function() {
  24829. if (GlobalEvents.hasListeners.idle && !Ext._suppressIdle) {
  24830. GlobalEvents.fireEventArgs('idle');
  24831. }
  24832. Ext._suppressIdle = false;
  24833. };
  24834. Ext._suppressIdle = false;
  24835. });
  24836. Ext.define('Ext.Glyph', {
  24837. isGlyph: true,
  24838. constructor: function(glyph) {
  24839. if (glyph) {
  24840. this.setGlyph(glyph);
  24841. }
  24842. },
  24843. setGlyph: function(glyph) {
  24844. var glyphParts;
  24845. this.glyphConfig = glyph;
  24846. if (typeof glyph === 'string') {
  24847. glyphParts = glyph.split('@');
  24848. glyph = isNaN(glyphParts[0]) ? parseInt('0' + glyphParts[0], 16) : parseInt(glyphParts[0], 10);
  24849. if (isNaN(glyph) || !glyph) {
  24850. glyph = glyphParts[0].charCodeAt(0);
  24851. }
  24852. this.fontFamily = glyphParts[1] || Ext._glyphFontFamily;
  24853. } else {
  24854. this.fontFamily = Ext._glyphFontFamily;
  24855. }
  24856. this.codepoint = glyph;
  24857. this.character = Ext.String.fromCodePoint(this.codepoint);
  24858. return this;
  24859. },
  24860. getStyle: function() {
  24861. return {
  24862. 'font-family': this.fontFamily
  24863. };
  24864. },
  24865. isEqual: function(other) {
  24866. return other && other.isGlyph && other.codepoint === this.codepoint && other.fontFamily === this.fontFamily;
  24867. },
  24868. statics: (function() {
  24869. var instance;
  24870. return {
  24871. fly: function(glyph) {
  24872. return glyph.isGlyph ? glyph : (instance || (instance = new Ext.Glyph())).setGlyph(glyph);
  24873. }
  24874. };
  24875. })()
  24876. });
  24877. Ext.USE_NATIVE_JSON = true;
  24878. Ext.JSON = (new (function() {
  24879. var me = this,
  24880. hasNative = window.JSON && JSON.toString() === '[object JSON]',
  24881. useHasOwn = !!{}.hasOwnProperty,
  24882. pad = function(n) {
  24883. return n < 10 ? "0" + n : n;
  24884. },
  24885. doDecode = function(json) {
  24886. return eval("(" + json + ')');
  24887. },
  24888. doEncode = function(o, newline) {
  24889. if (o === null || o === undefined) {
  24890. return "null";
  24891. } else if (Ext.isDate(o)) {
  24892. return me.encodeDate(o);
  24893. } else if (Ext.isString(o)) {
  24894. if (Ext.isMSDate(o)) {
  24895. return me.encodeMSDate(o);
  24896. } else {
  24897. return me.encodeString(o);
  24898. }
  24899. } else if (typeof o === "number") {
  24900. return isFinite(o) ? String(o) : "null";
  24901. } else if (Ext.isBoolean(o)) {
  24902. return String(o);
  24903. }
  24904. else if (typeof o.toJSON === 'function') {
  24905. return doEncode(o.toJSON());
  24906. } else if (Ext.isArray(o)) {
  24907. return encodeArray(o, newline);
  24908. } else if (Ext.isObject(o)) {
  24909. return encodeObject(o, newline);
  24910. } else if (typeof o === "function") {
  24911. return "null";
  24912. }
  24913. return 'undefined';
  24914. },
  24915. m = {
  24916. "\b": '\\b',
  24917. "\t": '\\t',
  24918. "\n": '\\n',
  24919. "\f": '\\f',
  24920. "\r": '\\r',
  24921. '"': '\\"',
  24922. "\\": '\\\\',
  24923. '\v': '\\u000b'
  24924. },
  24925. charToReplace = /[\\\"\x00-\x1f\x7f-\uffff]/g,
  24926. encodeString = function(s) {
  24927. return '"' + s.replace(charToReplace, function(a) {
  24928. var c = m[a];
  24929. return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  24930. }) + '"';
  24931. },
  24932. encodeMSDate = function(o) {
  24933. return '"' + o + '"';
  24934. },
  24935. encodeArrayPretty = function(o, newline) {
  24936. var len = o.length,
  24937. cnewline = newline + ' ',
  24938. sep = ',' + cnewline,
  24939. a = [
  24940. "[",
  24941. cnewline
  24942. ],
  24943. i;
  24944. for (i = 0; i < len; i += 1) {
  24945. a.push(me.encodeValue(o[i], cnewline), sep);
  24946. }
  24947. a[a.length - 1] = newline + ']';
  24948. return a.join('');
  24949. },
  24950. encodeObjectPretty = function(o, newline) {
  24951. var cnewline = newline + ' ',
  24952. sep = ',' + cnewline,
  24953. a = [
  24954. "{",
  24955. cnewline
  24956. ],
  24957. i, val;
  24958. for (i in o) {
  24959. val = o[i];
  24960. if (!useHasOwn || o.hasOwnProperty(i)) {
  24961. if (typeof val === 'function' || val === undefined || val.isInstance) {
  24962. continue;
  24963. }
  24964. a.push(me.encodeValue(i) + ': ' + me.encodeValue(val, cnewline), sep);
  24965. }
  24966. }
  24967. a[a.length - 1] = newline + '}';
  24968. return a.join('');
  24969. },
  24970. encodeArray = function(o, newline) {
  24971. if (newline) {
  24972. return encodeArrayPretty(o, newline);
  24973. }
  24974. var a = [
  24975. "[",
  24976. ""
  24977. ],
  24978. len = o.length,
  24979. i;
  24980. for (i = 0; i < len; i += 1) {
  24981. a.push(me.encodeValue(o[i]), ',');
  24982. }
  24983. a[a.length - 1] = ']';
  24984. return a.join("");
  24985. },
  24986. encodeObject = function(o, newline) {
  24987. if (newline) {
  24988. return encodeObjectPretty(o, newline);
  24989. }
  24990. var a = [
  24991. "{",
  24992. ""
  24993. ],
  24994. i, val;
  24995. for (i in o) {
  24996. val = o[i];
  24997. if (!useHasOwn || o.hasOwnProperty(i)) {
  24998. if (typeof val === 'function' || val === undefined) {
  24999. continue;
  25000. }
  25001. a.push(me.encodeValue(i), ":", me.encodeValue(val), ',');
  25002. }
  25003. }
  25004. a[a.length - 1] = '}';
  25005. return a.join("");
  25006. };
  25007. me.encodeString = encodeString;
  25008. me.encodeValue = doEncode;
  25009. me.encodeDate = function(o) {
  25010. return '"' + o.getFullYear() + "-" + pad(o.getMonth() + 1) + "-" + pad(o.getDate()) + "T" + pad(o.getHours()) + ":" + pad(o.getMinutes()) + ":" + pad(o.getSeconds()) + '"';
  25011. };
  25012. me.encode = function(o) {
  25013. if (hasNative && Ext.USE_NATIVE_JSON) {
  25014. return JSON.stringify(o);
  25015. }
  25016. return me.encodeValue(o);
  25017. };
  25018. me.decode = function(json, safe) {
  25019. try {
  25020. if (hasNative && Ext.USE_NATIVE_JSON) {
  25021. return JSON.parse(json);
  25022. }
  25023. return doDecode(json);
  25024. } catch (e) {
  25025. if (safe) {
  25026. return null;
  25027. }
  25028. Ext.raise({
  25029. sourceClass: "Ext.JSON",
  25030. sourceMethod: "decode",
  25031. msg: "You're trying to decode an invalid JSON String: " + json
  25032. });
  25033. }
  25034. };
  25035. me.encodeMSDate = encodeMSDate;
  25036. if (!Ext.util) {
  25037. Ext.util = {};
  25038. }
  25039. Ext.util.JSON = me;
  25040. Ext.encode = me.encode;
  25041. Ext.decode = me.decode;
  25042. })());
  25043. Ext.define('Ext.mixin.Inheritable', {
  25044. extend: Ext.Mixin,
  25045. mixinConfig: {
  25046. id: 'inheritable'
  25047. },
  25048. getInherited: function(inner) {
  25049. var me = this,
  25050. inheritedState = (inner && me.inheritedStateInner) || me.inheritedState,
  25051. ownerCt = me.getRefOwner(),
  25052. isContainer = me.isContainer,
  25053. parent, inheritedStateInner, getInner, ownerLayout;
  25054. if (!inheritedState || inheritedState.invalid) {
  25055. parent = me.getRefOwner();
  25056. ownerLayout = me.ownerLayout;
  25057. if (ownerCt) {
  25058. getInner = ownerLayout ? ownerLayout === ownerCt.layout : true;
  25059. }
  25060. me.inheritedState = inheritedState =
  25061. Ext.Object.chain(parent ? parent.getInherited(getInner) : Ext.rootInheritedState);
  25062. if (isContainer) {
  25063. me.inheritedStateInner = inheritedStateInner = Ext.Object.chain(inheritedState);
  25064. }
  25065. me.initInheritedState(inheritedState, inheritedStateInner);
  25066. inheritedState = (isContainer && inner) ? me.inheritedStateInner : me.inheritedState;
  25067. }
  25068. return inheritedState;
  25069. },
  25070. getInheritedConfig: function(property, skipThis) {
  25071. var state = this.inheritedState,
  25072. old, ret;
  25073. if (!state || state.invalid) {
  25074. state = this.getInherited();
  25075. }
  25076. ret = state[property];
  25077. if (skipThis && state.hasOwnProperty(property)) {
  25078. old = ret;
  25079. delete state[property];
  25080. ret = state[property];
  25081. state[property] = old;
  25082. }
  25083. return ret;
  25084. },
  25085. resolveListenerScope: function(defaultScope, skipThis) {
  25086. var me = this,
  25087. hasSkipThis = (typeof skipThis === 'boolean'),
  25088. namedScope = Ext._namedScopes[defaultScope],
  25089. ret;
  25090. if (!namedScope) {
  25091. ret = me.getInheritedConfig('defaultListenerScope', hasSkipThis ? skipThis : true) || defaultScope || me;
  25092. } else if (namedScope.isController) {
  25093. ret = me.getInheritedConfig('controller', hasSkipThis ? skipThis : !namedScope.isSelf);
  25094. } else if (namedScope.isOwner) {
  25095. ret = me.getRefOwner();
  25096. } else if (namedScope.isSelf) {
  25097. ret = me.getInheritedConfig('defaultListenerScope', hasSkipThis && skipThis) || me;
  25098. } else if (namedScope.isThis) {
  25099. ret = me;
  25100. }
  25101. return ret || null;
  25102. },
  25103. resolveSatelliteListenerScope: function(satellite, defaultScope) {
  25104. var me = this,
  25105. namedScope = Ext._namedScopes[defaultScope],
  25106. ret;
  25107. if (!namedScope) {
  25108. ret = me.getInheritedConfig('defaultListenerScope') || defaultScope || me;
  25109. } else if (namedScope.isController) {
  25110. ret = me.getInheritedConfig('controller');
  25111. } else if (namedScope.isSelf) {
  25112. ret = me.getInheritedConfig('defaultListenerScope') || satellite;
  25113. } else if (namedScope.isThis) {
  25114. ret = satellite;
  25115. }
  25116. return ret || null;
  25117. },
  25118. lookupNameHolder: function(skipThis) {
  25119. return this.getInheritedConfig('nameHolder', skipThis !== false) || null;
  25120. },
  25121. lookupReferenceHolder: function(skipThis) {
  25122. return this.getInheritedConfig('referenceHolder', skipThis !== false) || null;
  25123. },
  25124. getRefOwner: function() {
  25125. var me = this;
  25126. return me.ownerCmp || me.ownerCt || me.parent || me.$initParent || me.floatParent;
  25127. },
  25128. bubble: function(fn, scope, args) {
  25129. var target;
  25130. for (target = this; target; target = target.getRefOwner()) {
  25131. if (fn.apply(scope || target, args || [
  25132. target
  25133. ]) === false) {
  25134. break;
  25135. }
  25136. }
  25137. },
  25138. isDescendantOf: function(ancestor) {
  25139. return ancestor ? ancestor.isAncestor(this) : false;
  25140. },
  25141. isAncestor: function(possibleDescendant) {
  25142. while (possibleDescendant) {
  25143. if (possibleDescendant.getRefOwner() === this) {
  25144. return true;
  25145. }
  25146. possibleDescendant = possibleDescendant.getRefOwner();
  25147. }
  25148. return false;
  25149. },
  25150. invalidateInheritedState: function() {
  25151. var inheritedState = this.inheritedState;
  25152. if (inheritedState) {
  25153. inheritedState.invalid = true;
  25154. delete this.inheritedState;
  25155. }
  25156. },
  25157. privates: {
  25158. _fixReference: function() {
  25159. var me = this,
  25160. holder;
  25161. if (me.name && me.nameable) {
  25162. holder = me.lookupNameHolder();
  25163. if (holder && !holder.destroyed) {
  25164. holder.attachNameRef(me);
  25165. }
  25166. }
  25167. if (me.reference) {
  25168. holder = me.lookupReferenceHolder();
  25169. if (holder && !holder.destroyed) {
  25170. holder.attachReference(me);
  25171. }
  25172. }
  25173. },
  25174. onInheritedAdd: function(parent, instanced) {
  25175. var me = this;
  25176. if (me.inheritedState && instanced) {
  25177. me.invalidateInheritedState();
  25178. }
  25179. Ext.ComponentManager.markReferencesDirty();
  25180. },
  25181. onInheritedRemove: function(destroying) {
  25182. var me = this;
  25183. Ext.ComponentManager.markReferencesDirty();
  25184. if (me.inheritedState && !destroying) {
  25185. me.invalidateInheritedState();
  25186. }
  25187. }
  25188. }
  25189. },
  25190. function() {
  25191. Ext.rootInheritedState = {};
  25192. });
  25193. Ext.define('Ext.mixin.Bindable', {
  25194. mixinId: 'bindable',
  25195. config: {
  25196. bind: {
  25197. $value: null,
  25198. lazy: true
  25199. },
  25200. controller: null,
  25201. defaultListenerScope: false,
  25202. publishes: {
  25203. $value: null,
  25204. lazy: true,
  25205. merge: function(newValue, oldValue) {
  25206. return this.mergeSets(newValue, oldValue);
  25207. }
  25208. },
  25209. session: {
  25210. $value: null,
  25211. lazy: true
  25212. },
  25213. twoWayBindable: {
  25214. $value: null,
  25215. lazy: true,
  25216. merge: function(newValue, oldValue) {
  25217. return this.mergeSets(newValue, oldValue);
  25218. }
  25219. },
  25220. viewModel: {
  25221. $value: null,
  25222. lazy: true
  25223. }
  25224. },
  25225. defaultBindProperty: null,
  25226. nameable: false,
  25227. shareableName: false,
  25228. reference: null,
  25229. validRefRe: /^[a-z_][a-z0-9_]*$/i,
  25230. getReference: function() {
  25231. return this.reference;
  25232. },
  25233. initInheritedState: function(inheritedState) {
  25234. var me = this,
  25235. reference = me.reference,
  25236. controller = me.getController(),
  25237. viewModel = me.getConfig('viewModel', true),
  25238. session = me.getConfig('session', true),
  25239. defaultListenerScope = me.getDefaultListenerScope();
  25240. if (controller) {
  25241. inheritedState.controller = controller;
  25242. }
  25243. if (defaultListenerScope) {
  25244. inheritedState.defaultListenerScope = me;
  25245. } else if (controller) {
  25246. inheritedState.defaultListenerScope = controller;
  25247. }
  25248. if (viewModel) {
  25249. if (!viewModel.isViewModel) {
  25250. viewModel = me;
  25251. }
  25252. inheritedState.viewModel = viewModel;
  25253. }
  25254. if (session) {
  25255. if (!session.isSession) {
  25256. session = me;
  25257. }
  25258. inheritedState.session = session;
  25259. }
  25260. if (reference) {
  25261. me.referenceKey = (inheritedState.referencePath || '') + reference;
  25262. me.viewModelKey = (inheritedState.viewModelPath || '') + reference;
  25263. }
  25264. },
  25265. isBound: function(name) {
  25266. var bind = this.getBind();
  25267. return !!(bind && (bind[name || this.defaultBindProperty]));
  25268. },
  25269. lookupController: function(skipThis) {
  25270. return this.getInheritedConfig('controller', skipThis) || null;
  25271. },
  25272. lookupSession: function(skipThis) {
  25273. var ret = skipThis ? null : this.getSession();
  25274. if (!ret) {
  25275. ret = this.getInheritedConfig('session', skipThis);
  25276. if (ret && !ret.isSession) {
  25277. ret = ret.getInherited().session = ret.getSession();
  25278. }
  25279. }
  25280. return ret || null;
  25281. },
  25282. lookupViewModel: function(skipThis) {
  25283. var ret = skipThis ? null : this.getViewModel();
  25284. if (!ret) {
  25285. ret = this.getInheritedConfig('viewModel', skipThis);
  25286. if (ret && !ret.isViewModel) {
  25287. ret = ret.getInherited().viewModel = ret.getViewModel();
  25288. }
  25289. }
  25290. return ret || null;
  25291. },
  25292. publishState: function(property, value) {
  25293. var me = this,
  25294. state = me.publishedState,
  25295. binds = me.getBind(),
  25296. binding = binds && property && binds[property],
  25297. count = 0,
  25298. name, publishes, vm, path;
  25299. if (!(arguments.length === 0 || arguments.length === 2)) {
  25300. Ext.raise('publishState must either be called with no args, or with both name ' + 'AND value passed');
  25301. }
  25302. if (binding && !binding.syncing && !binding.isReadOnly()) {
  25303. if (binding.calls || !(value == null || value === me.getInitialConfig()[property])) {
  25304. binding.setValue(value);
  25305. }
  25306. }
  25307. if (!(publishes = me.getPublishes())) {
  25308. return;
  25309. }
  25310. if (!(vm = me.lookupViewModel())) {
  25311. return;
  25312. }
  25313. if (!(path = me.viewModelKey)) {
  25314. return;
  25315. }
  25316. state = state || (me.publishedState = {});
  25317. if (property) {
  25318. if (!publishes[property]) {
  25319. return;
  25320. }
  25321. if (!(value && value.constructor === Object) && !(value instanceof Array)) {
  25322. if (state[property] === value) {
  25323. return;
  25324. }
  25325. }
  25326. path += '.';
  25327. path += property;
  25328. } else {
  25329. for (name in publishes) {
  25330. ++count;
  25331. state[name] = me.getConfig(name);
  25332. }
  25333. if (!count) {
  25334. return;
  25335. }
  25336. value = state;
  25337. }
  25338. vm.set(path, value);
  25339. },
  25340. privates: {
  25341. applyBind: function(binds, currentBindings) {
  25342. if (!binds) {
  25343. return currentBindings;
  25344. }
  25345. var me = this,
  25346. viewModel = me.lookupViewModel(),
  25347. twoWayable = me.getTwoWayBindable(),
  25348. getBindTemplateScope = me._getBindTemplateScope,
  25349. b, watch, property, descriptor;
  25350. if (!viewModel) {
  25351. Ext.raise('Cannot use bind config without a viewModel');
  25352. }
  25353. if (typeof binds === 'string') {
  25354. if (!me.defaultBindProperty) {
  25355. Ext.raise(me.$className + ' has no defaultBindProperty - ' + 'Please specify a bind object');
  25356. }
  25357. b = binds;
  25358. binds = {};
  25359. binds[me.defaultBindProperty] = b;
  25360. }
  25361. for (property in binds) {
  25362. descriptor = binds[property];
  25363. b = currentBindings && currentBindings[property];
  25364. if (b) {
  25365. b.destroy();
  25366. delete currentBindings[property];
  25367. }
  25368. if (descriptor) {
  25369. if (!b && twoWayable && twoWayable[property]) {
  25370. (watch || (watch = {}))[property] = '_onConfigPropChange';
  25371. }
  25372. b = viewModel.bind(descriptor, me.onBindNotify, me);
  25373. b._config = Ext.Config.get(property);
  25374. b.getTemplateScope = getBindTemplateScope;
  25375. if (!me[b._config.names.set]) {
  25376. Ext.raise('Cannot bind ' + property + ' on ' + me.$className + ' - missing a ' + b._config.names.set + ' method.');
  25377. }
  25378. (currentBindings || (currentBindings = {}))[property] = b;
  25379. }
  25380. }
  25381. if (watch) {
  25382. watch.scope = me;
  25383. me.watchConfig(watch);
  25384. }
  25385. me.$bindings = currentBindings;
  25386. return currentBindings;
  25387. },
  25388. applyController: function(controller) {
  25389. if (controller) {
  25390. controller = Ext.Factory.controller(controller);
  25391. controller.setView(this);
  25392. }
  25393. this.controller = controller;
  25394. return controller;
  25395. },
  25396. updatePublishes: function(all) {
  25397. var me = this,
  25398. property, watch;
  25399. if (all && me.lookupViewModel()) {
  25400. for (property in all) {
  25401. if (all[property]) {
  25402. (watch || (watch = {}))[property] = '_onConfigPropChange';
  25403. }
  25404. }
  25405. if (watch) {
  25406. watch.scope = me;
  25407. me.watchConfig(watch);
  25408. }
  25409. }
  25410. return all;
  25411. },
  25412. applySession: function(session) {
  25413. var parentSession, config;
  25414. if (!session) {
  25415. return null;
  25416. }
  25417. if (!session.isSession) {
  25418. parentSession = this.lookupSession(true);
  25419. config = (session === true) ? {} : session;
  25420. if (parentSession) {
  25421. session = parentSession.spawn(config);
  25422. } else {
  25423. session = new Ext.data['Session'](config);
  25424. }
  25425. }
  25426. return session;
  25427. },
  25428. applyViewModel: function(viewModel) {
  25429. var me = this,
  25430. config, session;
  25431. if (!viewModel) {
  25432. return null;
  25433. }
  25434. if (!viewModel.isViewModel) {
  25435. config = {
  25436. parent: me.lookupViewModel(true),
  25437. view: me
  25438. };
  25439. config.session = me.getSession();
  25440. if (!session && !config.parent) {
  25441. config.session = me.lookupSession();
  25442. }
  25443. if (viewModel) {
  25444. if (viewModel.constructor === Object) {
  25445. Ext.apply(config, viewModel);
  25446. } else if (typeof viewModel === 'string') {
  25447. config.type = viewModel;
  25448. }
  25449. }
  25450. viewModel = Ext.Factory.viewModel(config);
  25451. }
  25452. return viewModel;
  25453. },
  25454. _getBindTemplateScope: function() {
  25455. return this.scope.resolveListenerScope();
  25456. },
  25457. destroyBindable: function() {
  25458. var me = this,
  25459. viewModel = me.getConfig('viewModel', true),
  25460. session = me.getConfig('session', true),
  25461. controller = me.getController();
  25462. if (viewModel && viewModel.isViewModel) {
  25463. viewModel.destroy();
  25464. me.setViewModel(null);
  25465. }
  25466. if (session && session.isSession) {
  25467. if (session.getAutoDestroy()) {
  25468. session.destroy();
  25469. }
  25470. me.setSession(null);
  25471. }
  25472. if (controller) {
  25473. me.setController(null);
  25474. controller.destroy();
  25475. }
  25476. },
  25477. initBindable: function() {
  25478. var me = this,
  25479. controller = me.controller;
  25480. me.initBindable = Ext.emptyFn;
  25481. me.getBind();
  25482. me.getPublishes();
  25483. if (!me.viewModel) {
  25484. me.getViewModel();
  25485. }
  25486. if (controller) {
  25487. controller.initBindings();
  25488. }
  25489. if (me.reference) {
  25490. me.publishState();
  25491. }
  25492. },
  25493. isSyncing: function(name) {
  25494. var bindings = this.getBind(),
  25495. ret = false,
  25496. binding;
  25497. if (bindings) {
  25498. binding = bindings[name];
  25499. if (binding) {
  25500. ret = binding.syncing > 0;
  25501. }
  25502. }
  25503. return ret;
  25504. },
  25505. notifyIf: function(skipThis) {
  25506. var vm = this.lookupViewModel(skipThis);
  25507. if (vm) {
  25508. vm.notify();
  25509. }
  25510. },
  25511. onBindNotify: function(value, oldValue, binding) {
  25512. binding.syncing = (binding.syncing + 1) || 1;
  25513. this[binding._config.names.set](value);
  25514. --binding.syncing;
  25515. },
  25516. _onConfigPropChange: function(me, name, value) {
  25517. me.publishState(name, value);
  25518. },
  25519. removeBindings: function() {
  25520. var me = this,
  25521. bindings = me.$bindings,
  25522. b, key;
  25523. if (bindings) {
  25524. for (key in bindings) {
  25525. b = bindings[key];
  25526. if (b) {
  25527. b.destroy();
  25528. b._config = b.getTemplateScope = null;
  25529. bindings[key] = null;
  25530. }
  25531. }
  25532. }
  25533. },
  25534. updateSession: function(session) {
  25535. var state = this.getInherited();
  25536. if (session) {
  25537. state.session = session;
  25538. } else {
  25539. delete state.session;
  25540. }
  25541. },
  25542. updateViewModel: function(viewModel, oldViewModel) {
  25543. var me = this,
  25544. state = me.getInherited(),
  25545. controller = me.getController();
  25546. if (viewModel) {
  25547. me.hasVM = true;
  25548. state.viewModel = viewModel;
  25549. viewModel.setView(me);
  25550. if (controller) {
  25551. controller.initViewModel(viewModel);
  25552. }
  25553. } else {
  25554. delete state.viewModel;
  25555. }
  25556. me.viewModel = viewModel;
  25557. }
  25558. }
  25559. });
  25560. Ext.define('Ext.mixin.ComponentDelegation', {
  25561. extend: Ext.Mixin,
  25562. mixinConfig: {
  25563. id: 'componentDelegation'
  25564. },
  25565. privates: {
  25566. addDelegatedListener: function(eventName, fn, scope, options, order, caller, manager) {
  25567. var me = this,
  25568. delegatedEvents, event, priority;
  25569. eventName = Ext.canonicalEventName(eventName);
  25570. order = order || options.order;
  25571. if (order) {
  25572. priority = (options && options.priority);
  25573. if (!priority) {
  25574. options = options ? Ext.Object.chain(options) : {};
  25575. options.priority = me.$orderToPriority[order];
  25576. }
  25577. }
  25578. if (options.target) {
  25579. Ext.raise("Cannot add '" + eventName + "' listener to component: '" + me.id + "' - 'delegate' and 'target' event options are incompatible.");
  25580. }
  25581. delegatedEvents = me.$delegatedEvents || (me.$delegatedEvents = {});
  25582. event = delegatedEvents[eventName] || (delegatedEvents[eventName] = new Ext.util.Event(me, eventName));
  25583. if (event.addListener(fn, scope, options, caller, manager)) {
  25584. me.$hasDelegatedListeners._incr_(eventName);
  25585. }
  25586. },
  25587. clearDelegatedListeners: function() {
  25588. var me = this,
  25589. delegatedEvents = me.$delegatedEvents,
  25590. eventName, event, listenerCount;
  25591. if (delegatedEvents) {
  25592. for (eventName in delegatedEvents) {
  25593. event = delegatedEvents[eventName];
  25594. listenerCount = event.listeners.length;
  25595. event.clearListeners();
  25596. me.$hasDelegatedListeners._decr_(eventName, listenerCount);
  25597. delete delegatedEvents[eventName];
  25598. }
  25599. }
  25600. },
  25601. doFireDelegatedEvent: function(eventName, args) {
  25602. var me = this,
  25603. ret = true,
  25604. owner, delegatedEvents, event;
  25605. if (me.$hasDelegatedListeners[eventName]) {
  25606. owner = me.getRefOwner();
  25607. while (owner) {
  25608. delegatedEvents = owner.$delegatedEvents;
  25609. if (delegatedEvents) {
  25610. event = delegatedEvents[eventName];
  25611. if (event) {
  25612. ret = event.fireDelegated(me, args);
  25613. if (ret === false) {
  25614. break;
  25615. }
  25616. }
  25617. }
  25618. owner = owner.getRefOwner();
  25619. }
  25620. }
  25621. return ret;
  25622. },
  25623. removeDelegatedListener: function(eventName, fn, scope) {
  25624. var me = this,
  25625. delegatedEvents = me.$delegatedEvents,
  25626. event;
  25627. if (delegatedEvents) {
  25628. event = delegatedEvents[eventName];
  25629. if (event && event.removeListener(fn, scope)) {
  25630. me.$hasDelegatedListeners._decr_(eventName);
  25631. if (event.listeners.length === 0) {
  25632. delete delegatedEvents[eventName];
  25633. }
  25634. }
  25635. }
  25636. },
  25637. destroyComponentDelegation: function() {
  25638. if (this.clearPropertiesOnDestroy) {
  25639. this.$delegatedEvents = null;
  25640. }
  25641. }
  25642. },
  25643. onClassMixedIn: function(T) {
  25644. function HasListeners() {}
  25645. T.prototype.HasListeners = T.HasListeners = HasListeners;
  25646. HasListeners.prototype = T.hasListeners = new Ext.mixin.ComponentDelegation.HasDelegatedListeners();
  25647. }
  25648. }, function(ComponentDelegation) {
  25649. function HasDelegatedListeners() {}
  25650. ComponentDelegation.HasDelegatedListeners = HasDelegatedListeners;
  25651. HasDelegatedListeners.prototype = ComponentDelegation.prototype.$hasDelegatedListeners = new Ext.mixin.Observable.HasListeners();
  25652. });
  25653. Ext.define('Ext.plugin.Abstract', {
  25654. alternateClassName: 'Ext.AbstractPlugin',
  25655. mixins: [
  25656. Ext.mixin.Identifiable
  25657. ],
  25658. isPlugin: true,
  25659. constructor: function(config) {
  25660. if (config) {
  25661. this.cmp = config.cmp;
  25662. this.pluginConfig = config;
  25663. this.initConfig(config);
  25664. }
  25665. },
  25666. init: Ext.emptyFn,
  25667. destroy: function() {
  25668. var me = this;
  25669. me.destroy = Ext.emptyFn;
  25670. me.destroying = true;
  25671. me.cmp = me.pluginConfig = null;
  25672. me.doDestroy();
  25673. me.callParent();
  25674. },
  25675. doDestroy: Ext.emptyFn,
  25676. clonePlugin: function(overrideCfg) {
  25677. return new this.self(Ext.apply({}, overrideCfg, this.pluginConfig));
  25678. },
  25679. getCmp: function() {
  25680. return this.cmp;
  25681. },
  25682. setCmp: function(host) {
  25683. this.cmp = host;
  25684. },
  25685. getStatefulOwner: function() {
  25686. return [
  25687. this.cmp,
  25688. 'plugins'
  25689. ];
  25690. },
  25691. onClassExtended: function(cls, data, hooks) {
  25692. var alias = data.alias,
  25693. prototype = cls.prototype;
  25694. if (alias && !data.ptype) {
  25695. if (Ext.isArray(alias)) {
  25696. alias = alias[0];
  25697. }
  25698. prototype.ptype = alias.split('plugin.')[1];
  25699. }
  25700. },
  25701. resolveListenerScope: function(defaultScope) {
  25702. var me = this,
  25703. cmp = me.getCmp(),
  25704. scope;
  25705. if (cmp) {
  25706. scope = cmp.resolveSatelliteListenerScope(me, defaultScope);
  25707. }
  25708. return scope || me.mixins.observable.resolveListenerScope.call(me, defaultScope);
  25709. },
  25710. statics: {
  25711. decode: function(plugins, typeProp, include) {
  25712. if (plugins) {
  25713. var type = Ext.typeOf(plugins),
  25714. entry, key, obj, value;
  25715. if (type === 'string') {
  25716. obj = {};
  25717. obj[typeProp] = plugins;
  25718. plugins = [
  25719. obj
  25720. ];
  25721. } else if (plugins.isInstance) {
  25722. plugins = [
  25723. plugins
  25724. ];
  25725. } else if (type === 'object') {
  25726. if (plugins[typeProp]) {
  25727. plugins = [
  25728. plugins
  25729. ];
  25730. } else {
  25731. obj = include ? Ext.merge(Ext.clone(include), plugins) : plugins;
  25732. plugins = [];
  25733. for (key in obj) {
  25734. if (!(value = obj[key])) {
  25735. continue;
  25736. }
  25737. entry = {
  25738. id: key
  25739. };
  25740. entry[typeProp] = key;
  25741. Ext.apply(entry, value);
  25742. plugins.push(entry);
  25743. }
  25744. Ext.sortByWeight(plugins);
  25745. }
  25746. }
  25747. else if (type !== 'array') {
  25748. Ext.raise('Invalid value for "plugins" config ("' + type + '"');
  25749. } else
  25750. {
  25751. plugins = plugins.slice();
  25752. }
  25753. }
  25754. return plugins;
  25755. }
  25756. }
  25757. });
  25758. Ext.define('Ext.mixin.Pluggable', function(Pluggable) {
  25759. return {
  25760. mixinId: 'pluggable',
  25761. config: {
  25762. plugins: null
  25763. },
  25764. addPlugin: function(plugin) {
  25765. var me = this,
  25766. plugins = me.getPlugins();
  25767. if (plugins) {
  25768. plugin = me.createPlugin(plugin);
  25769. plugin.init(me);
  25770. plugins.push(plugin);
  25771. } else {
  25772. me.setPlugins(plugin);
  25773. plugin = me.getPlugins()[0];
  25774. }
  25775. return plugin;
  25776. },
  25777. destroyPlugin: function(plugin) {
  25778. return this.removePlugin(plugin, true);
  25779. },
  25780. findPlugin: function(type) {
  25781. var plugins = this.getPlugins(),
  25782. n = plugins && plugins.length,
  25783. i, plugin, ret;
  25784. for (i = 0; i < n && !ret; i++) {
  25785. plugin = plugins[i];
  25786. if (plugin.type === type || plugin.ptype === type) {
  25787. ret = plugin;
  25788. }
  25789. }
  25790. return ret || null;
  25791. },
  25792. getPlugin: function(id) {
  25793. var plugins = this.getPlugins(),
  25794. n = plugins && plugins.length,
  25795. i, plugin, ret;
  25796. for (i = 0; i < n && !ret; i++) {
  25797. plugin = plugins[i];
  25798. if (plugin.id === id || plugin.pluginId === id) {
  25799. ret = plugin;
  25800. }
  25801. }
  25802. return ret || null;
  25803. },
  25804. removePlugin: function(plugin, destroy) {
  25805. var plugins = this.getPlugins(),
  25806. i = plugins && plugins.length || 0,
  25807. p;
  25808. while (i-- > 0) {
  25809. p = plugins[i];
  25810. if (p === plugin || p.id === plugin) {
  25811. plugins.splice(i, 1);
  25812. if (destroy) {
  25813. if (p.destroy) {
  25814. p.destroy();
  25815. }
  25816. } else if (p.detachCmp) {
  25817. p.detachCmp();
  25818. if (p.setCmp) {
  25819. p.setCmp(null);
  25820. }
  25821. }
  25822. break;
  25823. }
  25824. p = null;
  25825. }
  25826. return p;
  25827. },
  25828. privates: {
  25829. statics: {
  25830. idSeed: 0
  25831. },
  25832. activatePlugin: function(type) {
  25833. var me = this,
  25834. config = me.initialConfig,
  25835. plugins = config && config.plugins,
  25836. ret = null,
  25837. i, include, p;
  25838. if (plugins) {
  25839. include = me.config.plugins;
  25840. include = (include && typeof include === 'object') ? include : null;
  25841. plugins = Ext.plugin.Abstract.decode(plugins, 'type', include);
  25842. for (i = plugins.length; i-- > 0; ) {
  25843. p = plugins[i];
  25844. if (p === type || p.type === type) {
  25845. me.initialConfig = config = Ext.apply({}, config);
  25846. config.plugins = plugins;
  25847. plugins[i] = ret = me.createPlugin(p);
  25848. break;
  25849. }
  25850. }
  25851. }
  25852. return ret;
  25853. },
  25854. applyPlugins: function(plugins, oldPlugins) {
  25855. var me = this,
  25856. oldCount = oldPlugins && oldPlugins.length || 0,
  25857. count, i, plugin;
  25858. if (plugins) {
  25859. plugins = Ext.plugin.Abstract.decode(plugins, 'type');
  25860. }
  25861. for (i = 0; i < oldCount; ++i) {
  25862. oldPlugins[i].$dead = true;
  25863. }
  25864. count = plugins && plugins.length || 0;
  25865. for (i = 0; i < count; ++i) {
  25866. plugins[i] = me.createPlugin(plugins[i]);
  25867. }
  25868. for (i = 0; i < count; ++i) {
  25869. plugin = plugins[i];
  25870. if (plugin.$dead) {
  25871. delete plugin.$dead;
  25872. } else
  25873. {
  25874. plugin.init(me);
  25875. }
  25876. }
  25877. for (i = 0; i < oldCount; ++i) {
  25878. if ((plugin = oldPlugins[i]).$dead) {
  25879. delete plugin.$dead;
  25880. Ext.destroy(plugin);
  25881. }
  25882. }
  25883. return plugins;
  25884. },
  25885. createPlugin: function(config) {
  25886. var ret;
  25887. if (typeof config === 'string') {
  25888. config = {
  25889. type: config
  25890. };
  25891. }
  25892. ret = config;
  25893. if (!config.isInstance) {
  25894. config.cmp = this;
  25895. ret = Ext.factory(config, null, null, 'plugin');
  25896. delete config.cmp;
  25897. }
  25898. if (!ret.id) {
  25899. ret.id = ++Pluggable.idSeed;
  25900. }
  25901. if (ret.setCmp) {
  25902. ret.setCmp(this);
  25903. }
  25904. return ret;
  25905. }
  25906. }
  25907. };
  25908. });
  25909. Ext.define('Ext.mixin.Keyboard', function(Keyboard) {
  25910. return {
  25911. extend: Ext.Mixin,
  25912. mixinConfig: {
  25913. id: 'keyboard'
  25914. },
  25915. config: {
  25916. keyMap: {
  25917. $value: null,
  25918. cached: true,
  25919. merge: function(value, baseValue, cls, mixin) {
  25920. var ret, key, ucKey, v, vs;
  25921. if (value === null) {
  25922. return value;
  25923. }
  25924. ret = (baseValue && !cls.isInstance) ? Ext.Object.chain(baseValue) : {};
  25925. for (key in value) {
  25926. if (key !== 'scope') {
  25927. ucKey = key.toUpperCase();
  25928. if (!mixin || ret[ucKey] === undefined) {
  25929. v = value[key];
  25930. if (v) {
  25931. if (typeof v === 'string' || typeof v === 'function') {
  25932. v = {
  25933. handler: v
  25934. };
  25935. } else {
  25936. v = Ext.apply({
  25937. handler: v.fn
  25938. },
  25939. v);
  25940. }
  25941. vs = v.scope || value.scope || 'self';
  25942. v.scope = (vs === 'controller') ? 'self.controller' : vs;
  25943. }
  25944. ret[ucKey] = v;
  25945. }
  25946. }
  25947. }
  25948. return ret;
  25949. }
  25950. },
  25951. keyMapEnabled: null
  25952. },
  25953. keyMapTarget: 'el',
  25954. applyKeyMap: function(keyMap, existingKeyMap) {
  25955. var me = this,
  25956. own = me.hasOwnProperty('config');
  25957. if (own && existingKeyMap && existingKeyMap.$owner !== me) {
  25958. existingKeyMap = Ext.apply({}, existingKeyMap);
  25959. }
  25960. keyMap = keyMap ? Keyboard.combineKeyMaps(existingKeyMap, keyMap, own && me) : null;
  25961. if (me._keyMapReady) {
  25962. me.setKeyMapListener(keyMap && me.getKeyMapEnabled());
  25963. }
  25964. return keyMap;
  25965. },
  25966. initKeyMap: function() {
  25967. var me = this,
  25968. enabled = me.getKeyMapEnabled();
  25969. me._keyMapReady = true;
  25970. if (enabled === null) {
  25971. me.setKeyMapEnabled(true);
  25972. } else {
  25973. me.setKeyMapListener(enabled && me.getKeyMap());
  25974. }
  25975. },
  25976. disableKeyMapGroup: function(group) {
  25977. this.setKeyMapGroupEnabled(group, false);
  25978. },
  25979. enableKeyMapGroup: function(group) {
  25980. this.setKeyMapGroupEnabled(group, true);
  25981. },
  25982. setKeyMapGroupEnabled: function(group, state) {
  25983. var me = this,
  25984. disabledGroups = me.disabledKeyMapGroups || (me.disabledKeyMapGroups = {});
  25985. disabledGroups[group] = !state;
  25986. },
  25987. updateKeyMapEnabled: function(enabled) {
  25988. this.setKeyMapListener(enabled && this._keyMapReady && this.getKeyMap());
  25989. },
  25990. privates: {
  25991. _keyMapListenCount: 0,
  25992. _keyMapReady: false,
  25993. comparePriorities: function(lhs, rhs) {
  25994. return (rhs.priority || 0) - (lhs.priority || 0);
  25995. },
  25996. findKeyMapEntries: function(e) {
  25997. var me = this,
  25998. disabledGroups = me.disabledKeyMapGroups,
  25999. keyMap = me.getKeyMap(),
  26000. entries = keyMap && Keyboard.getKeyName(e),
  26001. result = [],
  26002. entry, len, i;
  26003. entries = entries && keyMap[entries];
  26004. if (entries) {
  26005. if (!entries.sorted) {
  26006. Ext.Array.sort(entries, me.comparePriorities);
  26007. entries.sorted = true;
  26008. }
  26009. len = entries.length;
  26010. for (i = 0; i < len; i++) {
  26011. entry = entries[i];
  26012. if (!disabledGroups || !disabledGroups[entry.group]) {
  26013. if (Keyboard.matchEntry(entry, e)) {
  26014. result.push(entry);
  26015. }
  26016. }
  26017. }
  26018. }
  26019. return result;
  26020. },
  26021. onKeyMapEvent: function(e) {
  26022. var me = this,
  26023. entries = me.getKeyMapEnabled() ? me.findKeyMapEntries(e) : null,
  26024. len = entries && entries.length,
  26025. i, entry, result;
  26026. me.lastKeyMapEvent = e;
  26027. for (i = 0; i < len && result !== false; i++) {
  26028. entry = entries[i];
  26029. result = Ext.callback(entry.handler, entry.scope, [
  26030. e,
  26031. this
  26032. ], 0, this);
  26033. }
  26034. return result;
  26035. },
  26036. setKeyMapListener: function(enabled) {
  26037. var me = this,
  26038. listener = me._keyMapListener,
  26039. eventSource;
  26040. if (listener) {
  26041. listener.destroy();
  26042. listener = null;
  26043. }
  26044. if (enabled) {
  26045. ++me._keyMapListenCount;
  26046. if (enabled) {
  26047. eventSource = me[me.keyMapTarget];
  26048. if (typeof eventSource === 'function') {
  26049. eventSource = eventSource.call(me);
  26050. }
  26051. listener = eventSource.on({
  26052. destroyable: true,
  26053. scope: me,
  26054. keydown: 'onKeyMapEvent',
  26055. keypress: 'onKeyMapEvent'
  26056. });
  26057. }
  26058. }
  26059. me._keyMapListener = listener || null;
  26060. },
  26061. statics: {
  26062. _charCodeRe: /^#([\d]+)$/,
  26063. _keySpecRe: /^(?:(?:(\*)[\+\-])|(?:([a-z\+\-]*)[\+\-]))?(?:([a-z0-9_]+|[\+\-]|(?:#?\d+))(?:\:([a-z]+))?)$/i,
  26064. _delimiterRe: /-|\+/,
  26065. _keyMapEvents: {
  26066. charCode: 'keypress',
  26067. keyCode: 'keydown'
  26068. },
  26069. combineKeyMaps: function(existingKeyMap, keyMap, owner) {
  26070. var defaultScope = keyMap.scope || 'controller',
  26071. entry, key, mapping, existingMapping;
  26072. for (key in keyMap) {
  26073. if (key === 'scope') {
  26074. continue;
  26075. }
  26076. if (!(mapping = keyMap[key])) {
  26077. if (mapping === undefined) {
  26078. Ext.raise('keyMap entry "' + key + '" is undefined');
  26079. }
  26080. if (!existingKeyMap) {
  26081. continue;
  26082. }
  26083. } else {
  26084. if (typeof mapping === 'string' || typeof mapping === 'function') {
  26085. mapping = {
  26086. handler: mapping,
  26087. scope: defaultScope
  26088. };
  26089. } else if (mapping) {
  26090. mapping = Ext.apply({
  26091. handler: mapping.fn,
  26092. scope: defaultScope
  26093. },
  26094. mapping);
  26095. }
  26096. existingKeyMap = existingKeyMap || {};
  26097. }
  26098. if (Keyboard.parseEntry(key, entry = mapping || {})) {
  26099. existingMapping = existingKeyMap[entry.name];
  26100. if (existingMapping) {
  26101. if (owner && existingMapping.$owner !== owner) {
  26102. existingKeyMap[entry.name] = existingMapping = existingMapping.slice();
  26103. existingMapping.$owner = owner;
  26104. }
  26105. existingMapping.push(mapping);
  26106. existingMapping.sorted = false;
  26107. } else {
  26108. existingMapping = existingKeyMap[entry.name] = [
  26109. mapping
  26110. ];
  26111. existingMapping.$owner = owner;
  26112. existingMapping.sorted = true;
  26113. }
  26114. } else
  26115. {
  26116. Ext.raise('Invalid keyMap key specification "' + key + '"');
  26117. }
  26118. }
  26119. if (existingKeyMap && owner) {
  26120. existingKeyMap.$owner = owner;
  26121. }
  26122. return existingKeyMap || null;
  26123. },
  26124. getKeyName: function(event) {
  26125. var keyCode;
  26126. if (event.isEvent) {
  26127. keyCode = event.keyCode || event.charCode;
  26128. event = event.browserEvent;
  26129. if (keyCode === 229 && 'code' in event) {
  26130. if (Ext.String.startsWith(event.code, 'Key')) {
  26131. return event.key.substr(3);
  26132. }
  26133. if (Ext.String.startsWith(event.code, 'Digit')) {
  26134. return event.key.substr(5);
  26135. }
  26136. }
  26137. } else {
  26138. keyCode = event;
  26139. }
  26140. return Ext.event.Event.keyCodes[keyCode] || String.fromCharCode(keyCode);
  26141. },
  26142. matchEntry: function(entry, e) {
  26143. var ev = e.browserEvent,
  26144. code;
  26145. if (e.type !== entry.event) {
  26146. return false;
  26147. }
  26148. if (!(code = entry.charCode)) {
  26149. if (entry.keyCode !== e.keyCode || (!entry.ignoreModifiers && !entry.shiftKey !== !ev.shiftKey)) {
  26150. return false;
  26151. }
  26152. } else if (e.getCharCode() !== code) {
  26153. return false;
  26154. }
  26155. return entry.ignoreModifiers || (!entry.ctrlKey === !ev.ctrlKey && !entry.altKey === !ev.altKey && !entry.metaKey === !ev.metaKey && !entry.shiftKey === !ev.shiftKey);
  26156. },
  26157. parseEntry: function(key, entry) {
  26158. key = key.toUpperCase();
  26159. var me = this,
  26160. Event = Ext.event.Event,
  26161. keyFlags = Event.keyFlags,
  26162. parts = me._keySpecRe.exec(key),
  26163. type = 'keyCode',
  26164. name, code, i, match, n;
  26165. if (parts) {
  26166. name = parts[3];
  26167. if (parts[4]) {
  26168. entry.group = parts[4];
  26169. }
  26170. if (!(entry.ignoreModifiers = !!parts[1]) && parts[2]) {
  26171. parts = parts[2].split(me._delimiterRe);
  26172. n = parts.length;
  26173. for (i = 0; i < n; i++) {
  26174. if (!keyFlags[parts[i]]) {
  26175. return false;
  26176. }
  26177. entry[keyFlags[parts[i]]] = true;
  26178. }
  26179. }
  26180. entry.name = name;
  26181. if (isNaN(code = Event[name])) {
  26182. if (!(match = me._charCodeRe.exec(name))) {
  26183. if (name.length === 1) {
  26184. code = name.charCodeAt(0);
  26185. }
  26186. } else {
  26187. code = +match[1];
  26188. }
  26189. if (code) {
  26190. type = 'charCode';
  26191. } else {
  26192. code = +name;
  26193. }
  26194. entry.name = Keyboard.getKeyName(code);
  26195. }
  26196. entry.event = entry.event || me._keyMapEvents[type];
  26197. return !isNaN(code) && (entry[type] = code);
  26198. }
  26199. }
  26200. }
  26201. }
  26202. };
  26203. });
  26204. Ext.define('Ext.mixin.Focusable', {
  26205. mixinId: 'focusable',
  26206. $isFocusableEntity: true,
  26207. focusable: false,
  26208. hasFocus: false,
  26209. containsFocus: false,
  26210. focusCls: Ext.baseCSSPrefix + 'focused',
  26211. focusEl: 'el',
  26212. getFocusEl: function()
  26213. {
  26214. var focusEl = this.focusEl;
  26215. return focusEl && focusEl.dom ? focusEl : null;
  26216. },
  26217. getFocusClsEl: function() {
  26218. return this.getFocusEl();
  26219. },
  26220. initFocusable: Ext.emptyFn,
  26221. initFocusableEvents: function(force) {
  26222. this.initFocusableElement(force);
  26223. },
  26224. enableFocusable: Ext.emptyFn,
  26225. disableFocusable: function() {
  26226. var me = this;
  26227. if (me.hasFocus) {
  26228. me.revertFocus();
  26229. }
  26230. me.removeFocusCls();
  26231. },
  26232. destroyFocusable: function() {
  26233. var me = this;
  26234. Ext.destroy(me.focusListeners);
  26235. me.focusListeners = me.focusEnterEvent = me.focusTask = null;
  26236. me.focusEl = me.ariaEl = null;
  26237. },
  26238. isFocusable: function(deep) {
  26239. var me = this,
  26240. focusEl;
  26241. if (!me.focusable && (!me.isContainer || !deep)) {
  26242. return false;
  26243. }
  26244. focusEl = me.getFocusEl();
  26245. if (focusEl && me.canFocus()) {
  26246. return focusEl && !focusEl.destroyed && focusEl.isFocusable(deep);
  26247. }
  26248. return false;
  26249. },
  26250. isDestructing: function() {
  26251. var c;
  26252. for (c = this; c; c = c.getRefOwner()) {
  26253. if (c.destroying || c.destroyed) {
  26254. return true;
  26255. }
  26256. }
  26257. return false;
  26258. },
  26259. canFocus: function(skipVisibility, includeFocusTarget) {
  26260. var me = this,
  26261. ownerFC = me.ownerFocusableContainer,
  26262. focusableIfDisabled = ownerFC && ownerFC.allowFocusingDisabledChildren,
  26263. canFocus;
  26264. canFocus = !me.destroyed && me.rendered && !me.isDestructing() && (me.isContainer || me.focusable) && (!me.isDisabled() || focusableIfDisabled) && (skipVisibility || me.isVisible(true));
  26265. return canFocus || (includeFocusTarget && !!me.findFocusTarget());
  26266. },
  26267. focus: function(selectText) {
  26268. var me = this,
  26269. focusTarget, focusElDom;
  26270. if ((!me.focusable && !me.isContainer) || me.destroyed || me.destroying) {
  26271. return false;
  26272. }
  26273. if (me.canFocus() && (focusTarget = me.getFocusEl())) {
  26274. if (focusTarget.$isFocusableEntity) {
  26275. return focusTarget.focus.apply(focusTarget, arguments);
  26276. }
  26277. focusElDom = focusTarget.dom;
  26278. if (focusElDom) {
  26279. focusTarget.focus();
  26280. if (selectText && (me.selectText || focusElDom.select)) {
  26281. if (me.selectText) {
  26282. if (Ext.isArray(selectText)) {
  26283. me.selectText.apply(me, selectText);
  26284. } else {
  26285. me.selectText();
  26286. }
  26287. } else {
  26288. focusElDom.select();
  26289. }
  26290. }
  26291. }
  26292. else if (focusTarget.focus) {
  26293. focusTarget.focus();
  26294. } else {
  26295. return false;
  26296. }
  26297. } else {
  26298. focusTarget = me.findFocusTarget();
  26299. if (focusTarget && focusTarget !== me) {
  26300. return focusTarget.focus.apply(focusTarget, arguments);
  26301. } else {
  26302. return false;
  26303. }
  26304. }
  26305. return true;
  26306. },
  26307. onBlur: function(e) {
  26308. var me = this,
  26309. container = me.ownerFocusableContainer;
  26310. me.hasFocus = false;
  26311. if (me.beforeBlur && !me.beforeBlur.$emptyFn) {
  26312. me.beforeBlur(e);
  26313. }
  26314. if (container) {
  26315. container.beforeFocusableChildBlur(me, e);
  26316. }
  26317. me.removeFocusCls(e);
  26318. if (me.hasListeners.blur) {
  26319. me.fireEvent('blur', me, e);
  26320. }
  26321. if (me.postBlur && !me.postBlur.$emptyFn) {
  26322. me.postBlur(e);
  26323. }
  26324. if (container) {
  26325. container.afterFocusableChildBlur(me, e);
  26326. }
  26327. },
  26328. onFocus: function(e) {
  26329. var me = this,
  26330. container = me.ownerFocusableContainer;
  26331. if (me.canFocus()) {
  26332. if (me.beforeFocus && !me.beforeFocus.$emptyFn) {
  26333. me.beforeFocus(e);
  26334. }
  26335. if (container) {
  26336. container.beforeFocusableChildFocus(me, e);
  26337. }
  26338. me.addFocusCls(e);
  26339. if (!me.hasFocus) {
  26340. me.hasFocus = true;
  26341. me.fireEvent('focus', me, e);
  26342. }
  26343. if (me.postFocus && !me.postFocus.$emptyFn) {
  26344. me.postFocus(e);
  26345. }
  26346. if (container) {
  26347. container.afterFocusableChildFocus(me, e);
  26348. }
  26349. }
  26350. },
  26351. getTabIndex: function() {
  26352. var me = this,
  26353. el, index;
  26354. if (!me.focusable) {
  26355. return;
  26356. }
  26357. el = me.getFocusEl();
  26358. if (el) {
  26359. if (el.$isFocusableEntity) {
  26360. index = el.getTabIndex();
  26361. } else if (el.isElement && el.dom) {
  26362. index = el.dom.getAttribute('tabIndex');
  26363. if (index !== null) {
  26364. index -= 0;
  26365. }
  26366. } else
  26367. {
  26368. return;
  26369. }
  26370. }
  26371. if (typeof index !== 'number') {
  26372. index = me.tabIndex;
  26373. }
  26374. return index;
  26375. },
  26376. setTabIndex: function(newTabIndex, focusEl) {
  26377. var me = this,
  26378. ownerFC = me.ownerFocusableContainer,
  26379. focusableIfDisabled = ownerFC && ownerFC.allowFocusingDisabledChildren,
  26380. wasFocusable = me.focusable,
  26381. el;
  26382. if (!wasFocusable && !(me.forceTabIndex || newTabIndex == null)) {
  26383. return;
  26384. }
  26385. me.tabIndex = newTabIndex;
  26386. if (me.destroying || me.destroyed || (me.isDisabled() && !focusableIfDisabled)) {
  26387. return;
  26388. }
  26389. me.focusable = true;
  26390. el = focusEl || me.getFocusEl();
  26391. me.focusable = wasFocusable;
  26392. if (el) {
  26393. if (el.$isFocusableEntity) {
  26394. el.setTabIndex(newTabIndex);
  26395. }
  26396. else if (el.isElement && el.dom) {
  26397. el.setTabIndex(newTabIndex);
  26398. }
  26399. }
  26400. },
  26401. onFocusEnter: function(e) {
  26402. var me = this;
  26403. if (me.destroying || me.destroyed) {
  26404. return;
  26405. }
  26406. me.focusEnterEvent = e;
  26407. me.containsFocus = true;
  26408. if (me.hasListeners.focusenter) {
  26409. me.fireEvent('focusenter', me, e);
  26410. }
  26411. },
  26412. onFocusLeave: function(e) {
  26413. var me = this;
  26414. if (me.destroying || me.destroyed) {
  26415. return;
  26416. }
  26417. me.focusEnterEvent = null;
  26418. me.containsFocus = false;
  26419. if (me.hasListeners.focusleave) {
  26420. me.fireEvent('focusleave', me, e);
  26421. }
  26422. },
  26423. onFocusMove: Ext.emptyFn,
  26424. privates: {
  26425. forceTabIndex: false,
  26426. revertFocus: function() {
  26427. var me = this,
  26428. focusEvent = me.focusEnterEvent,
  26429. activeElement = Ext.Element.getActiveElement(),
  26430. focusTarget, fromComponent, reverted;
  26431. if (focusEvent && !me.preventRefocus && me.el.contains(activeElement)) {
  26432. fromComponent = focusEvent.fromComponent;
  26433. if (fromComponent && (fromComponent.destroyed || fromComponent.isDestructing())) {
  26434. focusTarget = document.body;
  26435. } else
  26436. {
  26437. focusTarget = focusEvent.relatedTarget;
  26438. }
  26439. if (focusTarget === document.body) {
  26440. fromComponent = me.findFocusTarget();
  26441. if (fromComponent) {
  26442. focusTarget = fromComponent.getFocusEl();
  26443. }
  26444. }
  26445. if (focusTarget && focusTarget.$isFocusableEntity) {
  26446. if (!focusTarget.destroyed && focusTarget.isFocusable()) {
  26447. focusTarget.focus();
  26448. }
  26449. }
  26450. else if (Ext.getDoc().contains(focusTarget) && Ext.fly(focusTarget).isFocusable()) {
  26451. fromComponent = Ext.Component.from(focusTarget);
  26452. if (fromComponent) {
  26453. fromComponent.revertFocusTo(focusTarget);
  26454. } else {
  26455. focusTarget.focus();
  26456. }
  26457. }
  26458. else if (focusEvent.fromComponent && focusEvent.fromComponent.focus) {
  26459. reverted = focusEvent.fromComponent.focus();
  26460. if (!reverted) {
  26461. activeElement.blur();
  26462. }
  26463. }
  26464. }
  26465. },
  26466. revertFocusTo: function(target) {
  26467. target.focus();
  26468. },
  26469. findFocusTarget: function() {
  26470. var me = this,
  26471. parentAxis, candidate, len, i, focusTargets, focusIndex;
  26472. if (me.preventRefocus) {
  26473. return null;
  26474. }
  26475. for (parentAxis = [] , candidate = me.getRefOwner(); candidate; candidate = candidate.getRefOwner()) {
  26476. if (!candidate.isDisabled()) {
  26477. parentAxis.unshift(candidate);
  26478. }
  26479. }
  26480. for (i = 0 , len = parentAxis.length; i < len; i++) {
  26481. candidate = parentAxis[i];
  26482. if (candidate.destroying || !candidate.isVisible()) {
  26483. parentAxis.length = i;
  26484. break;
  26485. }
  26486. }
  26487. for (i = parentAxis.length - 1; i >= 0; i--) {
  26488. candidate = parentAxis[i];
  26489. focusTargets = Ext.ComponentQuery.query(':canfocus()', candidate);
  26490. if (focusTargets.length) {
  26491. focusIndex = Ext.Array.indexOf(focusTargets, Ext.ComponentManager.getActiveComponent());
  26492. return focusTargets[focusIndex + 1] || focusTargets[focusIndex - 1] || focusTargets[0];
  26493. }
  26494. if (candidate.isFocusable && candidate.isFocusable()) {
  26495. return candidate;
  26496. }
  26497. }
  26498. },
  26499. initFocusableElement: function(force) {
  26500. var me = this,
  26501. tabIndex = me.getTabIndex(),
  26502. focusEl = me.getFocusEl();
  26503. if (focusEl && !focusEl.$isFocusableEntity) {
  26504. if (tabIndex != null && (force || me.canFocus(true))) {
  26505. me.setTabIndex(tabIndex, focusEl);
  26506. }
  26507. if (!focusEl.dom.hasAttribute('data-componentid')) {
  26508. focusEl.dom.setAttribute('data-componentid', me.id);
  26509. }
  26510. }
  26511. },
  26512. addFocusCls: function(e) {
  26513. var focusCls = this.focusCls,
  26514. el;
  26515. el = this.getFocusClsEl();
  26516. if (focusCls) {
  26517. el = this.getFocusClsEl(e);
  26518. if (el) {
  26519. el.addCls(focusCls);
  26520. }
  26521. }
  26522. },
  26523. removeFocusCls: function(e) {
  26524. var focusCls = this.focusCls,
  26525. el;
  26526. if (focusCls) {
  26527. el = this.getFocusClsEl(e);
  26528. if (el) {
  26529. el.removeCls(focusCls);
  26530. }
  26531. }
  26532. },
  26533. handleFocusEvent: function(info) {
  26534. var me = this,
  26535. event;
  26536. if (!me.focusable || me.destroying || me.destroyed) {
  26537. return;
  26538. }
  26539. if (me.isFocusing(info)) {
  26540. event = new Ext.event.Event(info.event);
  26541. event.type = 'focus';
  26542. event.relatedTarget = info.fromElement;
  26543. event.target = info.toElement;
  26544. me.onFocus(event);
  26545. }
  26546. },
  26547. handleBlurEvent: function(info) {
  26548. var me = this,
  26549. event;
  26550. if (!me.focusable || me.destroying || me.destroyed) {
  26551. return;
  26552. }
  26553. if (info.toElement === document.body || me.isBlurring(info)) {
  26554. event = new Ext.event.Event(info.event);
  26555. event.type = 'blur';
  26556. event.target = info.fromElement;
  26557. event.relatedTarget = info.toElement;
  26558. me.onBlur(event);
  26559. }
  26560. },
  26561. isFocusing: function(e) {
  26562. var focusEl = this.getFocusEl();
  26563. if (focusEl) {
  26564. if (focusEl.isFocusing) {
  26565. return focusEl.isFocusing(e);
  26566. } else {
  26567. return focusEl.dom === document.activeElement && e.toElement === focusEl.dom && e.fromElement !== e.toElement;
  26568. }
  26569. }
  26570. return false;
  26571. },
  26572. isBlurring: function(e) {
  26573. var focusEl = this.getFocusEl();
  26574. if (focusEl) {
  26575. if (focusEl.isFocusing) {
  26576. return focusEl.isBlurring(e);
  26577. } else {
  26578. return focusEl.dom !== document.activeElement && e.fromElement === focusEl.dom && e.fromElement !== e.toElement;
  26579. }
  26580. }
  26581. return false;
  26582. },
  26583. blur: function() {
  26584. var me = this,
  26585. focusEl;
  26586. if (!me.focusable || !me.canFocus()) {
  26587. return;
  26588. }
  26589. focusEl = me.getFocusEl();
  26590. if (focusEl) {
  26591. me.blurring = true;
  26592. focusEl.blur();
  26593. delete me.blurring;
  26594. }
  26595. },
  26596. isTabbable: function() {
  26597. var me = this,
  26598. focusEl;
  26599. if (me.focusable) {
  26600. focusEl = me.getFocusEl();
  26601. if (focusEl && focusEl.isTabbable()) {
  26602. return focusEl.isTabbable();
  26603. }
  26604. }
  26605. return false;
  26606. },
  26607. disableTabbing: function() {
  26608. var me = this,
  26609. el = me.el,
  26610. focusEl;
  26611. if (me.destroying || me.destroyed) {
  26612. return;
  26613. }
  26614. if (el) {
  26615. el.saveTabbableState();
  26616. }
  26617. focusEl = me.getFocusEl();
  26618. if (focusEl) {
  26619. if (focusEl.$isFocusableEntity) {
  26620. focusEl.disableTabbing();
  26621. }
  26622. else if (focusEl.isElement && el && !el.contains(focusEl)) {
  26623. focusEl.saveTabbableState();
  26624. }
  26625. }
  26626. },
  26627. enableTabbing: function(reset) {
  26628. var me = this,
  26629. el = me.el,
  26630. focusEl;
  26631. if (me.destroying || me.destroyed) {
  26632. return;
  26633. }
  26634. focusEl = me.getFocusEl();
  26635. if (focusEl) {
  26636. if (focusEl.$isFocusableEntity) {
  26637. focusEl.enableTabbing();
  26638. } else if (focusEl.isElement && el && !el.contains(focusEl)) {
  26639. focusEl.restoreTabbableState();
  26640. }
  26641. }
  26642. if (el) {
  26643. el.restoreTabbableState({
  26644. reset: reset
  26645. });
  26646. }
  26647. }
  26648. }
  26649. }, function() {
  26650. var keyboardModeCls = Ext.baseCSSPrefix + 'keyboard-mode',
  26651. keyboardMode = false;
  26652. Ext.enableKeyboardMode = Ext.isModern || !Ext.os.is.Desktop;
  26653. Ext.setKeyboardMode = Ext.setKeyboardMode || function(keyboardMode) {
  26654. Ext.keyboardMode = keyboardMode;
  26655. Ext.getBody().toggleCls(keyboardModeCls, keyboardMode);
  26656. };
  26657. Ext.isTouchMode = function() {
  26658. return (Ext.now() - Ext.lastTouchTime) < 500;
  26659. };
  26660. Ext.syncKeyboardMode = function(e) {
  26661. var type;
  26662. if (!Ext.enableKeyboardMode) {
  26663. return;
  26664. }
  26665. type = e.type;
  26666. if (type === 'pointermove') {
  26667. keyboardMode = false;
  26668. } else {
  26669. keyboardMode = (type === 'keydown');
  26670. Ext.lastTouchTime = e.pointerType === 'touch' && Ext.now();
  26671. Ext.setKeyboardMode(keyboardMode);
  26672. }
  26673. };
  26674. function keyboardModeFocusHandler() {
  26675. if (keyboardMode !== Ext.getBody().hasCls(keyboardModeCls)) {
  26676. Ext.setKeyboardMode(keyboardMode);
  26677. }
  26678. }
  26679. Ext.getEnableKeyboardMode = function() {
  26680. return Ext.enableKeyboardMode;
  26681. };
  26682. Ext.setEnableKeyboardMode = function(enable) {
  26683. var listeners = {
  26684. pointerdown: Ext.syncKeyboardMode,
  26685. pointermove: Ext.syncKeyboardMode,
  26686. keydown: Ext.syncKeyboardMode,
  26687. capture: true,
  26688. delegated: false
  26689. };
  26690. Ext.enableKeyboardMode = !!enable;
  26691. if (Ext.enableKeyboardMode) {
  26692. Ext.getWin().on(listeners);
  26693. Ext.on('focus', keyboardModeFocusHandler);
  26694. } else {
  26695. Ext.getWin().un(listeners);
  26696. Ext.un('focus', keyboardModeFocusHandler);
  26697. }
  26698. };
  26699. Ext.onReady(function() {
  26700. if (!Ext.enableKeyboardMode) {
  26701. Ext.getBody().addCls(keyboardModeCls);
  26702. }
  26703. Ext.setEnableKeyboardMode(Ext.enableKeyboardMode);
  26704. });
  26705. });
  26706. Ext.define('Ext.mixin.Accessible', {
  26707. extend: Ext.Mixin,
  26708. mixinConfig: {
  26709. id: 'accessible'
  26710. },
  26711. config: {
  26712. ariaAttributes: {
  26713. $value: null,
  26714. lazy: true
  26715. }
  26716. },
  26717. ariaEl: 'el',
  26718. privates: {
  26719. getAriaLabelEl: function(reference) {
  26720. var ids = [],
  26721. refHolder, i, len, cmp;
  26722. if (reference) {
  26723. if (Ext.isFunction(reference)) {
  26724. return reference.call(this);
  26725. } else {
  26726. if (!Ext.isArray(reference)) {
  26727. reference = [
  26728. reference
  26729. ];
  26730. }
  26731. refHolder = this.lookupReferenceHolder();
  26732. if (refHolder) {
  26733. for (i = 0 , len = reference.length; i < len; i++) {
  26734. cmp = refHolder.lookupReference(reference[i]);
  26735. if (cmp) {
  26736. ids.push(cmp.ariaEl.id);
  26737. }
  26738. }
  26739. }
  26740. }
  26741. }
  26742. return ids.length ? ids.join(' ') : null;
  26743. }
  26744. }
  26745. });
  26746. Ext.define('Ext.Widget', {
  26747. extend: Ext.Evented,
  26748. xtype: 'widget',
  26749. alternateClassName: 'Ext.Gadget',
  26750. mixins: [
  26751. Ext.mixin.Inheritable,
  26752. Ext.mixin.Bindable,
  26753. Ext.mixin.ComponentDelegation,
  26754. Ext.mixin.Pluggable,
  26755. Ext.mixin.Keyboard,
  26756. Ext.mixin.Factoryable,
  26757. Ext.mixin.Focusable,
  26758. Ext.mixin.Accessible
  26759. ],
  26760. isWidget: true,
  26761. factoryConfig: {
  26762. creator: null,
  26763. defaultProperty: 'xtype',
  26764. defaultType: 'component',
  26765. typeProperty: 'xtype'
  26766. },
  26767. element: {
  26768. reference: 'element'
  26769. },
  26770. observableType: 'component',
  26771. cachedConfig: {
  26772. cls: null,
  26773. margin: null,
  26774. style: null,
  26775. border: null,
  26776. touchAction: null,
  26777. eventHandlers: {
  26778. focus: 'handleFocusEvent',
  26779. blur: 'handleBlurEvent'
  26780. }
  26781. },
  26782. name: null,
  26783. config: {
  26784. renderTo: null,
  26785. ui: null,
  26786. userCls: null,
  26787. ripple: null,
  26788. hideMode: null,
  26789. instanceCls: null
  26790. },
  26791. eventedConfig: {
  26792. width: null,
  26793. height: null,
  26794. hidden: null,
  26795. disabled: null
  26796. },
  26797. template: [],
  26798. baseCls: null,
  26799. classCls: null,
  26800. classClsRoot: true,
  26801. classClsList: [],
  26802. clearPropertiesOnDestroy: 'async',
  26803. focusEl: 'element',
  26804. ariaEl: 'element',
  26805. spaceRe: /\s+/,
  26806. noBorderCls: Ext.baseCSSPrefix + 'noborder-trbl',
  26807. borderedCls: Ext.baseCSSPrefix + 'bordered',
  26808. disabledCls: Ext.baseCSSPrefix + 'disabled',
  26809. heightedCls: Ext.baseCSSPrefix + 'heighted',
  26810. widthedCls: Ext.baseCSSPrefix + 'widthed',
  26811. constructor: function(config) {
  26812. var me = this,
  26813. baseCls = me.baseCls,
  26814. renderTo = config && config.renderTo,
  26815. controller;
  26816. me.$iid = ++Ext.$nextIid;
  26817. if (baseCls == null || baseCls === true) {
  26818. me.baseCls = me.classCls || Ext.baseCSSPrefix + me.xtype;
  26819. }
  26820. if (config && ('baseCls' in config)) {
  26821. Ext.raise('baseCls cannot be used as an instance config. It must be specified ' + 'at class definition time.');
  26822. }
  26823. if ((config && config.controller) || me.config.controller) {
  26824. me.referenceHolder = true;
  26825. }
  26826. me.initId(config);
  26827. me.initElement();
  26828. if (renderTo) {
  26829. config = Ext.apply({}, config);
  26830. delete config.renderTo;
  26831. }
  26832. me.mixins.observable.constructor.call(me, config);
  26833. if (me.focusable) {
  26834. me.initFocusableEvents(true);
  26835. }
  26836. me.syncUiCls();
  26837. Ext.ComponentManager.register(me);
  26838. controller = me.getController();
  26839. if (controller) {
  26840. controller.init(me);
  26841. }
  26842. if (renderTo) {
  26843. me.setRenderTo(renderTo);
  26844. }
  26845. },
  26846. afterCachedConfig: function() {
  26847. var me = this,
  26848. prototype = me.self.prototype,
  26849. referenceList = me.referenceList,
  26850. renderElement = me.renderElement,
  26851. renderTemplate, element, i, ln, reference, elements;
  26852. prototype.renderTemplate = renderTemplate = document.createDocumentFragment();
  26853. renderTemplate.appendChild(renderElement.clone(true, true));
  26854. elements = renderTemplate.querySelectorAll('[id]');
  26855. for (i = 0 , ln = elements.length; i < ln; i++) {
  26856. element = elements[i];
  26857. element.removeAttribute('id');
  26858. }
  26859. for (i = 0 , ln = referenceList.length; i < ln; i++) {
  26860. reference = referenceList[i];
  26861. me[reference].dom.removeAttribute('reference');
  26862. }
  26863. },
  26864. applyHidden: function(hidden) {
  26865. return !!hidden;
  26866. },
  26867. applyDisabled: function(disabled) {
  26868. return !!disabled;
  26869. },
  26870. updateDisabled: function(disabled) {
  26871. var me = this,
  26872. container = me.ownerFocusableContainer;
  26873. if (container) {
  26874. if (disabled) {
  26875. if (!container.beforeFocusableChildDisable.$nullFn) {
  26876. container.beforeFocusableChildDisable(me);
  26877. }
  26878. } else {
  26879. if (!container.beforeFocusableChildEnable.$nullFn) {
  26880. container.beforeFocusableChildEnable(me);
  26881. }
  26882. }
  26883. }
  26884. me.element.toggleCls(me.disabledCls, disabled);
  26885. if (me.focusable) {
  26886. if (disabled) {
  26887. me.disableFocusable();
  26888. } else {
  26889. me.enableFocusable();
  26890. }
  26891. }
  26892. if (container) {
  26893. if (disabled) {
  26894. if (!container.onFocusableChildDisable.$nullFn) {
  26895. container.onFocusableChildDisable(me);
  26896. }
  26897. } else {
  26898. if (!container.onFocusableChildEnable.$nullFn) {
  26899. container.onFocusableChildEnable(me);
  26900. }
  26901. }
  26902. }
  26903. },
  26904. disable: function() {
  26905. this.setDisabled(true);
  26906. },
  26907. enable: function() {
  26908. this.setDisabled(false);
  26909. },
  26910. isDisabled: function() {
  26911. return this.getDisabled();
  26912. },
  26913. isEnabled: function() {
  26914. return !this.getDisabled();
  26915. },
  26916. applyTouchAction: function(touchAction, oldTouchAction) {
  26917. if (oldTouchAction != null) {
  26918. touchAction = Ext.merge({}, oldTouchAction, touchAction);
  26919. }
  26920. return touchAction;
  26921. },
  26922. applyWidth: function(width) {
  26923. return this.filterLengthValue(width);
  26924. },
  26925. applyHeight: function(height) {
  26926. return this.filterLengthValue(height);
  26927. },
  26928. updateBorder: function(border) {
  26929. var me = this;
  26930. border = border || border === null;
  26931. me.toggleCls(me.noBorderCls, !border);
  26932. me.toggleCls(me.borderedCls, !!border);
  26933. },
  26934. clearListeners: function() {
  26935. var me = this;
  26936. me.mixins.observable.clearListeners.call(me);
  26937. me.mixins.componentDelegation.clearDelegatedListeners.call(me);
  26938. },
  26939. destroy: function() {
  26940. var me = this;
  26941. me.isDestroying = me.destroying = true;
  26942. me.destroy = Ext.emptyFn;
  26943. me.doDestroy();
  26944. me.clearListeners();
  26945. me.mixins.componentDelegation.destroyComponentDelegation.call(me);
  26946. me.callParent();
  26947. },
  26948. doDestroy: function() {
  26949. var me = this,
  26950. referenceList = me.referenceList,
  26951. container = me.ownerFocusableContainer,
  26952. i, ln, reference;
  26953. me.ownerCmp = null;
  26954. if (container && !container.onFocusableChildDestroy.$nullFn) {
  26955. container.onFocusableChildDestroy(me);
  26956. }
  26957. for (i = 0 , ln = referenceList.length; i < ln; i++) {
  26958. reference = referenceList[i];
  26959. if (me.hasOwnProperty(reference)) {
  26960. me[reference].destroy();
  26961. me[reference] = null;
  26962. }
  26963. }
  26964. me.destroyBindable();
  26965. Ext.ComponentManager.unregister(me);
  26966. },
  26967. doFireEvent: function(eventName, args, bubbles) {
  26968. var me = this,
  26969. ev, ret;
  26970. ret = me.mixins.observable.doFireEvent.call(me, eventName, args, bubbles);
  26971. if (ret !== false && !me.destroyed) {
  26972. ev = me.events[eventName];
  26973. if (!ev || !ev.suspended) {
  26974. ret = me.mixins.componentDelegation.doFireDelegatedEvent.call(me, eventName, args);
  26975. }
  26976. }
  26977. return ret;
  26978. },
  26979. getBubbleTarget: function() {
  26980. return this.getRefOwner();
  26981. },
  26982. getElementConfig: function() {
  26983. var me = this,
  26984. el = me.element;
  26985. if (!('children' in el)) {
  26986. el = Ext.apply({
  26987. children: me.getTemplate()
  26988. }, el);
  26989. }
  26990. return el;
  26991. },
  26992. getSize: function() {
  26993. return this.el.getSize();
  26994. },
  26995. getTemplate: function() {
  26996. return Ext.clone(this.template);
  26997. },
  26998. getClassCls: function() {
  26999. var proto = this.self.prototype,
  27000. prototype = proto,
  27001. classes, classCls, i, ln;
  27002. while (prototype) {
  27003. classCls = prototype.hasOwnProperty('classCls') ? prototype.classCls : null;
  27004. if (classCls) {
  27005. if (classCls instanceof Array) {
  27006. for (i = 0 , ln = classCls.length; i < ln; i++) {
  27007. (classes || (classes = [])).push(classCls[i]);
  27008. }
  27009. } else {
  27010. (classes || (classes = [])).push(classCls);
  27011. }
  27012. }
  27013. if (prototype.classClsRoot && prototype.hasOwnProperty('classClsRoot')) {
  27014. break;
  27015. }
  27016. prototype = prototype.superclass;
  27017. }
  27018. if (classes) {
  27019. proto.classClsList = classes;
  27020. }
  27021. return classes;
  27022. },
  27023. hide: function() {
  27024. this.setHidden(true);
  27025. },
  27026. initElement: function() {
  27027. var me = this,
  27028. prototype = me.self.prototype,
  27029. id = me.getId(),
  27030. referenceList = me.referenceList = me.referenceList = [],
  27031. isFirstInstance = !prototype.hasOwnProperty('renderTemplate'),
  27032. uiReferences = prototype.hasOwnProperty('uiReferences') ? prototype.uiReferences : (prototype.uiReferences = {
  27033. element: ''
  27034. }),
  27035. renderTemplate, renderElement, renderConfig, element, referenceNodes, i, ln, referenceNode, reference, classCls, uiCls, baseCls,
  27036. referenceElement;
  27037. if (isFirstInstance) {
  27038. renderTemplate = document.createDocumentFragment();
  27039. renderConfig = me.processElementConfig.call(prototype);
  27040. renderElement = Ext.Element.create(renderConfig, true);
  27041. renderTemplate.appendChild(renderElement);
  27042. referenceNodes = renderTemplate.querySelectorAll('[uiCls]');
  27043. for (i = 0 , ln = referenceNodes.length; i < ln; i++) {
  27044. referenceNode = referenceNodes[i];
  27045. reference = referenceNode.getAttribute('reference');
  27046. uiCls = referenceNode.getAttribute('uiCls');
  27047. if (!reference) {
  27048. Ext.raise('Cannot render element with uiCls="' + uiCls + '". uiCls is only allowed on elements that have a reference name.');
  27049. }
  27050. uiReferences[reference] = uiCls;
  27051. referenceNode.removeAttribute('uiCls');
  27052. }
  27053. } else {
  27054. renderTemplate = me.renderTemplate.cloneNode(true);
  27055. renderElement = renderTemplate.firstChild;
  27056. }
  27057. referenceNodes = renderTemplate.querySelectorAll('[reference]');
  27058. for (i = 0 , ln = referenceNodes.length; i < ln; i++) {
  27059. referenceNode = referenceNodes[i];
  27060. reference = referenceNode.getAttribute('reference');
  27061. if (!isFirstInstance) {
  27062. referenceNode.removeAttribute('reference');
  27063. }
  27064. if (reference === 'element') {
  27065. if (element) {
  27066. Ext.raise("Duplicate 'element' reference detected in '" + me.$className + "' template.");
  27067. }
  27068. referenceNode.id = id;
  27069. element = me.el = me.addElementReference(reference, referenceNode);
  27070. element.dom.setAttribute('data-componentid', id);
  27071. if (isFirstInstance) {
  27072. classCls = me.getClassCls();
  27073. if (classCls) {
  27074. element.addCls(classCls);
  27075. }
  27076. baseCls = me.baseCls;
  27077. if (baseCls && (baseCls !== me.classCls)) {
  27078. element.addCls(baseCls);
  27079. }
  27080. }
  27081. } else {
  27082. uiCls = uiReferences[reference];
  27083. if (uiCls && isFirstInstance) {
  27084. referenceElement = me.addElementReference(reference, referenceNode);
  27085. me.initUiReference(reference, uiCls, false);
  27086. } else {
  27087. me.addElementReferenceOnDemand(reference, referenceNode);
  27088. }
  27089. }
  27090. if (reference === me.focusEl) {
  27091. me.addElementReference('focusEl', referenceNode);
  27092. }
  27093. if (reference === me.ariaEl) {
  27094. me.addElementReferenceOnDemand('ariaEl', referenceNode);
  27095. }
  27096. referenceList.push(reference);
  27097. }
  27098. if (!element) {
  27099. Ext.raise("No 'element' reference found in '" + me.$className + "' template.");
  27100. }
  27101. if (renderElement === element.dom) {
  27102. me.renderElement = element;
  27103. } else {
  27104. me.addElementReferenceOnDemand('renderElement', renderElement);
  27105. }
  27106. renderElement.setAttribute(me.dataXid, me.$iid);
  27107. },
  27108. dataXid: 'data-' + Ext.baseCSSPrefix.substr(0, Ext.baseCSSPrefix.length - 1) + 'id',
  27109. is: function(selector) {
  27110. return Ext.ComponentQuery.is(this, selector);
  27111. },
  27112. isHidden: function(deep) {
  27113. var hidden = !!this.getHidden(),
  27114. owner;
  27115. if (!hidden && deep) {
  27116. owner = this.getRefOwner();
  27117. while (owner && owner !== deep && !hidden) {
  27118. hidden = !!owner.getHidden();
  27119. owner = owner.getRefOwner();
  27120. }
  27121. }
  27122. return hidden;
  27123. },
  27124. isVisible: function(deep) {
  27125. return this.rendered && !this.destroyed && !this.isHidden(deep);
  27126. },
  27127. isXType: function(xtype, shallow) {
  27128. return shallow ? (Ext.Array.indexOf(this.xtypes, xtype) !== -1) : !!this.xtypesMap[xtype];
  27129. },
  27130. lookupTpl: function(name) {
  27131. return Ext.XTemplate.getTpl(this, name);
  27132. },
  27133. owns: function(element) {
  27134. var result = false,
  27135. cmp;
  27136. if (element.isEvent) {
  27137. element = element.target;
  27138. } else if (element.isElement) {
  27139. element = element.dom;
  27140. }
  27141. cmp = Ext.Component.from(element);
  27142. if (cmp) {
  27143. result = (cmp === this) || (!!cmp.up(this));
  27144. }
  27145. return result;
  27146. },
  27147. render: function(container, insertBeforeElement) {
  27148. if (container && container.isWidget) {
  27149. container = container.el;
  27150. }
  27151. var dom = this.renderElement.dom,
  27152. containerDom = Ext.getDom(container),
  27153. insertBeforeChildDom;
  27154. if (Ext.isNumber(insertBeforeChildDom)) {
  27155. insertBeforeElement = containerDom.childNodes[insertBeforeElement];
  27156. }
  27157. insertBeforeChildDom = Ext.getDom(insertBeforeElement);
  27158. if (containerDom) {
  27159. if (insertBeforeChildDom) {
  27160. containerDom.insertBefore(dom, insertBeforeChildDom);
  27161. } else {
  27162. containerDom.appendChild(dom);
  27163. }
  27164. this.setRendered(Ext.getBody().contains(dom), true);
  27165. }
  27166. },
  27167. toggleCls: function(className, state) {
  27168. this.element.toggleCls(className, state);
  27169. return this;
  27170. },
  27171. resolveListenerScope: function(defaultScope, skipThis) {
  27172. return this.mixins.inheritable.resolveListenerScope.call(this, defaultScope, skipThis);
  27173. },
  27174. setSize: function(width, height) {
  27175. if (width && typeof width === 'object') {
  27176. return this.setSize(width.width, width.height);
  27177. }
  27178. if (width !== undefined) {
  27179. this.setWidth(width);
  27180. }
  27181. if (height !== undefined) {
  27182. this.setHeight(height);
  27183. }
  27184. },
  27185. show: function() {
  27186. this.setHidden(false);
  27187. },
  27188. addCls: function(cls, prefix, suffix) {
  27189. if (!this.destroyed) {
  27190. this.el.replaceCls(null, cls, prefix, suffix);
  27191. }
  27192. },
  27193. applyCls: function(cls) {
  27194. return cls && Ext.dom.Element.splitCls(cls);
  27195. },
  27196. applyUi: function(ui) {
  27197. return this.parseUi(ui, true);
  27198. },
  27199. removeCls: function(cls, prefix, suffix) {
  27200. if (!this.destroyed) {
  27201. this.el.replaceCls(cls, null, prefix, suffix);
  27202. }
  27203. },
  27204. replaceCls: function(oldCls, newCls, prefix, suffix) {
  27205. if (!this.destroyed) {
  27206. this.el.replaceCls(oldCls, newCls, prefix, suffix);
  27207. }
  27208. },
  27209. hasCls: function(className) {
  27210. return this.el.hasCls(className);
  27211. },
  27212. updateCls: function(newCls, oldCls) {
  27213. this.element.replaceCls(oldCls, newCls);
  27214. },
  27215. updateHidden: function(hidden) {
  27216. var me = this,
  27217. element = me.renderElement,
  27218. container = me.ownerFocusableContainer;
  27219. if (container) {
  27220. if (hidden) {
  27221. if (!container.beforeFocusableChildHide.$nullFn) {
  27222. container.beforeFocusableChildHide(me);
  27223. }
  27224. } else {
  27225. if (!container.beforeFocusableChildShow.$nullFn) {
  27226. container.beforeFocusableChildShow(me);
  27227. }
  27228. }
  27229. }
  27230. else if (hidden) {
  27231. me.revertFocus();
  27232. }
  27233. if (element && !element.destroyed) {
  27234. if (hidden) {
  27235. element.hide();
  27236. } else {
  27237. element.show();
  27238. }
  27239. }
  27240. if (me.focusableContainer && me.activateFocusableContainer) {
  27241. me.activateFocusableContainer(!hidden);
  27242. }
  27243. if (container) {
  27244. if (hidden) {
  27245. if (!container.onFocusableChildHide.$nullFn) {
  27246. container.onFocusableChildHide(me);
  27247. }
  27248. } else {
  27249. if (!container.onFocusableChildShow.$nullFn) {
  27250. container.onFocusableChildShow(me);
  27251. }
  27252. }
  27253. }
  27254. },
  27255. updateMargin: function(margin) {
  27256. this.element.setMargin(margin);
  27257. },
  27258. updateRipple: function(ripple) {
  27259. var me = this,
  27260. el = me.el;
  27261. if (el) {
  27262. el.un('touchstart', 'onRippleStart', me);
  27263. el.un('touchend', 'onRippleStart', me);
  27264. el.destroyAllRipples();
  27265. if (ripple.release) {
  27266. el.on('touchend', 'onRippleStart', me);
  27267. } else {
  27268. el.on('touchstart', 'onRippleStart', me);
  27269. }
  27270. }
  27271. },
  27272. shouldRipple: function(e) {
  27273. var me = this,
  27274. disabled = me.getDisabled && me.getDisabled(),
  27275. el = me.el,
  27276. ripple = !disabled && me.getRipple(),
  27277. target;
  27278. if (ripple && e) {
  27279. target = e.getTarget(me.noRippleSelector);
  27280. if (target) {
  27281. if ((el.dom === target) || el.contains(target)) {
  27282. ripple = null;
  27283. }
  27284. }
  27285. }
  27286. return ripple;
  27287. },
  27288. onRippleStart: function(e) {
  27289. var ripple = this.shouldRipple(e);
  27290. if (e.button === 0 && ripple) {
  27291. this.el.ripple(e, ripple);
  27292. }
  27293. },
  27294. applyStyle: function(style, oldStyle) {
  27295. if (oldStyle && style === oldStyle && Ext.isObject(oldStyle)) {
  27296. style = Ext.apply({}, style);
  27297. }
  27298. this.element.applyStyles(style);
  27299. return null;
  27300. },
  27301. getStyle: function() {
  27302. Ext.Error.raise("'style' is a write-only config. To query element styles use " + "the Ext.dom.Element API.");
  27303. },
  27304. updateRenderTo: function(newContainer) {
  27305. this.render(newContainer);
  27306. },
  27307. updateTouchAction: function(touchAction) {
  27308. var name, childEl, value, hasRootActions;
  27309. for (name in touchAction) {
  27310. childEl = this[name];
  27311. value = touchAction[name];
  27312. if (childEl && childEl.isElement) {
  27313. childEl.setTouchAction(value);
  27314. } else {
  27315. hasRootActions = true;
  27316. }
  27317. }
  27318. if (hasRootActions) {
  27319. this.el.setTouchAction(touchAction);
  27320. }
  27321. },
  27322. updateUi: function() {
  27323. if (!this.isConfiguring) {
  27324. this.syncUiCls();
  27325. }
  27326. },
  27327. updateWidth: function(width) {
  27328. var el = this.el;
  27329. el.setWidth(width);
  27330. el.toggleCls(this.widthedCls, width != null && width !== 'auto');
  27331. },
  27332. updateHeight: function(height) {
  27333. var el = this.el;
  27334. el.setHeight(height);
  27335. el.toggleCls(this.heightedCls, height != null && height !== 'auto');
  27336. },
  27337. isWidthed: function() {
  27338. var width = this.getWidth();
  27339. return width != null && width !== 'auto';
  27340. },
  27341. isHeighted: function() {
  27342. var height = this.getHeight();
  27343. return height != null && height !== 'auto';
  27344. },
  27345. up: function(selector, limit) {
  27346. var result = this.getRefOwner(),
  27347. limitSelector = typeof limit === 'string',
  27348. limitCount = typeof limit === 'number',
  27349. limitComponent = limit && limit.isComponent,
  27350. steps = 0;
  27351. if (selector) {
  27352. for (; result; result = result.getRefOwner()) {
  27353. if (result.destroyed) {
  27354. return null;
  27355. }
  27356. steps++;
  27357. if (selector.isComponent || selector.isWidget) {
  27358. if (result === selector) {
  27359. return result;
  27360. }
  27361. } else {
  27362. if (Ext.ComponentQuery.is(result, selector)) {
  27363. return result;
  27364. }
  27365. }
  27366. if (limitSelector && result.is(limit)) {
  27367. return;
  27368. }
  27369. if (limitCount && steps === limit) {
  27370. return;
  27371. }
  27372. if (limitComponent && result === limit) {
  27373. return;
  27374. }
  27375. }
  27376. }
  27377. return result;
  27378. },
  27379. updateLayout: Ext.emptyFn,
  27380. updateInstanceCls: function(instanceCls, oldInstanceCls) {
  27381. var me = this,
  27382. el = me.el,
  27383. classClsList = me.classClsList,
  27384. Array = Ext.Array,
  27385. uiReferences = me.uiReferences,
  27386. referenceName, referenceElement, i, ln, cls, uiCls;
  27387. if (oldInstanceCls) {
  27388. el.removeCls(oldInstanceCls);
  27389. oldInstanceCls = Array.from(oldInstanceCls);
  27390. for (i = 0 , ln = oldInstanceCls.length; i < ln; i++) {
  27391. cls = oldInstanceCls[i];
  27392. Array.remove(classClsList, cls);
  27393. for (referenceName in uiReferences) {
  27394. referenceElement = me[referenceName];
  27395. uiCls = uiReferences[referenceName];
  27396. referenceElement.removeCls(cls + '-' + uiCls);
  27397. }
  27398. }
  27399. }
  27400. if (instanceCls) {
  27401. el.addCls(instanceCls);
  27402. instanceCls = Array.from(instanceCls);
  27403. me.classClsList = classClsList.concat(instanceCls);
  27404. for (i = 0 , ln = instanceCls.length; i < ln; i++) {
  27405. cls = instanceCls[i];
  27406. for (referenceName in uiReferences) {
  27407. referenceElement = me[referenceName];
  27408. uiCls = uiReferences[referenceName];
  27409. referenceElement.addCls(cls + '-' + uiCls);
  27410. }
  27411. }
  27412. }
  27413. if (!me.isConfiguring) {
  27414. me.syncUiCls();
  27415. }
  27416. },
  27417. getBaseCls: function() {
  27418. return this.baseCls;
  27419. },
  27420. setBaseCls: function() {
  27421. Ext.raise('baseCls cannot be reconfigured. It must be specified at class definition time.');
  27422. },
  27423. onClassExtended: function(Class, members) {
  27424. if (members.config && members.config.baseCls) {
  27425. Ext.raise('baseCls must be declared directly on the class body. Please move it ' + 'outside of the config block.');
  27426. }
  27427. },
  27428. privates: {
  27429. _hideModes: {
  27430. clip: 'CLIP',
  27431. display: 'DISPLAY',
  27432. offsets: 'OFFSETS',
  27433. opacity: 'OPACITY',
  27434. visibility: 'VISIBILITY'
  27435. },
  27436. noRippleSelector: '.' + Ext.baseCSSPrefix + 'no-ripple',
  27437. addElementReferenceOnDemand: function(name, domNode) {
  27438. if (this._elementListeners[name]) {
  27439. this.addElementReference(name, domNode);
  27440. } else {
  27441. Ext.Object.defineProperty(this, name, {
  27442. get: function() {
  27443. if (this.destroyed) {
  27444. return null;
  27445. }
  27446. delete this[name];
  27447. return this.addElementReference(name, domNode);
  27448. },
  27449. configurable: true
  27450. });
  27451. }
  27452. },
  27453. addElementReference: function(name, domNode) {
  27454. var me = this,
  27455. referenceEl = me[name] = Ext.get(domNode),
  27456. listeners = me._elementListeners[name],
  27457. eventName, listener;
  27458. referenceEl.skipGarbageCollection = true;
  27459. referenceEl.component = me;
  27460. if (listeners) {
  27461. listeners = Ext.clone(listeners);
  27462. for (eventName in listeners) {
  27463. listener = listeners[eventName];
  27464. if (typeof listener === 'object') {
  27465. listener.scope = me;
  27466. }
  27467. }
  27468. listeners.scope = me;
  27469. referenceEl.on(listeners);
  27470. }
  27471. return referenceEl;
  27472. },
  27473. detachFromBody: function() {
  27474. Ext.getDetachedBody().appendChild(this.element, true);
  27475. this.isDetached = true;
  27476. },
  27477. reattachToBody: function() {
  27478. var detachedBody;
  27479. if (this.isDetached) {
  27480. detachedBody = Ext.getDetachedBody();
  27481. if (detachedBody.contains(this.element)) {
  27482. Ext.getBody().appendChild(this.element, true);
  27483. }
  27484. }
  27485. this.isDetached = false;
  27486. },
  27487. doAddListener: function(name, fn, scope, options, order, caller, manager) {
  27488. var me = this,
  27489. elementName = options && options.element,
  27490. delegate = options && options.delegate,
  27491. listeners, eventOptions, option;
  27492. if (elementName) {
  27493. if (Ext.Array.indexOf(me.referenceList, elementName) === -1) {
  27494. Ext.Logger.error("Adding event listener with an invalid element reference of '" + elementName + "' for this component. Available values are: '" + me.referenceList.join("', '") + "'", me);
  27495. }
  27496. listeners = {};
  27497. listeners[name] = fn;
  27498. if (scope) {
  27499. listeners.scope = scope;
  27500. }
  27501. eventOptions = Ext.Element.prototype.$eventOptions;
  27502. for (option in options) {
  27503. if (eventOptions[option]) {
  27504. listeners[option] = options[option];
  27505. }
  27506. }
  27507. me.mon(me[elementName], listeners);
  27508. return;
  27509. } else if (delegate) {
  27510. me.mixins.componentDelegation.addDelegatedListener.call(me, name, fn, scope, options, order, caller, manager);
  27511. return;
  27512. }
  27513. me.callParent([
  27514. name,
  27515. fn,
  27516. scope,
  27517. options,
  27518. order,
  27519. caller,
  27520. manager
  27521. ]);
  27522. },
  27523. doRemoveListener: function(eventName, fn, scope) {
  27524. var me = this;
  27525. me.mixins.observable.doRemoveListener.call(me, eventName, fn, scope);
  27526. me.mixins.componentDelegation.removeDelegatedListener.call(me, eventName, fn, scope);
  27527. },
  27528. filterLengthValue: function(value) {
  27529. if (!value && value !== 0) {
  27530. return null;
  27531. }
  27532. return value;
  27533. },
  27534. initElementListeners: function(elementConfig) {
  27535. var prototype = this,
  27536. superPrototype = prototype.self.superclass,
  27537. superElementListeners = superPrototype._elementListeners,
  27538. reference = elementConfig.reference,
  27539. children = elementConfig.children,
  27540. elementListeners, listeners, superListeners, ln, i;
  27541. if (prototype.hasOwnProperty('_elementListeners')) {
  27542. elementListeners = prototype._elementListeners;
  27543. } else {
  27544. elementListeners = prototype._elementListeners = (superElementListeners ? Ext.Object.chain(superElementListeners) : {});
  27545. }
  27546. if (reference) {
  27547. listeners = elementConfig.listeners;
  27548. if (listeners) {
  27549. if (superElementListeners) {
  27550. superListeners = superElementListeners[reference];
  27551. if (superListeners) {
  27552. listeners = Ext.Object.chain(superListeners);
  27553. Ext.apply(listeners, elementConfig.listeners);
  27554. }
  27555. }
  27556. elementListeners[reference] = listeners;
  27557. elementConfig.listeners = null;
  27558. }
  27559. }
  27560. if (children) {
  27561. for (i = 0 , ln = children.length; i < ln; i++) {
  27562. prototype.initElementListeners(children[i]);
  27563. }
  27564. }
  27565. },
  27566. initId: function(config) {
  27567. var me = this,
  27568. defaultConfig = me.config,
  27569. id = (config && config.id) || (defaultConfig && defaultConfig.id);
  27570. if (id) {
  27571. me.setId(id);
  27572. me.id = id;
  27573. } else {
  27574. me.getId();
  27575. }
  27576. },
  27577. measure: function(dimension) {
  27578. return this.element.measure(dimension);
  27579. },
  27580. processElementConfig: function() {
  27581. var prototype = this,
  27582. superPrototype = prototype.self.superclass,
  27583. elementConfig;
  27584. if (prototype.hasOwnProperty('_elementConfig')) {
  27585. elementConfig = prototype._elementConfig;
  27586. } else {
  27587. elementConfig = prototype._elementConfig = prototype.getElementConfig();
  27588. if (superPrototype.isWidget) {
  27589. prototype.processElementConfig.call(superPrototype);
  27590. }
  27591. prototype.initElementListeners(elementConfig);
  27592. }
  27593. return elementConfig;
  27594. },
  27595. parseUi: function(ui, asString) {
  27596. ui = Ext.String.splitWords(ui);
  27597. if (asString) {
  27598. ui = ui.join(' ');
  27599. }
  27600. return ui;
  27601. },
  27602. addUi: function(ui) {
  27603. this.setUi(this.doAddUi(ui, this.getUi()));
  27604. },
  27605. doAddUi: function(ui, oldUi) {
  27606. var me = this,
  27607. newUi = null,
  27608. i, u, len;
  27609. if (ui) {
  27610. ui = me.parseUi(ui);
  27611. len = ui.length;
  27612. oldUi = me.parseUi(oldUi);
  27613. for (i = 0; i < len; i++) {
  27614. u = ui[i];
  27615. if (Ext.Array.indexOf(oldUi, u) === -1) {
  27616. oldUi.push(u);
  27617. }
  27618. }
  27619. newUi = oldUi.join(' ');
  27620. }
  27621. return newUi;
  27622. },
  27623. removeUi: function(ui) {
  27624. this.setUi(this.doRemoveUi(ui, this.getUi()));
  27625. },
  27626. doRemoveUi: function(ui, oldUi) {
  27627. var me = this,
  27628. newUi = null,
  27629. i, u, index, len;
  27630. if (ui) {
  27631. ui = me.parseUi(ui);
  27632. len = ui.length;
  27633. oldUi = me.parseUi(oldUi);
  27634. for (i = 0; i < len; i++) {
  27635. u = ui[i];
  27636. index = Ext.Array.indexOf(oldUi, u);
  27637. if (index !== -1) {
  27638. oldUi.splice(index, 1);
  27639. }
  27640. }
  27641. newUi = oldUi.join(' ');
  27642. }
  27643. return newUi;
  27644. },
  27645. initUiReference: function(referenceName, uiCls, isInstance) {
  27646. var me = this,
  27647. referenceElement = me[referenceName],
  27648. baseCls = me.baseCls,
  27649. classClsList = me.classClsList,
  27650. cls = [],
  27651. i, n;
  27652. isInstance = (isInstance !== false);
  27653. if (isInstance) {
  27654. if (!me.hasOwnProperty('uiReferences')) {
  27655. me.uiReferences = Ext.clone(me.uiReferences);
  27656. }
  27657. me.uiReferences[referenceName] = uiCls;
  27658. }
  27659. uiCls = '-' + uiCls;
  27660. if (baseCls && (baseCls !== me.classCls)) {
  27661. cls.push(baseCls + uiCls);
  27662. }
  27663. if (classClsList) {
  27664. for (i = 0 , n = classClsList.length; i < n; i++) {
  27665. cls.push(classClsList[i] + uiCls);
  27666. }
  27667. }
  27668. referenceElement.addCls(cls);
  27669. if (isInstance && !me.isConfiguring) {
  27670. me.syncUiCls();
  27671. }
  27672. },
  27673. syncUiCls: function(refs) {
  27674. var me = this,
  27675. ui = me.getUi(),
  27676. currentUiCls = me.currentUiCls || (me.currentUiCls = {}),
  27677. baseCls = me.baseCls,
  27678. uiReferences = refs || me.uiReferences,
  27679. classClsList = me.classClsList,
  27680. classClsListLen = classClsList ? classClsList.length : 0,
  27681. uiCls, uiLen, refName, refEl, cls, suffix, uiSuffix, i, j;
  27682. if (ui) {
  27683. ui = me.parseUi(ui);
  27684. uiLen = ui.length;
  27685. }
  27686. for (refName in uiReferences) {
  27687. refEl = me[refName];
  27688. uiCls = [];
  27689. if (refEl) {
  27690. cls = currentUiCls[refName];
  27691. if (cls) {
  27692. refEl.removeCls(cls);
  27693. }
  27694. if (ui) {
  27695. suffix = uiReferences[refName];
  27696. suffix = suffix ? ('-' + suffix) : '';
  27697. for (i = 0; i < uiLen; i++) {
  27698. uiSuffix = '-' + ui[i] + suffix;
  27699. if (baseCls && (baseCls !== me.classCls)) {
  27700. uiCls.push(baseCls + uiSuffix);
  27701. }
  27702. if (classClsList) {
  27703. for (j = 0; j < classClsListLen; j++) {
  27704. uiCls.push(classClsList[j] + uiSuffix);
  27705. }
  27706. }
  27707. }
  27708. refEl.addCls(uiCls);
  27709. currentUiCls[refName] = uiCls;
  27710. }
  27711. }
  27712. }
  27713. },
  27714. applyHideMode: function(mode) {
  27715. return mode || 'display';
  27716. },
  27717. updateHideMode: function(mode) {
  27718. var me = this,
  27719. el = me.el,
  27720. shouldToggle = me.getHidden();
  27721. if (!me._hideModes[mode]) {
  27722. Ext.raise('Invalid hideMode: "' + mode + '" (must be one of: "' + Object.keys(me._hideModes).join('", "') + '")');
  27723. }
  27724. if (shouldToggle) {
  27725. el.show();
  27726. }
  27727. me.renderElement.setVisibilityMode(Ext.Element[me._hideModes[mode]]);
  27728. if (shouldToggle) {
  27729. el.hide();
  27730. }
  27731. },
  27732. updateUserCls: function(newCls, oldCls) {
  27733. this.element.replaceCls(oldCls, newCls);
  27734. }
  27735. }
  27736. }, function(Widget) {
  27737. var prototype = Widget.prototype;
  27738. (prototype.$elementEventOptions = Ext.Object.chain(Ext.Element.prototype.$eventOptions)).element = 1;
  27739. (prototype.$eventOptions = Ext.Object.chain(prototype.$eventOptions)).delegate = 1;
  27740. Ext.updateWidget = Ext.Factory.widget.update;
  27741. });
  27742. Ext.define('Ext.mixin.Traversable', {
  27743. extend: Ext.Mixin,
  27744. mixinConfig: {
  27745. id: 'traversable'
  27746. },
  27747. setParent: function(parent) {
  27748. this.parent = parent;
  27749. return this;
  27750. },
  27751. hasParent: function() {
  27752. return Boolean(this.getParent());
  27753. },
  27754. is: function() {
  27755. return true;
  27756. },
  27757. getParent: function() {
  27758. return this.parent || this.$initParent;
  27759. },
  27760. getAncestors: function() {
  27761. var ancestors = [],
  27762. parent = this.getParent();
  27763. while (parent) {
  27764. ancestors.push(parent);
  27765. parent = parent.getParent();
  27766. }
  27767. return ancestors;
  27768. },
  27769. getAncestorIds: function() {
  27770. var ancestorIds = [],
  27771. parent = this.getParent();
  27772. while (parent) {
  27773. ancestorIds.push(parent.getId());
  27774. parent = parent.getParent();
  27775. }
  27776. return ancestorIds;
  27777. },
  27778. previousNode: function(selector, includeSelf) {
  27779. var node = this,
  27780. parent = node.getRefOwner(),
  27781. result, it, i, sibling;
  27782. if (includeSelf && node.is(selector)) {
  27783. return node;
  27784. }
  27785. if (parent) {
  27786. for (it = parent.items.items , i = Ext.Array.indexOf(it, node) - 1; i > -1; i--) {
  27787. sibling = it[i];
  27788. if (sibling.query) {
  27789. result = sibling.query(selector);
  27790. result = result[result.length - 1];
  27791. if (result) {
  27792. return result;
  27793. }
  27794. }
  27795. if (!selector || sibling.is(selector)) {
  27796. return sibling;
  27797. }
  27798. }
  27799. return parent.previousNode(selector, true);
  27800. }
  27801. return null;
  27802. },
  27803. previousSibling: function(selector) {
  27804. var parent = this.getRefOwner(),
  27805. it, idx, sibling;
  27806. if (parent) {
  27807. it = parent.items;
  27808. idx = it.indexOf(this);
  27809. if (idx !== -1) {
  27810. if (selector) {
  27811. for (--idx; idx >= 0; idx--) {
  27812. if ((sibling = it.getAt(idx)).is(selector)) {
  27813. return sibling;
  27814. }
  27815. }
  27816. } else {
  27817. if (idx) {
  27818. return it.getAt(--idx);
  27819. }
  27820. }
  27821. }
  27822. }
  27823. return null;
  27824. },
  27825. nextNode: function(selector, includeSelf) {
  27826. var node = this,
  27827. parent = node.getRefOwner(),
  27828. result, it, len, i, sibling;
  27829. if (includeSelf && node.is(selector)) {
  27830. return node;
  27831. }
  27832. if (parent) {
  27833. for (it = parent.items.items , i = Ext.Array.indexOf(it, node) + 1 , len = it.length; i < len; i++) {
  27834. sibling = it[i];
  27835. if (!selector || sibling.is(selector)) {
  27836. return sibling;
  27837. }
  27838. if (sibling.down) {
  27839. result = sibling.down(selector);
  27840. if (result) {
  27841. return result;
  27842. }
  27843. }
  27844. }
  27845. return parent.nextNode(selector);
  27846. }
  27847. return null;
  27848. },
  27849. nextSibling: function(selector) {
  27850. var parent = this.getRefOwner(),
  27851. it, last, idx, sibling;
  27852. if (parent) {
  27853. it = parent.items;
  27854. idx = it.indexOf(this) + 1;
  27855. if (idx) {
  27856. if (selector) {
  27857. for (last = it.getCount(); idx < last; idx++) {
  27858. if ((sibling = it.getAt(idx)).is(selector)) {
  27859. return sibling;
  27860. }
  27861. }
  27862. } else {
  27863. if (idx < it.getCount()) {
  27864. return it.getAt(idx);
  27865. }
  27866. }
  27867. }
  27868. }
  27869. return null;
  27870. }
  27871. });
  27872. Ext.define('Ext.fx.easing.Abstract', {
  27873. config: {
  27874. startTime: 0,
  27875. startValue: 0
  27876. },
  27877. isEasing: true,
  27878. isEnded: false,
  27879. constructor: function(config) {
  27880. this.initConfig(config);
  27881. return this;
  27882. },
  27883. applyStartTime: function(startTime) {
  27884. if (!startTime) {
  27885. startTime = Ext.Date.now();
  27886. }
  27887. return startTime;
  27888. },
  27889. updateStartTime: function(startTime) {
  27890. this.reset();
  27891. },
  27892. reset: function() {
  27893. this.isEnded = false;
  27894. },
  27895. getValue: Ext.emptyFn
  27896. });
  27897. Ext.define('Ext.fx.easing.Linear', {
  27898. extend: Ext.fx.easing.Abstract,
  27899. alias: 'easing.linear',
  27900. config: {
  27901. duration: 0,
  27902. endValue: 0
  27903. },
  27904. updateStartValue: function(startValue) {
  27905. this.distance = this.getEndValue() - startValue;
  27906. },
  27907. updateEndValue: function(endValue) {
  27908. this.distance = endValue - this.getStartValue();
  27909. },
  27910. getValue: function() {
  27911. var deltaTime = Ext.Date.now() - this.getStartTime(),
  27912. duration = this.getDuration();
  27913. if (deltaTime > duration) {
  27914. this.isEnded = true;
  27915. return this.getEndValue();
  27916. } else {
  27917. return this.getStartValue() + ((deltaTime / duration) * this.distance);
  27918. }
  27919. }
  27920. });
  27921. Ext.define('Ext.util.translatable.Abstract', {
  27922. extend: Ext.Evented,
  27923. mixins: [
  27924. Ext.mixin.Factoryable
  27925. ],
  27926. factoryConfig: {
  27927. type: 'translatable',
  27928. defaultType: 'csstransform'
  27929. },
  27930. config: {
  27931. easing: null,
  27932. easingX: {
  27933. duration: 300
  27934. },
  27935. easingY: {
  27936. duration: 300
  27937. },
  27938. offsetX: 0,
  27939. offsetY: 0
  27940. },
  27941. x: 0,
  27942. y: 0,
  27943. activeEasingX: null,
  27944. activeEasingY: null,
  27945. isAnimating: false,
  27946. isTranslatable: true,
  27947. constructor: function(config) {
  27948. this.callParent([
  27949. config
  27950. ]);
  27951. this.position = {
  27952. x: 0,
  27953. y: 0
  27954. };
  27955. },
  27956. factoryEasing: function(easing) {
  27957. return Ext.factory(easing, Ext.fx.easing.Linear, null, 'easing');
  27958. },
  27959. applyEasing: function(easing) {
  27960. if (!this.getEasingX()) {
  27961. this.setEasingX(this.factoryEasing(easing));
  27962. }
  27963. if (!this.getEasingY()) {
  27964. this.setEasingY(this.factoryEasing(easing));
  27965. }
  27966. },
  27967. applyEasingX: function(easing) {
  27968. return this.factoryEasing(easing);
  27969. },
  27970. applyEasingY: function(easing) {
  27971. return this.factoryEasing(easing);
  27972. },
  27973. updateOffsetX: function() {
  27974. var me = this;
  27975. if (!me.isConfiguring && !me.isAnimating) {
  27976. me.translateXY(me.x, me.y);
  27977. }
  27978. },
  27979. updateOffsetY: function() {
  27980. var me = this;
  27981. if (!me.isConfiguring && !me.isAnimating) {
  27982. me.translateXY(me.x, me.y);
  27983. }
  27984. },
  27985. translate: function(x, y, animation) {
  27986. var me = this;
  27987. if (animation) {
  27988. return me.translateAnimated(x, y, animation);
  27989. }
  27990. if (me.isAnimating) {
  27991. me.stopAnimation();
  27992. }
  27993. if (!isNaN(x) && typeof x === 'number') {
  27994. me.x = x;
  27995. } else {
  27996. x = me.x;
  27997. }
  27998. if (!isNaN(y) && typeof y === 'number') {
  27999. me.y = y;
  28000. } else {
  28001. y = me.y;
  28002. }
  28003. me.translateXY(x, y);
  28004. },
  28005. translateXY: function(x, y) {
  28006. var me = this;
  28007. if (!me.destroyed) {
  28008. me.doTranslate(x + me.getOffsetX(), y + me.getOffsetY());
  28009. if (me.hasListeners.translate) {
  28010. me.fireEvent('translate', me, x, y);
  28011. }
  28012. }
  28013. },
  28014. translateAxis: function(axis, value, animation) {
  28015. var x, y;
  28016. if (axis === 'x') {
  28017. x = value;
  28018. } else {
  28019. y = value;
  28020. }
  28021. return this.translate(x, y, animation);
  28022. },
  28023. getPosition: function() {
  28024. var me = this,
  28025. position = me.position;
  28026. position.x = -me.x;
  28027. position.y = -me.y;
  28028. return position;
  28029. },
  28030. animate: function(easingX, easingY) {
  28031. var me = this;
  28032. me.activeEasingX = easingX;
  28033. me.activeEasingY = easingY;
  28034. me.isAnimating = true;
  28035. if (me.ownerCmp) {
  28036. me.ownerCmp.isTranslating = true;
  28037. }
  28038. me.lastX = null;
  28039. me.lastY = null;
  28040. Ext.AnimationQueue.start(me.doAnimationFrame, me);
  28041. me.fireEvent('animationstart', me, me.x, me.y);
  28042. return me;
  28043. },
  28044. translateAnimated: function(x, y, animation) {
  28045. var me = this,
  28046. now, easing, easingX, easingY;
  28047. if (!Ext.isObject(animation)) {
  28048. animation = {};
  28049. }
  28050. if (me.isAnimating) {
  28051. me.stopAnimation();
  28052. }
  28053. me.callback = animation.callback;
  28054. me.callbackScope = animation.scope;
  28055. now = Ext.Date.now();
  28056. easing = animation.easing;
  28057. easingX = (typeof x === 'number') ? (animation.easingX || easing || me.getEasingX() || true) : null;
  28058. easingY = (typeof y === 'number') ? (animation.easingY || easing || me.getEasingY() || true) : null;
  28059. if (easingX) {
  28060. easingX = me.factoryEasing(easingX);
  28061. easingX.setStartTime(now);
  28062. easingX.setStartValue(me.x);
  28063. easingX.setEndValue(x);
  28064. if ('duration' in animation) {
  28065. easingX.setDuration(animation.duration);
  28066. }
  28067. }
  28068. if (easingY) {
  28069. easingY = me.factoryEasing(easingY);
  28070. easingY.setStartTime(now);
  28071. easingY.setStartValue(me.y);
  28072. easingY.setEndValue(y);
  28073. if ('duration' in animation) {
  28074. easingY.setDuration(animation.duration);
  28075. }
  28076. }
  28077. return me.animate(easingX, easingY);
  28078. },
  28079. doAnimationFrame: function() {
  28080. var me = this,
  28081. easingX = me.activeEasingX,
  28082. easingY = me.activeEasingY,
  28083. now = Date.now(),
  28084. x, y;
  28085. if (!me.isAnimating) {
  28086. return;
  28087. }
  28088. me.lastRun = now;
  28089. if (easingX === null && easingY === null) {
  28090. me.stopAnimation();
  28091. return;
  28092. }
  28093. if (easingX !== null) {
  28094. me.x = x = Math.round(easingX.getValue());
  28095. if (easingX.isEnded) {
  28096. me.activeEasingX = null;
  28097. me.fireEvent('axisanimationend', me, 'x', x);
  28098. }
  28099. } else {
  28100. x = me.x;
  28101. }
  28102. if (easingY !== null) {
  28103. me.y = y = Math.round(easingY.getValue());
  28104. if (easingY.isEnded) {
  28105. me.activeEasingY = null;
  28106. me.fireEvent('axisanimationend', me, 'y', y);
  28107. }
  28108. } else {
  28109. y = me.y;
  28110. }
  28111. if (me.lastX !== x || me.lastY !== y) {
  28112. me.translateXY(x, y);
  28113. me.lastX = x;
  28114. me.lastY = y;
  28115. }
  28116. me.fireEvent('animationframe', me, x, y);
  28117. },
  28118. stopAnimation: function() {
  28119. var me = this;
  28120. if (!me.isAnimating) {
  28121. return;
  28122. }
  28123. me.activeEasingX = null;
  28124. me.activeEasingY = null;
  28125. me.isAnimating = false;
  28126. if (me.ownerCmp) {
  28127. me.ownerCmp.isTranslating = false;
  28128. }
  28129. Ext.AnimationQueue.stop(me.doAnimationFrame, me);
  28130. me.fireEvent('animationend', me, me.x, me.y);
  28131. if (me.callback) {
  28132. me.callback.call(me.callbackScope);
  28133. me.callback = null;
  28134. }
  28135. },
  28136. refresh: function() {
  28137. this.translate(this.x, this.y);
  28138. },
  28139. resolveListenerScope: function() {
  28140. var ownerCmp = this.ownerCmp,
  28141. a = arguments;
  28142. if (ownerCmp) {
  28143. return ownerCmp.resolveListenerScope.apply(ownerCmp, a);
  28144. }
  28145. return this.callParent(a);
  28146. },
  28147. destroy: function() {
  28148. var me = this;
  28149. me.destroying = true;
  28150. if (me.isAnimating) {
  28151. me.stopAnimation();
  28152. }
  28153. me.callParent();
  28154. me.destroyed = true;
  28155. }
  28156. });
  28157. Ext.define('Ext.util.Bag', {
  28158. isBag: true,
  28159. constructor: function() {
  28160. this.items = [];
  28161. this.map = {};
  28162. },
  28163. generation: 0,
  28164. length: 0,
  28165. beginUpdate: Ext.emptyFn,
  28166. endUpdate: Ext.emptyFn,
  28167. add: function(item) {
  28168. var me = this,
  28169. items = me.items,
  28170. map = me.map,
  28171. n = 1,
  28172. old, i, idx, id, it, ret, was;
  28173. if (Ext.isArray(item)) {
  28174. old = ret = [];
  28175. n = item.length;
  28176. }
  28177. for (i = 0; i < n; i++) {
  28178. id = me.getKey(it = old ? item[i] : item);
  28179. idx = map[id];
  28180. if (idx === undefined) {
  28181. items.push(it);
  28182. map[id] = me.length++;
  28183. if (old) {
  28184. old.push(it);
  28185. } else {
  28186. ret = it;
  28187. }
  28188. } else {
  28189. was = items[idx];
  28190. if (old) {
  28191. old.push(was);
  28192. } else {
  28193. ret = was;
  28194. }
  28195. items[idx] = it;
  28196. }
  28197. }
  28198. ++me.generation;
  28199. return ret;
  28200. },
  28201. clear: function() {
  28202. var me = this,
  28203. needsClear = me.generation || me.length,
  28204. ret = needsClear ? me.items : [];
  28205. if (needsClear) {
  28206. me.items = [];
  28207. me.length = 0;
  28208. me.map = {};
  28209. ++me.generation;
  28210. }
  28211. return ret;
  28212. },
  28213. clone: function() {
  28214. var me = this,
  28215. ret = new me.self(),
  28216. len = me.length;
  28217. if (len) {
  28218. Ext.apply(ret.map, me.map);
  28219. ret.items = me.items.slice();
  28220. ret.length = me.length;
  28221. }
  28222. return ret;
  28223. },
  28224. contains: function(item) {
  28225. var ret = false,
  28226. map = this.map,
  28227. key;
  28228. if (item != null) {
  28229. key = this.getKey(item);
  28230. if (key in map) {
  28231. ret = this.items[map[key]] === item;
  28232. }
  28233. }
  28234. return ret;
  28235. },
  28236. containsKey: function(key) {
  28237. return key in this.map;
  28238. },
  28239. destroy: function() {
  28240. this.items = this.map = null;
  28241. this.callParent();
  28242. },
  28243. each: function(fn, scope) {
  28244. var items = this.items,
  28245. len = items.length,
  28246. i, ret;
  28247. if (len) {
  28248. scope = scope || this;
  28249. items = items.slice(0);
  28250. for (i = 0; i < len; i++) {
  28251. ret = fn.call(scope, items[i], i, len);
  28252. if (ret === false) {
  28253. break;
  28254. }
  28255. }
  28256. }
  28257. return ret;
  28258. },
  28259. getAt: function(index) {
  28260. var out = null;
  28261. if (index < this.length) {
  28262. out = this.items[index];
  28263. }
  28264. return out;
  28265. },
  28266. get: function(key) {
  28267. return this.getByKey(key);
  28268. },
  28269. getByKey: function(key) {
  28270. var map = this.map,
  28271. ret = (key in map) ? this.items[map[key]] : null;
  28272. return ret;
  28273. },
  28274. indexOfKey: function(key) {
  28275. var map = this.map,
  28276. ret = (key in map) ? map[key] : -1;
  28277. return ret;
  28278. },
  28279. last: function() {
  28280. return this.items[this.length - 1];
  28281. },
  28282. updateKey: function(item, oldKey) {
  28283. var me = this,
  28284. map = me.map,
  28285. newKey;
  28286. if (!item || !oldKey) {
  28287. return;
  28288. }
  28289. if ((newKey = me.getKey(item)) !== oldKey) {
  28290. if (me.getAt(map[oldKey]) === item && !(newKey in map)) {
  28291. me.generation++;
  28292. map[newKey] = map[oldKey];
  28293. delete map[oldKey];
  28294. }
  28295. } else
  28296. {
  28297. if (newKey in map && me.getAt(map[newKey]) !== item) {
  28298. Ext.raise('Duplicate newKey "' + newKey + '" for item with oldKey "' + oldKey + '"');
  28299. }
  28300. if (oldKey in map && me.getAt(map[oldKey]) !== item) {
  28301. Ext.raise('Incorrect oldKey "' + oldKey + '" for item with newKey "' + newKey + '"');
  28302. }
  28303. }
  28304. },
  28305. getCount: function() {
  28306. return this.length;
  28307. },
  28308. getKey: function(item) {
  28309. return item.id || item.getId();
  28310. },
  28311. getRange: function(begin, end) {
  28312. var items = this.items,
  28313. length = items.length,
  28314. range;
  28315. if (!length) {
  28316. range = [];
  28317. } else {
  28318. range = Ext.Number.clipIndices(length, [
  28319. begin,
  28320. end
  28321. ]);
  28322. range = items.slice(range[0], range[1]);
  28323. }
  28324. return range;
  28325. },
  28326. remove: function(item) {
  28327. var me = this,
  28328. map = me.map,
  28329. items = me.items,
  28330. ret = null,
  28331. n = 1,
  28332. changed, old, i, idx, id, last, was;
  28333. if (Ext.isArray(item)) {
  28334. n = item.length;
  28335. old = ret = [];
  28336. }
  28337. if (me.length) {
  28338. for (i = 0; i < n; i++) {
  28339. idx = map[id = me.getKey(old ? item[i] : item)];
  28340. if (idx !== undefined) {
  28341. delete map[id];
  28342. was = items[idx];
  28343. if (old) {
  28344. old.push(was);
  28345. } else {
  28346. ret = was;
  28347. }
  28348. last = items.pop();
  28349. if (idx < --me.length) {
  28350. items[idx] = last;
  28351. map[me.getKey(last)] = idx;
  28352. }
  28353. changed = true;
  28354. }
  28355. }
  28356. if (changed) {
  28357. ++me.generation;
  28358. }
  28359. }
  28360. return ret;
  28361. },
  28362. removeByKey: function(key) {
  28363. var item = this.getByKey(key);
  28364. if (item) {
  28365. this.remove(item);
  28366. }
  28367. return item || null;
  28368. },
  28369. replace: function(item) {
  28370. this.add(item);
  28371. return item;
  28372. },
  28373. sort: function(fn) {
  28374. var me = this,
  28375. items = me.items,
  28376. n = items.length,
  28377. item;
  28378. if (n) {
  28379. Ext.Array.sort(items, fn);
  28380. me.map = {};
  28381. while (n-- > 0) {
  28382. item = items[n];
  28383. me.map[me.getKey(item)] = n;
  28384. }
  28385. ++me.generation;
  28386. }
  28387. }
  28388. });
  28389. Ext.define('Ext.util.Format', function() {
  28390. var me;
  28391. return {
  28392. singleton: true,
  28393. defaultDateFormat: 'm/d/Y',
  28394. thousandSeparator: ',',
  28395. decimalSeparator: '.',
  28396. currencyPrecision: 2,
  28397. currencySign: '$',
  28398. currencySpacer: '',
  28399. percentSign: '%',
  28400. currencyAtEnd: false,
  28401. stripTagsRe: /<\/?[^>]+>/gi,
  28402. stripScriptsRe: /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
  28403. nl2brRe: /\r?\n/g,
  28404. hashRe: /#+$/,
  28405. allHashes: /^#+$/,
  28406. formatPattern: /[\d,.#]+/,
  28407. formatCleanRe: /[^\d.#]/g,
  28408. I18NFormatCleanRe: null,
  28409. formatFns: {},
  28410. constructor: function() {
  28411. me = this;
  28412. },
  28413. nbsp: function(value, strict) {
  28414. strict = strict !== false;
  28415. if (strict ? value === '' || value == null : !value) {
  28416. value = '\xa0';
  28417. }
  28418. return value;
  28419. },
  28420. undef: function(value) {
  28421. return value !== undefined ? value : "";
  28422. },
  28423. defaultValue: function(value, defaultValue) {
  28424. return value !== undefined && value !== '' ? value : defaultValue;
  28425. },
  28426. substr: 'ab'.substr(-1) !== 'b' ? function(value, start, length) {
  28427. var str = String(value);
  28428. return (start < 0) ? str.substr(Math.max(str.length + start, 0), length) : str.substr(start, length);
  28429. } : function(value, start, length) {
  28430. return String(value).substr(start, length);
  28431. },
  28432. lowercase: function(value) {
  28433. return String(value).toLowerCase();
  28434. },
  28435. uppercase: function(value) {
  28436. return String(value).toUpperCase();
  28437. },
  28438. usMoney: function(value) {
  28439. return me.currency(value, '$', 2);
  28440. },
  28441. currency: function(value, currencySign, decimals, end, currencySpacer) {
  28442. var negativeSign = '',
  28443. format = ",0",
  28444. i = 0;
  28445. value = value - 0;
  28446. if (value < 0) {
  28447. value = -value;
  28448. negativeSign = '-';
  28449. }
  28450. decimals = Ext.isDefined(decimals) ? decimals : me.currencyPrecision;
  28451. format += (decimals > 0 ? '.' : '');
  28452. for (; i < decimals; i++) {
  28453. format += '0';
  28454. }
  28455. value = me.number(value, format);
  28456. if (currencySpacer == null) {
  28457. currencySpacer = me.currencySpacer;
  28458. }
  28459. if ((end || me.currencyAtEnd) === true) {
  28460. return Ext.String.format("{0}{1}{2}{3}", negativeSign, value, currencySpacer, currencySign || me.currencySign);
  28461. } else {
  28462. return Ext.String.format("{0}{1}{2}{3}", negativeSign, currencySign || me.currencySign, currencySpacer, value);
  28463. }
  28464. },
  28465. date: function(value, format) {
  28466. if (!value) {
  28467. return "";
  28468. }
  28469. if (!Ext.isDate(value)) {
  28470. value = new Date(Date.parse(value));
  28471. }
  28472. return Ext.Date.dateFormat(value, format || Ext.Date.defaultFormat);
  28473. },
  28474. dateRenderer: function(format) {
  28475. return function(v) {
  28476. return me.date(v, format);
  28477. };
  28478. },
  28479. hex: function(value, digits) {
  28480. var s = parseInt(value || 0, 10).toString(16);
  28481. if (digits) {
  28482. if (digits < 0) {
  28483. digits = -digits;
  28484. if (s.length > digits) {
  28485. s = s.substring(s.length - digits);
  28486. }
  28487. }
  28488. while (s.length < digits) {
  28489. s = '0' + s;
  28490. }
  28491. }
  28492. return s;
  28493. },
  28494. or: function(value, orValue) {
  28495. return value || orValue;
  28496. },
  28497. pick: function(value, firstValue, secondValue) {
  28498. var ret;
  28499. if (Ext.isNumber(value)) {
  28500. ret = arguments[value + 1];
  28501. if (ret) {
  28502. return ret;
  28503. }
  28504. }
  28505. return value ? secondValue : firstValue;
  28506. },
  28507. lessThanElse: function(value, threshold, below, above, equal) {
  28508. var v = Ext.Number.from(value, 0),
  28509. t = Ext.Number.from(threshold, 0),
  28510. missing = !Ext.isDefined(equal);
  28511. return v < t ? below : (v > t ? above : (missing ? above : equal));
  28512. },
  28513. sign: function(value, negative, positive, zero) {
  28514. if (zero === undefined) {
  28515. zero = positive;
  28516. }
  28517. return me.lessThanElse(value, 0, negative, positive, zero);
  28518. },
  28519. stripTags: function(value) {
  28520. return !value ? value : String(value).replace(me.stripTagsRe, "");
  28521. },
  28522. stripScripts: function(value) {
  28523. return !value ? value : String(value).replace(me.stripScriptsRe, "");
  28524. },
  28525. fileSize: (function() {
  28526. var byteLimit = 1024,
  28527. kbLimit = 1048576,
  28528. mbLimit = 1073741824;
  28529. return function(size) {
  28530. var out;
  28531. if (size < byteLimit) {
  28532. if (size === 1) {
  28533. out = '1 byte';
  28534. } else {
  28535. out = size + ' bytes';
  28536. }
  28537. } else if (size < kbLimit) {
  28538. out = (Math.round(((size * 10) / byteLimit)) / 10) + ' KB';
  28539. } else if (size < mbLimit) {
  28540. out = (Math.round(((size * 10) / kbLimit)) / 10) + ' MB';
  28541. } else {
  28542. out = (Math.round(((size * 10) / mbLimit)) / 10) + ' GB';
  28543. }
  28544. return out;
  28545. };
  28546. })(),
  28547. math: (function() {
  28548. var fns = {};
  28549. return function(v, a) {
  28550. if (!fns[a]) {
  28551. fns[a] = Ext.functionFactory('v', 'return v ' + a + ';');
  28552. }
  28553. return fns[a](v);
  28554. };
  28555. }()),
  28556. round: function(value, precision) {
  28557. var result = Number(value);
  28558. if (typeof precision === 'number') {
  28559. precision = Math.pow(10, precision);
  28560. result = Math.round(value * precision) / precision;
  28561. } else if (precision === undefined) {
  28562. result = Math.round(result);
  28563. }
  28564. return result;
  28565. },
  28566. number: function(v, formatString) {
  28567. var formatFn;
  28568. if (!formatString) {
  28569. return v;
  28570. }
  28571. if (isNaN(v)) {
  28572. return '';
  28573. }
  28574. formatFn = me.formatFns[formatString];
  28575. if (!formatFn) {
  28576. var originalFormatString = formatString,
  28577. comma = me.thousandSeparator,
  28578. decimalSeparator = me.decimalSeparator,
  28579. precision = 0,
  28580. trimPart = '',
  28581. hasComma, splitFormat, extraChars, trimTrailingZeroes, code, len;
  28582. if (formatString.substr(formatString.length - 2) === '/i') {
  28583. if (!me.I18NFormatCleanRe || me.lastDecimalSeparator !== decimalSeparator) {
  28584. me.I18NFormatCleanRe = new RegExp('[^\\d\\' + decimalSeparator + '#]', 'g');
  28585. me.lastDecimalSeparator = decimalSeparator;
  28586. }
  28587. formatString = formatString.substr(0, formatString.length - 2);
  28588. hasComma = formatString.indexOf(comma) !== -1;
  28589. splitFormat = formatString.replace(me.I18NFormatCleanRe, '').split(decimalSeparator);
  28590. } else {
  28591. hasComma = formatString.indexOf(',') !== -1;
  28592. splitFormat = formatString.replace(me.formatCleanRe, '').split('.');
  28593. }
  28594. extraChars = formatString.replace(me.formatPattern, '');
  28595. if (splitFormat.length > 2) {
  28596. Ext.raise({
  28597. sourceClass: "Ext.util.Format",
  28598. sourceMethod: "number",
  28599. value: v,
  28600. formatString: formatString,
  28601. msg: "Invalid number format, should have no more than 1 decimal"
  28602. });
  28603. }
  28604. else if (splitFormat.length === 2) {
  28605. precision = splitFormat[1].length;
  28606. trimTrailingZeroes = splitFormat[1].match(me.hashRe);
  28607. if (trimTrailingZeroes) {
  28608. len = trimTrailingZeroes[0].length;
  28609. trimPart = 'trailingZeroes=new RegExp(Ext.String.escapeRegex(utilFormat.decimalSeparator) + "*0{0,' + len + '}$")';
  28610. }
  28611. }
  28612. code = [
  28613. 'var utilFormat=Ext.util.Format,extNumber=Ext.Number,neg,absVal,fnum,parts' + (hasComma ? ',thousandSeparator,thousands=[],j,n,i' : '') + (extraChars ? ',formatString="' + formatString + '",formatPattern=/[\\d,\\.#]+/' : '') +
  28614. ',trailingZeroes;' + 'return function(v){' + 'if(typeof v!=="number"&&isNaN(v=extNumber.from(v,NaN)))return"";' + 'neg=v<0;',
  28615. 'absVal=Math.abs(v);',
  28616. 'fnum=Ext.Number.toFixed(absVal, ' + precision + ');',
  28617. trimPart,
  28618. ';'
  28619. ];
  28620. if (hasComma) {
  28621. if (precision) {
  28622. code[code.length] = 'parts=fnum.split(".");';
  28623. code[code.length] = 'fnum=parts[0];';
  28624. }
  28625. code[code.length] = 'if(absVal>=1000) {';
  28626. code[code.length] = 'thousandSeparator=utilFormat.thousandSeparator;' + 'thousands.length=0;' + 'j=fnum.length;' + 'n=fnum.length%3||3;' + 'for(i=0;i<j;i+=n){' + 'if(i!==0){' + 'n=3;' + '}' + 'thousands[thousands.length]=fnum.substr(i,n);' + '}' + 'fnum=thousands.join(thousandSeparator);' + '}';
  28627. if (precision) {
  28628. code[code.length] = 'fnum += utilFormat.decimalSeparator+parts[1];';
  28629. }
  28630. } else if (precision) {
  28631. code[code.length] = 'if(utilFormat.decimalSeparator!=="."){' + 'parts=fnum.split(".");' + 'fnum=parts[0]+utilFormat.decimalSeparator+parts[1];' + '}';
  28632. }
  28633. code[code.length] = 'if(neg&&fnum!=="' + (precision ? '0.' + Ext.String.repeat('0', precision) : '0') + '") { fnum="-"+fnum; }';
  28634. if (trimTrailingZeroes) {
  28635. code[code.length] = 'fnum=fnum.replace(trailingZeroes,"");';
  28636. }
  28637. code[code.length] = 'return ';
  28638. if (extraChars) {
  28639. code[code.length] = 'formatString.replace(formatPattern, fnum);';
  28640. } else {
  28641. code[code.length] = 'fnum;';
  28642. }
  28643. code[code.length] = '};';
  28644. formatFn = me.formatFns[originalFormatString] = Ext.functionFactory('Ext', code.join(''))(Ext);
  28645. }
  28646. return formatFn(v);
  28647. },
  28648. numberRenderer: function(format) {
  28649. return function(v) {
  28650. return me.number(v, format);
  28651. };
  28652. },
  28653. percent: function(value, formatString) {
  28654. return me.number(value * 100, formatString || '0') + me.percentSign;
  28655. },
  28656. repeat: function(value, text, sep) {
  28657. return Ext.String.repeat(text, value, sep);
  28658. },
  28659. attributes: function(attributes) {
  28660. var result, name;
  28661. if (typeof attributes === 'object') {
  28662. result = [];
  28663. for (name in attributes) {
  28664. if (attributes.hasOwnProperty(name)) {
  28665. result.push(name, '="', name === 'style' ? Ext.DomHelper.generateStyles(attributes[name], null, true) : Ext.htmlEncode(attributes[name]), '" ');
  28666. }
  28667. }
  28668. attributes = result.join('');
  28669. }
  28670. return attributes || '';
  28671. },
  28672. plural: function(value, singular, plural) {
  28673. return value + ' ' + (value === 1 ? singular : (plural ? plural : singular + 's'));
  28674. },
  28675. nl2br: function(v) {
  28676. return Ext.isEmpty(v) ? '' : v.replace(me.nl2brRe, '<br/>');
  28677. },
  28678. capitalize: Ext.String.capitalize,
  28679. uncapitalize: Ext.String.uncapitalize,
  28680. ellipsis: Ext.String.ellipsis,
  28681. escape: Ext.String.escape,
  28682. escapeRegex: Ext.String.escapeRegex,
  28683. htmlDecode: Ext.String.htmlDecode,
  28684. htmlEncode: Ext.String.htmlEncode,
  28685. leftPad: Ext.String.leftPad,
  28686. toggle: Ext.String.toggle,
  28687. trim: Ext.String.trim,
  28688. parseBox: function(box) {
  28689. box = box || 0;
  28690. if (typeof box === 'number') {
  28691. return {
  28692. top: box,
  28693. right: box,
  28694. bottom: box,
  28695. left: box
  28696. };
  28697. }
  28698. var parts = box.split(' '),
  28699. ln = parts.length;
  28700. if (ln === 1) {
  28701. parts[1] = parts[2] = parts[3] = parts[0];
  28702. } else if (ln === 2) {
  28703. parts[2] = parts[0];
  28704. parts[3] = parts[1];
  28705. } else if (ln === 3) {
  28706. parts[3] = parts[1];
  28707. }
  28708. return {
  28709. top: parseInt(parts[0], 10) || 0,
  28710. right: parseInt(parts[1], 10) || 0,
  28711. bottom: parseInt(parts[2], 10) || 0,
  28712. left: parseInt(parts[3], 10) || 0
  28713. };
  28714. },
  28715. resource: function(url, prefix) {
  28716. prefix = prefix || '';
  28717. return Ext.resolveResource(prefix + url);
  28718. },
  28719. uri: function(value) {
  28720. return encodeURI(value);
  28721. },
  28722. uriCmp: function(value) {
  28723. return encodeURIComponent(value);
  28724. },
  28725. wordBreakRe: /[\W\s]+/,
  28726. word: function(value, index, sep) {
  28727. var re = sep ? (typeof sep === 'string' ? new RegExp(sep) : sep) : me.wordBreakRe,
  28728. parts = (value || '').split(re);
  28729. return parts[index || 0] || '';
  28730. }
  28731. };
  28732. });
  28733. Ext.define('Ext.Template', {
  28734. inheritableStatics: {
  28735. from: function(el, config) {
  28736. el = Ext.getDom(el);
  28737. return new this(el.value || el.innerHTML, config || '');
  28738. }
  28739. },
  28740. useEval: Ext.isGecko,
  28741. constructor: function(html) {
  28742. var me = this,
  28743. args = arguments,
  28744. buffer = [],
  28745. length = args.length,
  28746. i, value;
  28747. me.initialConfig = {};
  28748. if (length === 1 && Ext.isArray(html)) {
  28749. args = html;
  28750. length = args.length;
  28751. }
  28752. if (length > 1) {
  28753. for (i = 0; i < length; i++) {
  28754. value = args[i];
  28755. if (typeof value === 'object') {
  28756. Ext.apply(me.initialConfig, value);
  28757. Ext.apply(me, value);
  28758. } else {
  28759. buffer.push(value);
  28760. }
  28761. }
  28762. } else {
  28763. buffer.push(html);
  28764. }
  28765. me.html = buffer.join('');
  28766. },
  28767. isTemplate: true,
  28768. disableFormats: false,
  28769. tokenRe: /\{(?:(?:(\d+)|([a-z_$][\w\-$]*))(?::([a-z_.]+)(?:\(([^)]*?)?\))?)?)\}/gi,
  28770. apply: function(values) {
  28771. var me = this;
  28772. if (me.compiled) {
  28773. if (!me.fn) {
  28774. me.compile();
  28775. }
  28776. return me.fn(values).join('');
  28777. }
  28778. return me.evaluate(values);
  28779. },
  28780. evaluate: function(values) {
  28781. var me = this,
  28782. useFormat = !me.disableFormats,
  28783. fm = Ext.util.Format,
  28784. tpl = me;
  28785. function fn(match, index, name, formatFn, args) {
  28786. if (name == null || name === '') {
  28787. name = index;
  28788. }
  28789. if (formatFn && useFormat) {
  28790. if (args) {
  28791. args = [
  28792. values[name]
  28793. ].concat(Ext.functionFactory('return [' + args + '];')());
  28794. } else {
  28795. args = [
  28796. values[name]
  28797. ];
  28798. }
  28799. if (formatFn.substr(0, 5) === "this.") {
  28800. return tpl[formatFn.substr(5)].apply(tpl, args);
  28801. }
  28802. else if (fm[formatFn]) {
  28803. return fm[formatFn].apply(fm, args);
  28804. } else
  28805. {
  28806. return match;
  28807. }
  28808. } else {
  28809. return values[name] !== undefined ? values[name] : "";
  28810. }
  28811. }
  28812. return me.html.replace(me.tokenRe, fn);
  28813. },
  28814. applyOut: function(values, out) {
  28815. var me = this;
  28816. if (me.compiled) {
  28817. if (!me.fn) {
  28818. me.compile();
  28819. }
  28820. out.push.apply(out, me.fn(values));
  28821. } else {
  28822. out.push(me.apply(values));
  28823. }
  28824. return out;
  28825. },
  28826. applyTemplate: function() {
  28827. return this.apply.apply(this, arguments);
  28828. },
  28829. set: function(html, compile) {
  28830. var me = this;
  28831. me.html = html;
  28832. me.compiled = !!compile;
  28833. me.fn = null;
  28834. return me;
  28835. },
  28836. compileARe: /\\/g,
  28837. compileBRe: /(\r\n|\n)/g,
  28838. compileCRe: /'/g,
  28839. compile: function() {
  28840. var me = this,
  28841. code;
  28842. code = me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.tokenRe, me.regexReplaceFn.bind(me));
  28843. code = (this.disableFormats !== true ? 'var fm=Ext.util.Format;' : '') + (me.useEval ? '$=' : 'return') + " function(v){return ['" + code + "'];};";
  28844. me.fn = me.useEval ? me.evalCompiled(code) : (new Function('Ext', code))(Ext);
  28845. me.compiled = true;
  28846. return me;
  28847. },
  28848. evalCompiled: function($) {
  28849. eval($);
  28850. return $;
  28851. },
  28852. regexReplaceFn: function(match, index, name, formatFn, args) {
  28853. if (index == null || index === '') {
  28854. index = '"' + name + '"';
  28855. }
  28856. else if (this.stringFormat) {
  28857. index = parseInt(index) + 1;
  28858. }
  28859. if (formatFn && this.disableFormats !== true) {
  28860. args = args ? ',' + args : "";
  28861. if (formatFn.substr(0, 5) === "this.") {
  28862. formatFn = formatFn + '(';
  28863. }
  28864. else if (Ext.util.Format[formatFn]) {
  28865. formatFn = "fm." + formatFn + '(';
  28866. } else
  28867. {
  28868. return match;
  28869. }
  28870. return "'," + formatFn + "v[" + index + "]" + args + "),'";
  28871. } else {
  28872. return "',v[" + index + "] == undefined ? '' : v[" + index + "],'";
  28873. }
  28874. },
  28875. insertFirst: function(el, values, returnElement) {
  28876. return this.doInsert('afterBegin', el, values, returnElement);
  28877. },
  28878. insertBefore: function(el, values, returnElement) {
  28879. return this.doInsert('beforeBegin', el, values, returnElement);
  28880. },
  28881. insertAfter: function(el, values, returnElement) {
  28882. return this.doInsert('afterEnd', el, values, returnElement);
  28883. },
  28884. append: function(el, values, returnElement) {
  28885. return this.doInsert('beforeEnd', el, values, returnElement);
  28886. },
  28887. doInsert: function(where, el, values, returnElement) {
  28888. var newNode = Ext.DomHelper.insertHtml(where, Ext.getDom(el), this.apply(values));
  28889. return returnElement ? Ext.get(newNode) : newNode;
  28890. },
  28891. overwrite: function(el, values, returnElement) {
  28892. var newNode = Ext.DomHelper.overwrite(Ext.getDom(el), this.apply(values));
  28893. return returnElement ? Ext.get(newNode) : newNode;
  28894. }
  28895. }, function(Template) {
  28896. var formatRe = /\{\d+\}/,
  28897. generateFormatFn = function(format) {
  28898. if (formatRe.test(format)) {
  28899. format = new Template(format, formatTplConfig);
  28900. return function() {
  28901. return format.apply(arguments);
  28902. };
  28903. } else
  28904. {
  28905. return function() {
  28906. return format;
  28907. };
  28908. }
  28909. },
  28910. formatTplConfig = {
  28911. useFormat: false,
  28912. compiled: true,
  28913. stringFormat: true
  28914. },
  28915. formatFns = {};
  28916. Ext.String.format = Ext.util.Format.format = function(format) {
  28917. var formatFn = formatFns[format] || (formatFns[format] = generateFormatFn(format));
  28918. return formatFn.apply(this, arguments);
  28919. };
  28920. Ext.String.formatEncode = function() {
  28921. return Ext.String.htmlEncode(Ext.String.format.apply(this, arguments));
  28922. };
  28923. });
  28924. Ext.define('Ext.util.XTemplateParser', {
  28925. constructor: function(config) {
  28926. Ext.apply(this, config);
  28927. },
  28928. doTpl: Ext.emptyFn,
  28929. parse: function(str) {
  28930. var me = this,
  28931. len = str.length,
  28932. aliases = {
  28933. elseif: 'elif'
  28934. },
  28935. topRe = me.topRe,
  28936. actionsRe = me.actionsRe,
  28937. index, stack, s, m, t, prev, frame, subMatch, begin, end, actions, prop, expectTplNext;
  28938. me.level = 0;
  28939. me.stack = stack = [];
  28940. for (index = 0; index < len; index = end) {
  28941. topRe.lastIndex = index;
  28942. m = topRe.exec(str);
  28943. if (!m) {
  28944. me.doText(str.substring(index, len));
  28945. break;
  28946. }
  28947. begin = m.index;
  28948. end = topRe.lastIndex;
  28949. if (index < begin) {
  28950. s = str.substring(index, begin);
  28951. if (!(expectTplNext && Ext.String.trim(s) === '')) {
  28952. me.doText(s);
  28953. }
  28954. }
  28955. expectTplNext = false;
  28956. if (m[1]) {
  28957. end = str.indexOf('%}', begin + 2);
  28958. me.doEval(str.substring(begin + 2, end));
  28959. end += 2;
  28960. } else if (m[2]) {
  28961. end = str.indexOf(']}', begin + 2);
  28962. me.doExpr(str.substring(begin + 2, end));
  28963. end += 2;
  28964. } else if (m[3]) {
  28965. me.doTag(m[3]);
  28966. } else if (m[4]) {
  28967. actions = null;
  28968. while ((subMatch = actionsRe.exec(m[4])) !== null) {
  28969. s = subMatch[2] || subMatch[3];
  28970. if (s) {
  28971. s = Ext.String.htmlDecode(s);
  28972. t = subMatch[1];
  28973. t = aliases[t] || t;
  28974. actions = actions || {};
  28975. prev = actions[t];
  28976. if (typeof prev === 'string') {
  28977. actions[t] = [
  28978. prev,
  28979. s
  28980. ];
  28981. } else if (prev) {
  28982. actions[t].push(s);
  28983. } else {
  28984. actions[t] = s;
  28985. }
  28986. }
  28987. }
  28988. if (!actions) {
  28989. if (me.elseRe.test(m[4])) {
  28990. me.doElse();
  28991. } else if (me.defaultRe.test(m[4])) {
  28992. me.doDefault();
  28993. } else {
  28994. me.doTpl();
  28995. stack.push({
  28996. type: 'tpl'
  28997. });
  28998. }
  28999. } else if (actions['if']) {
  29000. me.doIf(actions['if'], actions);
  29001. stack.push({
  29002. type: 'if'
  29003. });
  29004. } else if (actions['switch']) {
  29005. me.doSwitch(actions['switch'], actions);
  29006. stack.push({
  29007. type: 'switch'
  29008. });
  29009. expectTplNext = true;
  29010. } else if (actions['case']) {
  29011. me.doCase(actions['case'], actions);
  29012. } else if (actions['elif']) {
  29013. me.doElseIf(actions['elif'], actions);
  29014. } else if (actions['for']) {
  29015. ++me.level;
  29016. if (prop = me.propRe.exec(m[4])) {
  29017. actions.propName = prop[1] || prop[2];
  29018. }
  29019. me.doFor(actions['for'], actions);
  29020. stack.push({
  29021. type: 'for',
  29022. actions: actions
  29023. });
  29024. } else if (actions['foreach']) {
  29025. ++me.level;
  29026. if (prop = me.propRe.exec(m[4])) {
  29027. actions.propName = prop[1] || prop[2];
  29028. }
  29029. me.doForEach(actions['foreach'], actions);
  29030. stack.push({
  29031. type: 'foreach',
  29032. actions: actions
  29033. });
  29034. } else if (actions.exec) {
  29035. me.doExec(actions.exec, actions);
  29036. stack.push({
  29037. type: 'exec',
  29038. actions: actions
  29039. });
  29040. }
  29041. }
  29042. else if (m[0].length === 5) {
  29043. stack.push({
  29044. type: 'tpl'
  29045. });
  29046. } else {
  29047. frame = stack.pop();
  29048. me.doEnd(frame.type, frame.actions);
  29049. if (frame.type === 'for' || frame.type === 'foreach') {
  29050. --me.level;
  29051. }
  29052. }
  29053. }
  29054. },
  29055. topRe: /(?:(\{\%)|(\{\[)|\{([^{}]+)\})|(?:<tpl([^>]*)\>)|(?:<\/tpl>)/g,
  29056. actionsRe: /\s*(elif|elseif|if|for|foreach|exec|switch|case|eval|between)\s*\=\s*(?:(?:"([^"]*)")|(?:'([^']*)'))\s*/g,
  29057. propRe: /prop=(?:(?:"([^"]*)")|(?:'([^']*)'))/,
  29058. defaultRe: /^\s*default\s*$/,
  29059. elseRe: /^\s*else\s*$/
  29060. });
  29061. Ext.define('Ext.util.XTemplateCompiler', {
  29062. extend: Ext.util.XTemplateParser,
  29063. useEval: Ext.isGecko,
  29064. useIndex: Ext.isIE8m,
  29065. useFormat: true,
  29066. propNameRe: /^[\w\d$]*$/,
  29067. compile: function(tpl) {
  29068. var me = this,
  29069. code = me.generate(tpl);
  29070. return me.useEval ? me.evalTpl(code) : (new Function('Ext', code))(Ext);
  29071. },
  29072. generate: function(tpl) {
  29073. var me = this,
  29074. definitions = 'var fm=Ext.util.Format,ts=Object.prototype.toString;',
  29075. code;
  29076. me.maxLevel = 0;
  29077. me.body = [
  29078. 'var c0=values, a0=' + me.createArrayTest(0) + ', p0=parent, n0=xcount, i0=xindex, k0, v;\n'
  29079. ];
  29080. if (me.definitions) {
  29081. if (typeof me.definitions === 'string') {
  29082. me.definitions = [
  29083. me.definitions,
  29084. definitions
  29085. ];
  29086. } else {
  29087. me.definitions.push(definitions);
  29088. }
  29089. } else {
  29090. me.definitions = [
  29091. definitions
  29092. ];
  29093. }
  29094. me.switches = [];
  29095. me.parse(tpl);
  29096. me.definitions.push((me.useEval ? '$=' : 'return') + ' function (' + me.fnArgs + ') {', me.body.join(''), '}');
  29097. code = me.definitions.join('\n');
  29098. me.definitions.length = me.body.length = me.switches.length = 0;
  29099. me.definitions = me.body = me.switches = 0;
  29100. return code;
  29101. },
  29102. doText: function(text) {
  29103. var me = this,
  29104. out = me.body;
  29105. text = text.replace(me.aposRe, "\\'").replace(me.newLineRe, '\\n');
  29106. if (me.useIndex) {
  29107. out.push('out[out.length]=\'', text, '\'\n');
  29108. } else {
  29109. out.push('out.push(\'', text, '\')\n');
  29110. }
  29111. },
  29112. doExpr: function(expr) {
  29113. var out = this.body;
  29114. out.push('if ((v=' + expr + ') != null) out');
  29115. if (this.useIndex) {
  29116. out.push('[out.length]=v\n');
  29117. } else {
  29118. out.push('.push(v)\n');
  29119. }
  29120. },
  29121. doTag: function(tag) {
  29122. var expr = this.parseTag(tag);
  29123. if (expr) {
  29124. this.doExpr(expr);
  29125. } else {
  29126. this.doText('{' + tag + '}');
  29127. }
  29128. },
  29129. doElse: function() {
  29130. this.body.push('} else {\n');
  29131. },
  29132. doEval: function(text) {
  29133. this.body.push(text, '\n');
  29134. },
  29135. doIf: function(action, actions) {
  29136. var me = this;
  29137. if (action === '.') {
  29138. me.body.push('if (values) {\n');
  29139. } else if (me.propNameRe.test(action)) {
  29140. me.body.push('if (', me.parseTag(action), ') {\n');
  29141. } else
  29142. {
  29143. me.body.push('if (', me.addFn(action), me.callFn, ') {\n');
  29144. }
  29145. if (actions.exec) {
  29146. me.doExec(actions.exec);
  29147. }
  29148. },
  29149. doElseIf: function(action, actions) {
  29150. var me = this;
  29151. if (action === '.') {
  29152. me.body.push('else if (values) {\n');
  29153. } else if (me.propNameRe.test(action)) {
  29154. me.body.push('} else if (', me.parseTag(action), ') {\n');
  29155. } else
  29156. {
  29157. me.body.push('} else if (', me.addFn(action), me.callFn, ') {\n');
  29158. }
  29159. if (actions.exec) {
  29160. me.doExec(actions.exec);
  29161. }
  29162. },
  29163. doSwitch: function(action) {
  29164. var me = this,
  29165. key;
  29166. if (action === '.' || action === '#') {
  29167. key = action === '.' ? 'values' : 'xindex';
  29168. me.body.push('switch (', key, ') {\n');
  29169. } else if (me.propNameRe.test(action)) {
  29170. me.body.push('switch (', me.parseTag(action), ') {\n');
  29171. } else
  29172. {
  29173. me.body.push('switch (', me.addFn(action), me.callFn, ') {\n');
  29174. }
  29175. me.switches.push(0);
  29176. },
  29177. doCase: function(action) {
  29178. var me = this,
  29179. cases = Ext.isArray(action) ? action : [
  29180. action
  29181. ],
  29182. n = me.switches.length - 1,
  29183. match, i;
  29184. if (me.switches[n]) {
  29185. me.body.push('break;\n');
  29186. } else {
  29187. me.switches[n]++;
  29188. }
  29189. for (i = 0 , n = cases.length; i < n; ++i) {
  29190. match = me.intRe.exec(cases[i]);
  29191. cases[i] = match ? match[1] : ("'" + cases[i].replace(me.aposRe, "\\'") + "'");
  29192. }
  29193. me.body.push('case ', cases.join(': case '), ':\n');
  29194. },
  29195. doDefault: function() {
  29196. var me = this,
  29197. n = me.switches.length - 1;
  29198. if (me.switches[n]) {
  29199. me.body.push('break;\n');
  29200. } else {
  29201. me.switches[n]++;
  29202. }
  29203. me.body.push('default:\n');
  29204. },
  29205. doEnd: function(type, actions) {
  29206. var me = this,
  29207. L = me.level - 1;
  29208. if (type === 'for' || type === 'foreach') {
  29209. if (actions.exec) {
  29210. me.doExec(actions.exec);
  29211. }
  29212. me.body.push('}\n');
  29213. me.body.push('parent=p', L, ';values=r', L + 1, ';xcount=n' + L + ';xindex=i', L, '+1;xkey=k', L, ';\n');
  29214. } else if (type === 'if' || type === 'switch') {
  29215. me.body.push('}\n');
  29216. }
  29217. },
  29218. doFor: function(action, actions) {
  29219. var me = this,
  29220. s,
  29221. L = me.level,
  29222. up = L - 1,
  29223. parentAssignment;
  29224. if (action === '.') {
  29225. s = 'values';
  29226. } else if (me.propNameRe.test(action)) {
  29227. s = me.parseTag(action);
  29228. } else
  29229. {
  29230. s = me.addFn(action) + me.callFn;
  29231. }
  29232. if (me.maxLevel < L) {
  29233. me.maxLevel = L;
  29234. me.body.push('var ');
  29235. }
  29236. if (action === '.') {
  29237. parentAssignment = 'c' + L;
  29238. } else {
  29239. parentAssignment = 'a' + up + '?c' + up + '[i' + up + ']:c' + up;
  29240. }
  29241. me.body.push('i', L, '=0,n', L, '=0,c', L, '=', s, ',a', L, '=', me.createArrayTest(L), ',r', L, '=values,p', L, ',k', L, ';\n', 'p', L, '=parent=', parentAssignment, '\n', 'if (c', L, '){if(a', L, '){n', L, '=c', L, '.length;}else if (c', L, '.isMixedCollection){c', L, '=c', L, '.items;n', L, '=c', L, '.length;}else if(c', L, '.isStore){c', L, '=c', L, '.data.items;n', L, '=c', L, '.length;}else{c', L, '=[c', L, '];n', L, '=1;}}\n', 'for (xcount=n', L, ';i', L, '<n' + L + ';++i', L, '){\n', 'values=c', L, '[i', L, ']');
  29242. if (actions.propName) {
  29243. me.body.push('.', actions.propName);
  29244. }
  29245. me.body.push('\n', 'xindex=i', L, '+1\n');
  29246. if (actions.between) {
  29247. me.body.push('if(xindex>1){ out.push("', actions.between, '"); } \n');
  29248. }
  29249. },
  29250. doForEach: function(action, actions) {
  29251. var me = this,
  29252. L = me.level,
  29253. up = L - 1,
  29254. s, parentAssignment;
  29255. if (action === '.') {
  29256. s = 'values';
  29257. } else if (me.propNameRe.test(action)) {
  29258. s = me.parseTag(action);
  29259. } else
  29260. {
  29261. s = me.addFn(action) + me.callFn;
  29262. }
  29263. if (me.maxLevel < L) {
  29264. me.maxLevel = L;
  29265. me.body.push('var ');
  29266. }
  29267. if (action === '.') {
  29268. parentAssignment = 'c' + L;
  29269. } else {
  29270. parentAssignment = 'a' + up + '?c' + up + '[i' + up + ']:c' + up;
  29271. }
  29272. me.body.push('i', L, '=-1,n', L, '=0,c', L, '=', s, ',a', L, '=', me.createArrayTest(L), ',r', L, '=values,p', L, ',k', L, ';\n', 'p', L, '=parent=', parentAssignment, '\n', 'for(k', L, ' in c', L, '){\n', 'xindex=++i', L, '+1;\n', 'xkey=k', L, ';\n', 'values=c', L, '[k', L, '];');
  29273. if (actions.propName) {
  29274. me.body.push('.', actions.propName);
  29275. }
  29276. if (actions.between) {
  29277. me.body.push('if(xindex>1){ out.push("', actions.between, '"); } \n');
  29278. }
  29279. },
  29280. createArrayTest: ('isArray' in Array) ? function(L) {
  29281. return 'Array.isArray(c' + L + ')';
  29282. } : function(L) {
  29283. return 'ts.call(c' + L + ')==="[object Array]"';
  29284. },
  29285. doExec: function(action, actions) {
  29286. var me = this,
  29287. name = 'f' + me.definitions.length,
  29288. guards = me.guards[me.strict ? 0 : 1];
  29289. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', guards.doTry, ' var $v = values; with($v) {', ' ' + action, ' }', guards.doCatch, '}');
  29290. me.body.push(name + me.callFn + '\n');
  29291. },
  29292. guards: [
  29293. {
  29294. doTry: '',
  29295. doCatch: ''
  29296. },
  29297. {
  29298. doTry: 'try { ',
  29299. doCatch: ' } catch(e) {\n' +
  29300. 'Ext.log.warn("XTemplate evaluation exception: " + e.message);\n' +
  29301. '}'
  29302. }
  29303. ],
  29304. addFn: function(body) {
  29305. var me = this,
  29306. name = 'f' + me.definitions.length,
  29307. guards = me.guards[me.strict ? 0 : 1];
  29308. if (body === '.') {
  29309. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', ' return values', '}');
  29310. } else if (body === '..') {
  29311. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', ' return parent', '}');
  29312. } else {
  29313. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', guards.doTry, ' var $v = values; with($v) {', ' return(' + body + ')', ' }', guards.doCatch, '}');
  29314. }
  29315. return name;
  29316. },
  29317. parseTag: function(tag) {
  29318. var me = this,
  29319. m = me.tagRe.exec(tag),
  29320. name, format, args, math, v;
  29321. if (!m) {
  29322. return null;
  29323. }
  29324. name = m[1];
  29325. format = m[2];
  29326. args = m[3];
  29327. math = m[4];
  29328. if (name === '.') {
  29329. if (!me.validTypes) {
  29330. me.definitions.push('var validTypes={string:1,number:1,boolean:1};');
  29331. me.validTypes = true;
  29332. }
  29333. v = 'validTypes[typeof values] || ts.call(values) === "[object Date]" ? values : ""';
  29334. }
  29335. else if (name === '#') {
  29336. v = 'xindex';
  29337. }
  29338. else if (name === '$') {
  29339. v = 'xkey';
  29340. } else if (name.substr(0, 7) === "parent.") {
  29341. v = name;
  29342. }
  29343. else if (isNaN(name) && name.indexOf('-') === -1 && name.indexOf('.') !== -1) {
  29344. v = "values." + name;
  29345. } else
  29346. {
  29347. v = "values['" + name + "']";
  29348. }
  29349. if (math) {
  29350. v = '(' + v + math + ')';
  29351. }
  29352. if (format && me.useFormat) {
  29353. args = args ? ',' + args : "";
  29354. if (format.substr(0, 5) !== "this.") {
  29355. format = "fm." + format + '(';
  29356. } else {
  29357. format += '(';
  29358. }
  29359. } else {
  29360. return v;
  29361. }
  29362. return format + v + args + ')';
  29363. },
  29364. evalTpl: function($) {
  29365. eval($);
  29366. return $;
  29367. },
  29368. newLineRe: /\r\n|\r|\n/g,
  29369. aposRe: /[']/g,
  29370. intRe: /^\s*(\d+)\s*$/,
  29371. tagRe: /^([\w-\.\#\$]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\s?[\+\-\*\/]\s?[\d\.\+\-\*\/\(\)]+)?$/
  29372. }, function() {
  29373. var proto = this.prototype;
  29374. proto.fnArgs = 'out,values,parent,xindex,xcount,xkey';
  29375. proto.callFn = '.call(this,' + proto.fnArgs + ')';
  29376. });
  29377. Ext.define('Ext.XTemplate', {
  29378. extend: Ext.Template,
  29379. isXTemplate: true,
  29380. emptyObj: {},
  29381. fn: null,
  29382. strict: false,
  29383. apply: function(values, parent, xindex, xcount) {
  29384. var buffer = this.applyOut(values, [], parent, xindex, xcount);
  29385. return buffer.length === 1 ? buffer[0] : buffer.join('');
  29386. },
  29387. applyOut: function(values, out, parent, xindex, xcount) {
  29388. var me = this,
  29389. compiler;
  29390. if (!me.fn) {
  29391. compiler = new Ext.util.XTemplateCompiler({
  29392. useFormat: me.disableFormats !== true,
  29393. definitions: me.definitions,
  29394. strict: me.strict
  29395. });
  29396. me.fn = compiler.compile(me.html);
  29397. }
  29398. xindex = xindex || 1;
  29399. xcount = xcount || 1;
  29400. if (me.strict) {
  29401. me.fn(out, values, parent || me.emptyObj, xindex, xcount);
  29402. } else {
  29403. try {
  29404. me.fn(out, values, parent || me.emptyObj, xindex, xcount);
  29405. } catch (e) {
  29406. Ext.log.warn('XTemplate evaluation exception: ' + e.message);
  29407. }
  29408. }
  29409. return out;
  29410. },
  29411. compile: function() {
  29412. return this;
  29413. },
  29414. statics: {
  29415. get: function(config, source, defaultTpl) {
  29416. var ret = config;
  29417. if (config == null) {
  29418. if (source && defaultTpl) {
  29419. ret = this.getTpl(source, defaultTpl);
  29420. }
  29421. } else if ((config || config === '') && !config.isTemplate) {
  29422. ret = new this(config);
  29423. }
  29424. return ret;
  29425. },
  29426. getTpl: function(instance, name) {
  29427. var tpl = instance[name],
  29428. owner;
  29429. if (tpl) {
  29430. if (!tpl.isTemplate) {
  29431. tpl = Ext.XTemplate.get(tpl);
  29432. }
  29433. if (!tpl.owner) {
  29434. if (instance.hasOwnProperty(name)) {
  29435. owner = instance;
  29436. } else {
  29437. for (owner = instance.self.prototype; owner && !owner.hasOwnProperty(name); owner = owner.superclass) {}
  29438. }
  29439. owner[name] = tpl;
  29440. tpl.owner = owner;
  29441. }
  29442. }
  29443. return tpl || null;
  29444. }
  29445. }
  29446. });
  29447. Ext.define('Ext.util.translatable.Dom', {
  29448. extend: Ext.util.translatable.Abstract,
  29449. alias: 'translatable.dom',
  29450. config: {
  29451. element: null
  29452. },
  29453. applyElement: function(element) {
  29454. if (!element) {
  29455. return;
  29456. }
  29457. return Ext.get(element);
  29458. },
  29459. updateElement: function() {
  29460. this.refresh();
  29461. },
  29462. translateXY: function(x, y) {
  29463. var element = this.getElement();
  29464. if (element && !element.destroyed) {
  29465. this.callParent([
  29466. x,
  29467. y
  29468. ]);
  29469. }
  29470. }
  29471. });
  29472. Ext.define('Ext.util.translatable.CssPosition', {
  29473. extend: Ext.util.translatable.Dom,
  29474. alias: 'translatable.cssposition',
  29475. doTranslate: function(x, y) {
  29476. var domStyle = this.getElement().dom.style;
  29477. if (typeof x === 'number') {
  29478. domStyle.left = x + 'px';
  29479. }
  29480. if (typeof y === 'number') {
  29481. domStyle.top = y + 'px';
  29482. }
  29483. },
  29484. syncPosition: function() {
  29485. var domStyle = this.getElement().dom.style;
  29486. return [
  29487. this.x = parseFloat(domStyle.left),
  29488. this.y = parseFloat(domStyle.top)
  29489. ];
  29490. },
  29491. destroy: function() {
  29492. var domStyle = this.getElement().dom.style;
  29493. domStyle.left = null;
  29494. domStyle.top = null;
  29495. this.callParent();
  29496. }
  29497. });
  29498. Ext.define('Ext.util.translatable.CssTransform', {
  29499. extend: Ext.util.translatable.Dom,
  29500. alias: 'translatable.csstransform',
  29501. isCssTransform: true,
  29502. posRegex: /(\d+)px[^\d]*(\d+)px/,
  29503. doTranslate: function(x, y) {
  29504. this.getElement().translate(x, y);
  29505. },
  29506. syncPosition: function() {
  29507. var pos = this.posRegex.exec(this.getElement().dom.style.tranform);
  29508. if (pos) {
  29509. this.x = parseFloat(pos[1]);
  29510. this.y = parseFloat(pos[2]);
  29511. }
  29512. return [
  29513. this.x,
  29514. this.y
  29515. ];
  29516. },
  29517. destroy: function() {
  29518. var element = this.getElement();
  29519. if (element && !element.destroyed) {
  29520. element.dom.style.webkitTransform = null;
  29521. }
  29522. this.callParent();
  29523. }
  29524. });
  29525. Ext.define('Ext.mixin.Responsive', function(Responsive) {
  29526. return {
  29527. extend: Ext.Mixin,
  29528. mixinConfig: {
  29529. id: 'responsive',
  29530. after: {
  29531. destroy: 'destroy'
  29532. }
  29533. },
  29534. config: {
  29535. responsiveConfig: {
  29536. $value: undefined,
  29537. merge: function(newValue, oldValue, target, mixinClass) {
  29538. var marker, entry, ret, rule;
  29539. if (!newValue) {
  29540. return oldValue;
  29541. }
  29542. ret = oldValue ? Ext.Object.chain(oldValue) : {};
  29543. marker = Responsive.context;
  29544. for (rule in newValue) {
  29545. if (!mixinClass || !(rule in ret)) {
  29546. entry = newValue[rule];
  29547. if (entry.fn !== marker) {
  29548. entry = {
  29549. fn: marker,
  29550. config: entry
  29551. };
  29552. }
  29553. ret[rule] = entry;
  29554. }
  29555. }
  29556. return ret;
  29557. }
  29558. },
  29559. responsiveFormulas: {
  29560. $value: null,
  29561. merge: function(newValue, oldValue, target, mixinClass) {
  29562. return this.mergeNew(newValue, oldValue, target, mixinClass);
  29563. }
  29564. }
  29565. },
  29566. destroy: function() {
  29567. Responsive.unregister(this);
  29568. },
  29569. privates: {
  29570. statics: {
  29571. active: false,
  29572. all: {},
  29573. _configNames: [
  29574. 'responsiveConfig',
  29575. 'responsiveFormulas'
  29576. ],
  29577. context: Ext.Object.chain(Ext.platformTags),
  29578. count: 0,
  29579. nextId: 0,
  29580. activate: function() {
  29581. Responsive.active = true;
  29582. Responsive.updateContext();
  29583. Ext.on('resize', Responsive.onResize, Responsive);
  29584. },
  29585. deactivate: function() {
  29586. Responsive.active = false;
  29587. Ext.un('resize', Responsive.onResize, Responsive);
  29588. },
  29589. notify: function() {
  29590. var all = Responsive.all,
  29591. context = Responsive.context,
  29592. timer = Responsive.timer,
  29593. id;
  29594. if (timer) {
  29595. Responsive.timer = Ext.unasap(timer);
  29596. }
  29597. Responsive.updateContext();
  29598. Ext.suspendLayouts();
  29599. Ext.fireEvent('beforeresponsiveupdate', context);
  29600. for (id in all) {
  29601. all[id].setupResponsiveContext();
  29602. }
  29603. Ext.fireEvent('beginresponsiveupdate', context);
  29604. for (id in all) {
  29605. all[id].updateResponsiveState();
  29606. }
  29607. Ext.fireEvent('responsiveupdate', context);
  29608. Ext.resumeLayouts(true);
  29609. },
  29610. onResize: function() {
  29611. if (!Responsive.timer) {
  29612. Responsive.timer = Ext.asap(Responsive.onTimer);
  29613. }
  29614. },
  29615. onTimer: function() {
  29616. Responsive.timer = null;
  29617. Responsive.notify();
  29618. },
  29619. register: function(responder) {
  29620. var id = responder.$responsiveId;
  29621. if (!id) {
  29622. responder.$responsiveId = id = ++Responsive.nextId;
  29623. Responsive.all[id] = responder;
  29624. if (++Responsive.count === 1) {
  29625. Responsive.activate();
  29626. }
  29627. }
  29628. },
  29629. unregister: function(responder) {
  29630. var id = responder.$responsiveId;
  29631. if (id in Responsive.all) {
  29632. responder.$responsiveId = null;
  29633. delete Responsive.all[id];
  29634. if (--Responsive.count === 0) {
  29635. Responsive.deactivate();
  29636. }
  29637. }
  29638. },
  29639. updateContext: function() {
  29640. var El = Ext.Element,
  29641. width = El.getViewportWidth(),
  29642. height = El.getViewportHeight(),
  29643. context = Responsive.context;
  29644. context.width = width;
  29645. context.height = height;
  29646. context.tall = width < height;
  29647. context.wide = !context.tall;
  29648. context.landscape = context.portrait = false;
  29649. if (!context.platform) {
  29650. context.platform = Ext.platformTags;
  29651. }
  29652. context[Ext.dom.Element.getOrientation()] = true;
  29653. }
  29654. },
  29655. afterClassMixedIn: function(targetClass) {
  29656. var proto = targetClass.prototype,
  29657. responsiveConfig = proto.responsiveConfig,
  29658. responsiveFormulas = proto.responsiveFormulas,
  29659. config;
  29660. if (responsiveConfig || responsiveFormulas) {
  29661. config = {};
  29662. if (responsiveConfig) {
  29663. delete proto.responsiveConfig;
  29664. config.responsiveConfig = responsiveConfig;
  29665. }
  29666. if (responsiveFormulas) {
  29667. delete proto.responsiveFormulas;
  29668. config.responsiveFormulas = responsiveFormulas;
  29669. }
  29670. targetClass.getConfigurator().add(config);
  29671. }
  29672. targetClass.addConfigTransform('transformResponsiveConfig', 10);
  29673. },
  29674. applyResponsiveConfig: function(rules) {
  29675. var rule;
  29676. for (rule in rules) {
  29677. rules[rule].fn = Ext.createRuleFn(rule);
  29678. }
  29679. return rules;
  29680. },
  29681. applyResponsiveFormulas: function(formulas) {
  29682. var fn, name, ret;
  29683. if (formulas) {
  29684. ret = {};
  29685. for (name in formulas) {
  29686. if (Ext.isString(fn = formulas[name])) {
  29687. fn = Ext.createRuleFn(fn);
  29688. }
  29689. ret[name] = fn;
  29690. }
  29691. }
  29692. return ret;
  29693. },
  29694. getResponsiveState: function() {
  29695. var context = Responsive.context,
  29696. rules = this.getResponsiveConfig(),
  29697. entry, ret, rule;
  29698. if (rules) {
  29699. ret = {};
  29700. for (rule in rules) {
  29701. entry = rules[rule];
  29702. if (entry.fn.call(this, context)) {
  29703. Ext.merge(ret, entry.config);
  29704. }
  29705. }
  29706. }
  29707. return ret;
  29708. },
  29709. setupResponsiveContext: function() {
  29710. var formulas = this.getResponsiveFormulas(),
  29711. context = Responsive.context,
  29712. name;
  29713. if (formulas) {
  29714. for (name in formulas) {
  29715. context[name] = formulas[name].call(this, context);
  29716. }
  29717. }
  29718. },
  29719. transformResponsiveConfig: function(instanceConfig, configurator) {
  29720. var me = this,
  29721. ret = instanceConfig,
  29722. state;
  29723. if (configurator.hoistConfigs(me, instanceConfig, Responsive._configNames)) {
  29724. Responsive.register(me);
  29725. me.setupResponsiveContext();
  29726. state = me.getResponsiveState();
  29727. if (state) {
  29728. ret = Ext.merge({}, instanceConfig, state);
  29729. delete ret.responsiveConfig;
  29730. delete ret.responsiveFormulas;
  29731. }
  29732. }
  29733. return ret;
  29734. },
  29735. updateResponsiveState: function() {
  29736. var config = this.getResponsiveState();
  29737. this.setConfig(config);
  29738. }
  29739. }
  29740. };
  29741. });
  29742. Ext.define('Ext.ProgressBase', {
  29743. mixinId: 'progressbase',
  29744. config: {
  29745. value: 0,
  29746. textTpl: null
  29747. },
  29748. applyTextTpl: function(textTpl) {
  29749. if (!textTpl.isTemplate) {
  29750. textTpl = new Ext.XTemplate(textTpl);
  29751. }
  29752. return textTpl;
  29753. },
  29754. applyValue: function(value) {
  29755. return value || 0;
  29756. }
  29757. });
  29758. Ext.define('Ext.Progress', {
  29759. extend: Ext.Gadget,
  29760. xtype: [
  29761. 'progress',
  29762. 'progressbarwidget'
  29763. ],
  29764. alternateClassName: 'Ext.ProgressBarWidget',
  29765. mixins: [
  29766. Ext.ProgressBase
  29767. ],
  29768. config: {
  29769. text: null,
  29770. animate: false
  29771. },
  29772. cachedConfig: {
  29773. textCls: Ext.baseCSSPrefix + 'progress-text',
  29774. cls: null
  29775. },
  29776. baseCls: Ext.baseCSSPrefix + 'progress',
  29777. template: [
  29778. {
  29779. reference: 'backgroundEl'
  29780. },
  29781. {
  29782. reference: 'barEl',
  29783. cls: Ext.baseCSSPrefix + 'progress-bar',
  29784. children: [
  29785. {
  29786. reference: 'textEl'
  29787. }
  29788. ]
  29789. }
  29790. ],
  29791. defaultBindProperty: 'value',
  29792. updateCls: function(cls, oldCls) {
  29793. var el = this.element;
  29794. if (oldCls) {
  29795. el.removeCls(oldCls);
  29796. }
  29797. if (cls) {
  29798. el.addCls(cls);
  29799. }
  29800. },
  29801. updateUi: function(ui, oldUi) {
  29802. var element = this.element,
  29803. barEl = this.barEl,
  29804. baseCls = this.baseCls + '-';
  29805. this.callParent([
  29806. ui,
  29807. oldUi
  29808. ]);
  29809. if (oldUi) {
  29810. element.removeCls(baseCls + oldUi);
  29811. barEl.removeCls(baseCls + 'bar-' + oldUi);
  29812. }
  29813. element.addCls(baseCls + ui);
  29814. barEl.addCls(baseCls + 'bar-' + ui);
  29815. },
  29816. updateTextCls: function(textCls) {
  29817. this.backgroundEl.addCls(textCls + ' ' + textCls + '-back');
  29818. this.textEl.addCls(textCls);
  29819. },
  29820. updateValue: function(value, oldValue) {
  29821. var me = this,
  29822. textTpl = me.getTextTpl();
  29823. if (textTpl) {
  29824. me.setText(textTpl.apply({
  29825. value: value,
  29826. percent: Math.round(value * 100)
  29827. }));
  29828. }
  29829. if (!me.isConfiguring && me.getAnimate()) {
  29830. me.stopBarAnimation();
  29831. me.startBarAnimation(Ext.apply({
  29832. from: {
  29833. width: (oldValue * 100) + '%'
  29834. },
  29835. to: {
  29836. width: (value * 100) + '%'
  29837. }
  29838. }, me.animate));
  29839. } else {
  29840. me.barEl.setStyle('width', (value * 100) + '%');
  29841. }
  29842. },
  29843. updateText: function(text) {
  29844. this.backgroundEl.setHtml(text);
  29845. this.textEl.setHtml(text);
  29846. },
  29847. doDestroy: function() {
  29848. this.stopBarAnimation();
  29849. this.callParent();
  29850. },
  29851. privates: {
  29852. startBarAnimation: Ext.privateFn,
  29853. stopBarAnimation: Ext.privateFn
  29854. }
  29855. });
  29856. Ext.define('Ext.fx.State', {
  29857. isAnimatable: {
  29858. 'background-color': true,
  29859. 'background-image': true,
  29860. 'background-position': true,
  29861. 'border-bottom-color': true,
  29862. 'border-bottom-width': true,
  29863. 'border-color': true,
  29864. 'border-left-color': true,
  29865. 'border-left-width': true,
  29866. 'border-right-color': true,
  29867. 'border-right-width': true,
  29868. 'border-spacing': true,
  29869. 'border-top-color': true,
  29870. 'border-top-width': true,
  29871. 'border-width': true,
  29872. 'bottom': true,
  29873. 'color': true,
  29874. 'crop': true,
  29875. 'font-size': true,
  29876. 'font-weight': true,
  29877. 'height': true,
  29878. 'left': true,
  29879. 'letter-spacing': true,
  29880. 'line-height': true,
  29881. 'margin-bottom': true,
  29882. 'margin-left': true,
  29883. 'margin-right': true,
  29884. 'margin-top': true,
  29885. 'max-height': true,
  29886. 'max-width': true,
  29887. 'min-height': true,
  29888. 'min-width': true,
  29889. 'opacity': true,
  29890. 'outline-color': true,
  29891. 'outline-offset': true,
  29892. 'outline-width': true,
  29893. 'padding-bottom': true,
  29894. 'padding-left': true,
  29895. 'padding-right': true,
  29896. 'padding-top': true,
  29897. 'right': true,
  29898. 'text-indent': true,
  29899. 'text-shadow': true,
  29900. 'top': true,
  29901. 'vertical-align': true,
  29902. 'visibility': true,
  29903. 'width': true,
  29904. 'word-spacing': true,
  29905. 'z-index': true,
  29906. 'zoom': true,
  29907. 'transform': true
  29908. },
  29909. constructor: function(data) {
  29910. this.data = {};
  29911. this.set(data);
  29912. },
  29913. setConfig: function(data) {
  29914. this.set(data);
  29915. return this;
  29916. },
  29917. setRaw: function(data) {
  29918. this.data = data;
  29919. return this;
  29920. },
  29921. clear: function() {
  29922. return this.setRaw({});
  29923. },
  29924. setTransform: function(name, value) {
  29925. var data = this.data,
  29926. isArray = Ext.isArray(value),
  29927. transform = data.transform,
  29928. ln, key;
  29929. if (!transform) {
  29930. transform = data.transform = {
  29931. translateX: 0,
  29932. translateY: 0,
  29933. translateZ: 0,
  29934. scaleX: 1,
  29935. scaleY: 1,
  29936. scaleZ: 1,
  29937. rotate: 0,
  29938. rotateX: 0,
  29939. rotateY: 0,
  29940. rotateZ: 0,
  29941. skewX: 0,
  29942. skewY: 0
  29943. };
  29944. }
  29945. if (typeof name === 'string') {
  29946. switch (name) {
  29947. case 'translate':
  29948. if (isArray) {
  29949. ln = value.length;
  29950. if (ln === 0) {
  29951. break;
  29952. }
  29953. transform.translateX = value[0];
  29954. if (ln === 1) {
  29955. break;
  29956. }
  29957. transform.translateY = value[1];
  29958. if (ln === 2) {
  29959. break;
  29960. }
  29961. transform.translateZ = value[2];
  29962. } else {
  29963. transform.translateX = value;
  29964. };
  29965. break;
  29966. case 'rotate':
  29967. if (isArray) {
  29968. ln = value.length;
  29969. if (ln === 0) {
  29970. break;
  29971. }
  29972. transform.rotateX = value[0];
  29973. if (ln === 1) {
  29974. break;
  29975. }
  29976. transform.rotateY = value[1];
  29977. if (ln === 2) {
  29978. break;
  29979. }
  29980. transform.rotateZ = value[2];
  29981. } else {
  29982. transform.rotate = value;
  29983. };
  29984. break;
  29985. case 'scale':
  29986. if (isArray) {
  29987. ln = value.length;
  29988. if (ln === 0) {
  29989. break;
  29990. }
  29991. transform.scaleX = value[0];
  29992. if (ln === 1) {
  29993. break;
  29994. }
  29995. transform.scaleY = value[1];
  29996. if (ln === 2) {
  29997. break;
  29998. }
  29999. transform.scaleZ = value[2];
  30000. } else {
  30001. transform.scaleX = value;
  30002. transform.scaleY = value;
  30003. };
  30004. break;
  30005. case 'skew':
  30006. if (isArray) {
  30007. ln = value.length;
  30008. if (ln === 0) {
  30009. break;
  30010. }
  30011. transform.skewX = value[0];
  30012. if (ln === 1) {
  30013. break;
  30014. }
  30015. transform.skewY = value[1];
  30016. } else {
  30017. transform.skewX = value;
  30018. };
  30019. break;
  30020. default:
  30021. transform[name] = value;
  30022. }
  30023. } else {
  30024. for (key in name) {
  30025. if (name.hasOwnProperty(key)) {
  30026. value = name[key];
  30027. this.setTransform(key, value);
  30028. }
  30029. }
  30030. }
  30031. },
  30032. set: function(name, value) {
  30033. var data = this.data,
  30034. key;
  30035. if (typeof name !== 'string') {
  30036. for (key in name) {
  30037. value = name[key];
  30038. if (key === 'transform') {
  30039. this.setTransform(value);
  30040. } else {
  30041. data[key] = value;
  30042. }
  30043. }
  30044. } else {
  30045. if (name === 'transform') {
  30046. this.setTransform(value);
  30047. } else {
  30048. data[name] = value;
  30049. }
  30050. }
  30051. return this;
  30052. },
  30053. unset: function(name) {
  30054. var data = this.data;
  30055. if (data.hasOwnProperty(name)) {
  30056. delete data[name];
  30057. }
  30058. return this;
  30059. },
  30060. getData: function() {
  30061. return this.data;
  30062. }
  30063. });
  30064. Ext.define('Ext.fx.animation.Abstract', {
  30065. extend: Ext.Evented,
  30066. mixins: [
  30067. Ext.mixin.Factoryable
  30068. ],
  30069. factoryConfig: {
  30070. type: 'animation'
  30071. },
  30072. isAnimation: true,
  30073. config: {
  30074. name: '',
  30075. element: null,
  30076. before: null,
  30077. from: {},
  30078. to: {},
  30079. after: null,
  30080. states: {},
  30081. duration: 300,
  30082. easing: 'linear',
  30083. iteration: 1,
  30084. direction: 'normal',
  30085. delay: 0,
  30086. onBeforeStart: null,
  30087. callback: null,
  30088. onEnd: null,
  30089. onBeforeEnd: null,
  30090. scope: null,
  30091. reverse: null,
  30092. preserveEndState: false,
  30093. replacePrevious: true
  30094. },
  30095. STATE_FROM: '0%',
  30096. STATE_TO: '100%',
  30097. DIRECTION_UP: 'up',
  30098. DIRECTION_TOP: 'top',
  30099. DIRECTION_DOWN: 'down',
  30100. DIRECTION_BOTTOM: 'bottom',
  30101. DIRECTION_LEFT: 'left',
  30102. DIRECTION_RIGHT: 'right',
  30103. stateNameRegex: /^(?:[\d.]+)%$/,
  30104. constructor: function() {
  30105. this.states = {};
  30106. this.callParent(arguments);
  30107. return this;
  30108. },
  30109. applyElement: function(element) {
  30110. return Ext.get(element);
  30111. },
  30112. applyBefore: function(before, current) {
  30113. if (before) {
  30114. return Ext.factory(before, Ext.fx.State, current);
  30115. }
  30116. },
  30117. applyAfter: function(after, current) {
  30118. if (after) {
  30119. return Ext.factory(after, Ext.fx.State, current);
  30120. }
  30121. },
  30122. setFrom: function(from) {
  30123. return this.setState(this.STATE_FROM, from);
  30124. },
  30125. setTo: function(to) {
  30126. return this.setState(this.STATE_TO, to);
  30127. },
  30128. getFrom: function() {
  30129. return this.getState(this.STATE_FROM);
  30130. },
  30131. getTo: function() {
  30132. return this.getState(this.STATE_TO);
  30133. },
  30134. setStates: function(states) {
  30135. var validNameRegex = this.stateNameRegex,
  30136. name;
  30137. for (name in states) {
  30138. if (validNameRegex.test(name)) {
  30139. this.setState(name, states[name]);
  30140. }
  30141. }
  30142. return this;
  30143. },
  30144. getStates: function() {
  30145. return this.states;
  30146. },
  30147. updateCallback: function(callback) {
  30148. if (callback) {
  30149. this.setOnEnd(callback);
  30150. }
  30151. },
  30152. end: function() {
  30153. this.stop();
  30154. },
  30155. stop: function() {
  30156. this.fireEvent('stop', this);
  30157. },
  30158. destroy: function() {
  30159. this.destroying = true;
  30160. this.stop();
  30161. this.callParent();
  30162. this.destroying = false;
  30163. this.destroyed = true;
  30164. },
  30165. setState: function(name, state) {
  30166. var states = this.getStates(),
  30167. stateInstance;
  30168. stateInstance = Ext.factory(state, Ext.fx.State, states[name]);
  30169. if (stateInstance) {
  30170. states[name] = stateInstance;
  30171. }
  30172. else if (name === this.STATE_TO) {
  30173. Ext.Logger.error("Setting and invalid '100%' / 'to' state of: " + state);
  30174. }
  30175. return this;
  30176. },
  30177. getState: function(name) {
  30178. return this.getStates()[name];
  30179. },
  30180. getData: function() {
  30181. var me = this,
  30182. states = me.getStates(),
  30183. statesData = {},
  30184. before = me.getBefore(),
  30185. after = me.getAfter(),
  30186. from = states[me.STATE_FROM],
  30187. to = states[me.STATE_TO],
  30188. fromData = from.getData(),
  30189. toData = to.getData(),
  30190. data, name, state;
  30191. for (name in states) {
  30192. if (states.hasOwnProperty(name)) {
  30193. state = states[name];
  30194. data = state.getData();
  30195. statesData[name] = data;
  30196. }
  30197. }
  30198. return {
  30199. before: before ? before.getData() : {},
  30200. after: after ? after.getData() : {},
  30201. states: statesData,
  30202. from: fromData,
  30203. to: toData,
  30204. duration: me.getDuration(),
  30205. iteration: me.getIteration(),
  30206. direction: me.getDirection(),
  30207. easing: me.getEasing(),
  30208. delay: me.getDelay(),
  30209. onEnd: me.getOnEnd(),
  30210. onBeforeEnd: me.getOnBeforeEnd(),
  30211. onBeforeStart: me.getOnBeforeStart(),
  30212. scope: me.getScope(),
  30213. preserveEndState: me.getPreserveEndState(),
  30214. replacePrevious: me.getReplacePrevious()
  30215. };
  30216. }
  30217. });
  30218. Ext.define('Ext.fx.animation.Slide', {
  30219. extend: Ext.fx.animation.Abstract,
  30220. alternateClassName: 'Ext.fx.animation.SlideIn',
  30221. alias: [
  30222. 'animation.slide',
  30223. 'animation.slideIn'
  30224. ],
  30225. config: {
  30226. direction: 'left',
  30227. out: false,
  30228. offset: 0,
  30229. easing: 'auto',
  30230. containerBox: 'auto',
  30231. elementBox: 'auto',
  30232. isElementBoxFit: true,
  30233. useCssTransform: true
  30234. },
  30235. reverseDirectionMap: {
  30236. up: 'down',
  30237. top: 'down',
  30238. down: 'up',
  30239. bottom: 'up',
  30240. left: 'right',
  30241. right: 'left'
  30242. },
  30243. applyEasing: function(easing) {
  30244. if (easing === 'auto') {
  30245. return 'ease-' + ((this.getOut()) ? 'in' : 'out');
  30246. }
  30247. return easing;
  30248. },
  30249. getContainerBox: function() {
  30250. var box = this._containerBox;
  30251. if (box === 'auto') {
  30252. box = this.getElement().getParent().getBox();
  30253. }
  30254. return box;
  30255. },
  30256. getElementBox: function() {
  30257. var box = this._elementBox;
  30258. if (this.getIsElementBoxFit()) {
  30259. return this.getContainerBox();
  30260. }
  30261. if (box === 'auto') {
  30262. box = this.getElement().getBox();
  30263. }
  30264. return box;
  30265. },
  30266. getData: function() {
  30267. var elementBox = this.getElementBox(),
  30268. containerBox = this.getContainerBox(),
  30269. box = elementBox ? elementBox : containerBox,
  30270. from = this.getFrom(),
  30271. to = this.getTo(),
  30272. out = this.getOut(),
  30273. offset = this.getOffset(),
  30274. direction = this.getDirection(),
  30275. useCssTransform = this.getUseCssTransform(),
  30276. reverse = this.getReverse(),
  30277. translateX = 0,
  30278. translateY = 0,
  30279. offsetPct, fromX, fromY, toX, toY;
  30280. if (typeof offset === 'string') {
  30281. offsetPct = true;
  30282. offset = parseFloat(offset);
  30283. }
  30284. if (reverse) {
  30285. direction = this.reverseDirectionMap[direction];
  30286. }
  30287. switch (direction) {
  30288. case this.DIRECTION_UP:
  30289. case this.DIRECTION_TOP:
  30290. if (offsetPct) {
  30291. offset = box.height * offset / 100;
  30292. };
  30293. if (out) {
  30294. translateY = containerBox.top - box.top - box.height - offset;
  30295. } else {
  30296. translateY = containerBox.bottom - box.bottom + box.height + offset;
  30297. };
  30298. break;
  30299. case this.DIRECTION_DOWN:
  30300. case this.DIRECTION_BOTTOM:
  30301. if (offsetPct) {
  30302. offset = box.height * offset / 100;
  30303. };
  30304. if (out) {
  30305. translateY = containerBox.bottom - box.bottom + box.height + offset;
  30306. } else {
  30307. translateY = containerBox.top - box.height - box.top - offset;
  30308. };
  30309. break;
  30310. case this.DIRECTION_RIGHT:
  30311. if (offsetPct) {
  30312. offset = box.width * offset / 100;
  30313. };
  30314. if (out) {
  30315. translateX = containerBox.right - box.right + box.width + offset;
  30316. } else {
  30317. translateX = containerBox.left - box.left - box.width - offset;
  30318. };
  30319. break;
  30320. case this.DIRECTION_LEFT:
  30321. if (offsetPct) {
  30322. offset = box.width * offset / 100;
  30323. };
  30324. if (out) {
  30325. translateX = containerBox.left - box.left - box.width - offset;
  30326. } else {
  30327. translateX = containerBox.right - box.right + box.width + offset;
  30328. };
  30329. break;
  30330. }
  30331. fromX = (out) ? 0 : translateX;
  30332. fromY = (out) ? 0 : translateY;
  30333. if (useCssTransform) {
  30334. from.setTransform({
  30335. translateX: fromX,
  30336. translateY: fromY
  30337. });
  30338. } else {
  30339. from.set('left', fromX);
  30340. from.set('top', fromY);
  30341. }
  30342. toX = (out) ? translateX : 0;
  30343. toY = (out) ? translateY : 0;
  30344. if (useCssTransform) {
  30345. to.setTransform({
  30346. translateX: toX,
  30347. translateY: toY
  30348. });
  30349. } else {
  30350. to.set('left', toX);
  30351. to.set('top', toY);
  30352. }
  30353. return this.callParent(arguments);
  30354. }
  30355. });
  30356. Ext.define('Ext.fx.animation.SlideOut', {
  30357. extend: Ext.fx.animation.Slide,
  30358. alias: [
  30359. 'animation.slideOut'
  30360. ],
  30361. config: {
  30362. out: true
  30363. }
  30364. });
  30365. Ext.define('Ext.fx.animation.Fade', {
  30366. extend: Ext.fx.animation.Abstract,
  30367. alternateClassName: 'Ext.fx.animation.FadeIn',
  30368. alias: [
  30369. 'animation.fade',
  30370. 'animation.fadeIn'
  30371. ],
  30372. config: {
  30373. out: false,
  30374. before: {
  30375. display: null,
  30376. opacity: 0
  30377. },
  30378. after: {
  30379. opacity: null
  30380. },
  30381. reverse: null
  30382. },
  30383. updateOut: function(newOut) {
  30384. var to = this.getTo(),
  30385. from = this.getFrom();
  30386. if (newOut) {
  30387. from.set('opacity', 1);
  30388. to.set('opacity', 0);
  30389. } else {
  30390. from.set('opacity', 0);
  30391. to.set('opacity', 1);
  30392. }
  30393. }
  30394. });
  30395. Ext.define('Ext.fx.animation.FadeOut', {
  30396. extend: Ext.fx.animation.Fade,
  30397. alias: 'animation.fadeOut',
  30398. config: {
  30399. out: true,
  30400. before: {}
  30401. }
  30402. });
  30403. Ext.define('Ext.fx.animation.Flip', {
  30404. extend: Ext.fx.animation.Abstract,
  30405. alias: 'animation.flip',
  30406. config: {
  30407. easing: 'ease-in',
  30408. direction: 'right',
  30409. half: false,
  30410. out: null
  30411. },
  30412. getData: function() {
  30413. var me = this,
  30414. from = me.getFrom(),
  30415. to = me.getTo(),
  30416. direction = me.getDirection(),
  30417. out = me.getOut(),
  30418. half = me.getHalf(),
  30419. rotate = half ? 90 : 180,
  30420. fromScale = 1,
  30421. toScale = 1,
  30422. fromRotateX = 0,
  30423. fromRotateY = 0,
  30424. toRotateX = 0,
  30425. toRotateY = 0;
  30426. if (out) {
  30427. toScale = 0.8;
  30428. } else {
  30429. fromScale = 0.8;
  30430. }
  30431. switch (direction) {
  30432. case this.DIRECTION_UP:
  30433. case this.DIRECTION_TOP:
  30434. if (out) {
  30435. toRotateX = rotate;
  30436. } else {
  30437. fromRotateX = -rotate;
  30438. };
  30439. break;
  30440. case this.DIRECTION_DOWN:
  30441. case this.DIRECTION_BOTTOM:
  30442. if (out) {
  30443. toRotateX = -rotate;
  30444. } else {
  30445. fromRotateX = rotate;
  30446. };
  30447. break;
  30448. case this.DIRECTION_RIGHT:
  30449. if (out) {
  30450. toRotateY = rotate;
  30451. } else {
  30452. fromRotateY = -rotate;
  30453. };
  30454. break;
  30455. case this.DIRECTION_LEFT:
  30456. if (out) {
  30457. toRotateY = -rotate;
  30458. } else {
  30459. fromRotateY = rotate;
  30460. };
  30461. break;
  30462. }
  30463. from.setTransform({
  30464. rotateX: fromRotateX,
  30465. rotateY: fromRotateY,
  30466. scale: fromScale
  30467. });
  30468. to.setTransform({
  30469. rotateX: toRotateX,
  30470. rotateY: toRotateY,
  30471. scale: toScale
  30472. });
  30473. return this.callParent();
  30474. }
  30475. });
  30476. Ext.define('Ext.fx.animation.Pop', {
  30477. extend: Ext.fx.animation.Abstract,
  30478. alias: [
  30479. 'animation.pop',
  30480. 'animation.popIn'
  30481. ],
  30482. alternateClassName: 'Ext.fx.animation.PopIn',
  30483. config: {
  30484. out: false,
  30485. before: {
  30486. display: null,
  30487. opacity: 0
  30488. },
  30489. after: {
  30490. opacity: null
  30491. }
  30492. },
  30493. getData: function() {
  30494. var to = this.getTo(),
  30495. from = this.getFrom(),
  30496. out = this.getOut();
  30497. if (out) {
  30498. from.set('opacity', 1);
  30499. from.setTransform({
  30500. scale: 1
  30501. });
  30502. to.set('opacity', 0);
  30503. to.setTransform({
  30504. scale: 0
  30505. });
  30506. } else {
  30507. from.set('opacity', 0);
  30508. from.setTransform({
  30509. scale: 0
  30510. });
  30511. to.set('opacity', 1);
  30512. to.setTransform({
  30513. scale: 1
  30514. });
  30515. }
  30516. return this.callParent(arguments);
  30517. }
  30518. });
  30519. Ext.define('Ext.fx.animation.PopOut', {
  30520. extend: Ext.fx.animation.Pop,
  30521. alias: 'animation.popOut',
  30522. config: {
  30523. out: true,
  30524. before: {}
  30525. }
  30526. });
  30527. Ext.define('Ext.fx.Animation', {
  30528. constructor: function(config) {
  30529. var defaultClass = Ext.fx.animation.Abstract,
  30530. type;
  30531. if (typeof config === 'string') {
  30532. type = config;
  30533. config = {};
  30534. } else if (config && config.type) {
  30535. type = config.type;
  30536. }
  30537. if (type) {
  30538. defaultClass = Ext.ClassManager.getByAlias('animation.' + type);
  30539. if (!defaultClass) {
  30540. Ext.Logger.error("Invalid animation type of: '" + type + "'");
  30541. }
  30542. }
  30543. return Ext.factory(config, defaultClass);
  30544. }
  30545. });
  30546. Ext.define('Ext.app.EventDomain', {
  30547. statics: {
  30548. instances: {}
  30549. },
  30550. isEventDomain: true,
  30551. isInstance: false,
  30552. constructor: function() {
  30553. var me = this;
  30554. if (!me.isInstance) {
  30555. Ext.app.EventDomain.instances[me.type] = me;
  30556. }
  30557. me.bus = {};
  30558. me.monitoredClasses = [];
  30559. },
  30560. dispatch: function(target, ev, args) {
  30561. ev = Ext.canonicalEventName(ev);
  30562. var me = this,
  30563. bus = me.bus,
  30564. selectors = bus[ev],
  30565. selector, controllers, id, info, events, len, i, event;
  30566. if (!selectors) {
  30567. return true;
  30568. }
  30569. for (selector in selectors) {
  30570. if (selectors.hasOwnProperty(selector) && me.match(target, selector, me.controller)) {
  30571. controllers = selectors[selector];
  30572. for (id in controllers) {
  30573. if (controllers.hasOwnProperty(id)) {
  30574. info = controllers[id];
  30575. if (info.controller.isActive()) {
  30576. events = info.list;
  30577. len = events.length;
  30578. for (i = 0; i < len; i++) {
  30579. event = events[i];
  30580. if (event.fire.apply(event, args) === false) {
  30581. return false;
  30582. }
  30583. }
  30584. }
  30585. }
  30586. }
  30587. }
  30588. }
  30589. return true;
  30590. },
  30591. listen: function(selectors, controller) {
  30592. var me = this,
  30593. bus = me.bus,
  30594. idProperty = me.idProperty,
  30595. monitoredClasses = me.monitoredClasses,
  30596. monitoredClassesCount = monitoredClasses.length,
  30597. controllerId = controller.getId(),
  30598. isComponentDomain = (me.type === 'component'),
  30599. refMap = isComponentDomain ? controller.getRefMap() : null,
  30600. i, tree, info, selector, options, listener, scope, event, listeners, ev, classHasListeners;
  30601. for (selector in selectors) {
  30602. listeners = selectors[selector];
  30603. if (isComponentDomain) {
  30604. selector = refMap[selector] || selector;
  30605. }
  30606. if (listeners) {
  30607. if (idProperty) {
  30608. if (!/^[*#]/.test(selector)) {
  30609. Ext.raise('Selectors containing id should begin with #');
  30610. }
  30611. selector = selector === '*' ? selector : selector.substring(1);
  30612. }
  30613. for (ev in listeners) {
  30614. options = null;
  30615. listener = listeners[ev];
  30616. scope = controller;
  30617. ev = Ext.canonicalEventName(ev);
  30618. event = new Ext.util.Event(controller, ev);
  30619. if (Ext.isObject(listener)) {
  30620. options = listener;
  30621. listener = options.fn;
  30622. scope = options.scope || controller;
  30623. delete options.fn;
  30624. delete options.scope;
  30625. }
  30626. if ((!options || !options.scope) && typeof listener === 'string') {
  30627. if (!scope[listener]) {
  30628. Ext.raise('Cannot resolve "' + listener + '" on controller.');
  30629. }
  30630. scope = null;
  30631. }
  30632. else if (typeof listener === 'string') {
  30633. listener = scope[listener];
  30634. }
  30635. event.addListener(listener, scope, options);
  30636. for (i = 0; i < monitoredClassesCount; ++i) {
  30637. classHasListeners = monitoredClasses[i].hasListeners;
  30638. if (classHasListeners) {
  30639. classHasListeners._incr_(ev);
  30640. }
  30641. }
  30642. tree = bus[ev] || (bus[ev] = {});
  30643. tree = tree[selector] || (tree[selector] = {});
  30644. info = tree[controllerId] || (tree[controllerId] = {
  30645. controller: controller,
  30646. list: []
  30647. });
  30648. info.list.push(event);
  30649. }
  30650. }
  30651. }
  30652. },
  30653. match: function(target, selector) {
  30654. var idProperty = this.idProperty;
  30655. if (idProperty) {
  30656. return selector === '*' || target[idProperty] === selector;
  30657. }
  30658. return false;
  30659. },
  30660. monitor: function(observable) {
  30661. var domain = this,
  30662. prototype = observable.isInstance ? observable : observable.prototype,
  30663. doFireEvent = prototype.doFireEvent;
  30664. domain.monitoredClasses.push(observable);
  30665. prototype.doFireEvent = function(ev, args) {
  30666. var me = this,
  30667. ret;
  30668. ret = doFireEvent.apply(me, arguments);
  30669. if (ret !== false && !me.destroyed && !me.isSuspended(ev)) {
  30670. ret = domain.dispatch(me, ev, args);
  30671. }
  30672. return ret;
  30673. };
  30674. },
  30675. unlisten: function(controllerId) {
  30676. var bus = this.bus,
  30677. id = controllerId,
  30678. monitoredClasses = this.monitoredClasses,
  30679. monitoredClassesCount = monitoredClasses.length,
  30680. controllers, ev, events, len, item, selector, selectors, i, j, info, classHasListeners;
  30681. if (controllerId.isController) {
  30682. id = controllerId.getId();
  30683. }
  30684. for (ev in bus) {
  30685. ev = Ext.canonicalEventName(ev);
  30686. if (bus.hasOwnProperty(ev) && (selectors = bus[ev])) {
  30687. for (selector in selectors) {
  30688. controllers = selectors[selector];
  30689. info = controllers[id];
  30690. if (info) {
  30691. events = info.list;
  30692. if (events) {
  30693. for (i = 0 , len = events.length; i < len; ++i) {
  30694. item = events[i];
  30695. item.clearListeners();
  30696. for (j = 0; j < monitoredClassesCount; ++j) {
  30697. classHasListeners = monitoredClasses[j].hasListeners;
  30698. if (classHasListeners) {
  30699. classHasListeners._decr_(item.name);
  30700. }
  30701. }
  30702. }
  30703. delete controllers[id];
  30704. }
  30705. }
  30706. }
  30707. }
  30708. }
  30709. },
  30710. destroy: function() {
  30711. this.monitoredClasses = this.bus = null;
  30712. this.callParent();
  30713. }
  30714. });
  30715. Ext.define('Ext.app.domain.Component', {
  30716. extend: Ext.app.EventDomain,
  30717. singleton: true,
  30718. type: 'component',
  30719. constructor: function() {
  30720. this.callParent();
  30721. this.monitor(Ext.Widget);
  30722. },
  30723. dispatch: function(target, ev, args) {
  30724. var controller = target.lookupController(false),
  30725. domain, view;
  30726. while (controller) {
  30727. domain = controller.compDomain;
  30728. if (domain) {
  30729. if (domain.dispatch(target, ev, args) === false) {
  30730. return false;
  30731. }
  30732. }
  30733. view = controller.getView();
  30734. controller = view ? view.lookupController(true) : null;
  30735. }
  30736. return this.callParent([
  30737. target,
  30738. ev,
  30739. args
  30740. ]);
  30741. },
  30742. match: function(target, selector) {
  30743. return target.is(selector);
  30744. }
  30745. });
  30746. Ext.define('Ext.app.EventBus', {
  30747. singleton: true,
  30748. constructor: function() {
  30749. var me = this,
  30750. domains = Ext.app.EventDomain.instances;
  30751. me.callParent();
  30752. me.domains = domains;
  30753. me.bus = domains.component.bus;
  30754. },
  30755. control: function(selectors, controller) {
  30756. return this.domains.component.listen(selectors, controller);
  30757. },
  30758. listen: function(to, controller) {
  30759. var domains = this.domains,
  30760. domain;
  30761. for (domain in to) {
  30762. if (to.hasOwnProperty(domain)) {
  30763. domains[domain].listen(to[domain], controller);
  30764. }
  30765. }
  30766. },
  30767. unlisten: function(controllerId) {
  30768. var domains = Ext.app.EventDomain.instances,
  30769. domain;
  30770. for (domain in domains) {
  30771. domains[domain].unlisten(controllerId);
  30772. }
  30773. }
  30774. });
  30775. Ext.define('Ext.app.domain.Global', {
  30776. extend: Ext.app.EventDomain,
  30777. singleton: true,
  30778. type: 'global',
  30779. constructor: function() {
  30780. var me = this;
  30781. me.callParent();
  30782. me.monitor(Ext.GlobalEvents);
  30783. },
  30784. listen: function(listeners, controller) {
  30785. this.callParent([
  30786. {
  30787. global: listeners
  30788. },
  30789. controller
  30790. ]);
  30791. },
  30792. match: Ext.returnTrue
  30793. });
  30794. Ext.define('Ext.route.Handler', {
  30795. lazy: false,
  30796. statics: {
  30797. fromRouteConfig: function(config, scope) {
  30798. var handler = {
  30799. action: config.action,
  30800. before: config.before,
  30801. lazy: config.lazy,
  30802. exit: config.exit,
  30803. scope: scope,
  30804. single: config.single
  30805. };
  30806. return new this(handler);
  30807. }
  30808. },
  30809. constructor: function(config) {
  30810. Ext.apply(this, config);
  30811. }
  30812. });
  30813. Ext.define('Ext.route.Action', {
  30814. config: {
  30815. actions: null,
  30816. befores: null,
  30817. urlParams: []
  30818. },
  30819. started: false,
  30820. stopped: false,
  30821. constructor: function(config) {
  30822. var me = this;
  30823. me.deferred = new Ext.Deferred();
  30824. me.resume = me.resume.bind(me);
  30825. me.stop = me.stop.bind(me);
  30826. me.initConfig(config);
  30827. me.callParent([
  30828. config
  30829. ]);
  30830. },
  30831. applyActions: function(actions) {
  30832. if (actions) {
  30833. actions = Ext.Array.from(actions);
  30834. }
  30835. return actions;
  30836. },
  30837. applyBefores: function(befores) {
  30838. if (befores) {
  30839. befores = Ext.Array.from(befores);
  30840. }
  30841. return befores;
  30842. },
  30843. destroy: function() {
  30844. this.deferred = null;
  30845. this.setBefores(null).setActions(null).setUrlParams(null);
  30846. this.callParent();
  30847. },
  30848. resume: function() {
  30849. return this.next();
  30850. },
  30851. stop: function() {
  30852. this.stopped = true;
  30853. return this.done();
  30854. },
  30855. next: function() {
  30856. var me = this,
  30857. actions = me.getActions(),
  30858. befores = me.getBefores(),
  30859. urlParams = me.getUrlParams(),
  30860. config, ret, args;
  30861. if (Ext.isArray(urlParams)) {
  30862. args = urlParams.slice();
  30863. } else {
  30864. args = [
  30865. urlParams
  30866. ];
  30867. }
  30868. if (me.stopped || (befores ? !befores.length : true) && (actions ? !actions.length : true)) {
  30869. me.done();
  30870. } else {
  30871. if (befores && befores.length) {
  30872. config = befores.shift();
  30873. args.push(me);
  30874. ret = Ext.callback(config.fn, config.scope, args);
  30875. if (ret && ret.then) {
  30876. ret.then(function(arg) {
  30877. me.resume(arg);
  30878. }, function(arg) {
  30879. me.stop(arg);
  30880. });
  30881. }
  30882. } else if (actions && actions.length) {
  30883. config = actions.shift();
  30884. Ext.callback(config.fn, config.scope, args);
  30885. me.next();
  30886. } else {
  30887. me.next();
  30888. }
  30889. }
  30890. return me;
  30891. },
  30892. run: function() {
  30893. var deferred = this.deferred;
  30894. if (!this.started) {
  30895. this.next();
  30896. this.started = true;
  30897. }
  30898. return deferred.promise;
  30899. },
  30900. done: function() {
  30901. var deferred = this.deferred;
  30902. if (this.stopped) {
  30903. deferred.reject();
  30904. } else {
  30905. deferred.resolve();
  30906. }
  30907. this.destroy();
  30908. return this;
  30909. },
  30910. before: function(first, fn, scope) {
  30911. if (!Ext.isBoolean(first)) {
  30912. scope = fn;
  30913. fn = first;
  30914. first = false;
  30915. }
  30916. var befores = this.getBefores(),
  30917. config = {
  30918. fn: fn,
  30919. scope: scope
  30920. };
  30921. if (this.destroyed) {
  30922. Ext.raise('This action has has already resolved and therefore will never ' + 'execute this function.');
  30923. return;
  30924. }
  30925. if (befores) {
  30926. if (first) {
  30927. befores.unshift(config);
  30928. } else {
  30929. befores.push(config);
  30930. }
  30931. } else {
  30932. this.setBefores(config);
  30933. }
  30934. return this;
  30935. },
  30936. action: function(first, fn, scope) {
  30937. if (!Ext.isBoolean(first)) {
  30938. scope = fn;
  30939. fn = first;
  30940. first = false;
  30941. }
  30942. var actions = this.getActions(),
  30943. config = {
  30944. fn: fn,
  30945. scope: scope
  30946. };
  30947. if (this.destroyed) {
  30948. Ext.raise('This action has has already resolved and therefore will never ' + 'execute this function.');
  30949. return;
  30950. }
  30951. if (actions) {
  30952. if (first) {
  30953. actions.unshift(config);
  30954. } else {
  30955. actions.push(config);
  30956. }
  30957. } else {
  30958. this.setActions(config);
  30959. }
  30960. return this;
  30961. },
  30962. then: function(resolve, reject) {
  30963. if (this.destroyed) {
  30964. Ext.raise('This action has has already resolved and therefore will never ' + 'execute either function.');
  30965. return;
  30966. }
  30967. return this.deferred.then(resolve, reject);
  30968. }
  30969. });
  30970. Ext.define('Ext.route.Route', {
  30971. config: {
  30972. name: null,
  30973. url: null,
  30974. allowInactive: false,
  30975. conditions: {},
  30976. caseInsensitive: false,
  30977. handlers: [],
  30978. types: {
  30979. cached: true,
  30980. $value: {
  30981. alpha: {
  30982. re: '([a-zA-Z]+)'
  30983. },
  30984. alphanum: {
  30985. re: '([a-zA-Z0-9]+|[0-9]+(?:\\.[0-9]+)?|[0-9]*(?:\\.[0-9]+){1})',
  30986. parse: function(value) {
  30987. var test;
  30988. if (value && this.numRe.test(value)) {
  30989. test = parseFloat(value);
  30990. if (!isNaN(test)) {
  30991. value = test;
  30992. }
  30993. }
  30994. return value;
  30995. }
  30996. },
  30997. num: {
  30998. re: '([0-9]+(?:\\.[0-9]+)?|[0-9]*(?:\\.[0-9]+){1})',
  30999. parse: function(value) {
  31000. if (value) {
  31001. value = parseFloat(value);
  31002. }
  31003. return value;
  31004. }
  31005. },
  31006. '...': {
  31007. re: '(.+)?',
  31008. split: '/',
  31009. parse: function(values) {
  31010. var length, i, value;
  31011. if (values) {
  31012. length = values.length;
  31013. for (i = 0; i < length; i++) {
  31014. value = parseFloat(values[i]);
  31015. if (!isNaN(value)) {
  31016. values[i] = value;
  31017. }
  31018. }
  31019. }
  31020. return values;
  31021. }
  31022. }
  31023. }
  31024. }
  31025. },
  31026. defaultMatcher: '([%a-zA-Z0-9\\-\\_\\s,]+)',
  31027. numRe: /^[0-9]*(?:\.[0-9]*)?$/,
  31028. typeParamRegex: /:{([0-9A-Za-z_]+)(?::?([0-9A-Za-z_]+|.{3})?)}/g,
  31029. optionalGroupRegex: /\((.+?)\)/g,
  31030. paramMatchingRegex: /:([0-9A-Za-z_]+)/g,
  31031. isRoute: true,
  31032. constructor: function(config) {
  31033. var me = this,
  31034. url;
  31035. this.initConfig(config);
  31036. url = me.getUrl().replace(me.optionalGroupRegex, function(match, middle) {
  31037. return '(?:' + middle + ')?';
  31038. });
  31039. if (url.match(me.typeParamRegex)) {
  31040. me.handleNamedPattern(url);
  31041. } else {
  31042. me.handlePositionalPattern(url);
  31043. }
  31044. },
  31045. handlePositionalPattern: function(url) {
  31046. var me = this;
  31047. me.paramsInMatchString = url.match(me.paramMatchingRegex) || [];
  31048. me.matcherRegex = me.createMatcherRegex(url);
  31049. me.mode = 'positional';
  31050. },
  31051. handleNamedPattern: function(url) {
  31052. var me = this,
  31053. typeParamRegex = me.typeParamRegex,
  31054. conditions = me.getConditions(),
  31055. types = me.getTypes(),
  31056. defaultMatcher = me.defaultMatcher,
  31057. params = {},
  31058. re = url.replace(typeParamRegex, function(match, param, typeMatch) {
  31059. var type = typeMatch && types[typeMatch],
  31060. matcher = conditions[param] || type || defaultMatcher;
  31061. if (params[param]) {
  31062. Ext.raise('"' + param + '" already defined in route "' + url + '"');
  31063. }
  31064. if (typeMatch && !type) {
  31065. Ext.raise('Unknown parameter type "' + typeMatch + '" in route "' + url + '"');
  31066. }
  31067. if (Ext.isObject(matcher)) {
  31068. matcher = matcher.re;
  31069. }
  31070. params[param] = {
  31071. matcher: matcher,
  31072. type: typeMatch
  31073. };
  31074. return matcher;
  31075. });
  31076. if (re.search(me.paramMatchingRegex) !== -1) {
  31077. Ext.raise('URL parameter mismatch. Positional url parameter found ' + 'while in named mode.');
  31078. }
  31079. me.paramsInMatchString = params;
  31080. me.matcherRegex = new RegExp('^' + re + '$', me.getCaseInsensitive() ? 'i' : '');
  31081. me.mode = 'named';
  31082. },
  31083. recognize: function(url) {
  31084. var me = this,
  31085. recognized = me.recognizes(url),
  31086. handlers, length, hasHandler, handler, matches, urlParams, i;
  31087. if (recognized) {
  31088. handlers = me.getHandlers();
  31089. length = handlers.length;
  31090. for (i = 0; i < length; i++) {
  31091. handler = handlers[i];
  31092. if (handler.lastToken !== url) {
  31093. hasHandler = true;
  31094. break;
  31095. }
  31096. }
  31097. if (!hasHandler && url === me.lastToken) {
  31098. return true;
  31099. }
  31100. matches = me.matchesFor(url);
  31101. urlParams = me.getUrlParams(url);
  31102. return Ext.applyIf(matches, {
  31103. historyUrl: url,
  31104. urlParams: urlParams
  31105. });
  31106. }
  31107. return false;
  31108. },
  31109. getUrlParams: function(url) {
  31110. if (this.mode === 'named') {
  31111. return this.getNamedUrlParams(url);
  31112. } else {
  31113. return this.getPositionalUrlParams(url);
  31114. }
  31115. },
  31116. getPositionalUrlParams: function(url) {
  31117. var params = [],
  31118. conditions = this.getConditions(),
  31119. keys = this.paramsInMatchString,
  31120. values = url.match(this.matcherRegex),
  31121. length = keys.length,
  31122. i, key, type, value;
  31123. values.shift();
  31124. for (i = 0; i < length; i++) {
  31125. key = keys[i];
  31126. value = values[i];
  31127. if (conditions[key]) {
  31128. type = conditions[key];
  31129. } else if (key[0] === ':') {
  31130. key = key.substr(1);
  31131. if (conditions[key]) {
  31132. type = conditions[key];
  31133. }
  31134. }
  31135. value = this.parseValue(value, type);
  31136. if (Ext.isDefined(value) && value !== '') {
  31137. if (Ext.isArray(value)) {
  31138. params.push.apply(params, value);
  31139. } else {
  31140. params.push(value);
  31141. }
  31142. }
  31143. }
  31144. return params;
  31145. },
  31146. getNamedUrlParams: function(url) {
  31147. var conditions = this.getConditions(),
  31148. types = this.getTypes(),
  31149. params = {},
  31150. keys = this.paramsInMatchString,
  31151. values = url.match(this.matcherRegex),
  31152. name, obj, value, type, condition;
  31153. values.shift();
  31154. for (name in keys) {
  31155. obj = keys[name];
  31156. value = values.shift();
  31157. condition = conditions[name];
  31158. type = types[obj.type];
  31159. if (condition || type) {
  31160. type = Ext.merge({}, condition, types[obj.type]);
  31161. }
  31162. params[name] = this.parseValue(value, type);
  31163. }
  31164. return params;
  31165. },
  31166. parseValue: function(value, type) {
  31167. if (type) {
  31168. if (value && type.split) {
  31169. value = value.split(type.split);
  31170. if (!value[0]) {
  31171. value.shift();
  31172. }
  31173. if (!value[value.length - 1]) {
  31174. value.pop();
  31175. }
  31176. }
  31177. if (type.parse) {
  31178. value = type.parse.call(this, value);
  31179. }
  31180. }
  31181. if (!value && Ext.isString(value)) {
  31182. value = undefined;
  31183. }
  31184. return value;
  31185. },
  31186. recognizes: function(url) {
  31187. return this.matcherRegex.test(url);
  31188. },
  31189. execute: function(token, argConfig) {
  31190. var me = this,
  31191. allowInactive = me.getAllowInactive(),
  31192. handlers = me.getHandlers(),
  31193. queue = Ext.route.Router.getQueueRoutes(),
  31194. length = handlers.length,
  31195. urlParams = (argConfig && argConfig.urlParams) || [],
  31196. i, handler, scope, action, promises, single, remover;
  31197. me.lastToken = token;
  31198. if (!queue) {
  31199. promises = [];
  31200. }
  31201. return new Ext.Promise(function(resolve, reject) {
  31202. if (argConfig === false) {
  31203. reject();
  31204. } else {
  31205. if (queue) {
  31206. action = new Ext.route.Action({
  31207. urlParams: urlParams
  31208. });
  31209. }
  31210. for (i = 0; i < length; i++) {
  31211. handler = handlers[i];
  31212. if (token != null && handler.lastToken === token) {
  31213. continue;
  31214. }
  31215. scope = handler.scope;
  31216. handler.lastToken = token;
  31217. if (!allowInactive && scope.isActive && !scope.isActive()) {
  31218. continue;
  31219. }
  31220. if (!queue) {
  31221. action = new Ext.route.Action({
  31222. urlParams: urlParams
  31223. });
  31224. }
  31225. single = handler.single;
  31226. if (handler.before) {
  31227. action.before(handler.before, scope);
  31228. }
  31229. if (handler.action) {
  31230. action.action(handler.action, scope);
  31231. }
  31232. if (single) {
  31233. remover = Ext.bind(me.removeHandler, me, [
  31234. null,
  31235. handler
  31236. ]);
  31237. if (single === true) {
  31238. if (handler.action) {
  31239. action.action(remover, me);
  31240. } else {
  31241. action.before(function() {
  31242. remover();
  31243. return Ext.Promise.resolve();
  31244. }, me);
  31245. }
  31246. } else {
  31247. action.before(single === 'before', function() {
  31248. remover();
  31249. return Ext.Promise.resolve();
  31250. }, me);
  31251. }
  31252. }
  31253. if (!queue) {
  31254. if (Ext.fireEvent('beforeroute', action, me) === false) {
  31255. action.destroy();
  31256. } else {
  31257. promises.push(action.run());
  31258. }
  31259. }
  31260. }
  31261. if (queue) {
  31262. if (Ext.fireEvent('beforeroute', action, me) === false) {
  31263. action.destroy();
  31264. reject();
  31265. } else {
  31266. action.run().then(resolve, reject);
  31267. }
  31268. } else {
  31269. Ext.Promise.all(promises).then(resolve, reject);
  31270. }
  31271. }
  31272. });
  31273. },
  31274. matchesFor: function(url) {
  31275. var params = {},
  31276. keys = this.mode === 'named' ? Ext.Object.getKeys(this.paramsInMatchString) : this.paramsInMatchString,
  31277. values = url.match(this.matcherRegex),
  31278. length = keys.length,
  31279. i;
  31280. values.shift();
  31281. for (i = 0; i < length; i++) {
  31282. params[keys[i].replace(':', '')] = values[i];
  31283. }
  31284. return params;
  31285. },
  31286. createMatcherRegex: function(url) {
  31287. var me = this,
  31288. paramsInMatchString = me.paramsInMatchString,
  31289. conditions = me.getConditions(),
  31290. defaultMatcher = me.defaultMatcher,
  31291. length = paramsInMatchString.length,
  31292. modifiers = me.getCaseInsensitive() ? 'i' : '',
  31293. i, param, matcher;
  31294. if (url === '*') {
  31295. url = url.replace('*', '\\*');
  31296. } else {
  31297. for (i = 0; i < length; i++) {
  31298. param = paramsInMatchString[i];
  31299. if (conditions[param]) {
  31300. matcher = conditions[param];
  31301. }
  31302. else if (param[0] === ':' && conditions[param.substr(1)]) {
  31303. matcher = conditions[param.substr(1)];
  31304. } else {
  31305. matcher = defaultMatcher;
  31306. }
  31307. if (Ext.isObject(matcher)) {
  31308. matcher = matcher.re;
  31309. }
  31310. url = url.replace(new RegExp(param), matcher || defaultMatcher);
  31311. }
  31312. }
  31313. return new RegExp('^' + url + '$', modifiers);
  31314. },
  31315. addHandler: function(handler) {
  31316. var handlers = this.getHandlers();
  31317. if (!handler.isInstance) {
  31318. handler = new Ext.route.Handler(handler);
  31319. }
  31320. handlers.push(handler);
  31321. return handler.route = this;
  31322. },
  31323. removeHandler: function(scope, handler) {
  31324. var handlers = this.getHandlers(),
  31325. length = handlers.length,
  31326. newHandlers = [],
  31327. i, item;
  31328. for (i = 0; i < length; i++) {
  31329. item = handlers[i];
  31330. if (handler) {
  31331. if (item !== handler) {
  31332. newHandlers.push(item);
  31333. }
  31334. } else if (item.scope !== scope) {
  31335. newHandlers.push(item);
  31336. }
  31337. }
  31338. this.setHandlers(newHandlers);
  31339. return this;
  31340. },
  31341. clearLastTokens: function() {
  31342. var handlers = this.getHandlers(),
  31343. length = handlers.length,
  31344. i;
  31345. for (i = 0; i < length; i++) {
  31346. handlers[i].lastToken = null;
  31347. }
  31348. this.lastToken = null;
  31349. },
  31350. onExit: function() {
  31351. var me = this,
  31352. handlers = me.getHandlers(),
  31353. allowInactive = me.getAllowInactive(),
  31354. length = handlers.length,
  31355. action = new Ext.route.Action({
  31356. urlParams: [
  31357. me.lastToken
  31358. ]
  31359. }),
  31360. i, handler, scope;
  31361. me.clearLastTokens();
  31362. for (i = 0; i < length; i++) {
  31363. handler = handlers[i];
  31364. if (handler.exit) {
  31365. scope = handler.scope;
  31366. if (!allowInactive && scope.isActive && !scope.isActive()) {
  31367. continue;
  31368. }
  31369. action.action(handler.exit, scope);
  31370. }
  31371. }
  31372. if (Ext.fireEvent('beforerouteexit', action, me) === false) {
  31373. action.destroy();
  31374. } else {
  31375. action.run();
  31376. }
  31377. }
  31378. });
  31379. Ext.define('Ext.util.Observable', {
  31380. extend: Ext.mixin.Observable,
  31381. $applyConfigs: true
  31382. }, function(Observable) {
  31383. var Super = Ext.mixin.Observable;
  31384. Observable.releaseCapture = Super.releaseCapture;
  31385. Observable.capture = Super.capture;
  31386. Observable.captureArgs = Super.captureArgs;
  31387. Observable.observe = Observable.observeClass = Super.observe;
  31388. });
  31389. Ext.define('Ext.util.History', {
  31390. singleton: true,
  31391. alternateClassName: 'Ext.History',
  31392. mixins: {
  31393. observable: Ext.util.Observable
  31394. },
  31395. useTopWindow: false,
  31396. hashRe: /^(#?!?)/,
  31397. constructor: function() {
  31398. var me = this;
  31399. me.ready = false;
  31400. me.currentToken = null;
  31401. me.mixins.observable.constructor.call(me);
  31402. },
  31403. getHash: function() {
  31404. return (this.win.location.hash || '').replace(this.hashRe, '');
  31405. },
  31406. setHash: function(hash, replace) {
  31407. var me = this,
  31408. hashRe = me.hashRe,
  31409. loc = me.win.location;
  31410. hash = hash.replace(hashRe, me.hashbang ? '#!' : '#');
  31411. try {
  31412. if (replace) {
  31413. loc.replace(hash);
  31414. } else {
  31415. loc.hash = hash;
  31416. }
  31417. me.currentToken = hash.replace(hashRe, '');
  31418. } catch (e) {}
  31419. },
  31420. handleStateChange: function(token) {
  31421. token = token.replace(this.hashRe, '');
  31422. this.fireEvent('change', this.currentToken = token);
  31423. },
  31424. startUp: function() {
  31425. var me = this;
  31426. me.currentToken = me.getHash();
  31427. Ext.get(me.win).on('hashchange', me.onHashChange, me);
  31428. me.ready = true;
  31429. me.fireEvent('ready', me);
  31430. },
  31431. onHashChange: function() {
  31432. var me = this,
  31433. newHash = me.getHash();
  31434. if (newHash !== me.hash) {
  31435. me.hash = newHash;
  31436. me.handleStateChange(newHash);
  31437. }
  31438. },
  31439. init: function(onReady, scope) {
  31440. var me = this;
  31441. if (me.ready) {
  31442. Ext.callback(onReady, scope, [
  31443. me
  31444. ]);
  31445. return;
  31446. }
  31447. if (!Ext.isReady) {
  31448. Ext.onInternalReady(function() {
  31449. me.init(onReady, scope);
  31450. });
  31451. return;
  31452. }
  31453. me.win = me.useTopWindow ? window.top : window;
  31454. me.hash = me.getHash();
  31455. if (onReady) {
  31456. me.on('ready', onReady, scope, {
  31457. single: true
  31458. });
  31459. }
  31460. me.startUp();
  31461. },
  31462. add: function(token, preventDuplicates) {
  31463. var me = this,
  31464. set = false;
  31465. if (preventDuplicates === false || me.getToken() !== token) {
  31466. me.setHash(token);
  31467. set = true;
  31468. }
  31469. return set;
  31470. },
  31471. replace: function(token, preventDuplicates) {
  31472. var me = this,
  31473. set = false;
  31474. if (preventDuplicates === false || me.getToken() !== token) {
  31475. this.setHash(token, true);
  31476. set = true;
  31477. }
  31478. return set;
  31479. },
  31480. back: function() {
  31481. this.win.history.go(-1);
  31482. },
  31483. forward: function() {
  31484. this.win.history.go(1);
  31485. },
  31486. getToken: function() {
  31487. return this.ready ? this.currentToken : this.getHash();
  31488. }
  31489. });
  31490. Ext.define('Ext.route.Router', {
  31491. singleton: true,
  31492. config: {
  31493. hashbang: null,
  31494. multipleToken: '|',
  31495. queueRoutes: true
  31496. },
  31497. constructor: function() {
  31498. var History = Ext.util.History;
  31499. if (!History.ready) {
  31500. History.init();
  31501. }
  31502. History.on('change', this.onStateChange, this);
  31503. this.initConfig();
  31504. this.clear();
  31505. },
  31506. updateHashbang: function(hashbang) {
  31507. Ext.util.History.hashbang = hashbang;
  31508. },
  31509. onStateChange: function(token) {
  31510. var me = this,
  31511. tokens = token.split(me.getMultipleToken()),
  31512. queue, i, length;
  31513. if (me.isSuspended) {
  31514. queue = me.suspendedQueue;
  31515. i = 0;
  31516. length = tokens.length;
  31517. if (queue) {
  31518. for (; i < length; i++) {
  31519. token = tokens[i];
  31520. if (!Ext.Array.contains(queue, token)) {
  31521. queue.push(token);
  31522. }
  31523. }
  31524. }
  31525. } else {
  31526. me.handleBefore(tokens);
  31527. }
  31528. },
  31529. handleBefore: function(tokens) {
  31530. var me = this,
  31531. action = new Ext.route.Action();
  31532. if (Ext.fireEvent('beforeroutes', action, tokens) === false) {
  31533. action.destroy();
  31534. } else {
  31535. action.run().then(me.handleBeforeRoute.bind(me, tokens), Ext.emptyFn);
  31536. }
  31537. },
  31538. handleBeforeRoute: function(tokens) {
  31539. var me = this,
  31540. beforeRoute = me.getByName('*');
  31541. if (beforeRoute) {
  31542. beforeRoute.execute().then(me.doRun.bind(me, tokens), Ext.emptyFn);
  31543. } else {
  31544. me.doRun(tokens);
  31545. }
  31546. },
  31547. doRun: function(tokens) {
  31548. var me = this,
  31549. app = me.application,
  31550. routes = me.routes,
  31551. i = 0,
  31552. length = tokens.length,
  31553. matched = {},
  31554. unmatched = [],
  31555. token, found, name, route, recognize;
  31556. for (; i < length; i++) {
  31557. token = tokens[i];
  31558. found = false;
  31559. for (name in routes) {
  31560. route = routes[name];
  31561. recognize = route.recognize(token);
  31562. if (recognize) {
  31563. found = true;
  31564. if (recognize !== true) {
  31565. route.execute(token, recognize).then(null, Ext.bind(me.onRouteRejection, me, [
  31566. route
  31567. ], 0));
  31568. }
  31569. Ext.Array.remove(unmatched, route);
  31570. if (!matched[name]) {
  31571. matched[name] = 1;
  31572. }
  31573. } else if (!matched[name]) {
  31574. unmatched.push(route);
  31575. }
  31576. }
  31577. if (!found) {
  31578. if (app) {
  31579. app.fireEvent('unmatchedroute', token);
  31580. }
  31581. Ext.fireEvent('unmatchedroute', token);
  31582. }
  31583. }
  31584. i = 0;
  31585. length = unmatched.length;
  31586. for (; i < length; i++) {
  31587. unmatched[i].onExit();
  31588. }
  31589. },
  31590. onRouteRejection: function(route, error) {
  31591. Ext.fireEvent('routereject', route, error);
  31592. if (error) {
  31593. Ext.raise(error);
  31594. }
  31595. },
  31596. connect: function(url, config, instance) {
  31597. var routes = this.routes,
  31598. delimiter = this.getMultipleToken(),
  31599. name = config.name || url,
  31600. handler, route;
  31601. if (url[0] === '!') {
  31602. if (!Ext.util.History.hashbang) {
  31603. Ext.log({
  31604. level: 'error',
  31605. msg: 'Route found with "!" ("' + url + '"). Should use new hashbang functionality instead. ' + 'Please see the router guide for more: https://docs.sencha.com/extjs/' + Ext.getVersion().version + '/guides/application_architecture/router.html'
  31606. });
  31607. }
  31608. url = url.substr(1);
  31609. this.setHashbang(true);
  31610. }
  31611. if (Ext.isString(config)) {
  31612. config = {
  31613. action: config
  31614. };
  31615. }
  31616. handler = Ext.route.Handler.fromRouteConfig(config, instance);
  31617. route = routes[name];
  31618. if (!route) {
  31619. config.name = name;
  31620. config.url = url;
  31621. route = routes[name] = new Ext.route.Route(config);
  31622. }
  31623. route.addHandler(handler);
  31624. if (handler.lazy) {
  31625. var currentHash = Ext.util.History.getToken(),
  31626. tokens = currentHash.split(delimiter),
  31627. length = tokens.length,
  31628. matched = [],
  31629. i, token;
  31630. for (i = 0; i < length; i++) {
  31631. token = tokens[i];
  31632. if (Ext.Array.indexOf(matched, token) === -1 && route.recognize(token)) {
  31633. matched.push(token);
  31634. }
  31635. }
  31636. this.onStateChange(matched.join(delimiter));
  31637. }
  31638. return handler;
  31639. },
  31640. disconnect: function(instance, config) {
  31641. var routes = this.routes,
  31642. route, name;
  31643. if (config) {
  31644. route = config.route || this.getByName(config.name || config.url);
  31645. if (route) {
  31646. route.removeHandler(instance, config);
  31647. }
  31648. } else {
  31649. for (name in routes) {
  31650. route = routes[name];
  31651. route.removeHandler(instance);
  31652. }
  31653. }
  31654. },
  31655. recognize: function(url) {
  31656. var routes = this.routes,
  31657. matches = [],
  31658. name, arr, i, length, route, urlParams;
  31659. for (name in routes) {
  31660. arr = routes[name];
  31661. length = arr && arr.length;
  31662. if (length) {
  31663. i = 0;
  31664. for (; i < length; i++) {
  31665. route = arr[i];
  31666. urlParams = route.recognize(url);
  31667. if (urlParams) {
  31668. matches.push({
  31669. route: route,
  31670. urlParams: urlParams
  31671. });
  31672. }
  31673. }
  31674. }
  31675. }
  31676. return matches.length ? matches : false;
  31677. },
  31678. draw: function(fn) {
  31679. fn.call(this, this);
  31680. },
  31681. clear: function() {
  31682. this.routes = {};
  31683. },
  31684. clearLastTokens: function(token) {
  31685. var routes = this.routes,
  31686. name, route;
  31687. for (name in routes) {
  31688. route = routes[name];
  31689. if (!token || route.recognize(token)) {
  31690. route.clearLastTokens();
  31691. }
  31692. }
  31693. },
  31694. getByName: function(name) {
  31695. var routes = this.routes;
  31696. if (routes) {
  31697. return routes[name];
  31698. }
  31699. },
  31700. suspend: function(trackTokens) {
  31701. this.isSuspended = true;
  31702. if (!this.suspendedQueue && trackTokens !== false) {
  31703. this.suspendedQueue = [];
  31704. }
  31705. },
  31706. resume: function(discardQueue) {
  31707. var me = this,
  31708. queue = me.suspendedQueue,
  31709. token;
  31710. if (me.isSuspended) {
  31711. me.isSuspended = false;
  31712. me.suspendedQueue = null;
  31713. if (!discardQueue && queue) {
  31714. token = queue.join(me.getMultipleToken());
  31715. me.onStateChange(token);
  31716. }
  31717. }
  31718. }
  31719. });
  31720. Ext.define('Ext.route.Mixin', {
  31721. extend: Ext.Mixin,
  31722. mixinConfig: {
  31723. id: 'routerable',
  31724. before: {
  31725. destroy: 'destroyRouterable'
  31726. }
  31727. },
  31728. config: {
  31729. routes: null
  31730. },
  31731. destroyRouterable: function() {
  31732. Ext.route.Router.disconnect(this);
  31733. },
  31734. applyRoutes: function(routes, oldRoutes) {
  31735. var Router = Ext.route.Router,
  31736. url;
  31737. if (routes) {
  31738. for (url in routes) {
  31739. routes[url] = Router.connect(url, routes[url], this);
  31740. }
  31741. }
  31742. if (oldRoutes) {
  31743. for (url in oldRoutes) {
  31744. Router.disconnect(this, oldRoutes[url]);
  31745. }
  31746. }
  31747. return routes;
  31748. },
  31749. redirectTo: function(hash, opt) {
  31750. var currentHash = Ext.util.History.getToken(),
  31751. Router = Ext.route.Router,
  31752. delimiter = Router.getMultipleToken(),
  31753. tokens = currentHash ? currentHash.split(delimiter) : [],
  31754. length = tokens.length,
  31755. force, i, name, obj, route, token, match;
  31756. if (hash === -1) {
  31757. return Ext.util.History.back();
  31758. } else if (hash === 1) {
  31759. return Ext.util.History.forward();
  31760. } else if (hash.isModel) {
  31761. hash = hash.toUrl();
  31762. } else if (Ext.isObject(hash)) {
  31763. for (name in hash) {
  31764. obj = hash[name];
  31765. if (!Ext.isObject(obj)) {
  31766. obj = {
  31767. token: obj
  31768. };
  31769. }
  31770. if (length) {
  31771. route = Router.getByName(name);
  31772. if (route) {
  31773. match = false;
  31774. for (i = 0; i < length; i++) {
  31775. token = tokens[i];
  31776. if (route.matcherRegex.test(token)) {
  31777. match = true;
  31778. if (obj.token) {
  31779. if (obj.fn && obj.fn.call(this, token, tokens, obj) === false) {
  31780. continue;
  31781. }
  31782. tokens[i] = obj.token;
  31783. if (obj.force) {
  31784. route.lastToken = null;
  31785. }
  31786. } else {
  31787. tokens.splice(i, 1);
  31788. i--;
  31789. length--;
  31790. route.lastToken = null;
  31791. }
  31792. }
  31793. }
  31794. if (obj && obj.token && !match) {
  31795. tokens.push(obj.token);
  31796. }
  31797. }
  31798. } else if (obj && obj.token) {
  31799. tokens.push(obj.token);
  31800. }
  31801. }
  31802. hash = tokens.join(delimiter);
  31803. }
  31804. if (opt === true) {
  31805. force = opt;
  31806. opt = null;
  31807. } else if (opt) {
  31808. force = opt.force;
  31809. }
  31810. length = tokens.length;
  31811. if (force && length) {
  31812. for (i = 0; i < length; i++) {
  31813. token = tokens[i];
  31814. Router.clearLastTokens(token);
  31815. }
  31816. }
  31817. if (currentHash === hash) {
  31818. if (force) {
  31819. Router.onStateChange(hash);
  31820. }
  31821. return false;
  31822. }
  31823. if (opt && opt.replace) {
  31824. Ext.util.History.replace(hash);
  31825. } else {
  31826. Ext.util.History.add(hash);
  31827. }
  31828. return true;
  31829. },
  31830. privates: {
  31831. afterClassMixedIn: function(targetClass) {
  31832. var proto = targetClass.prototype,
  31833. routes = proto.routes;
  31834. if (routes) {
  31835. delete proto.routes;
  31836. targetClass.getConfigurator().add({
  31837. routes: routes
  31838. });
  31839. }
  31840. }
  31841. }
  31842. });
  31843. Ext.define('Ext.app.BaseController', {
  31844. mixins: [
  31845. Ext.mixin.Observable,
  31846. Ext.route.Mixin
  31847. ],
  31848. isController: true,
  31849. config: {
  31850. id: undefined,
  31851. control: null,
  31852. listen: null
  31853. },
  31854. constructor: function(config) {
  31855. var me = this;
  31856. Ext.apply(me, config);
  31857. delete me.control;
  31858. delete me.listen;
  31859. me.eventbus = Ext.app.EventBus;
  31860. me.mixins.observable.constructor.call(me, config);
  31861. },
  31862. updateId: function(id) {
  31863. this.id = id;
  31864. },
  31865. applyListen: function(listen) {
  31866. if (Ext.isObject(listen)) {
  31867. listen = Ext.clone(listen);
  31868. }
  31869. return listen;
  31870. },
  31871. applyControl: function(control) {
  31872. if (Ext.isObject(control)) {
  31873. control = Ext.clone(control);
  31874. }
  31875. return control;
  31876. },
  31877. updateControl: function(control) {
  31878. this.getId();
  31879. if (control) {
  31880. this.control(control);
  31881. }
  31882. },
  31883. updateListen: function(listen) {
  31884. this.getId();
  31885. if (listen) {
  31886. this.listen(listen);
  31887. }
  31888. },
  31889. isActive: function() {
  31890. return true;
  31891. },
  31892. control: function(selectors, listeners, controller) {
  31893. var me = this,
  31894. ctrl = controller,
  31895. obj;
  31896. if (Ext.isString(selectors)) {
  31897. obj = {};
  31898. obj[selectors] = listeners;
  31899. } else {
  31900. obj = selectors;
  31901. ctrl = listeners;
  31902. }
  31903. me.eventbus.control(obj, ctrl || me);
  31904. },
  31905. listen: function(to, controller) {
  31906. this.eventbus.listen(to, controller || this);
  31907. },
  31908. destroy: function() {
  31909. var me = this,
  31910. bus = me.eventbus;
  31911. if (bus) {
  31912. bus.unlisten(me);
  31913. me.eventbus = null;
  31914. }
  31915. me.callParent();
  31916. }
  31917. });
  31918. Ext.define('Ext.app.Util', {}, function() {
  31919. Ext.apply(Ext.app, {
  31920. namespaces: {
  31921. Ext: {}
  31922. },
  31923. addNamespaces: function(namespace) {
  31924. var namespaces = Ext.app.namespaces,
  31925. i, l;
  31926. if (!Ext.isArray(namespace)) {
  31927. namespace = [
  31928. namespace
  31929. ];
  31930. }
  31931. for (i = 0 , l = namespace.length; i < l; i++) {
  31932. namespaces[namespace[i]] = true;
  31933. }
  31934. },
  31935. clearNamespaces: function() {
  31936. Ext.app.namespaces = {};
  31937. },
  31938. getNamespace: function(className) {
  31939. var namespaces = Ext.apply({}, Ext.ClassManager.paths, Ext.app.namespaces),
  31940. deepestPrefix = '',
  31941. prefix;
  31942. for (prefix in namespaces) {
  31943. if (namespaces.hasOwnProperty(prefix) && prefix.length > deepestPrefix.length && (prefix + '.' === className.substring(0, prefix.length + 1))) {
  31944. deepestPrefix = prefix;
  31945. }
  31946. }
  31947. return deepestPrefix === '' ? undefined : deepestPrefix;
  31948. },
  31949. setupPaths: function(appName, appFolder, paths) {
  31950. var manifestPaths = Ext.manifest,
  31951. ns;
  31952. if (appName && appFolder !== null) {
  31953. manifestPaths = manifestPaths && manifestPaths.paths;
  31954. if (!manifestPaths || appFolder !== undefined) {
  31955. Ext.Loader.setPath(appName, (appFolder === undefined) ? 'app' : appFolder);
  31956. }
  31957. }
  31958. if (paths) {
  31959. for (ns in paths) {
  31960. if (paths.hasOwnProperty(ns)) {
  31961. Ext.Loader.setPath(ns, paths[ns]);
  31962. }
  31963. }
  31964. }
  31965. }
  31966. });
  31967. Ext.getNamespace = Ext.app.getNamespace;
  31968. });
  31969. Ext.define('Ext.util.BasicFilter', {
  31970. isFilter: true,
  31971. config: {
  31972. id: null,
  31973. disabled: false,
  31974. serializer: null
  31975. },
  31976. generation: 0,
  31977. constructor: function(config) {
  31978. this.initConfig(config);
  31979. },
  31980. updateDisabled: function() {
  31981. if (!this.isConfiguring) {
  31982. ++this.generation;
  31983. }
  31984. }
  31985. });
  31986. Ext.define('Ext.util.Filter', {
  31987. extend: Ext.util.BasicFilter,
  31988. config: {
  31989. property: null,
  31990. root: null,
  31991. value: null,
  31992. filterFn: null,
  31993. anyMatch: false,
  31994. exactMatch: false,
  31995. caseSensitive: false,
  31996. disableOnEmpty: false,
  31997. operator: null,
  31998. convert: null
  31999. },
  32000. scope: null,
  32001. $configStrict: false,
  32002. statics: {
  32003. createFilterFn: function(filters) {
  32004. if (!filters) {
  32005. return Ext.returnTrue;
  32006. }
  32007. return function(candidate) {
  32008. var items = filters.isCollection ? filters.items : filters,
  32009. length = items.length,
  32010. match = true,
  32011. i, filter;
  32012. for (i = 0; match && i < length; i++) {
  32013. filter = items[i];
  32014. if (!filter.getDisabled()) {
  32015. match = filter.filter(candidate);
  32016. }
  32017. }
  32018. return match;
  32019. };
  32020. },
  32021. isEqual: function(filter1, filter2) {
  32022. if (filter1.getProperty() !== filter2.getProperty()) {
  32023. return false;
  32024. }
  32025. if (filter1.getOperator() !== filter2.getOperator()) {
  32026. return false;
  32027. }
  32028. if (filter1.getValue() === filter2.getValue()) {
  32029. return true;
  32030. }
  32031. if (Ext.isArray(filter1) && Ext.isArray(filter2)) {
  32032. return Ext.Array.equals(filter1, filter2);
  32033. }
  32034. return false;
  32035. },
  32036. isInvalid: function(cfg) {
  32037. if (!cfg.filterFn) {
  32038. if (!cfg.property) {
  32039. return 'A Filter requires either a property or a filterFn to be set';
  32040. }
  32041. if (!cfg.hasOwnProperty('value') && !cfg.operator) {
  32042. return 'A Filter requires either a property and value, or a filterFn to be set';
  32043. }
  32044. }
  32045. return false;
  32046. }
  32047. },
  32048. constructor: function(config) {
  32049. var warn = Ext.util.Filter.isInvalid(config);
  32050. if (warn) {
  32051. Ext.log.warn(warn);
  32052. }
  32053. this.callParent([
  32054. config
  32055. ]);
  32056. },
  32057. preventConvert: {
  32058. 'in': 1,
  32059. notin: 1
  32060. },
  32061. filter: function(item) {
  32062. var me = this,
  32063. filterFn = me._filterFn || me.getFilterFn(),
  32064. convert = me.getConvert(),
  32065. value = me._value;
  32066. me._filterValue = value;
  32067. me.isDateValue = Ext.isDate(value);
  32068. if (me.isDateValue) {
  32069. me.dateValue = value.getTime();
  32070. }
  32071. if (convert && !me.preventConvert[me.getOperator()]) {
  32072. me._filterValue = convert.call(me.scope || me, value);
  32073. }
  32074. return filterFn.call(me.scope || me, item);
  32075. },
  32076. getId: function() {
  32077. var me = this,
  32078. id = me._id;
  32079. if (!id) {
  32080. id = me.getProperty();
  32081. if (!id) {
  32082. id = Ext.id(null, 'ext-filter-');
  32083. }
  32084. me._id = id;
  32085. }
  32086. return id;
  32087. },
  32088. getFilterFn: function() {
  32089. var me = this,
  32090. filterFn = me._filterFn,
  32091. operator;
  32092. if (!filterFn) {
  32093. operator = me.getOperator();
  32094. if (operator) {
  32095. filterFn = me.operatorFns[operator];
  32096. } else {
  32097. filterFn = me.createRegexFilter();
  32098. }
  32099. me._filterFn = filterFn;
  32100. me.generatedFilterFn = true;
  32101. }
  32102. return filterFn;
  32103. },
  32104. createRegexFilter: function() {
  32105. var me = this,
  32106. anyMatch = !!me.getAnyMatch(),
  32107. exact = !!me.getExactMatch(),
  32108. value = me.getValue(),
  32109. matcher = Ext.String.createRegex(value, !anyMatch,
  32110. !anyMatch && exact,
  32111. !me.getCaseSensitive());
  32112. return function(item) {
  32113. var val = me.getPropertyValue(item);
  32114. return matcher ? matcher.test(val) : (val == null);
  32115. };
  32116. },
  32117. getPropertyValue: function(item) {
  32118. var root = this._root,
  32119. value = (root == null) ? item : item[root];
  32120. return value[this._property];
  32121. },
  32122. getState: function() {
  32123. var config = this.getInitialConfig(),
  32124. result = {},
  32125. name;
  32126. for (name in config) {
  32127. if (config.hasOwnProperty(name)) {
  32128. result[name] = config[name];
  32129. }
  32130. }
  32131. delete result.root;
  32132. result.value = this.getValue();
  32133. return result;
  32134. },
  32135. getScope: function() {
  32136. return this.scope;
  32137. },
  32138. serialize: function() {
  32139. var result = this.getState(),
  32140. serializer = this.getSerializer(),
  32141. serialized;
  32142. delete result.id;
  32143. delete result.serializer;
  32144. if (serializer) {
  32145. serialized = serializer.call(this, result);
  32146. if (serialized) {
  32147. result = serialized;
  32148. }
  32149. }
  32150. return result;
  32151. },
  32152. serializeTo: function(out) {
  32153. var me = this,
  32154. primitive, serialized;
  32155. me.getFilterFn();
  32156. if (me.generatedFilterFn) {
  32157. out.push(serialized = me.serialize());
  32158. primitive = me.primitiveRe.test(typeof serialized);
  32159. }
  32160. return !primitive;
  32161. },
  32162. updateOperator: function() {
  32163. this.onConfigMutation();
  32164. },
  32165. updateConvert: function() {
  32166. this.onConfigMutation();
  32167. },
  32168. updateProperty: function() {
  32169. this.onConfigMutation();
  32170. },
  32171. updateAnyMatch: function() {
  32172. this.onConfigMutation();
  32173. },
  32174. updateExactMatch: function() {
  32175. this.onConfigMutation();
  32176. },
  32177. updateCaseSensitive: function() {
  32178. this.onConfigMutation();
  32179. },
  32180. updateValue: function(value) {
  32181. this.onConfigMutation();
  32182. if (this.getDisableOnEmpty()) {
  32183. this.setDisabled(Ext.isEmpty(value));
  32184. }
  32185. },
  32186. updateFilterFn: function(filterFn) {
  32187. delete this.generatedFilterFn;
  32188. },
  32189. onConfigMutation: function() {
  32190. this.generation++;
  32191. if (this.generatedFilterFn) {
  32192. this._filterFn = null;
  32193. }
  32194. },
  32195. updateDisableOnEmpty: function(disableOnEmpty) {
  32196. if (disableOnEmpty) {
  32197. this.setDisabled(Ext.isEmpty(this.getValue()));
  32198. }
  32199. },
  32200. privates: {
  32201. primitiveRe: /string|number|boolean/,
  32202. getCandidateValue: function(candidate, v, preventCoerce) {
  32203. var me = this,
  32204. convert = me._convert,
  32205. result = me.getPropertyValue(candidate);
  32206. if (convert) {
  32207. result = convert.call(me.scope || me, result);
  32208. } else if (!preventCoerce) {
  32209. result = Ext.coerce(result, v);
  32210. }
  32211. return result;
  32212. }
  32213. }
  32214. }, function(Filter) {
  32215. var prototype = Filter.prototype,
  32216. operatorFns = (prototype.operatorFns = {
  32217. "<": function(candidate) {
  32218. var v = this._filterValue;
  32219. return this.getCandidateValue(candidate, v) < v;
  32220. },
  32221. "<=": function(candidate) {
  32222. var v = this._filterValue;
  32223. return this.getCandidateValue(candidate, v) <= v;
  32224. },
  32225. "=": function(candidate) {
  32226. var me = this,
  32227. v = me._filterValue;
  32228. candidate = me.getCandidateValue(candidate, v);
  32229. if (me.isDateValue && candidate instanceof Date) {
  32230. candidate = candidate.getTime();
  32231. v = me.dateValue;
  32232. }
  32233. return candidate == v;
  32234. },
  32235. "===": function(candidate) {
  32236. var me = this,
  32237. v = me._filterValue;
  32238. candidate = me.getCandidateValue(candidate, v, true);
  32239. if (me.isDateValue && candidate instanceof Date) {
  32240. candidate = candidate.getTime();
  32241. v = me.dateValue;
  32242. }
  32243. return candidate === v;
  32244. },
  32245. ">=": function(candidate) {
  32246. var v = this._filterValue;
  32247. return this.getCandidateValue(candidate, v) >= v;
  32248. },
  32249. ">": function(candidate) {
  32250. var v = this._filterValue;
  32251. return this.getCandidateValue(candidate, v) > v;
  32252. },
  32253. "!=": function(candidate) {
  32254. var me = this,
  32255. v = me._filterValue;
  32256. candidate = me.getCandidateValue(candidate, v);
  32257. if (me.isDateValue && candidate instanceof Date) {
  32258. candidate = candidate.getTime();
  32259. v = me.dateValue;
  32260. }
  32261. return candidate != v;
  32262. },
  32263. "!==": function(candidate) {
  32264. var me = this,
  32265. v = me._filterValue;
  32266. candidate = me.getCandidateValue(candidate, v, true);
  32267. if (me.isDateValue && candidate instanceof Date) {
  32268. candidate = candidate.getTime();
  32269. v = me.dateValue;
  32270. }
  32271. return candidate !== v;
  32272. },
  32273. "in": function(candidate) {
  32274. var v = this._filterValue;
  32275. return Ext.Array.contains(v, this.getCandidateValue(candidate, v));
  32276. },
  32277. notin: function(candidate) {
  32278. var v = this._filterValue;
  32279. return !Ext.Array.contains(v, this.getCandidateValue(candidate, v));
  32280. },
  32281. like: function(candidate) {
  32282. var v = this._filterValue;
  32283. return v && this.getCandidateValue(candidate, v).toLowerCase().indexOf(v.toLowerCase()) > -1;
  32284. },
  32285. "/=": function(candidate) {
  32286. var me = this,
  32287. v = me._filterValue;
  32288. candidate = me.getCandidateValue(candidate, v);
  32289. if (v !== me.lastRegExpSource) {
  32290. me.lastRegExpSource = v;
  32291. try {
  32292. me.regex = new RegExp(v, 'i');
  32293. } catch (e) {
  32294. me.regex = null;
  32295. }
  32296. }
  32297. return me.regex ? me.regex.test(candidate) : false;
  32298. }
  32299. });
  32300. operatorFns['=='] = operatorFns['='];
  32301. operatorFns.gt = operatorFns['>'];
  32302. operatorFns.ge = operatorFns['>='];
  32303. operatorFns.lt = operatorFns['<'];
  32304. operatorFns.le = operatorFns['<='];
  32305. operatorFns.eq = operatorFns['='];
  32306. operatorFns.ne = operatorFns['!='];
  32307. });
  32308. Ext.define('Ext.util.AbstractMixedCollection', {
  32309. mixins: {
  32310. observable: Ext.util.Observable
  32311. },
  32312. isMixedCollection: true,
  32313. generation: 0,
  32314. indexGeneration: 0,
  32315. constructor: function(allowFunctions, keyFn) {
  32316. var me = this;
  32317. if (arguments.length === 1 && Ext.isObject(allowFunctions)) {
  32318. me.initialConfig = allowFunctions;
  32319. Ext.apply(me, allowFunctions);
  32320. } else
  32321. {
  32322. me.allowFunctions = allowFunctions === true;
  32323. if (keyFn) {
  32324. me.getKey = keyFn;
  32325. }
  32326. me.initialConfig = {
  32327. allowFunctions: me.allowFunctions,
  32328. getKey: me.getKey
  32329. };
  32330. }
  32331. me.items = [];
  32332. me.map = {};
  32333. me.keys = [];
  32334. me.indexMap = {};
  32335. me.length = 0;
  32336. me.mixins.observable.constructor.call(me);
  32337. },
  32338. destroy: function() {
  32339. var me = this;
  32340. me.items = me.map = me.keys = me.indexMap = null;
  32341. me.callParent();
  32342. },
  32343. allowFunctions: false,
  32344. add: function(key, obj) {
  32345. var len = this.length,
  32346. out;
  32347. if (arguments.length === 1) {
  32348. out = this.insert(len, key);
  32349. } else {
  32350. out = this.insert(len, key, obj);
  32351. }
  32352. return out;
  32353. },
  32354. getKey: function(item) {
  32355. return item.id;
  32356. },
  32357. replace: function(key, o) {
  32358. var me = this,
  32359. old, index;
  32360. if (arguments.length === 1) {
  32361. o = arguments[0];
  32362. key = me.getKey(o);
  32363. }
  32364. old = me.map[key];
  32365. if (typeof key === 'undefined' || key === null || typeof old === 'undefined') {
  32366. return me.add(key, o);
  32367. }
  32368. me.generation++;
  32369. index = me.indexOfKey(key);
  32370. me.items[index] = o;
  32371. me.map[key] = o;
  32372. if (me.hasListeners.replace) {
  32373. me.fireEvent('replace', key, old, o);
  32374. }
  32375. return o;
  32376. },
  32377. reorder: function(mapping) {
  32378. var me = this,
  32379. items = me.items,
  32380. index = 0,
  32381. length = items.length,
  32382. order = [],
  32383. remaining = [],
  32384. oldIndex;
  32385. me.suspendEvents();
  32386. for (oldIndex in mapping) {
  32387. order[mapping[oldIndex]] = items[oldIndex];
  32388. }
  32389. for (index = 0; index < length; index++) {
  32390. if (mapping[index] == undefined) {
  32391. remaining.push(items[index]);
  32392. }
  32393. }
  32394. for (index = 0; index < length; index++) {
  32395. if (order[index] == undefined) {
  32396. order[index] = remaining.shift();
  32397. }
  32398. }
  32399. me.clear();
  32400. me.addAll(order);
  32401. me.resumeEvents();
  32402. },
  32403. updateKey: function(oldKey, newKey) {
  32404. var me = this,
  32405. map = me.map,
  32406. index = me.indexOfKey(oldKey),
  32407. indexMap = me.indexMap,
  32408. item;
  32409. if (index > -1) {
  32410. item = map[oldKey];
  32411. delete map[oldKey];
  32412. delete indexMap[oldKey];
  32413. map[newKey] = item;
  32414. indexMap[newKey] = index;
  32415. me.keys[index] = newKey;
  32416. me.indexGeneration = ++me.generation;
  32417. }
  32418. },
  32419. addAll: function(objs) {
  32420. var me = this,
  32421. key;
  32422. if (arguments.length > 1 || Ext.isArray(objs)) {
  32423. me.insert(me.length, arguments.length > 1 ? arguments : objs);
  32424. } else {
  32425. for (key in objs) {
  32426. if (objs.hasOwnProperty(key)) {
  32427. if (me.allowFunctions || typeof objs[key] !== 'function') {
  32428. me.add(key, objs[key]);
  32429. }
  32430. }
  32431. }
  32432. }
  32433. },
  32434. each: function(fn, scope) {
  32435. var items = Ext.Array.push([], this.items),
  32436. i = 0,
  32437. len = items.length,
  32438. item;
  32439. for (; i < len; i++) {
  32440. item = items[i];
  32441. if (fn.call(scope || item, item, i, len) === false) {
  32442. break;
  32443. }
  32444. }
  32445. },
  32446. eachKey: function(fn, scope) {
  32447. var keys = this.keys,
  32448. items = this.items,
  32449. i = 0,
  32450. len = keys.length;
  32451. for (; i < len; i++) {
  32452. fn.call(scope || window, keys[i], items[i], i, len);
  32453. }
  32454. },
  32455. findBy: function(fn, scope) {
  32456. var keys = this.keys,
  32457. items = this.items,
  32458. i = 0,
  32459. len = items.length;
  32460. for (; i < len; i++) {
  32461. if (fn.call(scope || window, items[i], keys[i])) {
  32462. return items[i];
  32463. }
  32464. }
  32465. return null;
  32466. },
  32467. insert: function(index, key, obj) {
  32468. var out;
  32469. if (Ext.isIterable(key)) {
  32470. out = this.doInsert(index, key, obj);
  32471. } else {
  32472. if (arguments.length > 2) {
  32473. out = this.doInsert(index, [
  32474. key
  32475. ], [
  32476. obj
  32477. ]);
  32478. } else {
  32479. out = this.doInsert(index, [
  32480. key
  32481. ]);
  32482. }
  32483. out = out[0];
  32484. }
  32485. return out;
  32486. },
  32487. doInsert: function(index, keys, objects) {
  32488. var me = this,
  32489. itemKey, removeIndex, i,
  32490. len = keys.length,
  32491. deDupedLen = len,
  32492. fireAdd = me.hasListeners.add,
  32493. syncIndices,
  32494. newKeys = {},
  32495. passedDuplicates, oldKeys, oldObjects;
  32496. if (objects != null) {
  32497. me.useLinearSearch = true;
  32498. } else
  32499. {
  32500. objects = keys;
  32501. keys = new Array(len);
  32502. for (i = 0; i < len; i++) {
  32503. keys[i] = this.getKey(objects[i]);
  32504. }
  32505. }
  32506. me.suspendEvents();
  32507. for (i = 0; i < len; i++) {
  32508. itemKey = keys[i];
  32509. removeIndex = me.indexOfKey(itemKey);
  32510. if (removeIndex !== -1) {
  32511. if (removeIndex < index) {
  32512. index--;
  32513. }
  32514. me.removeAt(removeIndex);
  32515. }
  32516. if (itemKey != null) {
  32517. if (newKeys[itemKey] != null) {
  32518. passedDuplicates = true;
  32519. deDupedLen--;
  32520. }
  32521. newKeys[itemKey] = i;
  32522. }
  32523. }
  32524. me.resumeEvents();
  32525. if (passedDuplicates) {
  32526. oldKeys = keys;
  32527. oldObjects = objects;
  32528. keys = new Array(deDupedLen);
  32529. objects = new Array(deDupedLen);
  32530. i = 0;
  32531. for (itemKey in newKeys) {
  32532. keys[i] = oldKeys[newKeys[itemKey]];
  32533. objects[i] = oldObjects[newKeys[itemKey]];
  32534. i++;
  32535. }
  32536. len = deDupedLen;
  32537. }
  32538. syncIndices = index === me.length && me.indexGeneration === me.generation;
  32539. Ext.Array.insert(me.items, index, objects);
  32540. Ext.Array.insert(me.keys, index, keys);
  32541. me.length += len;
  32542. me.generation++;
  32543. if (syncIndices) {
  32544. me.indexGeneration = me.generation;
  32545. }
  32546. for (i = 0; i < len; i++ , index++) {
  32547. itemKey = keys[i];
  32548. if (itemKey != null) {
  32549. me.map[itemKey] = objects[i];
  32550. if (syncIndices) {
  32551. me.indexMap[itemKey] = index;
  32552. }
  32553. }
  32554. if (fireAdd) {
  32555. me.fireEvent('add', index, objects[i], itemKey);
  32556. }
  32557. }
  32558. return objects;
  32559. },
  32560. remove: function(o) {
  32561. var me = this,
  32562. removeKey, index;
  32563. if (!me.useLinearSearch && (removeKey = me.getKey(o))) {
  32564. index = me.indexOfKey(removeKey);
  32565. } else
  32566. {
  32567. index = Ext.Array.indexOf(me.items, o);
  32568. }
  32569. return (index === -1) ? false : me.removeAt(index);
  32570. },
  32571. removeAll: function(items) {
  32572. var me = this,
  32573. i;
  32574. if (items || me.hasListeners.remove) {
  32575. if (items) {
  32576. for (i = items.length - 1; i >= 0; --i) {
  32577. me.remove(items[i]);
  32578. }
  32579. } else {
  32580. while (me.length) {
  32581. me.removeAt(0);
  32582. }
  32583. }
  32584. } else {
  32585. me.length = me.items.length = me.keys.length = 0;
  32586. me.map = {};
  32587. me.indexMap = {};
  32588. me.generation++;
  32589. me.indexGeneration = me.generation;
  32590. }
  32591. },
  32592. removeAt: function(index) {
  32593. var me = this,
  32594. o, key;
  32595. if (index < me.length && index >= 0) {
  32596. me.length--;
  32597. o = me.items[index];
  32598. Ext.Array.erase(me.items, index, 1);
  32599. key = me.keys[index];
  32600. if (typeof key !== 'undefined') {
  32601. delete me.map[key];
  32602. }
  32603. Ext.Array.erase(me.keys, index, 1);
  32604. if (me.hasListeners.remove) {
  32605. me.fireEvent('remove', o, key);
  32606. }
  32607. me.generation++;
  32608. return o;
  32609. }
  32610. return false;
  32611. },
  32612. removeRange: function(index, removeCount) {
  32613. var me = this,
  32614. o, key, i, limit, syncIndices, trimming;
  32615. if (index < me.length && index >= 0) {
  32616. if (!removeCount) {
  32617. removeCount = 1;
  32618. }
  32619. limit = Math.min(index + removeCount, me.length);
  32620. removeCount = limit - index;
  32621. trimming = limit === me.length;
  32622. syncIndices = trimming && me.indexGeneration === me.generation;
  32623. for (i = index; i < limit; i++) {
  32624. key = me.keys[i];
  32625. if (key != null) {
  32626. delete me.map[key];
  32627. if (syncIndices) {
  32628. delete me.indexMap[key];
  32629. }
  32630. }
  32631. }
  32632. o = me.items[i - 1];
  32633. me.length -= removeCount;
  32634. me.generation++;
  32635. if (syncIndices) {
  32636. me.indexGeneration = me.generation;
  32637. }
  32638. if (trimming) {
  32639. me.items.length = me.keys.length = me.length;
  32640. } else {
  32641. me.items.splice(index, removeCount);
  32642. me.keys.splice(index, removeCount);
  32643. }
  32644. return o;
  32645. }
  32646. return false;
  32647. },
  32648. removeAtKey: function(key) {
  32649. var me = this,
  32650. keys = me.keys,
  32651. i;
  32652. if (key == null) {
  32653. for (i = keys.length - 1; i >= 0; i--) {
  32654. if (keys[i] == null) {
  32655. me.removeAt(i);
  32656. }
  32657. }
  32658. } else
  32659. {
  32660. return me.removeAt(me.indexOfKey(key));
  32661. }
  32662. },
  32663. getCount: function() {
  32664. return this.length;
  32665. },
  32666. indexOf: function(o) {
  32667. var me = this,
  32668. key;
  32669. if (o != null) {
  32670. if (!me.useLinearSearch && (key = me.getKey(o))) {
  32671. return this.indexOfKey(key);
  32672. }
  32673. return Ext.Array.indexOf(me.items, o);
  32674. }
  32675. return -1;
  32676. },
  32677. indexOfKey: function(key) {
  32678. if (!this.map.hasOwnProperty(key)) {
  32679. return -1;
  32680. }
  32681. if (this.indexGeneration !== this.generation) {
  32682. this.rebuildIndexMap();
  32683. }
  32684. return this.indexMap[key];
  32685. },
  32686. rebuildIndexMap: function() {
  32687. var me = this,
  32688. indexMap = me.indexMap = {},
  32689. keys = me.keys,
  32690. len = keys.length,
  32691. i;
  32692. for (i = 0; i < len; i++) {
  32693. indexMap[keys[i]] = i;
  32694. }
  32695. me.indexGeneration = me.generation;
  32696. },
  32697. get: function(key) {
  32698. var me = this,
  32699. mk = me.map[key],
  32700. item = mk !== undefined ? mk : (typeof key === 'number') ? me.items[key] : undefined;
  32701. return typeof item !== 'function' || me.allowFunctions ? item : null;
  32702. },
  32703. getAt: function(index) {
  32704. return this.items[index];
  32705. },
  32706. getByKey: function(key) {
  32707. return this.map[key];
  32708. },
  32709. contains: function(o) {
  32710. var me = this,
  32711. key;
  32712. if (o != null) {
  32713. if (!me.useLinearSearch && (key = me.getKey(o))) {
  32714. return this.map[key] != null;
  32715. }
  32716. return Ext.Array.indexOf(this.items, o) !== -1;
  32717. }
  32718. return false;
  32719. },
  32720. containsKey: function(key) {
  32721. return this.map.hasOwnProperty(key);
  32722. },
  32723. clear: function() {
  32724. var me = this;
  32725. if (me.generation) {
  32726. me.length = 0;
  32727. me.items = [];
  32728. me.keys = [];
  32729. me.map = {};
  32730. me.indexMap = {};
  32731. me.generation++;
  32732. me.indexGeneration = me.generation;
  32733. }
  32734. if (me.hasListeners.clear) {
  32735. me.fireEvent('clear');
  32736. }
  32737. },
  32738. first: function() {
  32739. return this.items[0];
  32740. },
  32741. last: function() {
  32742. return this.items[this.length - 1];
  32743. },
  32744. sum: function(property, root, start, end) {
  32745. var values = this.extractValues(property, root),
  32746. length = values.length,
  32747. sum = 0,
  32748. i;
  32749. start = start || 0;
  32750. end = (end || end === 0) ? end : length - 1;
  32751. for (i = start; i <= end; i++) {
  32752. sum += values[i];
  32753. }
  32754. return sum;
  32755. },
  32756. collect: function(property, root, allowNull) {
  32757. var values = this.extractValues(property, root),
  32758. length = values.length,
  32759. hits = {},
  32760. unique = [],
  32761. value, strValue, i;
  32762. for (i = 0; i < length; i++) {
  32763. value = values[i];
  32764. strValue = String(value);
  32765. if ((allowNull || !Ext.isEmpty(value)) && !hits[strValue]) {
  32766. hits[strValue] = true;
  32767. unique.push(value);
  32768. }
  32769. }
  32770. return unique;
  32771. },
  32772. extractValues: function(property, root) {
  32773. var values = this.items;
  32774. if (root) {
  32775. values = Ext.Array.pluck(values, root);
  32776. }
  32777. return Ext.Array.pluck(values, property);
  32778. },
  32779. hasRange: function(start, end) {
  32780. return (end < this.length);
  32781. },
  32782. getRange: function(start, end) {
  32783. var me = this,
  32784. items = me.items,
  32785. range = [],
  32786. len = items.length,
  32787. tmp, reverse;
  32788. if (len < 1) {
  32789. return range;
  32790. }
  32791. if (start > end) {
  32792. reverse = true;
  32793. tmp = start;
  32794. start = end;
  32795. end = tmp;
  32796. }
  32797. if (start < 0) {
  32798. start = 0;
  32799. }
  32800. if (end == null || end >= len) {
  32801. end = len - 1;
  32802. }
  32803. range = items.slice(start, end + 1);
  32804. if (reverse && range.length) {
  32805. range.reverse();
  32806. }
  32807. return range;
  32808. },
  32809. filter: function(property, value, anyMatch, caseSensitive) {
  32810. var filters = [];
  32811. if (Ext.isString(property)) {
  32812. filters.push(new Ext.util.Filter({
  32813. property: property,
  32814. value: value,
  32815. anyMatch: anyMatch,
  32816. caseSensitive: caseSensitive
  32817. }));
  32818. } else if (Ext.isArray(property) || property instanceof Ext.util.Filter) {
  32819. filters = filters.concat(property);
  32820. }
  32821. return this.filterBy(Ext.util.Filter.createFilterFn(filters));
  32822. },
  32823. filterBy: function(fn, scope) {
  32824. var me = this,
  32825. newMC = new me.self(me.initialConfig),
  32826. keys = me.keys,
  32827. items = me.items,
  32828. length = items.length,
  32829. i;
  32830. newMC.getKey = me.getKey;
  32831. for (i = 0; i < length; i++) {
  32832. if (fn.call(scope || me, items[i], keys[i])) {
  32833. newMC.add(keys[i], items[i]);
  32834. }
  32835. }
  32836. newMC.useLinearSearch = me.useLinearSearch;
  32837. return newMC;
  32838. },
  32839. findIndex: function(property, value, start, anyMatch, caseSensitive) {
  32840. if (Ext.isEmpty(value, false)) {
  32841. return -1;
  32842. }
  32843. value = this.createValueMatcher(value, anyMatch, caseSensitive);
  32844. return this.findIndexBy(function(o) {
  32845. return o && value.test(o[property]);
  32846. }, null, start);
  32847. },
  32848. findIndexBy: function(fn, scope, start) {
  32849. var me = this,
  32850. keys = me.keys,
  32851. items = me.items,
  32852. i = start || 0,
  32853. len = items.length;
  32854. for (; i < len; i++) {
  32855. if (fn.call(scope || me, items[i], keys[i])) {
  32856. return i;
  32857. }
  32858. }
  32859. return -1;
  32860. },
  32861. createValueMatcher: function(value, anyMatch, caseSensitive, exactMatch) {
  32862. var er;
  32863. if (!value.exec) {
  32864. er = Ext.String.escapeRegex;
  32865. value = String(value);
  32866. if (anyMatch === true) {
  32867. value = er(value);
  32868. } else {
  32869. value = '^' + er(value);
  32870. if (exactMatch === true) {
  32871. value += '$';
  32872. }
  32873. }
  32874. value = new RegExp(value, caseSensitive ? '' : 'i');
  32875. }
  32876. return value;
  32877. },
  32878. clone: function() {
  32879. var me = this,
  32880. copy = new me.self(me.initialConfig);
  32881. copy.add(me.keys, me.items);
  32882. copy.useLinearSearch = me.useLinearSearch;
  32883. return copy;
  32884. }
  32885. });
  32886. Ext.define('Ext.util.Sorter', {
  32887. isSorter: true,
  32888. config: {
  32889. property: null,
  32890. sorterFn: null,
  32891. root: null,
  32892. transform: null,
  32893. direction: "ASC",
  32894. id: undefined
  32895. },
  32896. statics: {
  32897. createComparator: function(sorters, nextFn) {
  32898. nextFn = nextFn || 0;
  32899. return function(lhs, rhs) {
  32900. var items = sorters.isCollection ? sorters.items : sorters,
  32901. n = items.length,
  32902. comp, i;
  32903. for (i = 0; i < n; ++i) {
  32904. comp = items[i].sort(lhs, rhs);
  32905. if (comp) {
  32906. return comp;
  32907. }
  32908. }
  32909. return nextFn && nextFn(lhs, rhs);
  32910. };
  32911. }
  32912. },
  32913. multiplier: 1,
  32914. constructor: function(config) {
  32915. if (config && !this.isGrouper) {
  32916. if (!config.property === !config.sorterFn) {
  32917. Ext.raise("A Sorter requires either a property or a sorterFn.");
  32918. }
  32919. }
  32920. this.initConfig(config);
  32921. },
  32922. getId: function() {
  32923. var id = this._id;
  32924. if (!id) {
  32925. id = this.getProperty();
  32926. if (!id) {
  32927. id = Ext.id(null, 'ext-sorter-');
  32928. }
  32929. this._id = id;
  32930. }
  32931. return id;
  32932. },
  32933. sort: function(lhs, rhs) {
  32934. return this.multiplier * this.sortFn(lhs, rhs);
  32935. },
  32936. sortFn: function(item1, item2) {
  32937. var me = this,
  32938. transform = me._transform,
  32939. root = me._root,
  32940. property = me._property,
  32941. lhs, rhs;
  32942. if (root) {
  32943. item1 = item1[root];
  32944. item2 = item2[root];
  32945. }
  32946. lhs = item1[property];
  32947. rhs = item2[property];
  32948. if (transform) {
  32949. lhs = transform(lhs);
  32950. rhs = transform(rhs);
  32951. }
  32952. return (lhs > rhs) ? 1 : (lhs < rhs ? -1 : 0);
  32953. },
  32954. applyDirection: function(direction) {
  32955. return direction ? direction : 'ASC';
  32956. },
  32957. updateDirection: function(direction) {
  32958. this.multiplier = (direction.toUpperCase() === "DESC") ? -1 : 1;
  32959. },
  32960. updateProperty: function(property) {
  32961. if (property) {
  32962. delete this.sortFn;
  32963. }
  32964. },
  32965. updateSorterFn: function(sorterFn) {
  32966. this.sortFn = sorterFn;
  32967. },
  32968. toggle: function() {
  32969. this.setDirection(Ext.String.toggle(this.getDirection(), "ASC", "DESC"));
  32970. },
  32971. getState: function() {
  32972. var me = this,
  32973. result = {
  32974. root: me.getRoot(),
  32975. property: me.getProperty(),
  32976. direction: me.getDirection()
  32977. };
  32978. if (me._id) {
  32979. result.id = me._id;
  32980. }
  32981. return result;
  32982. },
  32983. serialize: function() {
  32984. return {
  32985. property: this.getProperty(),
  32986. direction: this.getDirection()
  32987. };
  32988. }
  32989. });
  32990. Ext.define("Ext.util.Sortable", {
  32991. isSortable: true,
  32992. $configPrefixed: false,
  32993. $configStrict: false,
  32994. config: {
  32995. sorters: null
  32996. },
  32997. defaultSortDirection: "ASC",
  32998. multiSortLimit: 3,
  32999. statics: {
  33000. createComparator: function(sorters) {
  33001. return sorters && sorters.length ? function(r1, r2) {
  33002. var result = sorters[0].sort(r1, r2),
  33003. length = sorters.length,
  33004. i = 1;
  33005. for (; !result && i < length; i++) {
  33006. result = sorters[i].sort.call(sorters[i], r1, r2);
  33007. }
  33008. return result;
  33009. } : function() {
  33010. return 0;
  33011. };
  33012. }
  33013. },
  33014. applySorters: function(sorters) {
  33015. var me = this,
  33016. sortersCollection;
  33017. sortersCollection = me.getSorters() || new Ext.util.MixedCollection(false, Ext.returnId);
  33018. if (sorters) {
  33019. sortersCollection.addAll(me.decodeSorters(sorters));
  33020. }
  33021. return sortersCollection;
  33022. },
  33023. sort: function(sorters, direction, insertionPosition, doSort) {
  33024. var me = this,
  33025. sorter, overFlow,
  33026. currentSorters = me.getSorters();
  33027. if (!currentSorters) {
  33028. me.setSorters(null);
  33029. currentSorters = me.getSorters();
  33030. }
  33031. if (Ext.isArray(sorters)) {
  33032. doSort = insertionPosition;
  33033. insertionPosition = direction;
  33034. } else if (Ext.isObject(sorters)) {
  33035. sorters = [
  33036. sorters
  33037. ];
  33038. doSort = insertionPosition;
  33039. insertionPosition = direction;
  33040. } else if (Ext.isString(sorters)) {
  33041. sorter = currentSorters.get(sorters);
  33042. if (!sorter) {
  33043. sorter = {
  33044. property: sorters,
  33045. direction: direction
  33046. };
  33047. } else if (direction == null) {
  33048. sorter.toggle();
  33049. } else {
  33050. sorter.setDirection(direction);
  33051. }
  33052. sorters = [
  33053. sorter
  33054. ];
  33055. }
  33056. if (sorters && sorters.length) {
  33057. sorters = me.decodeSorters(sorters);
  33058. switch (insertionPosition) {
  33059. case "multi":
  33060. currentSorters.insert(0, sorters[0]);
  33061. overFlow = currentSorters.getCount() - me.multiSortLimit;
  33062. if (overFlow > 0) {
  33063. currentSorters.removeRange(me.multiSortLimit, overFlow);
  33064. };
  33065. break;
  33066. case "prepend":
  33067. currentSorters.insert(0, sorters);
  33068. break;
  33069. case "append":
  33070. currentSorters.addAll(sorters);
  33071. break;
  33072. case undefined:
  33073. case null:
  33074. case "replace":
  33075. currentSorters.clear();
  33076. currentSorters.addAll(sorters);
  33077. break;
  33078. default:
  33079. Ext.raise('Sorter insertion point must be "multi", "prepend", ' + '"append" or "replace"');
  33080. }
  33081. }
  33082. if (doSort !== false) {
  33083. me.fireEvent('beforesort', me, sorters);
  33084. me.onBeforeSort(sorters);
  33085. if (me.getSorterCount()) {
  33086. me.doSort(me.generateComparator());
  33087. }
  33088. }
  33089. return sorters;
  33090. },
  33091. getSorterCount: function() {
  33092. return this.getSorters().items.length;
  33093. },
  33094. generateComparator: function() {
  33095. var sorters = this.getSorters().getRange();
  33096. return sorters.length ? this.createComparator(sorters) : this.emptyComparator;
  33097. },
  33098. emptyComparator: function() {
  33099. return 0;
  33100. },
  33101. onBeforeSort: Ext.emptyFn,
  33102. decodeSorters: function(sorters) {
  33103. if (!Ext.isArray(sorters)) {
  33104. if (sorters === undefined) {
  33105. sorters = [];
  33106. } else {
  33107. sorters = [
  33108. sorters
  33109. ];
  33110. }
  33111. }
  33112. var length = sorters.length,
  33113. Sorter = Ext.util.Sorter,
  33114. model = this.getModel ? this.getModel() : this.model,
  33115. field, config, i;
  33116. for (i = 0; i < length; i++) {
  33117. config = sorters[i];
  33118. if (!(config instanceof Sorter)) {
  33119. if (Ext.isString(config)) {
  33120. config = {
  33121. property: config
  33122. };
  33123. }
  33124. Ext.applyIf(config, {
  33125. root: this.sortRoot,
  33126. direction: "ASC"
  33127. });
  33128. if (config.fn) {
  33129. config.sorterFn = config.fn;
  33130. }
  33131. if (typeof config === 'function') {
  33132. config = {
  33133. sorterFn: config
  33134. };
  33135. }
  33136. if (model && !config.transform) {
  33137. field = model.getField(config.property);
  33138. config.transform = field && field.sortType !== Ext.identityFn ? field.sortType : undefined;
  33139. }
  33140. sorters[i] = new Ext.util.Sorter(config);
  33141. }
  33142. }
  33143. return sorters;
  33144. },
  33145. getFirstSorter: function() {
  33146. var sorters = this.getSorters().items,
  33147. len = sorters.length,
  33148. i = 0,
  33149. sorter;
  33150. for (; i < len; ++i) {
  33151. sorter = sorters[i];
  33152. if (!sorter.isGrouper) {
  33153. return sorter;
  33154. }
  33155. }
  33156. return null;
  33157. }
  33158. }, function() {
  33159. this.prototype.createComparator = this.createComparator;
  33160. });
  33161. Ext.define('Ext.util.MixedCollection', {
  33162. extend: Ext.util.AbstractMixedCollection,
  33163. mixins: {
  33164. sortable: Ext.util.Sortable
  33165. },
  33166. constructor: function() {
  33167. this.initConfig();
  33168. this.callParent(arguments);
  33169. },
  33170. doSort: function(sorterFn) {
  33171. this.sortBy(sorterFn);
  33172. },
  33173. _sort: function(property, dir, fn) {
  33174. var me = this,
  33175. i, len,
  33176. dsc = String(dir).toUpperCase() === 'DESC' ? -1 : 1,
  33177. c = [],
  33178. keys = me.keys,
  33179. items = me.items,
  33180. o;
  33181. fn = fn || function(a, b) {
  33182. return a - b;
  33183. };
  33184. for (i = 0 , len = items.length; i < len; i++) {
  33185. c[c.length] = {
  33186. key: keys[i],
  33187. value: items[i],
  33188. index: i
  33189. };
  33190. }
  33191. Ext.Array.sort(c, function(a, b) {
  33192. return fn(a[property], b[property]) * dsc || (
  33193. a.index < b.index ? -1 : 1);
  33194. });
  33195. for (i = 0 , len = c.length; i < len; i++) {
  33196. o = c[i];
  33197. items[i] = o.value;
  33198. keys[i] = o.key;
  33199. me.indexMap[o.key] = i;
  33200. }
  33201. me.generation++;
  33202. me.indexGeneration = me.generation;
  33203. me.fireEvent('sort', me);
  33204. },
  33205. sortBy: function(sorterFn) {
  33206. var me = this,
  33207. items = me.items,
  33208. item,
  33209. keys = me.keys,
  33210. key,
  33211. length = items.length,
  33212. i;
  33213. for (i = 0; i < length; i++) {
  33214. items[i].$extCollectionIndex = i;
  33215. }
  33216. Ext.Array.sort(items, function(a, b) {
  33217. return sorterFn(a, b) || (
  33218. a.$extCollectionIndex < b.$extCollectionIndex ? -1 : 1);
  33219. });
  33220. for (i = 0; i < length; i++) {
  33221. item = items[i];
  33222. key = me.getKey(item);
  33223. keys[i] = key;
  33224. me.indexMap[key] = i;
  33225. delete item.$extCollectionIndex;
  33226. }
  33227. me.generation++;
  33228. me.indexGeneration = me.generation;
  33229. me.fireEvent('sort', me, items, keys);
  33230. },
  33231. findInsertionIndex: function(newItem, sorterFn) {
  33232. var me = this,
  33233. items = me.items,
  33234. start = 0,
  33235. end = items.length - 1,
  33236. middle, comparison;
  33237. if (!sorterFn) {
  33238. sorterFn = me.generateComparator();
  33239. }
  33240. while (start <= end) {
  33241. middle = (start + end) >> 1;
  33242. comparison = sorterFn(newItem, items[middle]);
  33243. if (comparison >= 0) {
  33244. start = middle + 1;
  33245. } else if (comparison < 0) {
  33246. end = middle - 1;
  33247. }
  33248. }
  33249. return start;
  33250. },
  33251. reorder: function(mapping) {
  33252. this.callParent([
  33253. mapping
  33254. ]);
  33255. this.fireEvent('sort', this);
  33256. },
  33257. sortByKey: function(dir, fn) {
  33258. this._sort('key', dir, fn || function(a, b) {
  33259. var v1 = String(a).toUpperCase(),
  33260. v2 = String(b).toUpperCase();
  33261. return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
  33262. });
  33263. }
  33264. });
  33265. Ext.define('Ext.util.CollectionKey', {
  33266. mixins: [
  33267. Ext.mixin.Identifiable
  33268. ],
  33269. isCollectionKey: true,
  33270. observerPriority: -200,
  33271. config: {
  33272. collection: null,
  33273. keyFn: null,
  33274. property: null,
  33275. rootProperty: null,
  33276. unique: true
  33277. },
  33278. generation: 0,
  33279. map: null,
  33280. mapRebuilds: 0,
  33281. constructor: function(config) {
  33282. this.initConfig(config);
  33283. if (!Ext.isFunction(this.getKey)) {
  33284. Ext.raise('CollectionKey requires a keyFn or property config');
  33285. }
  33286. },
  33287. get: function(key) {
  33288. var map = this.map || this.getMap();
  33289. return map[key] || null;
  33290. },
  33291. clear: function() {
  33292. this.map = null;
  33293. },
  33294. getRootProperty: function() {
  33295. var me = this,
  33296. root = this.callParent();
  33297. return root !== null ? root : me.getCollection().getRootProperty();
  33298. },
  33299. indexOf: function(key, startAt) {
  33300. var map = this.map || this.getMap(),
  33301. item = map[key],
  33302. collection = this.getCollection(),
  33303. length = collection.length,
  33304. i, index, items, n;
  33305. if (!item) {
  33306. return -1;
  33307. }
  33308. if (startAt === undefined) {
  33309. startAt = -1;
  33310. }
  33311. if (item instanceof Array) {
  33312. items = item;
  33313. index = length;
  33314. for (n = items.length; n-- > 0; ) {
  33315. i = collection.indexOf(items[n]);
  33316. if (i < index && i > startAt) {
  33317. index = i;
  33318. }
  33319. }
  33320. if (index === length) {
  33321. return -1;
  33322. }
  33323. } else {
  33324. index = collection.indexOf(item);
  33325. }
  33326. return (index > startAt) ? index : -1;
  33327. },
  33328. updateKey: function(item, oldKey) {
  33329. var me = this,
  33330. map = me.map,
  33331. bucket, index;
  33332. if (map) {
  33333. bucket = map[oldKey];
  33334. if (bucket instanceof Array) {
  33335. index = Ext.Array.indexOf(bucket, item);
  33336. if (index >= 0) {
  33337. if (bucket.length > 2) {
  33338. bucket.splice(index, 1);
  33339. } else {
  33340. map[oldKey] = bucket[1 - index];
  33341. }
  33342. }
  33343. }
  33344. else if (bucket) {
  33345. if (me.getUnique() && bucket !== item) {
  33346. Ext.raise('Incorrect oldKey "' + oldKey + '" for item with newKey "' + me.getKey(item) + '"');
  33347. }
  33348. delete map[oldKey];
  33349. }
  33350. me.add([
  33351. item
  33352. ]);
  33353. }
  33354. },
  33355. onCollectionAdd: function(collection, add) {
  33356. if (this.map) {
  33357. this.add(add.items);
  33358. }
  33359. },
  33360. onCollectionItemChange: function(collection, details) {
  33361. this.map = null;
  33362. },
  33363. onCollectionRefresh: function() {
  33364. this.map = null;
  33365. },
  33366. onCollectionRemove: function(collection, remove) {
  33367. var me = this,
  33368. map = me.map,
  33369. items = remove.items,
  33370. length = items.length,
  33371. i, key;
  33372. if (map) {
  33373. if (me.getUnique() && length < collection.length / 2) {
  33374. for (i = 0; i < length; ++i) {
  33375. key = me.getKey(items[i]);
  33376. delete map[key];
  33377. }
  33378. } else {
  33379. me.map = null;
  33380. }
  33381. }
  33382. },
  33383. add: function(items) {
  33384. var me = this,
  33385. map = me.map,
  33386. bucket, i, item, key, length, unique;
  33387. length = items.length;
  33388. unique = me.getUnique();
  33389. for (i = 0; i < length; ++i) {
  33390. key = me.getKey(item = items[i]);
  33391. if (unique || !(key in map)) {
  33392. map[key] = item;
  33393. } else {
  33394. if (!((bucket = map[key]) instanceof Array)) {
  33395. map[key] = bucket = [
  33396. bucket
  33397. ];
  33398. }
  33399. bucket.push(item);
  33400. }
  33401. }
  33402. },
  33403. applyKeyFn: function(keyFn) {
  33404. if (Ext.isString(keyFn)) {
  33405. this.getKey = function(item) {
  33406. return item[keyFn]();
  33407. };
  33408. } else {
  33409. this.getKey = keyFn;
  33410. }
  33411. },
  33412. updateProperty: function(property) {
  33413. var root = this.getRootProperty();
  33414. this.getKey = function(item) {
  33415. return (root ? item[root] : item)[property];
  33416. };
  33417. },
  33418. getMap: function() {
  33419. var me = this,
  33420. map = me.map;
  33421. if (!map) {
  33422. me.map = map = {};
  33423. me.keysByItemKey = {};
  33424. ++me.mapRebuilds;
  33425. me.add(me.getCollection().items);
  33426. }
  33427. return map;
  33428. },
  33429. updateCollection: function(collection, oldCollection) {
  33430. if (collection) {
  33431. collection.addObserver(this);
  33432. }
  33433. if (oldCollection) {
  33434. oldCollection.removeObserver(this);
  33435. }
  33436. },
  33437. clone: function() {
  33438. return new Ext.util.CollectionKey(this.getCurrentConfig());
  33439. },
  33440. destroy: function() {
  33441. this.clear();
  33442. this.getCollection().removeObserver(this);
  33443. this.destroyed = true;
  33444. }
  33445. });
  33446. Ext.define('Ext.util.Grouper', {
  33447. extend: Ext.util.Sorter,
  33448. isGrouper: true,
  33449. config: {
  33450. groupFn: null,
  33451. sortProperty: null
  33452. },
  33453. constructor: function(config) {
  33454. if (config) {
  33455. if (config.getGroupString) {
  33456. Ext.raise("Cannot set getGroupString - use groupFn instead");
  33457. }
  33458. }
  33459. this.callParent(arguments);
  33460. },
  33461. getGroupString: function(item) {
  33462. var group = item.$collapsedGroupPlaceholder ? item.$groupKey : this._groupFn(item);
  33463. return (group != null) ? String(group) : '';
  33464. },
  33465. sortFn: function(item1, item2) {
  33466. var me = this,
  33467. lhs = me.getGroupString(item1),
  33468. rhs = me.getGroupString(item2),
  33469. property = me._sortProperty,
  33470. root = me._root,
  33471. sorterFn = me._sorterFn,
  33472. transform = me._transform;
  33473. if (lhs === rhs) {
  33474. return 0;
  33475. }
  33476. if (property || sorterFn) {
  33477. if (sorterFn) {
  33478. return sorterFn.call(this, item1, item2);
  33479. }
  33480. if (root) {
  33481. item1 = item1[root];
  33482. item2 = item2[root];
  33483. }
  33484. lhs = item1[property];
  33485. rhs = item2[property];
  33486. if (transform) {
  33487. lhs = transform(lhs);
  33488. rhs = transform(rhs);
  33489. }
  33490. }
  33491. return (lhs > rhs) ? 1 : (lhs < rhs ? -1 : 0);
  33492. },
  33493. standardGroupFn: function(item) {
  33494. var root = this._root;
  33495. return (root ? item[root] : item)[this._property];
  33496. },
  33497. updateSorterFn: function() {},
  33498. updateProperty: function() {
  33499. if (!this.getGroupFn()) {
  33500. this.setGroupFn(this.standardGroupFn);
  33501. }
  33502. }
  33503. });
  33504. Ext.define('Ext.util.Collection', {
  33505. mixins: [
  33506. Ext.mixin.Observable
  33507. ],
  33508. isCollection: true,
  33509. config: {
  33510. autoFilter: true,
  33511. autoSort: true,
  33512. autoGroup: true,
  33513. decoder: null,
  33514. extraKeys: null,
  33515. filters: null,
  33516. grouper: null,
  33517. groups: null,
  33518. groupConfig: null,
  33519. rootProperty: null,
  33520. sorters: null,
  33521. multiSortLimit: 3,
  33522. defaultSortDirection: 'ASC',
  33523. source: null,
  33524. trackGroups: true
  33525. },
  33526. generation: 0,
  33527. indices: null,
  33528. indexRebuilds: 0,
  33529. updating: 0,
  33530. grouped: false,
  33531. sorted: false,
  33532. filtered: false,
  33533. $endUpdatePriority: 1001,
  33534. manageSorters: true,
  33535. constructor: function(config) {
  33536. var me = this;
  33537. me.callParent([
  33538. config
  33539. ]);
  33540. me.items = [];
  33541. me.map = {};
  33542. me.length = 0;
  33543. if (config && config.keyFn) {
  33544. me.getKey = config.keyFn;
  33545. }
  33546. me.mixins.observable.constructor.call(me, config);
  33547. },
  33548. destroy: function() {
  33549. var me = this,
  33550. filters = me._filters,
  33551. sorters = me._sorters,
  33552. groups = me._groups;
  33553. if (filters) {
  33554. filters.destroy();
  33555. me._filters = null;
  33556. }
  33557. if (sorters) {
  33558. me.grouped = me.sorted = false;
  33559. me.setSorters(null);
  33560. if (me.manageSorters) {
  33561. sorters.destroy();
  33562. }
  33563. }
  33564. if (groups) {
  33565. groups.destroy();
  33566. me._groups = null;
  33567. }
  33568. me.setSource(null);
  33569. me.observers = me.items = me.map = null;
  33570. me.callParent();
  33571. },
  33572. add: function(item) {
  33573. var me = this,
  33574. items = me.decodeItems(arguments, 0),
  33575. ret = items;
  33576. if (items.length) {
  33577. me.splice(me.length, 0, items);
  33578. ret = (items.length === 1) ? items[0] : items;
  33579. }
  33580. return ret;
  33581. },
  33582. replaceAll: function() {
  33583. var me = this,
  33584. ret, items;
  33585. items = me.decodeItems(arguments, 0);
  33586. ret = items;
  33587. if (items.length) {
  33588. me.splice(0, me.length, items);
  33589. ret = (items.length === 1) ? items[0] : items;
  33590. } else {
  33591. me.removeAll();
  33592. }
  33593. return ret;
  33594. },
  33595. aggregate: function(property, operation, begin, end, scope) {
  33596. var me = this,
  33597. args = Ext.Array.slice(arguments);
  33598. args.unshift(me.items);
  33599. return me.aggregateItems.apply(me, args);
  33600. },
  33601. aggregateByGroup: function(property, operation, scope) {
  33602. var groups = this.getGroups();
  33603. return this.aggregateGroups(groups, property, operation, scope);
  33604. },
  33605. aggregateItems: function(items, property, operation, begin, end, scope) {
  33606. var me = this,
  33607. range = Ext.Number.clipIndices(items.length, [
  33608. begin,
  33609. end
  33610. ]),
  33611. subsetRequested = (begin !== 0 && end !== items.length),
  33612. i, j, rangeLen, root, value, values, valueItems;
  33613. begin = range[0];
  33614. end = range[1];
  33615. if (!Ext.isFunction(operation)) {
  33616. operation = me._aggregators[operation];
  33617. return operation.call(me, items, begin, end, property, me.getRootProperty());
  33618. }
  33619. root = me.getRootProperty();
  33620. values = new Array(rangeLen);
  33621. valueItems = subsetRequested ? new Array(rangeLen) : items;
  33622. for (i = begin , j = 0; i < end; ++i , j++) {
  33623. if (subsetRequested) {
  33624. valueItems[j] = value = items[i];
  33625. }
  33626. values[j] = (root ? value[root] : value)[property];
  33627. }
  33628. return operation.call(scope || me, items, values, 0);
  33629. },
  33630. aggregateGroups: function(groups, property, operation, scope) {
  33631. var items = groups.items,
  33632. len = items.length,
  33633. callDirect = !Ext.isFunction(operation),
  33634. out = {},
  33635. i, group, result;
  33636. for (i = 0; i < len; ++i) {
  33637. group = items[i];
  33638. if (!callDirect) {
  33639. result = this.aggregateItems(group.items, property, operation, null, null, scope);
  33640. } else {
  33641. result = group[operation](property);
  33642. }
  33643. out[group.getGroupKey()] = result;
  33644. }
  33645. return out;
  33646. },
  33647. beginUpdate: function() {
  33648. if (!this.updating++) {
  33649. this.notify('beginupdate');
  33650. }
  33651. },
  33652. clear: function() {
  33653. var me = this,
  33654. generation = me.generation,
  33655. ret = generation ? me.items : [],
  33656. extraKeys, indexName;
  33657. if (generation) {
  33658. me.items.length = me.length = 0;
  33659. me.map = {};
  33660. me.indices = {};
  33661. me.generation++;
  33662. extraKeys = me.getExtraKeys();
  33663. if (extraKeys) {
  33664. for (indexName in extraKeys) {
  33665. extraKeys[indexName].clear();
  33666. }
  33667. }
  33668. }
  33669. return ret;
  33670. },
  33671. clone: function() {
  33672. var me = this,
  33673. copy = new me.self(me.initialConfig);
  33674. copy.add(me.items);
  33675. return copy;
  33676. },
  33677. collect: function(property, root, allowNull) {
  33678. var items = this.items,
  33679. length = items.length,
  33680. map = {},
  33681. ret = [],
  33682. i, strValue, value;
  33683. for (i = 0; i < length; ++i) {
  33684. value = items[i];
  33685. value = (root ? value[root] : value)[property];
  33686. strValue = String(value);
  33687. if ((allowNull || !Ext.isEmpty(value)) && !map[strValue]) {
  33688. map[strValue] = 1;
  33689. ret.push(value);
  33690. }
  33691. }
  33692. return ret;
  33693. },
  33694. contains: function(item) {
  33695. var ret = false,
  33696. key;
  33697. if (item != null) {
  33698. key = this.getKey(item);
  33699. ret = this.map[key] === item;
  33700. }
  33701. return ret;
  33702. },
  33703. containsAll: function(items) {
  33704. var all = Ext.isArray(items) ? items : arguments,
  33705. i;
  33706. for (i = all.length; i-- > 0; ) {
  33707. if (!this.contains(all[i])) {
  33708. return false;
  33709. }
  33710. }
  33711. return true;
  33712. },
  33713. containsKey: function(key) {
  33714. return key in this.map;
  33715. },
  33716. createFiltered: function(property, value, anyMatch, caseSensitive, exactMatch) {
  33717. var me = this,
  33718. ret = new me.self(Ext.applyIf({
  33719. source: null
  33720. }, me.initialConfig)),
  33721. root = me.getRootProperty(),
  33722. items = me.items,
  33723. length, i, filters, fn, scope;
  33724. if (Ext.isFunction(property)) {
  33725. fn = property;
  33726. scope = value;
  33727. } else {
  33728. if (Ext.isString(property)) {
  33729. filters = [
  33730. new Ext.util.Filter({
  33731. property: property,
  33732. value: value,
  33733. root: root,
  33734. anyMatch: anyMatch,
  33735. caseSensitive: caseSensitive,
  33736. exactMatch: exactMatch
  33737. })
  33738. ];
  33739. } else if (property instanceof Ext.util.Filter) {
  33740. filters = [
  33741. property
  33742. ];
  33743. property.setRoot(root);
  33744. } else if (Ext.isArray(property)) {
  33745. filters = property.slice(0);
  33746. for (i = 0 , length = filters.length; i < length; ++i) {
  33747. filters[i].setRoot(root);
  33748. }
  33749. }
  33750. fn = Ext.util.Filter.createFilterFn(filters);
  33751. }
  33752. scope = scope || me;
  33753. for (i = 0 , length = items.length; i < length; i++) {
  33754. if (fn.call(scope, items[i])) {
  33755. ret.add(items[i]);
  33756. }
  33757. }
  33758. return ret;
  33759. },
  33760. filterBy: function(fn, scope) {
  33761. return this.createFiltered(fn, scope);
  33762. },
  33763. each: function(fn, scope) {
  33764. var items = this.items,
  33765. len = items.length,
  33766. i, ret;
  33767. if (len) {
  33768. scope = scope || this;
  33769. items = items.slice(0);
  33770. for (i = 0; i < len; i++) {
  33771. ret = fn.call(scope, items[i], i, len);
  33772. if (ret === false) {
  33773. break;
  33774. }
  33775. }
  33776. }
  33777. return ret;
  33778. },
  33779. eachKey: function(fn, scope) {
  33780. var me = this,
  33781. items = me.items,
  33782. len = items.length,
  33783. i, item, key, ret;
  33784. if (len) {
  33785. scope = scope || me;
  33786. items = items.slice(0);
  33787. for (i = 0; i < len; i++) {
  33788. key = me.getKey(item = items[i]);
  33789. ret = fn.call(scope, key, item, i, len);
  33790. if (ret === false) {
  33791. break;
  33792. }
  33793. }
  33794. }
  33795. return ret;
  33796. },
  33797. endUpdate: function() {
  33798. if (!--this.updating) {
  33799. this.notify('endupdate');
  33800. }
  33801. },
  33802. find: function(property, value, start, startsWith, endsWith, ignoreCase) {
  33803. var regex, root;
  33804. if (Ext.isEmpty(value, false)) {
  33805. return null;
  33806. }
  33807. regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase);
  33808. root = this.getRootProperty();
  33809. return this.findBy(function(item) {
  33810. return item && regex.test((root ? item[root] : item)[property]);
  33811. }, null, start);
  33812. },
  33813. findBy: function(fn, scope, start) {
  33814. var me = this,
  33815. items = me.items,
  33816. len = items.length,
  33817. i, item, key;
  33818. scope = scope || me;
  33819. for (i = start || 0; i < len; i++) {
  33820. key = me.getKey(item = items[i]);
  33821. if (fn.call(scope, item, key)) {
  33822. return items[i];
  33823. }
  33824. }
  33825. return null;
  33826. },
  33827. findIndex: function(property, value, start, startsWith, endsWith, ignoreCase) {
  33828. var item = this.find(property, value, start, startsWith, endsWith, ignoreCase);
  33829. return item ? this.indexOf(item) : -1;
  33830. },
  33831. findIndexBy: function(fn, scope, start) {
  33832. var item = this.findBy(fn, scope, start);
  33833. return item ? this.indexOf(item) : -1;
  33834. },
  33835. first: function(grouped) {
  33836. var groups = grouped ? this.getGroups() : undefined;
  33837. return groups ? this.aggregateGroups(groups, null, 'first') : this.items[0];
  33838. },
  33839. last: function(grouped) {
  33840. var groups = grouped ? this.getGroups() : undefined;
  33841. return groups ? this.aggregateGroups(groups, null, 'last') : this.items[this.length - 1];
  33842. },
  33843. get: function(key) {
  33844. return this.map[key];
  33845. },
  33846. getAt: function(index) {
  33847. return this.items[index];
  33848. },
  33849. getByKey: function(key) {
  33850. return this.map[key];
  33851. },
  33852. getCount: function() {
  33853. return this.length;
  33854. },
  33855. getKey: function(item) {
  33856. var id = item.id;
  33857. return (id === 0 || id) ? id : ((id = item._id) === 0 || id) ? id : item.getId();
  33858. },
  33859. getRange: function(begin, end) {
  33860. var items = this.items,
  33861. length = items.length,
  33862. range;
  33863. if (begin > end) {
  33864. Ext.raise('Inverted range passed to Collection.getRange: [' + begin + ',' + end + ']');
  33865. }
  33866. if (!length) {
  33867. range = [];
  33868. } else {
  33869. range = Ext.Number.clipIndices(length, [
  33870. begin,
  33871. end
  33872. ]);
  33873. range = items.slice(range[0], range[1]);
  33874. }
  33875. return range;
  33876. },
  33877. getValues: function(property, root, start, end) {
  33878. var items = this.items,
  33879. range = Ext.Number.clipIndices(items.length, [
  33880. start,
  33881. end
  33882. ]),
  33883. ret = [],
  33884. i, value;
  33885. for (i = range[0] , end = range[1]; i < end; ++i) {
  33886. value = items[i];
  33887. value = (root ? value[root] : value)[property];
  33888. ret.push(value);
  33889. }
  33890. return ret;
  33891. },
  33892. indexOf: function(item) {
  33893. var key;
  33894. if (!item) {
  33895. return -1;
  33896. }
  33897. key = this.getKey(item);
  33898. return this.indexOfKey(key);
  33899. },
  33900. indexOfKey: function(key) {
  33901. var me = this,
  33902. indices = me.indices;
  33903. if (key in me.map) {
  33904. if (!indices) {
  33905. indices = me.getIndices();
  33906. }
  33907. return indices[key];
  33908. }
  33909. return -1;
  33910. },
  33911. insert: function(index, item) {
  33912. var me = this,
  33913. items = me.decodeItems(arguments, 1),
  33914. ret = items;
  33915. if (items.length) {
  33916. me.splice(index, 0, items);
  33917. ret = (items.length === 1) ? items[0] : items;
  33918. }
  33919. return ret;
  33920. },
  33921. itemChanged: function(item, modified, oldKey, meta) {
  33922. var me = this,
  33923. keyChanged = oldKey !== undefined,
  33924. filtered = me.filtered && me.getAutoFilter(),
  33925. filterChanged = false,
  33926. itemMovement = 0,
  33927. items = me.items,
  33928. last = me.length - 1,
  33929. sorted = me.sorted && last > 0 && me.getAutoSort(),
  33930. source = me.getSource(),
  33931. toRemove = 0,
  33932. itemFiltered = false,
  33933. wasFiltered = false,
  33934. details, newKey, sortFn, toAdd, index, newIndex;
  33935. if (source && !source.updating) {
  33936. me.sourceUpdating = true;
  33937. source.itemChanged(item, modified, oldKey, meta);
  33938. me.sourceUpdating = false;
  33939. } else
  33940. {
  33941. newKey = me.getKey(item);
  33942. if (filtered) {
  33943. index = me.indexOfKey(keyChanged ? oldKey : newKey);
  33944. wasFiltered = (index < 0);
  33945. itemFiltered = me.isItemFiltered(item);
  33946. filterChanged = (wasFiltered !== itemFiltered);
  33947. }
  33948. if (filterChanged) {
  33949. if (itemFiltered) {
  33950. toRemove = [
  33951. item
  33952. ];
  33953. newIndex = -1;
  33954. } else {
  33955. toAdd = [
  33956. item
  33957. ];
  33958. newIndex = me.length;
  33959. }
  33960. }
  33961. else if (sorted && !itemFiltered) {
  33962. if (!filtered) {
  33963. index = me.indexOfKey(keyChanged ? oldKey : newKey);
  33964. }
  33965. sortFn = me.getSortFn();
  33966. if (index !== -1) {
  33967. if (index && sortFn(items[index - 1], items[index]) > 0) {
  33968. itemMovement = -1;
  33969. newIndex = Ext.Array.binarySearch(items, item, 0, index, sortFn);
  33970. } else if (index < last && sortFn(items[index], items[index + 1]) > 0) {
  33971. itemMovement = 1;
  33972. newIndex = Ext.Array.binarySearch(items, item, index + 1, sortFn);
  33973. }
  33974. if (itemMovement) {
  33975. toAdd = [
  33976. item
  33977. ];
  33978. }
  33979. }
  33980. }
  33981. details = {
  33982. item: item,
  33983. key: newKey,
  33984. index: newIndex,
  33985. filterChanged: filterChanged,
  33986. keyChanged: keyChanged,
  33987. indexChanged: !!itemMovement,
  33988. filtered: itemFiltered,
  33989. oldIndex: index,
  33990. newIndex: newIndex,
  33991. wasFiltered: wasFiltered,
  33992. meta: meta
  33993. };
  33994. if (keyChanged) {
  33995. details.oldKey = oldKey;
  33996. }
  33997. if (modified) {
  33998. details.modified = modified;
  33999. }
  34000. ++me.generation;
  34001. me.beginUpdate();
  34002. me.notify('beforeitemchange', [
  34003. details
  34004. ]);
  34005. if (keyChanged) {
  34006. me.updateKey(item, oldKey, details);
  34007. }
  34008. if (toAdd || toRemove) {
  34009. me.splice(newIndex, toRemove, toAdd);
  34010. }
  34011. if (itemMovement > 0) {
  34012. details.newIndex--;
  34013. } else if (itemMovement < 0) {
  34014. details.oldIndex++;
  34015. }
  34016. me.notify(itemFiltered ? 'filtereditemchange' : 'itemchange', [
  34017. details
  34018. ]);
  34019. me.endUpdate();
  34020. }
  34021. },
  34022. remove: function(item) {
  34023. var me = this,
  34024. items = me.decodeRemoveItems(arguments, 0),
  34025. length = me.length;
  34026. me.splice(0, items);
  34027. return length - me.length;
  34028. },
  34029. removeAll: function() {
  34030. var me = this,
  34031. length = me.length;
  34032. if (me.generation && length) {
  34033. me.splice(0, length);
  34034. }
  34035. return me;
  34036. },
  34037. removeAt: function(index, count) {
  34038. var me = this,
  34039. length = me.length,
  34040. Num = Ext.Number,
  34041. range = Num.clipIndices(length, [
  34042. index,
  34043. (count === undefined) ? 1 : count
  34044. ], Num.Clip.COUNT),
  34045. n = range[0],
  34046. removeCount = range[1] - n,
  34047. item = (removeCount === 1) && me.getAt(n),
  34048. removed;
  34049. me.splice(n, removeCount);
  34050. removed = me.length - length;
  34051. return (item && removed) ? item : removed;
  34052. },
  34053. removeByKey: function(key) {
  34054. var item = this.getByKey(key);
  34055. if (!item || !this.remove(item)) {
  34056. return false;
  34057. }
  34058. return item;
  34059. },
  34060. replace: function(item) {
  34061. var index = this.indexOf(item);
  34062. if (index === -1) {
  34063. this.add(item);
  34064. } else {
  34065. this.insert(index, item);
  34066. }
  34067. },
  34068. splice: function(index, toRemove, toAdd) {
  34069. var me = this,
  34070. autoSort = me.sorted && me.getAutoSort(),
  34071. map = me.map,
  34072. items = me.items,
  34073. length = me.length,
  34074. removeItems = (toRemove instanceof Array) ? me.decodeRemoveItems(toRemove) : null,
  34075. isRemoveCount = !removeItems,
  34076. Num = Ext.Number,
  34077. range = Num.clipIndices(length, [
  34078. index,
  34079. isRemoveCount ? toRemove : 0
  34080. ], Num.Clip.COUNT),
  34081. begin = range[0],
  34082. end = range[1],
  34083. removeCount = end - begin,
  34084. newItems = me.decodeItems(arguments, 2),
  34085. newCount = newItems ? newItems.length : 0,
  34086. addItems, newItemsMap, removeMap,
  34087. insertAt = begin,
  34088. indices = me.indices || ((newCount || removeItems) ? me.getIndices() : null),
  34089. adds = null,
  34090. removes = removeCount ? [
  34091. begin
  34092. ] : null,
  34093. newKeys = null,
  34094. source = me.getSource(),
  34095. chunk, chunkItems, chunks, i, item, itemIndex, k, key, keys, n, duplicates, sorters;
  34096. if (source && !source.updating) {
  34097. if (isRemoveCount) {
  34098. removeItems = [];
  34099. for (i = 0; i < removeCount; ++i) {
  34100. removeItems.push(items[begin + i]);
  34101. }
  34102. }
  34103. if (begin < length) {
  34104. i = source.indexOf(items[begin]);
  34105. } else {
  34106. i = source.length;
  34107. }
  34108. me.requestedIndex = index;
  34109. source.splice(i, removeItems, newItems);
  34110. delete me.requestedIndex;
  34111. return me;
  34112. }
  34113. if (newCount) {
  34114. addItems = newItems;
  34115. newKeys = [];
  34116. newItemsMap = {};
  34117. if (autoSort) {
  34118. sorters = me.getSorters();
  34119. if (newCount > 1) {
  34120. if (!addItems.$cloned) {
  34121. newItems = addItems = addItems.slice(0);
  34122. }
  34123. me.sortData(addItems);
  34124. }
  34125. }
  34126. for (i = 0; i < newCount; ++i) {
  34127. key = me.getKey(item = newItems[i]);
  34128. if ((k = newItemsMap[key]) !== undefined) {
  34129. (duplicates || (duplicates = {}))[k] = 1;
  34130. } else {
  34131. itemIndex = indices[key];
  34132. if (itemIndex < begin || end <= itemIndex) {
  34133. (removes || (removes = [])).push(itemIndex);
  34134. }
  34135. }
  34136. newItemsMap[key] = i;
  34137. newKeys.push(key);
  34138. }
  34139. if (duplicates) {
  34140. keys = newKeys;
  34141. addItems = [];
  34142. newKeys = [];
  34143. addItems.$cloned = true;
  34144. for (i = 0; i < newCount; ++i) {
  34145. if (!duplicates[i]) {
  34146. item = newItems[i];
  34147. addItems.push(item);
  34148. newKeys.push(keys[i]);
  34149. }
  34150. }
  34151. newCount = addItems.length;
  34152. }
  34153. adds = {
  34154. items: addItems,
  34155. keys: newKeys
  34156. };
  34157. }
  34158. for (i = removeItems ? removeItems.length : 0; i-- > 0; ) {
  34159. key = me.getKey(removeItems[i]);
  34160. if ((itemIndex = indices[key]) !== undefined) {
  34161. (removes || (removes = [])).push(itemIndex);
  34162. }
  34163. }
  34164. if (!adds && !removes) {
  34165. return me;
  34166. }
  34167. me.beginUpdate();
  34168. if (removes) {
  34169. chunk = null;
  34170. chunks = [];
  34171. removeMap = {};
  34172. if (removes.length > 1) {
  34173. removes.sort(Ext.Array.numericSortFn);
  34174. }
  34175. for (i = 0 , n = removes.length; i < n; ++i) {
  34176. key = me.getKey(item = items[itemIndex = removes[i]]);
  34177. if (!(key in map)) {
  34178. continue;
  34179. }
  34180. delete map[key];
  34181. if (!chunk || itemIndex > (chunk.at + chunkItems.length)) {
  34182. chunks.push(chunk = {
  34183. at: itemIndex,
  34184. items: (chunkItems = []),
  34185. keys: (keys = []),
  34186. map: removeMap,
  34187. next: chunk,
  34188. replacement: adds
  34189. });
  34190. if (adds) {
  34191. adds.replaced = chunk;
  34192. }
  34193. }
  34194. chunkItems.push(removeMap[key] = item);
  34195. keys.push(key);
  34196. if (itemIndex < insertAt) {
  34197. --insertAt;
  34198. }
  34199. if (removeCount > 1 && itemIndex === begin) {
  34200. --removeCount;
  34201. removes[i--] = ++begin;
  34202. }
  34203. }
  34204. if (adds) {
  34205. adds.at = insertAt;
  34206. }
  34207. for (k = chunks.length; k-- > 0; ) {
  34208. chunk = chunks[k];
  34209. i = chunk.at;
  34210. n = chunk.items.length;
  34211. if (i + n < length) {
  34212. me.indices = indices = null;
  34213. }
  34214. me.length = length -= n;
  34215. items.splice(i, n);
  34216. if (indices) {
  34217. keys = chunk.keys;
  34218. for (i = 0; i < n; ++i) {
  34219. delete indices[keys[i]];
  34220. }
  34221. }
  34222. ++me.generation;
  34223. me.notify('remove', [
  34224. chunk
  34225. ]);
  34226. }
  34227. }
  34228. if (adds) {
  34229. if (autoSort && newCount > 1 && length) {
  34230. me.spliceMerge(addItems, newKeys);
  34231. } else {
  34232. if (autoSort) {
  34233. if (newCount > 1) {
  34234. insertAt = 0;
  34235. me.indices = indices = null;
  34236. } else {
  34237. insertAt = sorters.findInsertionIndex(adds.items[0], items, me.getSortFn(), index);
  34238. }
  34239. }
  34240. if (insertAt === length) {
  34241. end = insertAt;
  34242. for (i = addItems.length - 1; i >= 0; --i) {
  34243. items[end + i] = addItems[i];
  34244. }
  34245. indices = me.indices;
  34246. if (indices) {
  34247. for (i = 0; i < newCount; ++i) {
  34248. indices[newKeys[i]] = insertAt + i;
  34249. }
  34250. }
  34251. } else {
  34252. me.indices = null;
  34253. Ext.Array.insert(items, insertAt, addItems);
  34254. }
  34255. for (i = 0; i < newCount; ++i) {
  34256. map[newKeys[i]] = addItems[i];
  34257. }
  34258. me.length += newCount;
  34259. adds.at = insertAt;
  34260. adds.atItem = insertAt === 0 ? null : items[insertAt - 1];
  34261. ++me.generation;
  34262. me.notify('add', [
  34263. adds
  34264. ]);
  34265. }
  34266. }
  34267. me.endUpdate();
  34268. return me;
  34269. },
  34270. update: function(fn, scope) {
  34271. var me = this;
  34272. me.beginUpdate();
  34273. try {
  34274. return fn.call(scope || me, me);
  34275. } catch (e) {
  34276. Ext.log.error(this.$className + ': Unhandled Exception: ', e.description || e.message);
  34277. throw e;
  34278. } finally {
  34279. me.endUpdate();
  34280. }
  34281. },
  34282. updateKey: function(item, oldKey, details) {
  34283. var me = this,
  34284. map = me.map,
  34285. indices = me.indices,
  34286. source = me.getSource(),
  34287. newKey;
  34288. if (source && !source.updating) {
  34289. source.updateKey(item, oldKey);
  34290. } else if ((newKey = me.getKey(item)) !== oldKey) {
  34291. if (map[oldKey] === item && !(newKey in map)) {
  34292. delete map[oldKey];
  34293. me.updating++;
  34294. me.generation++;
  34295. map[newKey] = item;
  34296. if (indices) {
  34297. indices[newKey] = indices[oldKey];
  34298. delete indices[oldKey];
  34299. }
  34300. me.notify('updatekey', [
  34301. Ext.apply({
  34302. item: item,
  34303. newKey: newKey,
  34304. oldKey: oldKey
  34305. }, details)
  34306. ]);
  34307. me.updating--;
  34308. } else
  34309. {
  34310. if (newKey in map && map[newKey] !== item) {
  34311. Ext.raise('Duplicate newKey "' + newKey + '" for item with oldKey "' + oldKey + '"');
  34312. }
  34313. if (oldKey in map && map[oldKey] !== item) {
  34314. Ext.raise('Incorrect oldKey "' + oldKey + '" for item with newKey "' + newKey + '"');
  34315. }
  34316. }
  34317. }
  34318. },
  34319. findInsertIndex: function(item, defaultIndex) {
  34320. var source = this.getSource(),
  34321. sourceItems = source.items,
  34322. i = source.indexOf(item) - 1,
  34323. sourceItem, index;
  34324. while (i > -1) {
  34325. sourceItem = sourceItems[i];
  34326. index = this.indexOf(sourceItem);
  34327. if (index > -1) {
  34328. return index + 1;
  34329. }
  34330. --i;
  34331. }
  34332. return defaultIndex;
  34333. },
  34334. onCollectionAdd: function(source, details) {
  34335. var me = this,
  34336. atItem = details.atItem,
  34337. items = me.transformItems(details.items),
  34338. requestedIndex = me.requestedIndex,
  34339. filtered, index, copy, i, item, n;
  34340. if (requestedIndex !== undefined) {
  34341. index = requestedIndex;
  34342. } else {
  34343. item = atItem || source.items[1];
  34344. index = item ? me.indexOf(item) : -1;
  34345. if (index > -1) {
  34346. if (atItem) {
  34347. ++index;
  34348. }
  34349. }
  34350. else if (!me.sorted) {
  34351. index = me.findInsertIndex(items[0], details.at ? me.length : 0);
  34352. }
  34353. }
  34354. if (me.getAutoFilter() && me.filtered) {
  34355. for (i = 0 , n = items.length; i < n; ++i) {
  34356. item = items[i];
  34357. if (me.isItemFiltered(item)) {
  34358. if (!copy) {
  34359. copy = items.slice(0, i);
  34360. }
  34361. if (!filtered) {
  34362. filtered = [];
  34363. }
  34364. filtered.push(item);
  34365. } else if (copy) {
  34366. copy.push(item);
  34367. }
  34368. }
  34369. }
  34370. me.splice((index < 0) ? me.length : index, 0, copy || items);
  34371. if (filtered) {
  34372. me.notify('filteradd', [
  34373. filtered
  34374. ]);
  34375. }
  34376. },
  34377. onCollectionBeforeItemChange: function(source, details) {
  34378. var me = this;
  34379. me.onCollectionUpdateKey = null;
  34380. if (!me.sourceUpdating) {
  34381. me.notify('beforeitemchange', [
  34382. details
  34383. ]);
  34384. }
  34385. },
  34386. onCollectionBeginUpdate: function() {
  34387. this.beginUpdate();
  34388. },
  34389. onCollectionEndUpdate: function() {
  34390. this.endUpdate();
  34391. },
  34392. onCollectionItemChange: function(source, details) {
  34393. delete this.onCollectionUpdateKey;
  34394. this.itemChanged(details.item, details.modified, details.oldKey, details.meta);
  34395. },
  34396. onCollectionFilteredItemChange: function() {
  34397. delete this.onCollectionUpdateKey;
  34398. },
  34399. onCollectionRefresh: function(source) {
  34400. var me = this,
  34401. map = {},
  34402. indices = {},
  34403. items = me.items,
  34404. sourceItems = me.transformItems(source.items),
  34405. filterFn = me.getFilterFn(),
  34406. i, item, key, length, newLength;
  34407. if (me.filtered && me.getAutoFilter()) {
  34408. for (i = 0 , newLength = 0 , length = sourceItems.length; i < length; i++) {
  34409. if (filterFn(sourceItems[i])) {
  34410. items[newLength++] = sourceItems[i];
  34411. }
  34412. }
  34413. items.length = newLength;
  34414. } else {
  34415. items.length = 0;
  34416. items.push.apply(items, sourceItems);
  34417. }
  34418. if (me.sorted) {
  34419. me.sortData(items);
  34420. }
  34421. me.length = length = items.length;
  34422. me.map = map;
  34423. me.indices = indices;
  34424. for (i = 0; i < length; ++i) {
  34425. key = me.getKey(item = items[i]);
  34426. map[key] = item;
  34427. indices[key] = i;
  34428. }
  34429. ++me.generation;
  34430. me.notify('refresh');
  34431. },
  34432. onCollectionRemove: function(source, details) {
  34433. this.splice(0, details.items);
  34434. },
  34435. onCollectionUpdateKey: function(source, details) {
  34436. this.updateKey(details.item, details.oldKey, details);
  34437. },
  34438. _aggregators: {
  34439. average: function(items, begin, end, property, root) {
  34440. var n = end - begin;
  34441. return n && this._aggregators.sum.call(this, items, begin, end, property, root) / n;
  34442. },
  34443. bounds: function(items, begin, end, property, root) {
  34444. var value, max, min, i;
  34445. for (i = begin; i < end; ++i) {
  34446. value = items[i];
  34447. value = (root ? value[root] : value)[property];
  34448. if (!(value < max)) {
  34449. max = value;
  34450. }
  34451. if (!(value > min)) {
  34452. min = value;
  34453. }
  34454. }
  34455. return [
  34456. min,
  34457. max
  34458. ];
  34459. },
  34460. count: function(items) {
  34461. return items.length;
  34462. },
  34463. extremes: function(items, begin, end, property, root) {
  34464. var most = null,
  34465. least = null,
  34466. i, item, max, min, value;
  34467. for (i = begin; i < end; ++i) {
  34468. item = items[i];
  34469. value = (root ? item[root] : item)[property];
  34470. if (!(value < max)) {
  34471. max = value;
  34472. most = item;
  34473. }
  34474. if (!(value > min)) {
  34475. min = value;
  34476. least = item;
  34477. }
  34478. }
  34479. return [
  34480. least,
  34481. most
  34482. ];
  34483. },
  34484. max: function(items, begin, end, property, root) {
  34485. var b = this._aggregators.bounds.call(this, items, begin, end, property, root);
  34486. return b[1];
  34487. },
  34488. maxItem: function(items, begin, end, property, root) {
  34489. var b = this._aggregators.extremes.call(this, items, begin, end, property, root);
  34490. return b[1];
  34491. },
  34492. min: function(items, begin, end, property, root) {
  34493. var b = this._aggregators.bounds.call(this, items, begin, end, property, root);
  34494. return b[0];
  34495. },
  34496. minItem: function(items, begin, end, property, root) {
  34497. var b = this._aggregators.extremes.call(this, items, begin, end, property, root);
  34498. return b[0];
  34499. },
  34500. sum: function(items, begin, end, property, root) {
  34501. var value, sum, i;
  34502. for (sum = 0 , i = begin; i < end; ++i) {
  34503. value = items[i];
  34504. value = (root ? value[root] : value)[property];
  34505. sum += value;
  34506. }
  34507. return sum;
  34508. }
  34509. },
  34510. _eventToMethodMap: {
  34511. add: 'onCollectionAdd',
  34512. beforeitemchange: 'onCollectionBeforeItemChange',
  34513. beginupdate: 'onCollectionBeginUpdate',
  34514. endupdate: 'onCollectionEndUpdate',
  34515. itemchange: 'onCollectionItemChange',
  34516. filtereditemchange: 'onCollectionFilteredItemChange',
  34517. refresh: 'onCollectionRefresh',
  34518. remove: 'onCollectionRemove',
  34519. beforesort: 'beforeCollectionSort',
  34520. sort: 'onCollectionSort',
  34521. filter: 'onCollectionFilter',
  34522. filteradd: 'onCollectionFilterAdd',
  34523. updatekey: 'onCollectionUpdateKey'
  34524. },
  34525. addObserver: function(observer) {
  34526. var me = this,
  34527. observers = me.observers;
  34528. if (!observers) {
  34529. me.observers = observers = [];
  34530. }
  34531. if (Ext.Array.contains(observers, observer)) {
  34532. Ext.Error.raise('Observer already added');
  34533. }
  34534. if (me.notifying) {
  34535. me.observers = observers = observers.slice(0);
  34536. }
  34537. observers.push(observer);
  34538. if (observers.length > 1) {
  34539. Ext.Array.sort(observers, me.prioritySortFn);
  34540. }
  34541. },
  34542. prioritySortFn: function(o1, o2) {
  34543. var a = o1.observerPriority || 0,
  34544. b = o2.observerPriority || 0;
  34545. return a - b;
  34546. },
  34547. applyExtraKeys: function(extraKeys, oldExtraKeys) {
  34548. var me = this,
  34549. ret = oldExtraKeys || {},
  34550. config, name, value;
  34551. for (name in extraKeys) {
  34552. value = extraKeys[name];
  34553. if (!value.isCollectionKey) {
  34554. config = {
  34555. collection: me
  34556. };
  34557. if (Ext.isString(value)) {
  34558. config.property = value;
  34559. } else {
  34560. config = Ext.apply(config, value);
  34561. }
  34562. value = new Ext.util.CollectionKey(config);
  34563. } else {
  34564. value.setCollection(me);
  34565. }
  34566. ret[name] = me[name] = value;
  34567. value.name = name;
  34568. }
  34569. return ret;
  34570. },
  34571. applyGrouper: function(grouper) {
  34572. if (grouper) {
  34573. grouper = this.getSorters().decodeSorter(grouper, Ext.util.Grouper);
  34574. }
  34575. return grouper;
  34576. },
  34577. decodeItems: function(args, index) {
  34578. var me = this,
  34579. ret = (index === undefined) ? args : args[index],
  34580. cloned, decoder, i;
  34581. if (!ret || !ret.$cloned) {
  34582. cloned = args.length > index + 1 || !Ext.isIterable(ret);
  34583. if (cloned) {
  34584. ret = Ext.Array.slice(args, index);
  34585. if (ret.length === 1 && ret[0] === undefined) {
  34586. ret.length = 0;
  34587. }
  34588. }
  34589. decoder = me.getDecoder();
  34590. if (decoder) {
  34591. if (!cloned) {
  34592. ret = ret.slice(0);
  34593. cloned = true;
  34594. }
  34595. for (i = ret.length; i-- > 0; ) {
  34596. if ((ret[i] = decoder.call(me, ret[i])) === false) {
  34597. ret.splice(i, 1);
  34598. }
  34599. }
  34600. }
  34601. if (cloned) {
  34602. ret.$cloned = true;
  34603. }
  34604. }
  34605. return ret;
  34606. },
  34607. getIndices: function() {
  34608. var me = this,
  34609. indices = me.indices,
  34610. items = me.items,
  34611. n = items.length,
  34612. i, key;
  34613. if (!indices) {
  34614. me.indices = indices = {};
  34615. ++me.indexRebuilds;
  34616. for (i = 0; i < n; ++i) {
  34617. key = me.getKey(items[i]);
  34618. indices[key] = i;
  34619. }
  34620. }
  34621. return indices;
  34622. },
  34623. notify: function(eventName, args) {
  34624. var me = this,
  34625. observers = me.observers,
  34626. methodName = me._eventToMethodMap[eventName],
  34627. added = 0,
  34628. index, length, method, observer;
  34629. args = args || [];
  34630. if (observers && methodName) {
  34631. me.notifying = true;
  34632. for (index = 0 , length = observers.length; index < length; ++index) {
  34633. method = (observer = observers[index])[methodName];
  34634. if (method) {
  34635. if (!added++) {
  34636. args.unshift(me);
  34637. }
  34638. method.apply(observer, args);
  34639. }
  34640. }
  34641. me.notifying = false;
  34642. }
  34643. if (!me.hasListeners) {
  34644. return;
  34645. }
  34646. if (me.hasListeners[eventName]) {
  34647. if (!added) {
  34648. args.unshift(me);
  34649. }
  34650. me.fireEventArgs(eventName, args);
  34651. }
  34652. },
  34653. getFilterFn: function() {
  34654. return this.getFilters().getFilterFn();
  34655. },
  34656. getFilters: function(autoCreate) {
  34657. var ret = this._filters;
  34658. if (!ret && autoCreate !== false) {
  34659. ret = new Ext.util.FilterCollection(
  34660. {
  34661. id: this.getId() + '-filters' + (this.generation || '')
  34662. });
  34663. this.setFilters(ret);
  34664. }
  34665. return ret;
  34666. },
  34667. isItemFiltered: function(item) {
  34668. return !this.getFilters().filterFn(item);
  34669. },
  34670. onFilterChange: function(filters) {
  34671. var me = this,
  34672. source = me.getSource(),
  34673. extraKeys, newKeys, key;
  34674. if (!source) {
  34675. extraKeys = me.getExtraKeys();
  34676. if (extraKeys) {
  34677. newKeys = {};
  34678. for (key in extraKeys) {
  34679. newKeys[key] = extraKeys[key].clone(me);
  34680. }
  34681. }
  34682. source = new Ext.util.Collection({
  34683. keyFn: me.getKey,
  34684. extraKeys: newKeys,
  34685. rootProperty: me.getRootProperty()
  34686. });
  34687. if (me.length) {
  34688. source.add(me.items);
  34689. }
  34690. me.setSource(source);
  34691. me.autoSource = source;
  34692. } else {
  34693. if (source.destroyed) {
  34694. return;
  34695. }
  34696. if (source.length || me.length) {
  34697. me.onCollectionRefresh(source);
  34698. }
  34699. }
  34700. me.notify('filter');
  34701. },
  34702. applyFilters: function(filters, collection) {
  34703. if (!filters || filters.isFilterCollection) {
  34704. return filters;
  34705. }
  34706. if (filters) {
  34707. if (!collection) {
  34708. collection = this.getFilters();
  34709. }
  34710. collection.splice(0, collection.length, filters);
  34711. }
  34712. return collection;
  34713. },
  34714. updateFilters: function(newFilters, oldFilters) {
  34715. var me = this;
  34716. if (oldFilters) {
  34717. oldFilters.un('endupdate', 'onEndUpdateFilters', me);
  34718. }
  34719. if (newFilters) {
  34720. newFilters.on({
  34721. endupdate: 'onEndUpdateFilters',
  34722. scope: me,
  34723. priority: me.$endUpdatePriority
  34724. });
  34725. newFilters.$filterable = me;
  34726. }
  34727. me.onEndUpdateFilters(newFilters);
  34728. },
  34729. onEndUpdateFilters: function(filters) {
  34730. var me = this,
  34731. was = me.filtered,
  34732. is = !!filters && (filters.getFilterCount() > 0);
  34733. if (was || is) {
  34734. me.filtered = is;
  34735. me.onFilterChange(filters);
  34736. }
  34737. },
  34738. getSortFn: function() {
  34739. return this._sortFn || this.createSortFn();
  34740. },
  34741. getSorters: function(autoCreate) {
  34742. var ret = this._sorters;
  34743. if (!ret && autoCreate !== false) {
  34744. ret = new Ext.util.SorterCollection(
  34745. {
  34746. id: this.getId() + '-sorters' + (this.generation || '')
  34747. });
  34748. this.setSorters(ret);
  34749. }
  34750. return ret;
  34751. },
  34752. onSortChange: function() {
  34753. if (this.sorted) {
  34754. this.sortItems();
  34755. }
  34756. },
  34757. sort: function(property, direction, mode) {
  34758. var sorters = this.getSorters();
  34759. sorters.addSort.apply(sorters, arguments);
  34760. return this;
  34761. },
  34762. sortData: function(data) {
  34763. Ext.Array.sort(data, this.getSortFn());
  34764. return data;
  34765. },
  34766. sortItems: function(sortFn) {
  34767. var me = this;
  34768. if (me.sorted) {
  34769. if (sortFn) {
  34770. Ext.raise('Collections with sorters cannot resorted');
  34771. }
  34772. sortFn = me.getSortFn();
  34773. }
  34774. me.indices = null;
  34775. me.notify('beforesort', [
  34776. me.getSorters(false)
  34777. ]);
  34778. if (me.length) {
  34779. Ext.Array.sort(me.items, sortFn);
  34780. }
  34781. me.notify('sort');
  34782. },
  34783. sortBy: function(sortFn) {
  34784. return this.sortItems(sortFn);
  34785. },
  34786. findInsertionIndex: function(item, items, comparatorFn, index) {
  34787. return Ext.Array.findInsertionIndex(item, items || this.items, comparatorFn || this.getSortFn(), index);
  34788. },
  34789. applySorters: function(sorters, collection) {
  34790. if (!sorters || sorters.isSorterCollection) {
  34791. return sorters;
  34792. }
  34793. if (sorters) {
  34794. if (!collection) {
  34795. collection = this.getSorters();
  34796. }
  34797. collection.splice(0, collection.length, sorters);
  34798. }
  34799. return collection;
  34800. },
  34801. createSortFn: function() {
  34802. var me = this,
  34803. grouper = me.getGrouper(),
  34804. sorters = me.getSorters(false),
  34805. sorterFn = sorters ? sorters.getSortFn() : null;
  34806. if (!grouper) {
  34807. return sorterFn;
  34808. }
  34809. return function(lhs, rhs) {
  34810. var ret = grouper.sort(lhs, rhs);
  34811. if (!ret && sorterFn) {
  34812. ret = sorterFn(lhs, rhs);
  34813. }
  34814. return ret;
  34815. };
  34816. },
  34817. updateGrouper: function(grouper) {
  34818. var me = this,
  34819. groups = me.getGroups(),
  34820. sorters = me.getSorters(),
  34821. populate;
  34822. me.onSorterChange();
  34823. me.grouped = !!grouper;
  34824. if (grouper) {
  34825. if (me.getTrackGroups()) {
  34826. if (!groups) {
  34827. groups = new Ext.util.GroupCollection({
  34828. id: me.getId() + '-groups' + (me.generation || ''),
  34829. itemRoot: me.getRootProperty(),
  34830. groupConfig: me.getGroupConfig()
  34831. });
  34832. groups.$groupable = me;
  34833. me.setGroups(groups);
  34834. }
  34835. groups.setGrouper(grouper);
  34836. populate = true;
  34837. }
  34838. } else {
  34839. if (groups) {
  34840. me.removeObserver(groups);
  34841. groups.destroy();
  34842. }
  34843. me.setGroups(null);
  34844. }
  34845. if (!sorters.updating) {
  34846. me.onEndUpdateSorters(sorters);
  34847. }
  34848. if (populate) {
  34849. groups.onCollectionRefresh(me);
  34850. }
  34851. },
  34852. updateSorters: function(newSorters, oldSorters) {
  34853. var me = this;
  34854. if (oldSorters && !oldSorters.destroyed) {
  34855. oldSorters.un('endupdate', 'onEndUpdateSorters', me);
  34856. }
  34857. if (newSorters) {
  34858. newSorters.on({
  34859. endupdate: 'onEndUpdateSorters',
  34860. scope: me,
  34861. priority: me.$endUpdatePriority
  34862. });
  34863. if (me.manageSorters) {
  34864. newSorters.$sortable = me;
  34865. }
  34866. }
  34867. me.onSorterChange();
  34868. me.onEndUpdateSorters(newSorters);
  34869. },
  34870. onSorterChange: function() {
  34871. this._sortFn = null;
  34872. },
  34873. onEndUpdateSorters: function(sorters) {
  34874. var me = this,
  34875. was = me.sorted,
  34876. is = (me.grouped && me.getAutoGroup()) || (sorters && sorters.length > 0);
  34877. if (was || is) {
  34878. me.sorted = !!is;
  34879. me.onSortChange(sorters);
  34880. }
  34881. },
  34882. removeObserver: function(observer) {
  34883. var observers = this.observers;
  34884. if (observers) {
  34885. Ext.Array.remove(observers, observer);
  34886. }
  34887. },
  34888. spliceMerge: function(newItems, newKeys) {
  34889. var me = this,
  34890. map = me.map,
  34891. newLength = newItems.length,
  34892. oldIndex = 0,
  34893. oldItems = me.items,
  34894. oldLength = oldItems.length,
  34895. adds = [],
  34896. count = 0,
  34897. items = [],
  34898. sortFn = me.getSortFn(),
  34899. addItems, end, i, newItem, oldItem, newIndex;
  34900. me.items = items;
  34901. for (newIndex = 0; newIndex < newLength; newIndex = end) {
  34902. newItem = newItems[newIndex];
  34903. for (; oldIndex < oldLength; ++oldIndex) {
  34904. if (sortFn(newItem, oldItem = oldItems[oldIndex]) < 0) {
  34905. break;
  34906. }
  34907. items.push(oldItem);
  34908. }
  34909. if (oldIndex === oldLength) {
  34910. adds[count++] = {
  34911. at: items.length,
  34912. itemAt: items[items.length - 1],
  34913. items: (addItems = [])
  34914. };
  34915. if (count > 1) {
  34916. adds[count - 2].next = adds[count - 1];
  34917. }
  34918. for (; newIndex < newLength; ++newIndex) {
  34919. addItems.push(newItem = newItems[newIndex]);
  34920. items.push(newItem);
  34921. }
  34922. break;
  34923. }
  34924. adds[count++] = {
  34925. at: items.length,
  34926. itemAt: items[items.length - 1],
  34927. items: (addItems = [
  34928. newItem
  34929. ])
  34930. };
  34931. if (count > 1) {
  34932. adds[count - 2].next = adds[count - 1];
  34933. }
  34934. items.push(newItem);
  34935. for (end = newIndex + 1; end < newLength; ++end) {
  34936. if (sortFn(newItem = newItems[end], oldItem) >= 0) {
  34937. break;
  34938. }
  34939. items.push(newItem);
  34940. addItems.push(newItem);
  34941. }
  34942. }
  34943. for (; oldIndex < oldLength; ++oldIndex) {
  34944. items.push(oldItems[oldIndex]);
  34945. }
  34946. for (i = 0; i < newLength; ++i) {
  34947. map[newKeys[i]] = newItems[i];
  34948. }
  34949. me.length = items.length;
  34950. ++me.generation;
  34951. me.indices = null;
  34952. for (i = 0; i < count; ++i) {
  34953. me.notify('add', [
  34954. adds[i]
  34955. ]);
  34956. }
  34957. },
  34958. transformItems: Ext.identityFn,
  34959. getGroups: function() {
  34960. return this.callParent() || null;
  34961. },
  34962. updateAutoGroup: function(autoGroup) {
  34963. var groups = this.getGroups();
  34964. if (groups) {
  34965. groups.setAutoGroup(autoGroup);
  34966. }
  34967. this.onEndUpdateSorters(this._sorters);
  34968. },
  34969. updateGroups: function(newGroups, oldGroups) {
  34970. if (oldGroups) {
  34971. this.removeObserver(oldGroups);
  34972. }
  34973. if (newGroups) {
  34974. this.addObserver(newGroups);
  34975. }
  34976. },
  34977. updateSource: function(newSource, oldSource) {
  34978. var me = this,
  34979. auto = me.autoSource;
  34980. if (oldSource) {
  34981. if (!oldSource.destroyed) {
  34982. oldSource.removeObserver(me);
  34983. }
  34984. if (oldSource === auto) {
  34985. auto.destroy();
  34986. me.autoSource = null;
  34987. }
  34988. }
  34989. if (newSource) {
  34990. newSource.addObserver(me);
  34991. if (newSource.length || me.length) {
  34992. me.onCollectionRefresh(newSource);
  34993. }
  34994. }
  34995. }
  34996. }, function() {
  34997. var prototype = this.prototype;
  34998. prototype.removeAtKey = prototype.removeByKey;
  34999. prototype.decodeRemoveItems = prototype.decodeItems;
  35000. Ext.Object.each(prototype._aggregators, function(name) {
  35001. prototype[name] = function(property, begin, end) {
  35002. return this.aggregate(property, name, begin, end);
  35003. };
  35004. prototype[name + 'ByGroup'] = function(property) {
  35005. return this.aggregateByGroup(property, name);
  35006. };
  35007. });
  35008. });
  35009. Ext.define('Ext.data.Range', {
  35010. isDataRange: true,
  35011. begin: 0,
  35012. buffer: 0,
  35013. end: 0,
  35014. length: 0,
  35015. store: null,
  35016. constructor: function(config) {
  35017. var me = this,
  35018. activeRanges, store;
  35019. Ext.apply(me, config);
  35020. store = me.store;
  35021. if (!(activeRanges = store.activeRanges)) {
  35022. store.activeRanges = activeRanges = [];
  35023. }
  35024. activeRanges.push(me);
  35025. me.refresh();
  35026. if ('begin' in config) {
  35027. me.begin = me.end = 0;
  35028. me.goto(config.begin, config.end);
  35029. }
  35030. },
  35031. destroy: function() {
  35032. var me = this,
  35033. store = me.store,
  35034. activeRanges = store && store.activeRanges;
  35035. Ext.destroy(me.storeListeners);
  35036. if (activeRanges) {
  35037. Ext.Array.remove(activeRanges, me);
  35038. }
  35039. me.callParent();
  35040. },
  35041. "goto": function(begin, end) {
  35042. var me = this,
  35043. buffer = me.buffer,
  35044. task = me.task;
  35045. me.begin = begin;
  35046. me.end = end;
  35047. me.length = end - begin;
  35048. if (buffer > 0) {
  35049. if (!task) {
  35050. me.task = task = new Ext.util.DelayedTask(me.doGoto, me);
  35051. }
  35052. task.delay(buffer);
  35053. } else {
  35054. me.doGoto();
  35055. }
  35056. },
  35057. privates: {
  35058. lastBegin: 0,
  35059. lastEnd: 0,
  35060. doGoto: Ext.privateFn,
  35061. refresh: function() {
  35062. this.records = this.store.getData().items;
  35063. }
  35064. }
  35065. });
  35066. Ext.define('Ext.util.ObjectTemplate', {
  35067. isObjectTemplate: true,
  35068. excludeProperties: {},
  35069. valueRe: /^[{][a-z.]+[}]$/i,
  35070. statics: {
  35071. create: function(template, options) {
  35072. if (!Ext.isObject(template)) {
  35073. Ext.raise('The template is not an Object');
  35074. }
  35075. return template.isObjectTemplate ? template : new Ext.util.ObjectTemplate(template, options);
  35076. }
  35077. },
  35078. constructor: function(template, options) {
  35079. Ext.apply(this, options);
  35080. this.template = template;
  35081. },
  35082. apply: function(context) {
  35083. var me = this;
  35084. delete me.apply;
  35085. me.apply = me.compile(me.template);
  35086. return me.apply(context);
  35087. },
  35088. privates: {
  35089. compile: function(template) {
  35090. var me = this,
  35091. exclude = me.excludeProperties,
  35092. compiled, i, len, fn;
  35093. if (Ext.isString(template)) {
  35094. if (template.indexOf('{') < 0) {
  35095. fn = function() {
  35096. return template;
  35097. };
  35098. } else if (me.valueRe.test(template)) {
  35099. template = template.substring(1, template.length - 1).split('.');
  35100. fn = function(context) {
  35101. var v, i;
  35102. for (v = context , i = 0; v && i < template.length; ++i) {
  35103. v = v[template[i]];
  35104. }
  35105. return v;
  35106. };
  35107. } else {
  35108. template = new Ext.XTemplate(template);
  35109. fn = function(context) {
  35110. return template.apply(context);
  35111. };
  35112. }
  35113. } else if (!template || Ext.isPrimitive(template) || Ext.isFunction(template)) {
  35114. fn = function() {
  35115. return template;
  35116. };
  35117. } else if (template instanceof Array) {
  35118. compiled = [];
  35119. for (i = 0 , len = template.length; i < len; ++i) {
  35120. compiled[i] = me.compile(template[i]);
  35121. }
  35122. fn = function(context) {
  35123. var ret = [],
  35124. i;
  35125. for (i = 0; i < len; ++i) {
  35126. ret[i] = compiled[i](context);
  35127. }
  35128. return ret;
  35129. };
  35130. } else {
  35131. compiled = {};
  35132. for (i in template) {
  35133. if (!exclude[i]) {
  35134. compiled[i] = me.compile(template[i]);
  35135. }
  35136. }
  35137. fn = function(context) {
  35138. var ret = {},
  35139. i, v;
  35140. for (i in template) {
  35141. v = exclude[i] ? template[i] : compiled[i](context);
  35142. if (v !== undefined) {
  35143. ret[i] = v;
  35144. }
  35145. }
  35146. return ret;
  35147. };
  35148. }
  35149. return fn;
  35150. }
  35151. }
  35152. });
  35153. Ext.define('Ext.data.schema.Role', {
  35154. isRole: true,
  35155. left: true,
  35156. owner: false,
  35157. side: 'left',
  35158. isMany: false,
  35159. defaultReaderType: 'json',
  35160. _internalReadOptions: {
  35161. recordsOnly: true,
  35162. asRoot: true
  35163. },
  35164. constructor: function(association, config) {
  35165. var me = this,
  35166. extra = config.extra;
  35167. Ext.apply(me, config);
  35168. if (extra) {
  35169. extra = Ext.apply({}, extra);
  35170. delete extra.type;
  35171. Ext.apply(me, extra);
  35172. delete me.extra;
  35173. }
  35174. me.association = association;
  35175. if (association.owner === me.side) {
  35176. association.owner = me;
  35177. me.owner = true;
  35178. }
  35179. },
  35180. processUpdate: function() {
  35181. Ext.raise('Only the "many" for an association may be processed. "' + this.role + '" is not valid.');
  35182. },
  35183. processLoad: function(store, associatedEntity, records, session) {
  35184. return records;
  35185. },
  35186. checkMembership: Ext.emptyFn,
  35187. adoptAssociated: function(record, session) {
  35188. var other = this.getAssociatedItem(record);
  35189. if (other) {
  35190. session.adopt(other);
  35191. }
  35192. },
  35193. $roleFilterId: '$associationRoleFilter',
  35194. createAssociationStore: function(session, from, records, isComplete) {
  35195. var me = this,
  35196. association = me.association,
  35197. foreignKeyName = association.getFieldName(),
  35198. isMany = association.isManyToMany,
  35199. storeConfig = me.storeConfig,
  35200. id = from.getId(),
  35201. config = {
  35202. asynchronousLoad: false,
  35203. model: me.cls,
  35204. role: me,
  35205. session: session,
  35206. associatedEntity: from,
  35207. disableMetaChangeEvent: true,
  35208. pageSize: null,
  35209. remoteFilter: true,
  35210. trackRemoved: !session
  35211. },
  35212. store;
  35213. if (isMany) {
  35214. config.filters = [
  35215. {
  35216. id: me.$roleFilterId,
  35217. property: me.inverse.field,
  35218. value: id,
  35219. exactMatch: true
  35220. }
  35221. ];
  35222. } else if (foreignKeyName) {
  35223. config.filters = [
  35224. {
  35225. id: me.$roleFilterId,
  35226. property: foreignKeyName,
  35227. value: id,
  35228. exactMatch: true
  35229. }
  35230. ];
  35231. config.foreignKeyName = foreignKeyName;
  35232. }
  35233. if (storeConfig) {
  35234. Ext.apply(config, storeConfig);
  35235. }
  35236. store = Ext.Factory.store(config);
  35237. me.onStoreCreate(store, session, id);
  35238. if (!isMany || session) {
  35239. store.on({
  35240. scope: me,
  35241. add: 'onAddToMany',
  35242. remove: 'onRemoveFromMany',
  35243. clear: 'onRemoveFromMany'
  35244. });
  35245. }
  35246. if (records) {
  35247. store.loadData(records);
  35248. }
  35249. store.complete = !!isComplete;
  35250. return store;
  35251. },
  35252. onStoreCreate: Ext.emptyFn,
  35253. getAssociatedStore: function(inverseRecord, options, scope, records, allowInfer) {
  35254. var me = this,
  35255. storeName = me.getStoreName(),
  35256. store = inverseRecord[storeName],
  35257. hadStore = store,
  35258. session = inverseRecord.session,
  35259. load = options && options.reload,
  35260. source = inverseRecord.$source,
  35261. isComplete = false,
  35262. phantom = false,
  35263. hadSourceStore, args, i, len, raw, rec, sourceStore, hadRecords, isLoading;
  35264. if (!store) {
  35265. if (session) {
  35266. if (source) {
  35267. phantom = source.phantom;
  35268. }
  35269. if (!records && source) {
  35270. sourceStore = source[storeName];
  35271. if (sourceStore && !sourceStore.isLoading()) {
  35272. records = [];
  35273. raw = sourceStore.getData().items;
  35274. for (i = 0 , len = raw.length; i < len; ++i) {
  35275. rec = raw[i];
  35276. records.push(session.getRecord(rec.self, rec.id));
  35277. }
  35278. isComplete = !!sourceStore.complete;
  35279. hadSourceStore = true;
  35280. }
  35281. }
  35282. if (!hadSourceStore) {
  35283. hadRecords = !!records;
  35284. records = me.findRecords(session, inverseRecord, records, allowInfer);
  35285. if (!hadRecords && (!records || !records.length)) {
  35286. records = null;
  35287. }
  35288. isComplete = phantom || hadRecords;
  35289. }
  35290. } else {
  35291. isComplete = !!records;
  35292. }
  35293. store = me.createAssociationStore(session, inverseRecord, records, isComplete || inverseRecord.phantom);
  35294. store.$source = sourceStore;
  35295. if (!records && (me.autoLoad || options)) {
  35296. load = true;
  35297. }
  35298. inverseRecord[storeName] = store;
  35299. }
  35300. if (options) {
  35301. if (load || store.isLoading()) {
  35302. store.on('load', function(store, records, success, operation) {
  35303. args = [
  35304. store,
  35305. operation
  35306. ];
  35307. scope = scope || options.scope || inverseRecord;
  35308. if (success) {
  35309. Ext.callback(options.success, scope, args);
  35310. } else {
  35311. Ext.callback(options.failure, scope, args);
  35312. }
  35313. args.push(success);
  35314. Ext.callback(options, scope, args);
  35315. Ext.callback(options.callback, scope, args);
  35316. }, null, {
  35317. single: true
  35318. });
  35319. } else {
  35320. args = [
  35321. store,
  35322. null
  35323. ];
  35324. scope = scope || options.scope || inverseRecord;
  35325. Ext.callback(options.success, scope, args);
  35326. args.push(true);
  35327. Ext.callback(options, scope, args);
  35328. Ext.callback(options.callback, scope, args);
  35329. }
  35330. }
  35331. isLoading = store.isLoading();
  35332. if (load) {
  35333. if (!isLoading) {
  35334. store.load();
  35335. }
  35336. } else if (hadStore && records && !isLoading) {
  35337. store.loadData(records);
  35338. }
  35339. return store;
  35340. },
  35341. getAssociatedItem: function(rec) {
  35342. var key = this.isMany ? this.getStoreName() : this.getInstanceName();
  35343. return rec[key] || null;
  35344. },
  35345. onDrop: Ext.emptyFn,
  35346. onIdChanged: Ext.emptyFn,
  35347. getReaderRoot: function() {
  35348. var me = this;
  35349. return me.associationKey || (me.associationKey = me.association.schema.getNamer().readerRoot(me.role));
  35350. },
  35351. getReader: function() {
  35352. var me = this,
  35353. reader = me.reader,
  35354. Model = me.cls,
  35355. useSimpleAccessors = !me.associationKey,
  35356. root = this.getReaderRoot();
  35357. if (reader && !reader.isReader) {
  35358. if (Ext.isString(reader)) {
  35359. reader = {
  35360. type: reader
  35361. };
  35362. }
  35363. Ext.applyIf(reader, {
  35364. model: Model,
  35365. rootProperty: root,
  35366. useSimpleAccessors: useSimpleAccessors,
  35367. type: me.defaultReaderType
  35368. });
  35369. reader = me.reader = Ext.createByAlias('reader.' + reader.type, reader);
  35370. }
  35371. return reader;
  35372. },
  35373. getInstanceName: function() {
  35374. var me = this;
  35375. return me.instanceName || (me.instanceName = me.association.schema.getNamer().instanceName(me.role));
  35376. },
  35377. getOldInstanceName: function() {
  35378. return this.oldInstanceName || (this.oldInstanceName = '$old' + this.getInstanceName());
  35379. },
  35380. getStoreName: function() {
  35381. var me = this;
  35382. return me.storeName || (me.storeName = me.association.schema.getNamer().storeName(me.role));
  35383. },
  35384. constructReader: function(fromReader) {
  35385. var me = this,
  35386. reader = me.getReader(),
  35387. Model = me.cls,
  35388. useSimpleAccessors = !me.associationKey,
  35389. root = me.getReaderRoot(),
  35390. proxyReader, proxy;
  35391. if (!reader) {
  35392. proxy = Model.getProxy();
  35393. if (proxy) {
  35394. proxyReader = proxy.getReader();
  35395. reader = new proxyReader.self();
  35396. reader.copyFrom(proxyReader);
  35397. reader.setRootProperty(root);
  35398. } else {
  35399. reader = new fromReader.self({
  35400. model: Model,
  35401. useSimpleAccessors: useSimpleAccessors,
  35402. rootProperty: root
  35403. });
  35404. }
  35405. me.reader = reader;
  35406. }
  35407. return reader;
  35408. },
  35409. read: function(record, data, fromReader, readOptions) {
  35410. var reader = this.constructReader(fromReader),
  35411. root = reader.getRoot(data);
  35412. if (root) {
  35413. return reader.readRecords(root, readOptions, this._internalReadOptions);
  35414. }
  35415. },
  35416. getCallbackOptions: function(options, scope, defaultScope) {
  35417. if (typeof options === 'function') {
  35418. options = {
  35419. callback: options,
  35420. scope: scope || defaultScope
  35421. };
  35422. } else if (options) {
  35423. options = Ext.apply({}, options);
  35424. options.scope = scope || options.scope || defaultScope;
  35425. }
  35426. return options;
  35427. },
  35428. doGetFK: function(leftRecord, options, scope) {
  35429. var me = this,
  35430. cls = me.cls,
  35431. foreignKey = me.association.getFieldName(),
  35432. instanceName = me.getInstanceName(),
  35433. rightRecord = leftRecord[instanceName],
  35434. reload = options && options.reload,
  35435. done = rightRecord !== undefined && !reload,
  35436. session = leftRecord.session,
  35437. foreignKeyId, args;
  35438. if (!done) {
  35439. if (session) {
  35440. foreignKeyId = leftRecord.get(foreignKey);
  35441. if (foreignKeyId || foreignKeyId === 0) {
  35442. done = session.peekRecord(cls, foreignKeyId, true) && !reload;
  35443. rightRecord = session.getRecord(cls, foreignKeyId, false);
  35444. } else {
  35445. done = true;
  35446. leftRecord[instanceName] = rightRecord = null;
  35447. }
  35448. } else if (foreignKey) {
  35449. foreignKeyId = leftRecord.get(foreignKey);
  35450. if (!foreignKeyId && foreignKeyId !== 0) {
  35451. done = true;
  35452. leftRecord[instanceName] = rightRecord = null;
  35453. } else {
  35454. if (!rightRecord) {
  35455. rightRecord = cls.createWithId(foreignKeyId);
  35456. }
  35457. }
  35458. } else
  35459. {
  35460. done = true;
  35461. rightRecord = null;
  35462. }
  35463. } else if (rightRecord) {
  35464. done = !rightRecord.isLoading();
  35465. }
  35466. if (done) {
  35467. if (options) {
  35468. args = [
  35469. rightRecord,
  35470. null
  35471. ];
  35472. scope = scope || options.scope || leftRecord;
  35473. Ext.callback(options.success, scope, args);
  35474. args.push(true);
  35475. Ext.callback(options, scope, args);
  35476. Ext.callback(options.callback, scope, args);
  35477. }
  35478. } else {
  35479. leftRecord[instanceName] = rightRecord;
  35480. options = me.getCallbackOptions(options, scope, leftRecord);
  35481. rightRecord.load(options);
  35482. }
  35483. return rightRecord;
  35484. },
  35485. doSetFK: function(leftRecord, rightRecord, options, scope) {
  35486. var me = this,
  35487. foreignKey = me.association.getFieldName(),
  35488. instanceName = me.getInstanceName(),
  35489. current = leftRecord[instanceName],
  35490. inverse = me.inverse,
  35491. inverseSetter = inverse.setterName,
  35492. modified, oldInstanceName;
  35493. if (rightRecord && rightRecord.isEntity) {
  35494. if (current !== rightRecord) {
  35495. oldInstanceName = me.getOldInstanceName();
  35496. leftRecord[oldInstanceName] = current;
  35497. leftRecord[instanceName] = rightRecord;
  35498. if (current && current.isEntity) {
  35499. current[inverse.getInstanceName()] = undefined;
  35500. }
  35501. if (foreignKey) {
  35502. leftRecord.set(foreignKey, rightRecord.getId());
  35503. }
  35504. delete leftRecord[oldInstanceName];
  35505. leftRecord.onAssociatedRecordSet(rightRecord, me);
  35506. if (inverseSetter) {
  35507. rightRecord[inverseSetter](leftRecord);
  35508. }
  35509. }
  35510. } else {
  35511. if (!foreignKey) {
  35512. Ext.raise('No foreignKey specified for "' + me.association.left.role + '" by ' + leftRecord.$className);
  35513. }
  35514. modified = (leftRecord.changingKey && !inverse.isMany) || leftRecord.set(foreignKey, rightRecord);
  35515. if (modified && current && current.isEntity && !current.isEqual(current.getId(), rightRecord)) {
  35516. leftRecord[instanceName] = undefined;
  35517. if (!inverse.isMany) {
  35518. current[inverse.getInstanceName()] = undefined;
  35519. }
  35520. }
  35521. }
  35522. if (options) {
  35523. if (Ext.isFunction(options)) {
  35524. options = {
  35525. callback: options,
  35526. scope: scope || leftRecord
  35527. };
  35528. }
  35529. return leftRecord.save(options);
  35530. }
  35531. }
  35532. });
  35533. Ext.define('Ext.data.schema.Association', {
  35534. isOneToOne: false,
  35535. isManyToOne: false,
  35536. isManyToMany: false,
  35537. owner: null,
  35538. field: null,
  35539. constructor: function(config) {
  35540. var me = this,
  35541. left, right;
  35542. Ext.apply(me, config);
  35543. me.left = left = new me.Left(me, me.left);
  35544. me.right = right = new me.Right(me, me.right);
  35545. left.inverse = right;
  35546. right.inverse = left;
  35547. },
  35548. hasField: function() {
  35549. return !!this.field;
  35550. },
  35551. getFieldName: function() {
  35552. var field = this.field;
  35553. return field ? field.name : '';
  35554. }
  35555. });
  35556. Ext.define('Ext.data.schema.OneToOne', {
  35557. extend: Ext.data.schema.Association,
  35558. isOneToOne: true,
  35559. isToOne: true,
  35560. kind: 'one-to-one',
  35561. Left: Ext.define(null, {
  35562. extend: 'Ext.data.schema.Role',
  35563. onDrop: function(rightRecord, session) {
  35564. var leftRecord = this.getAssociatedItem(rightRecord);
  35565. rightRecord[this.getInstanceName()] = null;
  35566. if (leftRecord) {
  35567. leftRecord[this.inverse.getInstanceName()] = null;
  35568. }
  35569. },
  35570. onIdChanged: function(rightRecord, oldId, newId) {
  35571. var leftRecord = this.getAssociatedItem(rightRecord),
  35572. fieldName = this.association.getFieldName();
  35573. if (!rightRecord.session && leftRecord && fieldName) {
  35574. leftRecord.set(fieldName, newId);
  35575. }
  35576. },
  35577. createGetter: function() {
  35578. var me = this;
  35579. return function() {
  35580. return me.doGet(this);
  35581. };
  35582. },
  35583. createSetter: function() {
  35584. var me = this;
  35585. return function(value) {
  35586. return me.doSet(this, value);
  35587. };
  35588. },
  35589. doGet: function(rightRecord) {
  35590. var instanceName = this.getInstanceName(),
  35591. ret = rightRecord[instanceName],
  35592. session = rightRecord.session;
  35593. if (!ret && session) {}
  35594. return ret || null;
  35595. },
  35596. doSet: function(rightRecord, leftRecord) {
  35597. var instanceName = this.getInstanceName(),
  35598. ret = rightRecord[instanceName],
  35599. inverseSetter = this.inverse.setterName;
  35600. if (ret !== leftRecord) {
  35601. rightRecord[instanceName] = leftRecord;
  35602. if (inverseSetter) {
  35603. leftRecord[inverseSetter](rightRecord);
  35604. }
  35605. rightRecord.onAssociatedRecordSet(leftRecord, this);
  35606. }
  35607. return ret;
  35608. },
  35609. read: function(rightRecord, node, fromReader, readOptions) {
  35610. var me = this,
  35611. leftRecords = me.callParent([
  35612. rightRecord,
  35613. node,
  35614. fromReader,
  35615. readOptions
  35616. ]),
  35617. leftRecord;
  35618. if (leftRecords) {
  35619. leftRecord = leftRecords[0];
  35620. if (leftRecord) {
  35621. leftRecord[me.inverse.getInstanceName()] = rightRecord;
  35622. rightRecord[me.getInstanceName()] = leftRecord;
  35623. delete rightRecord.data[me.role];
  35624. }
  35625. }
  35626. }
  35627. }),
  35628. Right: Ext.define(null, {
  35629. extend: 'Ext.data.schema.Role',
  35630. left: false,
  35631. side: 'right',
  35632. createGetter: function() {
  35633. var me = this;
  35634. return function(options, scope) {
  35635. return me.doGetFK(this, options, scope);
  35636. };
  35637. },
  35638. createSetter: function() {
  35639. var me = this;
  35640. return function(value, options, scope) {
  35641. return me.doSetFK(this, value, options, scope);
  35642. };
  35643. },
  35644. onDrop: function(leftRecord, session) {
  35645. var me = this,
  35646. field = me.association.field,
  35647. rightRecord = me.getAssociatedItem(leftRecord),
  35648. id;
  35649. if (me.inverse.owner) {
  35650. if (session && field) {
  35651. id = leftRecord.get(field.name);
  35652. if (id || id === 0) {
  35653. rightRecord = session.getEntry(me.cls, id).record;
  35654. if (rightRecord) {
  35655. rightRecord.drop();
  35656. }
  35657. }
  35658. } else {
  35659. if (rightRecord) {
  35660. rightRecord.drop();
  35661. }
  35662. }
  35663. }
  35664. if (field) {
  35665. leftRecord.set(field.name, null);
  35666. }
  35667. leftRecord[me.getInstanceName()] = null;
  35668. if (rightRecord) {
  35669. rightRecord[me.inverse.getInstanceName()] = null;
  35670. }
  35671. },
  35672. onValueChange: function(leftRecord, session, newValue) {
  35673. var me = this,
  35674. rightRecord = leftRecord[me.getOldInstanceName()] || me.getAssociatedItem(leftRecord),
  35675. hasNewValue = newValue || newValue === 0,
  35676. instanceName = me.getInstanceName(),
  35677. cls = me.cls;
  35678. leftRecord.changingKey = true;
  35679. me.doSetFK(leftRecord, newValue);
  35680. if (!hasNewValue) {
  35681. leftRecord[instanceName] = null;
  35682. } else if (session && cls) {
  35683. leftRecord[instanceName] = session.peekRecord(cls, newValue) || undefined;
  35684. }
  35685. if (me.inverse.owner && rightRecord) {
  35686. me.association.schema.queueKeyCheck(rightRecord, me);
  35687. }
  35688. leftRecord.changingKey = false;
  35689. },
  35690. checkKeyForDrop: function(rightRecord) {
  35691. var leftRecord = this.inverse.getAssociatedItem(rightRecord);
  35692. if (!leftRecord) {
  35693. rightRecord.drop();
  35694. }
  35695. },
  35696. read: function(leftRecord, node, fromReader, readOptions) {
  35697. var me = this,
  35698. rightRecords = me.callParent([
  35699. leftRecord,
  35700. node,
  35701. fromReader,
  35702. readOptions
  35703. ]),
  35704. rightRecord, field, fieldName, session, refs, id, oldId, setKey, data;
  35705. if (rightRecords) {
  35706. rightRecord = rightRecords[0];
  35707. field = me.association.field;
  35708. if (field) {
  35709. fieldName = field.name;
  35710. }
  35711. session = leftRecord.session;
  35712. data = leftRecord.data;
  35713. if (rightRecord) {
  35714. if (session) {
  35715. refs = session.getRefs(rightRecord, this.inverse, true);
  35716. setKey = (refs && refs[leftRecord.id]) || (data[fieldName] === undefined);
  35717. } else {
  35718. setKey = true;
  35719. }
  35720. if (setKey) {
  35721. if (field) {
  35722. oldId = data[fieldName];
  35723. id = rightRecord.id;
  35724. if (oldId !== id) {
  35725. data[fieldName] = id;
  35726. if (session) {
  35727. session.updateReference(leftRecord, field, id, oldId);
  35728. }
  35729. }
  35730. }
  35731. rightRecord[me.inverse.getInstanceName()] = leftRecord;
  35732. leftRecord[me.getInstanceName()] = rightRecord;
  35733. }
  35734. delete data[me.role];
  35735. }
  35736. }
  35737. }
  35738. })
  35739. });
  35740. Ext.define('Ext.data.schema.ManyToOne', {
  35741. extend: Ext.data.schema.Association,
  35742. isManyToOne: true,
  35743. isToOne: true,
  35744. kind: 'many-to-one',
  35745. Left: Ext.define(null, {
  35746. extend: 'Ext.data.schema.Role',
  35747. isMany: true,
  35748. onDrop: function(rightRecord, session) {
  35749. var me = this,
  35750. store = me.getAssociatedItem(rightRecord),
  35751. leftRecords, len, i, id;
  35752. if (store) {
  35753. leftRecords = store.removeAll();
  35754. if (leftRecords && me.inverse.owner) {
  35755. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35756. leftRecords[i].drop();
  35757. }
  35758. }
  35759. store.destroy();
  35760. rightRecord[me.getStoreName()] = null;
  35761. } else if (session) {
  35762. leftRecords = session.getRefs(rightRecord, me);
  35763. if (leftRecords) {
  35764. for (id in leftRecords) {
  35765. leftRecords[id].drop();
  35766. }
  35767. }
  35768. }
  35769. },
  35770. onIdChanged: function(rightRecord, oldId, newId) {
  35771. var fieldName = this.association.getFieldName(),
  35772. store = this.getAssociatedItem(rightRecord),
  35773. leftRecords, i, len, filter;
  35774. if (store) {
  35775. filter = store.getFilters().get(this.$roleFilterId);
  35776. if (filter) {
  35777. filter.setValue(newId);
  35778. }
  35779. if (!rightRecord.session && fieldName) {
  35780. leftRecords = store.getDataSource().items;
  35781. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35782. leftRecords[i].set(fieldName, newId);
  35783. }
  35784. }
  35785. }
  35786. },
  35787. processUpdate: function(session, associationData) {
  35788. var me = this,
  35789. entityType = me.inverse.cls,
  35790. items = associationData.R,
  35791. id, rightRecord, store, leftRecords;
  35792. if (items) {
  35793. for (id in items) {
  35794. rightRecord = session.peekRecord(entityType, id);
  35795. if (rightRecord) {
  35796. leftRecords = session.getEntityList(me.cls, items[id]);
  35797. store = me.getAssociatedItem(rightRecord);
  35798. if (store) {
  35799. store.loadData(leftRecords);
  35800. store.complete = true;
  35801. } else {
  35802. rightRecord[me.getterName](null, null, leftRecords);
  35803. }
  35804. } else {
  35805. session.onInvalidAssociationEntity(entityType, id);
  35806. }
  35807. }
  35808. }
  35809. },
  35810. findRecords: function(session, rightRecord, leftRecords, allowInfer) {
  35811. var ret = leftRecords,
  35812. refs = session.getRefs(rightRecord, this, true),
  35813. field = this.association.field,
  35814. fieldName, leftRecord, id, i, len, seen;
  35815. if (field && (refs || allowInfer)) {
  35816. fieldName = field.name;
  35817. ret = [];
  35818. if (leftRecords) {
  35819. seen = {};
  35820. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35821. leftRecord = leftRecords[i];
  35822. id = leftRecord.id;
  35823. if (refs && refs[id]) {
  35824. ret.push(leftRecord);
  35825. } else if (allowInfer && leftRecord.data[fieldName] === undefined) {
  35826. ret.push(leftRecord);
  35827. leftRecord.data[fieldName] = rightRecord.id;
  35828. session.updateReference(leftRecord, field, rightRecord.id, undefined);
  35829. }
  35830. seen[id] = true;
  35831. }
  35832. }
  35833. if (refs) {
  35834. for (id in refs) {
  35835. if (!seen || !seen[id]) {
  35836. ret.push(refs[id]);
  35837. }
  35838. }
  35839. }
  35840. }
  35841. return ret;
  35842. },
  35843. processLoad: function(store, rightRecord, leftRecords, session) {
  35844. var ret = leftRecords;
  35845. if (session) {
  35846. ret = this.findRecords(session, rightRecord, leftRecords, true);
  35847. }
  35848. this.onLoadMany(rightRecord, ret, session);
  35849. return ret;
  35850. },
  35851. adoptAssociated: function(rightRecord, session) {
  35852. var store = this.getAssociatedItem(rightRecord),
  35853. leftRecords, i, len;
  35854. if (store) {
  35855. store.setSession(session);
  35856. leftRecords = store.getData().items;
  35857. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35858. session.adopt(leftRecords[i]);
  35859. }
  35860. }
  35861. },
  35862. createGetter: function() {
  35863. var me = this;
  35864. return function(options, scope, leftRecords) {
  35865. return me.getAssociatedStore(this, options, scope, leftRecords, true);
  35866. };
  35867. },
  35868. createSetter: null,
  35869. onAddToMany: function(store, leftRecords) {
  35870. var rightRecord = store.getAssociatedEntity();
  35871. if (this.association.field) {
  35872. this.syncFK(leftRecords, rightRecord, false);
  35873. } else {
  35874. this.setInstances(rightRecord, leftRecords);
  35875. }
  35876. },
  35877. onLoadMany: function(rightRecord, leftRecords, session) {
  35878. this.setInstances(rightRecord, leftRecords, session);
  35879. },
  35880. onRemoveFromMany: function(store, leftRecords) {
  35881. if (this.association.field) {
  35882. this.syncFK(leftRecords, store.getAssociatedEntity(), true);
  35883. } else {
  35884. this.setInstances(null, leftRecords);
  35885. }
  35886. },
  35887. read: function(rightRecord, node, fromReader, readOptions) {
  35888. var me = this,
  35889. instanceName = me.inverse.getInstanceName(),
  35890. leftRecords = me.callParent([
  35891. rightRecord,
  35892. node,
  35893. fromReader,
  35894. readOptions
  35895. ]),
  35896. store, len, i;
  35897. if (leftRecords) {
  35898. store = rightRecord[me.getterName](null, null, leftRecords);
  35899. delete rightRecord.data[me.role];
  35900. leftRecords = store.getData().items;
  35901. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35902. leftRecords[i][instanceName] = rightRecord;
  35903. }
  35904. }
  35905. },
  35906. setInstances: function(rightRecord, leftRecords, session) {
  35907. var instanceName = this.inverse.getInstanceName(),
  35908. id = rightRecord ? rightRecord.getId() : null,
  35909. field = this.association.field,
  35910. len = leftRecords.length,
  35911. i, leftRecord, oldId, data, name;
  35912. for (i = 0; i < len; ++i) {
  35913. leftRecord = leftRecords[i];
  35914. leftRecord[instanceName] = rightRecord;
  35915. if (field) {
  35916. name = field.name;
  35917. data = leftRecord.data;
  35918. oldId = data[name];
  35919. if (oldId !== id) {
  35920. data[name] = id;
  35921. if (session) {
  35922. session.updateReference(leftRecord, field, id, oldId);
  35923. }
  35924. }
  35925. }
  35926. }
  35927. },
  35928. syncFK: function(leftRecords, rightRecord, clearing) {
  35929. var foreignKeyName = this.association.getFieldName(),
  35930. inverse = this.inverse,
  35931. setter = inverse.setterName,
  35932. instanceName = inverse.getInstanceName(),
  35933. i = leftRecords.length,
  35934. id = rightRecord.getId(),
  35935. different, leftRecord, val;
  35936. while (i-- > 0) {
  35937. leftRecord = leftRecords[i];
  35938. different = !leftRecord.isEqual(id, leftRecord.get(foreignKeyName));
  35939. val = clearing ? null : rightRecord;
  35940. if (different !== clearing) {
  35941. leftRecord.changingKey = true;
  35942. leftRecord[setter](val);
  35943. leftRecord.changingKey = false;
  35944. } else {
  35945. leftRecord[instanceName] = val;
  35946. }
  35947. }
  35948. }
  35949. }),
  35950. Right: Ext.define(null, {
  35951. extend: 'Ext.data.schema.Role',
  35952. left: false,
  35953. side: 'right',
  35954. onDrop: function(leftRecord, session) {
  35955. var field = this.association.field;
  35956. if (field) {
  35957. leftRecord.set(field.name, null);
  35958. }
  35959. leftRecord[this.getInstanceName()] = null;
  35960. },
  35961. createGetter: function() {
  35962. var me = this;
  35963. return function(options, scope) {
  35964. return me.doGetFK(this, options, scope);
  35965. };
  35966. },
  35967. createSetter: function() {
  35968. var me = this;
  35969. return function(rightRecord, options, scope) {
  35970. return me.doSetFK(this, rightRecord, options, scope);
  35971. };
  35972. },
  35973. checkMembership: function(session, leftRecord) {
  35974. var field = this.association.field,
  35975. store;
  35976. if (field) {
  35977. store = this.getSessionStore(session, leftRecord.get(field.name));
  35978. if (store && !store.contains(leftRecord)) {
  35979. store.add(leftRecord);
  35980. }
  35981. }
  35982. },
  35983. onValueChange: function(leftRecord, session, newValue, oldValue) {
  35984. var me = this,
  35985. instanceName = me.getInstanceName(),
  35986. cls = me.cls,
  35987. hasNewValue, joined, store, i, associated, rightRecord;
  35988. if (!leftRecord.changingKey) {
  35989. hasNewValue = newValue || newValue === 0;
  35990. if (!hasNewValue) {
  35991. leftRecord[instanceName] = null;
  35992. }
  35993. if (session) {
  35994. store = me.getSessionStore(session, oldValue);
  35995. if (store) {
  35996. store.remove(leftRecord);
  35997. }
  35998. if (hasNewValue) {
  35999. store = me.getSessionStore(session, newValue);
  36000. if (store && !store.isLoading()) {
  36001. store.add(leftRecord);
  36002. }
  36003. if (cls) {
  36004. rightRecord = session.peekRecord(cls, newValue);
  36005. }
  36006. leftRecord[instanceName] = rightRecord || undefined;
  36007. }
  36008. } else {
  36009. joined = leftRecord.joined;
  36010. if (joined) {
  36011. for (i = joined.length - 1; i >= 0; i--) {
  36012. store = joined[i];
  36013. if (store.isStore) {
  36014. associated = store.getAssociatedEntity();
  36015. if (associated && associated.self === me.cls && associated.getId() === oldValue) {
  36016. store.remove(leftRecord);
  36017. }
  36018. }
  36019. }
  36020. }
  36021. }
  36022. }
  36023. if (me.owner && newValue === null) {
  36024. me.association.schema.queueKeyCheck(leftRecord, me);
  36025. }
  36026. },
  36027. checkKeyForDrop: function(leftRecord) {
  36028. var field = this.association.field;
  36029. if (leftRecord.get(field.name) === null) {
  36030. leftRecord.drop();
  36031. }
  36032. },
  36033. getSessionStore: function(session, value) {
  36034. var cls = this.cls,
  36035. rec;
  36036. if (cls) {
  36037. rec = session.peekRecord(cls, value);
  36038. if (rec) {
  36039. return this.inverse.getAssociatedItem(rec);
  36040. }
  36041. }
  36042. },
  36043. read: function(leftRecord, node, fromReader, readOptions) {
  36044. var rightRecords = this.callParent([
  36045. leftRecord,
  36046. node,
  36047. fromReader,
  36048. readOptions
  36049. ]),
  36050. rightRecord;
  36051. if (rightRecords) {
  36052. rightRecord = rightRecords[0];
  36053. if (rightRecord) {
  36054. leftRecord[this.getInstanceName()] = rightRecord;
  36055. delete leftRecord.data[this.role];
  36056. }
  36057. }
  36058. }
  36059. })
  36060. });
  36061. Ext.define('Ext.data.schema.ManyToMany', {
  36062. extend: Ext.data.schema.Association,
  36063. isManyToMany: true,
  36064. isToMany: true,
  36065. kind: 'many-to-many',
  36066. Left: Ext.define(null, {
  36067. extend: 'Ext.data.schema.Role',
  36068. isMany: true,
  36069. digitRe: /^\d+$/,
  36070. findRecords: function(session, rightRecord, leftRecords) {
  36071. var slice = session.getMatrixSlice(this.inverse, rightRecord.id),
  36072. members = slice.members,
  36073. ret = [],
  36074. cls = this.cls,
  36075. seen, i, len, id, member, leftRecord;
  36076. if (leftRecords) {
  36077. seen = {};
  36078. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  36079. leftRecord = leftRecords[i];
  36080. id = leftRecord.id;
  36081. member = members[id];
  36082. if (!(member && member[2] === -1)) {
  36083. ret.push(leftRecord);
  36084. }
  36085. seen[id] = true;
  36086. }
  36087. }
  36088. for (id in members) {
  36089. member = members[id];
  36090. if (!seen || !seen[id] && (member && member[2] !== -1)) {
  36091. leftRecord = session.peekRecord(cls, id);
  36092. if (leftRecord) {
  36093. ret.push(leftRecord);
  36094. }
  36095. }
  36096. }
  36097. return ret;
  36098. },
  36099. onIdChanged: function(rightRecord, oldId, newId) {
  36100. var store = this.getAssociatedItem(rightRecord);
  36101. if (store) {
  36102. store.getFilters().get(this.$roleFilterId).setValue(newId);
  36103. }
  36104. },
  36105. processLoad: function(store, rightRecord, leftRecords, session) {
  36106. var ret = leftRecords;
  36107. if (session) {
  36108. ret = this.findRecords(session, rightRecord, leftRecords);
  36109. this.onAddToMany(store, ret, true);
  36110. }
  36111. return ret;
  36112. },
  36113. processUpdate: function(session, associationData) {
  36114. var me = this,
  36115. entityType = me.inverse.cls,
  36116. items = associationData.R,
  36117. id, rightRecord, store, leftRecords;
  36118. if (items) {
  36119. for (id in items) {
  36120. rightRecord = session.peekRecord(entityType, id);
  36121. if (rightRecord) {
  36122. leftRecords = session.getEntityList(me.cls, items[id]);
  36123. store = me.getAssociatedItem(rightRecord);
  36124. if (store) {
  36125. store.loadData(leftRecords);
  36126. store.complete = true;
  36127. } else {
  36128. rightRecord[me.getterName](null, null, leftRecords);
  36129. }
  36130. } else {
  36131. session.onInvalidAssociationEntity(entityType, id);
  36132. }
  36133. }
  36134. }
  36135. me.processMatrixBlock(session, associationData.C, 1);
  36136. me.processMatrixBlock(session, associationData.D, -1);
  36137. },
  36138. checkMembership: function(session, rightRecord) {
  36139. var matrix = session.getMatrix(this.association, true),
  36140. side, entityType, inverse, slice, slices, id, members, member, leftRecord, store;
  36141. if (!matrix) {
  36142. return;
  36143. }
  36144. side = this.left ? matrix.right : matrix.left;
  36145. entityType = side.inverse.role.cls;
  36146. inverse = this.inverse;
  36147. slices = side.slices;
  36148. if (slices) {
  36149. slice = slices[rightRecord.id];
  36150. if (slice) {
  36151. members = slice.members;
  36152. for (id in members) {
  36153. member = members[id];
  36154. if (member[2] !== -1) {
  36155. leftRecord = session.peekRecord(entityType, id);
  36156. if (leftRecord) {
  36157. store = inverse.getAssociatedItem(leftRecord);
  36158. if (store) {
  36159. store.matrixUpdate = 1;
  36160. store.add(rightRecord);
  36161. store.matrixUpdate = 0;
  36162. }
  36163. }
  36164. }
  36165. }
  36166. }
  36167. }
  36168. },
  36169. onStoreCreate: function(store, session, id) {
  36170. var me = this,
  36171. matrix;
  36172. if (session) {
  36173. matrix = session.getMatrixSlice(me.inverse, id);
  36174. matrix.attach(store);
  36175. matrix.notify = me.onMatrixUpdate;
  36176. matrix.scope = me;
  36177. }
  36178. },
  36179. processMatrixBlock: function(session, leftKeys, state) {
  36180. var inverse = this.inverse,
  36181. digitRe = this.digitRe,
  36182. slice, id;
  36183. if (leftKeys) {
  36184. for (id in leftKeys) {
  36185. if (digitRe.test(id)) {
  36186. id = parseInt(id, 10);
  36187. }
  36188. slice = session.getMatrixSlice(inverse, id);
  36189. slice.update(leftKeys[id], state);
  36190. }
  36191. }
  36192. },
  36193. createGetter: function() {
  36194. var me = this;
  36195. return function(options, scope, leftRecords) {
  36196. return me.getAssociatedStore(this, options, scope, leftRecords, false);
  36197. };
  36198. },
  36199. onAddToMany: function(store, leftRecords, load) {
  36200. if (!store.matrixUpdate) {
  36201. store.matrixUpdate = 1;
  36202. store.matrix.update(leftRecords, load === true ? 0 : 1);
  36203. store.matrixUpdate = 0;
  36204. }
  36205. },
  36206. onRemoveFromMany: function(store, records) {
  36207. if (!store.matrixUpdate) {
  36208. store.matrixUpdate = 1;
  36209. store.matrix.update(records, -1);
  36210. store.matrixUpdate = 0;
  36211. }
  36212. },
  36213. read: function(rightRecord, node, fromReader, readOptions) {
  36214. var me = this,
  36215. leftRecords = me.callParent([
  36216. rightRecord,
  36217. node,
  36218. fromReader,
  36219. readOptions
  36220. ]);
  36221. if (leftRecords) {
  36222. rightRecord[me.getterName](null, null, leftRecords);
  36223. delete rightRecord.data[me.role];
  36224. }
  36225. },
  36226. onMatrixUpdate: function(matrixSlice, id, state) {
  36227. var store = matrixSlice.store,
  36228. index, leftRecord, entry;
  36229. if (store && !store.loading && !store.matrixUpdate) {
  36230. store.matrixUpdate = 1;
  36231. index = store.indexOfId(id);
  36232. if (state < 0) {
  36233. if (index >= 0) {
  36234. store.remove([
  36235. index
  36236. ]);
  36237. }
  36238. } else if (index < 0) {
  36239. entry = store.getSession().getEntry(this.type, id);
  36240. leftRecord = entry && entry.record;
  36241. if (leftRecord) {
  36242. store.add(leftRecord);
  36243. }
  36244. }
  36245. store.matrixUpdate = 0;
  36246. }
  36247. },
  36248. adoptAssociated: function(record, session) {
  36249. var store = this.getAssociatedItem(record),
  36250. records, i, len;
  36251. if (store) {
  36252. store.setSession(session);
  36253. this.onStoreCreate(store, session, record.getId());
  36254. records = store.getData().items;
  36255. for (i = 0 , len = records.length; i < len; ++i) {
  36256. session.adopt(records[i]);
  36257. }
  36258. }
  36259. }
  36260. }, function() {
  36261. var Left = this;
  36262. Ext.ClassManager.onCreated(function() {
  36263. Ext.data.schema.ManyToMany.prototype.Right = Ext.define(null, {
  36264. extend: Left,
  36265. left: false,
  36266. side: 'right'
  36267. });
  36268. }, null, 'Ext.data.schema.ManyToMany');
  36269. })
  36270. });
  36271. Ext.define('Ext.util.Inflector', {
  36272. singleton: true,
  36273. plurals: [
  36274. [
  36275. (/(quiz)$/i),
  36276. "$1zes"
  36277. ],
  36278. [
  36279. (/^(ox)$/i),
  36280. "$1en"
  36281. ],
  36282. [
  36283. (/([m|l])ouse$/i),
  36284. "$1ice"
  36285. ],
  36286. [
  36287. (/(matr|vert|ind)ix|ex$/i),
  36288. "$1ices"
  36289. ],
  36290. [
  36291. (/(x|ch|ss|sh)$/i),
  36292. "$1es"
  36293. ],
  36294. [
  36295. (/([^aeiouy]|qu)y$/i),
  36296. "$1ies"
  36297. ],
  36298. [
  36299. (/(hive)$/i),
  36300. "$1s"
  36301. ],
  36302. [
  36303. (/(?:([^f])fe|([lr])f)$/i),
  36304. "$1$2ves"
  36305. ],
  36306. [
  36307. (/sis$/i),
  36308. "ses"
  36309. ],
  36310. [
  36311. (/([ti])um$/i),
  36312. "$1a"
  36313. ],
  36314. [
  36315. (/(buffal|tomat|potat)o$/i),
  36316. "$1oes"
  36317. ],
  36318. [
  36319. (/(bu)s$/i),
  36320. "$1ses"
  36321. ],
  36322. [
  36323. (/(alias|status|sex)$/i),
  36324. "$1es"
  36325. ],
  36326. [
  36327. (/(octop|vir)us$/i),
  36328. "$1i"
  36329. ],
  36330. [
  36331. (/(ax|test)is$/i),
  36332. "$1es"
  36333. ],
  36334. [
  36335. (/^(p)erson$/i),
  36336. "$1eople"
  36337. ],
  36338. [
  36339. (/^(m)an$/i),
  36340. "$1en"
  36341. ],
  36342. [
  36343. (/(.*)(child)(ren)?$/i),
  36344. "$1$2ren"
  36345. ],
  36346. [
  36347. (/s$/i),
  36348. "s"
  36349. ],
  36350. [
  36351. (/$/),
  36352. "s"
  36353. ]
  36354. ],
  36355. singulars: [
  36356. [
  36357. (/(address)$/i),
  36358. "$1"
  36359. ],
  36360. [
  36361. (/(quiz)zes$/i),
  36362. "$1"
  36363. ],
  36364. [
  36365. (/(matr)ices$/i),
  36366. "$1ix"
  36367. ],
  36368. [
  36369. (/(vert|ind)ices$/i),
  36370. "$1ex"
  36371. ],
  36372. [
  36373. (/^(ox)en/i),
  36374. "$1"
  36375. ],
  36376. [
  36377. (/(alias|status)es$/i),
  36378. "$1"
  36379. ],
  36380. [
  36381. (/(octop|vir)i$/i),
  36382. "$1us"
  36383. ],
  36384. [
  36385. (/(cris|ax|test)es$/i),
  36386. "$1is"
  36387. ],
  36388. [
  36389. (/(shoe)s$/i),
  36390. "$1"
  36391. ],
  36392. [
  36393. (/(o)es$/i),
  36394. "$1"
  36395. ],
  36396. [
  36397. (/(bus)es$/i),
  36398. "$1"
  36399. ],
  36400. [
  36401. (/([m|l])ice$/i),
  36402. "$1ouse"
  36403. ],
  36404. [
  36405. (/(x|ch|ss|sh)es$/i),
  36406. "$1"
  36407. ],
  36408. [
  36409. (/(m)ovies$/i),
  36410. "$1ovie"
  36411. ],
  36412. [
  36413. (/(s)eries$/i),
  36414. "$1eries"
  36415. ],
  36416. [
  36417. (/([^aeiouy]|qu)ies$/i),
  36418. "$1y"
  36419. ],
  36420. [
  36421. (/([lr])ves$/i),
  36422. "$1f"
  36423. ],
  36424. [
  36425. (/(tive)s$/i),
  36426. "$1"
  36427. ],
  36428. [
  36429. (/(hive)s$/i),
  36430. "$1"
  36431. ],
  36432. [
  36433. (/([^f])ves$/i),
  36434. "$1fe"
  36435. ],
  36436. [
  36437. (/(^analy)ses$/i),
  36438. "$1sis"
  36439. ],
  36440. [
  36441. (/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i),
  36442. "$1$2sis"
  36443. ],
  36444. [
  36445. (/([ti])a$/i),
  36446. "$1um"
  36447. ],
  36448. [
  36449. (/(n)ews$/i),
  36450. "$1ews"
  36451. ],
  36452. [
  36453. (/(p)eople$/i),
  36454. "$1erson"
  36455. ],
  36456. [
  36457. (/s$/i),
  36458. ""
  36459. ]
  36460. ],
  36461. uncountable: [
  36462. "sheep",
  36463. "fish",
  36464. "series",
  36465. "species",
  36466. "money",
  36467. "rice",
  36468. "information",
  36469. "equipment",
  36470. "grass",
  36471. "mud",
  36472. "offspring",
  36473. "deer",
  36474. "means"
  36475. ],
  36476. singular: function(matcher, replacer) {
  36477. this.singulars.unshift([
  36478. matcher,
  36479. replacer
  36480. ]);
  36481. },
  36482. plural: function(matcher, replacer) {
  36483. this.plurals.unshift([
  36484. matcher,
  36485. replacer
  36486. ]);
  36487. },
  36488. clearSingulars: function() {
  36489. this.singulars = [];
  36490. },
  36491. clearPlurals: function() {
  36492. this.plurals = [];
  36493. },
  36494. isTransnumeral: function(word) {
  36495. return Ext.Array.indexOf(this.uncountable, word) !== -1;
  36496. },
  36497. pluralize: function(word) {
  36498. if (this.isTransnumeral(word)) {
  36499. return word;
  36500. }
  36501. var plurals = this.plurals,
  36502. length = plurals.length,
  36503. tuple, regex, i;
  36504. for (i = 0; i < length; i++) {
  36505. tuple = plurals[i];
  36506. regex = tuple[0];
  36507. if (regex == word || (regex.test && regex.test(word))) {
  36508. return word.replace(regex, tuple[1]);
  36509. }
  36510. }
  36511. return word;
  36512. },
  36513. singularize: function(word) {
  36514. if (this.isTransnumeral(word)) {
  36515. return word;
  36516. }
  36517. var singulars = this.singulars,
  36518. length = singulars.length,
  36519. tuple, regex, i;
  36520. for (i = 0; i < length; i++) {
  36521. tuple = singulars[i];
  36522. regex = tuple[0];
  36523. if (regex == word || (regex.test && regex.test(word))) {
  36524. return word.replace(regex, tuple[1]);
  36525. }
  36526. }
  36527. return word;
  36528. },
  36529. classify: function(word) {
  36530. return Ext.String.capitalize(this.singularize(word));
  36531. },
  36532. ordinalize: function(number) {
  36533. var parsed = parseInt(number, 10),
  36534. mod10 = parsed % 10,
  36535. mod100 = parsed % 100;
  36536. if (11 <= mod100 && mod100 <= 13) {
  36537. return number + "th";
  36538. } else {
  36539. switch (mod10) {
  36540. case 1:
  36541. return number + "st";
  36542. case 2:
  36543. return number + "nd";
  36544. case 3:
  36545. return number + "rd";
  36546. default:
  36547. return number + "th";
  36548. }
  36549. }
  36550. }
  36551. }, function() {
  36552. var singular,
  36553. irregulars = {
  36554. alumnus: 'alumni',
  36555. cactus: 'cacti',
  36556. focus: 'foci',
  36557. nucleus: 'nuclei',
  36558. radius: 'radii',
  36559. stimulus: 'stimuli',
  36560. ellipsis: 'ellipses',
  36561. paralysis: 'paralyses',
  36562. oasis: 'oases',
  36563. appendix: 'appendices',
  36564. index: 'indexes',
  36565. beau: 'beaux',
  36566. bureau: 'bureaux',
  36567. tableau: 'tableaux',
  36568. woman: 'women',
  36569. child: 'children',
  36570. man: 'men',
  36571. corpus: 'corpora',
  36572. criterion: 'criteria',
  36573. curriculum: 'curricula',
  36574. genus: 'genera',
  36575. memorandum: 'memoranda',
  36576. phenomenon: 'phenomena',
  36577. foot: 'feet',
  36578. goose: 'geese',
  36579. tooth: 'teeth',
  36580. antenna: 'antennae',
  36581. formula: 'formulae',
  36582. nebula: 'nebulae',
  36583. vertebra: 'vertebrae',
  36584. vita: 'vitae'
  36585. };
  36586. for (singular in irregulars) {
  36587. if (irregulars.hasOwnProperty(singular)) {
  36588. this.plural(singular, irregulars[singular]);
  36589. this.singular(irregulars[singular], singular);
  36590. }
  36591. }
  36592. });
  36593. Ext.define('Ext.data.schema.Namer', {
  36594. mixins: [
  36595. Ext.mixin.Factoryable
  36596. ],
  36597. alias: 'namer.default',
  36598. isNamer: true,
  36599. capitalize: function(name) {
  36600. return Ext.String.capitalize(name);
  36601. },
  36602. fieldRole: function(name) {
  36603. var match = name.match(this.endsWithIdRe, '');
  36604. if (match) {
  36605. name = name.substr(0, name.length - (match[1] || match[2]).length);
  36606. }
  36607. return this.apply('uncapitalize', name);
  36608. },
  36609. idField: function(name) {
  36610. return this.apply('uncapitalize,singularize', name) + 'Id';
  36611. },
  36612. instanceName: function(roleName) {
  36613. return this.apply('underscore', roleName);
  36614. },
  36615. multiRole: function(name) {
  36616. return this.apply('undotted,uncapitalize,pluralize', name);
  36617. },
  36618. pluralize: function(name) {
  36619. return Ext.util.Inflector.pluralize(name);
  36620. },
  36621. readerRoot: function(roleName) {
  36622. return this.apply('uncapitalize', roleName);
  36623. },
  36624. singularize: function(name) {
  36625. return Ext.util.Inflector.singularize(name);
  36626. },
  36627. storeName: function(roleName) {
  36628. return this.apply('underscore', roleName);
  36629. },
  36630. uncapitalize: function(name) {
  36631. return Ext.String.uncapitalize(name);
  36632. },
  36633. underscore: function(name) {
  36634. return '_' + name;
  36635. },
  36636. uniRole: function(name) {
  36637. return this.apply('undotted,uncapitalize,singularize', name);
  36638. },
  36639. undotted: function(name) {
  36640. var parts, index;
  36641. if (name.indexOf('.') < 0) {
  36642. return name;
  36643. }
  36644. parts = name.split('.');
  36645. index = parts.length;
  36646. while (index-- > 1) {
  36647. parts[index] = this.apply('capitalize', parts[index]);
  36648. }
  36649. return parts.join('');
  36650. },
  36651. getterName: function(role) {
  36652. var name = role.role;
  36653. if (role && role.isMany) {
  36654. return name;
  36655. }
  36656. return 'get' + this.apply('capitalize', name);
  36657. },
  36658. inverseFieldRole: function(leftType, unique, rightRole, rightType) {
  36659. var me = this,
  36660. leftRole = me.apply(unique ? 'uniRole' : 'multiRole', leftType),
  36661. s1 = me.apply('pluralize', rightRole),
  36662. s2 = me.apply('undotted,pluralize', rightType);
  36663. if (s1.toLowerCase() !== s2.toLowerCase()) {
  36664. leftRole = rightRole + me.apply('capitalize', leftRole);
  36665. }
  36666. return leftRole;
  36667. },
  36668. manyToMany: function(relation, leftType, rightType) {
  36669. var me = this,
  36670. ret = me.apply('undotted,capitalize,singularize', leftType) + me.apply('undotted,capitalize,pluralize', rightType);
  36671. if (relation) {
  36672. ret = me.apply('capitalize', relation + ret);
  36673. }
  36674. return ret;
  36675. },
  36676. manyToOne: function(leftType, leftRole, rightType, rightRole) {
  36677. return this.apply('capitalize,singularize', rightType) + this.apply('capitalize', leftRole);
  36678. },
  36679. matrixRole: function(relation, entityType) {
  36680. var ret = this.apply(relation ? 'multiRole,capitalize' : 'multiRole', entityType);
  36681. return relation ? relation + ret : ret;
  36682. },
  36683. oneToOne: function(leftType, leftRole, rightType, rightRole) {
  36684. return this.apply('undotted,capitalize,singularize', rightType) + this.apply('capitalize', leftRole);
  36685. },
  36686. setterName: function(role) {
  36687. return 'set' + this.apply('capitalize', role.role);
  36688. },
  36689. endsWithIdRe: /(?:(_id)|[^A-Z](Id))$/,
  36690. cache: {},
  36691. apply: function(operation, name) {
  36692. var me = this,
  36693. cache = me.cache,
  36694. entry = cache[name] || (cache[name] = {}),
  36695. ret = entry[operation],
  36696. i, length, operations;
  36697. if (!ret) {
  36698. if (operation.indexOf(',') < 0) {
  36699. ret = me[operation](name);
  36700. } else {
  36701. length = (operations = operation.split(',')).length;
  36702. ret = name;
  36703. for (i = 0; i < length; ++i) {
  36704. ret = me.apply(operations[i], ret);
  36705. }
  36706. }
  36707. entry[operation] = ret;
  36708. }
  36709. return ret;
  36710. }
  36711. });
  36712. Ext.define('Ext.data.schema.Schema', {
  36713. mixins: [
  36714. Ext.mixin.Factoryable
  36715. ],
  36716. alias: 'schema.default',
  36717. aliasPrefix: 'schema.',
  36718. isSchema: true,
  36719. type: 'default',
  36720. statics: {
  36721. instances: {},
  36722. clearInstance: function(id) {
  36723. var schema = this.instances[id];
  36724. delete this.instances[id];
  36725. if (schema) {
  36726. schema.clear(true);
  36727. schema.destroy();
  36728. }
  36729. },
  36730. get: function(config) {
  36731. var Schema = this,
  36732. cache = Schema.instances,
  36733. id = 'default',
  36734. isString = config && Ext.isString(config),
  36735. instance, newConfig;
  36736. if (config) {
  36737. if (config.isSchema) {
  36738. return config;
  36739. }
  36740. id = isString ? config : (config.id || id);
  36741. }
  36742. if (!(instance = cache[id])) {
  36743. cache[id] = instance = Schema.create(config);
  36744. instance.id = id;
  36745. } else if (config && !isString) {
  36746. if (id !== 'default') {
  36747. Ext.raise('Only the default Schema instance can be reconfigured');
  36748. }
  36749. newConfig = Ext.merge({}, instance.config);
  36750. Ext.merge(newConfig, config);
  36751. instance.setConfig(newConfig);
  36752. instance.config = newConfig;
  36753. instance.setConfig = function() {
  36754. Ext.raise('The schema can only be reconfigured once');
  36755. };
  36756. }
  36757. return instance;
  36758. },
  36759. lookupEntity: function(entity) {
  36760. var ret = null,
  36761. instances = this.instances,
  36762. match, name, schema;
  36763. if (entity) {
  36764. if (entity.isEntity) {
  36765. ret = entity.self;
  36766. }
  36767. else if (Ext.isFunction(entity)) {
  36768. ret = entity;
  36769. } else if (Ext.isString(entity)) {
  36770. ret = Ext.ClassManager.get(entity);
  36771. if (ret && (!ret.prototype || !ret.prototype.isEntity)) {
  36772. ret = null;
  36773. }
  36774. if (!ret) {
  36775. for (name in instances) {
  36776. schema = instances[name];
  36777. match = schema.getEntity(entity);
  36778. if (match) {
  36779. if (ret) {
  36780. Ext.raise('Ambiguous entity name "' + entity + '". Defined by schema "' + ret.schema.type + '" and "' + name + '"');
  36781. }
  36782. ret = match;
  36783. }
  36784. }
  36785. }
  36786. if (!ret) {
  36787. Ext.raise('No such Entity "' + entity + '".');
  36788. }
  36789. }
  36790. }
  36791. return ret;
  36792. }
  36793. },
  36794. assocCount: 0,
  36795. entityCount: 0,
  36796. config: {
  36797. defaultIdentifier: null,
  36798. keyCheckDelay: 10,
  36799. namer: 'default',
  36800. namespace: null,
  36801. proxy: {
  36802. type: 'ajax',
  36803. url: '{prefix}/{entityName}'
  36804. },
  36805. urlPrefix: ''
  36806. },
  36807. onClassExtended: function(cls, data) {
  36808. var alias = data.alias;
  36809. if (alias && !data.type) {
  36810. if (!Ext.isString(alias)) {
  36811. alias = alias[0];
  36812. }
  36813. cls.prototype.type = alias.substring(this.prototype.aliasPrefix.length);
  36814. }
  36815. },
  36816. constructor: function(config) {
  36817. this.initConfig(config);
  36818. this.clear();
  36819. },
  36820. applyDefaultIdentifier: function(identifier) {
  36821. return identifier && Ext.Factory.dataIdentifier(identifier);
  36822. },
  36823. applyNamer: function(namer) {
  36824. var ret = Ext.data.schema.Namer.create(namer);
  36825. ret.schema = this;
  36826. return ret;
  36827. },
  36828. applyNamespace: function(namespace) {
  36829. var end;
  36830. if (namespace) {
  36831. end = namespace.length - 1;
  36832. if (namespace.charAt(end) !== '.') {
  36833. namespace += '.';
  36834. }
  36835. }
  36836. return namespace;
  36837. },
  36838. applyProxy: function(proxy) {
  36839. return Ext.util.ObjectTemplate.create(proxy);
  36840. },
  36841. eachAssociation: function(fn, scope) {
  36842. var associations = this.associations,
  36843. name;
  36844. for (name in associations) {
  36845. if (associations.hasOwnProperty(name)) {
  36846. if (fn.call(scope, name, associations[name]) === false) {
  36847. break;
  36848. }
  36849. }
  36850. }
  36851. },
  36852. eachEntity: function(fn, scope) {
  36853. var entities = this.entities,
  36854. name;
  36855. for (name in entities) {
  36856. if (entities.hasOwnProperty(name)) {
  36857. if (fn.call(scope, name, entities[name].cls) === false) {
  36858. break;
  36859. }
  36860. }
  36861. }
  36862. },
  36863. getAssociation: function(name) {
  36864. var entry = this.associations[name];
  36865. return entry || null;
  36866. },
  36867. getEntity: function(name) {
  36868. var entry = this.entityClasses[name] || this.entities[name];
  36869. return (entry && entry.cls) || null;
  36870. },
  36871. getEntityName: function(cls) {
  36872. var ns = this.getNamespace(),
  36873. index, name;
  36874. if (typeof cls === 'string') {
  36875. name = cls;
  36876. } else {
  36877. name = cls.$className || null;
  36878. }
  36879. if (name) {
  36880. if (ns) {
  36881. index = ns.length;
  36882. if (name.substring(0, index) !== ns) {
  36883. return name;
  36884. }
  36885. }
  36886. if (index) {
  36887. name = name.substring(index);
  36888. }
  36889. }
  36890. return name;
  36891. },
  36892. hasAssociations: function(name) {
  36893. name = name.entityName || name;
  36894. return !!this.associationEntityMap[name];
  36895. },
  36896. hasEntity: function(entity) {
  36897. var name = this.getEntityName(entity);
  36898. return !!(this.entities[name] || this.entityClasses[name]);
  36899. },
  36900. addMatrix: function(entityType, matrixName, relation, left, right) {
  36901. var me = this,
  36902. namer = me.getNamer(),
  36903. associations = me.associations,
  36904. entities = me.entities,
  36905. leftType = left.type,
  36906. rightType = right.type,
  36907. leftField = left.field || namer.apply('idField', leftType),
  36908. rightField = right.field || namer.apply('idField', rightType),
  36909. leftRole = left.role || namer.matrixRole(relation, leftType),
  36910. rightRole = right.role || namer.matrixRole(relation, rightType),
  36911. matrix, leftEntry, rightEntry;
  36912. leftEntry = entities[leftType] || (entities[leftType] = {
  36913. cls: null,
  36914. name: leftType,
  36915. associations: {}
  36916. });
  36917. rightEntry = entities[rightType] || (entities[rightType] = {
  36918. cls: null,
  36919. name: rightType,
  36920. associations: {}
  36921. });
  36922. ++me.assocCount;
  36923. associations[matrixName] = matrix = new Ext.data.schema.ManyToMany({
  36924. name: matrixName,
  36925. schema: me,
  36926. definedBy: entityType,
  36927. left: {
  36928. cls: leftEntry.cls,
  36929. type: leftType,
  36930. role: leftRole,
  36931. field: leftField,
  36932. associationKey: left.associationKey
  36933. },
  36934. right: {
  36935. cls: rightEntry.cls,
  36936. type: rightType,
  36937. role: rightRole,
  36938. field: rightField,
  36939. associationKey: right.associationKey
  36940. }
  36941. });
  36942. leftEntry.associations[matrix.right.role] = matrix.right;
  36943. rightEntry.associations[matrix.left.role] = matrix.left;
  36944. if (leftEntry.cls) {
  36945. me.associationEntityMap[leftEntry.cls.entityName] = true;
  36946. }
  36947. if (rightEntry.cls) {
  36948. me.associationEntityMap[rightEntry.cls.entityName] = true;
  36949. }
  36950. me.decorateModel(matrix);
  36951. },
  36952. addReference: function(entityType, referenceField, descr, unique, dupeCheck) {
  36953. var me = this,
  36954. namer = me.getNamer(),
  36955. entities = me.entities,
  36956. associations = me.associations,
  36957. entityName = entityType.entityName,
  36958. association = descr.association,
  36959. child = descr.child,
  36960. parent = descr.parent,
  36961. rightRole = descr.role,
  36962. rightType = descr.type || parent || child,
  36963. leftVal = descr.inverse,
  36964. left = Ext.isString(leftVal) ? {
  36965. role: leftVal
  36966. } : leftVal,
  36967. leftRole = left && left.role,
  36968. entry, T;
  36969. if (!rightRole) {
  36970. if (!referenceField || descr.legacy) {
  36971. rightRole = namer.apply('uncapitalize', rightType);
  36972. } else {
  36973. rightRole = namer.apply('fieldRole', referenceField.name);
  36974. }
  36975. }
  36976. if (!leftRole) {
  36977. leftRole = namer.inverseFieldRole(entityName, unique, rightRole, rightType);
  36978. }
  36979. if (!association) {
  36980. if (unique) {
  36981. association = namer.oneToOne(entityType, leftRole, rightType, rightRole);
  36982. } else {
  36983. association = namer.manyToOne(entityType, leftRole, rightType, rightRole);
  36984. }
  36985. }
  36986. if (dupeCheck && association in associations) {
  36987. if (dupeCheck(associations[association], association, leftRole, rightRole) !== false) {
  36988. return;
  36989. }
  36990. }
  36991. if (association in associations) {
  36992. Ext.raise('Duplicate association: "' + association + '" declared by ' + entityName + (referenceField ? ('.' + referenceField.name) : '') + ' (collides with ' + associations[association].definedBy.entityName + ')');
  36993. }
  36994. if (referenceField && referenceField.definedBy === entities[rightType]) {
  36995. Ext.raise('ForeignKey reference should not be owned by the target model');
  36996. }
  36997. entry = entities[rightType] || (entities[rightType] = {
  36998. cls: null,
  36999. name: rightType,
  37000. associations: {}
  37001. });
  37002. T = unique ? Ext.data.schema.OneToOne : Ext.data.schema.ManyToOne;
  37003. association = new T({
  37004. name: association,
  37005. owner: child ? 'left' : (parent ? 'right' : null),
  37006. definedBy: entityType,
  37007. schema: me,
  37008. field: referenceField,
  37009. nullable: referenceField ? !!referenceField.allowBlank : true,
  37010. left: {
  37011. cls: entityType,
  37012. type: entityName,
  37013. role: leftRole,
  37014. extra: left
  37015. },
  37016. right: {
  37017. cls: entry.cls,
  37018. type: rightType,
  37019. role: rightRole,
  37020. extra: descr
  37021. },
  37022. meta: descr
  37023. });
  37024. entityType.associations[rightRole] = association.right;
  37025. entry.associations[leftRole] = association.left;
  37026. if (referenceField) {
  37027. referenceField.reference = association.right;
  37028. entityType.references.push(referenceField);
  37029. }
  37030. ++me.assocCount;
  37031. me.associationEntityMap[entityName] = true;
  37032. if (entry.cls) {
  37033. me.associationEntityMap[entry.cls.entityName] = true;
  37034. }
  37035. associations[association.name] = association;
  37036. if (association.right.cls) {
  37037. me.decorateModel(association);
  37038. }
  37039. },
  37040. privates: {
  37041. addEntity: function(entityType) {
  37042. var me = this,
  37043. entities = me.entities,
  37044. entityName = entityType.entityName,
  37045. entry = entities[entityName],
  37046. fields = entityType.fields,
  37047. associations, field, i, length, name;
  37048. if (!entry) {
  37049. entities[entityName] = entry = {
  37050. name: entityName,
  37051. associations: {}
  37052. };
  37053. }
  37054. else if (entry.cls) {
  37055. Ext.raise('Duplicate entity name "' + entityName + '": ' + entry.cls.$className + ' and ' + entityType.$className);
  37056. } else
  37057. {
  37058. associations = entry.associations;
  37059. for (name in associations) {
  37060. associations[name].inverse.cls = entityType;
  37061. me.associationEntityMap[entityName] = true;
  37062. me.decorateModel(associations[name].association);
  37063. }
  37064. }
  37065. entry.cls = entityType;
  37066. entityType.prototype.associations = entityType.associations = entry.associations;
  37067. me.entityClasses[entityType.$className] = entry;
  37068. ++me.entityCount;
  37069. for (i = 0 , length = fields.length; i < length; ++i) {
  37070. field = fields[i];
  37071. if (field.reference) {
  37072. me.addReferenceDescr(entityType, field);
  37073. }
  37074. }
  37075. },
  37076. addMatrices: function(entityType, matrices) {
  37077. var me = this,
  37078. i, length, matrixName;
  37079. if (Ext.isString(matrices)) {
  37080. me.addMatrixDescr(entityType, null, matrices);
  37081. } else if (matrices[0]) {
  37082. for (i = 0 , length = matrices.length; i < length; ++i) {
  37083. me.addMatrixDescr(entityType, null, matrices[i]);
  37084. }
  37085. } else {
  37086. for (matrixName in matrices) {
  37087. me.addMatrixDescr(entityType, matrixName, matrices[matrixName]);
  37088. }
  37089. }
  37090. },
  37091. addMatrixDescr: function(entityType, matrixName, matrixDef) {
  37092. var me = this,
  37093. entityName = entityType.entityName,
  37094. associations = me.associations,
  37095. namer = me.getNamer(),
  37096. left = matrixDef.left,
  37097. right = matrixDef.right,
  37098. last, relation;
  37099. if (Ext.isString(matrixDef)) {
  37100. if (matrixDef.charAt(0) === '#') {
  37101. left = {
  37102. type: entityName
  37103. };
  37104. right = {
  37105. type: matrixDef.substring(1)
  37106. };
  37107. }
  37108. else if (matrixDef.charAt(last = matrixDef.length - 1) === '#') {
  37109. left = {
  37110. type: matrixDef.substring(0, last)
  37111. };
  37112. right = {
  37113. type: entityName
  37114. };
  37115. }
  37116. else if (namer.apply('multiRole', entityName) < namer.apply('multiRole', matrixDef)) {
  37117. left = {
  37118. type: entityName
  37119. };
  37120. right = {
  37121. type: matrixDef
  37122. };
  37123. } else
  37124. {
  37125. left = {
  37126. type: matrixDef
  37127. };
  37128. right = {
  37129. type: entityName
  37130. };
  37131. }
  37132. } else
  37133. {
  37134. Ext.Assert.isString(matrixDef.type, 'No "type" for manyToMany in ' + entityName);
  37135. relation = matrixDef.relation;
  37136. if (left || (!right && namer.apply('multiRole', entityName) < namer.apply('multiRole', matrixDef.type))) {
  37137. if (!left || left === true) {
  37138. left = {
  37139. type: entityName
  37140. };
  37141. } else
  37142. {
  37143. left = Ext.apply({
  37144. type: entityName
  37145. }, left);
  37146. }
  37147. right = matrixDef;
  37148. } else
  37149. {
  37150. if (!right || right === true) {
  37151. right = {
  37152. type: entityName
  37153. };
  37154. } else
  37155. {
  37156. right = Ext.apply({
  37157. type: entityName
  37158. }, right);
  37159. }
  37160. left = matrixDef;
  37161. }
  37162. }
  37163. if (!matrixName) {
  37164. matrixName = namer.manyToMany(relation, left.type, right.type);
  37165. }
  37166. if (!(matrixName in associations)) {
  37167. me.addMatrix(entityType, matrixName, relation, left, right);
  37168. } else
  37169. {
  37170. var entry = associations[matrixName],
  37171. before = [
  37172. entry.kind,
  37173. entry.left.type,
  37174. entry.left.role,
  37175. entry.left.field,
  37176. entry.right.type,
  37177. entry.right.role,
  37178. entry.right.field
  37179. ].join('|'),
  37180. after;
  37181. delete associations[matrixName];
  37182. me.addMatrix(entityType, matrixName, relation, left, right);
  37183. after = associations[matrixName];
  37184. associations[matrixName] = entry;
  37185. entry.left.cls.associations[entry.right.role] = entry.right;
  37186. entry.right.cls.associations[entry.left.role] = entry.left;
  37187. --me.assocCount;
  37188. after = [
  37189. after.kind,
  37190. after.left.type,
  37191. after.left.role,
  37192. after.left.field,
  37193. after.right.type,
  37194. after.right.role,
  37195. after.right.field
  37196. ].join('|');
  37197. if (before != after) {
  37198. Ext.log.warn(matrixName + '(' + entry.definedBy.entityName + '): ' + before);
  37199. Ext.log.warn(matrixName + '(' + entityName + '): ' + after);
  37200. Ext.raise('Conflicting association: "' + matrixName + '" declared by ' + entityName + ' was previously declared by ' + entry.definedBy.entityName);
  37201. }
  37202. }
  37203. },
  37204. addReferenceDescr: function(entityType, referenceField) {
  37205. var me = this,
  37206. descr = referenceField.$reference;
  37207. if (Ext.isString(descr)) {
  37208. descr = {
  37209. type: descr
  37210. };
  37211. } else {
  37212. descr = Ext.apply({}, descr);
  37213. }
  37214. me.addReference(entityType, referenceField, descr, referenceField.unique);
  37215. },
  37216. addBelongsTo: function(entityType, assoc) {
  37217. this.addKeylessSingle(entityType, assoc, false);
  37218. },
  37219. addHasOne: function(entityType, assoc) {
  37220. this.addKeylessSingle(entityType, assoc, true);
  37221. },
  37222. addKeylessSingle: function(entityType, assoc, unique) {
  37223. var foreignKey, referenceField;
  37224. assoc = Ext.apply({}, this.checkLegacyAssociation(entityType, assoc));
  37225. assoc.type = this.getEntityName(assoc.child || assoc.parent || assoc.type);
  37226. foreignKey = assoc.foreignKey || (assoc.type.toLowerCase() + '_id');
  37227. referenceField = entityType.getField(foreignKey);
  37228. assoc.fromSingle = true;
  37229. if (referenceField) {
  37230. referenceField.$reference = assoc;
  37231. referenceField.unique = true;
  37232. assoc.legacy = true;
  37233. Ext.log.warn('Using foreignKey is deprecated, use a keyed association. ' + 'See Ext.data.field.Field.reference');
  37234. }
  37235. this.addReference(entityType, referenceField, assoc, unique);
  37236. },
  37237. addHasMany: function(entityType, assoc) {
  37238. var me = this,
  37239. entities = me.entities,
  37240. pending = me.pending,
  37241. cls, name, referenceField, target, foreignKey, inverseOptions, child, declaredInverse;
  37242. assoc = Ext.apply({}, this.checkLegacyAssociation(entityType, assoc));
  37243. assoc.type = this.getEntityName(assoc.child || assoc.parent || assoc.type);
  37244. name = assoc.type;
  37245. target = entities[name];
  37246. cls = target && target.cls;
  37247. if (cls) {
  37248. name = entityType.entityName;
  37249. foreignKey = assoc.foreignKey || (name.toLowerCase() + '_id');
  37250. delete assoc.foreignKey;
  37251. declaredInverse = Ext.apply({}, assoc.inverse);
  37252. delete assoc.inverse;
  37253. inverseOptions = Ext.apply({}, assoc);
  37254. delete inverseOptions.type;
  37255. assoc = Ext.apply({
  37256. type: name,
  37257. inverse: inverseOptions
  37258. }, declaredInverse);
  37259. child = inverseOptions.child;
  37260. if (child) {
  37261. delete inverseOptions.child;
  37262. assoc.parent = name;
  37263. }
  37264. referenceField = cls.getField(foreignKey);
  37265. if (referenceField) {
  37266. referenceField.$reference = assoc;
  37267. assoc.legacy = true;
  37268. Ext.log.warn('Using foreignKey is deprecated, use a keyed association. ' + 'See Ext.data.field.Field.reference');
  37269. }
  37270. me.addReference(cls, referenceField, assoc, false,
  37271. function(association, name, leftRole, rightRole) {
  37272. var result = !!association.meta.fromSingle && cls === association.left.cls,
  37273. l, r;
  37274. if (result) {
  37275. l = cls.entityName;
  37276. r = entityType.entityName;
  37277. Ext.raise('hasMany ("' + r + '") and belongsTo ("' + l + '") should not be used in conjunction to declare ' + 'a relationship. Use only one.');
  37278. }
  37279. return result;
  37280. });
  37281. } else
  37282. {
  37283. if (!pending[name]) {
  37284. pending[name] = [];
  37285. }
  37286. pending[name].push([
  37287. entityType,
  37288. assoc
  37289. ]);
  37290. }
  37291. },
  37292. checkLegacyAssociation: function(entityType, assoc) {
  37293. var name;
  37294. if (Ext.isString(assoc)) {
  37295. assoc = {
  37296. type: assoc
  37297. };
  37298. } else {
  37299. assoc = Ext.apply({}, assoc);
  37300. }
  37301. if (assoc.model) {
  37302. assoc.type = assoc.model;
  37303. delete assoc.model;
  37304. }
  37305. name = assoc.associatedName || assoc.name;
  37306. if (name) {
  37307. delete assoc.associatedName;
  37308. delete assoc.name;
  37309. assoc.role = name;
  37310. }
  37311. return assoc;
  37312. },
  37313. afterKeylessAssociations: function(cls) {
  37314. var pending = this.pending,
  37315. name = cls.entityName,
  37316. mine = pending[name],
  37317. i, len;
  37318. if (mine) {
  37319. for (i = 0 , len = mine.length; i < len; ++i) {
  37320. this.addHasMany.apply(this, mine[i]);
  37321. }
  37322. delete pending[name];
  37323. }
  37324. },
  37325. clear: function(clearNamespace) {
  37326. var me = this,
  37327. timer = me.timer;
  37328. delete me.setConfig;
  37329. if (timer) {
  37330. window.clearTimeout(timer);
  37331. me.timer = null;
  37332. }
  37333. me.associations = {};
  37334. me.associationEntityMap = {};
  37335. me.entities = {};
  37336. me.entityClasses = {};
  37337. me.pending = {};
  37338. me.assocCount = me.entityCount = 0;
  37339. if (clearNamespace) {
  37340. me.setNamespace(null);
  37341. }
  37342. },
  37343. constructProxy: function(Model) {
  37344. var me = this,
  37345. data = Ext.Object.chain(Model),
  37346. proxy = me.getProxy();
  37347. data.schema = me;
  37348. data.prefix = me.getUrlPrefix();
  37349. return proxy.apply(data);
  37350. },
  37351. applyDecoration: function(role) {
  37352. var me = this,
  37353. cls = role.inverse.cls,
  37354. namer = me.getNamer(),
  37355. getterName, setterName, proto;
  37356. if (cls && !role.decorated) {
  37357. role.decorated = true;
  37358. proto = cls.prototype;
  37359. if (!(getterName = role.getterName)) {
  37360. role.getterName = getterName = namer.getterName(role);
  37361. }
  37362. proto[getterName] = role.createGetter();
  37363. if (role.createSetter) {
  37364. if (!(setterName = role.setterName)) {
  37365. role.setterName = setterName = namer.setterName(role);
  37366. }
  37367. proto[setterName] = role.createSetter();
  37368. }
  37369. }
  37370. },
  37371. decorateModel: function(association) {
  37372. this.applyDecoration(association.left);
  37373. this.applyDecoration(association.right);
  37374. },
  37375. processKeyChecks: function(processAll) {
  37376. var me = this,
  37377. keyCheckQueue = me.keyCheckQueue,
  37378. timer = me.timer,
  37379. len, i, item;
  37380. if (timer) {
  37381. window.clearTimeout(timer);
  37382. me.timer = null;
  37383. }
  37384. if (!keyCheckQueue) {
  37385. return;
  37386. }
  37387. do {
  37388. keyCheckQueue = me.keyCheckQueue;
  37389. me.keyCheckQueue = [];
  37390. for (i = 0 , len = keyCheckQueue.length; i < len; ++i) {
  37391. item = keyCheckQueue[i];
  37392. item.role.checkKeyForDrop(item.record);
  37393. }
  37394. } while (processAll && me.keyCheckQueue.length);
  37395. },
  37396. queueKeyCheck: function(record, role) {
  37397. var me = this,
  37398. keyCheckQueue = me.keyCheckQueue,
  37399. timer = me.timer;
  37400. if (!keyCheckQueue) {
  37401. me.keyCheckQueue = keyCheckQueue = [];
  37402. }
  37403. keyCheckQueue.push({
  37404. record: record,
  37405. role: role
  37406. });
  37407. if (!timer) {
  37408. me.timer = timer = Ext.defer(me.processKeyChecks, me.getKeyCheckDelay(), me);
  37409. }
  37410. },
  37411. rankEntities: function() {
  37412. var me = this,
  37413. entities = me.entities,
  37414. entityNames = Ext.Object.getKeys(entities),
  37415. length = entityNames.length,
  37416. entityType, i;
  37417. me.nextRank = 1;
  37418. entityNames.sort();
  37419. for (i = 0; i < length; ++i) {
  37420. entityType = entities[entityNames[i]].cls;
  37421. if (!entityType.rank) {
  37422. me.rankEntity(entityType);
  37423. }
  37424. }
  37425. me.topoStack = null;
  37426. },
  37427. rankEntity: function(entityType) {
  37428. var associations = entityType.associations,
  37429. associatedType, role, roleName;
  37430. var topoStack = this.topoStack || (this.topoStack = []),
  37431. entityName = entityType.entityName;
  37432. topoStack.push(entityName);
  37433. if (entityType.rank === 0) {
  37434. Ext.raise(entityName + " has circular foreign-key references: " + topoStack.join(" --> "));
  37435. }
  37436. entityType.rank = 0;
  37437. for (roleName in associations) {
  37438. role = associations[roleName];
  37439. if (!role.left && role.association.field) {
  37440. associatedType = role.cls;
  37441. if (!associatedType.rank) {
  37442. this.rankEntity(associatedType);
  37443. }
  37444. }
  37445. }
  37446. entityType.rank = this.nextRank++;
  37447. topoStack.pop();
  37448. }
  37449. }
  37450. });
  37451. Ext.define('Ext.data.AbstractStore', {
  37452. mixins: [
  37453. Ext.mixin.Observable,
  37454. Ext.mixin.Factoryable
  37455. ],
  37456. factoryConfig: {
  37457. defaultType: 'store',
  37458. type: 'store'
  37459. },
  37460. $configPrefixed: false,
  37461. $configStrict: false,
  37462. config: {
  37463. filters: null,
  37464. autoDestroy: undefined,
  37465. storeId: null,
  37466. statefulFilters: false,
  37467. sorters: null,
  37468. remoteSort: {
  37469. lazy: true,
  37470. $value: false
  37471. },
  37472. remoteFilter: {
  37473. lazy: true,
  37474. $value: false
  37475. },
  37476. groupField: undefined,
  37477. groupDir: 'ASC',
  37478. grouper: null,
  37479. pageSize: 25,
  37480. autoSort: null,
  37481. reloadOnClearSorters: false
  37482. },
  37483. currentPage: 1,
  37484. loading: false,
  37485. isStore: true,
  37486. updating: 0,
  37487. constructor: function(config) {
  37488. var me = this,
  37489. storeId;
  37490. me.callParent([
  37491. config
  37492. ]);
  37493. me.isInitializing = true;
  37494. me.mixins.observable.constructor.call(me, config);
  37495. me.isInitializing = false;
  37496. storeId = me.getStoreId();
  37497. if (!storeId && (config && config.id)) {
  37498. me.setStoreId(storeId = config.id);
  37499. }
  37500. if (storeId) {
  37501. Ext.data.StoreManager.register(me);
  37502. }
  37503. },
  37504. createActiveRange: function(config) {
  37505. var range = Ext.apply({
  37506. store: this
  37507. }, config);
  37508. return new Ext.data.Range(range);
  37509. },
  37510. syncActiveRanges: function() {
  37511. var activeRanges = this.activeRanges,
  37512. len = activeRanges && activeRanges.length,
  37513. i;
  37514. for (i = 0; i < len; i++) {
  37515. activeRanges[i].refresh();
  37516. }
  37517. },
  37518. getCount: function() {
  37519. var data = this.getData();
  37520. return data ? data.getCount() : 0;
  37521. },
  37522. rangeCached: function(start, end) {
  37523. return this.getData().getCount() >= Math.max(start, end);
  37524. },
  37525. find: function(property, value, startIndex, anyMatch, caseSensitive, exactMatch) {
  37526. var startsWith = !anyMatch,
  37527. endsWith = !!(startsWith && exactMatch);
  37528. return this.getData().findIndex(property, value, startIndex, startsWith, endsWith, !caseSensitive);
  37529. },
  37530. findRecord: function() {
  37531. var me = this,
  37532. index = me.find.apply(me, arguments);
  37533. return index !== -1 ? me.getAt(index) : null;
  37534. },
  37535. findExact: function(fieldName, value, startIndex) {
  37536. return this.getData().findIndexBy(function(rec) {
  37537. return rec.isEqual(rec.get(fieldName), value);
  37538. }, this, startIndex);
  37539. },
  37540. findBy: function(fn, scope, start) {
  37541. return this.getData().findIndexBy(fn, scope, start);
  37542. },
  37543. getAt: function(index) {
  37544. return this.getData().getAt(index) || null;
  37545. },
  37546. getRange: function(start, end, options) {
  37547. var result = this.getData().getRange(start, Ext.isNumber(end) ? end + 1 : end);
  37548. if (options && options.callback) {
  37549. options.callback.call(options.scope || this, result, start, end, options);
  37550. }
  37551. return result;
  37552. },
  37553. getFilters: function(autoCreate) {
  37554. var me = this,
  37555. result = me.callParent();
  37556. if (!result && autoCreate !== false) {
  37557. me.setFilters([]);
  37558. result = me.callParent();
  37559. }
  37560. return result;
  37561. },
  37562. applyFilters: function(filters, filtersCollection) {
  37563. var me = this,
  37564. created;
  37565. if (!filtersCollection) {
  37566. filtersCollection = me.createFiltersCollection();
  37567. created = true;
  37568. }
  37569. filtersCollection.add(filters);
  37570. if (created) {
  37571. me.onRemoteFilterSet(filtersCollection, me.getRemoteFilter());
  37572. }
  37573. return filtersCollection;
  37574. },
  37575. getSorters: function(autoCreate) {
  37576. var me = this,
  37577. result = me.callParent();
  37578. if (!result && autoCreate !== false) {
  37579. me.setSorters([]);
  37580. result = me.callParent();
  37581. }
  37582. return result;
  37583. },
  37584. applySorters: function(sorters, sortersCollection) {
  37585. var me = this,
  37586. created;
  37587. if (!sortersCollection) {
  37588. sortersCollection = me.createSortersCollection();
  37589. created = true;
  37590. }
  37591. sortersCollection.add(sorters);
  37592. if (created) {
  37593. me.onRemoteSortSet(sortersCollection, me.getRemoteSort());
  37594. }
  37595. return sortersCollection;
  37596. },
  37597. filter: function(filters, value, suppressEvent) {
  37598. if (Ext.isString(filters)) {
  37599. filters = {
  37600. property: filters,
  37601. value: value
  37602. };
  37603. }
  37604. this.suppressNextFilter = !!suppressEvent;
  37605. this.getFilters().add(filters);
  37606. this.suppressNextFilter = false;
  37607. },
  37608. removeFilter: function(toRemove, suppressEvent) {
  37609. var me = this,
  37610. filters = me.getFilters();
  37611. me.suppressNextFilter = !!suppressEvent;
  37612. if (toRemove instanceof Ext.util.Filter) {
  37613. filters.remove(toRemove);
  37614. } else {
  37615. filters.removeByKey(toRemove);
  37616. }
  37617. me.suppressNextFilter = false;
  37618. },
  37619. updateAutoSort: function(autoSort) {
  37620. this.getData().setAutoSort(autoSort);
  37621. },
  37622. updateRemoteSort: function(remoteSort) {
  37623. this.onRemoteSortSet(this.getSorters(false), remoteSort);
  37624. },
  37625. updateRemoteFilter: function(remoteFilter) {
  37626. this.onRemoteFilterSet(this.getFilters(false), remoteFilter);
  37627. },
  37628. addFilter: function(filters, suppressEvent) {
  37629. this.suppressNextFilter = !!suppressEvent;
  37630. this.getFilters().add(filters);
  37631. this.suppressNextFilter = false;
  37632. },
  37633. filterBy: function(fn, scope) {
  37634. this.getFilters().add({
  37635. filterFn: fn,
  37636. scope: scope || this
  37637. });
  37638. },
  37639. clearFilter: function(suppressEvent) {
  37640. var me = this,
  37641. filters = me.getFilters(false);
  37642. if (!filters || filters.getCount() === 0) {
  37643. return;
  37644. }
  37645. me.suppressNextFilter = !!suppressEvent;
  37646. filters.removeAll();
  37647. me.suppressNextFilter = false;
  37648. },
  37649. isFiltered: function() {
  37650. return this.getFilters().getCount() > 0;
  37651. },
  37652. isSorted: function() {
  37653. var sorters = this.getSorters(false);
  37654. return !!(sorters && sorters.length > 0) || this.isGrouped();
  37655. },
  37656. addFieldTransform: function(sorter) {
  37657. if (sorter.getTransform()) {
  37658. return;
  37659. }
  37660. var fieldName = sorter.getProperty(),
  37661. Model = this.getModel(),
  37662. field, sortType;
  37663. if (Model) {
  37664. field = Model.getField(fieldName);
  37665. sortType = field ? field.getSortType() : null;
  37666. }
  37667. if (sortType && sortType !== Ext.identityFn) {
  37668. sorter.setTransform(sortType);
  37669. }
  37670. },
  37671. beginUpdate: function() {
  37672. if (!this.updating++ && this.hasListeners.beginupdate) {
  37673. this.fireEvent('beginupdate');
  37674. }
  37675. },
  37676. endUpdate: function() {
  37677. if (this.updating && !--this.updating) {
  37678. if (this.hasListeners.endupdate) {
  37679. this.fireEvent('endupdate');
  37680. }
  37681. this.onEndUpdate();
  37682. }
  37683. },
  37684. getState: function() {
  37685. var me = this,
  37686. sorters = [],
  37687. filters = me.getFilters(),
  37688. grouper = me.getGrouper(),
  37689. filterState, hasState, result;
  37690. me.getSorters().each(function(s) {
  37691. sorters[sorters.length] = s.getState();
  37692. hasState = true;
  37693. });
  37694. if (me.statefulFilters && me.saveStatefulFilters) {
  37695. hasState = true;
  37696. filterState = [];
  37697. filters.each(function(f) {
  37698. filterState[filterState.length] = f.getState();
  37699. });
  37700. }
  37701. if (grouper) {
  37702. hasState = true;
  37703. }
  37704. if (hasState) {
  37705. result = {};
  37706. if (sorters.length) {
  37707. result.sorters = sorters;
  37708. }
  37709. if (filterState) {
  37710. result.filters = filterState;
  37711. }
  37712. if (grouper) {
  37713. result.grouper = grouper.getState();
  37714. }
  37715. }
  37716. return result;
  37717. },
  37718. applyState: function(state) {
  37719. var me = this,
  37720. stateSorters = state.sorters,
  37721. stateFilters = state.filters,
  37722. stateGrouper = state.grouper;
  37723. if (stateSorters) {
  37724. me.getSorters().replaceAll(stateSorters);
  37725. }
  37726. if (stateFilters) {
  37727. me.saveStatefulFilters = true;
  37728. me.getFilters().replaceAll(stateFilters);
  37729. }
  37730. if (stateGrouper) {
  37731. me.setGrouper(stateGrouper);
  37732. }
  37733. },
  37734. hasPendingLoad: Ext.emptyFn,
  37735. isLoaded: Ext.emptyFn,
  37736. isLoading: Ext.emptyFn,
  37737. destroy: function() {
  37738. var me = this;
  37739. if (me.hasListeners.beforedestroy) {
  37740. me.fireEvent('beforedestroy', me);
  37741. }
  37742. me.destroying = true;
  37743. if (me.getStoreId()) {
  37744. Ext.data.StoreManager.unregister(me);
  37745. }
  37746. me.doDestroy();
  37747. if (me.hasListeners.destroy) {
  37748. me.fireEvent('destroy', me);
  37749. }
  37750. me.callParent();
  37751. },
  37752. doDestroy: Ext.emptyFn,
  37753. sort: function(field, direction, mode) {
  37754. var me = this;
  37755. if (arguments.length === 0) {
  37756. if (me.getRemoteSort()) {
  37757. me.load();
  37758. } else {
  37759. me.forceLocalSort();
  37760. }
  37761. } else {
  37762. me.getSorters().addSort(field, direction, mode);
  37763. }
  37764. },
  37765. onBeforeCollectionSort: function(store, sorters) {
  37766. if (sorters) {
  37767. this.fireEvent('beforesort', this, sorters.getRange());
  37768. }
  37769. },
  37770. onSorterEndUpdate: function() {
  37771. var me = this,
  37772. fireSort = true,
  37773. sorters = me.getSorters(false),
  37774. sorterCount;
  37775. if (me.settingGroups || !sorters) {
  37776. return;
  37777. }
  37778. sorters = sorters.getRange();
  37779. sorterCount = sorters.length;
  37780. if (me.getRemoteSort()) {
  37781. if (sorters.length || me.getReloadOnClearSorters()) {
  37782. fireSort = false;
  37783. me.load({
  37784. callback: function() {
  37785. me.fireEvent('sort', me, sorters);
  37786. }
  37787. });
  37788. }
  37789. } else if (sorterCount) {
  37790. me.fireEvent('datachanged', me);
  37791. me.fireEvent('refresh', me);
  37792. }
  37793. if (fireSort) {
  37794. me.fireEvent('sort', me, sorters);
  37795. }
  37796. },
  37797. onFilterEndUpdate: function() {
  37798. var me = this,
  37799. suppressNext = me.suppressNextFilter,
  37800. filters = me.getFilters(false);
  37801. if (!filters) {
  37802. return;
  37803. }
  37804. if (me.getRemoteFilter()) {
  37805. me.getFilters().each(function(filter) {
  37806. if (filter.getInitialConfig().filterFn) {
  37807. Ext.raise('Unable to use a filtering function in conjunction with ' + 'remote filtering.');
  37808. }
  37809. });
  37810. me.currentPage = 1;
  37811. if (!suppressNext) {
  37812. me.load();
  37813. }
  37814. } else if (!suppressNext) {
  37815. me.fireEvent('datachanged', me);
  37816. me.fireEvent('refresh', me);
  37817. }
  37818. if (me.trackStateChanges) {
  37819. me.saveStatefulFilters = true;
  37820. }
  37821. me.fireEvent('filterchange', me, me.getFilters().getRange());
  37822. },
  37823. updateGroupField: function(field) {
  37824. if (field) {
  37825. this.setGrouper({
  37826. property: field,
  37827. direction: this.getGroupDir()
  37828. });
  37829. } else {
  37830. this.setGrouper(null);
  37831. }
  37832. },
  37833. getGrouper: function() {
  37834. return this.getData().getGrouper();
  37835. },
  37836. group: function(grouper, direction) {
  37837. var me = this,
  37838. sorters = me.getSorters(false),
  37839. change = grouper || (sorters && sorters.length),
  37840. data = me.getData();
  37841. if (grouper && typeof grouper === 'string') {
  37842. grouper = {
  37843. property: grouper,
  37844. direction: direction || me.getGroupDir()
  37845. };
  37846. }
  37847. me.settingGroups = true;
  37848. if (grouper === data.getGrouper()) {
  37849. data.updateGrouper(grouper);
  37850. } else {
  37851. data.setGrouper(grouper);
  37852. }
  37853. delete me.settingGroups;
  37854. if (change) {
  37855. if (me.getRemoteSort()) {
  37856. if (!me.isInitializing) {
  37857. me.load({
  37858. scope: me,
  37859. callback: function() {
  37860. me.fireGroupChange();
  37861. }
  37862. });
  37863. }
  37864. } else
  37865. {
  37866. me.fireEvent('datachanged', me);
  37867. me.fireEvent('refresh', me);
  37868. me.fireGroupChange();
  37869. }
  37870. } else
  37871. {
  37872. me.fireGroupChange();
  37873. }
  37874. },
  37875. fireGroupChange: function(grouper) {
  37876. var me = this;
  37877. if (!me.isConfiguring && !me.destroying && !me.destroyed) {
  37878. me.fireGroupChangeEvent(grouper || me.getGrouper());
  37879. }
  37880. },
  37881. fireGroupChangeEvent: function(grouper) {
  37882. this.fireEvent('groupchange', this, grouper);
  37883. },
  37884. clearGrouping: function() {
  37885. this.group(null);
  37886. },
  37887. getGroupField: function() {
  37888. var grouper = this.getGrouper(),
  37889. group = '';
  37890. if (grouper) {
  37891. group = grouper.getProperty();
  37892. }
  37893. return group;
  37894. },
  37895. isGrouped: function() {
  37896. return !!this.getGrouper();
  37897. },
  37898. applyGrouper: function(grouper) {
  37899. this.group(grouper);
  37900. return this.getData().getGrouper();
  37901. },
  37902. getGroups: function() {
  37903. return this.getData().getGroups();
  37904. },
  37905. onEndUpdate: Ext.emptyFn,
  37906. privates: {
  37907. _metaProperties: {
  37908. count: 'getCount',
  37909. first: 'first',
  37910. last: 'last',
  37911. loading: 'hasPendingLoad',
  37912. totalCount: 'getTotalCount'
  37913. },
  37914. interpret: function(name) {
  37915. var me = this,
  37916. accessor = me._metaProperties[name];
  37917. return accessor && me[accessor]();
  37918. },
  37919. loadsSynchronously: Ext.privateFn,
  37920. onRemoteFilterSet: function(filters, remoteFilter) {
  37921. if (filters) {
  37922. filters[remoteFilter ? 'on' : 'un']('endupdate', 'onFilterEndUpdate', this);
  37923. }
  37924. },
  37925. onRemoteSortSet: function(sorters, remoteSort) {
  37926. var me = this,
  37927. data;
  37928. if (sorters) {
  37929. sorters[remoteSort ? 'on' : 'un']('endupdate', 'onSorterEndUpdate', me);
  37930. data = me.getData();
  37931. if (data) {
  37932. data[remoteSort ? 'un' : 'on']('beforesort', 'onBeforeCollectionSort', me);
  37933. }
  37934. }
  37935. }
  37936. },
  37937. deprecated: {
  37938. 5: {
  37939. methods: {
  37940. destroyStore: function() {
  37941. this.destroy();
  37942. }
  37943. }
  37944. }
  37945. }
  37946. });
  37947. Ext.define('Ext.data.Error', {
  37948. isError: true,
  37949. $configPrefixed: false,
  37950. config: {
  37951. field: null,
  37952. message: ''
  37953. },
  37954. constructor: function(config) {
  37955. this.initConfig(config);
  37956. this.msg = this.message;
  37957. }
  37958. });
  37959. Ext.define('Ext.data.ErrorCollection', {
  37960. extend: Ext.util.MixedCollection,
  37961. alternateClassName: 'Ext.data.Errors',
  37962. init: function(record) {
  37963. var me = this,
  37964. fields = record.fields,
  37965. data = record.data,
  37966. before, field, i, len, msg, val, name;
  37967. for (i = 0 , len = fields.length; i < len; ++i) {
  37968. field = fields[i];
  37969. name = field.name;
  37970. val = data[name];
  37971. if (field.validate && !field.validate.$nullFn) {
  37972. before = me.length;
  37973. msg = field.validate(val, null, me, record);
  37974. if (before === me.length && msg !== true) {
  37975. me.add(name, msg);
  37976. }
  37977. }
  37978. }
  37979. return me;
  37980. },
  37981. add: function(key, value) {
  37982. var me = this,
  37983. defaultMessage = Ext.data.field.Field.defaultInvalidMessage,
  37984. obj = key,
  37985. current;
  37986. if (Ext.isString(key)) {
  37987. obj = new Ext.data.Error({
  37988. field: key,
  37989. message: value || defaultMessage
  37990. });
  37991. } else {
  37992. if (!(obj.isError)) {
  37993. obj = new Ext.data.Error({
  37994. field: obj.field || obj.name,
  37995. message: obj.error || obj.message || obj.msg || defaultMessage
  37996. });
  37997. }
  37998. key = obj.field;
  37999. }
  38000. current = me.get(key);
  38001. if (current) {
  38002. if (Ext.isArray(current)) {
  38003. current.push(obj);
  38004. return current;
  38005. }
  38006. me.removeAtKey(key);
  38007. obj = [
  38008. current,
  38009. obj
  38010. ];
  38011. obj.field = key;
  38012. obj = [
  38013. obj
  38014. ];
  38015. }
  38016. return me.callParent([
  38017. obj
  38018. ]);
  38019. },
  38020. getKey: function(item) {
  38021. return item.field;
  38022. },
  38023. isValid: function() {
  38024. return this.length === 0;
  38025. },
  38026. getByField: function(fieldName) {
  38027. var values = this.get(fieldName);
  38028. if (values && !Ext.isArray(values)) {
  38029. values = [
  38030. values
  38031. ];
  38032. }
  38033. return values || [];
  38034. }
  38035. });
  38036. Ext.define('Ext.data.operation.Operation', {
  38037. alternateClassName: 'Ext.data.Operation',
  38038. isOperation: true,
  38039. config: {
  38040. synchronous: false,
  38041. url: '',
  38042. params: undefined,
  38043. callback: undefined,
  38044. scope: undefined,
  38045. resultSet: null,
  38046. response: null,
  38047. request: null,
  38048. records: null,
  38049. id: undefined,
  38050. proxy: null,
  38051. batch: null,
  38052. recordCreator: null,
  38053. internalCallback: null,
  38054. internalScope: null
  38055. },
  38056. order: 0,
  38057. foreignKeyDirection: 1,
  38058. started: false,
  38059. running: false,
  38060. complete: false,
  38061. success: undefined,
  38062. exception: false,
  38063. error: undefined,
  38064. idPrefix: 'ext-operation-',
  38065. constructor: function(config) {
  38066. var scope = config && config.scope;
  38067. this.initConfig(config);
  38068. if (config) {
  38069. config.scope = scope;
  38070. }
  38071. if (scope) {
  38072. this.setScope(scope);
  38073. this.initialConfig.scope = scope;
  38074. }
  38075. this._internalId = Ext.id(this, this.idPrefix);
  38076. },
  38077. getAction: function() {
  38078. return this.action;
  38079. },
  38080. execute: function() {
  38081. var me = this,
  38082. request;
  38083. delete me.error;
  38084. delete me.success;
  38085. me.complete = me.exception = false;
  38086. me.setStarted();
  38087. me.request = request = me.doExecute();
  38088. if (request) {
  38089. request.setOperation(me);
  38090. }
  38091. return request;
  38092. },
  38093. doExecute: Ext.emptyFn,
  38094. abort: function() {
  38095. var me = this,
  38096. request = me.request,
  38097. proxy;
  38098. me.aborted = true;
  38099. if (me.running && request) {
  38100. proxy = me.getProxy();
  38101. if (proxy && !proxy.destroyed) {
  38102. proxy.abort(request);
  38103. }
  38104. me.request = null;
  38105. }
  38106. me.running = false;
  38107. },
  38108. process: function(resultSet, request, response, autoComplete) {
  38109. var me = this;
  38110. autoComplete = autoComplete !== false;
  38111. me.setResponse(response);
  38112. me.setResultSet(resultSet);
  38113. if (resultSet.getSuccess()) {
  38114. me.doProcess(resultSet, request, response);
  38115. me.setSuccessful(autoComplete);
  38116. } else if (autoComplete) {
  38117. me.setException(resultSet.getMessage());
  38118. }
  38119. },
  38120. _commitSetOptions: {
  38121. convert: true,
  38122. commit: true
  38123. },
  38124. doProcess: function(resultSet, request, response) {
  38125. var me = this,
  38126. commitSetOptions = me._commitSetOptions,
  38127. clientRecords = me.getRecords(),
  38128. clientLen = clientRecords.length,
  38129. clientIdProperty = clientRecords[0].clientIdProperty,
  38130. serverRecords = resultSet.getRecords(),
  38131. serverLen = serverRecords ? serverRecords.length : 0,
  38132. clientMap, serverRecord, clientRecord, i;
  38133. if (serverLen && clientIdProperty) {
  38134. clientMap = Ext.Array.toValueMap(clientRecords, 'id');
  38135. for (i = 0; i < serverLen; ++i) {
  38136. serverRecord = serverRecords[i];
  38137. clientRecord = clientMap[serverRecord[clientIdProperty]];
  38138. if (clientRecord) {
  38139. delete clientMap[clientRecord.id];
  38140. delete serverRecord[clientIdProperty];
  38141. clientRecord.set(serverRecord, commitSetOptions);
  38142. } else
  38143. {
  38144. Ext.log.warn('Ignoring server record: ' + Ext.encode(serverRecord));
  38145. }
  38146. }
  38147. for (i in clientMap) {
  38148. clientMap[i].commit();
  38149. }
  38150. } else {
  38151. for (i = 0; i < clientLen; ++i) {
  38152. clientRecord = clientRecords[i];
  38153. if (serverLen === 0 || !(serverRecord = serverRecords[i])) {
  38154. clientRecord.commit();
  38155. } else {
  38156. clientRecord.set(serverRecord, commitSetOptions);
  38157. }
  38158. }
  38159. }
  38160. },
  38161. setStarted: function() {
  38162. this.started = this.running = true;
  38163. },
  38164. setCompleted: function() {
  38165. var me = this,
  38166. proxy;
  38167. me.complete = true;
  38168. me.running = false;
  38169. if (!me.destroying) {
  38170. me.triggerCallbacks();
  38171. }
  38172. if (me.destroyed) {
  38173. return;
  38174. }
  38175. proxy = me.getProxy();
  38176. if (proxy && !proxy.destroyed) {
  38177. proxy.completeOperation(me);
  38178. }
  38179. },
  38180. setSuccessful: function(complete) {
  38181. this.success = true;
  38182. if (complete) {
  38183. this.setCompleted();
  38184. }
  38185. },
  38186. setException: function(error) {
  38187. var me = this;
  38188. me.exception = true;
  38189. me.success = me.running = false;
  38190. me.error = error;
  38191. me.setCompleted();
  38192. },
  38193. triggerCallbacks: function() {
  38194. var me = this,
  38195. callback = me.getInternalCallback();
  38196. if (callback) {
  38197. callback.call(me.getInternalScope() || me, me);
  38198. if (me.destroyed) {
  38199. return;
  38200. }
  38201. me.setInternalCallback(null);
  38202. me.setInternalScope(null);
  38203. }
  38204. callback = me.getCallback();
  38205. if (callback) {
  38206. callback.call(me.getScope() || me, me.getRecords(), me, me.wasSuccessful());
  38207. if (me.destroyed) {
  38208. return;
  38209. }
  38210. me.setCallback(null);
  38211. me.setScope(null);
  38212. }
  38213. },
  38214. hasException: function() {
  38215. return this.exception;
  38216. },
  38217. getError: function() {
  38218. return this.error;
  38219. },
  38220. getRecords: function() {
  38221. var resultSet;
  38222. return this._records || ((resultSet = this.getResultSet()) ? resultSet.getRecords() : null);
  38223. },
  38224. isStarted: function() {
  38225. return this.started;
  38226. },
  38227. isRunning: function() {
  38228. return this.running;
  38229. },
  38230. isComplete: function() {
  38231. return this.complete;
  38232. },
  38233. wasSuccessful: function() {
  38234. return this.isComplete() && this.success === true;
  38235. },
  38236. allowWrite: function() {
  38237. return true;
  38238. },
  38239. destroy: function() {
  38240. var me = this;
  38241. me.destroying = true;
  38242. if (me.running) {
  38243. me.abort();
  38244. }
  38245. me._params = me._callback = me._scope = me._resultSet = me._response = null;
  38246. me.request = me._request = me._records = me._proxy = me._batch = null;
  38247. me._recordCreator = me._internalCallback = me._internalScope = null;
  38248. me.callParent();
  38249. }
  38250. });
  38251. Ext.define('Ext.data.operation.Create', {
  38252. extend: Ext.data.operation.Operation,
  38253. alias: 'data.operation.create',
  38254. action: 'create',
  38255. isCreateOperation: true,
  38256. order: 10,
  38257. config: {
  38258. recordCreator: Ext.identityFn
  38259. },
  38260. doExecute: function() {
  38261. return this.getProxy().create(this);
  38262. }
  38263. });
  38264. Ext.define('Ext.data.operation.Destroy', {
  38265. extend: Ext.data.operation.Operation,
  38266. alias: 'data.operation.destroy',
  38267. action: 'destroy',
  38268. isDestroyOperation: true,
  38269. order: 30,
  38270. foreignKeyDirection: -1,
  38271. doProcess: function()
  38272. {
  38273. var clientRecords = this.getRecords(),
  38274. clientLen = clientRecords.length,
  38275. i;
  38276. for (i = 0; i < clientLen; ++i) {
  38277. clientRecords[i].setErased();
  38278. }
  38279. },
  38280. doExecute: function() {
  38281. return this.getProxy().erase(this);
  38282. },
  38283. getRecordData: function(record, operation) {
  38284. var data = {},
  38285. idField = record.idField,
  38286. nameProperty = this.getNameProperty() || 'name';
  38287. data[idField[nameProperty]] = record.id;
  38288. return data;
  38289. }
  38290. });
  38291. Ext.define('Ext.data.operation.Read', {
  38292. extend: Ext.data.operation.Operation,
  38293. alias: 'data.operation.read',
  38294. action: 'read',
  38295. isReadOperation: true,
  38296. config: {
  38297. filters: undefined,
  38298. sorters: undefined,
  38299. grouper: undefined,
  38300. start: undefined,
  38301. limit: undefined,
  38302. page: undefined,
  38303. addRecords: false
  38304. },
  38305. doExecute: function() {
  38306. return this.getProxy().read(this);
  38307. },
  38308. doProcess: Ext.emptyFn,
  38309. allowWrite: function() {
  38310. return false;
  38311. }
  38312. });
  38313. Ext.define('Ext.data.operation.Update', {
  38314. extend: Ext.data.operation.Operation,
  38315. alias: 'data.operation.update',
  38316. action: 'update',
  38317. isUpdateOperation: true,
  38318. order: 20,
  38319. config: {
  38320. recordCreator: Ext.identityFn
  38321. },
  38322. doExecute: function() {
  38323. return this.getProxy().update(this);
  38324. }
  38325. });
  38326. Ext.define('Ext.data.SortTypes', function() {
  38327. var me;
  38328. return {
  38329. singleton: true,
  38330. constructor: function() {
  38331. me = this;
  38332. },
  38333. none: Ext.identityFn,
  38334. stripCommasRe: /,/g,
  38335. stripTagsRE: /<\/?[^>]+>/gi,
  38336. asText: function(s) {
  38337. return (s != null) ? String(s).replace(me.stripTagsRE, '') : '\x00';
  38338. },
  38339. asUCText: function(s) {
  38340. return (s != null) ? String(s).toUpperCase().replace(me.stripTagsRE, '') : '\x00';
  38341. },
  38342. asUCString: function(s) {
  38343. return (s != null) ? String(s).toUpperCase() : '\x00';
  38344. },
  38345. asDate: function(s) {
  38346. if (!s) {
  38347. return 0;
  38348. }
  38349. if (Ext.isDate(s)) {
  38350. return s.getTime();
  38351. }
  38352. return Date.parse(String(s));
  38353. },
  38354. asFloat: function(s) {
  38355. var val = parseFloat(String(s).replace(me.stripCommasRe, ''));
  38356. return isNaN(val) ? 0 : val;
  38357. },
  38358. asInt: function(s) {
  38359. var val = parseInt(String(s).replace(me.stripCommasRe, ''), 10);
  38360. return isNaN(val) ? 0 : val;
  38361. }
  38362. };
  38363. });
  38364. Ext.define('Ext.data.validator.Validator', {
  38365. mixins: [
  38366. Ext.mixin.Factoryable
  38367. ],
  38368. alias: 'data.validator.base',
  38369. isValidator: true,
  38370. factoryConfig: {
  38371. cacheable: true
  38372. },
  38373. type: 'base',
  38374. constructor: function(config) {
  38375. if (typeof config === 'function') {
  38376. this.fnOnly = true;
  38377. this.validate = config;
  38378. } else {
  38379. this.initConfig(config);
  38380. }
  38381. },
  38382. validate: function() {
  38383. return true;
  38384. },
  38385. clone: function() {
  38386. var me = this;
  38387. if (me.fnOnly) {
  38388. return new Ext.data.validator.Validator(me.validate);
  38389. }
  38390. return new me.self(me.getCurrentConfig());
  38391. }
  38392. }, function(Validator) {
  38393. Ext.Factory.validator = Ext.Factory.dataValidator;
  38394. });
  38395. Ext.define('Ext.data.field.Field', {
  38396. mixins: [
  38397. Ext.mixin.Factoryable
  38398. ],
  38399. alternateClassName: 'Ext.data.Field',
  38400. alias: 'data.field.auto',
  38401. aliasPrefix: 'data.field.',
  38402. type: 'auto',
  38403. factoryConfig: {
  38404. defaultProperty: 'name'
  38405. },
  38406. isDataField: true,
  38407. isField: true,
  38408. allowBlank: true,
  38409. allowNull: false,
  38410. critical: false,
  38411. defaultInvalidMessage: 'This field is invalid',
  38412. defaultValue: undefined,
  38413. definedBy: null,
  38414. depends: null,
  38415. dependents: null,
  38416. mapping: null,
  38417. name: null,
  38418. ordinal: undefined,
  38419. persist: null,
  38420. reference: null,
  38421. summary: null,
  38422. summaryField: '',
  38423. unique: false,
  38424. rank: null,
  38425. stripRe: /[$,%]/g,
  38426. calculated: false,
  38427. evil: false,
  38428. identifier: false,
  38429. onClassExtended: function(cls, data) {
  38430. var sortType = data.sortType,
  38431. proto = cls.prototype,
  38432. superValidators = proto.validators,
  38433. validators = data.validators,
  38434. alias = data.alias;
  38435. if (alias) {
  38436. if (typeof alias !== 'string') {
  38437. alias = alias[0];
  38438. }
  38439. if (alias) {
  38440. proto.type = alias.substr(alias.lastIndexOf('.') + 1);
  38441. }
  38442. }
  38443. if (sortType && Ext.isString(sortType)) {
  38444. proto.sortType = Ext.data.SortTypes[sortType];
  38445. }
  38446. if (validators) {
  38447. if (!Ext.isArray(validators)) {
  38448. validators = [
  38449. validators
  38450. ];
  38451. }
  38452. delete data.validators;
  38453. if (superValidators) {
  38454. validators = superValidators.concat(validators);
  38455. }
  38456. proto.validators = validators;
  38457. }
  38458. },
  38459. argumentNamesRe: /^function\s*\(\s*([^,\)\s]+)/,
  38460. calculateRe: /[^.a-z0-9_]([a-z_][a-z_0-9]*)\.([a-z_][a-z_0-9]*)/gi,
  38461. constructor: function(config) {
  38462. var me = this,
  38463. calculateRe = me.calculateRe,
  38464. calculate, calculated, defaultValue, sortType, depends, map, match, dataProp, str, fld, validators;
  38465. if (config) {
  38466. if (Ext.isString(config)) {
  38467. me.name = config;
  38468. } else {
  38469. validators = config.validators;
  38470. if (validators) {
  38471. delete config.validators;
  38472. me.instanceValidators = validators;
  38473. }
  38474. Ext.apply(me, config);
  38475. }
  38476. }
  38477. if (!me.allowNull) {
  38478. me.allowNull = !!me.reference;
  38479. }
  38480. calculate = me.calculate;
  38481. depends = me.depends;
  38482. if (calculate) {
  38483. me.convert = me.doCalculate;
  38484. if (!depends) {
  38485. if (!(depends = calculate.$depends)) {
  38486. map = {};
  38487. str = Ext.Function.toCode(calculate);
  38488. calculate.$depends = depends = [];
  38489. match = me.argumentNamesRe.exec(str);
  38490. dataProp = match ? match[1] : 'data';
  38491. while ((match = calculateRe.exec(str))) {
  38492. if (dataProp === match[1] && !map[fld = match[2]]) {
  38493. map[fld] = 1;
  38494. depends.push(fld);
  38495. }
  38496. }
  38497. }
  38498. me.depends = depends;
  38499. }
  38500. }
  38501. defaultValue = me.defaultValue;
  38502. if (me.convert) {
  38503. me.calculated = calculated = me.convert.length > 1;
  38504. me.evil = calculated && !depends;
  38505. }
  38506. if (me.persist === null) {
  38507. me.persist = !calculate;
  38508. }
  38509. sortType = me.sortType;
  38510. if (!me.sortType) {
  38511. me.sortType = Ext.data.SortTypes.none;
  38512. } else if (Ext.isString(sortType)) {
  38513. me.sortType = Ext.data.SortTypes[sortType];
  38514. }
  38515. if (depends && typeof depends === 'string') {
  38516. me.depends = [
  38517. depends
  38518. ];
  38519. }
  38520. me.cloneDefaultValue = defaultValue !== undefined && (Ext.isDate(defaultValue) || Ext.isArray(defaultValue) || Ext.isObject(defaultValue));
  38521. },
  38522. setModelValidators: function(modelValidators) {
  38523. this._validators = null;
  38524. this.modelValidators = modelValidators;
  38525. },
  38526. constructValidators: function(validators) {
  38527. var all, length, i, item, validator, presence;
  38528. if (validators) {
  38529. if (!(validators instanceof Array)) {
  38530. validators = [
  38531. validators
  38532. ];
  38533. }
  38534. all = this._validators;
  38535. for (i = 0 , length = validators.length; i < length; ++i) {
  38536. item = validators[i];
  38537. if (item.fn) {
  38538. item = item.fn;
  38539. }
  38540. validator = Ext.Factory.dataValidator(item);
  38541. if (!validator.isPresence) {
  38542. all.push(validator);
  38543. } else {
  38544. presence = validator;
  38545. }
  38546. }
  38547. if (presence) {
  38548. this.presence = [
  38549. presence
  38550. ];
  38551. }
  38552. }
  38553. },
  38554. collate: function(value1, value2) {
  38555. var me = this,
  38556. lhs = value1,
  38557. rhs = value2;
  38558. if (me.sortType) {
  38559. lhs = me.sortType(lhs);
  38560. rhs = me.sortType(rhs);
  38561. }
  38562. return (lhs === rhs) ? 0 : ((lhs < rhs) ? -1 : 1);
  38563. },
  38564. compare: function(value1, value2) {
  38565. return (value1 === value2) ? 0 : ((value1 < value2) ? -1 : 1);
  38566. },
  38567. isEqual: function(value1, value2) {
  38568. return this.compare(value1, value2) === 0;
  38569. },
  38570. convert: null,
  38571. serialize: null,
  38572. validate: function(value, separator, errors, record) {
  38573. var me = this,
  38574. validators = me.getValidators(),
  38575. result, presence;
  38576. presence = this.presence;
  38577. if (presence && (value == null || value === '')) {
  38578. result = me.validateGroup(presence, value, separator, errors, record);
  38579. if (result !== true) {
  38580. return result;
  38581. }
  38582. }
  38583. return me.validateGroup(validators, value, separator, errors, record);
  38584. },
  38585. validateGroup: function(validators, value, separator, errors, record) {
  38586. var ret = '',
  38587. validator, length, i, result;
  38588. for (i = 0 , length = validators.length; i < length; ++i) {
  38589. validator = validators[i];
  38590. result = validator.validate(value, record);
  38591. if (result !== true) {
  38592. result = result || this.defaultInvalidMessage;
  38593. if (errors) {
  38594. if (errors.isMixedCollection) {
  38595. errors.add(this.name, result);
  38596. } else if (errors.isCollection) {
  38597. errors.add(result);
  38598. } else {
  38599. errors.push(result);
  38600. }
  38601. ret = ret || result;
  38602. } else if (separator) {
  38603. if (ret) {
  38604. ret += separator;
  38605. }
  38606. ret += result;
  38607. } else {
  38608. ret = result;
  38609. break;
  38610. }
  38611. }
  38612. }
  38613. return ret || true;
  38614. },
  38615. doCalculate: function(v, rec) {
  38616. return rec ? this.calculate(rec.data) : v;
  38617. },
  38618. getName: function() {
  38619. return this.name;
  38620. },
  38621. getAllowBlank: function() {
  38622. return this.allowBlank;
  38623. },
  38624. getAllowNull: function() {
  38625. return this.allowNull;
  38626. },
  38627. getConvert: function() {
  38628. return this.convert;
  38629. },
  38630. getDefaultValue: function() {
  38631. return this.defaultValue;
  38632. },
  38633. getDepends: function() {
  38634. return this.depends;
  38635. },
  38636. getMapping: function() {
  38637. return this.mapping;
  38638. },
  38639. hasMapping: function() {
  38640. var map = this.mapping;
  38641. return !!(map || map === 0);
  38642. },
  38643. getPersist: function() {
  38644. return this.persist;
  38645. },
  38646. getSortType: function() {
  38647. return this.sortType;
  38648. },
  38649. getSummary: function() {
  38650. var me = this,
  38651. doneSummary = me.doneSummary,
  38652. summary = me.summary;
  38653. if (!doneSummary) {
  38654. me.doneSummary = true;
  38655. if (summary) {
  38656. me.summary = summary = Ext.Factory.dataSummary(summary);
  38657. }
  38658. }
  38659. return summary || null;
  38660. },
  38661. getType: function() {
  38662. return 'auto';
  38663. },
  38664. privates: {
  38665. getValidators: function() {
  38666. var me = this,
  38667. validators = me._validators;
  38668. if (!validators) {
  38669. me._validators = validators = [];
  38670. me.constructValidators(me.validators);
  38671. me.constructValidators(me.modelValidators);
  38672. me.constructValidators(me.instanceValidators);
  38673. }
  38674. return validators;
  38675. }
  38676. },
  38677. deprecated: {
  38678. 5.1: {
  38679. methods: {
  38680. getSortDir: function() {
  38681. return this.sortDir;
  38682. }
  38683. }
  38684. }
  38685. }
  38686. });
  38687. Ext.define('Ext.data.field.Boolean', {
  38688. extend: Ext.data.field.Field,
  38689. alias: [
  38690. 'data.field.bool',
  38691. 'data.field.boolean'
  38692. ],
  38693. isBooleanField: true,
  38694. trueRe: /^\s*(?:true|yes|on|1)\s*$/i,
  38695. convert: function(v) {
  38696. if (typeof v === 'boolean') {
  38697. return v;
  38698. }
  38699. if (this.allowNull && (v === undefined || v === null || v === '')) {
  38700. return null;
  38701. }
  38702. return this.trueRe.test(String(v));
  38703. },
  38704. getType: function() {
  38705. return 'bool';
  38706. }
  38707. });
  38708. Ext.define('Ext.data.field.Date', {
  38709. extend: Ext.data.field.Field,
  38710. alias: 'data.field.date',
  38711. sortType: 'asDate',
  38712. isDateField: true,
  38713. dateFormat: null,
  38714. dateReadFormat: null,
  38715. dateWriteFormat: null,
  38716. compare: function(lhs, rhs) {
  38717. var lhsIsDate = lhs instanceof Date,
  38718. rhsIsDate = rhs instanceof Date,
  38719. result;
  38720. if (rhsIsDate && lhsIsDate) {
  38721. result = lhs.getTime() - rhs.getTime();
  38722. if (result === 0) {
  38723. result = 0;
  38724. } else {
  38725. result = result < 0 ? -1 : 1;
  38726. }
  38727. } else if (lhsIsDate === rhsIsDate) {
  38728. result = 0;
  38729. } else {
  38730. result = lhsIsDate ? 1 : -1;
  38731. }
  38732. return result;
  38733. },
  38734. convert: function(v) {
  38735. if (!v) {
  38736. return null;
  38737. }
  38738. if (v instanceof Date) {
  38739. return v;
  38740. }
  38741. var dateFormat = this.dateReadFormat || this.dateFormat,
  38742. parsed;
  38743. if (dateFormat) {
  38744. return Ext.Date.parse(v, dateFormat, this.useStrict);
  38745. }
  38746. parsed = Date.parse(v);
  38747. return parsed ? new Date(parsed) : null;
  38748. },
  38749. serialize: function(value) {
  38750. var result = null,
  38751. format;
  38752. if (Ext.isDate(value)) {
  38753. format = this.getDateWriteFormat();
  38754. result = format ? Ext.Date.format(value, format) : value;
  38755. }
  38756. return result;
  38757. },
  38758. getDateFormat: function() {
  38759. return this.dateFormat;
  38760. },
  38761. getDateReadFormat: function() {
  38762. return this.dateReadFormat;
  38763. },
  38764. getDateWriteFormat: function() {
  38765. var me = this;
  38766. if (me.hasOwnProperty('dateWriteFormat')) {
  38767. return me.dateWriteFormat;
  38768. }
  38769. if (me.hasOwnProperty('dateFormat')) {
  38770. return me.dateFormat;
  38771. }
  38772. return me.dateWriteFormat || me.dateFormat || 'timestamp';
  38773. },
  38774. getType: function() {
  38775. return 'date';
  38776. }
  38777. });
  38778. Ext.define('Ext.data.field.Integer', {
  38779. extend: Ext.data.field.Field,
  38780. alias: [
  38781. 'data.field.int',
  38782. 'data.field.integer'
  38783. ],
  38784. isNumeric: true,
  38785. isIntegerField: true,
  38786. numericType: 'int',
  38787. convert: function(v) {
  38788. if (typeof v === 'number') {
  38789. return this.getNumber(v);
  38790. }
  38791. var empty = v == null || v === '',
  38792. allowNull = this.allowNull,
  38793. out;
  38794. if (empty) {
  38795. out = allowNull ? null : 0;
  38796. } else {
  38797. out = this.parse(v);
  38798. if (allowNull && isNaN(out)) {
  38799. out = null;
  38800. }
  38801. }
  38802. return out;
  38803. },
  38804. getNumber: function(v) {
  38805. return parseInt(v, 10);
  38806. },
  38807. getType: function() {
  38808. return this.numericType;
  38809. },
  38810. parse: function(v) {
  38811. return parseInt(String(v).replace(this.stripRe, ''), 10);
  38812. },
  38813. sortType: function(s) {
  38814. if (s == null) {
  38815. s = Infinity;
  38816. }
  38817. return s;
  38818. }
  38819. });
  38820. Ext.define('Ext.data.field.Number', {
  38821. extend: Ext.data.field.Integer,
  38822. alias: [
  38823. 'data.field.float',
  38824. 'data.field.number'
  38825. ],
  38826. isIntegerField: false,
  38827. isNumberField: true,
  38828. numericType: 'float',
  38829. getNumber: Ext.identityFn,
  38830. parse: function(v) {
  38831. return parseFloat(String(v).replace(this.stripRe, ''));
  38832. }
  38833. });
  38834. Ext.define('Ext.data.field.String', {
  38835. extend: Ext.data.field.Field,
  38836. alias: 'data.field.string',
  38837. sortType: 'asUCString',
  38838. isStringField: true,
  38839. convert: function(v) {
  38840. var defaultValue = this.allowNull ? null : '';
  38841. return (v === undefined || v === null) ? defaultValue : String(v);
  38842. },
  38843. getType: function() {
  38844. return 'string';
  38845. }
  38846. });
  38847. Ext.define('Ext.data.identifier.Generator', {
  38848. 'abstract': true,
  38849. mixins: [
  38850. Ext.mixin.Factoryable
  38851. ],
  38852. alias: 'data.identifier.default',
  38853. factoryConfig: {
  38854. defaultType: 'sequential'
  38855. },
  38856. isGenerator: true,
  38857. config: {
  38858. id: null
  38859. },
  38860. constructor: function(config) {
  38861. var me = this,
  38862. id;
  38863. me.initConfig(config);
  38864. id = me.getId();
  38865. if (id) {
  38866. Ext.data.identifier.Generator.all[id] = me;
  38867. }
  38868. },
  38869. privates: {
  38870. clone: function(config) {
  38871. var cfg = this.getInitialConfig();
  38872. cfg = config ? Ext.apply({}, config, cfg) : cfg;
  38873. return new this.self(cfg);
  38874. },
  38875. statics: {
  38876. all: {}
  38877. }
  38878. }
  38879. }, function() {
  38880. var Generator = this,
  38881. Factory = Ext.Factory,
  38882. factory = Factory.dataIdentifier;
  38883. Factory.dataIdentifier = function(config) {
  38884. var id = Ext.isString(config) ? config : (config && config.id),
  38885. existing = id && Generator.all[id];
  38886. return existing || factory(config);
  38887. };
  38888. });
  38889. Ext.define('Ext.data.identifier.Sequential', {
  38890. extend: Ext.data.identifier.Generator,
  38891. alias: 'data.identifier.sequential',
  38892. config: {
  38893. increment: 1,
  38894. prefix: null,
  38895. seed: 1
  38896. },
  38897. generate: function() {
  38898. var me = this,
  38899. seed = me._seed,
  38900. prefix = me._prefix;
  38901. me._seed += me._increment;
  38902. return (prefix !== null) ? prefix + seed : seed;
  38903. }
  38904. });
  38905. Ext.define('Ext.data.Model', {
  38906. alternateClassName: 'Ext.data.Record',
  38907. isEntity: true,
  38908. isModel: true,
  38909. validIdRe: null,
  38910. erasing: false,
  38911. loadOperation: null,
  38912. loadCount: 0,
  38913. observableType: 'record',
  38914. crudState: 'R',
  38915. crudStateWas: null,
  38916. constructor: function(data, session, skipStoreAddition) {
  38917. var me = this,
  38918. cls = me.self,
  38919. identifier = cls.identifier,
  38920. Model = Ext.data.Model,
  38921. modelIdentifier = Model.identifier,
  38922. idProperty = me.idField.name,
  38923. array, id, initializeFn, internalId, len, i, fields;
  38924. me.data = me.data = data || (data = {});
  38925. me.internalId = internalId = modelIdentifier.generate();
  38926. var dataId = data[idProperty];
  38927. if (session && !session.isSession) {
  38928. Ext.raise('Bad Model constructor argument 2 - "session" is not a Session');
  38929. }
  38930. if ((array = data) instanceof Array) {
  38931. me.data = data = {};
  38932. fields = me.getFields();
  38933. len = Math.min(fields.length, array.length);
  38934. for (i = 0; i < len; ++i) {
  38935. data[fields[i].name] = array[i];
  38936. }
  38937. }
  38938. if (!(initializeFn = cls.initializeFn)) {
  38939. cls.initializeFn = initializeFn = Model.makeInitializeFn(cls);
  38940. }
  38941. if (!initializeFn.$nullFn) {
  38942. cls.initializeFn(me);
  38943. }
  38944. if (!me.isSummaryModel) {
  38945. if (!(me.id = id = data[idProperty]) && id !== 0) {
  38946. if (dataId) {
  38947. Ext.raise('The model ID configured in data ("' + dataId + '") has been rejected by the ' + me.fieldsMap[idProperty].type + ' field converter for the ' + idProperty + ' field');
  38948. }
  38949. if (session) {
  38950. identifier = session.getIdentifier(cls);
  38951. id = identifier.generate();
  38952. } else if (modelIdentifier === identifier) {
  38953. id = internalId;
  38954. } else {
  38955. id = identifier.generate();
  38956. }
  38957. data[idProperty] = me.id = id;
  38958. me.phantom = true;
  38959. me.crudState = 'C';
  38960. }
  38961. if (session && !skipStoreAddition) {
  38962. session.add(me);
  38963. }
  38964. if (me.phantom) {
  38965. me.crudStateWas = 'C';
  38966. }
  38967. }
  38968. if (me.init && Ext.isFunction(me.init)) {
  38969. me.init();
  38970. }
  38971. },
  38972. editing: false,
  38973. dirty: false,
  38974. session: null,
  38975. dropped: false,
  38976. erased: false,
  38977. clientIdProperty: null,
  38978. evented: false,
  38979. phantom: false,
  38980. idProperty: 'id',
  38981. manyToMany: null,
  38982. identifier: null,
  38983. previousValues: undefined,
  38984. proxy: undefined,
  38985. schema: 'default',
  38986. summary: null,
  38987. versionProperty: null,
  38988. generation: 1,
  38989. validationSeparator: null,
  38990. convertOnSet: true,
  38991. beginEdit: function() {
  38992. var me = this,
  38993. modified = me.modified,
  38994. previousValues = me.previousValues;
  38995. if (!me.editing) {
  38996. me.editing = true;
  38997. me.editMemento = {
  38998. dirty: me.dirty,
  38999. data: Ext.apply({}, me.data),
  39000. generation: me.generation,
  39001. modified: modified && Ext.apply({}, modified),
  39002. previousValues: previousValues && Ext.apply({}, previousValues)
  39003. };
  39004. }
  39005. },
  39006. calculateSummary: function(records) {
  39007. var fields = this.getFields(),
  39008. len = fields.length,
  39009. recLen = records.length,
  39010. i, result, summary, prop, name, field;
  39011. for (i = 0; i < len; ++i) {
  39012. field = fields[i];
  39013. summary = field.getSummary();
  39014. if (summary) {
  39015. result = result || {};
  39016. name = field.name;
  39017. prop = field.summaryField || name;
  39018. result[name] = summary.calculate(records, prop, 'data', 0, recLen);
  39019. }
  39020. }
  39021. if (result) {
  39022. this.set(result, this._commitOptions);
  39023. }
  39024. },
  39025. cancelEdit: function() {
  39026. var me = this,
  39027. editMemento = me.editMemento,
  39028. validation = me.validation;
  39029. if (editMemento) {
  39030. me.editing = false;
  39031. Ext.apply(me, editMemento);
  39032. me.editMemento = null;
  39033. if (validation && validation.syncGeneration !== me.generation) {
  39034. validation.syncGeneration = 0;
  39035. }
  39036. }
  39037. },
  39038. endEdit: function(silent, modifiedFieldNames) {
  39039. var me = this,
  39040. editMemento = me.editMemento;
  39041. if (editMemento) {
  39042. me.editing = false;
  39043. me.editMemento = null;
  39044. me.previousValues = editMemento.previousValues;
  39045. if (!silent) {
  39046. if (!modifiedFieldNames) {
  39047. modifiedFieldNames = me.getModifiedFieldNames(editMemento.data);
  39048. }
  39049. if (me.dirty || (modifiedFieldNames && modifiedFieldNames.length)) {
  39050. me.callJoined('afterEdit', [
  39051. modifiedFieldNames
  39052. ]);
  39053. }
  39054. }
  39055. }
  39056. },
  39057. getField: function(name) {
  39058. return this.self.getField(name);
  39059. },
  39060. getFields: function() {
  39061. return this.self.getFields();
  39062. },
  39063. getFieldsMap: function() {
  39064. return this.fieldsMap;
  39065. },
  39066. getIdProperty: function() {
  39067. return this.idProperty;
  39068. },
  39069. getId: function() {
  39070. return this.id;
  39071. },
  39072. getObservableId: function() {
  39073. return this.internalId;
  39074. },
  39075. setId: function(id, options) {
  39076. this.set(this.idProperty, id, options);
  39077. },
  39078. getPrevious: function(fieldName) {
  39079. var previousValues = this.previousValues;
  39080. return previousValues && previousValues[fieldName];
  39081. },
  39082. isModified: function(fieldName) {
  39083. var modified = this.modified;
  39084. return !!(modified && modified.hasOwnProperty(fieldName));
  39085. },
  39086. getModified: function(fieldName) {
  39087. var out;
  39088. if (this.isModified(fieldName)) {
  39089. out = this.modified[fieldName];
  39090. }
  39091. return out;
  39092. },
  39093. get: function(fieldName) {
  39094. return this.data[fieldName];
  39095. },
  39096. _singleProp: {},
  39097. _rejectOptions: {
  39098. convert: false,
  39099. silent: true
  39100. },
  39101. set: function(fieldName, newValue, options) {
  39102. var me = this,
  39103. cls = me.self,
  39104. data = me.data,
  39105. modified = me.modified,
  39106. prevVals = me.previousValues,
  39107. session = me.session,
  39108. single = Ext.isString(fieldName),
  39109. opt = (single ? options : newValue),
  39110. convertOnSet = opt ? opt.convert !== false : me.convertOnSet,
  39111. fieldsMap = me.fieldsMap,
  39112. silent = opt && opt.silent,
  39113. commit = opt && opt.commit,
  39114. updateRefs = !(opt && opt.refs === false) && session,
  39115. dirty = !(opt && opt.dirty === false && !commit),
  39116. modifiedFieldNames = null,
  39117. dirtyRank = 0,
  39118. associations = me.associations,
  39119. currentValue, field, idChanged, key, name, oldId, comparator, dep, dependents, i, numFields, newId, rankedFields, reference, value, values, roleName;
  39120. if (single) {
  39121. values = me._singleProp;
  39122. values[fieldName] = newValue;
  39123. } else {
  39124. values = fieldName;
  39125. }
  39126. if (!(rankedFields = cls.rankedFields)) {
  39127. rankedFields = cls.rankFields();
  39128. }
  39129. numFields = rankedFields.length;
  39130. do {
  39131. for (name in values) {
  39132. value = values[name];
  39133. currentValue = data[name];
  39134. comparator = me;
  39135. field = fieldsMap[name];
  39136. if (field) {
  39137. if (convertOnSet && field.convert) {
  39138. value = field.convert(value, me);
  39139. }
  39140. comparator = field;
  39141. reference = field.reference;
  39142. } else {
  39143. reference = null;
  39144. }
  39145. if (comparator.isEqual(currentValue, value)) {
  39146. continue;
  39147. }
  39148. data[name] = value;
  39149. (modifiedFieldNames || (modifiedFieldNames = [])).push(name);
  39150. (prevVals || (me.previousValues = prevVals = {}))[name] = currentValue;
  39151. if (reference && reference.cls) {
  39152. if (updateRefs) {
  39153. session.updateReference(me, field, value, currentValue);
  39154. }
  39155. reference.onValueChange(me, session, value, currentValue);
  39156. }
  39157. i = (dependents = field && field.dependents) && dependents.length;
  39158. while (i-- > 0) {
  39159. (dep = dependents[i]).dirty = true;
  39160. dirtyRank = dirtyRank ? Math.min(dirtyRank, dep.rank) : dep.rank;
  39161. }
  39162. if (!field || field.persist) {
  39163. if (modified && modified.hasOwnProperty(name)) {
  39164. if (!dirty || comparator.isEqual(modified[name], value)) {
  39165. delete modified[name];
  39166. me.dirty = -1;
  39167. }
  39168. } else if (dirty) {
  39169. if (!modified) {
  39170. me.modified = modified = {};
  39171. }
  39172. me.dirty = true;
  39173. modified[name] = currentValue;
  39174. }
  39175. }
  39176. if (name === me.idField.name) {
  39177. idChanged = true;
  39178. oldId = currentValue;
  39179. newId = value;
  39180. }
  39181. }
  39182. if (!dirtyRank) {
  39183. break;
  39184. }
  39185. field = rankedFields[dirtyRank - 1];
  39186. field.dirty = false;
  39187. if (single) {
  39188. delete values[fieldName];
  39189. } else {
  39190. values = me._singleProp;
  39191. single = true;
  39192. }
  39193. fieldName = field.name;
  39194. values[fieldName] = data[fieldName];
  39195. convertOnSet = true;
  39196. for (; dirtyRank < numFields; ++dirtyRank) {
  39197. if (rankedFields[dirtyRank].dirty) {
  39198. break;
  39199. }
  39200. }
  39201. if (dirtyRank < numFields) {
  39202. ++dirtyRank;
  39203. } else {
  39204. dirtyRank = 0;
  39205. }
  39206. } while (
  39207. 1);
  39208. if (me.dirty < 0) {
  39209. me.dirty = false;
  39210. for (key in modified) {
  39211. if (modified.hasOwnProperty(key)) {
  39212. me.dirty = true;
  39213. break;
  39214. }
  39215. }
  39216. }
  39217. if (single) {
  39218. delete values[fieldName];
  39219. }
  39220. ++me.generation;
  39221. if (idChanged) {
  39222. me.id = newId;
  39223. me.onIdChanged(newId, oldId);
  39224. me.callJoined('onIdChanged', [
  39225. oldId,
  39226. newId
  39227. ]);
  39228. if (associations) {
  39229. for (roleName in associations) {
  39230. associations[roleName].onIdChanged(me, oldId, newId);
  39231. }
  39232. }
  39233. }
  39234. if (commit) {
  39235. me.commit(silent, modifiedFieldNames);
  39236. } else if (!silent && !me.editing && modifiedFieldNames) {
  39237. me.callJoined('afterEdit', [
  39238. modifiedFieldNames
  39239. ]);
  39240. }
  39241. return modifiedFieldNames;
  39242. },
  39243. reject: function(silent) {
  39244. var me = this,
  39245. modified = me.modified;
  39246. if (me.erased) {
  39247. Ext.raise('Cannot reject once a record has been erased.');
  39248. }
  39249. if (modified) {
  39250. me.set(modified, me._rejectOptions);
  39251. }
  39252. me.dropped = false;
  39253. me.clearState();
  39254. if (!silent) {
  39255. me.callJoined('afterReject');
  39256. }
  39257. },
  39258. commit: function(silent, modifiedFieldNames) {
  39259. var me = this,
  39260. versionProperty = me.versionProperty,
  39261. data = me.data,
  39262. erased;
  39263. me.clearState();
  39264. if (versionProperty && !me.phantom && !isNaN(data[versionProperty])) {
  39265. ++data[versionProperty];
  39266. }
  39267. me.phantom = false;
  39268. if (me.dropped) {
  39269. me.erased = erased = true;
  39270. }
  39271. if (!silent) {
  39272. if (erased) {
  39273. me.callJoined('afterErase');
  39274. } else {
  39275. me.callJoined('afterCommit', [
  39276. modifiedFieldNames
  39277. ]);
  39278. }
  39279. }
  39280. },
  39281. clearState: function() {
  39282. var me = this;
  39283. me.dirty = me.editing = false;
  39284. me.editMemento = me.modified = null;
  39285. },
  39286. drop: function(cascade) {
  39287. var me = this,
  39288. associations = me.associations,
  39289. session = me.session,
  39290. roleName;
  39291. if (me.erased || me.dropped) {
  39292. return;
  39293. }
  39294. me.dropped = true;
  39295. if (associations && cascade !== false) {
  39296. for (roleName in associations) {
  39297. associations[roleName].onDrop(me, session);
  39298. }
  39299. }
  39300. me.callJoined('afterDrop');
  39301. if (me.phantom) {
  39302. me.setErased();
  39303. }
  39304. },
  39305. join: function(owner) {
  39306. var me = this,
  39307. joined = me.joined;
  39308. if (!joined) {
  39309. joined = me.joined = [
  39310. owner
  39311. ];
  39312. } else if (!joined.length) {
  39313. joined[0] = owner;
  39314. } else {
  39315. Ext.Array.include(joined, owner);
  39316. }
  39317. if (owner.isStore && !me.store) {
  39318. me.store = owner;
  39319. }
  39320. },
  39321. unjoin: function(owner) {
  39322. var me = this,
  39323. joined = me.joined,
  39324. len = joined && joined.length,
  39325. store = me.store,
  39326. i;
  39327. if (owner === me.session) {
  39328. me.session = null;
  39329. } else {
  39330. if (len === 1 && joined[0] === owner) {
  39331. joined.length = 0;
  39332. } else if (len) {
  39333. Ext.Array.remove(joined, owner);
  39334. }
  39335. if (store === owner) {
  39336. store = null;
  39337. if (joined) {
  39338. for (i = 0 , len = joined.length; i < len; ++i) {
  39339. owner = joined[i];
  39340. if (owner.isStore) {
  39341. store = owner;
  39342. break;
  39343. }
  39344. }
  39345. }
  39346. me.store = store;
  39347. }
  39348. }
  39349. },
  39350. clone: function(session) {
  39351. var me = this,
  39352. modified = me.modified,
  39353. ret = me.copy(me.id, session);
  39354. if (modified) {
  39355. ret.modified = Ext.apply({}, modified);
  39356. }
  39357. ret.dirty = me.dirty;
  39358. ret.dropped = me.dropped;
  39359. ret.phantom = me.phantom;
  39360. return ret;
  39361. },
  39362. copy: function(newId, session) {
  39363. var me = this,
  39364. data = Ext.apply({}, me.data),
  39365. idProperty = me.idProperty,
  39366. T = me.self;
  39367. if (newId || newId === 0) {
  39368. data[idProperty] = newId;
  39369. } else if (newId === null) {
  39370. delete data[idProperty];
  39371. }
  39372. return new T(data, session);
  39373. },
  39374. getProxy: function() {
  39375. return this.self.getProxy();
  39376. },
  39377. getValidation: function(refresh) {
  39378. var me = this,
  39379. ret = me.validation;
  39380. if (!ret) {
  39381. me.validation = ret = new Ext.data.Validation();
  39382. ret.attach(me);
  39383. }
  39384. if (refresh === true || (refresh !== false && ret.syncGeneration !== me.generation)) {
  39385. ret.refresh(refresh);
  39386. }
  39387. return ret;
  39388. },
  39389. validate: function() {
  39390. return new Ext.data.ErrorCollection().init(this);
  39391. },
  39392. isValid: function() {
  39393. return this.getValidation().isValid();
  39394. },
  39395. toUrl: function() {
  39396. var pieces = this.$className.split('.'),
  39397. name = pieces[pieces.length - 1].toLowerCase();
  39398. return name + '/' + this.getId();
  39399. },
  39400. erase: function(options) {
  39401. var me = this;
  39402. me.erasing = true;
  39403. me.drop();
  39404. me.erasing = false;
  39405. return me.save(options);
  39406. },
  39407. setErased: function() {
  39408. this.erased = true;
  39409. this.callJoined('afterErase');
  39410. },
  39411. getChanges: function() {
  39412. return this.getData(this._getChangesOptions);
  39413. },
  39414. getCriticalFields: function() {
  39415. var cls = this.self,
  39416. ret = cls.criticalFields;
  39417. if (!ret) {
  39418. cls.rankFields();
  39419. ret = cls.criticalFields;
  39420. }
  39421. return ret;
  39422. },
  39423. getAssociatedData: function(result, options) {
  39424. var me = this,
  39425. associations = me.associations,
  39426. deep, i, item, items, itemData, length, record, role, roleName, opts, clear, associated;
  39427. result = result || {};
  39428. me.$gathering = 1;
  39429. if (options) {
  39430. options = Ext.apply({}, options);
  39431. }
  39432. for (roleName in associations) {
  39433. role = associations[roleName];
  39434. item = role.getAssociatedItem(me);
  39435. if (!item || item.$gathering) {
  39436. continue;
  39437. }
  39438. if (item.isStore) {
  39439. item.$gathering = 1;
  39440. items = item.getData().items;
  39441. length = items.length;
  39442. itemData = [];
  39443. for (i = 0; i < length; ++i) {
  39444. record = items[i];
  39445. deep = !record.$gathering;
  39446. record.$gathering = 1;
  39447. if (options) {
  39448. associated = options.associated;
  39449. if (associated === undefined) {
  39450. options.associated = deep;
  39451. clear = true;
  39452. } else if (!deep) {
  39453. options.associated = false;
  39454. clear = true;
  39455. }
  39456. opts = options;
  39457. } else {
  39458. opts = deep ? me._getAssociatedOptions : me._getNotAssociatedOptions;
  39459. }
  39460. itemData.push(record.getData(opts));
  39461. if (clear) {
  39462. options.associated = associated;
  39463. clear = false;
  39464. }
  39465. delete record.$gathering;
  39466. }
  39467. delete item.$gathering;
  39468. } else {
  39469. opts = options || me._getAssociatedOptions;
  39470. if (options && options.associated === undefined) {
  39471. opts.associated = true;
  39472. }
  39473. itemData = item.getData(opts);
  39474. }
  39475. result[roleName] = itemData;
  39476. }
  39477. delete me.$gathering;
  39478. return result;
  39479. },
  39480. getData: function(options) {
  39481. var me = this,
  39482. ret = {},
  39483. opts = (options === true) ? me._getAssociatedOptions : (options || ret),
  39484. data = me.data,
  39485. associated = opts.associated,
  39486. changes = opts.changes,
  39487. critical = changes && opts.critical,
  39488. content = changes ? me.modified : data,
  39489. fieldsMap = me.fieldsMap,
  39490. persist = opts.persist,
  39491. serialize = opts.serialize,
  39492. criticalFields, field, n, name, value;
  39493. if (content) {
  39494. for (name in content) {
  39495. value = data[name];
  39496. field = fieldsMap[name];
  39497. if (field) {
  39498. if (persist && !field.persist) {
  39499. continue;
  39500. }
  39501. if (serialize && field.serialize) {
  39502. value = field.serialize(value, me);
  39503. }
  39504. }
  39505. ret[name] = value;
  39506. }
  39507. }
  39508. if (critical) {
  39509. criticalFields = me.self.criticalFields || me.getCriticalFields();
  39510. for (n = criticalFields.length; n-- > 0; ) {
  39511. name = (field = criticalFields[n]).name;
  39512. if (!(name in ret)) {
  39513. value = data[name];
  39514. if (serialize && field.serialize) {
  39515. value = field.serialize(value, me);
  39516. }
  39517. ret[name] = value;
  39518. }
  39519. }
  39520. }
  39521. if (associated) {
  39522. if (typeof associated === 'object') {
  39523. me.getNestedData(opts, ret);
  39524. } else {
  39525. me.getAssociatedData(ret, opts);
  39526. }
  39527. }
  39528. return ret;
  39529. },
  39530. getNestedData: function(options, result) {
  39531. var me = this,
  39532. associations = me.associations,
  39533. graph = options.associated,
  39534. i, item, items, itemData, length, record, role, roleName, opts;
  39535. result = result || {};
  39536. for (roleName in graph) {
  39537. role = associations[roleName];
  39538. opts = graph[roleName];
  39539. if (opts === true) {
  39540. delete options.associated;
  39541. } else {
  39542. options.associated = opts;
  39543. }
  39544. item = role.getAssociatedItem(me);
  39545. if (item.isStore) {
  39546. items = item.getData().items;
  39547. length = items.length;
  39548. itemData = [];
  39549. for (i = 0; i < length; ++i) {
  39550. record = items[i];
  39551. itemData.push(record.getData(options));
  39552. }
  39553. } else {
  39554. itemData = item.getData(options);
  39555. }
  39556. result[roleName] = itemData;
  39557. }
  39558. options.associated = graph;
  39559. return result;
  39560. },
  39561. getTransientFields: function() {
  39562. var cls = this.self,
  39563. ret = cls.transientFields;
  39564. if (!ret) {
  39565. cls.rankFields();
  39566. ret = cls.transientFields;
  39567. }
  39568. return ret;
  39569. },
  39570. isLoading: function() {
  39571. return !!this.loadOperation;
  39572. },
  39573. abort: function() {
  39574. var operation = this.loadOperation;
  39575. if (operation) {
  39576. operation.abort();
  39577. }
  39578. },
  39579. load: function(options) {
  39580. options = Ext.apply({}, options);
  39581. var me = this,
  39582. scope = options.scope || me,
  39583. proxy = me.getProxy(),
  39584. callback = options.callback,
  39585. operation = me.loadOperation,
  39586. id = me.getId(),
  39587. extras;
  39588. if (operation) {
  39589. extras = operation.extraCalls;
  39590. if (!extras) {
  39591. extras = operation.extraCalls = [];
  39592. }
  39593. extras.push(options);
  39594. return operation;
  39595. }
  39596. var doIdCheck = true;
  39597. if (me.phantom) {
  39598. doIdCheck = false;
  39599. }
  39600. options.id = id;
  39601. options.recordCreator = function(data, type, readOptions) {
  39602. var session = me.session;
  39603. if (readOptions) {
  39604. readOptions.recordCreator = session ? session.recordCreator : null;
  39605. }
  39606. me.set(data, me._commitOptions);
  39607. if (doIdCheck && me.getId() !== id) {
  39608. Ext.raise('Invalid record id returned for ' + id + '@' + me.entityName);
  39609. }
  39610. return me;
  39611. };
  39612. options.internalCallback = function(operation) {
  39613. var success = operation.wasSuccessful() && operation.getRecords().length > 0,
  39614. op = me.loadOperation,
  39615. extras = op.extraCalls,
  39616. successFailArgs = [
  39617. me,
  39618. operation
  39619. ],
  39620. callbackArgs = [
  39621. me,
  39622. operation,
  39623. success
  39624. ],
  39625. i, len;
  39626. me.loadOperation = null;
  39627. ++me.loadCount;
  39628. if (success) {
  39629. Ext.callback(options.success, scope, successFailArgs);
  39630. } else {
  39631. Ext.callback(options.failure, scope, successFailArgs);
  39632. }
  39633. Ext.callback(callback, scope, callbackArgs);
  39634. if (extras) {
  39635. for (i = 0 , len = extras.length; i < len; ++i) {
  39636. options = extras[i];
  39637. if (success) {
  39638. Ext.callback(options.success, scope, successFailArgs);
  39639. } else {
  39640. Ext.callback(options.failure, scope, successFailArgs);
  39641. }
  39642. Ext.callback(options.callback, scope, callbackArgs);
  39643. }
  39644. }
  39645. me.callJoined('afterLoad');
  39646. };
  39647. delete options.callback;
  39648. me.loadOperation = operation = proxy.createOperation('read', options);
  39649. operation.execute();
  39650. return operation;
  39651. },
  39652. mergeData: function(data) {
  39653. if (!this.dirty) {
  39654. this.set(data, this._commitOptions);
  39655. }
  39656. },
  39657. save: function(options) {
  39658. options = Ext.apply({}, options);
  39659. var me = this,
  39660. phantom = me.phantom,
  39661. dropped = me.dropped,
  39662. action = dropped ? 'destroy' : (phantom ? 'create' : 'update'),
  39663. scope = options.scope || me,
  39664. callback = options.callback,
  39665. proxy = me.getProxy(),
  39666. operation;
  39667. options.records = [
  39668. me
  39669. ];
  39670. options.internalCallback = function(operation) {
  39671. var args = [
  39672. me,
  39673. operation
  39674. ],
  39675. success = operation.wasSuccessful();
  39676. if (success) {
  39677. Ext.callback(options.success, scope, args);
  39678. } else {
  39679. Ext.callback(options.failure, scope, args);
  39680. }
  39681. args.push(success);
  39682. Ext.callback(callback, scope, args);
  39683. };
  39684. delete options.callback;
  39685. operation = proxy.createOperation(action, options);
  39686. if (dropped && phantom) {
  39687. operation.setResultSet(Ext.data.reader.Reader.prototype.nullResultSet);
  39688. me.setErased();
  39689. operation.setSuccessful(true);
  39690. } else {
  39691. operation.execute();
  39692. }
  39693. return operation;
  39694. },
  39695. statics: {
  39696. defaultProxy: 'memory'
  39697. },
  39698. inheritableStatics: {
  39699. _associatedReadOptions: {
  39700. recordsOnly: true,
  39701. asRoot: true
  39702. },
  39703. loadData: function(data, session) {
  39704. var rec;
  39705. if (data) {
  39706. rec = this.getProxy().getReader().readRecords([
  39707. data
  39708. ], session ? {
  39709. recordCreator: session.recordCreator
  39710. } : undefined, this._associatedReadOptions)[0];
  39711. } else {
  39712. rec = new this(data, session);
  39713. }
  39714. return rec;
  39715. },
  39716. getSummaryModel: function() {
  39717. var me = this,
  39718. proto = me.prototype,
  39719. summaryModel = me.summaryModel;
  39720. if (!summaryModel) {
  39721. summaryModel = Ext.define(null, {
  39722. extend: me,
  39723. fields: proto.summaryFields || [],
  39724. isSummaryModel: true
  39725. });
  39726. summaryModel.isSummaryModel = true;
  39727. me.summaryModel = proto.summaryModel = summaryModel;
  39728. }
  39729. return summaryModel || null;
  39730. },
  39731. addFields: function(newFields) {
  39732. this.replaceFields(newFields);
  39733. },
  39734. replaceFields: function(newFields, removeFields) {
  39735. var me = this,
  39736. proto = me.prototype,
  39737. Field = Ext.data.field.Field,
  39738. fields = me.fields,
  39739. fieldsMap = me.fieldsMap,
  39740. ordinals = me.fieldOrdinals,
  39741. field, i, idField, len, name, ordinal, cleared;
  39742. if (removeFields === true) {
  39743. fields.length = 0;
  39744. me.fieldsMap = fieldsMap = {};
  39745. me.fieldOrdinals = ordinals = {};
  39746. cleared = true;
  39747. } else if (removeFields) {
  39748. for (i = removeFields.length; i-- > 0; ) {
  39749. name = removeFields[i];
  39750. if (name in ordinals) {
  39751. delete ordinals[name];
  39752. delete fieldsMap[name];
  39753. }
  39754. }
  39755. for (i = 0 , len = fields.length; i < len; ++i) {
  39756. name = (field = fields[i]).name;
  39757. if (name in ordinals) {
  39758. ordinals[name] = i;
  39759. } else {
  39760. fields.splice(i, 1);
  39761. --i;
  39762. --len;
  39763. }
  39764. }
  39765. }
  39766. for (i = 0 , len = newFields ? newFields.length : 0; i < len; i++) {
  39767. name = (field = newFields[i]).name;
  39768. if (!(name in ordinals)) {
  39769. ordinals[name] = ordinal = fields.length;
  39770. fields.push(field = Field.create(field));
  39771. fieldsMap[name] = field;
  39772. field.ordinal = ordinal;
  39773. field.definedBy = field.owner = this;
  39774. }
  39775. }
  39776. if (!cleared) {
  39777. for (i = 0 , len = fields.length; i < len; ++i) {
  39778. fields[i].rank = null;
  39779. }
  39780. }
  39781. me.idField = proto.idField = idField = fieldsMap[proto.idProperty];
  39782. if (idField) {
  39783. idField.allowNull = idField.critical = idField.identifier = true;
  39784. idField.defaultValue = null;
  39785. }
  39786. me.initializeFn = me.rankedFields = me.transientFields = me.criticalFields = null;
  39787. },
  39788. removeFields: function(removeFields) {
  39789. this.replaceFields(null, removeFields);
  39790. },
  39791. getIdFromData: function(data) {
  39792. var T = this,
  39793. idField = T.idField,
  39794. id = idField.calculated ? (new T(data)).id : data[idField.name];
  39795. return id;
  39796. },
  39797. createWithId: function(id, data, session) {
  39798. var d = data,
  39799. T = this;
  39800. if (id || id === 0) {
  39801. d = {};
  39802. if (data) {
  39803. Ext.apply(d, data);
  39804. }
  39805. d[T.idField.name] = id;
  39806. }
  39807. return new T(d, session);
  39808. },
  39809. getFields: function() {
  39810. return this.fields;
  39811. },
  39812. getFieldsMap: function() {
  39813. return this.fieldsMap;
  39814. },
  39815. getField: function(name) {
  39816. return this.fieldsMap[name] || null;
  39817. },
  39818. getProxy: function() {
  39819. var me = this,
  39820. proxy = me.proxy,
  39821. defaultProxy = me.defaultProxy,
  39822. defaults;
  39823. if (!proxy) {
  39824. proxy = me.proxyConfig;
  39825. if (!proxy && defaultProxy) {
  39826. proxy = defaultProxy;
  39827. }
  39828. if (!proxy || !proxy.isProxy) {
  39829. if (typeof proxy === 'string') {
  39830. proxy = {
  39831. type: proxy
  39832. };
  39833. }
  39834. defaults = Ext.merge(me.schema.constructProxy(me), proxy);
  39835. if (proxy && proxy.type) {
  39836. proxy = proxy.schema === false ? proxy : defaults;
  39837. } else {
  39838. proxy = defaults;
  39839. }
  39840. }
  39841. proxy = me.setProxy(proxy);
  39842. }
  39843. return proxy;
  39844. },
  39845. setProxy: function(proxy) {
  39846. var me = this,
  39847. model;
  39848. if (proxy) {
  39849. if (!proxy.isProxy) {
  39850. proxy = Ext.Factory.proxy(proxy);
  39851. } else {
  39852. model = proxy.getModel();
  39853. if (model && model !== me) {
  39854. proxy = proxy.clone();
  39855. }
  39856. }
  39857. proxy.setModel(me);
  39858. }
  39859. return (me.prototype.proxy = me.proxy = proxy);
  39860. },
  39861. load: function(id, options, session) {
  39862. var data = {},
  39863. rec;
  39864. if (session) {
  39865. rec = session.peekRecord(this, id);
  39866. }
  39867. if (!rec) {
  39868. data[this.prototype.idProperty] = id;
  39869. rec = new this(data, session);
  39870. }
  39871. rec.load(options);
  39872. return rec;
  39873. }
  39874. },
  39875. deprecated: {
  39876. 5: {
  39877. methods: {
  39878. hasId: null,
  39879. markDirty: null,
  39880. setDirty: null,
  39881. eachStore: function(callback, scope) {
  39882. var me = this,
  39883. stores = me.stores,
  39884. len = stores.length,
  39885. i;
  39886. for (i = 0; i < len; ++i) {
  39887. callback.call(scope, stores[i]);
  39888. }
  39889. },
  39890. join: function(item) {
  39891. var me = this,
  39892. stores = me.stores,
  39893. joined = me.joined;
  39894. if (!joined) {
  39895. joined = me.joined = [
  39896. item
  39897. ];
  39898. } else {
  39899. joined.push(item);
  39900. }
  39901. if (item.isStore) {
  39902. me.store = me.store || item;
  39903. if (!stores) {
  39904. stores = me.stores = [];
  39905. }
  39906. stores.push(item);
  39907. }
  39908. },
  39909. unjoin: function(item) {
  39910. var me = this,
  39911. stores = me.stores,
  39912. joined = me.joined;
  39913. if (joined.length === 1) {
  39914. joined.length = 0;
  39915. } else {
  39916. Ext.Array.remove(joined, item);
  39917. }
  39918. if (item.isStore) {
  39919. Ext.Array.remove(stores, item);
  39920. me.store = stores[0] || null;
  39921. }
  39922. }
  39923. },
  39924. properties: {
  39925. persistenceProperty: null
  39926. },
  39927. inheritableStatics: {
  39928. methods: {
  39929. setFields: null
  39930. }
  39931. }
  39932. }
  39933. },
  39934. privates: {
  39935. _commitOptions: {
  39936. commit: true
  39937. },
  39938. _getChangesOptions: {
  39939. changes: true
  39940. },
  39941. _getAssociatedOptions: {
  39942. associated: true
  39943. },
  39944. _getNotAssociatedOptions: {
  39945. associated: false
  39946. },
  39947. _metaProperties: {
  39948. dirty: 'isDirty',
  39949. phantom: 'isPhantom',
  39950. valid: 'isValid'
  39951. },
  39952. copyFrom: function(sourceRecord) {
  39953. var me = this,
  39954. fields = me.fields,
  39955. fieldCount = fields.length,
  39956. modifiedFieldNames = [],
  39957. idProperty = me.idProperty,
  39958. i = 0,
  39959. field, myData, sourceData, name, value;
  39960. if (sourceRecord) {
  39961. myData = me.data;
  39962. sourceData = sourceRecord.data;
  39963. for (; i < fieldCount; i++) {
  39964. field = fields[i];
  39965. name = field.name;
  39966. if (name !== idProperty) {
  39967. value = sourceData[name];
  39968. if (value !== undefined && !me.isEqual(myData[name], value)) {
  39969. myData[name] = value;
  39970. modifiedFieldNames.push(name);
  39971. }
  39972. }
  39973. }
  39974. if (me.phantom && !sourceRecord.phantom) {
  39975. me.beginEdit();
  39976. me.setId(sourceRecord.getId());
  39977. me.endEdit(true);
  39978. me.commit(true);
  39979. }
  39980. }
  39981. return modifiedFieldNames;
  39982. },
  39983. callJoined: function(funcName, args) {
  39984. var me = this,
  39985. joined = me.joined,
  39986. session = me.session,
  39987. state = me.dropped ? 'D' : (me.phantom ? 'C' : (me.dirty ? 'U' : 'R')),
  39988. i, len, fn, item;
  39989. me.crudState = state;
  39990. if (joined || session) {
  39991. if (args) {
  39992. args.unshift(me);
  39993. } else {
  39994. args = [
  39995. me
  39996. ];
  39997. }
  39998. fn = session && session[funcName];
  39999. if (fn) {
  40000. fn.apply(session, args);
  40001. }
  40002. if (joined) {
  40003. for (i = 0 , len = joined.length; i < len; ++i) {
  40004. item = joined[i];
  40005. if (item && (fn = item[funcName])) {
  40006. fn.apply(item, args);
  40007. }
  40008. }
  40009. }
  40010. }
  40011. me.crudStateWas = state;
  40012. },
  40013. hasPendingLoad: function() {
  40014. return this.isLoading();
  40015. },
  40016. interpret: function(name) {
  40017. var me = this,
  40018. accessor = me._metaProperties[name];
  40019. if (!accessor) {
  40020. accessor = me.associations;
  40021. accessor = accessor && accessor[name] && accessor[name].getterName;
  40022. }
  40023. if (accessor) {
  40024. return me[accessor]();
  40025. }
  40026. return me.data[name];
  40027. },
  40028. isDirty: function() {
  40029. return this.dirty;
  40030. },
  40031. isPhantom: function() {
  40032. return this.phantom;
  40033. },
  40034. onAssociatedRecordSet: function(record, role) {
  40035. this.callJoined('afterAssociatedRecordSet', [
  40036. record,
  40037. role
  40038. ]);
  40039. },
  40040. onIdChanged: Ext.privateFn,
  40041. setSession: function(session) {
  40042. if (session) {
  40043. if (this.session) {
  40044. Ext.raise('This model already belongs to a session.');
  40045. }
  40046. if (!this.id) {
  40047. Ext.raise('The model must have an id to participate in a session.');
  40048. }
  40049. }
  40050. this.session = session;
  40051. if (session) {
  40052. session.add(this);
  40053. }
  40054. },
  40055. getModifiedFieldNames: function(old) {
  40056. var me = this,
  40057. data = me.data,
  40058. modified = [],
  40059. oldData = old || me.editMemento.data,
  40060. key;
  40061. for (key in data) {
  40062. if (data.hasOwnProperty(key)) {
  40063. if (!me.isEqual(data[key], oldData[key], key)) {
  40064. modified.push(key);
  40065. }
  40066. }
  40067. }
  40068. return modified;
  40069. },
  40070. isEqual: function(lhs, rhs, field) {
  40071. var f;
  40072. if (field) {
  40073. f = field.isField ? field : this.fieldsMap[field];
  40074. if (f) {
  40075. return f.isEqual(lhs, rhs);
  40076. }
  40077. }
  40078. if (lhs instanceof Date && rhs instanceof Date) {
  40079. return lhs.getTime() === rhs.getTime();
  40080. }
  40081. return lhs === rhs;
  40082. },
  40083. statics: {
  40084. EDIT: 'edit',
  40085. REJECT: 'reject',
  40086. COMMIT: 'commit',
  40087. rankFields: function() {
  40088. var cls = this,
  40089. prototype = cls.prototype,
  40090. fields = cls.fields,
  40091. length = fields.length,
  40092. rankedFields = [],
  40093. criticalFields = [],
  40094. transientFields = [],
  40095. evilFields, field, i;
  40096. cls.rankedFields = prototype.rankedFields = rankedFields;
  40097. cls.criticalFields = prototype.criticalFields = criticalFields;
  40098. cls.transientFields = prototype.transientFields = transientFields;
  40099. for (i = 0; i < length; ++i) {
  40100. field = fields[i];
  40101. if (field.critical) {
  40102. criticalFields.push(field);
  40103. }
  40104. if (!field.persist) {
  40105. transientFields.push(field);
  40106. }
  40107. if (field.evil) {
  40108. (evilFields || (evilFields = [])).push(field);
  40109. } else if (!field.depends) {
  40110. rankedFields.push(field);
  40111. field.rank = rankedFields.length;
  40112. }
  40113. }
  40114. for (i = 0; i < length; ++i) {
  40115. if (!(field = fields[i]).rank && !field.evil) {
  40116. cls.topoAdd(field);
  40117. }
  40118. }
  40119. if (evilFields) {
  40120. for (i = 0 , length = evilFields.length; i < length; ++i) {
  40121. rankedFields.push(field = evilFields[i]);
  40122. field.rank = rankedFields.length;
  40123. }
  40124. }
  40125. cls.topoStack = null;
  40126. return rankedFields;
  40127. },
  40128. topoAdd: function(field) {
  40129. var cls = this,
  40130. dep = field.depends,
  40131. dependsLength = dep ? dep.length : 0,
  40132. rankedFields = cls.rankedFields,
  40133. i, targetField;
  40134. var topoStack = cls.topoStack || (cls.topoStack = []);
  40135. topoStack.push(field.name);
  40136. if (field.rank === 0) {
  40137. Ext.raise(cls.$className + " has circular field dependencies: " + topoStack.join(" --> "));
  40138. }
  40139. if (topoStack.length && field.evil) {
  40140. Ext.raise(cls.$className + ": Field " + topoStack[topoStack.length - 1] + " cannot depend on depends-less field " + field.name);
  40141. }
  40142. field.rank = 0;
  40143. for (i = 0; i < dependsLength; ++i) {
  40144. targetField = cls.fieldsMap[dep[i]];
  40145. if (!targetField) {
  40146. Ext.raise(cls.$className + ": Field " + field.name + " depends on undefined field " + dep[i]);
  40147. }
  40148. (targetField.dependents || (targetField.dependents = [])).push(field);
  40149. if (!targetField.rank) {
  40150. cls.topoAdd(targetField);
  40151. }
  40152. }
  40153. rankedFields.push(field);
  40154. field.rank = rankedFields.length;
  40155. topoStack.pop();
  40156. },
  40157. initFields: function(data, cls, proto) {
  40158. var Field = Ext.data.field.Field,
  40159. fieldDefs = data.fields,
  40160. fields = [],
  40161. fieldOrdinals = {},
  40162. fieldsMap = {},
  40163. references = [],
  40164. superFields = proto.fields,
  40165. versionProperty = data.versionProperty || proto.versionProperty,
  40166. idProperty = cls.idProperty,
  40167. idField, field, i, length, name, ordinal, reference, superIdField, superIdFieldName, superIdDeclared, idDeclared;
  40168. cls.fields = proto.fields = fields;
  40169. cls.fieldOrdinals = proto.fieldOrdinals = fieldOrdinals;
  40170. cls.fieldsMap = proto.fieldsMap = fieldsMap;
  40171. cls.references = proto.references = references;
  40172. if (superFields) {
  40173. for (i = 0 , length = superFields.length; i < length; ++i) {
  40174. fields[i] = field = Ext.Object.chain(superFields[i]);
  40175. field.dependents = null;
  40176. field.owner = cls;
  40177. fieldOrdinals[name = field.name] = i;
  40178. fieldsMap[name] = field;
  40179. field.rank = null;
  40180. if (field.generated) {
  40181. superIdField = field;
  40182. superIdFieldName = field.name;
  40183. }
  40184. }
  40185. }
  40186. delete data.fields;
  40187. if (fieldDefs) {
  40188. for (i = 0 , length = fieldDefs.length; i < length; ++i) {
  40189. field = fieldDefs[i];
  40190. reference = field.reference;
  40191. if (reference && typeof reference !== 'string') {
  40192. reference = Ext.merge({}, reference);
  40193. }
  40194. field.$reference = reference;
  40195. field = Field.create(fieldDefs[i]);
  40196. name = field.name;
  40197. ordinal = fieldOrdinals[name];
  40198. if (ordinal === undefined) {
  40199. fieldOrdinals[name] = ordinal = fields.length;
  40200. }
  40201. fieldsMap[name] = field;
  40202. fields[ordinal] = field;
  40203. field.definedBy = field.owner = cls;
  40204. field.ordinal = ordinal;
  40205. if (name === idProperty) {
  40206. idDeclared = field;
  40207. }
  40208. if (name === superIdFieldName) {
  40209. superIdDeclared = true;
  40210. }
  40211. }
  40212. }
  40213. idField = fieldsMap[idProperty];
  40214. if (!idField) {
  40215. if (superIdField && superIdField.generated) {
  40216. ordinal = superIdField.ordinal;
  40217. } else {
  40218. ordinal = fields.length;
  40219. }
  40220. delete fieldsMap[superIdFieldName];
  40221. delete fieldOrdinals[superIdFieldName];
  40222. idField = new Field(idProperty);
  40223. fields[ordinal] = idField;
  40224. fieldOrdinals[idProperty] = ordinal;
  40225. fieldsMap[idProperty] = idField;
  40226. idField.definedBy = cls;
  40227. idField.ordinal = ordinal;
  40228. idField.generated = true;
  40229. } else if (idDeclared && !superIdDeclared && superIdField && superIdField.generated) {
  40230. Ext.Array.remove(fields, superIdField);
  40231. delete fieldsMap[superIdFieldName];
  40232. delete fieldOrdinals[superIdFieldName];
  40233. fieldsMap[idProperty] = idDeclared;
  40234. for (i = 0 , length = fields.length; i < length; ++i) {
  40235. field = fields[i];
  40236. fields.ordinal = i;
  40237. fieldOrdinals[field.name] = i;
  40238. }
  40239. }
  40240. idField.allowNull = idField.critical = idField.identifier = true;
  40241. idField.defaultValue = null;
  40242. cls.idField = proto.idField = idField;
  40243. if (versionProperty) {
  40244. field = fieldsMap[versionProperty];
  40245. if (!field) {
  40246. ordinal = fields.length;
  40247. field = new Field({
  40248. name: versionProperty,
  40249. type: 'int'
  40250. });
  40251. fields[ordinal] = field;
  40252. fieldOrdinals[versionProperty] = ordinal;
  40253. fieldsMap[versionProperty] = field;
  40254. field.definedBy = cls;
  40255. field.ordinal = ordinal;
  40256. field.generated = true;
  40257. }
  40258. field.defaultValue = 1;
  40259. field.critical = true;
  40260. }
  40261. },
  40262. initSummaries: function(data, cls, proto) {
  40263. var summaryDefs = data.summary,
  40264. superSummaries = proto.summaryFields,
  40265. summaries, summaryMap, name, summary, len, i, index, field;
  40266. if (superSummaries) {
  40267. summaries = [];
  40268. summaryMap = {};
  40269. for (i = 0 , len = superSummaries.length; i < len; ++i) {
  40270. summary = superSummaries[i];
  40271. summaries.push(summary);
  40272. summaries[summary.name] = i;
  40273. }
  40274. }
  40275. if (summaryDefs) {
  40276. delete data.summary;
  40277. summaries = summaries || [];
  40278. summaryMap = summaryMap || {};
  40279. for (name in summaryDefs) {
  40280. summary = summaryDefs[name];
  40281. if (typeof summary === 'function') {
  40282. summary = {
  40283. summary: summary
  40284. };
  40285. }
  40286. index = summaryMap[name];
  40287. summary = Ext.apply({
  40288. name: name
  40289. }, summary);
  40290. field = summary.field;
  40291. if (field) {
  40292. delete summary.field;
  40293. summary.summaryField = field;
  40294. }
  40295. if (index === undefined) {
  40296. index = summaries.length;
  40297. summaryMap[name] = summary;
  40298. }
  40299. summaries[index] = summary;
  40300. }
  40301. }
  40302. if (summaries) {
  40303. for (i = 0 , len = summaries.length; i < len; ++i) {
  40304. if (summaries[i].name in proto.fieldsMap) {
  40305. Ext.raise('Cannot redefine field, use the summary property ' + 'on the field.');
  40306. }
  40307. }
  40308. proto.summaryFields = summaries;
  40309. }
  40310. },
  40311. initValidators: function(data, cls, proto) {
  40312. var superValidators = proto.validators,
  40313. validators, field, copy, validatorDefs, i, length, fieldValidator, name, validator, item;
  40314. if (superValidators) {
  40315. validators = {};
  40316. for (field in superValidators) {
  40317. validators[field] = Ext.Array.clone(superValidators[field]);
  40318. }
  40319. }
  40320. validatorDefs = data.validators || data.validations;
  40321. if (data.validations) {
  40322. delete data.validations;
  40323. Ext.log.warn((cls.$className || 'Ext.data.Model') + ': validations has been deprecated. Please use validators ' + 'instead.');
  40324. }
  40325. if (validatorDefs) {
  40326. delete data.validators;
  40327. validators = validators || {};
  40328. if (Ext.isArray(validatorDefs)) {
  40329. copy = {};
  40330. for (i = 0 , length = validatorDefs.length; i < length; ++i) {
  40331. item = validatorDefs[i];
  40332. name = item.field;
  40333. if (!copy[name]) {
  40334. copy[name] = [];
  40335. }
  40336. item = item.fn || item;
  40337. copy[name].push(item);
  40338. }
  40339. validatorDefs = copy;
  40340. }
  40341. for (name in validatorDefs) {
  40342. fieldValidator = validatorDefs[name];
  40343. if (!Ext.isArray(fieldValidator)) {
  40344. fieldValidator = [
  40345. fieldValidator
  40346. ];
  40347. }
  40348. validator = validators[name];
  40349. if (validator) {
  40350. Ext.Array.push(validator, fieldValidator);
  40351. } else {
  40352. validators[name] = fieldValidator;
  40353. }
  40354. }
  40355. }
  40356. if (validators) {
  40357. for (name in validators) {
  40358. field = cls.getField(name);
  40359. if (field) {
  40360. field.setModelValidators(validators[name]);
  40361. }
  40362. }
  40363. }
  40364. cls.validators = proto.validators = validators;
  40365. },
  40366. initAssociations: function(schema, data, cls) {
  40367. var associations = data.associations,
  40368. belongsTo = data.belongsTo,
  40369. hasMany = data.hasMany,
  40370. hasOne = data.hasOne,
  40371. matrices = data.manyToMany,
  40372. i, length, assoc, o;
  40373. delete data.associations;
  40374. delete data.belongsTo;
  40375. delete data.hasMany;
  40376. delete data.hasOne;
  40377. delete data.manyToMany;
  40378. if (matrices) {
  40379. schema.addMatrices(cls, matrices);
  40380. }
  40381. if (associations) {
  40382. associations = Ext.isArray(associations) ? associations : [
  40383. associations
  40384. ];
  40385. for (i = 0 , length = associations.length; i < length; ++i) {
  40386. assoc = associations[i];
  40387. o = Ext.apply({}, assoc);
  40388. delete o.type;
  40389. switch (assoc.type) {
  40390. case 'belongsTo':
  40391. schema.addBelongsTo(cls, o);
  40392. break;
  40393. case 'hasMany':
  40394. schema.addHasMany(cls, o);
  40395. break;
  40396. case 'hasOne':
  40397. schema.addHasOne(cls, o);
  40398. break;
  40399. default:
  40400. Ext.raise('Invalid association type: "' + assoc.type + '"');
  40401. }
  40402. }
  40403. }
  40404. if (belongsTo) {
  40405. belongsTo = Ext.isArray(belongsTo) ? belongsTo : [
  40406. belongsTo
  40407. ];
  40408. for (i = 0 , length = belongsTo.length; i < length; ++i) {
  40409. schema.addBelongsTo(cls, belongsTo[i]);
  40410. }
  40411. }
  40412. if (hasMany) {
  40413. hasMany = Ext.isArray(hasMany) ? hasMany : [
  40414. hasMany
  40415. ];
  40416. for (i = 0 , length = hasMany.length; i < length; ++i) {
  40417. schema.addHasMany(cls, hasMany[i]);
  40418. }
  40419. }
  40420. if (hasOne) {
  40421. hasOne = Ext.isArray(hasOne) ? hasOne : [
  40422. hasOne
  40423. ];
  40424. for (i = 0 , length = hasOne.length; i < length; ++i) {
  40425. schema.addHasOne(cls, hasOne[i]);
  40426. }
  40427. }
  40428. schema.afterKeylessAssociations(cls);
  40429. },
  40430. initIdentifier: function(data, cls, proto) {
  40431. var identifier = data.identifier || data.idgen,
  40432. superIdent = proto.identifier || cls.schema._defaultIdentifier,
  40433. generatorPrefix;
  40434. if (data.idgen) {
  40435. Ext.log.warn('Ext.data.Model: idgen has been deprecated. Please use ' + 'identifier instead.');
  40436. }
  40437. if (identifier) {
  40438. delete data.identifier;
  40439. delete data.idgen;
  40440. identifier = Ext.Factory.dataIdentifier(identifier);
  40441. } else if (superIdent) {
  40442. if (superIdent.clone && !superIdent.getId()) {
  40443. identifier = superIdent.clone();
  40444. } else if (superIdent.isGenerator) {
  40445. identifier = superIdent;
  40446. } else {
  40447. identifier = Ext.Factory.dataIdentifier(superIdent);
  40448. }
  40449. }
  40450. cls.identifier = proto.identifier = identifier;
  40451. if (!identifier) {
  40452. generatorPrefix = cls.entityName;
  40453. if (!generatorPrefix) {
  40454. generatorPrefix = Ext.id(null, 'extModel');
  40455. }
  40456. cls.identifier = Ext.Factory.dataIdentifier({
  40457. type: 'sequential',
  40458. prefix: generatorPrefix + '-'
  40459. });
  40460. }
  40461. },
  40462. findValidator: function(validators, name, cfg) {
  40463. var type = cfg.type || cfg,
  40464. field = validators[name],
  40465. len, i, item;
  40466. if (field) {
  40467. for (i = 0 , len = field.length; i < len; ++i) {
  40468. item = field[i];
  40469. if (item.type === type) {
  40470. return item;
  40471. }
  40472. }
  40473. }
  40474. return null;
  40475. },
  40476. makeInitializeFn: function(cls) {
  40477. var code = [
  40478. 'var '
  40479. ],
  40480. body = [
  40481. '\nreturn function (e) {\n var data = e.data, v;\n'
  40482. ],
  40483. work = 0,
  40484. bc, ec,
  40485. convert, expr, factory, field, fields, fs, hasDefValue, i, length;
  40486. if (!(fields = cls.rankedFields)) {
  40487. fields = cls.rankFields();
  40488. }
  40489. for (i = 0 , length = fields.length; i < length; ++i) {
  40490. field = fields[i];
  40491. fs = 'f' + i;
  40492. convert = field.convert;
  40493. if (i) {
  40494. code.push(', \n ');
  40495. }
  40496. code.push(fs, ' = $fields[' + i + ']');
  40497. code.push(' /* ', field.name, ' */');
  40498. if ((hasDefValue = (field.defaultValue !== undefined)) || convert) {
  40499. expr = 'data["' + field.name + '"]';
  40500. ++work;
  40501. bc = ec = '';
  40502. if (field.cloneDefaultValue) {
  40503. bc = 'Ext.clone(';
  40504. ec = ')';
  40505. }
  40506. body.push('\n');
  40507. if (convert && hasDefValue) {
  40508. body.push(' v = ', expr, ';\n' + ' if (v !== undefined) {\n' + ' v = ', fs, '.convert(v, e);\n' + ' }\n' + ' if (v === undefined) {\n' + ' v = ', bc, fs, '.defaultValue', ec, ';\n' + ' }\n' + ' ', expr, ' = v;');
  40509. } else if (convert) {
  40510. body.push(' v = ', fs, '.convert(', expr, ',e);\n' + ' if (v !== undefined) {\n' + ' ', expr, ' = v;\n' + ' }\n');
  40511. } else if (hasDefValue) {
  40512. body.push(' if (', expr, ' === undefined) {\n' + ' ', expr, ' = ', bc, fs, '.defaultValue', ec, ';\n' + ' }\n');
  40513. }
  40514. }
  40515. }
  40516. if (!work) {
  40517. return Ext.emptyFn;
  40518. }
  40519. code.push(';\n');
  40520. code.push.apply(code, body);
  40521. code.push('}');
  40522. code = code.join('');
  40523. factory = new Function('$fields', 'Ext', code);
  40524. return factory(fields, Ext);
  40525. }
  40526. }
  40527. }
  40528. },
  40529. function() {
  40530. var Model = this,
  40531. proto = Model.prototype,
  40532. Schema = Ext.data.schema.Schema,
  40533. defaultSchema;
  40534. Model.proxyConfig = proto.proxy;
  40535. delete proto.proxy;
  40536. Model.fields = [];
  40537. Model.fieldsMap = proto.fieldsMap = {};
  40538. Model.schema = proto.schema = Schema.get(proto.schema);
  40539. proto.idField = new Ext.data.field.Field(proto.idProperty);
  40540. Model.identifier = new Ext.data.identifier.Sequential();
  40541. Model.onExtended(function(cls, data) {
  40542. var proto = cls.prototype,
  40543. schemaName = data.schema,
  40544. superCls = proto.superclass.self,
  40545. schema, entityName, proxy;
  40546. cls.idProperty = data.idProperty || proto.idProperty;
  40547. if (schemaName) {
  40548. delete data.schema;
  40549. schema = Schema.get(schemaName);
  40550. } else if (!(schema = proto.schema)) {
  40551. schema = defaultSchema || (defaultSchema = Schema.get('default'));
  40552. }
  40553. cls.rankFields = Model.rankFields;
  40554. cls.topoAdd = Model.topoAdd;
  40555. proto.schema = cls.schema = schema;
  40556. if (!(entityName = data.entityName)) {
  40557. proto.entityName = entityName = schema.getEntityName(cls);
  40558. if (!entityName) {
  40559. if (data.associations) {
  40560. Ext.raise('Anonymous entities cannot specify "associations"');
  40561. }
  40562. if (data.belongsTo) {
  40563. Ext.raise('Anonymous entities cannot specify "belongsTo"');
  40564. }
  40565. if (data.hasMany) {
  40566. Ext.raise('Anonymous entities cannot specify "hasMany"');
  40567. }
  40568. if (data.hasOne) {
  40569. Ext.raise('Anonymous entities cannot specify "hasOne"');
  40570. }
  40571. if (data.matrices) {
  40572. Ext.raise('Anonymous entities cannot specify "manyToMany"');
  40573. }
  40574. }
  40575. }
  40576. cls.entityName = entityName;
  40577. cls.fieldExtractors = {};
  40578. Model.initIdentifier(data, cls, proto);
  40579. Model.initFields(data, cls, proto);
  40580. Model.initValidators(data, cls, proto);
  40581. if (!data.isSummaryModel) {
  40582. Model.initSummaries(data, cls, proto);
  40583. }
  40584. cls.fields.items = cls.fields;
  40585. if (entityName) {
  40586. schema.addEntity(cls);
  40587. Model.initAssociations(schema, data, cls);
  40588. }
  40589. proxy = data.proxy;
  40590. if (proxy) {
  40591. delete data.proxy;
  40592. } else if (superCls !== Model) {
  40593. proxy = superCls.proxyConfig || superCls.proxy;
  40594. }
  40595. cls.proxyConfig = proxy;
  40596. });
  40597. });
  40598. Ext.define('Ext.data.ResultSet', {
  40599. isResultSet: true,
  40600. $configPrefixed: false,
  40601. config: {
  40602. loaded: true,
  40603. count: null,
  40604. total: null,
  40605. remoteTotal: null,
  40606. success: false,
  40607. records: null,
  40608. message: null,
  40609. metadata: null,
  40610. groupData: null,
  40611. summaryData: null
  40612. },
  40613. constructor: function(config) {
  40614. this.initConfig(config);
  40615. },
  40616. getCount: function() {
  40617. var count = this.callParent(),
  40618. records;
  40619. if (!count) {
  40620. records = this.getRecords();
  40621. if (records) {
  40622. count = records.length;
  40623. }
  40624. }
  40625. return count;
  40626. }
  40627. });
  40628. Ext.define('Ext.data.reader.Reader', {
  40629. alternateClassName: [
  40630. 'Ext.data.Reader',
  40631. 'Ext.data.DataReader'
  40632. ],
  40633. mixins: [
  40634. Ext.mixin.Observable,
  40635. Ext.mixin.Factoryable
  40636. ],
  40637. alias: 'reader.base',
  40638. factoryConfig: {
  40639. defaultType: null
  40640. },
  40641. config: {
  40642. groupRootProperty: '',
  40643. implicitIncludes: true,
  40644. keepRawData: null,
  40645. messageProperty: '',
  40646. model: null,
  40647. proxy: null,
  40648. readRecordsOnFailure: true,
  40649. rootProperty: '',
  40650. successProperty: 'success',
  40651. summaryRootProperty: '',
  40652. totalProperty: 'total',
  40653. transform: null,
  40654. typeProperty: ''
  40655. },
  40656. isReader: true,
  40657. constructor: function(config) {
  40658. var me = this;
  40659. if (config && config.hasOwnProperty('root')) {
  40660. config = Ext.apply({}, config);
  40661. config.rootProperty = config.root;
  40662. delete config.root;
  40663. Ext.log.error('Ext.data.reader.Reader: Using the deprecated "root" configuration. ' + 'Use "rootProperty" instead.');
  40664. }
  40665. me.duringInit = 1;
  40666. me.mixins.observable.constructor.call(me, config);
  40667. --me.duringInit;
  40668. me.buildExtractors();
  40669. },
  40670. forceBuildExtractors: function() {
  40671. if (!this.duringInit) {
  40672. this.buildExtractors(true);
  40673. }
  40674. },
  40675. updateGroupRootProperty: function() {
  40676. this.forceBuildExtractors();
  40677. },
  40678. updateMessageProperty: function() {
  40679. this.forceBuildExtractors();
  40680. },
  40681. applyModel: function(model) {
  40682. return Ext.data.schema.Schema.lookupEntity(model);
  40683. },
  40684. updateSuccessProperty: function() {
  40685. this.forceBuildExtractors();
  40686. },
  40687. updateTotalProperty: function() {
  40688. this.forceBuildExtractors();
  40689. },
  40690. applyTransform: function(transform) {
  40691. if (transform) {
  40692. if (Ext.isFunction(transform)) {
  40693. transform = {
  40694. fn: transform
  40695. };
  40696. } else if (transform.charAt) {
  40697. transform = {
  40698. fn: this[transform]
  40699. };
  40700. }
  40701. return transform.fn.bind(transform.scope || this);
  40702. }
  40703. return transform;
  40704. },
  40705. read: function(response, readOptions) {
  40706. var data, result, responseText;
  40707. if (response) {
  40708. responseText = response.responseText;
  40709. if (response.responseType || responseText) {
  40710. result = this.getResponseData(response);
  40711. if (result && result.__$isError) {
  40712. return new Ext.data.ResultSet({
  40713. total: 0,
  40714. count: 0,
  40715. records: [],
  40716. success: false,
  40717. message: result.msg
  40718. });
  40719. } else {
  40720. data = this.readRecords(result, readOptions);
  40721. }
  40722. } else if (responseText !== '') {
  40723. data = this.readRecords(response, readOptions);
  40724. }
  40725. }
  40726. return data || this.nullResultSet;
  40727. },
  40728. getNullResultSet: function() {
  40729. return this.nullResultSet;
  40730. },
  40731. createReadError: function(msg) {
  40732. return {
  40733. __$isError: true,
  40734. msg: msg
  40735. };
  40736. },
  40737. readRecords: function(data, readOptions, internalReadOptions) {
  40738. var me = this,
  40739. recordsOnly = internalReadOptions && internalReadOptions.recordsOnly,
  40740. asRoot = internalReadOptions && internalReadOptions.asRoot,
  40741. groupData = null,
  40742. summaryData = null,
  40743. success, recordCount, records, root, remoteTotal, total, value, message, transform, meta, summaryOptions;
  40744. meta = me.getMeta ? me.getMeta(data) : data.metaData;
  40745. if (meta) {
  40746. me.onMetaChange(meta);
  40747. }
  40748. transform = me.getTransform();
  40749. if (transform) {
  40750. data = transform(data);
  40751. }
  40752. me.buildExtractors();
  40753. if (me.getKeepRawData()) {
  40754. me.rawData = data;
  40755. }
  40756. if (me.hasListeners.rawdata) {
  40757. me.fireEventArgs('rawdata', [
  40758. data
  40759. ]);
  40760. }
  40761. data = me.getData(data);
  40762. success = true;
  40763. recordCount = 0;
  40764. records = [];
  40765. if (me.getSuccessProperty()) {
  40766. value = me.getSuccess(data);
  40767. if (value === false || value === 'false') {
  40768. success = false;
  40769. }
  40770. }
  40771. if (me.getMessageProperty()) {
  40772. message = me.getMessage(data);
  40773. }
  40774. if (success || me.getReadRecordsOnFailure()) {
  40775. root = (asRoot || Ext.isArray(data)) ? data : me.getRoot(data);
  40776. if (root) {
  40777. total = root.length;
  40778. }
  40779. if (me.getTotalProperty()) {
  40780. value = parseInt(me.getTotal(data), 10);
  40781. if (!isNaN(value)) {
  40782. remoteTotal = total = value;
  40783. }
  40784. }
  40785. if (root) {
  40786. records = me.extractData(root, readOptions);
  40787. recordCount = records.length;
  40788. }
  40789. if (me.getGroupRootProperty()) {
  40790. root = me.getGroupRoot(data);
  40791. if (root) {
  40792. summaryOptions = {
  40793. includes: false,
  40794. model: me.getModel().getSummaryModel()
  40795. };
  40796. groupData = me.extractData(root, summaryOptions) || null;
  40797. }
  40798. }
  40799. if (me.getSummaryRootProperty()) {
  40800. root = me.getSummaryRoot(data);
  40801. if (root) {
  40802. summaryOptions = summaryOptions || {
  40803. includes: false,
  40804. model: me.getModel().getSummaryModel()
  40805. };
  40806. summaryData = me.extractData(root, summaryOptions) || null;
  40807. if (summaryData) {
  40808. summaryData = summaryData[0];
  40809. }
  40810. }
  40811. }
  40812. }
  40813. return recordsOnly ? records : new Ext.data.ResultSet({
  40814. total: total || recordCount,
  40815. remoteTotal: remoteTotal,
  40816. metadata: meta,
  40817. count: recordCount,
  40818. records: records,
  40819. success: success,
  40820. message: message,
  40821. groupData: groupData,
  40822. summaryData: summaryData
  40823. });
  40824. },
  40825. extractData: function(root, readOptions) {
  40826. var me = this,
  40827. entityType = readOptions && readOptions.model ? Ext.data.schema.Schema.lookupEntity(readOptions.model) : me.getModel(),
  40828. schema = entityType.schema,
  40829. includes = readOptions && 'includes' in readOptions ? readOptions.includes : schema.hasAssociations(entityType) && me.getImplicitIncludes(),
  40830. fieldExtractorInfo = me.getFieldExtractorInfo(entityType),
  40831. length = root.length,
  40832. records = new Array(length),
  40833. typeProperty = me.getTypeProperty(),
  40834. reader, node, nodeType, record, i;
  40835. if (!length && Ext.isObject(root)) {
  40836. root = [
  40837. root
  40838. ];
  40839. length = 1;
  40840. }
  40841. for (i = 0; i < length; i++) {
  40842. record = root[i];
  40843. if (!record.isModel) {
  40844. node = record;
  40845. if (typeProperty && (nodeType = me.getChildType(schema, node, typeProperty))) {
  40846. reader = nodeType.getProxy().getReader();
  40847. record = reader.extractRecord(node, readOptions, nodeType, schema.hasAssociations(nodeType) && reader.getImplicitIncludes(), reader.getFieldExtractorInfo(nodeType));
  40848. } else {
  40849. record = me.extractRecord(node, readOptions, entityType, includes, fieldExtractorInfo);
  40850. }
  40851. if (record.isModel && record.isNode) {
  40852. record.raw = node;
  40853. }
  40854. }
  40855. if (record.onLoad) {
  40856. record.onLoad();
  40857. }
  40858. records[i] = record;
  40859. }
  40860. return records;
  40861. },
  40862. getChildType: function(schema, rawNode, typeProperty) {
  40863. var namespace;
  40864. switch (typeof typeProperty) {
  40865. case 'string':
  40866. return schema.getEntity(rawNode[typeProperty]);
  40867. case 'object':
  40868. namespace = typeProperty.namespace;
  40869. return schema.getEntity((namespace ? namespace + '.' : '') + rawNode[typeProperty.name]);
  40870. case 'function':
  40871. return schema.getEntity(typeProperty(rawNode));
  40872. }
  40873. },
  40874. extractRecordData: function(node, readOptions) {
  40875. var entityType = readOptions && readOptions.model ? Ext.data.schema.Schema.lookupEntity(readOptions.model) : this.getModel(),
  40876. fieldExtractorInfo = this.getFieldExtractorInfo(entityType);
  40877. return this.extractRecord(node, readOptions, entityType, false, fieldExtractorInfo);
  40878. },
  40879. extractRecord: function(node, readOptions, entityType, includes, fieldExtractorInfo) {
  40880. var me = this,
  40881. creatorFn = (readOptions && readOptions.recordCreator) || me.defaultRecordCreator,
  40882. modelData, record;
  40883. modelData = me.extractModelData(node, fieldExtractorInfo);
  40884. record = creatorFn.call(me, modelData, entityType || me.getModel(), readOptions);
  40885. if (includes && record.isModel) {
  40886. me.readAssociated(record, node, readOptions);
  40887. }
  40888. return record;
  40889. },
  40890. getFieldExtractorInfo: function(entityType) {
  40891. var extractors = entityType.fieldExtractors,
  40892. type, extractor;
  40893. if (!extractors) {
  40894. return;
  40895. }
  40896. type = this.$className;
  40897. extractor = extractors[type];
  40898. if (extractor === undefined) {
  40899. extractors[type] = extractor = this.buildFieldExtractors(entityType);
  40900. }
  40901. return extractor;
  40902. },
  40903. buildFieldExtractors: function(entityType) {
  40904. var fields = entityType.getFields(),
  40905. len = fields.length,
  40906. buffer = [],
  40907. extractors = [],
  40908. out = null,
  40909. cnt = 0,
  40910. field, name, i, extractor;
  40911. for (i = 0; i < len; ++i) {
  40912. field = fields[i];
  40913. extractor = this.createFieldAccessor(field);
  40914. if (extractor) {
  40915. name = field.name;
  40916. buffer.push('val = extractors[' + cnt + '](raw, self); if (val !== undefined) { data[\'' + name + '\'] = val; }');
  40917. extractors.push(extractor);
  40918. ++cnt;
  40919. }
  40920. }
  40921. if (buffer.length) {
  40922. out = {
  40923. extractors: extractors,
  40924. fn: new Function('raw', 'data', 'extractors', 'self', 'var val;' + buffer.join('\n'))
  40925. };
  40926. }
  40927. return out;
  40928. },
  40929. defaultRecordCreator: function(data, Model) {
  40930. return new Model(data);
  40931. },
  40932. defaultRecordCreatorFromServer: function(data, Model) {
  40933. var record = new Model(data);
  40934. record.phantom = false;
  40935. return record;
  40936. },
  40937. getModelData: function(raw) {
  40938. return {};
  40939. },
  40940. extractModelData: function(raw, fieldExtractorInfo) {
  40941. var data = this.getModelData(raw),
  40942. fn;
  40943. if (fieldExtractorInfo) {
  40944. fn = fieldExtractorInfo.fn;
  40945. fn(raw, data, fieldExtractorInfo.extractors, this);
  40946. }
  40947. return data;
  40948. },
  40949. readAssociated: function(record, data, readOptions) {
  40950. var roles = record.associations,
  40951. key, role;
  40952. for (key in roles) {
  40953. if (roles.hasOwnProperty(key)) {
  40954. role = roles[key];
  40955. if (role.cls) {
  40956. role.read(record, data, this, readOptions);
  40957. }
  40958. }
  40959. }
  40960. },
  40961. getData: Ext.identityFn,
  40962. getRoot: Ext.identityFn,
  40963. getResponseData: function(response) {
  40964. Ext.raise("getResponseData must be implemented in the Ext.data.reader.Reader subclass");
  40965. },
  40966. onMetaChange: function(meta) {
  40967. var me = this,
  40968. fields = meta.fields,
  40969. model, newModel, clientIdProperty, proxy;
  40970. me.metaData = meta;
  40971. if (meta.root) {
  40972. me.setRootProperty(meta.root);
  40973. }
  40974. if (meta.totalProperty) {
  40975. me.setTotalProperty(meta.totalProperty);
  40976. }
  40977. if (meta.successProperty) {
  40978. me.setSuccessProperty(meta.successProperty);
  40979. }
  40980. if (meta.messageProperty) {
  40981. me.setMessageProperty(meta.messageProperty);
  40982. }
  40983. clientIdProperty = meta.clientIdProperty;
  40984. if (fields) {
  40985. newModel = Ext.define(null, {
  40986. extend: 'Ext.data.Model',
  40987. fields: fields,
  40988. clientIdProperty: clientIdProperty
  40989. });
  40990. me.setModel(newModel);
  40991. proxy = me.getProxy();
  40992. if (proxy) {
  40993. proxy.setModel(newModel);
  40994. }
  40995. } else if (clientIdProperty) {
  40996. model = me.getModel();
  40997. if (model) {
  40998. model.self.prototype.clientIdProperty = clientIdProperty;
  40999. }
  41000. }
  41001. },
  41002. buildExtractors: function(force) {
  41003. var me = this,
  41004. totalProp, successProp, messageProp;
  41005. if (force || !me.hasExtractors) {
  41006. totalProp = me.getTotalProperty();
  41007. successProp = me.getSuccessProperty();
  41008. messageProp = me.getMessageProperty();
  41009. if (totalProp) {
  41010. me.getTotal = me.getAccessor(totalProp);
  41011. }
  41012. if (successProp) {
  41013. me.getSuccess = me.getAccessor(successProp);
  41014. }
  41015. if (messageProp) {
  41016. me.getMessage = me.getAccessor(messageProp);
  41017. }
  41018. me.hasExtractors = true;
  41019. return true;
  41020. }
  41021. },
  41022. getAccessor: function(prop) {
  41023. var me = this,
  41024. cache = me.extractorCache,
  41025. ret, key;
  41026. if (typeof prop === 'string') {
  41027. key = me.getAccessorKey(prop);
  41028. if (key) {
  41029. ret = cache.get(key);
  41030. }
  41031. if (!ret) {
  41032. ret = me.createAccessor(prop);
  41033. if (key) {
  41034. cache.add(key, ret);
  41035. }
  41036. }
  41037. } else {
  41038. ret = me.createAccessor(prop);
  41039. }
  41040. return ret;
  41041. },
  41042. getAccessorKey: function(prop) {
  41043. var className = this.$className;
  41044. return className ? className + prop : '';
  41045. },
  41046. createAccessor: Ext.emptyFn,
  41047. createFieldAccessor: Ext.emptyFn,
  41048. destroy: function() {
  41049. var me = this;
  41050. me.model = me.getTotal = me.getSuccess = me.getMessage = me.rawData = null;
  41051. me.onMetaChange = null;
  41052. me.transform = null;
  41053. me.callParent();
  41054. },
  41055. privates: {
  41056. copyFrom: function(reader) {
  41057. var me = this;
  41058. reader.buildExtractors();
  41059. me.getTotal = reader.getTotal;
  41060. me.getSuccess = reader.getSuccess;
  41061. me.getMessage = reader.getMessage;
  41062. ++me.duringInit;
  41063. me.setConfig(reader.getConfig());
  41064. --me.duringInit;
  41065. me.hasExtractors = true;
  41066. },
  41067. getGroupRoot: Ext.privateFn,
  41068. getSummaryRoot: Ext.privateFn
  41069. }
  41070. }, function(Cls) {
  41071. var proto = Cls.prototype;
  41072. Ext.apply(proto, {
  41073. nullResultSet: new Ext.data.ResultSet({
  41074. total: 0,
  41075. count: 0,
  41076. records: [],
  41077. success: true,
  41078. message: ''
  41079. })
  41080. });
  41081. proto.extractorCache = new Ext.util.LruCache();
  41082. });
  41083. Ext.define('Ext.data.writer.Writer', {
  41084. alias: 'writer.base',
  41085. alternateClassName: [
  41086. 'Ext.data.DataWriter',
  41087. 'Ext.data.Writer'
  41088. ],
  41089. mixins: [
  41090. Ext.mixin.Factoryable
  41091. ],
  41092. factoryConfig: {
  41093. defaultType: null
  41094. },
  41095. isWriter: true,
  41096. config: {
  41097. clientIdProperty: null,
  41098. allDataOptions: {
  41099. persist: true
  41100. },
  41101. partialDataOptions: {
  41102. changes: true,
  41103. critical: true
  41104. },
  41105. writeAllFields: false,
  41106. dateFormat: null,
  41107. nameProperty: 'name',
  41108. writeRecordId: true,
  41109. transform: null
  41110. },
  41111. constructor: function(config) {
  41112. this.initConfig(config);
  41113. },
  41114. applyTransform: function(transform) {
  41115. if (transform) {
  41116. if (Ext.isFunction(transform)) {
  41117. transform = {
  41118. fn: transform
  41119. };
  41120. }
  41121. return transform.fn.bind(transform.scope || this);
  41122. }
  41123. return transform;
  41124. },
  41125. write: function(request) {
  41126. var operation = request.getOperation(),
  41127. records = operation.getRecords() || [],
  41128. len = records.length,
  41129. data = [],
  41130. i;
  41131. for (i = 0; i < len; i++) {
  41132. data.push(this.getRecordData(records[i], operation));
  41133. }
  41134. return this.writeRecords(request, data);
  41135. },
  41136. writeRecords: Ext.emptyFn,
  41137. getRecordData: function(record, operation) {
  41138. var me = this,
  41139. nameProperty = me.getNameProperty(),
  41140. mapping = nameProperty !== 'name',
  41141. idField = record.self.idField,
  41142. key = idField ? (idField[nameProperty] || idField.name) : 'id',
  41143. value = record.id,
  41144. writeAll = me.getWriteAllFields(),
  41145. ret, dateFormat, phantom, options, clientIdProperty, fieldsMap, data, field;
  41146. if (idField && idField.serialize) {
  41147. value = idField.serialize(value);
  41148. }
  41149. if (!writeAll && operation && operation.isDestroyOperation) {
  41150. ret = {};
  41151. ret[key] = value;
  41152. } else {
  41153. dateFormat = me.getDateFormat();
  41154. phantom = record.phantom;
  41155. options = (phantom || writeAll) ? me.getAllDataOptions() : me.getPartialDataOptions();
  41156. clientIdProperty = phantom && me.getClientIdProperty();
  41157. fieldsMap = record.getFieldsMap();
  41158. options.serialize = false;
  41159. data = record.getData(options);
  41160. ret = mapping ? {} : data;
  41161. if (clientIdProperty) {
  41162. ret[clientIdProperty] = value;
  41163. delete data[key];
  41164. }
  41165. else if (!me.getWriteRecordId()) {
  41166. delete data[key];
  41167. }
  41168. for (key in data) {
  41169. value = data[key];
  41170. if (!(field = fieldsMap[key])) {
  41171. if (mapping) {
  41172. ret[key] = value;
  41173. }
  41174. } else {
  41175. if (field.isDateField && dateFormat && Ext.isDate(value)) {
  41176. value = Ext.Date.format(value, dateFormat);
  41177. } else if (field.serialize) {
  41178. value = field.serialize(value, record);
  41179. }
  41180. if (mapping) {
  41181. key = field[nameProperty] || key;
  41182. }
  41183. ret[key] = value;
  41184. }
  41185. }
  41186. }
  41187. return ret;
  41188. }
  41189. });
  41190. Ext.define('Ext.data.proxy.Proxy', {
  41191. mixins: [
  41192. Ext.mixin.Factoryable,
  41193. Ext.mixin.Observable
  41194. ],
  41195. $configPrefixed: false,
  41196. alias: 'proxy.proxy',
  41197. alternateClassName: [
  41198. 'Ext.data.DataProxy',
  41199. 'Ext.data.Proxy'
  41200. ],
  41201. config: {
  41202. batchOrder: 'create,update,destroy',
  41203. batchActions: true,
  41204. model: undefined,
  41205. reader: {
  41206. type: 'json'
  41207. },
  41208. writer: {
  41209. type: 'json'
  41210. }
  41211. },
  41212. isProxy: true,
  41213. isSynchronous: false,
  41214. constructor: function(config) {
  41215. this.mixins.observable.constructor.call(this, config);
  41216. this.pendingOperations = {};
  41217. },
  41218. applyModel: function(model) {
  41219. return Ext.data.schema.Schema.lookupEntity(model);
  41220. },
  41221. updateModel: function(model) {
  41222. var reader;
  41223. if (model) {
  41224. reader = this.getReader();
  41225. if (reader && !reader.getModel()) {
  41226. reader.setModel(model);
  41227. }
  41228. }
  41229. },
  41230. applyReader: function(reader) {
  41231. if (this.isSynchronous) {
  41232. reader = reader || {};
  41233. reader.keepRawData = true;
  41234. }
  41235. return Ext.Factory.reader(reader);
  41236. },
  41237. updateReader: function(reader) {
  41238. var me = this,
  41239. model;
  41240. if (reader) {
  41241. model = me.getModel();
  41242. if (!model) {
  41243. model = reader.getModel();
  41244. if (model) {
  41245. me.setModel(model);
  41246. }
  41247. } else {
  41248. reader.setModel(model);
  41249. }
  41250. if (reader.responseType != null) {
  41251. me.responseType = reader.responseType;
  41252. }
  41253. }
  41254. },
  41255. applyWriter: function(writer) {
  41256. var reader = this.getReader();
  41257. writer = Ext.Factory.writer(writer);
  41258. if (writer.getRecord && !writer.getRecord() && reader && reader.getRecord) {
  41259. reader = reader.getRecord();
  41260. if (reader) {
  41261. writer.setRecord(reader);
  41262. }
  41263. }
  41264. return writer;
  41265. },
  41266. abort: Ext.emptyFn,
  41267. onMetaChange: function(meta) {
  41268. this.fireEvent('metachange', this, meta);
  41269. },
  41270. create: Ext.emptyFn,
  41271. read: Ext.emptyFn,
  41272. update: Ext.emptyFn,
  41273. erase: Ext.emptyFn,
  41274. batch: function(options, listeners) {
  41275. var me = this,
  41276. useBatch = me.getBatchActions(),
  41277. batch, records, actions, aLen, action, a, r, rLen, record;
  41278. if (options.operations === undefined) {
  41279. options = {
  41280. operations: options,
  41281. listeners: listeners
  41282. };
  41283. }
  41284. if (options.batch) {
  41285. if (Ext.isDefined(options.batch.runOperation)) {
  41286. batch = Ext.applyIf(options.batch, {
  41287. proxy: me,
  41288. listeners: {}
  41289. });
  41290. }
  41291. } else {
  41292. options.batch = {
  41293. proxy: me,
  41294. listeners: options.listeners || {}
  41295. };
  41296. }
  41297. if (!batch) {
  41298. batch = new Ext.data.Batch(options.batch);
  41299. }
  41300. batch.on('complete', Ext.bind(me.onBatchComplete, me, [
  41301. options
  41302. ], 0), null, {
  41303. single: true,
  41304. priority: 1000
  41305. });
  41306. batch.$destroyOwner = options.$destroyOwner;
  41307. actions = me.getBatchOrder().split(',');
  41308. aLen = actions.length;
  41309. for (a = 0; a < aLen; a++) {
  41310. action = actions[a];
  41311. records = options.operations[action];
  41312. if (records) {
  41313. if (useBatch) {
  41314. batch.add(me.createOperation(action, {
  41315. records: records,
  41316. params: options.params
  41317. }));
  41318. } else {
  41319. rLen = records.length;
  41320. for (r = 0; r < rLen; r++) {
  41321. record = records[r];
  41322. batch.add(me.createOperation(action, {
  41323. records: [
  41324. record
  41325. ],
  41326. params: options.params
  41327. }));
  41328. }
  41329. }
  41330. }
  41331. }
  41332. batch.start();
  41333. return batch;
  41334. },
  41335. onBatchComplete: function(batchOptions, batch) {
  41336. var scope = batchOptions.scope || this;
  41337. if (batch.hasException()) {
  41338. if (Ext.isFunction(batchOptions.failure)) {
  41339. Ext.callback(batchOptions.failure, scope, [
  41340. batch,
  41341. batchOptions
  41342. ]);
  41343. }
  41344. } else if (Ext.isFunction(batchOptions.success)) {
  41345. Ext.callback(batchOptions.success, scope, [
  41346. batch,
  41347. batchOptions
  41348. ]);
  41349. }
  41350. if (Ext.isFunction(batchOptions.callback)) {
  41351. Ext.callback(batchOptions.callback, scope, [
  41352. batch,
  41353. batchOptions
  41354. ]);
  41355. }
  41356. if (!batch.$destroyOwner) {
  41357. batch.destroy();
  41358. }
  41359. },
  41360. createOperation: function(action, config) {
  41361. var operation = Ext.createByAlias('data.operation.' + action, config);
  41362. operation.setProxy(this);
  41363. this.pendingOperations[operation._internalId] = operation;
  41364. return operation;
  41365. },
  41366. completeOperation: function(operation) {
  41367. delete this.pendingOperations[operation._internalId];
  41368. },
  41369. clone: function() {
  41370. return new this.self(this.getInitialConfig());
  41371. },
  41372. destroy: function() {
  41373. var ops = this.pendingOperations,
  41374. opId, op;
  41375. for (opId in ops) {
  41376. op = ops[opId];
  41377. if (op && op.isRunning()) {
  41378. op.abort();
  41379. }
  41380. op.destroy();
  41381. }
  41382. this.pendingOperations = null;
  41383. this.callParent();
  41384. }
  41385. });
  41386. Ext.define('Ext.data.proxy.Client', {
  41387. extend: Ext.data.proxy.Proxy,
  41388. alternateClassName: 'Ext.data.ClientProxy',
  41389. isSynchronous: true,
  41390. clear: function() {
  41391. Ext.raise("The Ext.data.proxy.Client subclass that you are using has not defined " + "a 'clear' function. See src/data/ClientProxy.js for details.");
  41392. }
  41393. });
  41394. Ext.define('Ext.data.proxy.Memory', {
  41395. extend: Ext.data.proxy.Client,
  41396. alias: 'proxy.memory',
  41397. alternateClassName: 'Ext.data.MemoryProxy',
  41398. isMemoryProxy: true,
  41399. config: {
  41400. enablePaging: null,
  41401. data: {
  41402. $value: null,
  41403. merge: function(newValue, currentValue, target, mixinClass) {
  41404. return newValue ? Ext.clone(newValue) : newValue;
  41405. }
  41406. },
  41407. clearOnRead: null
  41408. },
  41409. finishOperation: function(operation) {
  41410. var recs = operation.getRecords(),
  41411. len = recs.length,
  41412. i;
  41413. for (i = 0; i < len; i++) {
  41414. recs[i].dropped = !!operation.isDestroyOperation;
  41415. recs[i].commit();
  41416. }
  41417. operation.setSuccessful(true);
  41418. },
  41419. create: function(operation) {
  41420. this.finishOperation(operation);
  41421. },
  41422. update: function(operation) {
  41423. this.finishOperation(operation);
  41424. },
  41425. erase: function(operation) {
  41426. this.finishOperation(operation);
  41427. },
  41428. read: function(operation) {
  41429. var me = this,
  41430. reader = me.getReader(),
  41431. resultSet = reader.read(me.getData(), {
  41432. recordCreator: reader.defaultRecordCreatorFromServer
  41433. }),
  41434. records = resultSet.getRecords(),
  41435. sorters = operation.getSorters(),
  41436. grouper = operation.getGrouper(),
  41437. filters = operation.getFilters(),
  41438. start = operation.getStart(),
  41439. limit = operation.getLimit(),
  41440. meta;
  41441. if (operation.process(resultSet, null, null, false) !== false) {
  41442. if (operation.success && me.getClearOnRead()) {
  41443. this.setData(null);
  41444. }
  41445. if (filters && filters.length) {
  41446. resultSet.setRecords(records = Ext.Array.filter(records, Ext.util.Filter.createFilterFn(filters)));
  41447. resultSet.setTotal(records.length);
  41448. }
  41449. if (grouper) {
  41450. sorters = sorters ? sorters.concat(grouper) : sorters;
  41451. }
  41452. if (sorters && sorters.length) {
  41453. resultSet.setRecords(records = Ext.Array.sort(records, Ext.util.Sortable.createComparator(sorters)));
  41454. }
  41455. if (me.getEnablePaging() && start !== undefined && limit !== undefined) {
  41456. if (start >= resultSet.getTotal()) {
  41457. resultSet.setConfig({
  41458. success: false,
  41459. records: [],
  41460. total: 0
  41461. });
  41462. } else
  41463. {
  41464. resultSet.setRecords(Ext.Array.slice(records, start, start + limit));
  41465. }
  41466. }
  41467. operation.setCompleted();
  41468. meta = resultSet.getMetadata();
  41469. if (meta) {
  41470. me.onMetaChange(meta);
  41471. }
  41472. }
  41473. },
  41474. clear: Ext.emptyFn
  41475. });
  41476. Ext.define('Ext.data.ProxyStore', {
  41477. extend: Ext.data.AbstractStore,
  41478. config: {
  41479. model: undefined,
  41480. fields: null,
  41481. proxy: undefined,
  41482. autoLoad: undefined,
  41483. autoSync: false,
  41484. batchUpdateMode: 'operation',
  41485. sortOnLoad: true,
  41486. trackRemoved: true,
  41487. asynchronousLoad: undefined
  41488. },
  41489. onClassExtended: function(cls, data, hooks) {
  41490. var model = data.model,
  41491. onBeforeClassCreated;
  41492. if (typeof model === 'string') {
  41493. onBeforeClassCreated = hooks.onBeforeCreated;
  41494. hooks.onBeforeCreated = function() {
  41495. var me = this,
  41496. args = arguments;
  41497. Ext.require(model, function() {
  41498. onBeforeClassCreated.apply(me, args);
  41499. });
  41500. };
  41501. }
  41502. },
  41503. implicitModel: 'Ext.data.Model',
  41504. autoSyncSuspended: 0,
  41505. removed: null,
  41506. constructor: function(config) {
  41507. var me = this;
  41508. var configModel = me.model;
  41509. me.callParent(arguments);
  41510. if (me.getAsynchronousLoad() === false) {
  41511. me.flushLoad();
  41512. }
  41513. if (!me.getModel() && me.useModelWarning !== false && me.getStoreId() !== 'ext-empty-store') {
  41514. var logMsg = [
  41515. Ext.getClassName(me) || 'Store',
  41516. ' created with no model.'
  41517. ];
  41518. if (typeof configModel === 'string') {
  41519. logMsg.push(" The name '", configModel, "'", ' does not correspond to a valid model.');
  41520. }
  41521. Ext.log.warn(logMsg.join(''));
  41522. }
  41523. },
  41524. doDestroy: function() {
  41525. var me = this,
  41526. proxy = me.getProxy();
  41527. me.clearLoadTask();
  41528. Ext.destroy(me.getData());
  41529. me.data = null;
  41530. me.setProxy(null);
  41531. if (proxy.autoCreated) {
  41532. proxy.destroy();
  41533. }
  41534. me.setModel(null);
  41535. me.callParent();
  41536. },
  41537. applyAsynchronousLoad: function(asynchronousLoad) {
  41538. if (asynchronousLoad == null) {
  41539. asynchronousLoad = !this.loadsSynchronously();
  41540. }
  41541. return asynchronousLoad;
  41542. },
  41543. updateAutoLoad: function(autoLoad) {
  41544. this.getData();
  41545. if (autoLoad) {
  41546. this.load(Ext.isObject(autoLoad) ? autoLoad : undefined);
  41547. }
  41548. },
  41549. getTotalCount: function() {
  41550. return this.totalCount || 0;
  41551. },
  41552. applyFields: function(fields) {
  41553. if (fields) {
  41554. this.createImplicitModel(fields);
  41555. }
  41556. },
  41557. applyModel: function(model) {
  41558. if (model) {
  41559. model = Ext.data.schema.Schema.lookupEntity(model);
  41560. } else if (!this.destroying) {
  41561. this.getFields();
  41562. model = this.getModel() || this.createImplicitModel();
  41563. }
  41564. return model;
  41565. },
  41566. applyProxy: function(proxy) {
  41567. var model = this.getModel();
  41568. if (proxy !== null) {
  41569. if (proxy) {
  41570. if (proxy.isProxy) {
  41571. proxy.setModel(model);
  41572. } else {
  41573. if (Ext.isString(proxy)) {
  41574. proxy = {
  41575. type: proxy,
  41576. model: model
  41577. };
  41578. } else if (!proxy.model) {
  41579. proxy = Ext.apply({
  41580. model: model
  41581. }, proxy);
  41582. }
  41583. proxy = Ext.createByAlias('proxy.' + proxy.type, proxy);
  41584. proxy.autoCreated = true;
  41585. }
  41586. } else if (model) {
  41587. proxy = model.getProxy();
  41588. this.useModelProxy = true;
  41589. }
  41590. if (!proxy) {
  41591. proxy = Ext.createByAlias('proxy.memory');
  41592. proxy.autoCreated = true;
  41593. }
  41594. }
  41595. return proxy;
  41596. },
  41597. applyState: function(state) {
  41598. var me = this;
  41599. me.callParent([
  41600. state
  41601. ]);
  41602. if (me.getAutoLoad() || me.isLoaded()) {
  41603. me.load();
  41604. }
  41605. },
  41606. updateProxy: function(proxy, oldProxy) {
  41607. this.proxyListeners = Ext.destroy(this.proxyListeners);
  41608. },
  41609. updateTrackRemoved: function(track) {
  41610. this.cleanRemoved();
  41611. this.removed = track ? [] : null;
  41612. },
  41613. onMetaChange: function(proxy, meta) {
  41614. this.fireEvent('metachange', this, meta);
  41615. },
  41616. create: function(data, options) {
  41617. var me = this,
  41618. Model = me.getModel(),
  41619. instance = new Model(data),
  41620. operation;
  41621. options = Ext.apply({}, options);
  41622. if (!options.records) {
  41623. options.records = [
  41624. instance
  41625. ];
  41626. }
  41627. options.internalScope = me;
  41628. options.internalCallback = me.onProxyWrite;
  41629. operation = me.createOperation('create', options);
  41630. return operation.execute();
  41631. },
  41632. read: function() {
  41633. return this.load.apply(this, arguments);
  41634. },
  41635. update: function(options) {
  41636. var me = this,
  41637. operation;
  41638. options = Ext.apply({}, options);
  41639. if (!options.records) {
  41640. options.records = me.getUpdatedRecords();
  41641. }
  41642. options.internalScope = me;
  41643. options.internalCallback = me.onProxyWrite;
  41644. operation = me.createOperation('update', options);
  41645. return operation.execute();
  41646. },
  41647. onProxyWrite: function(operation) {
  41648. var me = this,
  41649. success = operation.wasSuccessful(),
  41650. records = operation.getRecords();
  41651. switch (operation.getAction()) {
  41652. case 'create':
  41653. me.onCreateRecords(records, operation, success);
  41654. break;
  41655. case 'update':
  41656. me.onUpdateRecords(records, operation, success);
  41657. break;
  41658. case 'destroy':
  41659. me.onDestroyRecords(records, operation, success);
  41660. break;
  41661. }
  41662. if (success) {
  41663. me.fireEvent('write', me, operation);
  41664. me.fireEvent('datachanged', me);
  41665. }
  41666. },
  41667. onCreateRecords: Ext.emptyFn,
  41668. onUpdateRecords: Ext.emptyFn,
  41669. onDestroyRecords: function(records, operation, success) {
  41670. if (success) {
  41671. this.cleanRemoved();
  41672. }
  41673. },
  41674. erase: function(options) {
  41675. var me = this,
  41676. operation;
  41677. options = Ext.apply({}, options);
  41678. if (!options.records) {
  41679. options.records = me.getRemovedRecords();
  41680. }
  41681. options.internalScope = me;
  41682. options.internalCallback = me.onProxyWrite;
  41683. operation = me.createOperation('destroy', options);
  41684. return operation.execute();
  41685. },
  41686. onBatchOperationComplete: function(batch, operation) {
  41687. return this.onProxyWrite(operation);
  41688. },
  41689. onBatchComplete: function(batch, operation) {
  41690. var me = this,
  41691. operations = batch.operations,
  41692. length = operations.length,
  41693. i;
  41694. if (me.batchUpdateMode !== 'operation') {
  41695. me.suspendEvents();
  41696. for (i = 0; i < length; i++) {
  41697. me.onProxyWrite(operations[i]);
  41698. }
  41699. me.resumeEvents();
  41700. }
  41701. me.isSyncing = false;
  41702. if (batch.$destroyOwner === me) {
  41703. batch.destroy();
  41704. }
  41705. me.fireEvent('datachanged', me);
  41706. },
  41707. onBatchException: function(batch, operation) {},
  41708. filterNew: function(item) {
  41709. return item.phantom && item.isValid();
  41710. },
  41711. getNewRecords: function() {
  41712. return [];
  41713. },
  41714. getUpdatedRecords: function() {
  41715. return [];
  41716. },
  41717. getModifiedRecords: function() {
  41718. return [].concat(this.getNewRecords(), this.getUpdatedRecords());
  41719. },
  41720. filterUpdated: function(item) {
  41721. return item.dirty && !item.phantom && item.isValid();
  41722. },
  41723. getRemovedRecords: function() {
  41724. var removed = this.getRawRemovedRecords();
  41725. return removed ? Ext.Array.clone(removed) : [];
  41726. },
  41727. sync: function(options) {
  41728. var me = this,
  41729. operations = {},
  41730. toCreate = me.getNewRecords(),
  41731. toUpdate = me.getUpdatedRecords(),
  41732. toDestroy = me.getRemovedRecords(),
  41733. needsSync = false;
  41734. if (me.isSyncing) {
  41735. Ext.log.warn('Sync called while a sync operation is in progress. ' + 'Consider configuring autoSync as false.');
  41736. }
  41737. me.needsSync = false;
  41738. if (toCreate.length > 0) {
  41739. operations.create = toCreate;
  41740. needsSync = true;
  41741. }
  41742. if (toUpdate.length > 0) {
  41743. operations.update = toUpdate;
  41744. needsSync = true;
  41745. }
  41746. if (toDestroy.length > 0) {
  41747. operations.destroy = toDestroy;
  41748. needsSync = true;
  41749. }
  41750. if (needsSync && me.fireEvent('beforesync', operations) !== false) {
  41751. me.isSyncing = true;
  41752. options = options || {};
  41753. me.proxy.batch(Ext.apply(options, {
  41754. operations: operations,
  41755. listeners: me.getBatchListeners(),
  41756. $destroyOwner: me
  41757. }));
  41758. }
  41759. return me;
  41760. },
  41761. getBatchListeners: function() {
  41762. var me = this,
  41763. listeners = {
  41764. scope: me,
  41765. exception: me.onBatchException,
  41766. complete: me.onBatchComplete
  41767. };
  41768. if (me.batchUpdateMode === 'operation') {
  41769. listeners.operationcomplete = me.onBatchOperationComplete;
  41770. }
  41771. return listeners;
  41772. },
  41773. save: function() {
  41774. return this.sync.apply(this, arguments);
  41775. },
  41776. load: function(options) {
  41777. var me = this;
  41778. if (typeof options === 'function') {
  41779. options = {
  41780. callback: options
  41781. };
  41782. } else {
  41783. options = options ? Ext.Object.chain(options) : {};
  41784. }
  41785. me.pendingLoadOptions = options;
  41786. if (me.getAsynchronousLoad()) {
  41787. if (!me.loadTimer) {
  41788. me.loadTimer = Ext.asap(me.flushLoad, me);
  41789. }
  41790. } else
  41791. {
  41792. me.flushLoad();
  41793. }
  41794. return me;
  41795. },
  41796. flushLoad: function() {
  41797. var me = this,
  41798. options = me.pendingLoadOptions,
  41799. operation;
  41800. if (me.destroying || me.destroyed) {
  41801. return;
  41802. }
  41803. me.clearLoadTask();
  41804. if (!options) {
  41805. return;
  41806. }
  41807. me.setLoadOptions(options);
  41808. if (me.getRemoteSort() && options.sorters) {
  41809. me.fireEvent('beforesort', me, options.sorters);
  41810. }
  41811. operation = Ext.apply({
  41812. internalScope: me,
  41813. internalCallback: me.onProxyLoad,
  41814. scope: me
  41815. }, options);
  41816. me.lastOptions = operation;
  41817. operation = me.createOperation('read', operation);
  41818. if (me.fireEvent('beforeload', me, operation) !== false) {
  41819. me.onBeforeLoad(operation);
  41820. me.loading = true;
  41821. if (me.hasListeners.beginload) {
  41822. me.fireEvent('beginload', me, operation);
  41823. }
  41824. operation.execute();
  41825. } else {
  41826. if (me.getAsynchronousLoad()) {
  41827. operation.abort();
  41828. }
  41829. operation.setCompleted();
  41830. }
  41831. },
  41832. reload: function(options) {
  41833. return this.load(Ext.apply({}, options, this.lastOptions));
  41834. },
  41835. onEndUpdate: function() {
  41836. var me = this;
  41837. if (me.needsSync && me.autoSync && !me.autoSyncSuspended) {
  41838. me.sync();
  41839. }
  41840. },
  41841. afterReject: function(record) {
  41842. var me = this;
  41843. if (me.contains(record)) {
  41844. me.onUpdate(record, Ext.data.Model.REJECT, null);
  41845. me.fireEvent('update', me, record, Ext.data.Model.REJECT, null);
  41846. me.fireEvent('datachanged', me);
  41847. }
  41848. },
  41849. afterCommit: function(record, modifiedFieldNames) {
  41850. var me = this;
  41851. if (!modifiedFieldNames) {
  41852. modifiedFieldNames = null;
  41853. }
  41854. if (me.contains(record)) {
  41855. me.onUpdate(record, Ext.data.Model.COMMIT, modifiedFieldNames);
  41856. me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
  41857. me.fireEvent('datachanged', me);
  41858. }
  41859. },
  41860. afterErase: function(record) {
  41861. this.onErase(record);
  41862. },
  41863. onErase: Ext.emptyFn,
  41864. onUpdate: Ext.emptyFn,
  41865. hasPendingLoad: function() {
  41866. return !!this.pendingLoadOptions || this.isLoading();
  41867. },
  41868. isLoading: function() {
  41869. return !!this.loading;
  41870. },
  41871. isLoaded: function() {
  41872. return this.loadCount > 0;
  41873. },
  41874. suspendAutoSync: function() {
  41875. ++this.autoSyncSuspended;
  41876. },
  41877. resumeAutoSync: function(syncNow) {
  41878. var me = this;
  41879. if (!me.autoSyncSuspended) {
  41880. Ext.log.warn('Mismatched call to resumeAutoSync - auto synchronization ' + 'is currently not suspended.');
  41881. }
  41882. if (me.autoSyncSuspended && !--me.autoSyncSuspended) {
  41883. if (syncNow) {
  41884. me.sync();
  41885. }
  41886. }
  41887. },
  41888. removeAll: Ext.emptyFn,
  41889. clearData: Ext.emptyFn,
  41890. privates: {
  41891. getRawRemovedRecords: function() {
  41892. return this.removed;
  41893. },
  41894. onExtraParamsChanged: function() {},
  41895. clearLoadTask: function() {
  41896. this.pendingLoadOptions = this.loadTimer = Ext.unasap(this.loadTimer);
  41897. },
  41898. cleanRemoved: function() {
  41899. var removed = this.getRawRemovedRecords(),
  41900. len, i;
  41901. if (removed) {
  41902. for (i = 0 , len = removed.length; i < len; ++i) {
  41903. removed[i].unjoin(this);
  41904. }
  41905. removed.length = 0;
  41906. }
  41907. },
  41908. createOperation: function(type, options) {
  41909. var me = this,
  41910. proxy = me.getProxy(),
  41911. listeners;
  41912. if (!me.proxyListeners) {
  41913. listeners = {
  41914. scope: me,
  41915. destroyable: true,
  41916. beginprocessresponse: me.beginUpdate,
  41917. endprocessresponse: me.endUpdate
  41918. };
  41919. if (!me.disableMetaChangeEvent) {
  41920. listeners.metachange = me.onMetaChange;
  41921. }
  41922. me.proxyListeners = proxy.on(listeners);
  41923. }
  41924. return proxy.createOperation(type, options);
  41925. },
  41926. createImplicitModel: function(fields) {
  41927. var me = this,
  41928. modelCfg = {
  41929. extend: me.implicitModel,
  41930. statics: {
  41931. defaultProxy: 'memory'
  41932. }
  41933. },
  41934. proxy, model;
  41935. if (fields) {
  41936. modelCfg.fields = fields;
  41937. }
  41938. model = Ext.define(null, modelCfg);
  41939. me.setModel(model);
  41940. proxy = me.getProxy();
  41941. if (proxy) {
  41942. model.setProxy(proxy);
  41943. } else {
  41944. me.setProxy(model.getProxy());
  41945. }
  41946. },
  41947. loadsSynchronously: function() {
  41948. return this.getProxy().isSynchronous;
  41949. },
  41950. onBeforeLoad: Ext.privateFn,
  41951. removeFromRemoved: function(record) {
  41952. var removed = this.getRawRemovedRecords();
  41953. if (removed) {
  41954. Ext.Array.remove(removed, record);
  41955. record.unjoin(this);
  41956. }
  41957. },
  41958. setLoadOptions: function(options) {
  41959. var me = this,
  41960. filters, sorters;
  41961. if (me.getRemoteFilter()) {
  41962. filters = me.getFilters(false);
  41963. if (filters && filters.getCount()) {
  41964. options.filters = filters.getRange();
  41965. }
  41966. }
  41967. if (me.getRemoteSort()) {
  41968. sorters = me.getSorters(false);
  41969. if (sorters && sorters.getCount()) {
  41970. options.sorters = sorters.getRange();
  41971. }
  41972. }
  41973. }
  41974. }
  41975. });
  41976. Ext.define('Ext.util.Group', {
  41977. extend: Ext.util.Collection,
  41978. isGroup: true,
  41979. config: {
  41980. groupKey: null
  41981. },
  41982. $endUpdatePriority: 2001,
  41983. manageSorters: false
  41984. });
  41985. Ext.define('Ext.data.Group', {
  41986. extend: Ext.util.Group,
  41987. isDataGroup: true,
  41988. store: null,
  41989. getSummaryRecord: function() {
  41990. var me = this,
  41991. summaryRecord = me.summaryRecord,
  41992. store = me.store,
  41993. generation = store.getData().generation,
  41994. M, T;
  41995. if (!summaryRecord) {
  41996. M = store.getModel();
  41997. T = M.getSummaryModel();
  41998. me.summaryRecord = summaryRecord = new T();
  41999. }
  42000. if (!summaryRecord.isRemote && summaryRecord.summaryGeneration !== generation) {
  42001. summaryRecord.calculateSummary(me.items);
  42002. summaryRecord.summaryGeneration = generation;
  42003. }
  42004. return summaryRecord;
  42005. }
  42006. });
  42007. Ext.define('Ext.data.LocalStore', {
  42008. extend: Ext.Mixin,
  42009. mixinConfig: {
  42010. id: 'localstore',
  42011. after: {
  42012. fireGroupChangeEvent: 'onGrouperChange'
  42013. }
  42014. },
  42015. config: {
  42016. extraKeys: null
  42017. },
  42018. applyExtraKeys: function(extraKeys) {
  42019. var indexName,
  42020. data = this.getData();
  42021. data.setExtraKeys(extraKeys);
  42022. extraKeys = data.getExtraKeys();
  42023. for (indexName in extraKeys) {
  42024. this[indexName] = extraKeys[indexName];
  42025. }
  42026. },
  42027. add: function(record) {
  42028. return this.insert(this.getCount(), arguments.length === 1 ? record : arguments);
  42029. },
  42030. constructDataCollection: function() {
  42031. var result = new Ext.util.Collection({
  42032. id: this.getId() + '-data',
  42033. rootProperty: 'data',
  42034. groupConfig: {
  42035. xclass: 'Ext.data.Group',
  42036. store: this
  42037. }
  42038. });
  42039. result.addObserver(this);
  42040. return result;
  42041. },
  42042. createModel: function(record) {
  42043. var session = this.getSession(),
  42044. Model;
  42045. if (!record.isModel) {
  42046. Model = this.getModel();
  42047. record = new Model(record, session);
  42048. }
  42049. return record;
  42050. },
  42051. createFiltersCollection: function() {
  42052. return this.getData().getFilters();
  42053. },
  42054. createSortersCollection: function() {
  42055. var sorters = this.getData().getSorters();
  42056. sorters.setSorterConfigure(this.addFieldTransform, this);
  42057. return sorters;
  42058. },
  42059. getSummaryRecord: function() {
  42060. var me = this,
  42061. summaryRecord = me.summaryRecord,
  42062. data = me.getData(),
  42063. generation = data.generation,
  42064. T;
  42065. if (!summaryRecord) {
  42066. T = me.getModel().getSummaryModel();
  42067. me.summaryRecord = summaryRecord = new T();
  42068. }
  42069. if (!summaryRecord.isRemote && summaryRecord.summaryGeneration !== generation) {
  42070. summaryRecord.calculateSummary(data.items);
  42071. summaryRecord.summaryGeneration = generation;
  42072. }
  42073. return summaryRecord;
  42074. },
  42075. onCollectionBeginUpdate: function() {
  42076. this.beginUpdate();
  42077. },
  42078. onCollectionEndUpdate: function() {
  42079. this.endUpdate();
  42080. },
  42081. onCollectionSort: function() {
  42082. this.onSorterEndUpdate();
  42083. },
  42084. onCollectionFilter: function() {
  42085. this.onFilterEndUpdate();
  42086. },
  42087. onGrouperChange: function(grouper) {
  42088. this.callObservers('GrouperChange', [
  42089. grouper
  42090. ]);
  42091. },
  42092. notifySorterChange: function() {
  42093. this.getData().onSorterChange();
  42094. },
  42095. forceLocalSort: function() {
  42096. var sorters = this.getSorters();
  42097. sorters.beginUpdate();
  42098. sorters.endUpdate();
  42099. },
  42100. contains: function(record) {
  42101. return this.indexOf(record) > -1;
  42102. },
  42103. each: function(fn, scope, includeOptions) {
  42104. var data = this.getData(),
  42105. bypassFilters = includeOptions,
  42106. len, record, i;
  42107. if (typeof includeOptions === 'object') {
  42108. bypassFilters = includeOptions.filtered;
  42109. }
  42110. if (bypassFilters && data.filtered) {
  42111. data = data.getSource();
  42112. }
  42113. data = data.items.slice(0);
  42114. len = data.length;
  42115. for (i = 0; i < len; ++i) {
  42116. record = data[i];
  42117. if (fn.call(scope || record, record, i, len) === false) {
  42118. break;
  42119. }
  42120. }
  42121. },
  42122. collect: function(property, includeOptions, filtered) {
  42123. var me = this,
  42124. allowNull = includeOptions,
  42125. data = me.getData();
  42126. if (typeof includeOptions === 'object') {
  42127. filtered = includeOptions.filtered;
  42128. allowNull = includeOptions.allowNull;
  42129. }
  42130. if (filtered && data.filtered) {
  42131. data = data.getSource();
  42132. }
  42133. return data.collect(property, 'data', allowNull);
  42134. },
  42135. getById: function(id) {
  42136. var data = this.getData();
  42137. if (data.filtered) {
  42138. data = data.getSource();
  42139. }
  42140. return data.get(id) || null;
  42141. },
  42142. getByInternalId: function(internalId) {
  42143. var data = this.getData(),
  42144. keyCfg;
  42145. if (data.filtered) {
  42146. if (!data.$hasExtraKeys) {
  42147. keyCfg = this.makeInternalKeyCfg();
  42148. data.setExtraKeys(keyCfg);
  42149. data.$hasExtraKeys = true;
  42150. }
  42151. data = data.getSource();
  42152. }
  42153. if (!data.$hasExtraKeys) {
  42154. data.setExtraKeys(keyCfg || this.makeInternalKeyCfg());
  42155. data.$hasExtraKeys = true;
  42156. }
  42157. return data.byInternalId.get(internalId) || null;
  42158. },
  42159. getDataSource: function() {
  42160. var data = this.getData();
  42161. return data.getSource() || data;
  42162. },
  42163. indexOf: function(record) {
  42164. return this.getData().indexOf(record);
  42165. },
  42166. indexOfId: function(id) {
  42167. return this.indexOf(this.getById(id));
  42168. },
  42169. insert: function(index, records) {
  42170. var me = this,
  42171. len, i;
  42172. if (records) {
  42173. if (!Ext.isIterable(records)) {
  42174. records = [
  42175. records
  42176. ];
  42177. } else {
  42178. records = Ext.Array.clone(records);
  42179. }
  42180. len = records.length;
  42181. }
  42182. if (!len) {
  42183. return [];
  42184. }
  42185. for (i = 0; i < len; ++i) {
  42186. records[i] = me.createModel(records[i]);
  42187. }
  42188. me.getData().insert(index, records);
  42189. return records;
  42190. },
  42191. queryBy: function(fn, scope) {
  42192. var data = this.getData();
  42193. return (data.getSource() || data).createFiltered(fn, scope);
  42194. },
  42195. query: function(property, value, anyMatch, caseSensitive, exactMatch) {
  42196. var data = this.getData();
  42197. return (data.getSource() || data).createFiltered(property, value, anyMatch, caseSensitive, exactMatch);
  42198. },
  42199. first: function(grouped) {
  42200. return this.getData().first(grouped) || null;
  42201. },
  42202. last: function(grouped) {
  42203. return this.getData().last(grouped) || null;
  42204. },
  42205. sum: function(field, grouped) {
  42206. var data = this.getData();
  42207. return (grouped && this.isGrouped()) ? data.sumByGroup(field) : data.sum(field);
  42208. },
  42209. count: function(grouped) {
  42210. var data = this.getData();
  42211. return (grouped && this.isGrouped()) ? data.countByGroup() : data.count();
  42212. },
  42213. min: function(field, grouped) {
  42214. var data = this.getData();
  42215. return (grouped && this.isGrouped()) ? data.minByGroup(field) : data.min(field);
  42216. },
  42217. max: function(field, grouped) {
  42218. var data = this.getData();
  42219. return (grouped && this.isGrouped()) ? data.maxByGroup(field) : data.max(field);
  42220. },
  42221. average: function(field, grouped) {
  42222. var data = this.getData();
  42223. return (grouped && this.isGrouped()) ? data.averageByGroup(field) : data.average(field);
  42224. },
  42225. aggregate: function(fn, scope, grouped, field) {
  42226. var me = this,
  42227. groups, len, out, group, i;
  42228. if (grouped && me.isGrouped()) {
  42229. groups = me.getGroups().items;
  42230. len = groups.length;
  42231. out = {};
  42232. for (i = 0; i < len; ++i) {
  42233. group = groups[i];
  42234. out[group.getGroupKey()] = me.getAggregate(fn, scope || me, group.items, field);
  42235. }
  42236. return out;
  42237. } else {
  42238. return me.getAggregate(fn, scope, me.getData().items, field);
  42239. }
  42240. },
  42241. getAggregate: function(fn, scope, records, field) {
  42242. var values = [],
  42243. len = records.length,
  42244. i;
  42245. for (i = 0; i < len; ++i) {
  42246. values[i] = records[i].get(field);
  42247. }
  42248. return fn.call(scope || this, records, values);
  42249. },
  42250. addObserver: function(observer) {
  42251. var observers = this.observers;
  42252. if (!observers) {
  42253. this.observers = observers = new Ext.util.Collection();
  42254. }
  42255. observers.add(observer);
  42256. },
  42257. removeObserver: function(observer) {
  42258. var observers = this.observers;
  42259. if (observers) {
  42260. observers.remove(observer);
  42261. }
  42262. },
  42263. callObservers: function(action, args) {
  42264. var observers = this.observers,
  42265. len, items, i, methodName, item;
  42266. if (observers) {
  42267. items = observers.items;
  42268. if (args) {
  42269. args.unshift(this);
  42270. } else {
  42271. args = [
  42272. this
  42273. ];
  42274. }
  42275. for (i = 0 , len = items.length; i < len; ++i) {
  42276. item = items[i];
  42277. methodName = 'onSource' + action;
  42278. if (item[methodName]) {
  42279. item[methodName].apply(item, args);
  42280. }
  42281. }
  42282. }
  42283. },
  42284. queryRecordsBy: function(fn, scope) {
  42285. var data = this.getData(),
  42286. matches = [],
  42287. len, i, record;
  42288. data = (data.getSource() || data).items;
  42289. scope = scope || this;
  42290. for (i = 0 , len = data.length; i < len; ++i) {
  42291. record = data[i];
  42292. if (fn.call(scope, record) === true) {
  42293. matches.push(record);
  42294. }
  42295. }
  42296. return matches;
  42297. },
  42298. queryRecords: function(field, value) {
  42299. var data = this.getData(),
  42300. matches = [],
  42301. len, i, record;
  42302. data = (data.getSource() || data).items;
  42303. for (i = 0 , len = data.length; i < len; ++i) {
  42304. record = data[i];
  42305. if (record.get(field) === value) {
  42306. matches.push(record);
  42307. }
  42308. }
  42309. return matches;
  42310. },
  42311. privates: {
  42312. isLast: function(record) {
  42313. return record === this.last();
  42314. },
  42315. makeInternalKeyCfg: function() {
  42316. return {
  42317. byInternalId: {
  42318. property: 'internalId',
  42319. rootProperty: ''
  42320. }
  42321. };
  42322. }
  42323. }
  42324. });
  42325. Ext.define('Ext.data.proxy.Server', {
  42326. extend: Ext.data.proxy.Proxy,
  42327. alias: 'proxy.server',
  42328. alternateClassName: 'Ext.data.ServerProxy',
  42329. isRemote: true,
  42330. config: {
  42331. url: '',
  42332. pageParam: 'page',
  42333. startParam: 'start',
  42334. limitParam: 'limit',
  42335. groupParam: 'group',
  42336. groupDirectionParam: 'groupDir',
  42337. sortParam: 'sort',
  42338. filterParam: 'filter',
  42339. directionParam: 'dir',
  42340. idParam: 'id',
  42341. simpleSortMode: false,
  42342. simpleGroupMode: false,
  42343. noCache: true,
  42344. cacheString: "_dc",
  42345. timeout: 30000,
  42346. api: {
  42347. create: undefined,
  42348. read: undefined,
  42349. update: undefined,
  42350. destroy: undefined
  42351. },
  42352. extraParams: {}
  42353. },
  42354. create: function() {
  42355. return this.doRequest.apply(this, arguments);
  42356. },
  42357. read: function() {
  42358. return this.doRequest.apply(this, arguments);
  42359. },
  42360. update: function() {
  42361. return this.doRequest.apply(this, arguments);
  42362. },
  42363. erase: function() {
  42364. return this.doRequest.apply(this, arguments);
  42365. },
  42366. setExtraParam: function(name, value) {
  42367. var extraParams = this.getExtraParams();
  42368. extraParams[name] = value;
  42369. this.fireEvent('extraparamschanged', extraParams);
  42370. },
  42371. updateExtraParams: function(newExtraParams, oldExtraParams) {
  42372. this.fireEvent('extraparamschanged', newExtraParams);
  42373. },
  42374. buildRequest: function(operation) {
  42375. var me = this,
  42376. initialParams = Ext.apply({}, operation.getParams()),
  42377. params = Ext.applyIf(initialParams, me.getExtraParams() || {}),
  42378. request, operationId, idParam;
  42379. Ext.applyIf(params, me.getParams(operation));
  42380. operationId = operation.getId();
  42381. idParam = me.getIdParam();
  42382. if (operationId !== undefined && params[idParam] === undefined) {
  42383. params[idParam] = operationId;
  42384. }
  42385. request = new Ext.data.Request({
  42386. params: params,
  42387. action: operation.getAction(),
  42388. records: operation.getRecords(),
  42389. url: operation.getUrl(),
  42390. operation: operation,
  42391. proxy: me
  42392. });
  42393. request.setUrl(me.buildUrl(request));
  42394. operation.setRequest(request);
  42395. return request;
  42396. },
  42397. processResponse: function(success, operation, request, response) {
  42398. var me = this,
  42399. exception, reader, resultSet, meta, destroyOp;
  42400. if (me.destroying || me.destroyed) {
  42401. return;
  42402. }
  42403. me.fireEvent('beginprocessresponse', me, response, operation);
  42404. if (success === true) {
  42405. reader = me.getReader();
  42406. if (response.status === 204) {
  42407. resultSet = reader.getNullResultSet();
  42408. } else {
  42409. resultSet = reader.read(me.extractResponseData(response), {
  42410. recordCreator: operation.getRecordCreator() || reader.defaultRecordCreatorFromServer
  42411. });
  42412. }
  42413. if (!operation.$destroyOwner) {
  42414. operation.$destroyOwner = me;
  42415. destroyOp = true;
  42416. }
  42417. operation.process(resultSet, request, response);
  42418. exception = !operation.wasSuccessful();
  42419. } else {
  42420. me.setException(operation, response);
  42421. exception = true;
  42422. }
  42423. if (me.destroyed) {
  42424. if (!operation.destroyed && destroyOp && operation.$destroyOwner === me) {
  42425. operation.destroy();
  42426. }
  42427. return;
  42428. }
  42429. if (exception) {
  42430. me.fireEvent('exception', me, response, operation);
  42431. } else
  42432. {
  42433. meta = resultSet.getMetadata();
  42434. if (meta) {
  42435. me.onMetaChange(meta);
  42436. }
  42437. }
  42438. if (me.destroyed) {
  42439. if (!operation.destroyed && destroyOp && operation.$destroyOwner === me) {
  42440. operation.destroy();
  42441. }
  42442. return;
  42443. }
  42444. me.afterRequest(request, success);
  42445. me.fireEvent('endprocessresponse', me, response, operation);
  42446. if (!operation.destroyed && destroyOp && operation.$destroyOwner === me) {
  42447. operation.destroy();
  42448. }
  42449. },
  42450. setException: function(operation, response) {
  42451. operation.setException({
  42452. status: response.status,
  42453. statusText: response.statusText,
  42454. response: response
  42455. });
  42456. },
  42457. extractResponseData: Ext.identityFn,
  42458. applyEncoding: function(value) {
  42459. return Ext.encode(value);
  42460. },
  42461. encodeSorters: function(sorters, preventArray) {
  42462. var out = [],
  42463. length = sorters.length,
  42464. i;
  42465. for (i = 0; i < length; i++) {
  42466. out[i] = sorters[i].serialize();
  42467. }
  42468. return this.applyEncoding(preventArray ? out[0] : out);
  42469. },
  42470. encodeFilters: function(filters) {
  42471. var out = [],
  42472. length = filters.length,
  42473. encode, i;
  42474. for (i = 0; i < length; i++) {
  42475. encode |= filters[i].serializeTo(out);
  42476. }
  42477. return encode ? this.applyEncoding(out) : out;
  42478. },
  42479. getParams: function(operation) {
  42480. if (!operation.isReadOperation) {
  42481. return {};
  42482. }
  42483. var me = this,
  42484. params = {},
  42485. grouper = operation.getGrouper(),
  42486. sorters = operation.getSorters(),
  42487. filters = operation.getFilters(),
  42488. page = operation.getPage(),
  42489. start = operation.getStart(),
  42490. limit = operation.getLimit(),
  42491. simpleSortMode = me.getSimpleSortMode(),
  42492. simpleGroupMode = me.getSimpleGroupMode(),
  42493. pageParam = me.getPageParam(),
  42494. startParam = me.getStartParam(),
  42495. limitParam = me.getLimitParam(),
  42496. groupParam = me.getGroupParam(),
  42497. groupDirectionParam = me.getGroupDirectionParam(),
  42498. sortParam = me.getSortParam(),
  42499. filterParam = me.getFilterParam(),
  42500. directionParam = me.getDirectionParam(),
  42501. hasGroups, index;
  42502. if (pageParam && page) {
  42503. params[pageParam] = page;
  42504. }
  42505. if (startParam && (start || start === 0)) {
  42506. params[startParam] = start;
  42507. }
  42508. if (limitParam && limit) {
  42509. params[limitParam] = limit;
  42510. }
  42511. hasGroups = groupParam && grouper;
  42512. if (hasGroups) {
  42513. if (simpleGroupMode) {
  42514. params[groupParam] = grouper.getProperty();
  42515. if (groupDirectionParam === groupParam) {
  42516. params[groupParam] += ' ' + grouper.getDirection();
  42517. } else {
  42518. params[groupDirectionParam] = grouper.getDirection();
  42519. }
  42520. } else {
  42521. params[groupParam] = me.encodeSorters([
  42522. grouper
  42523. ], true);
  42524. }
  42525. }
  42526. if (sortParam && sorters && sorters.length > 0) {
  42527. if (simpleSortMode) {
  42528. for (index = (sorters.length > 1 && hasGroups) ? 1 : 0; index < sorters.length; index++) {
  42529. if (directionParam === sortParam) {
  42530. params[sortParam] = Ext.Array.push(params[sortParam] || [], sorters[index].getProperty() + ' ' + sorters[index].getDirection());
  42531. } else {
  42532. params[sortParam] = Ext.Array.push(params[sortParam] || [], sorters[index].getProperty());
  42533. params[directionParam] = Ext.Array.push(params[directionParam] || [], sorters[index].getDirection());
  42534. }
  42535. }
  42536. } else {
  42537. params[sortParam] = me.encodeSorters(sorters);
  42538. }
  42539. }
  42540. if (filterParam && filters && filters.length > 0) {
  42541. params[filterParam] = me.encodeFilters(filters);
  42542. }
  42543. return params;
  42544. },
  42545. buildUrl: function(request) {
  42546. var me = this,
  42547. url = me.getUrl(request);
  42548. if (!url) {
  42549. Ext.raise("You are using a ServerProxy but have not supplied it with a url.");
  42550. }
  42551. if (me.getNoCache()) {
  42552. url = Ext.urlAppend(url, Ext.String.format("{0}={1}", me.getCacheString(), Ext.Date.now()));
  42553. }
  42554. return url;
  42555. },
  42556. getUrl: function(request) {
  42557. var url;
  42558. if (request) {
  42559. url = request.getUrl() || this.getApi()[request.getAction()];
  42560. }
  42561. return url ? url : this.callParent();
  42562. },
  42563. doRequest: function(operation, callback, scope) {
  42564. Ext.raise("The doRequest function has not been implemented on your " + "Ext.data.proxy.Server subclass. See src/data/ServerProxy.js for details");
  42565. },
  42566. afterRequest: Ext.emptyFn,
  42567. destroy: function() {
  42568. var me = this;
  42569. me.destroying = true;
  42570. me.reader = me.writer = Ext.destroy(me.reader, me.writer);
  42571. me.callParent();
  42572. me.destroyed = true;
  42573. }
  42574. });
  42575. Ext.define('Ext.data.proxy.Ajax', {
  42576. extend: Ext.data.proxy.Server,
  42577. alias: 'proxy.ajax',
  42578. alternateClassName: [
  42579. 'Ext.data.HttpProxy',
  42580. 'Ext.data.AjaxProxy'
  42581. ],
  42582. isAjaxProxy: true,
  42583. defaultActionMethods: {
  42584. create: 'POST',
  42585. read: 'GET',
  42586. update: 'POST',
  42587. destroy: 'POST'
  42588. },
  42589. config: {
  42590. binary: false,
  42591. headers: undefined,
  42592. paramsAsJson: false,
  42593. withCredentials: false,
  42594. useDefaultXhrHeader: true,
  42595. username: null,
  42596. password: null,
  42597. actionMethods: {
  42598. create: 'POST',
  42599. read: 'GET',
  42600. update: 'POST',
  42601. destroy: 'POST'
  42602. }
  42603. },
  42604. doRequest: function(operation) {
  42605. var me = this,
  42606. writer = me.getWriter(),
  42607. request = me.buildRequest(operation),
  42608. method = me.getMethod(request),
  42609. jsonData, params;
  42610. if (writer && operation.allowWrite()) {
  42611. request = writer.write(request);
  42612. }
  42613. request.setConfig({
  42614. binary: me.getBinary(),
  42615. headers: me.getHeaders(),
  42616. timeout: me.getTimeout(),
  42617. scope: me,
  42618. callback: me.createRequestCallback(request, operation),
  42619. method: method,
  42620. useDefaultXhrHeader: me.getUseDefaultXhrHeader(),
  42621. disableCaching: false
  42622. });
  42623. if (me.responseType != null && Ext.supports.XHR2) {
  42624. request.setResponseType(me.responseType);
  42625. }
  42626. if (method.toUpperCase() !== 'GET' && me.getParamsAsJson()) {
  42627. params = request.getParams();
  42628. if (params) {
  42629. jsonData = request.getJsonData();
  42630. if (jsonData) {
  42631. jsonData = Ext.Object.merge({}, jsonData, params);
  42632. } else {
  42633. jsonData = params;
  42634. }
  42635. request.setJsonData(jsonData);
  42636. request.setParams(undefined);
  42637. }
  42638. }
  42639. if (me.getWithCredentials()) {
  42640. request.setWithCredentials(true);
  42641. request.setUsername(me.getUsername());
  42642. request.setPassword(me.getPassword());
  42643. }
  42644. return me.sendRequest(request);
  42645. },
  42646. sendRequest: function(request) {
  42647. request.setRawRequest(Ext.Ajax.request(request.getCurrentConfig()));
  42648. this.lastRequest = request;
  42649. return request;
  42650. },
  42651. abort: function(request) {
  42652. request = request || this.lastRequest;
  42653. if (request) {
  42654. Ext.Ajax.abort(request.getRawRequest());
  42655. }
  42656. },
  42657. getMethod: function(request) {
  42658. var actions = this.getActionMethods(),
  42659. action = request.getAction(),
  42660. method;
  42661. if (actions) {
  42662. method = actions[action];
  42663. }
  42664. return method || this.defaultActionMethods[action];
  42665. },
  42666. createRequestCallback: function(request, operation) {
  42667. return function(options, success, response) {
  42668. var me = this;
  42669. if (request === me.lastRequest) {
  42670. me.lastRequest = null;
  42671. }
  42672. if (!me.destroying && !me.destroyed) {
  42673. me.processResponse(success, operation, request, response);
  42674. }
  42675. };
  42676. },
  42677. destroy: function() {
  42678. this.lastRequest = null;
  42679. this.callParent();
  42680. }
  42681. });
  42682. Ext.define('Ext.data.reader.Json', {
  42683. extend: Ext.data.reader.Reader,
  42684. alternateClassName: 'Ext.data.JsonReader',
  42685. alias: 'reader.json',
  42686. config: {
  42687. record: null,
  42688. metaProperty: 'metaData',
  42689. useSimpleAccessors: false,
  42690. preserveRawData: false
  42691. },
  42692. responseType: 'json',
  42693. updateRootProperty: function() {
  42694. this.forceBuildExtractors();
  42695. },
  42696. updateMetaProperty: function() {
  42697. this.forceBuildExtractors();
  42698. },
  42699. getResponseData: function(response) {
  42700. var error;
  42701. if (typeof response.responseJson === 'object') {
  42702. return response.responseJson;
  42703. }
  42704. try {
  42705. return Ext.decode(response.responseText);
  42706. } catch (ex) {
  42707. error = this.createReadError(ex.message);
  42708. Ext.Logger.warn('Unable to parse the JSON returned by the server');
  42709. this.fireEvent('exception', this, response, error);
  42710. return error;
  42711. }
  42712. },
  42713. buildExtractors: function(force) {
  42714. var me = this,
  42715. emptyFn = Ext.emptyFn;
  42716. if (me.callParent([
  42717. force
  42718. ])) {
  42719. me.getRoot = me.setupExtractor(me.getRootProperty(), Ext.identityFn);
  42720. me.getGroupRoot = me.setupExtractor(me.getGroupRootProperty(), emptyFn);
  42721. me.getSummaryRoot = me.setupExtractor(me.getSummaryRootProperty(), emptyFn);
  42722. me.getMeta = me.setupExtractor(me.getMetaProperty(), emptyFn);
  42723. }
  42724. },
  42725. extractData: function(root, readOptions) {
  42726. var recordName = this.getRecord(),
  42727. data = [],
  42728. length, i;
  42729. if (recordName) {
  42730. length = root.length;
  42731. if (!length && Ext.isObject(root)) {
  42732. length = 1;
  42733. root = [
  42734. root
  42735. ];
  42736. }
  42737. for (i = 0; i < length; i++) {
  42738. data[i] = root[i][recordName];
  42739. }
  42740. } else {
  42741. data = root;
  42742. }
  42743. return this.callParent([
  42744. data,
  42745. readOptions
  42746. ]);
  42747. },
  42748. getModelData: function(raw) {
  42749. return this.getPreserveRawData() ? Ext.apply({}, raw) : raw;
  42750. },
  42751. createAccessor: (function() {
  42752. var re = /[\[\.]/;
  42753. return function(expr) {
  42754. var simple = this.getUseSimpleAccessors(),
  42755. operatorIndex, result, current, parts, part, inExpr, isDot, isLeft, isRight, special, c, i, bracketed, len;
  42756. if (!(expr || expr === 0)) {
  42757. return;
  42758. }
  42759. if (typeof expr === 'function') {
  42760. return expr;
  42761. }
  42762. if (!simple) {
  42763. operatorIndex = String(expr).search(re);
  42764. }
  42765. if (simple === true || operatorIndex < 0) {
  42766. result = function(raw) {
  42767. return raw == null ? null : raw[expr];
  42768. };
  42769. } else {
  42770. current = 'raw';
  42771. parts = [];
  42772. part = '';
  42773. inExpr = 0;
  42774. len = expr.length;
  42775. for (i = 0; i <= len; ++i) {
  42776. c = expr[i];
  42777. isDot = c === '.';
  42778. isLeft = c === '[';
  42779. isRight = c === ']';
  42780. special = isDot || isLeft || isRight || !c;
  42781. if (!special || inExpr > 1 || (inExpr && !isRight)) {
  42782. part += c;
  42783. } else if (special) {
  42784. bracketed = false;
  42785. if (isLeft) {
  42786. ++inExpr;
  42787. } else if (isRight) {
  42788. --inExpr;
  42789. bracketed = true;
  42790. }
  42791. if (part) {
  42792. if (bracketed) {
  42793. part = '[' + part + ']';
  42794. } else {
  42795. part = '.' + part;
  42796. }
  42797. current += part;
  42798. parts.push('' + current);
  42799. part = '';
  42800. }
  42801. }
  42802. }
  42803. result = parts.join(' && ');
  42804. result = Ext.functionFactory('raw', 'return ' + result);
  42805. }
  42806. return result;
  42807. };
  42808. }()),
  42809. createFieldAccessor: function(field) {
  42810. var me = this,
  42811. mapping = field.mapping,
  42812. hasMap = mapping || mapping === 0,
  42813. map = hasMap ? mapping : field.name;
  42814. if (hasMap) {
  42815. if (typeof map === 'function') {
  42816. return function(raw, self) {
  42817. return field.mapping(raw, self);
  42818. };
  42819. } else {
  42820. return me.createAccessor(map);
  42821. }
  42822. }
  42823. },
  42824. getAccessorKey: function(prop) {
  42825. var simple = this.getUseSimpleAccessors() ? 'simple' : '';
  42826. return this.callParent([
  42827. simple + prop
  42828. ]);
  42829. },
  42830. privates: {
  42831. copyFrom: function(reader) {
  42832. this.callParent([
  42833. reader
  42834. ]);
  42835. this.getRoot = reader.getRoot;
  42836. },
  42837. setupExtractor: function(prop, defaultFn) {
  42838. return prop ? this.getAccessor(prop) : defaultFn;
  42839. }
  42840. }
  42841. });
  42842. Ext.define('Ext.data.writer.Json', {
  42843. extend: Ext.data.writer.Writer,
  42844. alternateClassName: 'Ext.data.JsonWriter',
  42845. alias: 'writer.json',
  42846. config: {
  42847. rootProperty: undefined,
  42848. encode: false,
  42849. allowSingle: true,
  42850. expandData: false
  42851. },
  42852. constructor: function(config) {
  42853. if (config && config.hasOwnProperty('root')) {
  42854. config = Ext.apply({}, config);
  42855. config.rootProperty = config.root;
  42856. delete config.root;
  42857. Ext.log.warn('Ext.data.writer.Json: Using the deprecated "root" configuration. ' + 'Use "rootProperty" instead.');
  42858. }
  42859. this.callParent([
  42860. config
  42861. ]);
  42862. },
  42863. getExpandedData: function(data) {
  42864. var dataLength = data.length,
  42865. i = 0,
  42866. item, prop, nameParts, j, tempObj, toObject;
  42867. toObject = function(name, value) {
  42868. var o = {};
  42869. o[name] = value;
  42870. return o;
  42871. };
  42872. for (; i < dataLength; i++) {
  42873. item = data[i];
  42874. for (prop in item) {
  42875. if (item.hasOwnProperty(prop)) {
  42876. nameParts = prop.split('.');
  42877. j = nameParts.length - 1;
  42878. if (j > 0) {
  42879. tempObj = item[prop];
  42880. for (; j > 0; j--) {
  42881. tempObj = toObject(nameParts[j], tempObj);
  42882. }
  42883. item[nameParts[0]] = item[nameParts[0]] || {};
  42884. Ext.Object.merge(item[nameParts[0]], tempObj);
  42885. delete item[prop];
  42886. }
  42887. }
  42888. }
  42889. }
  42890. return data;
  42891. },
  42892. writeRecords: function(request, data) {
  42893. var me = this,
  42894. root = me.getRootProperty(),
  42895. json, single, transform;
  42896. if (me.getExpandData()) {
  42897. data = me.getExpandedData(data);
  42898. }
  42899. if (me.getAllowSingle() && data.length === 1) {
  42900. data = data[0];
  42901. single = true;
  42902. }
  42903. transform = this.getTransform();
  42904. if (transform) {
  42905. data = transform(data, request);
  42906. }
  42907. if (me.getEncode()) {
  42908. if (root) {
  42909. request.setParam(root, Ext.encode(data));
  42910. } else {
  42911. Ext.raise('Must specify a root when using encode');
  42912. }
  42913. }
  42914. else if (single || (data && data.length)) {
  42915. json = request.getJsonData() || {};
  42916. if (root) {
  42917. json[root] = data;
  42918. } else {
  42919. json = data;
  42920. }
  42921. request.setJsonData(json);
  42922. }
  42923. return request;
  42924. }
  42925. });
  42926. Ext.define('Ext.util.SorterCollection', {
  42927. extend: Ext.util.Collection,
  42928. isSorterCollection: true,
  42929. $sortable: null,
  42930. sortFn: null,
  42931. config: {
  42932. sorterOptionsFn: null,
  42933. sorterOptionsScope: null
  42934. },
  42935. constructor: function(config) {
  42936. var me = this;
  42937. me.sortFn = Ext.util.Sorter.createComparator(me);
  42938. me.callParent([
  42939. config
  42940. ]);
  42941. me.setDecoder(me.decodeSorter);
  42942. },
  42943. addSort: function(property, direction, mode) {
  42944. var me = this,
  42945. count, index, limit, options, primary, sorter, sorters;
  42946. if (!property) {
  42947. me.beginUpdate();
  42948. me.endUpdate();
  42949. } else {
  42950. options = me.getOptions();
  42951. if (property instanceof Array) {
  42952. sorters = property;
  42953. mode = direction;
  42954. direction = null;
  42955. } else if (Ext.isString(property)) {
  42956. if (!(sorter = me.get(property))) {
  42957. sorters = [
  42958. {
  42959. property: property,
  42960. direction: direction || options.getDefaultSortDirection()
  42961. }
  42962. ];
  42963. } else {
  42964. sorters = [
  42965. sorter
  42966. ];
  42967. }
  42968. } else if (Ext.isFunction(property)) {
  42969. sorters = [
  42970. {
  42971. sorterFn: property,
  42972. direction: direction || options.getDefaultSortDirection()
  42973. }
  42974. ];
  42975. } else {
  42976. if (!Ext.isObject(property)) {
  42977. Ext.raise('Invalid sort descriptor: ' + property);
  42978. }
  42979. sorters = [
  42980. property
  42981. ];
  42982. mode = direction;
  42983. direction = null;
  42984. }
  42985. if (mode && !me._sortModes[mode]) {
  42986. Ext.raise('Sort mode should be "multi", "append", "prepend" or "replace", not "' + mode + '"');
  42987. }
  42988. mode = me._sortModes[mode || 'replace'];
  42989. primary = me.getAt(0);
  42990. count = me.length;
  42991. index = mode.append ? count : 0;
  42992. me.beginUpdate();
  42993. me.splice(index, mode.replace ? count : 0, sorters);
  42994. if (mode.multi) {
  42995. count = me.length;
  42996. limit = options.getMultiSortLimit();
  42997. if (count > limit) {
  42998. me.removeAt(limit, count);
  42999. }
  43000. }
  43001. if (sorter && direction) {
  43002. sorter.setDirection(direction);
  43003. } else if (index === 0 && primary && primary === me.getAt(0)) {
  43004. primary.toggle();
  43005. }
  43006. me.endUpdate();
  43007. }
  43008. },
  43009. clear: function() {
  43010. this.beginUpdate();
  43011. this.callParent();
  43012. this.endUpdate(this.items);
  43013. },
  43014. getSortFn: function() {
  43015. return this.sortFn;
  43016. },
  43017. getByProperty: function(prop) {
  43018. var items = this.items,
  43019. len = items.length,
  43020. i, item;
  43021. for (i = 0; i < len; ++i) {
  43022. item = items[i];
  43023. if (item.getProperty() === prop) {
  43024. return item;
  43025. }
  43026. }
  43027. return null;
  43028. },
  43029. _sortModes: {
  43030. append: {
  43031. append: 1
  43032. },
  43033. multi: {
  43034. multi: 1
  43035. },
  43036. prepend: {
  43037. prepend: 1
  43038. },
  43039. replace: {
  43040. replace: 1
  43041. }
  43042. },
  43043. decodeSorter: function(sorter, xclass) {
  43044. var me = this,
  43045. options = me.getOptions(),
  43046. root = options.getRootProperty(),
  43047. sorterOptionsFn = me.getSorterOptionsFn(),
  43048. currentSorter, sorterConfig, type;
  43049. if (sorter.isSorter) {
  43050. if (!sorter.getRoot()) {
  43051. sorter.setRoot(root);
  43052. }
  43053. } else {
  43054. sorterConfig = {
  43055. direction: options.getDefaultSortDirection(),
  43056. root: root
  43057. };
  43058. type = typeof sorter;
  43059. if (type === 'string') {
  43060. currentSorter = me.get(sorter);
  43061. if (currentSorter) {
  43062. return currentSorter;
  43063. }
  43064. sorterConfig.property = sorter;
  43065. }
  43066. else if (type === 'function') {
  43067. sorterConfig.sorterFn = sorter;
  43068. } else
  43069. {
  43070. if (!Ext.isObject(sorter)) {
  43071. Ext.raise('Invalid sorter specified: ' + sorter);
  43072. }
  43073. sorterConfig = Ext.apply(sorterConfig, sorter);
  43074. if (sorterConfig.fn) {
  43075. sorterConfig.sorterFn = sorterConfig.fn;
  43076. delete sorterConfig.fn;
  43077. }
  43078. }
  43079. sorter = Ext.create(xclass || Ext.util.Sorter, sorterConfig);
  43080. }
  43081. if (sorterOptionsFn) {
  43082. sorterOptionsFn.call(me.getSorterOptionsScope() || me, sorter);
  43083. }
  43084. return sorter;
  43085. },
  43086. setSorterConfigure: function(fn, scope) {
  43087. this.setSorterOptionsFn(fn);
  43088. this.setSorterOptionsScope(scope);
  43089. },
  43090. decodeRemoveItems: function(args, index) {
  43091. var me = this,
  43092. ret = (index === undefined) ? args : args[index];
  43093. if (!ret || !ret.$cloned) {
  43094. if (args.length > index + 1 || !Ext.isIterable(ret)) {
  43095. ret = Ext.Array.slice(args, index);
  43096. }
  43097. var currentSorters = me.items,
  43098. ln = ret.length,
  43099. remove = [],
  43100. i, item, n, sorter, type;
  43101. for (i = 0; i < ln; i++) {
  43102. sorter = ret[i];
  43103. if (sorter && sorter.isSorter) {
  43104. remove.push(sorter);
  43105. } else {
  43106. type = typeof sorter;
  43107. if (type === 'string') {
  43108. sorter = me.get(sorter);
  43109. if (sorter) {
  43110. remove.push(sorter);
  43111. }
  43112. } else if (type === 'function') {
  43113. for (n = currentSorters.length; n-- > 0; ) {
  43114. item = currentSorters[n];
  43115. if (item.getSorterFn() === sorter) {
  43116. remove.push(item);
  43117. }
  43118. }
  43119. } else
  43120. {
  43121. Ext.raise('Invalid sorter specification: ' + sorter);
  43122. }
  43123. }
  43124. }
  43125. ret = remove;
  43126. ret.$cloned = true;
  43127. }
  43128. return ret;
  43129. },
  43130. getOptions: function() {
  43131. return this.$sortable || this;
  43132. }
  43133. });
  43134. Ext.define('Ext.util.FilterCollection', {
  43135. extend: Ext.util.Collection,
  43136. isFilterCollection: true,
  43137. $filterable: null,
  43138. filterFn: null,
  43139. constructor: function(config) {
  43140. var me = this;
  43141. me.filterFn = Ext.util.Filter.createFilterFn(me);
  43142. me.callParent([
  43143. config
  43144. ]);
  43145. me.setDecoder(me.decodeFilter);
  43146. },
  43147. filterData: function(data) {
  43148. return this.filtered ? Ext.Array.filter(data, this.filterFn) : data;
  43149. },
  43150. getFilterFn: function() {
  43151. return this.filterFn;
  43152. },
  43153. isItemFiltered: function(item) {
  43154. return !this.filterFn(item);
  43155. },
  43156. getFilterCount: function() {
  43157. var filters = this.items,
  43158. len = filters.length,
  43159. i;
  43160. for (i = len - 1; i >= 0; i--) {
  43161. if (filters[i].getDisabled()) {
  43162. len--;
  43163. }
  43164. }
  43165. return len;
  43166. },
  43167. decodeFilter: function(filter) {
  43168. var options = this.getOptions(),
  43169. filterRoot = options.getRootProperty(),
  43170. filterConfig;
  43171. if (filter.isFilter) {
  43172. if (filter.setRoot && !filter.getRoot()) {
  43173. filter.setRoot(filterRoot);
  43174. }
  43175. } else {
  43176. filterConfig = {
  43177. root: filterRoot
  43178. };
  43179. if (Ext.isFunction(filter)) {
  43180. filterConfig.filterFn = filter;
  43181. } else
  43182. {
  43183. if (!Ext.isObject(filter)) {
  43184. Ext.raise('Invalid filter specified: ' + filter);
  43185. }
  43186. filterConfig = Ext.apply(filterConfig, filter);
  43187. if (filterConfig.fn) {
  43188. filterConfig.filterFn = filterConfig.fn;
  43189. delete filterConfig.fn;
  43190. }
  43191. if (Ext.util.Filter.isInvalid(filterConfig)) {
  43192. return false;
  43193. }
  43194. }
  43195. filter = new Ext.util.Filter(filterConfig);
  43196. }
  43197. return filter;
  43198. },
  43199. decodeRemoveItems: function(args, index) {
  43200. var me = this,
  43201. ret = (index === undefined) ? args : args[index];
  43202. if (!ret.$cloned) {
  43203. if (args.length > index + 1 || !Ext.isIterable(ret)) {
  43204. ret = Ext.Array.slice(args, index);
  43205. }
  43206. var currentFilters = me.items,
  43207. ln = ret.length,
  43208. remove = [],
  43209. filter, i, isFunction, isProp, isString, item, match, n, type;
  43210. for (i = 0; i < ln; i++) {
  43211. filter = ret[i];
  43212. if (filter && filter.isFilter) {
  43213. remove.push(filter);
  43214. } else {
  43215. type = typeof filter;
  43216. isFunction = type === 'function';
  43217. isProp = filter.property !== undefined && filter.value !== undefined;
  43218. isString = type === 'string';
  43219. if (!isFunction && !isProp && !isString) {
  43220. Ext.raise('Invalid filter specification: ' + filter);
  43221. }
  43222. for (n = currentFilters.length; n-- > 0; ) {
  43223. item = currentFilters[n];
  43224. match = false;
  43225. if (isString) {
  43226. match = item.getProperty() === filter;
  43227. } else if (isFunction) {
  43228. match = item.getFilterFn() === filter;
  43229. } else if (isProp) {
  43230. match = item.getProperty() === filter.property && item.getValue() === filter.value;
  43231. }
  43232. if (match) {
  43233. remove.push(item);
  43234. }
  43235. }
  43236. }
  43237. }
  43238. ret = remove;
  43239. ret.$cloned = true;
  43240. }
  43241. return ret;
  43242. },
  43243. getOptions: function() {
  43244. return this.$filterable || this;
  43245. }
  43246. });
  43247. Ext.define('Ext.util.GroupCollection', {
  43248. extend: Ext.util.Collection,
  43249. isGroupCollection: true,
  43250. config: {
  43251. grouper: null,
  43252. groupConfig: null,
  43253. itemRoot: null
  43254. },
  43255. observerPriority: -100,
  43256. emptyGroupRetainTime: 300000,
  43257. constructor: function(config) {
  43258. this.emptyGroups = {};
  43259. this.callParent([
  43260. config
  43261. ]);
  43262. this.on('remove', 'onGroupRemove', this);
  43263. },
  43264. getItemGroup: function(item) {
  43265. var key = this.getGrouper().getGroupString(item);
  43266. return this.get(key);
  43267. },
  43268. onCollectionAdd: function(source, details) {
  43269. if (!this.isConfiguring) {
  43270. this.addItemsToGroups(source, details.items, details.at);
  43271. }
  43272. },
  43273. onCollectionBeforeItemChange: function(source, details) {
  43274. this.changeDetails = details;
  43275. },
  43276. onCollectionBeginUpdate: function() {
  43277. this.beginUpdate();
  43278. },
  43279. onCollectionEndUpdate: function() {
  43280. this.endUpdate();
  43281. },
  43282. onCollectionItemChange: function(source, details) {
  43283. if (!details.indexChanged) {
  43284. this.syncItemGrouping(source, details);
  43285. }
  43286. this.changeDetails = null;
  43287. },
  43288. onCollectionRefresh: function(source) {
  43289. if (source.generation) {
  43290. var me = this,
  43291. itemGroupKeys = me.itemGroupKeys = {},
  43292. groupData = me.createEntries(source, source.items),
  43293. entries = groupData.entries,
  43294. groupKey, i, len, entry, j;
  43295. for (i = 0 , len = entries.length; i < len; ++i) {
  43296. entry = entries[i];
  43297. entry.group.splice(0, 1.0E99, entry.items);
  43298. for (j = 0; j < entry.items.length; j++) {
  43299. itemGroupKeys[source.getKey(entry.items[j])] = entry.group;
  43300. }
  43301. }
  43302. entries = null;
  43303. for (groupKey in me.map) {
  43304. if (!(groupKey in groupData.groups)) {
  43305. (entries || (entries = [])).push(me.map[groupKey]);
  43306. }
  43307. }
  43308. if (entries) {
  43309. me.remove(entries);
  43310. }
  43311. me.sortItems();
  43312. }
  43313. },
  43314. onCollectionRemove: function(source, details) {
  43315. var me = this,
  43316. changeDetails = me.changeDetails,
  43317. itemGroupKeys = me.itemGroupKeys || (me.itemGroupKeys = {}),
  43318. entries, entry, group, i, n, j, removeGroups, item;
  43319. if (source.getCount()) {
  43320. if (changeDetails) {
  43321. item = changeDetails.item || changeDetails.items[0];
  43322. entries = me.createEntries(source, [
  43323. item
  43324. ], false).entries;
  43325. entries[0].group = itemGroupKeys['oldKey' in details ? details.oldKey : source.getKey(item)];
  43326. } else {
  43327. entries = me.createEntries(source, details.items, false).entries;
  43328. }
  43329. for (i = 0 , n = entries.length; i < n; ++i) {
  43330. group = (entry = entries[i]).group;
  43331. if (group) {
  43332. group.remove(entry.items);
  43333. }
  43334. for (j = 0; j < entry.items.length; j++) {
  43335. delete itemGroupKeys[source.getKey(entry.items[j])];
  43336. }
  43337. if (group && !group.length) {
  43338. (removeGroups || (removeGroups = [])).push(group);
  43339. }
  43340. }
  43341. } else
  43342. {
  43343. me.itemGroupKeys = {};
  43344. removeGroups = me.items;
  43345. for (i = 0 , n = removeGroups.length; i < n; ++i) {
  43346. removeGroups[i].clear();
  43347. }
  43348. }
  43349. if (removeGroups) {
  43350. me.remove(removeGroups);
  43351. }
  43352. },
  43353. onCollectionSort: function(source) {
  43354. var me = this,
  43355. sorters = source.getSorters(false),
  43356. items, length, i, group;
  43357. if (sorters) {
  43358. items = me.items;
  43359. length = me.length;
  43360. for (i = 0; i < length; ++i) {
  43361. group = items[i];
  43362. if (group.getSorters() === sorters) {
  43363. group.sortItems();
  43364. } else {
  43365. group.setSorters(sorters);
  43366. }
  43367. }
  43368. }
  43369. },
  43370. onCollectionUpdateKey: function(source, details) {
  43371. if (!details.indexChanged) {
  43372. details.oldIndex = source.indexOf(details.item);
  43373. this.syncItemGrouping(source, details);
  43374. }
  43375. },
  43376. addItemsToGroups: function(source, items, at, oldIndex) {
  43377. var me = this,
  43378. itemGroupKeys = me.itemGroupKeys || (me.itemGroupKeys = {}),
  43379. entries = me.createEntries(source, items).entries,
  43380. index = -1,
  43381. sourceStartIndex, entry, i, len, j, group, firstIndex, item;
  43382. for (i = 0 , len = entries.length; i < len; ++i) {
  43383. entry = entries[i];
  43384. group = entry.group;
  43385. if (oldIndex || oldIndex === 0) {
  43386. item = items[0];
  43387. if (group.getCount() > 0 && source.getSorters().getCount() === 0) {
  43388. firstIndex = source.indexOf(group.items[0]);
  43389. if (oldIndex < firstIndex) {
  43390. index = 0;
  43391. } else {
  43392. index = oldIndex - firstIndex;
  43393. }
  43394. }
  43395. if (index === -1) {
  43396. group.add(item);
  43397. } else {
  43398. group.insert(index, item);
  43399. }
  43400. } else {
  43401. if (me.length > 1 && at) {
  43402. sourceStartIndex = source.indexOf(entries[0].group.getAt(0));
  43403. at = Math.max(at - sourceStartIndex, 0);
  43404. }
  43405. entry.group.insert(at != null ? at : group.items.length, entry.items);
  43406. for (j = 0; j < entry.items.length; j++) {
  43407. itemGroupKeys[source.getKey(entry.items[j])] = entry.group;
  43408. }
  43409. }
  43410. }
  43411. me.sortItems();
  43412. },
  43413. createEntries: function(source, items, createGroups) {
  43414. var me = this,
  43415. groups = {},
  43416. entries = [],
  43417. grouper = me.getGrouper(),
  43418. entry, group, groupKey, i, item, len;
  43419. for (i = 0 , len = items.length; i < len; ++i) {
  43420. groupKey = grouper.getGroupString(item = items[i]);
  43421. if (!(entry = groups[groupKey])) {
  43422. group = me.getGroup(source, groupKey, createGroups);
  43423. entries.push(groups[groupKey] = entry = {
  43424. group: group,
  43425. items: []
  43426. });
  43427. }
  43428. entry.items.push(item);
  43429. }
  43430. return {
  43431. groups: groups,
  43432. entries: entries
  43433. };
  43434. },
  43435. syncItemGrouping: function(source, details) {
  43436. var me = this,
  43437. itemGroupKeys = me.itemGroupKeys || (me.itemGroupKeys = {}),
  43438. item = details.item,
  43439. oldKey, itemKey, oldGroup, group;
  43440. itemKey = source.getKey(item);
  43441. oldKey = 'oldKey' in details ? details.oldKey : itemKey;
  43442. oldGroup = itemGroupKeys[oldKey];
  43443. group = me.getGroup(source, me.getGrouper().getGroupString(item));
  43444. details.group = group;
  43445. details.oldGroup = oldGroup;
  43446. if (!(details.groupChanged = group !== oldGroup)) {
  43447. oldGroup.itemChanged(item, details.modified, details.oldKey, details);
  43448. } else {
  43449. if (oldGroup) {
  43450. oldGroup.updateKey(item, oldKey, itemKey);
  43451. oldGroup.remove(item);
  43452. if (!oldGroup.length) {
  43453. me.remove(oldGroup);
  43454. }
  43455. }
  43456. me.addItemsToGroups(source, [
  43457. item
  43458. ], null, details.oldIndex);
  43459. }
  43460. delete itemGroupKeys[oldKey];
  43461. itemGroupKeys[itemKey] = group;
  43462. },
  43463. getGroup: function(source, key, createGroups) {
  43464. var me = this,
  43465. group = me.get(key),
  43466. autoSort = me.getAutoSort();
  43467. if (group) {
  43468. group.setSorters(source.getSorters());
  43469. } else if (createGroups !== false) {
  43470. group = me.emptyGroups[key] || Ext.create(Ext.apply({
  43471. xclass: 'Ext.util.Group',
  43472. id: me.getId() + '-group-' + key,
  43473. groupKey: key,
  43474. rootProperty: me.getItemRoot(),
  43475. sorters: source.getSorters()
  43476. }, me.getGroupConfig()));
  43477. group.ejectTime = null;
  43478. me.setAutoSort(false);
  43479. me.add(group);
  43480. me.setAutoSort(autoSort);
  43481. }
  43482. return group;
  43483. },
  43484. getKey: function(item) {
  43485. return item.getGroupKey();
  43486. },
  43487. createSortFn: function() {
  43488. var me = this,
  43489. grouper = me.getGrouper(),
  43490. sorterFn = me.getSorters().getSortFn();
  43491. if (!grouper) {
  43492. return sorterFn;
  43493. }
  43494. return function(lhs, rhs) {
  43495. return grouper.sort(lhs.items[0], rhs.items[0]) || sorterFn(lhs, rhs);
  43496. };
  43497. },
  43498. updateGrouper: function(grouper) {
  43499. var me = this;
  43500. me.grouped = !!(grouper && me.$groupable.getAutoGroup());
  43501. me.onSorterChange();
  43502. me.onEndUpdateSorters(me.getSorters());
  43503. },
  43504. destroy: function() {
  43505. var me = this;
  43506. me.$groupable = null;
  43507. me.destroyGroups(me.items);
  43508. Ext.undefer(me.checkRemoveQueueTimer);
  43509. me.callParent();
  43510. },
  43511. privates: {
  43512. destroyGroups: function(groups) {
  43513. var len = groups.length,
  43514. i;
  43515. for (i = 0; i < len; ++i) {
  43516. groups[i].destroy();
  43517. }
  43518. },
  43519. onGroupRemove: function(collection, info) {
  43520. var me = this,
  43521. groups = info.items,
  43522. emptyGroups = me.emptyGroups,
  43523. len, group, i;
  43524. groups = Ext.Array.from(groups);
  43525. for (i = 0 , len = groups.length; i < len; i++) {
  43526. group = groups[i];
  43527. group.setSorters(null);
  43528. emptyGroups[group.getGroupKey()] = group;
  43529. group.ejectTime = Ext.now();
  43530. }
  43531. me.checkRemoveQueue();
  43532. },
  43533. checkRemoveQueue: function() {
  43534. var me = this,
  43535. emptyGroups = me.emptyGroups,
  43536. groupKey, group, reschedule;
  43537. for (groupKey in emptyGroups) {
  43538. group = emptyGroups[groupKey];
  43539. if (!group.getCount() && Ext.now() - group.ejectTime > me.emptyGroupRetainTime) {
  43540. Ext.destroy(group);
  43541. delete emptyGroups[groupKey];
  43542. } else {
  43543. reschedule = true;
  43544. }
  43545. }
  43546. if (reschedule) {
  43547. Ext.undefer(me.checkRemoveQueueTimer);
  43548. me.checkRemoveQueueTimer = Ext.defer(me.checkRemoveQueue, me.emptyGroupRetainTime, me);
  43549. }
  43550. }
  43551. }
  43552. });
  43553. Ext.define('Ext.data.Store', {
  43554. extend: Ext.data.ProxyStore,
  43555. alias: 'store.store',
  43556. mixins: [
  43557. Ext.data.LocalStore
  43558. ],
  43559. config: {
  43560. data: undefined,
  43561. clearRemovedOnLoad: true,
  43562. clearOnPageLoad: true,
  43563. associatedEntity: null,
  43564. role: null,
  43565. session: null
  43566. },
  43567. addRecordsOptions: {
  43568. addRecords: true
  43569. },
  43570. loadCount: 0,
  43571. complete: false,
  43572. moveMapCount: 0,
  43573. constructor: function(config) {
  43574. var me = this,
  43575. data;
  43576. if (config) {
  43577. if (config.buffered) {
  43578. if (this.self !== Ext.data.Store) {
  43579. Ext.raise('buffered config not supported on derived Store classes. ' + 'Please derive from Ext.data.BufferedStore.');
  43580. }
  43581. return new Ext.data['BufferedStore'](config);
  43582. }
  43583. if (config.remoteGroup) {
  43584. Ext.log.warn('Ext.data.Store: remoteGroup has been removed. ' + 'Use remoteSort instead.');
  43585. }
  43586. }
  43587. me.callParent([
  43588. config
  43589. ]);
  43590. data = me.inlineData;
  43591. if (data) {
  43592. delete me.inlineData;
  43593. me.loadInlineData(data);
  43594. }
  43595. },
  43596. applyData: function(data, dataCollection) {
  43597. var me = this;
  43598. me.getFields();
  43599. me.getModel();
  43600. if (data && data.isCollection) {
  43601. data.setRootProperty('data');
  43602. dataCollection = data;
  43603. dataCollection.addObserver(this);
  43604. if (data.getCount()) {
  43605. me.afterLoadRecords(data.items);
  43606. if (me.hasListeners.load) {
  43607. me.fireEvent('load', me, data.items, true);
  43608. }
  43609. }
  43610. } else {
  43611. if (!dataCollection) {
  43612. dataCollection = me.constructDataCollection();
  43613. }
  43614. if (data) {
  43615. if (me.isInitializing) {
  43616. me.inlineData = data;
  43617. } else {
  43618. me.loadData(data);
  43619. }
  43620. }
  43621. }
  43622. return dataCollection;
  43623. },
  43624. loadInlineData: function(data) {
  43625. var me = this,
  43626. proxy = me.getProxy();
  43627. if (proxy && proxy.isMemoryProxy) {
  43628. proxy.setData(data);
  43629. me.suspendEvents();
  43630. me.read();
  43631. me.resumeEvents();
  43632. } else {
  43633. me.removeAll(true);
  43634. me.suspendEvents();
  43635. me.loadData(data);
  43636. me.resumeEvents();
  43637. }
  43638. },
  43639. onCollectionAdd: function(collection, info) {
  43640. this.loadCount = this.loadCount || 1;
  43641. this.onCollectionAddItems(collection, info.items, info);
  43642. },
  43643. onCollectionFilterAdd: function(collection, items) {
  43644. this.onCollectionAddItems(collection, items);
  43645. },
  43646. onCollectionAddItems: function(collection, records, info) {
  43647. var me = this,
  43648. len = records.length,
  43649. lastChunk = info ? !info.next : false,
  43650. removed = me.removed,
  43651. ignoreAdd = me.ignoreCollectionAdd,
  43652. session = me.getSession(),
  43653. replaced = info && info.replaced,
  43654. i, sync, record, replacedItems;
  43655. if (me.activeRanges) {
  43656. me.syncActiveRanges();
  43657. }
  43658. for (i = 0; i < len; ++i) {
  43659. record = records[i];
  43660. if (session) {
  43661. session.adopt(record);
  43662. }
  43663. if (!ignoreAdd) {
  43664. record.join(me);
  43665. if (removed && removed.length) {
  43666. Ext.Array.remove(removed, record);
  43667. }
  43668. sync = sync || record.phantom || record.dirty;
  43669. }
  43670. }
  43671. if (ignoreAdd) {
  43672. return;
  43673. }
  43674. if (replaced) {
  43675. replacedItems = [];
  43676. do {
  43677. Ext.Array.push(replacedItems, replaced.items);
  43678. replaced = replaced.next;
  43679. } while (replaced);
  43680. me.setMoving(replacedItems, true);
  43681. }
  43682. if (info) {
  43683. if (info.replaced) {
  43684. if (lastChunk) {
  43685. me.fireEvent('datachanged', me);
  43686. me.fireEvent('refresh', me);
  43687. }
  43688. } else {
  43689. me.fireEvent('add', me, records, info.at);
  43690. if (lastChunk) {
  43691. me.fireEvent('datachanged', me);
  43692. }
  43693. }
  43694. }
  43695. if (replacedItems) {
  43696. me.setMoving(replacedItems, false);
  43697. }
  43698. me.needsSync = me.needsSync || sync;
  43699. },
  43700. onCollectionBeforeItemChange: function(collection, info) {
  43701. var record = info.item,
  43702. modifiedFieldNames = info.modified || null,
  43703. type = info.meta;
  43704. this.fireEvent('beforeupdate', this, record, type, modifiedFieldNames, info);
  43705. },
  43706. onCollectionFilteredItemChange: function() {
  43707. this.onCollectionItemChange.apply(this, arguments);
  43708. },
  43709. onCollectionItemChange: function(collection, info) {
  43710. var me = this,
  43711. record = info.item,
  43712. modifiedFieldNames = info.modified || null,
  43713. type = info.meta;
  43714. if (me.fireChangeEvent(record)) {
  43715. me.onUpdate(record, type, modifiedFieldNames, info);
  43716. me.fireEvent('update', me, record, type, modifiedFieldNames, info);
  43717. me.fireEvent('datachanged', me);
  43718. }
  43719. },
  43720. afterChange: function(record, modifiedFieldNames, type) {
  43721. this.getData().itemChanged(record, modifiedFieldNames || null, undefined, type);
  43722. },
  43723. afterCommit: function(record, modifiedFieldNames) {
  43724. this.afterChange(record, modifiedFieldNames, Ext.data.Model.COMMIT);
  43725. },
  43726. afterEdit: function(record, modifiedFieldNames) {
  43727. this.needsSync = this.needsSync || record.dirty;
  43728. this.afterChange(record, modifiedFieldNames, Ext.data.Model.EDIT);
  43729. },
  43730. afterReject: function(record) {
  43731. this.afterChange(record, null, Ext.data.Model.REJECT);
  43732. },
  43733. afterDrop: function(record) {
  43734. this.getData().remove(record);
  43735. },
  43736. afterErase: function(record) {
  43737. this.removeFromRemoved(record);
  43738. },
  43739. addSorted: function(record) {
  43740. var me = this,
  43741. remote = me.getRemoteSort(),
  43742. data = me.getData(),
  43743. index;
  43744. if (remote) {
  43745. data.setSorters(me.getSorters());
  43746. }
  43747. index = data.findInsertionIndex(record);
  43748. if (remote) {
  43749. data.setSorters(null);
  43750. }
  43751. return me.insert(index, record);
  43752. },
  43753. remove: function(records, isMove, silent) {
  43754. var me = this,
  43755. data = me.getDataSource(),
  43756. len, i, toRemove, record;
  43757. if (records) {
  43758. if (records.isModel) {
  43759. if (data.indexOf(records) > -1) {
  43760. toRemove = [
  43761. records
  43762. ];
  43763. len = 1;
  43764. } else {
  43765. len = 0;
  43766. }
  43767. } else {
  43768. toRemove = [];
  43769. for (i = 0 , len = records.length; i < len; ++i) {
  43770. record = records[i];
  43771. if (record && record.isEntity) {
  43772. if (!data.contains(record)) {
  43773. continue;
  43774. }
  43775. } else if (!(record = data.getAt(record))) {
  43776. continue;
  43777. }
  43778. toRemove.push(record);
  43779. }
  43780. len = toRemove.length;
  43781. }
  43782. }
  43783. if (!len) {
  43784. return [];
  43785. }
  43786. me.removeIsMove = isMove === true;
  43787. me.removeIsSilent = silent;
  43788. data.remove(toRemove);
  43789. me.removeIsSilent = false;
  43790. return toRemove;
  43791. },
  43792. onCollectionRemove: function(collection, info) {
  43793. var me = this,
  43794. removed = me.removed,
  43795. records = info.items,
  43796. len = records.length,
  43797. index = info.at,
  43798. replacement = info.replacement,
  43799. isMove = me.removeIsMove || (replacement && Ext.Array.equals(records, replacement.items)),
  43800. silent = me.removeIsSilent,
  43801. lastChunk = !info.next,
  43802. data = me.getDataSource(),
  43803. i, record;
  43804. if (me.ignoreCollectionRemove) {
  43805. return;
  43806. }
  43807. if (replacement) {
  43808. me.setMoving(replacement.items, true);
  43809. }
  43810. for (i = len - 1; i >= 0; i--) {
  43811. record = records[i];
  43812. if (!data.contains(record)) {
  43813. if (removed && !isMove && !record.phantom && !record.erasing) {
  43814. record.removedFrom = index + i;
  43815. removed.push(record);
  43816. me.needsSync = true;
  43817. } else {
  43818. record.unjoin(me);
  43819. }
  43820. }
  43821. }
  43822. if (!silent) {
  43823. if (!replacement || !replacement.items.length) {
  43824. me.fireEvent('remove', me, records, index, isMove);
  43825. if (lastChunk) {
  43826. me.fireEvent('datachanged', me);
  43827. }
  43828. }
  43829. }
  43830. if (replacement) {
  43831. me.setMoving(replacement.items, false);
  43832. }
  43833. },
  43834. onFilterEndUpdate: function() {
  43835. var me = this;
  43836. if (me.destroying || me.destroyed) {
  43837. return;
  43838. }
  43839. if (me.activeRanges) {
  43840. me.syncActiveRanges();
  43841. }
  43842. me.callParent(arguments);
  43843. me.callObservers('Filter');
  43844. },
  43845. removeAt: function(index, count) {
  43846. var data = this.getData();
  43847. index = Math.max(index, 0);
  43848. if (index < data.length) {
  43849. if (arguments.length === 1) {
  43850. count = 1;
  43851. } else if (!count) {
  43852. return;
  43853. }
  43854. data.removeAt(index, count);
  43855. }
  43856. },
  43857. removeAll: function(silent) {
  43858. var me = this,
  43859. data = me.getData(),
  43860. records = data.getRange();
  43861. if (data.length) {
  43862. me.removeIsSilent = true;
  43863. me.callObservers('BeforeRemoveAll');
  43864. data.removeAll();
  43865. me.removeIsSilent = false;
  43866. if (!silent) {
  43867. me.fireEvent('clear', me, records);
  43868. me.fireEvent('datachanged', me);
  43869. }
  43870. me.callObservers('AfterRemoveAll', [
  43871. !!silent
  43872. ]);
  43873. }
  43874. return records;
  43875. },
  43876. setRecords: function(records) {
  43877. var count = this.getCount();
  43878. ++this.loadCount;
  43879. if (count) {
  43880. this.getData().splice(0, count, records);
  43881. } else {
  43882. this.add(records);
  43883. }
  43884. },
  43885. splice: function(index, toRemove, toAdd) {
  43886. return this.getData().splice(index, toRemove, toAdd);
  43887. },
  43888. onProxyLoad: function(operation) {
  43889. var me = this,
  43890. resultSet = operation.getResultSet(),
  43891. records = operation.getRecords(),
  43892. successful = operation.wasSuccessful();
  43893. if (me.destroyed) {
  43894. return;
  43895. }
  43896. if (resultSet) {
  43897. me.totalCount = resultSet.getTotal();
  43898. }
  43899. if (successful) {
  43900. records = me.processAssociation(records);
  43901. me.loadRecords(records, operation.getAddRecords() ? {
  43902. addRecords: true
  43903. } : undefined);
  43904. me.attachSummaryRecord(resultSet);
  43905. } else {
  43906. me.loading = false;
  43907. }
  43908. if (me.hasListeners.load) {
  43909. me.fireEvent('load', me, records, successful, operation);
  43910. }
  43911. me.callObservers('AfterLoad', [
  43912. records,
  43913. successful,
  43914. operation
  43915. ]);
  43916. },
  43917. onProxyWrite: function(operation) {
  43918. if (operation.wasSuccessful()) {
  43919. this.attachSummaryRecord(operation.getResultSet());
  43920. }
  43921. this.callParent([
  43922. operation
  43923. ]);
  43924. },
  43925. filterDataSource: function(fn) {
  43926. var source = this.getDataSource(),
  43927. items = source.items,
  43928. len = items.length,
  43929. ret = [],
  43930. i;
  43931. for (i = 0; i < len; i++) {
  43932. if (fn.call(source, items[i])) {
  43933. ret.push(items[i]);
  43934. }
  43935. }
  43936. return ret;
  43937. },
  43938. getNewRecords: function() {
  43939. return this.filterDataSource(this.filterNew);
  43940. },
  43941. getRejectRecords: function() {
  43942. return this.filterDataSource(this.filterRejects);
  43943. },
  43944. getUpdatedRecords: function() {
  43945. return this.filterDataSource(this.filterUpdated);
  43946. },
  43947. loadData: function(data, append) {
  43948. var me = this,
  43949. length = data.length,
  43950. newData = [],
  43951. i;
  43952. for (i = 0; i < length; i++) {
  43953. newData.push(me.createModel(data[i]));
  43954. }
  43955. newData = me.processAssociation(newData);
  43956. me.loadRecords(newData, append ? me.addRecordsOptions : undefined);
  43957. },
  43958. loadRawData: function(data, append) {
  43959. var me = this,
  43960. session = me.getSession(),
  43961. result, records, success;
  43962. result = me.getProxy().getReader().read(data, session ? {
  43963. recordCreator: session.recordCreator
  43964. } : undefined);
  43965. records = result.getRecords();
  43966. success = result.getSuccess();
  43967. if (success) {
  43968. me.totalCount = result.getTotal();
  43969. me.loadRecords(records, append ? me.addRecordsOptions : undefined);
  43970. }
  43971. return success;
  43972. },
  43973. loadRecords: function(records, options) {
  43974. var me = this,
  43975. data = me.getData(),
  43976. addRecords, skipSort;
  43977. if (options) {
  43978. addRecords = options.addRecords;
  43979. }
  43980. if (!me.getRemoteSort() && !me.getSortOnLoad()) {
  43981. skipSort = true;
  43982. data.setAutoSort(false);
  43983. }
  43984. if (!addRecords) {
  43985. me.clearData(true);
  43986. }
  43987. me.loading = false;
  43988. me.ignoreCollectionAdd = true;
  43989. me.callObservers('BeforePopulate');
  43990. data.add(records);
  43991. me.ignoreCollectionAdd = false;
  43992. if (skipSort) {
  43993. data.setAutoSort(true);
  43994. }
  43995. me.afterLoadRecords(records);
  43996. },
  43997. afterLoadRecords: function(records) {
  43998. var me = this,
  43999. length = records.length,
  44000. i;
  44001. for (i = 0; i < length; i++) {
  44002. records[i].join(me);
  44003. }
  44004. if (!me.isEmptyStore) {
  44005. ++me.loadCount;
  44006. me.complete = true;
  44007. }
  44008. if (me.hasListeners.datachanged) {
  44009. me.fireEvent('datachanged', me);
  44010. }
  44011. if (me.hasListeners.refresh) {
  44012. me.fireEvent('refresh', me);
  44013. }
  44014. me.callObservers('AfterPopulate');
  44015. },
  44016. loadPage: function(page, options) {
  44017. var me = this,
  44018. size = me.getPageSize();
  44019. me.currentPage = page;
  44020. options = Ext.apply({
  44021. page: page,
  44022. start: (page - 1) * size,
  44023. limit: size,
  44024. addRecords: !me.getClearOnPageLoad()
  44025. }, options);
  44026. me.read(options);
  44027. },
  44028. nextPage: function(options) {
  44029. this.loadPage(this.currentPage + 1, options);
  44030. },
  44031. previousPage: function(options) {
  44032. this.loadPage(this.currentPage - 1, options);
  44033. },
  44034. clearData: function(isLoad) {
  44035. var me = this,
  44036. removed = me.removed,
  44037. data = me.getDataSource(),
  44038. clearRemovedOnLoad = me.getClearRemovedOnLoad(),
  44039. needsUnjoinCheck = removed && isLoad && !clearRemovedOnLoad,
  44040. records, record, i, len;
  44041. if (data) {
  44042. records = data.items;
  44043. for (i = 0 , len = records.length; i < len; ++i) {
  44044. record = records[i];
  44045. if (needsUnjoinCheck && Ext.Array.contains(removed, record)) {
  44046. continue;
  44047. }
  44048. record.unjoin(me);
  44049. }
  44050. me.ignoreCollectionRemove = true;
  44051. me.callObservers('BeforeClear');
  44052. data.removeAll();
  44053. me.ignoreCollectionRemove = false;
  44054. me.callObservers('AfterClear');
  44055. }
  44056. if (removed && (!isLoad || clearRemovedOnLoad)) {
  44057. removed.length = 0;
  44058. }
  44059. },
  44060. onIdChanged: function(rec, oldId, newId) {
  44061. this.getData().updateKey(rec, oldId);
  44062. this.fireEvent('idchanged', this, rec, oldId, newId);
  44063. },
  44064. commitChanges: function() {
  44065. var me = this,
  44066. recs = me.getModifiedRecords(),
  44067. len = recs.length,
  44068. i = 0;
  44069. Ext.suspendLayouts();
  44070. me.beginUpdate();
  44071. for (; i < len; i++) {
  44072. recs[i].commit();
  44073. }
  44074. me.cleanRemoved();
  44075. me.endUpdate();
  44076. Ext.resumeLayouts(true);
  44077. me.fireEvent('commit', me);
  44078. },
  44079. filterNewOnly: function(item) {
  44080. return item.phantom === true;
  44081. },
  44082. filterRejects: function(item) {
  44083. return item.phantom || item.dirty;
  44084. },
  44085. rejectChanges: function() {
  44086. var me = this,
  44087. recs = me.getRejectRecords(),
  44088. len = recs.length,
  44089. i, rec, toRemove, sorted, data, currentAutoSort;
  44090. Ext.suspendLayouts();
  44091. me.beginUpdate();
  44092. for (i = 0; i < len; i++) {
  44093. rec = recs[i];
  44094. if (rec.phantom) {
  44095. toRemove = toRemove || [];
  44096. toRemove.push(rec);
  44097. } else {
  44098. rec.reject();
  44099. }
  44100. }
  44101. if (toRemove) {
  44102. me.remove(toRemove);
  44103. for (i = 0 , len = toRemove.length; i < len; ++i) {
  44104. toRemove[i].reject();
  44105. }
  44106. }
  44107. recs = me.getRawRemovedRecords();
  44108. if (recs) {
  44109. len = recs.length;
  44110. sorted = !me.getRemoteSort() && me.isSorted();
  44111. if (sorted) {
  44112. data = me.getData();
  44113. currentAutoSort = data.getAutoSort();
  44114. data.setAutoSort(false);
  44115. }
  44116. for (i = len - 1; i >= 0; i--) {
  44117. rec = recs[i];
  44118. rec.reject();
  44119. if (!sorted) {
  44120. me.insert(rec.removedFrom || 0, rec);
  44121. }
  44122. }
  44123. if (sorted) {
  44124. data.setAutoSort(currentAutoSort);
  44125. me.add(recs);
  44126. }
  44127. recs.length = 0;
  44128. }
  44129. me.endUpdate();
  44130. Ext.resumeLayouts(true);
  44131. me.fireEvent('reject', me);
  44132. },
  44133. doDestroy: function() {
  44134. var me = this,
  44135. task = me.loadTask,
  44136. data = me.getData(),
  44137. source = data.getSource();
  44138. me.clearData();
  44139. me.setSession(null);
  44140. me.observers = null;
  44141. if (task) {
  44142. task.cancel();
  44143. me.loadTask = null;
  44144. }
  44145. if (source) {
  44146. source.destroy();
  44147. }
  44148. me.callParent();
  44149. },
  44150. privates: {
  44151. commitOptions: {
  44152. commit: true
  44153. },
  44154. attachSummaryRecord: function(resultSet) {
  44155. if (!resultSet) {
  44156. return;
  44157. }
  44158. var me = this,
  44159. summary = resultSet.getSummaryData(),
  44160. grouper = me.getGrouper(),
  44161. current = me.summaryRecord,
  44162. commitOptions = me.commitOptions,
  44163. groups, len, i, rec, group;
  44164. if (summary) {
  44165. if (current) {
  44166. current.set(summary.data, commitOptions);
  44167. } else {
  44168. me.summaryRecord = summary;
  44169. summary.isRemote = true;
  44170. }
  44171. }
  44172. if (grouper) {
  44173. summary = resultSet.getGroupData();
  44174. if (summary) {
  44175. groups = me.getGroups();
  44176. for (i = 0 , len = summary.length; i < len; ++i) {
  44177. rec = summary[i];
  44178. group = groups.getItemGroup(rec);
  44179. if (group) {
  44180. current = group.summaryRecord;
  44181. if (current) {
  44182. current.set(rec.data, commitOptions);
  44183. } else {
  44184. group.summaryRecord = rec;
  44185. rec.isRemote = true;
  44186. }
  44187. }
  44188. }
  44189. }
  44190. }
  44191. },
  44192. fetch: function(options) {
  44193. var operation;
  44194. options = Ext.apply({}, options);
  44195. this.setLoadOptions(options);
  44196. operation = this.createOperation('read', options);
  44197. operation.execute();
  44198. },
  44199. fireChangeEvent: function(record) {
  44200. return this.getDataSource().contains(record);
  44201. },
  44202. onBeforeLoad: function(operation) {
  44203. this.callObservers('BeforeLoad', [
  44204. operation
  44205. ]);
  44206. },
  44207. onRemoteFilterSet: function(filters, remoteFilter) {
  44208. if (filters) {
  44209. this.getData().setFilters(remoteFilter ? null : filters);
  44210. }
  44211. this.callParent([
  44212. filters,
  44213. remoteFilter
  44214. ]);
  44215. },
  44216. onRemoteSortSet: function(sorters, remoteSort) {
  44217. var data = this.getData();
  44218. if (sorters) {
  44219. data.setSorters(remoteSort ? null : sorters);
  44220. }
  44221. data.setAutoGroup(!remoteSort);
  44222. this.callParent([
  44223. sorters,
  44224. remoteSort
  44225. ]);
  44226. },
  44227. isMoving: function(records, getMap) {
  44228. var map = this.moveMap,
  44229. moving = 0,
  44230. len, i;
  44231. if (map) {
  44232. if (records) {
  44233. if (Ext.isArray(records)) {
  44234. for (i = 0 , len = records.length; i < len; ++i) {
  44235. moving += map[records[i].id] ? 1 : 0;
  44236. }
  44237. } else if (map[records.id]) {
  44238. ++moving;
  44239. }
  44240. } else {
  44241. moving = getMap ? map : this.moveMapCount;
  44242. }
  44243. }
  44244. return moving;
  44245. },
  44246. setLoadOptions: function(options) {
  44247. var me = this,
  44248. pageSize = me.getPageSize(),
  44249. session, grouper;
  44250. if (me.getRemoteSort() && !options.grouper) {
  44251. grouper = me.getGrouper();
  44252. if (grouper) {
  44253. options.grouper = grouper;
  44254. }
  44255. }
  44256. if (pageSize || 'start' in options || 'limit' in options || 'page' in options) {
  44257. options.page = options.page != null ? options.page : me.currentPage;
  44258. options.start = (options.start !== undefined) ? options.start : (options.page - 1) * pageSize;
  44259. options.limit = options.limit != null ? options.limit : pageSize;
  44260. me.currentPage = options.page;
  44261. }
  44262. options.addRecords = options.addRecords || false;
  44263. if (!options.recordCreator) {
  44264. session = me.getSession();
  44265. if (session) {
  44266. options.recordCreator = session.recordCreator;
  44267. }
  44268. }
  44269. me.callParent([
  44270. options
  44271. ]);
  44272. },
  44273. setMoving: function(records, isMoving) {
  44274. var me = this,
  44275. map = me.moveMap || (me.moveMap = {}),
  44276. len = records.length,
  44277. i, id;
  44278. for (i = 0; i < len; ++i) {
  44279. id = records[i].id;
  44280. if (isMoving) {
  44281. if (map[id]) {
  44282. ++map[id];
  44283. } else {
  44284. map[id] = 1;
  44285. ++me.moveMapCount;
  44286. }
  44287. } else {
  44288. if (--map[id] === 0) {
  44289. delete map[id];
  44290. --me.moveMapCount;
  44291. }
  44292. }
  44293. }
  44294. if (me.moveMapCount === 0) {
  44295. me.moveMap = null;
  44296. }
  44297. },
  44298. processAssociation: function(records) {
  44299. var me = this,
  44300. associatedEntity = me.getAssociatedEntity();
  44301. if (associatedEntity) {
  44302. records = me.getRole().processLoad(me, associatedEntity, records, me.getSession());
  44303. }
  44304. return records;
  44305. }
  44306. }
  44307. });
  44308. Ext.define('Ext.data.reader.Array', {
  44309. extend: Ext.data.reader.Json,
  44310. alternateClassName: 'Ext.data.ArrayReader',
  44311. alias: 'reader.array',
  44312. config: {
  44313. totalProperty: undefined,
  44314. successProperty: undefined
  44315. },
  44316. createFieldAccessor: function(field) {
  44317. var oldMap = field.mapping,
  44318. index = field.hasMapping() ? oldMap : field.ordinal,
  44319. result;
  44320. field.mapping = index;
  44321. result = this.callParent(arguments);
  44322. field.mapping = oldMap;
  44323. return result;
  44324. },
  44325. getModelData: function(raw) {
  44326. return {};
  44327. }
  44328. });
  44329. Ext.define('Ext.data.ArrayStore', {
  44330. extend: Ext.data.Store,
  44331. alias: 'store.array',
  44332. alternateClassName: [
  44333. 'Ext.data.SimpleStore'
  44334. ],
  44335. config: {
  44336. proxy: {
  44337. type: 'memory',
  44338. reader: 'array'
  44339. }
  44340. },
  44341. loadData: function(data, append) {
  44342. if (this.expandData) {
  44343. var r = [],
  44344. i = 0,
  44345. ln = data.length;
  44346. for (; i < ln; i++) {
  44347. r[r.length] = [
  44348. data[i]
  44349. ];
  44350. }
  44351. data = r;
  44352. }
  44353. this.callParent([
  44354. data,
  44355. append
  44356. ]);
  44357. }
  44358. });
  44359. Ext.define('Ext.data.StoreManager', {
  44360. extend: Ext.util.MixedCollection,
  44361. alternateClassName: [
  44362. 'Ext.StoreMgr',
  44363. 'Ext.data.StoreMgr',
  44364. 'Ext.StoreManager'
  44365. ],
  44366. singleton: true,
  44367. register: function() {
  44368. var i, s;
  44369. for (i = 0; (s = arguments[i]); i++) {
  44370. this.add(s);
  44371. }
  44372. },
  44373. unregister: function() {
  44374. var i, s;
  44375. for (i = 0; (s = arguments[i]); i++) {
  44376. this.remove(this.lookup(s));
  44377. }
  44378. },
  44379. lookup: function(store, defaultType) {
  44380. var first, data, arrays, fields, i, len;
  44381. if (Ext.isArray(store)) {
  44382. first = store[0];
  44383. data = store;
  44384. if (Ext.isObject(first)) {
  44385. store = {
  44386. data: data
  44387. };
  44388. } else {
  44389. arrays = Ext.isArray(first);
  44390. fields = [
  44391. 'field1'
  44392. ];
  44393. if (arrays) {
  44394. for (i = 2 , len = first.length; i <= len; ++i) {
  44395. fields.push('field' + i);
  44396. }
  44397. } else {
  44398. data = [];
  44399. for (i = 0 , len = store.length; i < len; ++i) {
  44400. data.push([
  44401. store[i]
  44402. ]);
  44403. }
  44404. }
  44405. return new Ext.data.ArrayStore({
  44406. data: data,
  44407. fields: fields,
  44408. autoDestroy: true,
  44409. autoCreated: true,
  44410. expanded: !arrays
  44411. });
  44412. }
  44413. }
  44414. if (Ext.isString(store)) {
  44415. return this.get(store);
  44416. } else {
  44417. return Ext.Factory.store(store, defaultType);
  44418. }
  44419. },
  44420. getKey: function(o) {
  44421. return o.storeId;
  44422. },
  44423. addEmptyStore: function() {
  44424. var emptyStore = this.$emptyStore,
  44425. destoryable = {
  44426. destroy: Ext.emptyFn
  44427. };
  44428. if (!emptyStore) {
  44429. emptyStore = this.$emptyStore = Ext.regStore('ext-empty-store', {
  44430. proxy: 'memory',
  44431. useModelWarning: false
  44432. });
  44433. emptyStore.ignoreLeaked = true;
  44434. emptyStore.isEmptyStore = true;
  44435. emptyStore.on = emptyStore.addListener = function() {
  44436. return destoryable;
  44437. };
  44438. emptyStore.un = emptyStore.removeListener = Ext.emptyFn;
  44439. emptyStore.add = emptyStore.remove = emptyStore.insert = emptyStore.destroy = emptyStore.loadData = function() {
  44440. Ext.raise('Cannot modify ext-empty-store');
  44441. };
  44442. }
  44443. this.add(emptyStore);
  44444. },
  44445. clear: function() {
  44446. this.callParent();
  44447. this.addEmptyStore();
  44448. }
  44449. }, function() {
  44450. Ext.regStore = function(id, config) {
  44451. var store;
  44452. if (Ext.isObject(id)) {
  44453. config = id;
  44454. } else {
  44455. if (Ext.data.StoreManager.containsKey(id)) {
  44456. return Ext.data.StoreManager.lookup(id);
  44457. }
  44458. config.storeId = id;
  44459. }
  44460. if (config instanceof Ext.data.Store) {
  44461. store = config;
  44462. } else {
  44463. store = new Ext.data.Store(config);
  44464. }
  44465. Ext.data.StoreManager.register(store);
  44466. return store;
  44467. };
  44468. Ext.getStore = function(name) {
  44469. return Ext.data.StoreManager.lookup(name);
  44470. };
  44471. Ext.data.StoreManager.addEmptyStore();
  44472. });
  44473. Ext.define('Ext.app.domain.Store', {
  44474. extend: Ext.app.EventDomain,
  44475. singleton: true,
  44476. type: 'store',
  44477. prefix: 'store.',
  44478. idMatchRe: /^#/,
  44479. constructor: function() {
  44480. var me = this;
  44481. me.callParent();
  44482. me.monitor(Ext.data.AbstractStore);
  44483. },
  44484. match: function(target, selector) {
  44485. var result = false,
  44486. alias = target.alias;
  44487. if (selector === '*') {
  44488. result = true;
  44489. } else if (this.idMatchRe.test(selector)) {
  44490. result = target.getStoreId() === selector.substring(1);
  44491. } else if (alias) {
  44492. result = Ext.Array.indexOf(alias, this.prefix + selector) > -1;
  44493. }
  44494. return result;
  44495. }
  44496. });
  44497. Ext.define('Ext.app.Controller', {
  44498. extend: Ext.app.BaseController,
  44499. statics: {
  44500. strings: {
  44501. model: {
  44502. getter: 'getModel',
  44503. upper: 'Model'
  44504. },
  44505. view: {
  44506. getter: 'getView',
  44507. upper: 'View'
  44508. },
  44509. controller: {
  44510. getter: 'getController',
  44511. upper: 'Controller'
  44512. },
  44513. store: {
  44514. getter: 'getStore',
  44515. upper: 'Store'
  44516. },
  44517. profile: {
  44518. getter: 'getProfile',
  44519. upper: 'Profiles'
  44520. }
  44521. },
  44522. controllerRegex: /^(.*)\.controller\./,
  44523. profileRegex: /^(.*)\.profile\./,
  44524. createGetter: function(baseGetter, name) {
  44525. return function() {
  44526. return this[baseGetter](name);
  44527. };
  44528. },
  44529. getGetterName: function(name, kindUpper) {
  44530. var fn = 'get',
  44531. parts = name.split('.'),
  44532. numParts = parts.length,
  44533. index;
  44534. for (index = 0; index < numParts; index++) {
  44535. fn += Ext.String.capitalize(parts[index]);
  44536. }
  44537. fn += kindUpper;
  44538. return fn;
  44539. },
  44540. resolveNamespace: function(cls, data) {
  44541. var Controller = Ext.app.Controller,
  44542. namespaceRe, className, namespace, match;
  44543. namespaceRe = cls.prototype.isProfile ? Controller.profileRegex : Controller.controllerRegex;
  44544. className = Ext.getClassName(cls);
  44545. namespace = data.$namespace || data.namespace || Ext.app.getNamespace(className) || ((match = namespaceRe.exec(className)) && match[1]);
  44546. if (!namespace) {
  44547. Ext.log.warn("Missing namespace for " + className + ", please define it " + "in namespaces property of your Application class.");
  44548. }
  44549. return namespace;
  44550. },
  44551. processDependencies: function(cls, requires, namespace, kind, names, profileName) {
  44552. if (!names || !names.length) {
  44553. return;
  44554. }
  44555. var me = this,
  44556. strings = me.strings[kind],
  44557. o, absoluteName, shortName, name, j, subLn, getterName, getter;
  44558. if (!Ext.isArray(names)) {
  44559. names = [
  44560. names
  44561. ];
  44562. }
  44563. for (j = 0 , subLn = names.length; j < subLn; j++) {
  44564. name = names[j];
  44565. o = me.getFullName(name, kind, namespace, profileName);
  44566. names[j] = absoluteName = o.absoluteName;
  44567. shortName = o.shortName;
  44568. requires.push(absoluteName);
  44569. getterName = me.getGetterName(shortName, strings.upper);
  44570. if (!cls[getterName]) {
  44571. cls[getterName] = getter = me.createGetter(strings.getter, name);
  44572. }
  44573. else if (getterName === 'getMainView') {
  44574. Ext.log.warn('Cannot have a view named \'Main\' - getter conflicts ' + 'with mainView config.');
  44575. }
  44576. if (getter && kind !== 'controller') {
  44577. getter['Ext.app.getter'] = true;
  44578. }
  44579. }
  44580. },
  44581. getFullName: function(name, kind, namespace, profileName) {
  44582. var shortName = name,
  44583. sep, absoluteName;
  44584. if ((sep = name.indexOf('@')) > 0) {
  44585. shortName = name.substring(0, sep);
  44586. absoluteName = name.substring(sep + 1) + '.' + shortName;
  44587. }
  44588. else if (name.indexOf('.') > 0 && (Ext.ClassManager.isCreated(name) || this.hasRegisteredPrefix(name))) {
  44589. absoluteName = name;
  44590. shortName = name.replace(namespace + '.' + kind + '.', '');
  44591. } else {
  44592. if (!namespace) {
  44593. Ext.log.warn("Cannot find namespace for " + kind + " " + name + ", " + "assuming it is fully qualified class name");
  44594. }
  44595. if (namespace) {
  44596. absoluteName = namespace + '.' + kind + '.' + (profileName ? profileName + '.' + name : name);
  44597. shortName = name;
  44598. } else {
  44599. absoluteName = name;
  44600. }
  44601. }
  44602. return {
  44603. absoluteName: absoluteName,
  44604. shortName: shortName
  44605. };
  44606. },
  44607. hasRegisteredPrefix: function(className) {
  44608. var inventory = Ext.ClassManager,
  44609. prefix = inventory.getPrefix(className);
  44610. return prefix && prefix !== className;
  44611. }
  44612. },
  44613. models: null,
  44614. views: null,
  44615. stores: null,
  44616. controllers: null,
  44617. config: {
  44618. application: null,
  44619. refs: null,
  44620. active: true,
  44621. moduleClassName: null
  44622. },
  44623. onClassExtended: function(cls, data, hooks) {
  44624. var onBeforeClassCreated = hooks.onBeforeCreated;
  44625. hooks.onBeforeCreated = function(cls, data) {
  44626. var Controller = Ext.app.Controller,
  44627. requires = [],
  44628. namespace, proto;
  44629. proto = cls.prototype;
  44630. namespace = Controller.resolveNamespace(cls, data);
  44631. if (namespace) {
  44632. proto.$namespace = namespace;
  44633. }
  44634. Controller.processDependencies(proto, requires, namespace, 'model', data.models);
  44635. Controller.processDependencies(proto, requires, namespace, 'view', data.views);
  44636. Controller.processDependencies(proto, requires, namespace, 'store', data.stores);
  44637. Controller.processDependencies(proto, requires, namespace, 'controller', data.controllers);
  44638. Ext.require(requires, Ext.Function.pass(onBeforeClassCreated, arguments, this));
  44639. };
  44640. },
  44641. constructor: function(config) {
  44642. this.initAutoGetters();
  44643. this.callParent([
  44644. config
  44645. ]);
  44646. },
  44647. normalizeRefs: function(refs) {
  44648. var me = this,
  44649. newRefs = [];
  44650. if (refs) {
  44651. if (Ext.isObject(refs)) {
  44652. Ext.Object.each(refs, function(key, value) {
  44653. if (Ext.isString(value)) {
  44654. value = {
  44655. selector: value
  44656. };
  44657. }
  44658. value.ref = key;
  44659. newRefs.push(value);
  44660. });
  44661. } else if (Ext.isArray(refs)) {
  44662. newRefs = Ext.Array.merge(newRefs, refs);
  44663. }
  44664. }
  44665. refs = me.refs;
  44666. if (refs) {
  44667. me.refs = null;
  44668. refs = me.normalizeRefs(refs);
  44669. if (refs) {
  44670. newRefs = Ext.Array.merge(newRefs, refs);
  44671. }
  44672. }
  44673. return newRefs;
  44674. },
  44675. getRefMap: function() {
  44676. var me = this,
  44677. refMap = me._refMap,
  44678. refs, ref, ln, i;
  44679. if (!refMap) {
  44680. refs = me.getRefs();
  44681. refMap = me._refMap = {};
  44682. if (refs) {
  44683. for (i = 0 , ln = refs.length; i < ln; i++) {
  44684. ref = refs[i];
  44685. refMap[ref.ref] = ref.selector;
  44686. }
  44687. }
  44688. }
  44689. return refMap;
  44690. },
  44691. applyId: function(id) {
  44692. return id || Ext.app.Controller.getFullName(this.$className, 'controller', this.$namespace).shortName;
  44693. },
  44694. applyRefs: function(refs) {
  44695. return this.normalizeRefs(Ext.clone(refs));
  44696. },
  44697. updateRefs: function(refs) {
  44698. if (refs) {
  44699. this.ref(refs);
  44700. }
  44701. },
  44702. initAutoGetters: function() {
  44703. var proto = this.self.prototype,
  44704. prop, fn;
  44705. for (prop in proto) {
  44706. fn = proto[prop];
  44707. if (fn && fn['Ext.app.getter']) {
  44708. fn.call(this);
  44709. }
  44710. }
  44711. },
  44712. doInit: function(app) {
  44713. var me = this;
  44714. if (!me._initialized) {
  44715. me.init(app);
  44716. me._initialized = true;
  44717. }
  44718. },
  44719. finishInit: function(app) {
  44720. var me = this,
  44721. controllers = me.controllers,
  44722. controller, i, l;
  44723. if (me._initialized && controllers && controllers.length) {
  44724. for (i = 0 , l = controllers.length; i < l; i++) {
  44725. controller = me.getController(controllers[i]);
  44726. controller.finishInit(app);
  44727. }
  44728. }
  44729. },
  44730. init: Ext.emptyFn,
  44731. onLaunch: Ext.emptyFn,
  44732. activate: function() {
  44733. this.setActive(true);
  44734. },
  44735. deactivate: function() {
  44736. this.setActive(false);
  44737. },
  44738. isActive: function() {
  44739. return this.getActive();
  44740. },
  44741. ref: function(refs) {
  44742. var me = this,
  44743. i = 0,
  44744. length = refs.length,
  44745. info, ref, fn;
  44746. refs = Ext.Array.from(refs);
  44747. me.references = me.references || [];
  44748. for (; i < length; i++) {
  44749. info = refs[i];
  44750. ref = info.ref;
  44751. fn = 'get' + Ext.String.capitalize(ref);
  44752. if (!me[fn]) {
  44753. me[fn] = Ext.Function.pass(me.getRef, [
  44754. ref,
  44755. info
  44756. ], me);
  44757. }
  44758. me.references.push(ref.toLowerCase());
  44759. }
  44760. },
  44761. addRef: function(refs) {
  44762. this.ref(refs);
  44763. },
  44764. getRef: function(ref, info, config) {
  44765. var me = this,
  44766. refCache = me.refCache || (me.refCache = {}),
  44767. cached = refCache[ref];
  44768. info = info || {};
  44769. config = config || {};
  44770. Ext.apply(info, config);
  44771. if (info.forceCreate) {
  44772. return Ext.ComponentManager.create(info, 'component');
  44773. }
  44774. if (!cached) {
  44775. if (info.selector) {
  44776. refCache[ref] = cached = Ext.ComponentQuery.query(info.selector)[0];
  44777. }
  44778. if (!cached && info.autoCreate) {
  44779. refCache[ref] = cached = Ext.ComponentManager.create(info, 'component');
  44780. }
  44781. if (cached) {
  44782. cached.on('destroy', function() {
  44783. refCache[ref] = null;
  44784. });
  44785. }
  44786. }
  44787. return cached;
  44788. },
  44789. hasRef: function(ref) {
  44790. var references = this.references;
  44791. return references && Ext.Array.indexOf(references, ref.toLowerCase()) !== -1;
  44792. },
  44793. getController: function(id) {
  44794. var app = this.getApplication();
  44795. if (id === this.getId()) {
  44796. return this;
  44797. }
  44798. return app && app.getController(id);
  44799. },
  44800. getStore: function(name) {
  44801. var storeId, store;
  44802. storeId = (name.indexOf('@') === -1) ? name : name.split('@')[0];
  44803. store = Ext.StoreManager.get(storeId);
  44804. if (!store) {
  44805. name = Ext.app.Controller.getFullName(name, 'store', this.$namespace);
  44806. if (name) {
  44807. store = Ext.create(name.absoluteName, {
  44808. id: storeId
  44809. });
  44810. }
  44811. }
  44812. return store;
  44813. },
  44814. getModel: function(modelName) {
  44815. var name = Ext.app.Controller.getFullName(modelName, 'model', this.$namespace),
  44816. ret = Ext.ClassManager.get(name.absoluteName);
  44817. if (!ret) {
  44818. ret = Ext.data.schema.Schema.lookupEntity(modelName);
  44819. }
  44820. return ret;
  44821. },
  44822. getProfile: function(name) {
  44823. name = Ext.app.Controller.getFullName(name, 'profile', this.$namespace);
  44824. return name;
  44825. },
  44826. getView: function(view) {
  44827. var name = Ext.app.Controller.getFullName(view, 'view', this.$namespace);
  44828. return name && Ext.ClassManager.get(name.absoluteName);
  44829. },
  44830. destroy: function(destroyRefs, fromApp) {
  44831. var me = this,
  44832. app = me.application,
  44833. refCache, ref;
  44834. if (!fromApp && app) {
  44835. app.unregister(me);
  44836. }
  44837. me.application = null;
  44838. if (destroyRefs) {
  44839. refCache = me.refCache;
  44840. for (ref in refCache) {
  44841. if (refCache.hasOwnProperty(ref)) {
  44842. Ext.destroy(refCache[ref]);
  44843. }
  44844. }
  44845. }
  44846. me.callParent();
  44847. }
  44848. });
  44849. Ext.define('Ext.app.Application', {
  44850. extend: Ext.app.Controller,
  44851. isApplication: true,
  44852. scope: undefined,
  44853. namespaces: [],
  44854. paths: null,
  44855. config: {
  44856. name: '',
  44857. appProperty: 'app',
  44858. profiles: [],
  44859. currentProfile: null,
  44860. mainView: {
  44861. $value: null,
  44862. lazy: true
  44863. },
  44864. defaultToken: null,
  44865. glyphFontFamily: null,
  44866. quickTips: true,
  44867. router: null
  44868. },
  44869. onClassExtended: function(cls, data, hooks) {
  44870. var Controller = Ext.app.Controller,
  44871. proto = cls.prototype,
  44872. requires = [],
  44873. onBeforeClassCreated, namespace;
  44874. namespace = data.name || cls.superclass.name;
  44875. if (namespace) {
  44876. data.$namespace = namespace;
  44877. Ext.app.addNamespaces(namespace);
  44878. }
  44879. if (data.namespaces) {
  44880. Ext.app.addNamespaces(data.namespaces);
  44881. }
  44882. if (data['paths processed']) {
  44883. delete data['paths processed'];
  44884. } else {
  44885. Ext.app.setupPaths(namespace, ('appFolder' in data) ? data.appFolder : cls.superclass.appFolder, data.paths);
  44886. }
  44887. Controller.processDependencies(proto, requires, namespace, 'profile', data.profiles);
  44888. proto.getDependencies(cls, data, requires);
  44889. if (requires.length) {
  44890. onBeforeClassCreated = hooks.onBeforeCreated;
  44891. hooks.onBeforeCreated = function(cls, data) {
  44892. var args = Ext.Array.clone(arguments);
  44893. if (data.__handleRequires) {
  44894. data.__handleRequires.call(this, requires, Ext.bind(function() {
  44895. return onBeforeClassCreated.apply(this, args);
  44896. }, this));
  44897. return;
  44898. }
  44899. Ext.require(requires, function() {
  44900. return onBeforeClassCreated.apply(this, args);
  44901. });
  44902. };
  44903. }
  44904. },
  44905. getDependencies: Ext.emptyFn,
  44906. constructor: function(config) {
  44907. var me = this;
  44908. Ext.route.Router.application = me;
  44909. me.callParent([
  44910. config
  44911. ]);
  44912. if (Ext.isEmpty(me.getName())) {
  44913. Ext.raise("[Ext.app.Application] Name property is required");
  44914. }
  44915. me.doInit(me);
  44916. Ext.on('appupdate', me.onAppUpdate, me, {
  44917. single: true
  44918. });
  44919. Ext.Loader.setConfig({
  44920. enabled: true
  44921. });
  44922. this.onProfilesReady();
  44923. },
  44924. applyId: function(id) {
  44925. return id || this.$className;
  44926. },
  44927. updateRouter: function(cfg) {
  44928. if (cfg) {
  44929. Ext.route.Router.setConfig(cfg);
  44930. }
  44931. },
  44932. onAppUpdate: Ext.emptyFn,
  44933. onProfilesReady: function() {
  44934. var me = this,
  44935. profiles = me.getProfiles(),
  44936. length = profiles.length,
  44937. current, i, instance;
  44938. for (i = 0; i < length; i++) {
  44939. instance = Ext.create(profiles[i], {
  44940. application: me
  44941. });
  44942. if (instance.isActive() && !current) {
  44943. current = instance;
  44944. me.setCurrentProfile(current);
  44945. }
  44946. }
  44947. if (current) {
  44948. current.init();
  44949. }
  44950. me.initControllers();
  44951. me.onBeforeLaunch();
  44952. me.finishInitControllers();
  44953. },
  44954. doInit: function(app) {
  44955. this.initNamespace(app);
  44956. this.callParent([
  44957. app
  44958. ]);
  44959. },
  44960. initNamespace: function(me) {
  44961. var appProperty = me.getAppProperty(),
  44962. ns = Ext.namespace(me.getName());
  44963. if (ns) {
  44964. ns.getApplication = function() {
  44965. return me;
  44966. };
  44967. if (appProperty) {
  44968. if (!ns[appProperty]) {
  44969. ns[appProperty] = me;
  44970. }
  44971. else if (ns[appProperty] !== me) {
  44972. Ext.log.warn('An existing reference is being overwritten for ' + name + '.' + appProperty + '. See the appProperty config.');
  44973. }
  44974. }
  44975. }
  44976. },
  44977. initControllers: function() {
  44978. var me = this,
  44979. controllers = Ext.Array.from(me.controllers),
  44980. profile = me.getCurrentProfile(),
  44981. i, ln;
  44982. me.controllers = new Ext.util.MixedCollection();
  44983. for (i = 0 , ln = controllers.length; i < ln; i++) {
  44984. me.getController(controllers[i]);
  44985. }
  44986. if (profile) {
  44987. controllers = profile.getControllers();
  44988. for (i = 0 , ln = controllers.length; i < ln; i++) {
  44989. me.getController(controllers[i]);
  44990. }
  44991. }
  44992. },
  44993. finishInitControllers: function() {
  44994. var me = this,
  44995. controllers, i, l;
  44996. controllers = me.controllers.getRange();
  44997. for (i = 0 , l = controllers.length; i < l; i++) {
  44998. controllers[i].finishInit(me);
  44999. }
  45000. },
  45001. launch: Ext.emptyFn,
  45002. onBeforeLaunch: function() {
  45003. var me = this,
  45004. History = Ext.util.History,
  45005. defaultToken = me.getDefaultToken(),
  45006. currentProfile = me.getCurrentProfile(),
  45007. controllers, c, cLen, controller, token;
  45008. me.initMainView();
  45009. if (currentProfile) {
  45010. currentProfile.launch();
  45011. }
  45012. me.launch.call(me.scope || me);
  45013. me.launched = true;
  45014. me.fireEvent('launch', me);
  45015. controllers = me.controllers.items;
  45016. cLen = controllers.length;
  45017. for (c = 0; c < cLen; c++) {
  45018. controller = controllers[c];
  45019. controller.onLaunch(me);
  45020. }
  45021. if (!History.ready) {
  45022. History.init();
  45023. }
  45024. token = History.getToken();
  45025. if (token || token === defaultToken) {
  45026. Ext.route.Router.onStateChange(token);
  45027. } else if (defaultToken) {
  45028. History.replace(defaultToken);
  45029. }
  45030. if (Ext.Microloader && Ext.Microloader.appUpdate && Ext.Microloader.appUpdate.updated) {
  45031. Ext.Microloader.fireAppUpdate();
  45032. }
  45033. if (!me.cnsTimer) {
  45034. me.cnsTimer = Ext.defer(Ext.ClassManager.clearNamespaceCache, 2000, Ext.ClassManager);
  45035. }
  45036. },
  45037. getModuleClassName: function(name, kind) {
  45038. return Ext.app.Controller.getFullName(name, kind, this.getName()).absoluteName;
  45039. },
  45040. initMainView: function() {
  45041. var me = this,
  45042. currentProfile = me.getCurrentProfile(),
  45043. mainView;
  45044. if (currentProfile) {
  45045. mainView = currentProfile.getMainView();
  45046. }
  45047. if (mainView) {
  45048. me.setMainView(mainView);
  45049. } else {
  45050. me.getMainView();
  45051. }
  45052. },
  45053. applyMainView: function(value) {
  45054. var view = this.getView(value);
  45055. return view.create({
  45056. $initParent: this.viewport
  45057. });
  45058. },
  45059. createController: function(name) {
  45060. return this.getController(name);
  45061. },
  45062. destroyController: function(controller) {
  45063. if (typeof controller === 'string') {
  45064. controller = this.getController(controller, true);
  45065. }
  45066. Ext.destroy(controller);
  45067. },
  45068. getController: function(name, preventCreate) {
  45069. var me = this,
  45070. controllers = me.controllers,
  45071. className, controller, len, i, c, all;
  45072. controller = controllers.get(name);
  45073. if (!controller) {
  45074. all = controllers.items;
  45075. for (i = 0 , len = all.length; i < len; ++i) {
  45076. c = all[i];
  45077. className = c.getModuleClassName();
  45078. if (className && className === name) {
  45079. controller = c;
  45080. break;
  45081. }
  45082. }
  45083. }
  45084. if (!controller && !preventCreate) {
  45085. className = me.getModuleClassName(name, 'controller');
  45086. controller = Ext.create(className, {
  45087. application: me,
  45088. moduleClassName: className
  45089. });
  45090. controllers.add(controller);
  45091. if (me._initialized) {
  45092. controller.doInit(me);
  45093. }
  45094. }
  45095. return controller;
  45096. },
  45097. unregister: function(controller) {
  45098. this.controllers.remove(controller);
  45099. },
  45100. getApplication: function() {
  45101. return this;
  45102. },
  45103. destroy: function(destroyRefs) {
  45104. var me = this,
  45105. controllers = me.controllers,
  45106. ns = Ext.namespace(me.getName()),
  45107. appProp = me.getAppProperty();
  45108. Ext.undefer(me.cnsTimer);
  45109. Ext.un('appupdate', me.onAppUpdate, me);
  45110. Ext.destroy(me.viewport);
  45111. if (controllers) {
  45112. controllers.each(function(controller) {
  45113. controller.destroy(destroyRefs, true);
  45114. });
  45115. }
  45116. me.controllers = null;
  45117. me.callParent([
  45118. destroyRefs,
  45119. true
  45120. ]);
  45121. if (ns && ns[appProp] === me) {
  45122. delete ns[appProp];
  45123. }
  45124. if (Ext.route.Router.application === me) {
  45125. Ext.route.Router.application = null;
  45126. }
  45127. if (Ext.app.Application.instance === me) {
  45128. Ext.app.Application.instance = null;
  45129. }
  45130. },
  45131. updateGlyphFontFamily: function(fontFamily) {
  45132. Ext.setGlyphFontFamily(fontFamily);
  45133. },
  45134. applyProfiles: function(profiles) {
  45135. var me = this;
  45136. return Ext.Array.map(profiles, function(profile) {
  45137. return me.getModuleClassName(profile, "profile");
  45138. });
  45139. }
  45140. }, function() {
  45141. Ext.getApplication = function() {
  45142. return Ext.app.Application.instance;
  45143. };
  45144. });
  45145. Ext.application = function(config) {
  45146. var createApp = function(App) {
  45147. Ext.onReady(function() {
  45148. var Viewport = Ext.viewport;
  45149. Viewport = Viewport && Viewport['Viewport'];
  45150. if (Viewport && Viewport.setup) {
  45151. Viewport.setup(App.prototype.config.viewport);
  45152. }
  45153. Ext.app.Application.instance = new App();
  45154. });
  45155. };
  45156. if (typeof config === "string") {
  45157. Ext.require(config, function() {
  45158. createApp(Ext.ClassManager.get(config));
  45159. });
  45160. } else {
  45161. config = Ext.apply({
  45162. extend: 'Ext.app.Application'
  45163. },
  45164. config);
  45165. Ext.app.setupPaths(config.name, config.appFolder, config.paths);
  45166. config['paths processed'] = true;
  45167. Ext.define(config.name + ".$application", config, function() {
  45168. createApp(this);
  45169. });
  45170. }
  45171. };
  45172. Ext.define('Ext.util.ItemCollection', {
  45173. extend: Ext.util.MixedCollection,
  45174. alternateClassName: 'Ext.ItemCollection',
  45175. getKey: function(item) {
  45176. return item.getItemId && item.getItemId();
  45177. },
  45178. has: function(item) {
  45179. return this.map.hasOwnProperty(item.getId());
  45180. }
  45181. });
  45182. Ext.define('Ext.mixin.Queryable', {
  45183. mixinId: 'queryable',
  45184. isQueryable: true,
  45185. query: function(selector) {
  45186. selector = selector || '*';
  45187. return Ext.ComponentQuery.query(selector, this.getQueryRoot());
  45188. },
  45189. queryBy: function(fn, scope) {
  45190. var out = [],
  45191. items = this.getQueryRoot().getRefItems(true),
  45192. i = 0,
  45193. len = items.length,
  45194. item;
  45195. for (; i < len; ++i) {
  45196. item = items[i];
  45197. if (fn.call(scope || item, item) !== false) {
  45198. out.push(item);
  45199. }
  45200. }
  45201. return out;
  45202. },
  45203. queryById: function(id) {
  45204. return this.down(Ext.makeIdSelector(id));
  45205. },
  45206. child: function(selector) {
  45207. var children = this.getQueryRoot().getRefItems();
  45208. if (selector && selector.isComponent) {
  45209. return this.matchById(children, selector.getItemId());
  45210. }
  45211. if (selector) {
  45212. children = Ext.ComponentQuery.query(selector, children);
  45213. }
  45214. if (children.length) {
  45215. return children[0];
  45216. }
  45217. return null;
  45218. },
  45219. down: function(selector) {
  45220. if (selector && selector.isComponent) {
  45221. return this.matchById(this.getRefItems(true), selector.getItemId());
  45222. }
  45223. selector = selector || '';
  45224. return this.query(selector)[0] || null;
  45225. },
  45226. visitPreOrder: function(selector, fn, scope, extraArgs) {
  45227. Ext.ComponentQuery._visit(true, selector, this.getQueryRoot(), fn, scope, extraArgs);
  45228. },
  45229. visitPostOrder: function(selector, fn, scope, extraArgs) {
  45230. Ext.ComponentQuery._visit(false, selector, this.getQueryRoot(), fn, scope, extraArgs);
  45231. },
  45232. getRefItems: function() {
  45233. return [];
  45234. },
  45235. getQueryRoot: function() {
  45236. return this;
  45237. },
  45238. privates: {
  45239. matchById: function(items, id) {
  45240. var len = items.length,
  45241. i, item;
  45242. for (i = 0; i < len; ++i) {
  45243. item = items[i];
  45244. if (item.getItemId() === id) {
  45245. return item;
  45246. }
  45247. }
  45248. return null;
  45249. }
  45250. }
  45251. });
  45252. Ext.define('Ext.mixin.Container', {
  45253. extend: Ext.Mixin,
  45254. mixinConfig: {
  45255. id: 'container'
  45256. },
  45257. isContainer: true,
  45258. nameHolder: false,
  45259. referenceHolder: false,
  45260. getNamedItems: function() {
  45261. if (Ext.referencesDirty) {
  45262. Ext.fixReferences();
  45263. }
  45264. return this.nameRefs || null;
  45265. },
  45266. getReferences: function() {
  45267. if (Ext.referencesDirty) {
  45268. Ext.fixReferences();
  45269. }
  45270. return this.refs || null;
  45271. },
  45272. lookup: function(ref) {
  45273. var refs = this.getReferences();
  45274. return (refs && refs[ref]) || null;
  45275. },
  45276. lookupName: function(name) {
  45277. var items = this.getNamedItems();
  45278. return (items && items[name]) || null;
  45279. },
  45280. lookupReference: function(ref) {
  45281. return this.lookup(ref);
  45282. },
  45283. privates: {
  45284. attachNameRef: function(component) {
  45285. var me = this,
  45286. key = component.name || component._name,
  45287. entry, nameRefs;
  45288. if (key && !me.destroying && !me.destroyed) {
  45289. nameRefs = me.nameRefs || (me.nameRefs = {});
  45290. entry = nameRefs[key];
  45291. if (!entry) {
  45292. entry = component.shareableName ? [
  45293. component
  45294. ] : component;
  45295. } else if (!entry.isInstance) {
  45296. entry.push(component);
  45297. } else
  45298. {
  45299. Ext.raise('Duplicate name: "' + key + '" on ' + me.id + ' between ' + entry.id + ' and ' + component.id);
  45300. }
  45301. nameRefs[key] = entry;
  45302. }
  45303. },
  45304. attachReference: function(component) {
  45305. var me = this,
  45306. key, refs;
  45307. if (!me.destroying && !me.destroyed) {
  45308. refs = me.refs || (me.refs = {});
  45309. key = component.referenceKey;
  45310. if (refs[key] && refs[key] !== component) {
  45311. Ext.log.warn('Duplicate reference: "' + key + '" on ' + me.id);
  45312. }
  45313. refs[key] = component;
  45314. }
  45315. },
  45316. containerOnAdded: function(component, instanced) {
  45317. Ext.ComponentManager.markReferencesDirty();
  45318. },
  45319. containerOnRemoved: function(destroying) {
  45320. if (!destroying) {
  45321. Ext.ComponentManager.markReferencesDirty();
  45322. }
  45323. },
  45324. initContainerInheritedState: function(inheritedState, inheritedStateInner) {
  45325. var me = this,
  45326. controller = me.getController(),
  45327. session = me.getSession(),
  45328. viewModel = me.getConfig('viewModel', true),
  45329. reference = me.reference,
  45330. referenceHolder = me.referenceHolder;
  45331. if (me.nameHolder) {
  45332. inheritedState.nameHolder = me;
  45333. }
  45334. if (controller) {
  45335. inheritedState.referenceHolder = controller;
  45336. referenceHolder = true;
  45337. } else if (referenceHolder) {
  45338. inheritedState.referenceHolder = me;
  45339. }
  45340. if (referenceHolder) {
  45341. inheritedState.referencePath = '';
  45342. } else if (reference && me.isParentReference) {
  45343. inheritedState.referencePath = me.referenceKey + '.';
  45344. }
  45345. if (session) {
  45346. inheritedState.session = session;
  45347. }
  45348. if (viewModel) {
  45349. inheritedState.viewModelPath = '';
  45350. } else if (reference && me.isParentReference) {
  45351. inheritedState.viewModelPath = me.viewModelKey + '.';
  45352. }
  45353. },
  45354. setupReference: function(reference) {
  45355. var len;
  45356. if (reference && reference.charAt(len = reference.length - 1) === '>') {
  45357. this.isParentReference = true;
  45358. reference = reference.substring(0, len);
  45359. }
  45360. if (reference && !Ext.validIdRe.test(reference)) {
  45361. Ext.Error.raise('Invalid reference "' + reference + '" for ' + this.getId() + ' - not a valid identifier');
  45362. }
  45363. return reference;
  45364. }
  45365. }
  45366. });
  45367. Ext.define('Ext.util.KeyMap', {
  45368. alternateClassName: 'Ext.KeyMap',
  45369. eventName: 'keydown',
  45370. constructor: function(config) {
  45371. var me = this;
  45372. if ((arguments.length !== 1) || (typeof config === 'string') || config.dom || config.tagName || config === document || config.isComponent) {
  45373. Ext.raise("Legacy multi-argument KeyMap constructor is removed. " + "Use a config object instead.");
  45374. }
  45375. Ext.apply(me, config);
  45376. me.bindings = [];
  45377. if (!me.target.isComponent) {
  45378. me.target = Ext.get(me.target);
  45379. }
  45380. if (me.binding) {
  45381. me.addBinding(me.binding);
  45382. } else if (config.key) {
  45383. me.addBinding(config);
  45384. }
  45385. me.enable();
  45386. },
  45387. addBinding: function(binding) {
  45388. var me = this,
  45389. keyCode = binding.key,
  45390. i, len;
  45391. if (me.processing) {
  45392. me.bindings = me.bindings.slice(0);
  45393. }
  45394. if (Ext.isArray(binding)) {
  45395. for (i = 0 , len = binding.length; i < len; i++) {
  45396. me.addBinding(binding[i]);
  45397. }
  45398. return;
  45399. }
  45400. me.bindings.push(Ext.apply({
  45401. keyCode: me.processKeys(keyCode)
  45402. }, binding));
  45403. },
  45404. removeBinding: function(binding) {
  45405. var me = this,
  45406. bindings = me.bindings,
  45407. len = bindings.length,
  45408. i, item, keys;
  45409. if (me.processing) {
  45410. me.bindings = bindings.slice(0);
  45411. }
  45412. keys = me.processKeys(binding.key);
  45413. for (i = 0; i < len; i++) {
  45414. item = bindings[i];
  45415. if ((item.fn || item.handler) === (binding.fn || binding.handler) && item.scope === binding.scope) {
  45416. if (binding.alt === item.alt && binding.ctrl === item.ctrl && binding.shift === item.shift) {
  45417. if (Ext.Array.equals(item.keyCode, keys)) {
  45418. Ext.Array.erase(me.bindings, i, 1);
  45419. return;
  45420. }
  45421. }
  45422. }
  45423. }
  45424. },
  45425. processKeys: function(keyCode) {
  45426. var processed = false,
  45427. key, keys, keyString, len, i;
  45428. if (keyCode.test) {
  45429. return keyCode;
  45430. }
  45431. if (Ext.isString(keyCode)) {
  45432. keys = [];
  45433. keyString = keyCode.toUpperCase();
  45434. for (i = 0 , len = keyString.length; i < len; i++) {
  45435. keys.push(keyString.charCodeAt(i));
  45436. }
  45437. keyCode = keys;
  45438. processed = true;
  45439. }
  45440. if (!Ext.isArray(keyCode)) {
  45441. keyCode = [
  45442. keyCode
  45443. ];
  45444. }
  45445. if (!processed) {
  45446. for (i = 0 , len = keyCode.length; i < len; i++) {
  45447. key = keyCode[i];
  45448. if (Ext.isString(key)) {
  45449. keyCode[i] = key.toUpperCase().charCodeAt(0);
  45450. }
  45451. }
  45452. }
  45453. return keyCode;
  45454. },
  45455. handleTargetEvent: function(event) {
  45456. var me = this,
  45457. bindings, i, len, result;
  45458. if (me.enabled) {
  45459. bindings = me.bindings;
  45460. event = me.processEvent.apply(me.processEventScope || me, arguments);
  45461. if (event) {
  45462. me.lastKeyEvent = event;
  45463. if (me.ignoreInputFields && Ext.fly(event.target).isInputField()) {
  45464. return;
  45465. }
  45466. if (!event.getKey) {
  45467. return event;
  45468. }
  45469. me.processing = true;
  45470. for (i = 0 , len = bindings.length; i < len; i++) {
  45471. result = me.processBinding(bindings[i], event);
  45472. if (result === false) {
  45473. me.processing = false;
  45474. return result;
  45475. }
  45476. }
  45477. me.processing = false;
  45478. }
  45479. }
  45480. },
  45481. processEvent: Ext.identityFn,
  45482. processBinding: function(binding, event) {
  45483. if (this.checkModifiers(binding, event)) {
  45484. var key = event.getKey(),
  45485. handler = binding.fn || binding.handler,
  45486. scope = binding.scope || this,
  45487. keyCode = binding.keyCode,
  45488. defaultEventAction = binding.defaultEventAction,
  45489. i, len, result;
  45490. if (keyCode.test) {
  45491. if (keyCode.test(String.fromCharCode(event.getCharCode()))) {
  45492. result = handler.call(scope, key, event);
  45493. if (result !== true && defaultEventAction) {
  45494. event[defaultEventAction]();
  45495. }
  45496. if (result === false) {
  45497. return result;
  45498. }
  45499. }
  45500. }
  45501. else if (keyCode.length) {
  45502. for (i = 0 , len = keyCode.length; i < len; i++) {
  45503. if (key === keyCode[i]) {
  45504. result = handler.call(scope, key, event);
  45505. if (result !== true && defaultEventAction) {
  45506. event[defaultEventAction]();
  45507. }
  45508. if (result === false) {
  45509. return result;
  45510. }
  45511. break;
  45512. }
  45513. }
  45514. }
  45515. }
  45516. },
  45517. checkModifiers: function(binding, event) {
  45518. var keys = [
  45519. 'shift',
  45520. 'ctrl',
  45521. 'alt'
  45522. ],
  45523. i, len, val, key;
  45524. for (i = 0 , len = keys.length; i < len; i++) {
  45525. key = keys[i];
  45526. val = binding[key];
  45527. if (!(val === undefined || (val === event[key + 'Key']))) {
  45528. return false;
  45529. }
  45530. }
  45531. return true;
  45532. },
  45533. on: function(key, fn, scope) {
  45534. var keyCode, shift, ctrl, alt;
  45535. if (Ext.isObject(key) && !Ext.isArray(key)) {
  45536. keyCode = key.key;
  45537. shift = key.shift;
  45538. ctrl = key.ctrl;
  45539. alt = key.alt;
  45540. } else {
  45541. keyCode = key;
  45542. }
  45543. this.addBinding({
  45544. key: keyCode,
  45545. shift: shift,
  45546. ctrl: ctrl,
  45547. alt: alt,
  45548. fn: fn,
  45549. scope: scope
  45550. });
  45551. },
  45552. un: function(key, fn, scope) {
  45553. var keyCode, shift, ctrl, alt;
  45554. if (Ext.isObject(key) && !Ext.isArray(key)) {
  45555. keyCode = key.key;
  45556. shift = key.shift;
  45557. ctrl = key.ctrl;
  45558. alt = key.alt;
  45559. } else {
  45560. keyCode = key;
  45561. }
  45562. this.removeBinding({
  45563. key: keyCode,
  45564. shift: shift,
  45565. ctrl: ctrl,
  45566. alt: alt,
  45567. fn: fn,
  45568. scope: scope
  45569. });
  45570. },
  45571. isEnabled: function() {
  45572. return !!this.enabled;
  45573. },
  45574. enable: function() {
  45575. var me = this;
  45576. if (!me.enabled) {
  45577. me.target.on(me.eventName, me.handleTargetEvent, me, {
  45578. capture: me.capture,
  45579. priority: me.priority
  45580. });
  45581. me.enabled = true;
  45582. }
  45583. },
  45584. disable: function() {
  45585. var me = this;
  45586. if (me.enabled) {
  45587. if (!me.target.destroyed) {
  45588. me.target.removeListener(me.eventName, me.handleTargetEvent, me);
  45589. }
  45590. me.enabled = false;
  45591. }
  45592. },
  45593. setDisabled: function(disabled) {
  45594. if (disabled) {
  45595. this.disable();
  45596. } else {
  45597. this.enable();
  45598. }
  45599. },
  45600. destroy: function(removeTarget) {
  45601. var me = this,
  45602. target = me.target;
  45603. me.bindings = [];
  45604. me.disable();
  45605. me.target = null;
  45606. if (removeTarget) {
  45607. target.destroy();
  45608. Ext.raise("Using removeTarget argument in KeyMap destructor is not supported.");
  45609. }
  45610. me.callParent();
  45611. }
  45612. });
  45613. Ext.define('Ext.util.KeyNav', {
  45614. alternateClassName: 'Ext.KeyNav',
  45615. disabled: false,
  45616. defaultEventAction: false,
  45617. forceKeyDown: false,
  45618. eventName: 'keypress',
  45619. statics: {
  45620. keyOptions: {
  45621. left: 37,
  45622. right: 39,
  45623. up: 38,
  45624. down: 40,
  45625. space: 32,
  45626. pageUp: 33,
  45627. pageDown: 34,
  45628. del: 46,
  45629. backspace: 8,
  45630. home: 36,
  45631. end: 35,
  45632. enter: 13,
  45633. esc: 27,
  45634. tab: 9
  45635. }
  45636. },
  45637. constructor: function(config) {
  45638. var me = this,
  45639. keymapCfg, map;
  45640. if (arguments.length === 2) {
  45641. Ext.raise("2-argument KeyNav constructor is removed. Use a config object instead.");
  45642. }
  45643. config = config || {};
  45644. keymapCfg = {
  45645. target: config.target,
  45646. ignoreInputFields: config.ignoreInputFields,
  45647. eventName: me.getKeyEvent('forceKeyDown' in config ? config.forceKeyDown : me.forceKeyDown, config.eventName),
  45648. capture: config.capture
  45649. };
  45650. if (me.map) {
  45651. me.map.destroy();
  45652. }
  45653. me.initConfig(config);
  45654. if (config.processEvent) {
  45655. keymapCfg.processEvent = config.processEvent;
  45656. keymapCfg.processEventScope = config.processEventScope || me;
  45657. }
  45658. if (config.priority) {
  45659. keymapCfg.priority = config.priority;
  45660. }
  45661. if (config.keyMap) {
  45662. map = me.map = config.keyMap;
  45663. } else
  45664. {
  45665. map = me.map = new Ext.util.KeyMap(keymapCfg);
  45666. me.destroyKeyMap = true;
  45667. }
  45668. me.addBindings(config);
  45669. map.disable();
  45670. if (!config.disabled) {
  45671. map.enable();
  45672. }
  45673. },
  45674. addBindings: function(bindings) {
  45675. var me = this,
  45676. map = me.map,
  45677. keyCodes = Ext.util.KeyNav.keyOptions,
  45678. Event = Ext.event.Event,
  45679. defaultScope = bindings.scope || me,
  45680. binding, keyName, keyCode;
  45681. for (keyName in bindings) {
  45682. binding = bindings[keyName];
  45683. keyCode = keyName.length === 1 ? keyName.charCodeAt(0) : (keyCodes[keyName] || Event[keyName.toUpperCase()]);
  45684. if (keyCode != null) {
  45685. keyName = keyCode;
  45686. }
  45687. if (binding && (keyName.length === 1 || !isNaN(keyName = parseInt(keyName, 10)))) {
  45688. if (typeof binding === 'function') {
  45689. binding = {
  45690. handler: binding,
  45691. defaultEventAction: (bindings.defaultEventAction !== undefined) ? bindings.defaultEventAction : me.defaultEventAction
  45692. };
  45693. }
  45694. map.addBinding({
  45695. key: keyName,
  45696. ctrl: binding.ctrl,
  45697. shift: binding.shift,
  45698. alt: binding.alt,
  45699. handler: Ext.Function.bind(me.handleEvent, binding.scope || defaultScope, [
  45700. binding.handler || binding.fn,
  45701. me
  45702. ], true),
  45703. defaultEventAction: (binding.defaultEventAction !== undefined) ? binding.defaultEventAction : me.defaultEventAction
  45704. });
  45705. }
  45706. }
  45707. },
  45708. handleEvent: function(keyCode, event, handler, keyNav) {
  45709. keyNav.lastKeyEvent = event;
  45710. return handler.call(this, event);
  45711. },
  45712. destroy: function(removeEl) {
  45713. var me = this;
  45714. if (removeEl) {
  45715. Ext.raise("removeEl argument in KeyNav destructor is not supported anymore.");
  45716. }
  45717. if (me.destroyKeyMap) {
  45718. me.map.destroy(removeEl);
  45719. }
  45720. me.map = null;
  45721. me.callParent();
  45722. },
  45723. enable: function() {
  45724. if (this.map) {
  45725. this.map.enable();
  45726. this.disabled = false;
  45727. }
  45728. },
  45729. disable: function() {
  45730. if (this.map) {
  45731. this.map.disable();
  45732. }
  45733. this.disabled = true;
  45734. },
  45735. setDisabled: function(disabled) {
  45736. this.map.setDisabled(disabled);
  45737. this.disabled = disabled;
  45738. },
  45739. isEnabled: function() {
  45740. return !this.disabled;
  45741. },
  45742. getKeyEvent: function(forceKeyDown, configuredEventName) {
  45743. if (forceKeyDown || (Ext.supports.SpecialKeyDownRepeat && !configuredEventName)) {
  45744. return 'keydown';
  45745. } else {
  45746. return configuredEventName || this.eventName;
  45747. }
  45748. }
  45749. });
  45750. Ext.define('Ext.mixin.FocusableContainer', {
  45751. extend: Ext.Mixin,
  45752. mixinConfig: {
  45753. id: 'focusablecontainer'
  45754. },
  45755. isFocusableContainer: true,
  45756. focusableContainer: false,
  45757. resetFocusPosition: false,
  45758. activeChildTabIndex: 0,
  45759. inactiveChildTabIndex: -1,
  45760. allowFocusingDisabledChildren: false,
  45761. focusableContainerEl: 'el',
  45762. privates: {
  45763. initFocusableContainer: function(clearChildren) {
  45764. var items, i, len;
  45765. if (this.focusableContainer) {
  45766. clearChildren = clearChildren != null ? clearChildren : true;
  45767. this.doInitFocusableContainer(clearChildren);
  45768. } else
  45769. {
  45770. items = this.getFocusables();
  45771. for (i = 0 , len = items.length; i < len; i++) {
  45772. items[i].ownerFocusableContainer = null;
  45773. }
  45774. }
  45775. },
  45776. doInitFocusableContainer: function(clearChildren) {
  45777. var me = this,
  45778. el = me.focusableContainerEl,
  45779. child;
  45780. if (!el.isElement) {
  45781. el = me.focusableContainerEl = me[el];
  45782. }
  45783. if (me.initFocusableContainerKeyNav) {
  45784. me.initFocusableContainerKeyNav(el);
  45785. }
  45786. if (clearChildren) {
  45787. me.clearFocusables();
  45788. if (!me.isDisabled()) {
  45789. child = me.findNextFocusableChild({
  45790. step: 1
  45791. }) || me.findNextFocusableChild({
  45792. beforeRender: true
  45793. });
  45794. if (child) {
  45795. me.activateFocusable(child);
  45796. }
  45797. }
  45798. }
  45799. child = me.findNextFocusableChild({
  45800. firstTabbable: true
  45801. });
  45802. me.activateFocusableContainer(!!child && !me.isDisabled());
  45803. },
  45804. initFocusableContainerKeyNav: function(el) {
  45805. var me = this;
  45806. if (!me.focusableKeyNav) {
  45807. el = el || me.focusableContainerEl;
  45808. me.focusableKeyNav = new Ext.util.KeyNav({
  45809. target: el,
  45810. disabled: true,
  45811. eventName: 'keydown',
  45812. processEvent: me.processFocusableContainerKeyEvent,
  45813. processEventScope: me,
  45814. scope: me,
  45815. tab: me.onFocusableContainerTabKey,
  45816. enter: {
  45817. handler: me.onFocusableContainerEnterKey,
  45818. ctrl: false,
  45819. shift: false,
  45820. alt: false
  45821. },
  45822. space: {
  45823. handler: me.onFocusableContainerSpaceKey,
  45824. ctrl: false,
  45825. shift: false,
  45826. alt: false
  45827. },
  45828. up: {
  45829. handler: me.onFocusableContainerUpKey,
  45830. ctrl: false,
  45831. shift: false,
  45832. alt: false
  45833. },
  45834. down: {
  45835. handler: me.onFocusableContainerDownKey,
  45836. ctrl: false,
  45837. shift: false,
  45838. alt: false
  45839. },
  45840. left: {
  45841. handler: me.onFocusableContainerLeftKey,
  45842. ctrl: false,
  45843. shift: false,
  45844. alt: false
  45845. },
  45846. right: {
  45847. handler: me.onFocusableContainerRightKey,
  45848. ctrl: false,
  45849. shift: false,
  45850. alt: false
  45851. }
  45852. });
  45853. }
  45854. },
  45855. destroyFocusableContainer: function() {
  45856. this.focusableKeyNav = Ext.destroy(this.focusableKeyNav);
  45857. },
  45858. activateFocusableContainer: function(enable) {
  45859. var keyNav = this.focusableKeyNav;
  45860. if (keyNav) {
  45861. keyNav.setDisabled(!enable);
  45862. }
  45863. },
  45864. isFocusableContainerActive: function() {
  45865. var keyNav = this.focusableKeyNav;
  45866. return keyNav ? !keyNav.disabled : false;
  45867. },
  45868. getFocusables: function() {
  45869. return this.items.items;
  45870. },
  45871. initDefaultFocusable: function() {
  45872. var me = this,
  45873. haveFocusable = false,
  45874. items, item, i, len;
  45875. items = me.getFocusables();
  45876. len = items.length;
  45877. if (!len) {
  45878. return;
  45879. }
  45880. for (i = 0; i < len; i++) {
  45881. item = items[i];
  45882. if (!item.isDisabled() && item.isFocusable()) {
  45883. haveFocusable = true;
  45884. break;
  45885. }
  45886. }
  45887. if (!haveFocusable) {
  45888. return;
  45889. }
  45890. item = me.findNextFocusableChild({
  45891. items: items,
  45892. step: true
  45893. });
  45894. if (item) {
  45895. me.activateFocusable(item);
  45896. }
  45897. return item;
  45898. },
  45899. clearFocusables: function(skipFocused) {
  45900. var me = this,
  45901. items = me.getFocusables(),
  45902. len = items.length,
  45903. item, i;
  45904. for (i = 0; i < len; i++) {
  45905. item = items[i];
  45906. if (!item.destroyed && item.focusable && item.isTabbable()) {
  45907. me.deactivateFocusable(item);
  45908. }
  45909. }
  45910. },
  45911. processFocusableContainerKeyEvent: function(e) {
  45912. if (!Ext.fly(e.target).isInputField()) {
  45913. return e;
  45914. }
  45915. },
  45916. activateFocusable: function(child) {
  45917. child.setTabIndex(this.activeChildTabIndex);
  45918. },
  45919. deactivateFocusable: function(child) {
  45920. child.setTabIndex(this.inactiveChildTabIndex);
  45921. },
  45922. onFocusableContainerTabKey: function() {
  45923. return true;
  45924. },
  45925. onFocusableContainerEnterKey: function() {
  45926. return true;
  45927. },
  45928. onFocusableContainerSpaceKey: function() {
  45929. return true;
  45930. },
  45931. onFocusableContainerUpKey: function(e) {
  45932. e.preventDefault();
  45933. return this.moveChildFocus(e, false);
  45934. },
  45935. onFocusableContainerDownKey: function(e) {
  45936. e.preventDefault();
  45937. return this.moveChildFocus(e, true);
  45938. },
  45939. onFocusableContainerLeftKey: function(e) {
  45940. e.preventDefault();
  45941. return this.moveChildFocus(e, false);
  45942. },
  45943. onFocusableContainerRightKey: function(e) {
  45944. e.preventDefault();
  45945. return this.moveChildFocus(e, true);
  45946. },
  45947. getFocusableFromEvent: function(e) {
  45948. var child = Ext.Component.from(e);
  45949. if (!child) {
  45950. Ext.raise("No focusable child found for keyboard event!");
  45951. }
  45952. return child;
  45953. },
  45954. moveChildFocus: function(e, forward) {
  45955. var child = this.getFocusableFromEvent(e);
  45956. return this.focusChild(child, forward, e);
  45957. },
  45958. focusChild: function(child, forward) {
  45959. var nextChild = this.findNextFocusableChild({
  45960. child: child,
  45961. step: forward
  45962. });
  45963. if (nextChild) {
  45964. nextChild.focus();
  45965. }
  45966. return nextChild;
  45967. },
  45968. findNextFocusableChild: function(options) {
  45969. var beforeRender = options.beforeRender,
  45970. firstTabbable = options.firstTabbable,
  45971. items, item, child, step, idx, i, len, allowDisabled;
  45972. items = options.items || this.getFocusables();
  45973. step = options.step != null ? options.step : 1;
  45974. child = options.child;
  45975. allowDisabled = !!this.allowFocusingDisabledChildren;
  45976. idx = Ext.Array.indexOf(items, child);
  45977. step = step === true ? 1 : step === false ? -1 : step;
  45978. len = items.length;
  45979. i = step > 0 ? (idx < len ? idx + step : 0) : (idx > 0 ? idx + step : len - 1);
  45980. for (; ; i += step) {
  45981. if (idx < 0 && (i >= len || i < 0)) {
  45982. return null;
  45983. }
  45984. else if (i >= len) {
  45985. i = -1;
  45986. continue;
  45987. }
  45988. else if (i < 0) {
  45989. i = len;
  45990. continue;
  45991. }
  45992. else if (i === idx) {
  45993. return null;
  45994. }
  45995. item = items[i];
  45996. if (!item || !item.focusable || (item.isDisabled() && !allowDisabled)) {
  45997. continue;
  45998. }
  45999. if (firstTabbable) {
  46000. if (item.isTabbable && item.isTabbable()) {
  46001. return item;
  46002. }
  46003. }
  46004. else if (beforeRender || (item.isFocusable && item.isFocusable())) {
  46005. return item;
  46006. }
  46007. }
  46008. return null;
  46009. },
  46010. onFocusEnter: function(e) {
  46011. var me = this,
  46012. target = e.toComponent,
  46013. child;
  46014. if (target === me) {
  46015. child = me.initDefaultFocusable();
  46016. if (child) {
  46017. child.focus();
  46018. }
  46019. }
  46020. me.activateFocusableContainer(true);
  46021. },
  46022. onFocusLeave: function(e) {
  46023. var me = this;
  46024. if (me.resetFocusPosition) {
  46025. me.clearFocusables();
  46026. me.initDefaultFocusable();
  46027. }
  46028. },
  46029. beforeFocusableChildBlur: Ext.privateFn,
  46030. afterFocusableChildBlur: Ext.privateFn,
  46031. beforeFocusableChildFocus: function(child) {
  46032. var me = this;
  46033. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46034. return;
  46035. }
  46036. me.clearFocusables();
  46037. me.activateFocusable(child);
  46038. },
  46039. afterFocusableChildFocus: function(child) {
  46040. var me = this;
  46041. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46042. return;
  46043. }
  46044. me.lastFocusedChild = child;
  46045. },
  46046. onFocusableChildAdd: function(child) {
  46047. var me = this;
  46048. if (child.focusable) {
  46049. child.ownerFocusableContainer = me;
  46050. }
  46051. },
  46052. onFocusableChildRemove: function(child) {
  46053. var me = this,
  46054. next;
  46055. child.ownerFocusableContainer = null;
  46056. if (child === me.lastFocusedChild) {
  46057. me.lastFocusedChild = null;
  46058. next = me.initDefaultFocusable();
  46059. if (child.hasFocus) {
  46060. next = next || child.findFocusTarget();
  46061. if (next) {
  46062. next.focus();
  46063. }
  46064. }
  46065. }
  46066. child = next || me.findNextFocusableChild({
  46067. step: 1,
  46068. beforeRender: true
  46069. });
  46070. if (!child) {
  46071. me.activateFocusableContainer(false);
  46072. }
  46073. },
  46074. beforeFocusableChildEnable: Ext.privateFn,
  46075. onFocusableChildEnable: function(child) {
  46076. var me = this,
  46077. active;
  46078. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46079. return;
  46080. }
  46081. if (me.containsFocus) {
  46082. active = Ext.ComponentManager.getActiveComponent();
  46083. me.clearFocusables();
  46084. me.activateFocusable(active);
  46085. } else if (me.resetFocusPosition || me.lastFocusedChild == null) {
  46086. me.clearFocusables();
  46087. if (child.hasFocus) {
  46088. me.activateFocusable(child);
  46089. active = child;
  46090. }
  46091. } else {
  46092. me.deactivateFocusable(child);
  46093. if (child === me.lastFocusedChild) {
  46094. me.clearFocusables();
  46095. me.activateFocusable(child);
  46096. }
  46097. active = me.findNextFocusableChild({
  46098. firstTabbable: true
  46099. });
  46100. }
  46101. if (!active) {
  46102. me.initDefaultFocusable();
  46103. }
  46104. me.activateFocusableContainer(true);
  46105. },
  46106. beforeFocusableChildDisable: function(child) {
  46107. var me = this,
  46108. next;
  46109. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46110. return;
  46111. }
  46112. if (child.hasFocus) {
  46113. next = me.findNextFocusableChild({
  46114. child: child
  46115. }) || child.findFocusTarget();
  46116. if (next) {
  46117. next.focus();
  46118. }
  46119. }
  46120. },
  46121. onFocusableChildDisable: function(child) {
  46122. var me = this,
  46123. next;
  46124. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46125. return;
  46126. }
  46127. next = me.findNextFocusableChild({
  46128. firstTabbable: true
  46129. });
  46130. if (!next) {
  46131. next = me.initDefaultFocusable();
  46132. }
  46133. if (!next) {
  46134. me.activateFocusableContainer(false);
  46135. }
  46136. },
  46137. beforeFocusableChildHide: function(child) {
  46138. return this.beforeFocusableChildDisable(child);
  46139. },
  46140. onFocusableChildHide: function(child) {
  46141. return this.onFocusableChildDisable(child);
  46142. },
  46143. beforeFocusableChildShow: function(child) {
  46144. return this.beforeFocusableChildEnable(child);
  46145. },
  46146. onFocusableChildShow: function(child) {
  46147. return this.onFocusableChildEnable(child);
  46148. },
  46149. onFocusableChildMasked: Ext.privateFn,
  46150. onFocusableChildDestroy: Ext.privateFn,
  46151. onFocusableChildUpdate: Ext.privateFn
  46152. },
  46153. deprecated: {
  46154. 7: {
  46155. configs: {
  46156. enableFocusableContainer: 'focusableContainer'
  46157. }
  46158. }
  46159. }
  46160. });
  46161. Ext.define('Ext.mixin.Hookable', {
  46162. extend: Ext.Mixin,
  46163. mixinConfig: {
  46164. id: 'hookable'
  46165. },
  46166. bindHook: function(instance, boundMethod, bindingMethod, preventDefault, extraArgs) {
  46167. instance.afterMethod(boundMethod, bindingMethod || boundMethod, this, preventDefault, extraArgs);
  46168. return this;
  46169. },
  46170. unbindHook: function(instance, boundMethod, bindingMethod) {
  46171. instance.removeMethodListener(boundMethod, bindingMethod || boundMethod, this);
  46172. return this;
  46173. }
  46174. });
  46175. Ext.define('Ext.app.Profile', {
  46176. mixins: [
  46177. Ext.mixin.Observable
  46178. ],
  46179. isProfile: true,
  46180. config: {
  46181. mainView: {
  46182. $value: null,
  46183. lazy: true
  46184. },
  46185. application: null,
  46186. controllers: [],
  46187. models: [],
  46188. views: [],
  46189. stores: []
  46190. },
  46191. constructor: function(config) {
  46192. this.initConfig(config);
  46193. this.mixins.observable.constructor.apply(this, arguments);
  46194. },
  46195. isActive: function() {
  46196. return false;
  46197. },
  46198. init: function() {
  46199. var views = this.getViews(),
  46200. xtype;
  46201. if (views && !(views instanceof Array)) {
  46202. for (xtype in views) {
  46203. Ext.ClassManager.setXType(views[xtype], xtype);
  46204. }
  46205. }
  46206. },
  46207. launch: Ext.emptyFn,
  46208. onClassExtended: function(cls, data, hooks) {
  46209. var onBeforeClassCreated = hooks.onBeforeCreated;
  46210. hooks.onBeforeCreated = function(cls, data) {
  46211. var Controller = Ext.app.Controller,
  46212. className = cls.$className,
  46213. requires = [],
  46214. proto = cls.prototype,
  46215. views = data.views,
  46216. name, namespace;
  46217. name = data.name;
  46218. if (name) {
  46219. delete data.name;
  46220. } else {
  46221. name = className.split('.');
  46222. name = name[name.length - 1];
  46223. }
  46224. cls._name = name;
  46225. cls._namespace = name = (data.namespace || name).toLowerCase();
  46226. delete data.namespace;
  46227. namespace = Controller.resolveNamespace(cls, data);
  46228. Controller.processDependencies(proto, requires, namespace, 'model', data.models, name);
  46229. Controller.processDependencies(proto, requires, namespace, 'store', data.stores, name);
  46230. Controller.processDependencies(proto, requires, namespace, 'controller', data.controllers, name);
  46231. if (views) {
  46232. if (views instanceof Array) {
  46233. Controller.processDependencies(proto, requires, namespace, 'view', views, name);
  46234. } else {
  46235. Ext.app.Profile.processViews(className, views, requires);
  46236. }
  46237. }
  46238. Ext.require(requires, Ext.Function.pass(onBeforeClassCreated, arguments, this));
  46239. };
  46240. },
  46241. getName: function() {
  46242. return this.self._name;
  46243. },
  46244. getNamespace: function() {
  46245. return this.self._namespace;
  46246. },
  46247. privates: {
  46248. statics: {
  46249. processViews: function(className, views, requires) {
  46250. var body, cls, s, xtype;
  46251. for (xtype in views) {
  46252. cls = views[xtype];
  46253. if (typeof cls !== 'string') {
  46254. s = cls.xclass;
  46255. if (!s) {
  46256. Ext.raise('Views must specify an xclass');
  46257. }
  46258. body = Ext.apply({
  46259. extend: s
  46260. }, cls);
  46261. delete body.xclass;
  46262. Ext.define(views[xtype] = className + '$' + xtype, body);
  46263. cls = s;
  46264. }
  46265. requires.push(cls);
  46266. }
  46267. }
  46268. }
  46269. }
  46270. });
  46271. Ext.define('Ext.app.domain.View', {
  46272. extend: Ext.app.EventDomain,
  46273. isInstance: true,
  46274. constructor: function(controller) {
  46275. this.callParent([
  46276. controller
  46277. ]);
  46278. this.controller = controller;
  46279. this.monitoredClasses = [
  46280. Ext.Widget
  46281. ];
  46282. },
  46283. match: function(target, selector, controller) {
  46284. var out = false;
  46285. if (selector === '#') {
  46286. out = controller === target.getController();
  46287. } else {
  46288. out = target.is(selector);
  46289. }
  46290. return out;
  46291. },
  46292. destroy: function() {
  46293. this.controller = null;
  46294. this.callParent();
  46295. }
  46296. });
  46297. Ext.define('Ext.app.ViewController', {
  46298. extend: Ext.app.BaseController,
  46299. alias: 'controller.controller',
  46300. mixins: [
  46301. Ext.mixin.Factoryable
  46302. ],
  46303. isViewController: true,
  46304. factoryConfig: {
  46305. type: 'controller'
  46306. },
  46307. config: {
  46308. bindings: {
  46309. $value: null,
  46310. lazy: true
  46311. },
  46312. closeViewAction: 'destroy'
  46313. },
  46314. view: null,
  46315. constructor: function(config) {
  46316. this.compDomain = new Ext.app.domain.View(this);
  46317. this.callParent([
  46318. config
  46319. ]);
  46320. },
  46321. beforeInit: Ext.emptyFn,
  46322. init: Ext.emptyFn,
  46323. initViewModel: Ext.emptyFn,
  46324. destroy: function() {
  46325. var me = this,
  46326. domain = me.compDomain,
  46327. bind, b, key;
  46328. if (me.$hasBinds) {
  46329. bind = me.getBindings();
  46330. for (key in bind) {
  46331. b = bind[key];
  46332. if (b) {
  46333. b.destroy();
  46334. }
  46335. }
  46336. }
  46337. if (domain) {
  46338. domain.unlisten(me);
  46339. domain.destroy();
  46340. }
  46341. me.compDomain = me.view = null;
  46342. me.callParent();
  46343. },
  46344. closeView: function() {
  46345. var view = this.getView(),
  46346. action;
  46347. if (view) {
  46348. action = this.getCloseViewAction();
  46349. view[action]();
  46350. }
  46351. },
  46352. control: function(selectors, listeners) {
  46353. var obj = selectors;
  46354. if (Ext.isString(selectors)) {
  46355. obj = {};
  46356. obj[selectors] = listeners;
  46357. }
  46358. this.compDomain.listen(obj, this);
  46359. },
  46360. listen: function(to, controller) {
  46361. var component = to.component;
  46362. if (component) {
  46363. to = Ext.apply({}, to);
  46364. delete to.component;
  46365. this.control(component);
  46366. }
  46367. this.callParent([
  46368. to,
  46369. controller
  46370. ]);
  46371. },
  46372. applyId: function(id) {
  46373. if (!id) {
  46374. id = Ext.id(null, 'controller-');
  46375. }
  46376. return id;
  46377. },
  46378. getReferences: function() {
  46379. var view = this.view;
  46380. return view && view.getReferences();
  46381. },
  46382. getView: function() {
  46383. return this.view;
  46384. },
  46385. lookup: function(key) {
  46386. var view = this.view;
  46387. return view && view.lookup(key);
  46388. },
  46389. lookupReference: function(key) {
  46390. return this.lookup(key);
  46391. },
  46392. getSession: function() {
  46393. var view = this.view;
  46394. return view && view.lookupSession();
  46395. },
  46396. getViewModel: function() {
  46397. var view = this.view;
  46398. return view && view.lookupViewModel();
  46399. },
  46400. getStore: function(name) {
  46401. var viewModel = this.getViewModel();
  46402. return viewModel ? viewModel.getStore(name) : null;
  46403. },
  46404. fireViewEvent: function(eventName, args) {
  46405. var view = this.view,
  46406. result = false,
  46407. a = arguments;
  46408. if (view) {
  46409. if (view !== args) {
  46410. a = Ext.Array.slice(a);
  46411. a.splice(1, 0, view);
  46412. }
  46413. result = view.fireEvent.apply(view, a);
  46414. }
  46415. return result;
  46416. },
  46417. applyBindings: function(bindings) {
  46418. if (!bindings) {
  46419. return null;
  46420. }
  46421. var me = this,
  46422. viewModel = me.getViewModel(),
  46423. getBindTemplateScope = me.getBindTemplateScope(),
  46424. b, fn, descriptor;
  46425. me.$hasBinds = true;
  46426. if (!viewModel) {
  46427. Ext.raise('Cannot use bind config without a viewModel');
  46428. }
  46429. for (fn in bindings) {
  46430. descriptor = bindings[fn];
  46431. b = null;
  46432. if (descriptor) {
  46433. b = viewModel.bind(descriptor, fn, me);
  46434. b.getTemplateScope = getBindTemplateScope;
  46435. }
  46436. bindings[fn] = b;
  46437. }
  46438. return bindings;
  46439. },
  46440. privates: {
  46441. view: null,
  46442. attachReference: function(component) {
  46443. var view = this.view;
  46444. if (view) {
  46445. view.attachReference(component);
  46446. }
  46447. },
  46448. getBindTemplateScope: function() {
  46449. return this.scope;
  46450. },
  46451. initBindings: function() {
  46452. this.getBindings();
  46453. },
  46454. setView: function(view) {
  46455. this.view = view;
  46456. if (!this.beforeInit.$nullFn) {
  46457. this.beforeInit(view);
  46458. }
  46459. }
  46460. }
  46461. });
  46462. Ext.define('Ext.util.Scheduler', {
  46463. mixins: [
  46464. Ext.mixin.Observable
  46465. ],
  46466. busyCounter: 0,
  46467. lastBusyCounter: 0,
  46468. destroyed: false,
  46469. firing: null,
  46470. notifyIndex: -1,
  46471. nextId: 0,
  46472. orderedItems: null,
  46473. passes: 0,
  46474. scheduledCount: 0,
  46475. validIdRe: null,
  46476. config: {
  46477. cycleLimit: 5,
  46478. preSort: null,
  46479. tickDelay: 5
  46480. },
  46481. suspendOnNotify: true,
  46482. constructor: function(config) {
  46483. if (Ext.util.Scheduler.instances) {
  46484. Ext.util.Scheduler.instances.push(this);
  46485. } else {
  46486. Ext.util.Scheduler.instances = [
  46487. this
  46488. ];
  46489. }
  46490. this.id = Ext.util.Scheduler.count = (Ext.util.Scheduler.count || 0) + 1;
  46491. this.mixins.observable.constructor.call(this, config);
  46492. this.items = new Ext.util.Bag();
  46493. },
  46494. destroy: function() {
  46495. var me = this,
  46496. timer = me.timer;
  46497. if (timer) {
  46498. window.clearTimeout(timer);
  46499. me.timer = null;
  46500. }
  46501. me.items.destroy();
  46502. me.items = me.orderedItems = null;
  46503. me.callParent();
  46504. Ext.Array.remove(Ext.util.Scheduler.instances, this);
  46505. },
  46506. add: function(item) {
  46507. var me = this,
  46508. items = me.items;
  46509. if (items === me.firing) {
  46510. me.items = items = items.clone();
  46511. }
  46512. item.id = item.id || ++me.nextId;
  46513. item.scheduler = me;
  46514. items.add(item);
  46515. if (!me.sortMap) {
  46516. me.orderedItems = null;
  46517. }
  46518. },
  46519. remove: function(item) {
  46520. var me = this,
  46521. items = me.items;
  46522. if (me.destroyed) {
  46523. return;
  46524. }
  46525. if (me.sortMap) {
  46526. Ext.raise('Items cannot be removed during sort');
  46527. }
  46528. if (items === me.firing) {
  46529. me.items = items = items.clone();
  46530. }
  46531. if (item.scheduled) {
  46532. me.unscheduleItem(item);
  46533. item.scheduled = false;
  46534. }
  46535. items.remove(item);
  46536. me.orderedItems = null;
  46537. },
  46538. sort: function() {
  46539. var me = this,
  46540. items = me.items,
  46541. sortMap = {},
  46542. preSort = me.getPreSort(),
  46543. i, item;
  46544. me.orderedItems = [];
  46545. me.sortMap = sortMap;
  46546. me.sortStack = [];
  46547. if (preSort) {
  46548. items.sort(preSort);
  46549. }
  46550. items = items.items;
  46551. for (i = 0; i < items.length; ++i) {
  46552. item = items[i];
  46553. if (!sortMap[item.id]) {
  46554. me.sortItem(item);
  46555. }
  46556. }
  46557. me.sortMap = null;
  46558. me.sortStack = null;
  46559. },
  46560. sortItem: function(item) {
  46561. var me = this,
  46562. sortMap = me.sortMap,
  46563. orderedItems = me.orderedItems,
  46564. itemId;
  46565. if (!item.scheduler) {
  46566. me.add(item);
  46567. }
  46568. itemId = item.id;
  46569. if (item.scheduler !== me) {
  46570. Ext.raise('Item ' + itemId + ' belongs to another Scheduler');
  46571. }
  46572. me.sortStack.push(item);
  46573. if (sortMap[itemId] === 0) {
  46574. for (var cycle = [],
  46575. i = 0; i < me.sortStack.length; ++i) {
  46576. cycle[i] = me.sortStack[i].getFullName();
  46577. }
  46578. Ext.raise('Dependency cycle detected: ' + cycle.join('\n --> '));
  46579. }
  46580. if (!(itemId in sortMap)) {
  46581. sortMap[itemId] = 0;
  46582. if (!item.sort.$nullFn) {
  46583. item.sort();
  46584. }
  46585. sortMap[itemId] = 1;
  46586. item.order = me.orderedItems.length;
  46587. orderedItems.push(item);
  46588. }
  46589. me.sortStack.pop();
  46590. return me;
  46591. },
  46592. sortItems: function(items) {
  46593. var me = this,
  46594. sortItem = me.sortItem;
  46595. if (items) {
  46596. if (items instanceof Array) {
  46597. Ext.each(items, sortItem, me);
  46598. } else {
  46599. Ext.Object.eachValue(items, sortItem, me);
  46600. }
  46601. }
  46602. return me;
  46603. },
  46604. applyPreSort: function(preSort) {
  46605. if (typeof preSort === 'function') {
  46606. return preSort;
  46607. }
  46608. var parts = preSort.split(','),
  46609. direction = [],
  46610. length = parts.length,
  46611. c, i, s;
  46612. for (i = 0; i < length; ++i) {
  46613. direction[i] = 1;
  46614. s = parts[i];
  46615. if ((c = s.charAt(0)) === '-') {
  46616. direction[i] = -1;
  46617. } else if (c !== '+') {
  46618. c = 0;
  46619. }
  46620. if (c) {
  46621. parts[i] = s.substring(1);
  46622. }
  46623. }
  46624. return function(lhs, rhs) {
  46625. var ret = 0,
  46626. i, prop, v1, v2;
  46627. for (i = 0; !ret && i < length; ++i) {
  46628. prop = parts[i];
  46629. v1 = lhs[prop];
  46630. v2 = rhs[prop];
  46631. ret = direction[i] * ((v1 < v2) ? -1 : ((v2 < v1) ? 1 : 0));
  46632. }
  46633. return ret;
  46634. };
  46635. },
  46636. notify: function() {
  46637. var me = this,
  46638. timer = me.timer,
  46639. cyclesLeft = me.getCycleLimit(),
  46640. globalEvents = Ext.GlobalEvents,
  46641. suspend = me.suspendOnNotify,
  46642. busyCounter, i, item, len, queue, firedEvent;
  46643. if (timer) {
  46644. window.clearTimeout(timer);
  46645. me.timer = null;
  46646. }
  46647. if (!me.firing && me.scheduledCount) {
  46648. if (suspend) {
  46649. Ext.suspendLayouts();
  46650. }
  46651. while (me.scheduledCount) {
  46652. if (cyclesLeft) {
  46653. --cyclesLeft;
  46654. } else {
  46655. me.firing = null;
  46656. if (me.onCycleLimitExceeded) {
  46657. me.onCycleLimitExceeded();
  46658. }
  46659. break;
  46660. }
  46661. if (!firedEvent) {
  46662. firedEvent = true;
  46663. if (globalEvents.hasListeners.beforebindnotify) {
  46664. globalEvents.fireEvent('beforebindnotify', me);
  46665. }
  46666. }
  46667. ++me.passes;
  46668. if (!(queue = me.orderedItems)) {
  46669. me.sort();
  46670. queue = me.orderedItems;
  46671. }
  46672. len = queue.length;
  46673. if (len) {
  46674. me.firing = me.items;
  46675. for (i = 0; i < len; ++i) {
  46676. item = queue[i];
  46677. if (item.scheduled) {
  46678. item.scheduled = false;
  46679. --me.scheduledCount;
  46680. me.notifyIndex = i;
  46681. item.react();
  46682. if (!me.scheduledCount) {
  46683. break;
  46684. }
  46685. }
  46686. }
  46687. }
  46688. }
  46689. me.firing = null;
  46690. me.notifyIndex = -1;
  46691. if (suspend) {
  46692. Ext.resumeLayouts(true);
  46693. }
  46694. }
  46695. if ((busyCounter = me.busyCounter) !== me.lastBusyCounter) {
  46696. if (!(me.lastBusyCounter = busyCounter)) {
  46697. me.fireEvent('idle', me);
  46698. }
  46699. }
  46700. },
  46701. onTick: function() {
  46702. this.timer = null;
  46703. this.notify();
  46704. },
  46705. scheduleItem: function(item) {
  46706. var me = this;
  46707. ++me.scheduledCount;
  46708. if (!me.timer && !me.firing) {
  46709. me.scheduleTick();
  46710. }
  46711. },
  46712. scheduleTick: function() {
  46713. var me = this;
  46714. if (!me.destroyed && !me.timer) {
  46715. me.timer = Ext.defer(me.onTick, me.getTickDelay(), me);
  46716. }
  46717. },
  46718. unscheduleItem: function(item) {
  46719. if (this.scheduledCount) {
  46720. --this.scheduledCount;
  46721. }
  46722. },
  46723. adjustBusy: function(adjustment) {
  46724. var me = this,
  46725. busyCounter = me.busyCounter + adjustment;
  46726. me.busyCounter = busyCounter;
  46727. if (busyCounter) {
  46728. if (!me.lastBusyCounter) {
  46729. me.lastBusyCounter = busyCounter;
  46730. me.fireEvent('busy', me);
  46731. }
  46732. } else if (me.lastBusyCounter && !me.timer) {
  46733. me.scheduleTick();
  46734. }
  46735. },
  46736. isBusy: function() {
  46737. return !this.isIdle();
  46738. },
  46739. isIdle: function() {
  46740. return !(this.busyCounter + this.lastBusyCounter);
  46741. },
  46742. debugHooks: {
  46743. $enabled: false,
  46744. onCycleLimitExceeded: function() {
  46745. Ext.raise('Exceeded cycleLimit ' + this.getCycleLimit());
  46746. },
  46747. scheduleItem: function(item) {
  46748. if (!item) {
  46749. Ext.raise('scheduleItem: Invalid argument');
  46750. }
  46751. Ext.log('Schedule item: ' + item.getFullName() + ' - ' + (this.scheduledCount + 1));
  46752. if (item.order <= this.notifyIndex) {
  46753. Ext.log.warn('Suboptimal order: ' + item.order + ' < ' + this.notifyIndex);
  46754. }
  46755. this.callParent([
  46756. item
  46757. ]);
  46758. },
  46759. unscheduleItem: function(item) {
  46760. if (!this.scheduledCount) {
  46761. Ext.raise('Invalid scheduleCount');
  46762. }
  46763. this.callParent([
  46764. item
  46765. ]);
  46766. Ext.log('Unschedule item: ' + item.getFullName() + ' - ' + this.scheduledCount);
  46767. }
  46768. }
  46769. });
  46770. Ext.define('Ext.data.Batch', {
  46771. mixins: {
  46772. observable: Ext.mixin.Observable
  46773. },
  46774. config: {
  46775. pauseOnException: false
  46776. },
  46777. current: -1,
  46778. total: 0,
  46779. running: false,
  46780. complete: false,
  46781. exception: false,
  46782. constructor: function(config) {
  46783. var me = this;
  46784. me.mixins.observable.constructor.call(me, config);
  46785. me.operations = [];
  46786. me.exceptions = [];
  46787. },
  46788. add: function(operation) {
  46789. var me = this,
  46790. i, len;
  46791. if (Ext.isArray(operation)) {
  46792. for (i = 0 , len = operation.length; i < len; ++i) {
  46793. me.add(operation[i]);
  46794. }
  46795. } else {
  46796. me.total++;
  46797. operation.setBatch(me);
  46798. me.operations.push(operation);
  46799. }
  46800. return me;
  46801. },
  46802. sort: function() {
  46803. this.operations.sort(this.sortFn);
  46804. },
  46805. sortFn: function(operation1, operation2) {
  46806. var ret = operation1.order - operation2.order;
  46807. if (ret) {
  46808. return ret;
  46809. }
  46810. var entityType1 = operation1.entityType,
  46811. entityType2 = operation2.entityType,
  46812. rank;
  46813. if (!entityType1 || !entityType2) {
  46814. return 0;
  46815. }
  46816. if (!(rank = entityType1.rank)) {
  46817. entityType1.schema.rankEntities();
  46818. rank = entityType1.rank;
  46819. }
  46820. return (rank - entityType2.rank) * operation1.foreignKeyDirection;
  46821. },
  46822. start: function(index) {
  46823. var me = this;
  46824. if (me.destroyed || !me.operations.length || me.running) {
  46825. return me;
  46826. }
  46827. me.exceptions.length = 0;
  46828. me.exception = false;
  46829. me.running = true;
  46830. return me.runOperation(Ext.isDefined(index) ? index : me.current + 1);
  46831. },
  46832. abort: function() {
  46833. var me = this,
  46834. op;
  46835. if (me.running) {
  46836. op = me.getCurrent();
  46837. if (!op.destroyed) {
  46838. op.abort();
  46839. }
  46840. }
  46841. me.running = false;
  46842. me.aborted = true;
  46843. me.current = undefined;
  46844. },
  46845. retry: function() {
  46846. return this.start(this.current);
  46847. },
  46848. runNextOperation: function() {
  46849. var me = this;
  46850. if (me.running) {
  46851. me.runOperation(me.current + 1);
  46852. }
  46853. return me;
  46854. },
  46855. pause: function() {
  46856. this.running = false;
  46857. return this;
  46858. },
  46859. getOperations: function() {
  46860. return this.operations;
  46861. },
  46862. getExceptions: function() {
  46863. return this.exceptions;
  46864. },
  46865. getCurrent: function() {
  46866. var out = null,
  46867. current = this.current;
  46868. if (!(current === -1 || this.complete)) {
  46869. out = this.operations[current];
  46870. }
  46871. return out;
  46872. },
  46873. getTotal: function() {
  46874. return this.total;
  46875. },
  46876. isRunning: function() {
  46877. return this.running;
  46878. },
  46879. isComplete: function() {
  46880. return this.complete;
  46881. },
  46882. hasException: function() {
  46883. return this.exception;
  46884. },
  46885. runOperation: function(index) {
  46886. var me = this,
  46887. operations = me.operations,
  46888. operation = operations[index];
  46889. if (operation === undefined) {
  46890. me.running = false;
  46891. me.complete = true;
  46892. me.fireEvent('complete', me, operations[operations.length - 1]);
  46893. } else {
  46894. me.current = index;
  46895. operation.setInternalCallback(me.onOperationComplete);
  46896. operation.setInternalScope(me);
  46897. operation.execute();
  46898. }
  46899. return me;
  46900. },
  46901. onOperationComplete: function(operation) {
  46902. var me = this,
  46903. exception = operation.hasException();
  46904. if (exception) {
  46905. me.exception = true;
  46906. me.exceptions.push(operation);
  46907. me.fireEvent('exception', me, operation);
  46908. }
  46909. if (exception && me.getPauseOnException()) {
  46910. me.pause();
  46911. } else {
  46912. me.fireEvent('operationcomplete', me, operation);
  46913. me.runNextOperation();
  46914. }
  46915. },
  46916. destroy: function() {
  46917. var me = this,
  46918. operations = me.operations,
  46919. op, i, len;
  46920. if (me.running) {
  46921. me.abort();
  46922. }
  46923. for (i = 0 , len = me.operations.length; i < len; i++) {
  46924. op = operations[i];
  46925. if (op) {
  46926. if (!op.destroyed && !op.$destroyOwner) {
  46927. op.destroy();
  46928. }
  46929. op[i] = null;
  46930. }
  46931. }
  46932. me.operations = me.exceptions = null;
  46933. me.callParent();
  46934. }
  46935. });
  46936. Ext.define('Ext.data.matrix.Slice', {
  46937. constructor: function(side, id) {
  46938. this.id = id;
  46939. this.side = side;
  46940. this.members = {};
  46941. },
  46942. attach: function(store) {
  46943. var me = this;
  46944. Ext.Assert.falsey(me.store, 'Store is already attached');
  46945. me.store = store;
  46946. store.matrix = me;
  46947. store.on('load', me.onStoreLoad, me, {
  46948. single: true
  46949. });
  46950. },
  46951. commit: function() {
  46952. var members = this.members,
  46953. id;
  46954. for (id in members) {
  46955. members[id][2] = 0;
  46956. }
  46957. },
  46958. onStoreLoad: function(store) {
  46959. this.update(store.getData().items, 0);
  46960. },
  46961. update: function(recordsOrIds, state) {
  46962. if (!(recordsOrIds instanceof Array)) {
  46963. Ext.raise('Only array of records or record ids are supported');
  46964. }
  46965. var me = this,
  46966. MatrixSlice = Ext.data.matrix.Slice,
  46967. side = me.side,
  46968. assocIndex = side.index,
  46969. length = recordsOrIds.length,
  46970. id = me.id,
  46971. members = me.members,
  46972. otherSide = side.inverse,
  46973. otherSlices = otherSide.slices,
  46974. assoc, call, i, item, otherId, otherSlice, record;
  46975. for (i = 0; i < length; ++i) {
  46976. call = record = null;
  46977. item = recordsOrIds[i];
  46978. otherId = item.isEntity ? (record = item).id : item;
  46979. assoc = members[otherId];
  46980. if (state < 0 && assoc && assoc[2] === 1) {
  46981. delete members[otherId];
  46982. otherSlice = otherSlices[otherId];
  46983. if (otherSlice) {
  46984. delete otherSlice.members[id];
  46985. }
  46986. call = 1;
  46987. } else {
  46988. if (!assoc) {
  46989. assoc = [
  46990. otherId,
  46991. otherId,
  46992. state
  46993. ];
  46994. assoc[assocIndex] = id;
  46995. members[otherId] = assoc;
  46996. otherSlice = otherSlices[otherId];
  46997. if (!otherSlice) {
  46998. otherSlices[otherId] = otherSlice = new MatrixSlice(otherSide, otherId);
  46999. }
  47000. otherSlice.members[id] = assoc;
  47001. call = 1;
  47002. } else if (state !== assoc[2] && state !== 0 && !(state === 1 && assoc[2] === 0)) {
  47003. assoc[2] = state;
  47004. otherSlice = otherSlices[otherId];
  47005. call = 1;
  47006. }
  47007. }
  47008. if (call) {
  47009. if (me.notify) {
  47010. me.notify.call(me.scope, me, otherId, state);
  47011. }
  47012. if (otherSlice && otherSlice.notify) {
  47013. otherSlice.notify.call(otherSlice.scope, otherSlice, id, state);
  47014. }
  47015. }
  47016. }
  47017. },
  47018. updateId: function(newId) {
  47019. var me = this,
  47020. oldId = me.id,
  47021. side = me.side,
  47022. slices = side.slices,
  47023. slice = slices[oldId],
  47024. members = slice.members,
  47025. index = side.index,
  47026. otherSlices = side.inverse.slices,
  47027. assoc, otherId, otherMembers;
  47028. me.id = newId;
  47029. slices[newId] = slice;
  47030. delete slices[oldId];
  47031. for (otherId in members) {
  47032. assoc = members[otherId];
  47033. assoc[index] = newId;
  47034. otherMembers = otherSlices[otherId].members;
  47035. otherMembers[newId] = otherMembers[oldId];
  47036. delete otherMembers[oldId];
  47037. }
  47038. },
  47039. destroy: function() {
  47040. var me = this,
  47041. store = me.store;
  47042. if (store) {
  47043. store.matrix = null;
  47044. store.un('load', me.onStoreLoad, me);
  47045. }
  47046. me.notify = me.scope = me.store = me.side = me.members = null;
  47047. me.callParent();
  47048. }
  47049. });
  47050. Ext.define('Ext.data.matrix.Side', {
  47051. constructor: function(matrix, index, role) {
  47052. var me = this;
  47053. me.matrix = matrix;
  47054. me.index = index;
  47055. me.role = role;
  47056. me.slices = {};
  47057. },
  47058. commit: function() {
  47059. var slices = this.slices,
  47060. id;
  47061. for (id in slices) {
  47062. slices[id].commit();
  47063. }
  47064. },
  47065. get: function(id1, id2) {
  47066. var me = this,
  47067. slices = me.slices,
  47068. slice = slices[id1] || (slices[id1] = new Ext.data.matrix.Slice(me, id1));
  47069. return (id2 || id2 === 0) ? slice.members[id2] : slice;
  47070. },
  47071. update: function(id1, id2, state) {
  47072. var slice = this.get(id1);
  47073. return slice.update(id2, state);
  47074. },
  47075. updateId: function(oldId, newId) {
  47076. var slice = this.get(oldId);
  47077. if (slice) {
  47078. slice.updateId(newId);
  47079. }
  47080. },
  47081. destroy: function() {
  47082. var me = this,
  47083. slices = me.slices,
  47084. id;
  47085. for (id in slices) {
  47086. slices[id].destroy();
  47087. }
  47088. me.inverse = me.matrix = me.role = me.slices = null;
  47089. me.callParent();
  47090. }
  47091. });
  47092. Ext.define('Ext.data.matrix.Matrix', {
  47093. constructor: function(session, matrix) {
  47094. var me = this,
  47095. association = matrix.isManyToMany ? matrix : session.getSchema().getAssociation(matrix),
  47096. Side = Ext.data.matrix.Side,
  47097. left = new Side(me, 0, association.left),
  47098. right = new Side(me, 1, association.right);
  47099. Ext.Assert.truthy(association.isManyToMany, 'Association is not many-to-many');
  47100. me.association = association;
  47101. me.session = session;
  47102. me.left = left;
  47103. me.right = right;
  47104. left.inverse = right;
  47105. right.inverse = left;
  47106. },
  47107. commit: function() {
  47108. this.left.commit();
  47109. this.right.commit();
  47110. },
  47111. update: function(id1, id2, state) {
  47112. return this.left.update(id1, id2, state);
  47113. },
  47114. updateId: function(record, oldId, newId) {
  47115. var Type = record.self,
  47116. left = this.left,
  47117. right = this.right,
  47118. matchSide;
  47119. if (Type === left.role.cls) {
  47120. matchSide = left;
  47121. }
  47122. if (Type === right.role.cls) {
  47123. matchSide = right;
  47124. }
  47125. if (matchSide) {
  47126. matchSide.updateId(oldId, newId);
  47127. }
  47128. },
  47129. destroy: function() {
  47130. var me = this;
  47131. me.left.destroy();
  47132. me.right.destroy();
  47133. me.association = me.session = me.left = me.right = null;
  47134. me.callParent();
  47135. }
  47136. });
  47137. Ext.define('Ext.data.session.ChangesVisitor', {
  47138. constructor: function(session) {
  47139. var me = this,
  47140. crud;
  47141. me.session = session;
  47142. crud = session.getCrudProperties();
  47143. me.result = null;
  47144. me.writerOptions = {};
  47145. me.createKey = crud.create;
  47146. me.readKey = crud.read;
  47147. me.updateKey = crud.update;
  47148. me.dropKey = crud.drop;
  47149. },
  47150. onDirtyRecord: function(record) {
  47151. var me = this,
  47152. crud = me.crud,
  47153. created = record.phantom,
  47154. dropped = record.dropped,
  47155. type = record.$className,
  47156. prop = (created || dropped) ? 'allDataOptions' : 'partialDataOptions',
  47157. writerOptions = me.writerOptions,
  47158. name = record.entityName,
  47159. options, bucket, entry, result;
  47160. if (created && dropped) {
  47161. return false;
  47162. }
  47163. crud = created ? me.createKey : (dropped ? me.dropKey : me.updateKey);
  47164. writerOptions = writerOptions[type] || (writerOptions[type] = {});
  47165. if (dropped) {
  47166. if (!(options = writerOptions.drop)) {
  47167. writerOptions.drop = options = {
  47168. all: record.getProxy().getWriter().getWriteAllFields()
  47169. };
  47170. }
  47171. if (!options.all) {
  47172. entry = record.id;
  47173. }
  47174. }
  47175. if (!entry) {
  47176. if (!(options = writerOptions[prop])) {
  47177. options = record.getProxy().getWriter().getConfig(prop);
  47178. writerOptions[prop] = options = Ext.Object.chain(options);
  47179. me.setupOptions(options);
  47180. }
  47181. entry = record.getData(options);
  47182. }
  47183. result = me.result || (me.result = {});
  47184. bucket = result[name] || (result[name] = {});
  47185. bucket = bucket[crud] || (bucket[crud] = []);
  47186. bucket.push(entry);
  47187. },
  47188. setupOptions: function(options) {
  47189. options.serialize = true;
  47190. },
  47191. onMatrixChange: function(association, id1, id2, state) {
  47192. var me = this,
  47193. name = association.left.type,
  47194. assocName = association.right.role,
  47195. operation = state < 0 ? me.dropKey : me.createKey,
  47196. bucket, result;
  47197. result = me.result || (me.result = {});
  47198. bucket = result[name] || (result[name] = {});
  47199. bucket = bucket[assocName] || (bucket[assocName] = {});
  47200. bucket = bucket[operation] || (bucket[operation] = {});
  47201. bucket = bucket[id1] || (bucket[id1] = []);
  47202. bucket.push(id2);
  47203. }
  47204. });
  47205. Ext.define('Ext.data.session.ChildChangesVisitor', {
  47206. extend: Ext.data.session.ChangesVisitor,
  47207. constructor: function() {
  47208. this.seen = {};
  47209. this.callParent(arguments);
  47210. },
  47211. setupOptions: function(options) {
  47212. this.callParent([
  47213. options
  47214. ]);
  47215. options.serialize = false;
  47216. },
  47217. onDirtyRecord: function(record) {
  47218. if (this.callParent(arguments) !== false) {
  47219. if (!record.$source && (record.dropped || !record.phantom)) {
  47220. this.readEntity(record);
  47221. }
  47222. }
  47223. },
  47224. readEntity: function(record) {
  47225. var me = this,
  47226. readKey = me.readKey,
  47227. name = record.entityName,
  47228. id = record.id,
  47229. seen = me.seen,
  47230. seenKey = name + id,
  47231. result, bucket;
  47232. if (seen[seenKey]) {
  47233. return;
  47234. }
  47235. seen[seenKey] = true;
  47236. result = me.result || (me.result = {});
  47237. bucket = result[name] || (result[name] = {});
  47238. bucket = bucket[readKey] || (bucket[readKey] = []);
  47239. bucket.push(Ext.apply({}, record.modified, record.data));
  47240. }
  47241. });
  47242. Ext.define('Ext.data.session.BatchVisitor', {
  47243. map: null,
  47244. constructor: function(batch) {
  47245. this.batch = batch;
  47246. },
  47247. getBatch: function(sort) {
  47248. var map = this.map,
  47249. batch = this.batch,
  47250. bucket, entity, name, operation, operationType, proxy, batchActions, records, len, i;
  47251. if (map) {
  47252. if (!batch) {
  47253. batch = new Ext.data.Batch();
  47254. }
  47255. for (name in map) {
  47256. bucket = map[name];
  47257. entity = bucket.entity;
  47258. proxy = entity.getProxy();
  47259. batchActions = proxy.getBatchActions();
  47260. delete bucket.entity;
  47261. for (operationType in bucket) {
  47262. if (batchActions) {
  47263. operation = proxy.createOperation(operationType, {
  47264. records: bucket[operationType]
  47265. });
  47266. operation.entityType = entity;
  47267. batch.add(operation);
  47268. } else {
  47269. records = bucket[operationType];
  47270. for (i = 0 , len = records.length; i < len; ++i) {
  47271. operation = proxy.createOperation(operationType, {
  47272. records: [
  47273. records[i]
  47274. ]
  47275. });
  47276. operation.entityType = entity;
  47277. batch.add(operation);
  47278. }
  47279. }
  47280. }
  47281. }
  47282. }
  47283. if (batch && sort !== false) {
  47284. batch.sort();
  47285. }
  47286. return batch;
  47287. },
  47288. onDirtyRecord: function(record) {
  47289. var me = this,
  47290. operation = record.phantom ? 'create' : (record.dropped ? 'destroy' : 'update'),
  47291. name = record.$className,
  47292. map = (me.map || (me.map = {})),
  47293. bucket = (map[name] || (map[name] = {
  47294. entity: record.self
  47295. }));
  47296. bucket = bucket[operation] || (bucket[operation] = []);
  47297. bucket.push(record);
  47298. }
  47299. });
  47300. Ext.define('Ext.mixin.Dirty', {
  47301. mixinId: 'dirty',
  47302. config: {
  47303. dirty: {
  47304. $value: false,
  47305. lazy: true
  47306. }
  47307. },
  47308. dirty: false,
  47309. _dirtyRecordCount: 0,
  47310. ignoreDirty: false,
  47311. recordStateIsDirtyState: true,
  47312. isDirty: function() {
  47313. return this.getDirty();
  47314. },
  47315. applyDirty: function(dirty) {
  47316. return this.ignoreDirty ? false : dirty;
  47317. },
  47318. updateDirty: function(dirty) {
  47319. var me = this;
  47320. me.dirty = dirty;
  47321. if (me.fireEvent && !me.isDirtyInitializing) {
  47322. me.fireDirtyChange();
  47323. }
  47324. },
  47325. clearRecordStates: function() {
  47326. var me = this,
  47327. counters = me._crudCounters;
  47328. if (counters) {
  47329. counters.C = counters.U = counters.D = 0;
  47330. }
  47331. me._dirtyRecordCount = 0;
  47332. if (me.recordStateIsDirtyState) {
  47333. me.setDirty(false);
  47334. }
  47335. },
  47336. fireDirtyChange: function() {
  47337. var me = this;
  47338. if (!me.ignoreDirty && me.hasListeners.dirtychange) {
  47339. me.fireEvent('dirtychange', me, me.dirty);
  47340. }
  47341. },
  47342. trackRecordState: function(record, initial) {
  47343. var me = this,
  47344. counters = me._crudCounters || (me._crudCounters = {
  47345. C: 0,
  47346. R: 0,
  47347. U: 0,
  47348. D: 0
  47349. }),
  47350. dirtyRecordCountWas = me._dirtyRecordCount,
  47351. state = record.crudState,
  47352. stateWas = record.crudStateWas,
  47353. changed, dirtyRecordCount;
  47354. if (initial || state !== stateWas) {
  47355. if (!initial && stateWas) {
  47356. --counters[stateWas];
  47357. }
  47358. if (!(record.phantom && state === 'D')) {
  47359. ++counters[state];
  47360. }
  47361. me.checkCounters();
  47362. me._dirtyRecordCount = dirtyRecordCount = counters.C + counters.U + counters.D;
  47363. changed = !dirtyRecordCount !== !dirtyRecordCountWas;
  47364. if (changed && me.recordStateIsDirtyState) {
  47365. me.setDirty(dirtyRecordCount > 0);
  47366. }
  47367. }
  47368. return changed;
  47369. },
  47370. untrackRecordState: function(record) {
  47371. var me = this,
  47372. counters = me._crudCounters,
  47373. dirtyRecordCountWas = me._dirtyRecordCount,
  47374. state = record.crudState,
  47375. changed, dirtyRecordCount;
  47376. if (counters && state !== 'D' && !record.erased) {
  47377. --counters[state];
  47378. me.checkCounters();
  47379. me._dirtyRecordCount = dirtyRecordCount = counters.C + counters.U + counters.D;
  47380. changed = !dirtyRecordCount !== !dirtyRecordCountWas;
  47381. if (changed && me.recordStateIsDirtyState) {
  47382. me.setDirty(dirtyRecordCount > 0);
  47383. }
  47384. }
  47385. return changed;
  47386. },
  47387. checkCounters: function() {
  47388. var counters = this._crudCounters,
  47389. key;
  47390. for (key in counters) {
  47391. if (counters[key] < 0) {
  47392. Ext.raise('Invalid state for ' + key);
  47393. }
  47394. }
  47395. }
  47396. });
  47397. Ext.define('Ext.data.Session', {
  47398. mixins: [
  47399. Ext.mixin.Dirty,
  47400. Ext.mixin.Observable
  47401. ],
  47402. isSession: true,
  47403. config: {
  47404. schema: 'default',
  47405. parent: null,
  47406. autoDestroy: true,
  47407. crudProperties: {
  47408. create: 'C',
  47409. read: 'R',
  47410. update: 'U',
  47411. drop: 'D'
  47412. }
  47413. },
  47414. crudOperations: [
  47415. {
  47416. type: 'R',
  47417. entityMethod: 'readEntities'
  47418. },
  47419. {
  47420. type: 'C',
  47421. entityMethod: 'createEntities'
  47422. },
  47423. {
  47424. type: 'U',
  47425. entityMethod: 'updateEntities'
  47426. },
  47427. {
  47428. type: 'D',
  47429. entityMethod: 'dropEntities'
  47430. }
  47431. ],
  47432. crudKeys: {
  47433. C: 1,
  47434. R: 1,
  47435. U: 1,
  47436. D: 1
  47437. },
  47438. statics: {
  47439. nextId: 1
  47440. },
  47441. constructor: function(config) {
  47442. var me = this;
  47443. me.data = {};
  47444. me.matrices = {};
  47445. me.id = Ext.data.Session.nextId++;
  47446. me.identifierCache = {};
  47447. me.recordCreator = me.recordCreator.bind(me);
  47448. me.mixins.observable.constructor.call(me, config);
  47449. },
  47450. destroy: function() {
  47451. var me = this,
  47452. matrices = me.matrices,
  47453. data = me.data,
  47454. entityName, entities, record, id;
  47455. for (id in matrices) {
  47456. matrices[id].destroy();
  47457. }
  47458. for (entityName in data) {
  47459. entities = data[entityName];
  47460. for (id in entities) {
  47461. record = entities[id].record;
  47462. if (record) {
  47463. record.$source = null;
  47464. record.unjoin(me);
  47465. }
  47466. }
  47467. }
  47468. me.identifierCache = me.recordCreator = me.matrices = me.data = null;
  47469. me.setSchema(null);
  47470. me.callParent();
  47471. },
  47472. adopt: function(record) {
  47473. var me = this,
  47474. associations = record.associations,
  47475. roleName;
  47476. me.checkModelType(record.self);
  47477. if (record.session && record.session !== me) {
  47478. Ext.raise('Record already belongs to an existing session');
  47479. }
  47480. if (record.session !== me) {
  47481. me.add(record);
  47482. if (associations) {
  47483. for (roleName in associations) {
  47484. associations[roleName].adoptAssociated(record, me);
  47485. }
  47486. }
  47487. }
  47488. },
  47489. commit: function() {
  47490. var me = this,
  47491. data = me.data,
  47492. matrices = me.matrices,
  47493. dirtyWas = me.getDirty(),
  47494. entityName, entities, id, record;
  47495. me.suspendEvent('dirtychange');
  47496. for (entityName in data) {
  47497. entities = data[entityName];
  47498. for (id in entities) {
  47499. record = entities[id].record;
  47500. if (record) {
  47501. record.commit();
  47502. }
  47503. }
  47504. }
  47505. for (id in matrices) {
  47506. matrices[id].commit();
  47507. }
  47508. me.clearRecordStates();
  47509. me.resumeEvent('dirtychange');
  47510. if (me.getDirty() !== dirtyWas) {
  47511. me.fireDirtyChange();
  47512. }
  47513. },
  47514. createRecord: function(type, data, preventAdd) {
  47515. this.checkModelType(type);
  47516. var Model = type.$isClass ? type : this.getSchema().getEntity(type),
  47517. parent = this.getParent(),
  47518. id;
  47519. if (data && parent) {
  47520. id = Model.getIdFromData(data);
  47521. if (parent.peekRecord(Model, id)) {
  47522. Ext.raise('A parent session already contains an entry for ' + Model.entityName + ': ' + id);
  47523. }
  47524. }
  47525. return new Model(data, preventAdd ? null : this);
  47526. },
  47527. getChanges: function() {
  47528. var visitor = new Ext.data.session.ChangesVisitor(this);
  47529. this.visitData(visitor);
  47530. return visitor.result;
  47531. },
  47532. getChangesForParent: function() {
  47533. var visitor = new Ext.data.session.ChildChangesVisitor(this);
  47534. this.visitData(visitor);
  47535. return visitor.result;
  47536. },
  47537. getRecord: function(type, id, autoLoad) {
  47538. var me = this,
  47539. wasInstance = type.isModel,
  47540. record, Model, parent, parentRec;
  47541. if (wasInstance) {
  47542. wasInstance = type;
  47543. id = type.id;
  47544. type = type.self;
  47545. }
  47546. record = me.peekRecord(type, id);
  47547. if (!record) {
  47548. Model = type.$isClass ? type : me.getSchema().getEntity(type);
  47549. parent = me.getParent();
  47550. if (parent) {
  47551. parentRec = parent.peekRecord(Model, id);
  47552. }
  47553. if (parentRec) {
  47554. if (parentRec.isLoading()) {
  47555. wasInstance = false;
  47556. } else {
  47557. record = parentRec.copy(undefined, me);
  47558. record.$source = parentRec;
  47559. }
  47560. }
  47561. if (!record) {
  47562. if (wasInstance) {
  47563. record = wasInstance;
  47564. me.adopt(record);
  47565. } else {
  47566. record = Model.createWithId(id, null, me);
  47567. if (autoLoad !== false) {
  47568. record.load(Ext.isObject(autoLoad) ? autoLoad : undefined);
  47569. }
  47570. }
  47571. }
  47572. }
  47573. return record;
  47574. },
  47575. getSaveBatch: function(sort) {
  47576. var visitor = new Ext.data.session.BatchVisitor();
  47577. this.visitData(visitor);
  47578. return visitor.getBatch(sort);
  47579. },
  47580. onInvalidAssociationEntity: function(entityType, id) {
  47581. Ext.raise('Unable to read association entity: ' + this.getModelIdentifier(entityType, id));
  47582. },
  47583. onInvalidEntityCreate: function(entityType, id) {
  47584. Ext.raise('Cannot create, record already not exists: ' + this.getModelIdentifier(entityType, id));
  47585. },
  47586. onInvalidEntityDrop: function(entityType, id) {
  47587. Ext.raise('Cannot drop, record does not exist: ' + this.getModelIdentifier(entityType, id));
  47588. },
  47589. onInvalidEntityRead: function(entityType, id) {
  47590. Ext.raise('Cannot read, record already not exists: ' + this.getModelIdentifier(entityType, id));
  47591. },
  47592. onInvalidEntityUpdate: function(entityType, id, dropped) {
  47593. if (dropped) {
  47594. Ext.raise('Cannot update, record dropped: ' + this.getModelIdentifier(entityType, id));
  47595. } else {
  47596. Ext.raise('Cannot update, record does not exist: ' + this.getModelIdentifier(entityType, id));
  47597. }
  47598. },
  47599. peekRecord: function(type, id, deep) {
  47600. this.checkModelType(type);
  47601. var entityType = type.$isClass ? type : this.getSchema().getEntity(type),
  47602. entityName = entityType.entityName,
  47603. entry = this.data[entityName],
  47604. ret, parent;
  47605. entry = entry && entry[id];
  47606. ret = entry && entry.record;
  47607. if (!ret && deep) {
  47608. parent = this.getParent();
  47609. ret = parent && parent.peekRecord(type, id, deep);
  47610. }
  47611. return ret || null;
  47612. },
  47613. save: function() {
  47614. var me = this,
  47615. parent = me.getParent(),
  47616. visitor;
  47617. if (parent) {
  47618. visitor = new Ext.data.session.ChildChangesVisitor(me);
  47619. me.visitData(visitor);
  47620. parent.update(visitor.result);
  47621. me.commit();
  47622. } else
  47623. {
  47624. Ext.raise('Cannot commit session, no parent exists');
  47625. }
  47626. },
  47627. spawn: function() {
  47628. return new this.self({
  47629. schema: this.getSchema(),
  47630. parent: this
  47631. });
  47632. },
  47633. update: function(data) {
  47634. var me = this,
  47635. schema = me.getSchema(),
  47636. crudOperations = me.crudOperations,
  47637. len = crudOperations.length,
  47638. crudKeys = me.crudKeys,
  47639. dirtyWas = me.getDirty(),
  47640. entityName, entityType, entityInfo, i, operation, item, associations, key, role, associationData;
  47641. me.suspendEvent('dirtychange');
  47642. me.getSchema().processKeyChecks(true);
  47643. for (entityName in data) {
  47644. entityType = schema.getEntity(entityName);
  47645. if (!entityType) {
  47646. Ext.raise('Invalid entity type: ' + entityName);
  47647. }
  47648. entityInfo = data[entityName];
  47649. for (i = 0; i < len; ++i) {
  47650. operation = crudOperations[i];
  47651. item = entityInfo[operation.type];
  47652. if (item) {
  47653. me[operation.entityMethod](entityType, item);
  47654. }
  47655. }
  47656. }
  47657. for (entityName in data) {
  47658. entityType = schema.getEntity(entityName);
  47659. associations = entityType.associations;
  47660. entityInfo = data[entityName];
  47661. for (key in entityInfo) {
  47662. if (crudKeys[key]) {
  47663. continue;
  47664. }
  47665. role = associations[key];
  47666. if (!role) {
  47667. Ext.raise('Invalid association key for ' + entityName + ', "' + key + '"');
  47668. }
  47669. associationData = entityInfo[role.role];
  47670. role.processUpdate(me, associationData);
  47671. }
  47672. }
  47673. me.resumeEvent('dirtychange');
  47674. if (me.getDirty() !== dirtyWas) {
  47675. me.fireDirtyChange();
  47676. }
  47677. },
  47678. afterCommit: function(record) {
  47679. this.trackRecordState(record);
  47680. },
  47681. afterDrop: function(record) {
  47682. this.trackRecordState(record);
  47683. },
  47684. afterEdit: function(record) {
  47685. this.trackRecordState(record);
  47686. },
  47687. afterErase: function(record) {
  47688. this.evict(record);
  47689. },
  47690. afterReject: function(record) {
  47691. this.trackRecordState(record);
  47692. },
  47693. privates: {
  47694. add: function(record) {
  47695. var me = this,
  47696. id = record.id,
  47697. entry = me.getEntry(record.self, id),
  47698. associations, roleName;
  47699. if (entry.record) {
  47700. Ext.raise('Duplicate id ' + record.id + ' for ' + record.entityName);
  47701. }
  47702. record.session = me;
  47703. entry.record = record;
  47704. me.trackRecordState(record, true);
  47705. me.registerReferences(record);
  47706. associations = record.associations;
  47707. for (roleName in associations) {
  47708. associations[roleName].checkMembership(me, record);
  47709. }
  47710. },
  47711. applySchema: function(schema) {
  47712. return Ext.data.schema.Schema.get(schema);
  47713. },
  47714. checkModelType: function(name) {
  47715. if (name.$isClass) {
  47716. name = name.entityName;
  47717. }
  47718. if (!name) {
  47719. Ext.raise('Unable to use anonymous models in a Session');
  47720. } else if (!this.getSchema().getEntity(name)) {
  47721. Ext.raise('Unknown entity type ' + name);
  47722. }
  47723. },
  47724. createEntities: function(entityType, items) {
  47725. var me = this,
  47726. len = items.length,
  47727. i, data, rec, id;
  47728. for (i = 0; i < len; ++i) {
  47729. data = items[i];
  47730. id = entityType.getIdFromData(data);
  47731. rec = me.peekRecord(entityType, id);
  47732. if (!rec) {
  47733. rec = me.createRecord(entityType, data, true);
  47734. rec.phantom = true;
  47735. rec.crudState = 'C';
  47736. me.add(rec);
  47737. rec.crudStateWas = 'C';
  47738. } else {
  47739. me.onInvalidEntityCreate(entityType, id);
  47740. }
  47741. }
  47742. },
  47743. dropEntities: function(entityType, ids) {
  47744. var len = ids.length,
  47745. i, rec, id, extractId;
  47746. if (len) {
  47747. extractId = Ext.isObject(ids[0]);
  47748. }
  47749. for (i = 0; i < len; ++i) {
  47750. id = ids[i];
  47751. if (extractId) {
  47752. id = entityType.getIdFromData(id);
  47753. }
  47754. rec = this.peekRecord(entityType, id);
  47755. if (rec) {
  47756. rec.drop();
  47757. } else {
  47758. this.onInvalidEntityDrop(entityType, id);
  47759. }
  47760. }
  47761. },
  47762. evict: function(record) {
  47763. var me = this,
  47764. entityName = record.entityName,
  47765. entities = me.data[entityName],
  47766. id = record.id;
  47767. if (entities && entities[id]) {
  47768. me.untrackRecordState(record);
  47769. record.unjoin(me);
  47770. delete entities[id];
  47771. }
  47772. },
  47773. getEntityList: function(entityType, ids) {
  47774. var len = ids.length,
  47775. i, id, rec, invalid;
  47776. for (i = 0; i < len; ++i) {
  47777. id = ids[i];
  47778. rec = this.peekRecord(entityType, id);
  47779. if (rec) {
  47780. ids[i] = rec;
  47781. } else {
  47782. invalid = true;
  47783. ids[i] = null;
  47784. this.onInvalidAssociationEntity(entityType, id);
  47785. }
  47786. }
  47787. if (invalid) {
  47788. ids = Ext.Array.clean(ids);
  47789. }
  47790. return ids;
  47791. },
  47792. getEntry: function(type, id) {
  47793. if (type.isModel) {
  47794. id = type.getId();
  47795. type = type.self;
  47796. }
  47797. var entityType = type.$isClass ? type : this.getSchema().getEntity(type),
  47798. entityName = entityType.entityName,
  47799. data = this.data,
  47800. entry;
  47801. entry = data[entityName] || (data[entityName] = {});
  47802. entry = entry[id] || (entry[id] = {});
  47803. return entry;
  47804. },
  47805. getRefs: function(record, role, includeParent) {
  47806. var entry = this.getEntry(record),
  47807. refs = entry && entry.refs && entry.refs[role.role],
  47808. parent = includeParent && this.getParent(),
  47809. parentRefs, id, rec;
  47810. if (parent) {
  47811. parentRefs = parent.getRefs(record, role);
  47812. if (parentRefs) {
  47813. for (id in parentRefs) {
  47814. rec = parentRefs[id];
  47815. if ((!refs || !refs[id])) {
  47816. this.getRecord(rec.self, rec.id);
  47817. }
  47818. }
  47819. refs = entry && entry.refs && entry.refs[role.role];
  47820. }
  47821. }
  47822. return refs || null;
  47823. },
  47824. getIdentifier: function(entityType) {
  47825. var parent = this.getParent(),
  47826. cache, identifier, key, ret;
  47827. if (parent) {
  47828. ret = parent.getIdentifier(entityType);
  47829. } else {
  47830. cache = this.identifierCache;
  47831. identifier = entityType.identifier;
  47832. key = identifier.getId() || entityType.entityName;
  47833. ret = cache[key];
  47834. if (!ret) {
  47835. if (identifier.clone) {
  47836. ret = identifier.clone({
  47837. id: null
  47838. });
  47839. } else {
  47840. ret = identifier;
  47841. }
  47842. cache[key] = ret;
  47843. }
  47844. }
  47845. return ret;
  47846. },
  47847. getMatrix: function(matrix, preventCreate) {
  47848. var name = matrix.isManyToMany ? matrix.name : matrix,
  47849. matrices = this.matrices,
  47850. ret;
  47851. ret = matrices[name];
  47852. if (!ret && !preventCreate) {
  47853. ret = matrices[name] = new Ext.data.matrix.Matrix(this, matrix);
  47854. }
  47855. return ret || null;
  47856. },
  47857. getMatrixSlice: function(role, id) {
  47858. var matrix = this.getMatrix(role.association),
  47859. side = matrix[role.side];
  47860. return side.get(id);
  47861. },
  47862. getModelIdentifier: function(entityType, id) {
  47863. return id + '@' + entityType.entityName;
  47864. },
  47865. onIdChanged: function(record, oldId, newId) {
  47866. var me = this,
  47867. matrices = me.matrices,
  47868. entityName = record.entityName,
  47869. id = record.id,
  47870. bucket = me.data[entityName],
  47871. entry = bucket[oldId],
  47872. associations = record.associations,
  47873. refs = entry.refs,
  47874. setNoRefs = me._setNoRefs,
  47875. association, fieldName, refId, role, roleName, roleRefs, key;
  47876. if (bucket[newId]) {
  47877. Ext.raise('Cannot change ' + entityName + ' id from ' + oldId + ' to ' + newId + ' id already exists');
  47878. }
  47879. delete bucket[oldId];
  47880. bucket[newId] = entry;
  47881. for (key in matrices) {
  47882. matrices[key].updateId(record, oldId, newId);
  47883. }
  47884. if (refs) {
  47885. for (roleName in refs) {
  47886. roleRefs = refs[roleName];
  47887. role = associations[roleName];
  47888. association = role.association;
  47889. if (!association.isManyToMany) {
  47890. fieldName = association.field.name;
  47891. for (refId in roleRefs) {
  47892. roleRefs[refId].set(fieldName, id, setNoRefs);
  47893. }
  47894. }
  47895. }
  47896. }
  47897. me.registerReferences(record, oldId);
  47898. },
  47899. processManyBlock: function(entityType, role, items, processor) {
  47900. var me = this,
  47901. id, record, records, store;
  47902. if (items) {
  47903. for (id in items) {
  47904. record = me.peekRecord(entityType, id);
  47905. if (record) {
  47906. records = me.getEntityList(role.cls, items[id]);
  47907. store = role.getAssociatedItem(record);
  47908. me[processor](role, store, record, records);
  47909. } else {
  47910. me.onInvalidAssociationEntity(entityType, id);
  47911. }
  47912. }
  47913. }
  47914. },
  47915. processManyCreate: function(role, store, record, records) {
  47916. if (store) {
  47917. store.add(records);
  47918. } else {
  47919. record[role.getterName](null, null, records);
  47920. }
  47921. },
  47922. processManyDrop: function(role, store, record, records) {
  47923. if (store) {
  47924. store.remove(records);
  47925. }
  47926. },
  47927. processManyRead: function(role, store, record, records) {
  47928. if (store) {
  47929. store.setRecords(records);
  47930. } else {
  47931. record[role.getterName](null, null, records);
  47932. }
  47933. },
  47934. readEntities: function(entityType, items) {
  47935. var me = this,
  47936. len = items.length,
  47937. i, data, rec, id;
  47938. for (i = 0; i < len; ++i) {
  47939. data = items[i];
  47940. id = entityType.getIdFromData(data);
  47941. rec = me.peekRecord(entityType, id);
  47942. if (!rec) {
  47943. rec = me.createRecord(entityType, data, true);
  47944. } else {
  47945. me.onInvalidEntityRead(entityType, id);
  47946. }
  47947. rec.phantom = false;
  47948. me.add(rec);
  47949. }
  47950. },
  47951. recordCreator: function(data, Model) {
  47952. var me = this,
  47953. id = Model.getIdFromData(data),
  47954. record = me.peekRecord(Model, id, true);
  47955. if (!record) {
  47956. record = new Model(data, me);
  47957. } else {
  47958. record = me.getRecord(Model, id);
  47959. record.mergeData(data);
  47960. }
  47961. return record;
  47962. },
  47963. registerReferences: function(record, oldId) {
  47964. var entityName = record.entityName,
  47965. id = record.id,
  47966. recordData = record.data,
  47967. remove = oldId || oldId === 0,
  47968. entry, i, fk, len, reference, references, refs, roleName;
  47969. len = (references = record.references).length;
  47970. for (i = 0; i < len; ++i) {
  47971. reference = references[i];
  47972. fk = recordData[reference.name];
  47973. if (fk || fk === 0) {
  47974. reference = reference.reference;
  47975. entityName = reference.type;
  47976. roleName = reference.inverse.role;
  47977. entry = this.getEntry(reference.cls, fk);
  47978. refs = entry.refs || (entry.refs = {});
  47979. refs = refs[roleName] || (refs[roleName] = {});
  47980. refs[id] = record;
  47981. if (remove) {
  47982. delete refs[oldId];
  47983. }
  47984. }
  47985. }
  47986. },
  47987. updateEntities: function(entityType, items) {
  47988. var len = items.length,
  47989. i, data, rec, id, modified;
  47990. if (Ext.isArray(items)) {
  47991. for (i = 0; i < len; ++i) {
  47992. data = items[i];
  47993. id = entityType.getIdFromData(data);
  47994. rec = this.peekRecord(entityType, id);
  47995. if (rec) {
  47996. rec.set(data);
  47997. } else {
  47998. this.onInvalidEntityUpdate(entityType, id);
  47999. }
  48000. }
  48001. } else {
  48002. for (id in items) {
  48003. data = items[id];
  48004. rec = this.peekRecord(entityType, id);
  48005. if (rec && !rec.dropped) {
  48006. modified = rec.set(data);
  48007. } else {
  48008. this.onInvalidEntityUpdate(entityType, id, !!rec);
  48009. }
  48010. }
  48011. }
  48012. },
  48013. updateReference: function(record, field, newValue, oldValue) {
  48014. var reference = field.reference,
  48015. entityName = reference.type,
  48016. roleName = reference.inverse.role,
  48017. id = record.id,
  48018. entry, refs;
  48019. if (oldValue || oldValue === 0) {
  48020. refs = this.getEntry(entityName, oldValue).refs[roleName];
  48021. delete refs[id];
  48022. }
  48023. if (newValue || newValue === 0) {
  48024. entry = this.getEntry(entityName, newValue);
  48025. refs = entry.refs || (entry.refs = {});
  48026. refs = refs[roleName] || (refs[roleName] = {});
  48027. refs[id] = record;
  48028. }
  48029. },
  48030. visitData: function(visitor) {
  48031. var me = this,
  48032. data = me.data,
  48033. matrices = me.matrices,
  48034. all, assoc, id, id2, matrix, members, name, record, slice, slices, state;
  48035. me.getSchema().processKeyChecks(true);
  48036. for (name in data) {
  48037. all = data[name];
  48038. for (id in all) {
  48039. record = all[id].record;
  48040. if (record) {
  48041. if (record.phantom || record.dirty || record.dropped) {
  48042. if (visitor.onDirtyRecord) {
  48043. visitor.onDirtyRecord(record);
  48044. }
  48045. } else if (visitor.onCleanRecord) {
  48046. visitor.onCleanRecord(record);
  48047. }
  48048. }
  48049. }
  48050. }
  48051. if (visitor.onMatrixChange) {
  48052. for (name in matrices) {
  48053. matrix = matrices[name].left;
  48054. slices = matrix.slices;
  48055. assoc = matrix.role.association;
  48056. for (id in slices) {
  48057. slice = slices[id];
  48058. members = slice.members;
  48059. for (id2 in members) {
  48060. state = (record = members[id2])[2];
  48061. if (state) {
  48062. visitor.onMatrixChange(assoc, record[0], record[1], state);
  48063. }
  48064. }
  48065. }
  48066. }
  48067. }
  48068. return visitor;
  48069. },
  48070. _setNoRefs: {
  48071. refs: false
  48072. }
  48073. }
  48074. });
  48075. Ext.define('Ext.util.Schedulable', {
  48076. 'abstract': true,
  48077. isSchedulable: true,
  48078. scheduled: false,
  48079. constructor: function() {
  48080. this.getScheduler().add(this);
  48081. },
  48082. destroy: function() {
  48083. var me = this,
  48084. scheduler = me.getScheduler();
  48085. if (scheduler && !scheduler.destroyed) {
  48086. scheduler.remove(me);
  48087. }
  48088. me.scheduler = null;
  48089. me.schedule = me.react = Ext.emptyFn;
  48090. me.callParent();
  48091. },
  48092. getFullName: function() {
  48093. return this.name || this.id;
  48094. },
  48095. privates: {
  48096. getScheduler: function() {
  48097. return this.scheduler;
  48098. },
  48099. schedule: function() {
  48100. var me = this,
  48101. scheduler;
  48102. if (!me.scheduled) {
  48103. scheduler = me.getScheduler();
  48104. if (scheduler) {
  48105. me.scheduled = true;
  48106. if (me.onSchedule) {
  48107. me.onSchedule();
  48108. }
  48109. scheduler.scheduleItem(me);
  48110. }
  48111. }
  48112. },
  48113. unschedule: function() {
  48114. var me = this,
  48115. scheduler;
  48116. if (me.scheduled) {
  48117. scheduler = me.getScheduler();
  48118. if (scheduler && !scheduler.destroyed) {
  48119. scheduler.unscheduleItem(me);
  48120. }
  48121. me.scheduled = false;
  48122. }
  48123. },
  48124. sort: function() {}
  48125. }
  48126. });
  48127. Ext.define('Ext.app.bind.BaseBinding', {
  48128. extend: Ext.util.Schedulable,
  48129. isBinding: true,
  48130. calls: 0,
  48131. kind: 20,
  48132. defaultOptions: {},
  48133. lastValue: undefined,
  48134. constructor: function(owner, callback, scope, options) {
  48135. var me = this;
  48136. me.options = options;
  48137. me.owner = owner;
  48138. me.scope = scope;
  48139. me.callback = callback;
  48140. if (!callback) {
  48141. Ext.raise('Callback is required');
  48142. }
  48143. me.lateBound = Ext.isString(callback);
  48144. if (options && options.deep) {
  48145. me.deep = true;
  48146. }
  48147. me.callParent();
  48148. },
  48149. destroy: function() {
  48150. var me = this,
  48151. owner = me.owner;
  48152. if (owner) {
  48153. owner.onBindDestroy(me);
  48154. }
  48155. me.callParent();
  48156. me.scope = me.callback = me.owner = null;
  48157. },
  48158. isReadOnly: function() {
  48159. return true;
  48160. },
  48161. privates: {
  48162. getScheduler: function() {
  48163. var owner = this.owner;
  48164. return owner && owner.getScheduler();
  48165. },
  48166. getSession: function() {
  48167. var owner = this.owner;
  48168. return owner.isSession ? owner : owner.getSession();
  48169. },
  48170. notify: function(value) {
  48171. var me = this,
  48172. options = me.options || me.defaultOptions,
  48173. previous = me.lastValue;
  48174. if (!me.calls || me.deep || me.valueChanged(value, previous)) {
  48175. ++me.calls;
  48176. me.lastValue = value;
  48177. if (me.lateBound) {
  48178. me.scope[me.callback](value, previous, me);
  48179. } else {
  48180. me.callback.call(me.scope, value, previous, me);
  48181. }
  48182. if (options.single) {
  48183. me.destroy();
  48184. }
  48185. }
  48186. },
  48187. valueChanged: function(value, previous) {
  48188. var ret = true;
  48189. if (previous !== value) {
  48190. if (value && previous && value instanceof Date && previous instanceof Date) {
  48191. ret = value.getTime() !== previous.getTime();
  48192. }
  48193. } else {
  48194. ret = Ext.isArray(value);
  48195. }
  48196. return ret;
  48197. }
  48198. }
  48199. });
  48200. Ext.define('Ext.app.bind.Binding', {
  48201. extend: Ext.app.bind.BaseBinding,
  48202. constructor: function(stub, callback, scope, options) {
  48203. var me = this;
  48204. me.callParent([
  48205. stub.owner,
  48206. callback,
  48207. scope,
  48208. options
  48209. ]);
  48210. me.stub = stub;
  48211. me.depth = stub.depth;
  48212. if (stub.isAvailable() && !stub.scheduled) {
  48213. me.schedule();
  48214. }
  48215. },
  48216. destroy: function(fromParent) {
  48217. var me = this,
  48218. stub = me.stub;
  48219. if (stub && !fromParent) {
  48220. stub.unbind(me);
  48221. me.stub = null;
  48222. }
  48223. me.callParent();
  48224. },
  48225. bindValidation: function(callback, scope) {
  48226. var stub = this.stub;
  48227. return stub && stub.bindValidation(callback, scope);
  48228. },
  48229. bindValidationField: function(callback, scope) {
  48230. var stub = this.stub;
  48231. return stub && stub.bindValidationField(callback, scope);
  48232. },
  48233. getFullName: function() {
  48234. return this.fullName || (this.fullName = '@(' + this.stub.getFullName() + ')');
  48235. },
  48236. getValue: function() {
  48237. var me = this,
  48238. stub = me.stub;
  48239. return stub && stub.getValue();
  48240. },
  48241. isAvailable: function() {
  48242. var stub = this.stub;
  48243. return stub && stub.isAvailable();
  48244. },
  48245. isLoading: function() {
  48246. var stub = this.stub;
  48247. return stub && stub.isLoading();
  48248. },
  48249. isReadOnly: function() {
  48250. var stub = this.stub,
  48251. options = this.options,
  48252. ret = true;
  48253. if (!(options && options.twoWay === false)) {
  48254. if (stub) {
  48255. ret = stub.isReadOnly();
  48256. }
  48257. }
  48258. return ret;
  48259. },
  48260. refresh: function() {},
  48261. setValue: function(value) {
  48262. if (this.isReadOnly()) {
  48263. Ext.raise('Cannot setValue on a readonly binding');
  48264. }
  48265. this.stub.set(value);
  48266. },
  48267. privates: {
  48268. getDataObject: function() {
  48269. var stub = this.stub;
  48270. return stub && stub.getDataObject();
  48271. },
  48272. getRawValue: function() {
  48273. var me = this,
  48274. stub = me.stub;
  48275. return stub && stub.getRawValue();
  48276. },
  48277. isDescendantOf: function(item) {
  48278. var stub = this.stub;
  48279. return stub ? (item === stub) || stub.isDescendantOf(item) : false;
  48280. },
  48281. react: function() {
  48282. this.notify(this.getValue());
  48283. },
  48284. schedule: function() {
  48285. if (!this.stub.scheduled) {
  48286. this.callParent();
  48287. }
  48288. },
  48289. sort: function() {
  48290. var stub = this.stub;
  48291. stub.scheduler.sortItem(stub);
  48292. }
  48293. }
  48294. });
  48295. Ext.define('Ext.app.bind.AbstractStub', {
  48296. extend: Ext.util.Schedulable,
  48297. children: null,
  48298. depth: 0,
  48299. generation: 1,
  48300. kind: 10,
  48301. parent: null,
  48302. constructor: function(owner, name) {
  48303. var me = this;
  48304. me.owner = owner;
  48305. me.name = name;
  48306. me.callParent();
  48307. },
  48308. destroy: function() {
  48309. var me = this,
  48310. children = me.children,
  48311. bindings = me.bindings,
  48312. len, i, key;
  48313. if (bindings) {
  48314. for (i = 0 , len = bindings.length; i < len; ++i) {
  48315. bindings[i].destroy(true);
  48316. }
  48317. }
  48318. for (key in children) {
  48319. children[key].destroy();
  48320. }
  48321. if (me.scheduled) {
  48322. me.unschedule();
  48323. }
  48324. me.callParent();
  48325. },
  48326. add: function(child) {
  48327. var me = this;
  48328. (me.children || (me.children = {}))[child.name] = child;
  48329. child.depth = me.depth + 1;
  48330. child.parent = me;
  48331. },
  48332. getChild: function(path) {
  48333. var pathArray = Ext.isString(path) ? path.split('.') : path;
  48334. if (pathArray && pathArray.length) {
  48335. return this.descend(pathArray, 0);
  48336. }
  48337. return this;
  48338. },
  48339. getFullName: function() {
  48340. var me = this,
  48341. name = me.fullName,
  48342. parent = me.parent,
  48343. s;
  48344. if (!name) {
  48345. name = me.name || me.id;
  48346. if (parent && (s = parent.getFullName())) {
  48347. name = ((s.charAt(s.length - 1) !== ':') ? s + '.' : s) + name;
  48348. }
  48349. me.fullName = name;
  48350. }
  48351. return name;
  48352. },
  48353. getSession: function() {
  48354. var owner = this.owner;
  48355. return owner.isSession ? owner : owner.getSession();
  48356. },
  48357. bind: function(callback, scope, options) {
  48358. var me = this,
  48359. binding = new Ext.app.bind.Binding(me, callback, scope, options),
  48360. bindings = (me.bindings || (me.bindings = []));
  48361. binding.depth = me.depth;
  48362. bindings.push(binding);
  48363. return binding;
  48364. },
  48365. getValue: function() {
  48366. return this.isAvailable() ? this.getRawValue() : null;
  48367. },
  48368. graft: function(replacement) {
  48369. var me = this,
  48370. bindings = me.bindings,
  48371. name = me.name,
  48372. i;
  48373. me.parent = me.bindings = null;
  48374. me.destroy();
  48375. replacement.depth = me.depth;
  48376. replacement.bindings = bindings;
  48377. replacement.generation = me.generation + 1;
  48378. replacement.name = name;
  48379. replacement.id = me.id;
  48380. replacement.path = me.path;
  48381. if (bindings) {
  48382. for (i = bindings.length; i-- > 0; ) {
  48383. bindings[i].stub = replacement;
  48384. }
  48385. }
  48386. return replacement;
  48387. },
  48388. isDescendantOf: function(item) {
  48389. var parent;
  48390. for (parent = this; parent = parent.parent; ) {
  48391. if (parent === item) {
  48392. return true;
  48393. }
  48394. }
  48395. return false;
  48396. },
  48397. isAvailable: function() {
  48398. return true;
  48399. },
  48400. isLoading: function() {
  48401. return false;
  48402. },
  48403. onSchedule: function() {
  48404. var i, len, binding, bindings, p;
  48405. for (p = this.parent; p; p = p.parent) {
  48406. bindings = p.bindings;
  48407. if (bindings) {
  48408. for (i = 0 , len = bindings.length; i < len; ++i) {
  48409. binding = bindings[i];
  48410. if (binding.deep && !binding.scheduled) {
  48411. binding.schedule();
  48412. }
  48413. }
  48414. }
  48415. }
  48416. },
  48417. react: function() {
  48418. var bindings = this.bindings,
  48419. binding, i, len;
  48420. if (bindings) {
  48421. for (i = 0 , len = bindings.length; i < len; ++i) {
  48422. binding = bindings[i];
  48423. if (!binding.scheduled) {
  48424. binding.schedule();
  48425. }
  48426. }
  48427. }
  48428. },
  48429. unbind: function(binding) {
  48430. var bindings = this.bindings;
  48431. if (bindings && bindings.length) {
  48432. Ext.Array.remove(bindings, binding);
  48433. }
  48434. },
  48435. privates: {
  48436. collect: function() {
  48437. var children = this.children,
  48438. bindings = this.bindings,
  48439. totalCount = 0,
  48440. count = 0,
  48441. child, key;
  48442. if (children) {
  48443. for (key in children) {
  48444. child = children[key];
  48445. count = child.collect();
  48446. if (count === 0) {
  48447. child.destroy();
  48448. delete children[key];
  48449. }
  48450. totalCount += count;
  48451. }
  48452. }
  48453. if (bindings) {
  48454. totalCount += bindings.length;
  48455. }
  48456. return totalCount;
  48457. },
  48458. getScheduler: function() {
  48459. var owner = this.owner;
  48460. return owner && owner.getScheduler();
  48461. },
  48462. sort: function() {
  48463. var parent = this.parent;
  48464. if (parent) {
  48465. this.scheduler.sortItem(parent);
  48466. }
  48467. }
  48468. }
  48469. });
  48470. Ext.define('Ext.app.bind.Stub', {
  48471. extend: Ext.app.bind.AbstractStub,
  48472. isStub: true,
  48473. dirty: true,
  48474. formula: null,
  48475. validationKey: 'validation',
  48476. constructor: function(owner, name, parent) {
  48477. var me = this,
  48478. path = name;
  48479. me.callParent([
  48480. owner,
  48481. name
  48482. ]);
  48483. me.boundValue = null;
  48484. if (parent) {
  48485. parent.add(me);
  48486. if (!parent.isRootStub) {
  48487. path = parent.path + '.' + name;
  48488. }
  48489. me.checkHadValue();
  48490. }
  48491. me.path = path;
  48492. },
  48493. destroy: function() {
  48494. var me = this,
  48495. formula = me.formula,
  48496. storeBinding = me.storeBinding;
  48497. if (formula) {
  48498. formula.destroy();
  48499. }
  48500. if (storeBinding) {
  48501. storeBinding.destroy();
  48502. }
  48503. me.detachBound();
  48504. me.callParent();
  48505. },
  48506. bindValidation: function(callback, scope) {
  48507. var parent = this.parent;
  48508. return parent && parent.descend([
  48509. this.validationKey,
  48510. this.name
  48511. ]).bind(callback, scope);
  48512. },
  48513. bindValidationField: function(callback, scope) {
  48514. var parent = this.parent,
  48515. name = this.name,
  48516. lateBound = typeof callback === 'string',
  48517. ret;
  48518. if (parent) {
  48519. ret = parent.bind(function(value) {
  48520. var field = null;
  48521. if (value && value.isModel) {
  48522. field = value.getField(name);
  48523. }
  48524. if (lateBound) {
  48525. scope[callback](field, value, this);
  48526. } else {
  48527. callback.call(scope, field, value, this);
  48528. }
  48529. });
  48530. }
  48531. return ret || null;
  48532. },
  48533. descend: function(path, index) {
  48534. var me = this,
  48535. children = me.children || (me.children = {}),
  48536. pos = index || 0,
  48537. name = path[pos++],
  48538. ret;
  48539. if (!(ret = children[name])) {
  48540. ret = new Ext.app.bind.Stub(me.owner, name, me);
  48541. }
  48542. if (pos < path.length) {
  48543. ret = ret.descend(path, pos);
  48544. }
  48545. return ret;
  48546. },
  48547. getChildValue: function(parentData) {
  48548. var me = this,
  48549. name = me.name,
  48550. bindMappings = me.bindMappings,
  48551. storeMappings = bindMappings.store,
  48552. modelMappings = bindMappings.model,
  48553. ret;
  48554. if (!parentData && !Ext.isString(parentData)) {
  48555. ret = me.hadValue ? null : undefined;
  48556. } else {
  48557. ret = me.inspectValue(parentData);
  48558. if (!ret) {
  48559. if (parentData.isEntity) {
  48560. if (modelMappings[name]) {
  48561. ret = parentData[modelMappings[name]]();
  48562. } else {
  48563. ret = parentData.data[name];
  48564. }
  48565. } else if (parentData.isStore && storeMappings[name]) {
  48566. ret = parentData[storeMappings[name]]();
  48567. } else {
  48568. ret = parentData[name];
  48569. if (ret === undefined && me.hadValue) {
  48570. ret = null;
  48571. }
  48572. }
  48573. }
  48574. }
  48575. return ret;
  48576. },
  48577. getDataObject: function() {
  48578. var me = this,
  48579. parentData = me.parent.getDataObject(),
  48580. name = me.name,
  48581. ret = parentData ? parentData[name] : null,
  48582. storeMappings = me.bindMappings.store,
  48583. associations;
  48584. if (!ret) {
  48585. if (parentData && parentData.isEntity) {
  48586. associations = parentData.associations;
  48587. if (associations && name in associations) {
  48588. ret = parentData[associations[name].getterName]();
  48589. }
  48590. }
  48591. } else if (parentData.isStore && name in storeMappings) {
  48592. ret = parentData[storeMappings[name]]();
  48593. }
  48594. if (!ret || !(ret.$className || Ext.isObject(ret))) {
  48595. parentData[name] = ret = {};
  48596. me.hadValue = true;
  48597. me.invalidate(true, true);
  48598. }
  48599. return ret;
  48600. },
  48601. getRawValue: function() {
  48602. return this.getChildValue(this.getParentValue());
  48603. },
  48604. graft: function(replacement) {
  48605. var me = this,
  48606. parent = me.parent,
  48607. children = me.children,
  48608. name = me.name,
  48609. i, ret;
  48610. replacement.parent = parent;
  48611. replacement.children = children;
  48612. if (parent) {
  48613. parent.children[name] = replacement;
  48614. }
  48615. if (children) {
  48616. for (i in children) {
  48617. children[i].parent = replacement;
  48618. }
  48619. }
  48620. me.children = null;
  48621. replacement.checkHadValue();
  48622. ret = me.callParent([
  48623. replacement
  48624. ]);
  48625. ret.invalidate(true, true);
  48626. return ret;
  48627. },
  48628. isAvailable: function() {
  48629. return this.checkAvailability();
  48630. },
  48631. isLoading: function() {
  48632. return !this.checkAvailability(true);
  48633. },
  48634. invalidate: function(deep, dirtyOnly) {
  48635. var me = this,
  48636. children = me.children,
  48637. name;
  48638. me.dirty = true;
  48639. me.checkHadValue();
  48640. if (!dirtyOnly && me.isAvailable()) {
  48641. if (!me.scheduled) {
  48642. me.schedule();
  48643. }
  48644. }
  48645. if (deep && children) {
  48646. for (name in children) {
  48647. children[name].invalidate(deep, dirtyOnly);
  48648. }
  48649. }
  48650. },
  48651. isReadOnly: function() {
  48652. var formula = this.formula;
  48653. return !!(formula && !formula.set);
  48654. },
  48655. set: function(value, preventClimb) {
  48656. var me = this,
  48657. parent = me.parent,
  48658. name = me.name,
  48659. formula = me.formula,
  48660. parentData, associations, association, formulaStub, setterName;
  48661. if (formula && !formula.settingValue && formula.set) {
  48662. formula.setValue(value);
  48663. return;
  48664. } else if (me.isLinkStub) {
  48665. formulaStub = me.getLinkFormulaStub();
  48666. formula = formulaStub ? formulaStub.formula : null;
  48667. if (formula) {
  48668. if (formulaStub.isReadOnly()) {
  48669. Ext.raise('Cannot setValue on a readonly formula');
  48670. }
  48671. formula.setValue(value);
  48672. return;
  48673. }
  48674. }
  48675. parentData = parent.getDataObject();
  48676. if (parentData.isEntity) {
  48677. associations = parentData.associations;
  48678. if (associations && (name in associations)) {
  48679. association = associations[name];
  48680. setterName = association.setterName;
  48681. if (setterName) {
  48682. parentData[setterName](value);
  48683. }
  48684. me.invalidate(true);
  48685. } else {
  48686. parentData.set(name, value);
  48687. }
  48688. }
  48689. else if ((value && value.constructor === Object) || !(value === parentData[name] && parentData.hasOwnProperty(name))) {
  48690. if (preventClimb || !me.setByLink(value)) {
  48691. if (value === undefined) {
  48692. delete parentData[name];
  48693. } else {
  48694. parentData[name] = value;
  48695. }
  48696. me.inspectValue(parentData);
  48697. me.invalidate(true);
  48698. }
  48699. }
  48700. },
  48701. onStoreDataChanged: function() {
  48702. this.invalidate(true);
  48703. },
  48704. afterLoad: function(record) {
  48705. this.invalidate(true);
  48706. },
  48707. afterCommit: function(record) {
  48708. this.afterEdit(record, null);
  48709. },
  48710. afterEdit: function(record, modifiedFieldNames) {
  48711. var children = this.children,
  48712. len = modifiedFieldNames && modifiedFieldNames.length,
  48713. associations = record.associations,
  48714. bindMappings = this.bindMappings.model,
  48715. key, i, child, name, ref;
  48716. if (children) {
  48717. if (len) {
  48718. for (i = 0; i < len; ++i) {
  48719. name = modifiedFieldNames[i];
  48720. child = children[name];
  48721. if (!child) {
  48722. ref = record.fieldsMap[name];
  48723. ref = ref && ref.reference;
  48724. child = ref && children[ref.role];
  48725. }
  48726. if (child) {
  48727. child.invalidate(true);
  48728. }
  48729. }
  48730. } else {
  48731. for (key in children) {
  48732. if (!(associations && key in associations)) {
  48733. children[key].invalidate(true);
  48734. }
  48735. }
  48736. }
  48737. for (key in bindMappings) {
  48738. child = children[key];
  48739. if (child) {
  48740. child.invalidate();
  48741. }
  48742. }
  48743. }
  48744. this.invalidate();
  48745. },
  48746. afterReject: function(record) {
  48747. this.afterEdit(record, null);
  48748. },
  48749. afterAssociatedRecordSet: function(record, associated, role) {
  48750. var children = this.children,
  48751. key = role.role;
  48752. if (children && key in children) {
  48753. children[key].invalidate(true);
  48754. }
  48755. },
  48756. setByLink: function(value) {
  48757. var me = this,
  48758. n = 0,
  48759. ret = false,
  48760. i, link, path, stub, root, name;
  48761. for (stub = me; stub; stub = stub.parent) {
  48762. if (stub.isLinkStub) {
  48763. link = stub;
  48764. if (n) {
  48765. for (path = [] , i = 0 , stub = me; stub !== link; stub = stub.parent) {
  48766. ++i;
  48767. path[n - i] = stub.name;
  48768. }
  48769. }
  48770. break;
  48771. }
  48772. ++n;
  48773. }
  48774. stub = null;
  48775. if (link) {
  48776. root = link.parent;
  48777. name = link.name;
  48778. if (!root.shouldClimb(name)) {
  48779. stub = root.insertChild(name);
  48780. } else {
  48781. stub = link.getTargetStub();
  48782. }
  48783. }
  48784. if (stub) {
  48785. if (path) {
  48786. stub = stub.descend(path);
  48787. }
  48788. stub.set(value);
  48789. ret = true;
  48790. }
  48791. return ret;
  48792. },
  48793. setFormula: function(formula) {
  48794. var me = this,
  48795. oldFormula = me.formula;
  48796. if (oldFormula) {
  48797. oldFormula.destroy();
  48798. }
  48799. me.formula = new Ext.app.bind.Formula(me, formula);
  48800. },
  48801. react: function() {
  48802. var me = this,
  48803. bound = this.boundValue,
  48804. children = me.children,
  48805. generation;
  48806. if (bound) {
  48807. if (bound.isValidation) {
  48808. bound.refresh();
  48809. generation = bound.generation;
  48810. if (me.lastValidationGeneration === generation) {
  48811. return;
  48812. }
  48813. me.lastValidationGeneration = generation;
  48814. } else if (bound.isModel) {
  48815. if (children && children[me.validationKey]) {
  48816. bound.isValid();
  48817. }
  48818. }
  48819. }
  48820. this.callParent();
  48821. },
  48822. privates: {
  48823. bindMappings: {
  48824. store: {
  48825. count: 'getCount',
  48826. first: 'first',
  48827. last: 'last',
  48828. loading: 'hasPendingLoad',
  48829. totalCount: 'getTotalCount'
  48830. },
  48831. model: {
  48832. dirty: 'isDirty',
  48833. phantom: 'isPhantom',
  48834. valid: 'isValid'
  48835. }
  48836. },
  48837. checkAvailability: function(isLoading) {
  48838. var me = this,
  48839. parent = me.parent,
  48840. bindMappings = me.bindMappings,
  48841. name = me.name,
  48842. available = !!(parent && parent.checkAvailability(isLoading)),
  48843. associations, parentValue, value, availableSet;
  48844. if (available) {
  48845. parentValue = me.getParentValue();
  48846. value = me.inspectValue(parentValue);
  48847. if (value) {
  48848. if (isLoading) {
  48849. available = !value.hasPendingLoad();
  48850. } else {
  48851. if (value.isStore) {
  48852. available = true;
  48853. } else {
  48854. available = !value.isLoading() || value.loadCount > 0;
  48855. }
  48856. }
  48857. } else {
  48858. if (parentValue) {
  48859. if (parentValue.isModel) {
  48860. if (bindMappings.model[name]) {
  48861. available = !parent.isLoading();
  48862. availableSet = true;
  48863. } else {
  48864. associations = parentValue.associations;
  48865. if (!(associations && name in associations)) {
  48866. available = true;
  48867. availableSet = true;
  48868. }
  48869. }
  48870. } else if (parentValue.isStore && bindMappings.store[name] && name !== 'loading') {
  48871. available = !parent.isLoading();
  48872. availableSet = true;
  48873. }
  48874. }
  48875. if (!availableSet) {
  48876. available = me.hadValue || me.getRawValue() !== undefined;
  48877. }
  48878. }
  48879. }
  48880. return available;
  48881. },
  48882. checkHadValue: function() {
  48883. if (!this.hadValue) {
  48884. this.hadValue = this.getRawValue() !== undefined;
  48885. }
  48886. },
  48887. collect: function() {
  48888. var me = this,
  48889. result = me.callParent(),
  48890. storeBinding = me.storeBinding ? 1 : 0,
  48891. formula = me.formula ? 1 : 0;
  48892. return result + storeBinding + formula;
  48893. },
  48894. getLinkFormulaStub: function() {
  48895. var stub = this;
  48896. while (stub.isLinkStub) {
  48897. stub = stub.binding.stub;
  48898. }
  48899. return stub.formula ? stub : null;
  48900. },
  48901. getParentValue: function() {
  48902. var me = this;
  48903. if (me.dirty) {
  48904. me.parentValue = me.parent.getValue();
  48905. me.dirty = false;
  48906. }
  48907. return me.parentValue;
  48908. },
  48909. setStore: function(storeBinding) {
  48910. this.storeBinding = storeBinding;
  48911. },
  48912. inspectValue: function(parentData) {
  48913. var me = this,
  48914. name = me.name,
  48915. current = me.boundValue,
  48916. boundValue = null,
  48917. associations, raw, changed, associatedEntity;
  48918. if (parentData && parentData.isEntity) {
  48919. associations = parentData.associations;
  48920. if (associations && (name in associations)) {
  48921. boundValue = parentData[associations[name].getterName]();
  48922. } else if (name === me.validationKey) {
  48923. boundValue = parentData.getValidation();
  48924. me.lastValidationGeneration = null;
  48925. }
  48926. } else if (parentData) {
  48927. raw = parentData[name];
  48928. if (raw && (raw.isModel || raw.isStore)) {
  48929. boundValue = raw;
  48930. }
  48931. }
  48932. changed = current !== boundValue;
  48933. if (changed) {
  48934. if (current) {
  48935. me.detachBound();
  48936. }
  48937. if (boundValue) {
  48938. if (boundValue.isModel) {
  48939. boundValue.join(me);
  48940. } else {
  48941. associatedEntity = boundValue.associatedEntity;
  48942. if (associatedEntity && boundValue.autoLoad !== false && !boundValue.complete && !boundValue.hasPendingLoad()) {
  48943. boundValue.load();
  48944. }
  48945. boundValue.on({
  48946. scope: me,
  48947. beginload: 'onStoreDataChanged',
  48948. load: 'onStoreDataChanged',
  48949. datachanged: 'onStoreDataChanged',
  48950. destroy: 'onDestroyBound'
  48951. });
  48952. }
  48953. }
  48954. me.boundValue = boundValue;
  48955. }
  48956. return boundValue;
  48957. },
  48958. detachBound: function() {
  48959. var me = this,
  48960. current = me.boundValue;
  48961. if (current && !current.destroyed) {
  48962. if (current.isModel) {
  48963. current.unjoin(me);
  48964. } else {
  48965. current.un({
  48966. scope: me,
  48967. beginload: 'onStoreDataChanged',
  48968. load: 'onStoreDataChanged',
  48969. datachanged: 'onStoreDataChanged',
  48970. destroy: 'onDestroyBound'
  48971. });
  48972. }
  48973. }
  48974. },
  48975. onDestroyBound: function() {
  48976. if (!this.owner.destroying) {
  48977. this.set(null);
  48978. }
  48979. },
  48980. sort: function() {
  48981. var me = this,
  48982. formula = me.formula,
  48983. scheduler = me.scheduler,
  48984. storeBinding = me.storeBinding;
  48985. me.callParent();
  48986. if (storeBinding) {
  48987. scheduler.sortItem(storeBinding);
  48988. }
  48989. if (formula) {
  48990. scheduler.sortItem(formula);
  48991. }
  48992. }
  48993. }
  48994. });
  48995. Ext.define('Ext.app.bind.LinkStub', {
  48996. extend: Ext.app.bind.Stub,
  48997. isLinkStub: true,
  48998. binding: null,
  48999. destroy: function() {
  49000. var me = this,
  49001. binding = me.binding,
  49002. owner = me.owner;
  49003. if (binding) {
  49004. me.binding = null;
  49005. binding.destroy();
  49006. if (owner) {
  49007. delete owner.linkData[me.name];
  49008. }
  49009. }
  49010. me.target = null;
  49011. me.callParent();
  49012. },
  49013. getFullName: function() {
  49014. var me = this;
  49015. return me.fullName || (me.fullName = '(' + me.callParent() + ' -> ' + me.binding.getFullName() + ')');
  49016. },
  49017. getDataObject: function() {
  49018. var binding = this.binding,
  49019. root = this.parent,
  49020. name = this.name,
  49021. rootData, ret;
  49022. if (root.isRootStub && !root.shouldClimb(name)) {
  49023. rootData = root.owner.getData();
  49024. if (!rootData.hasOwnProperty(name)) {
  49025. rootData[name] = ret = {};
  49026. }
  49027. } else {
  49028. ret = binding && binding.getDataObject();
  49029. }
  49030. return ret;
  49031. },
  49032. getRawValue: function() {
  49033. var binding = this.binding;
  49034. return binding && binding.getRawValue();
  49035. },
  49036. getValue: function() {
  49037. var binding = this.binding;
  49038. return binding && binding.getValue();
  49039. },
  49040. getTargetStub: function() {
  49041. var binding = this.binding;
  49042. return binding && binding.stub;
  49043. },
  49044. isAvailable: function() {
  49045. var binding = this.binding;
  49046. return binding ? binding.isAvailable() : false;
  49047. },
  49048. isLoading: function() {
  49049. var binding = this.binding;
  49050. return binding ? binding.isLoading() : false;
  49051. },
  49052. link: function(bindDescriptor, target) {
  49053. var me = this,
  49054. binding = me.binding;
  49055. if (binding) {
  49056. binding.destroy();
  49057. }
  49058. target = me.target = target || me.owner;
  49059. me.linkDescriptor = bindDescriptor;
  49060. me.binding = target.bind(bindDescriptor, me.onChange, me);
  49061. me.binding.deep = true;
  49062. },
  49063. onChange: function() {
  49064. this.invalidate(true);
  49065. },
  49066. react: function() {
  49067. var me = this,
  49068. linkData = me.owner.linkData;
  49069. linkData[me.name] = me.getValue();
  49070. me.callParent();
  49071. },
  49072. privates: {
  49073. collect: function() {
  49074. var me = this,
  49075. result = me.callParent(),
  49076. binding = me.binding ? 1 : 0;
  49077. return result + binding;
  49078. },
  49079. sort: function() {
  49080. var binding = this.binding;
  49081. if (binding) {
  49082. this.scheduler.sortItem(binding);
  49083. }
  49084. }
  49085. }
  49086. });
  49087. Ext.define('Ext.app.bind.RootStub', {
  49088. extend: Ext.app.bind.AbstractStub,
  49089. isRootStub: true,
  49090. depth: 0,
  49091. createRootChild: function(name, direct) {
  49092. var me = this,
  49093. owner = me.owner,
  49094. ownerData = owner.getData(),
  49095. children = me.children,
  49096. previous = children && children[name],
  49097. parentStub = previous ? null : me,
  49098. parentVM, stub;
  49099. if (direct || ownerData.hasOwnProperty(name) || !(parentVM = owner.getParent())) {
  49100. stub = new Ext.app.bind.Stub(owner, name, parentStub);
  49101. } else {
  49102. stub = new Ext.app.bind.LinkStub(owner, name, parentStub);
  49103. stub.link('{' + name + '}', parentVM);
  49104. }
  49105. if (previous) {
  49106. previous.graft(stub);
  49107. }
  49108. return stub;
  49109. },
  49110. createStubChild: function(name) {
  49111. return this.createRootChild(name, true);
  49112. },
  49113. descend: function(path, index) {
  49114. var me = this,
  49115. children = me.children,
  49116. pos = index || 0,
  49117. name = path[pos++],
  49118. ret = (children && children[name]) || me.createRootChild(name);
  49119. if (pos < path.length) {
  49120. ret = ret.descend(path, pos);
  49121. }
  49122. return ret;
  49123. },
  49124. getFullName: function() {
  49125. return this.fullName || (this.fullName = this.owner.id + ':');
  49126. },
  49127. getDataObject: function() {
  49128. return this.owner.data;
  49129. },
  49130. getRawValue: function() {
  49131. return this.owner.data;
  49132. },
  49133. getValue: function() {
  49134. return this.owner.data;
  49135. },
  49136. isDescendantOf: function() {
  49137. return false;
  49138. },
  49139. set: function(value, preventClimb) {
  49140. if (!value || value.constructor !== Object) {
  49141. Ext.raise('Only an object can be set at the root');
  49142. }
  49143. var me = this,
  49144. children = me.children || (me.children = {}),
  49145. owner = me.owner,
  49146. data = owner.data,
  49147. parentVM = owner.getParent(),
  49148. stub, v, key, setSelf, created;
  49149. for (key in value) {
  49150. if (key.indexOf('.') >= 0) {
  49151. Ext.raise('Value names cannot contain dots');
  49152. }
  49153. v = value[key];
  49154. if (v !== undefined) {
  49155. stub = children[key];
  49156. setSelf = preventClimb || !me.shouldClimb(key);
  49157. if (!stub) {
  49158. stub = me.createRootChild(key, setSelf);
  49159. created = true;
  49160. } else if (setSelf && stub.isLinkStub && !stub.getLinkFormulaStub()) {
  49161. stub = me.insertChild(key);
  49162. }
  49163. if (!created || !data.hasOwnProperty(value)) {
  49164. owner.invalidateChildLinks(key);
  49165. }
  49166. stub.set(v, setSelf);
  49167. }
  49168. else if (data.hasOwnProperty(key)) {
  49169. delete data[key];
  49170. stub = children[key];
  49171. if (stub) {
  49172. if (!stub.isLinkStub && parentVM) {
  49173. stub = me.createRootChild(key);
  49174. }
  49175. owner.invalidateChildLinks(key, true);
  49176. stub.invalidate(true);
  49177. }
  49178. }
  49179. }
  49180. },
  49181. schedule: Ext.emptyFn,
  49182. unschedule: Ext.emptyFn,
  49183. privates: {
  49184. checkAvailability: function() {
  49185. return true;
  49186. },
  49187. insertChild: function(name) {
  49188. return this.createRootChild(name, true);
  49189. },
  49190. invalidateChildLink: function(name, clear) {
  49191. var children = this.children,
  49192. stub = children && children[name];
  49193. if (stub && stub.isLinkStub && !stub.getLinkFormulaStub()) {
  49194. stub = this.createRootChild(name);
  49195. if (clear) {
  49196. stub.invalidate(true);
  49197. }
  49198. this.owner.invalidateChildLinks(name, clear);
  49199. }
  49200. },
  49201. shouldClimb: function(name) {
  49202. var parent = this.owner.getParent();
  49203. while (parent) {
  49204. if (parent.getData().hasOwnProperty(name)) {
  49205. return true;
  49206. }
  49207. parent = parent.getParent();
  49208. }
  49209. return false;
  49210. }
  49211. }
  49212. });
  49213. Ext.define('Ext.app.bind.Multi', {
  49214. extend: Ext.app.bind.BaseBinding,
  49215. isMultiBinding: true,
  49216. missing: 1,
  49217. deep: true,
  49218. constructor: function(descriptor, owner, callback, scope, options) {
  49219. var me = this,
  49220. trackStatics = options && options.trackStatics;
  49221. me.callParent([
  49222. owner,
  49223. callback,
  49224. scope,
  49225. options
  49226. ]);
  49227. me.bindings = [];
  49228. me.literal = descriptor.$literal;
  49229. if (descriptor.constructor === Object) {
  49230. if (trackStatics) {
  49231. me.staticKeys = [];
  49232. }
  49233. me.addObject(descriptor, me.lastValue = {}, me.staticKeys);
  49234. } else {
  49235. me.addArray(descriptor, me.lastValue = []);
  49236. }
  49237. if (!--me.missing && !me.scheduled) {
  49238. me.schedule();
  49239. }
  49240. },
  49241. destroy: function() {
  49242. var me = this;
  49243. me.bindings = Ext.destroy(me.bindings);
  49244. me.callParent();
  49245. },
  49246. add: function(descriptor, data, property) {
  49247. var me = this,
  49248. owner = me.owner,
  49249. bindings = me.bindings,
  49250. method = me.literal ? (descriptor.reference ? 'bindEntity' : 'bindExpression') : 'bind',
  49251. binding, depth;
  49252. ++me.missing;
  49253. binding = owner[method](descriptor, function(value) {
  49254. data[property] = value;
  49255. if (binding.calls === 1) {
  49256. --me.missing;
  49257. }
  49258. if (!me.missing && !me.scheduled) {
  49259. me.schedule();
  49260. }
  49261. },
  49262. me, null);
  49263. depth = binding.depth;
  49264. if (!bindings.length || depth < me.depth) {
  49265. me.depth = depth;
  49266. }
  49267. bindings.push(binding);
  49268. return !this.isBindingStatic(binding);
  49269. },
  49270. addArray: function(multiBindDescr, array) {
  49271. var me = this,
  49272. n = multiBindDescr.length,
  49273. hasDynamic = false,
  49274. dynamic, b, i;
  49275. for (i = 0; i < n; ++i) {
  49276. b = multiBindDescr[i];
  49277. if (b && (b.reference || Ext.isString(b))) {
  49278. dynamic = me.add(b, array, i);
  49279. } else if (Ext.isArray(b)) {
  49280. dynamic = me.addArray(b, array[i] = []);
  49281. } else if (b && b.constructor === Object) {
  49282. dynamic = me.addObject(b, array[i] = {});
  49283. } else {
  49284. array[i] = b;
  49285. dynamic = false;
  49286. }
  49287. hasDynamic = hasDynamic || dynamic;
  49288. }
  49289. return hasDynamic;
  49290. },
  49291. addObject: function(multiBindDescr, object, staticKeys) {
  49292. var me = this,
  49293. hasDynamic = false,
  49294. dynamic, b, name;
  49295. for (name in multiBindDescr) {
  49296. b = multiBindDescr[name];
  49297. if (b && (b.reference || Ext.isString(b))) {
  49298. dynamic = me.add(b, object, name);
  49299. } else if (Ext.isArray(b)) {
  49300. dynamic = me.addArray(b, object[name] = []);
  49301. } else if (b && b.constructor === Object) {
  49302. dynamic = me.addObject(b, object[name] = {});
  49303. } else {
  49304. object[name] = b;
  49305. dynamic = false;
  49306. }
  49307. if (staticKeys && !dynamic) {
  49308. staticKeys.push(name);
  49309. }
  49310. hasDynamic = hasDynamic || dynamic;
  49311. }
  49312. return hasDynamic;
  49313. },
  49314. getFullName: function() {
  49315. var me = this,
  49316. fullName = me.fullName,
  49317. bindings = me.bindings,
  49318. length = bindings.length,
  49319. i;
  49320. if (!fullName) {
  49321. fullName = '@[';
  49322. for (i = 0; i < length; ++i) {
  49323. if (i) {
  49324. fullName += ',';
  49325. }
  49326. fullName += bindings[i].getFullName();
  49327. }
  49328. fullName += ']';
  49329. me.fullName = fullName;
  49330. }
  49331. return fullName;
  49332. },
  49333. getRawValue: function() {
  49334. return this.lastValue;
  49335. },
  49336. isDescendantOf: function() {
  49337. return false;
  49338. },
  49339. isLoading: function() {
  49340. var bindings = this.bindings,
  49341. n = bindings.length;
  49342. for (; n-- > 0; ) {
  49343. if (bindings[n].isLoading()) {
  49344. return true;
  49345. }
  49346. }
  49347. return false;
  49348. },
  49349. isAvailable: function() {
  49350. var bindings = this.bindings,
  49351. n = bindings.length;
  49352. for (; n-- > 0; ) {
  49353. if (bindings[n].isAvailable()) {
  49354. return true;
  49355. }
  49356. }
  49357. return false;
  49358. },
  49359. isBindingStatic: function(binding) {
  49360. return binding.isTemplateBinding && binding.isStatic;
  49361. },
  49362. isStatic: function() {
  49363. var bindings = this.bindings,
  49364. len = bindings.length,
  49365. i, binding;
  49366. for (i = 0; i < len; ++i) {
  49367. binding = bindings[i];
  49368. if (!this.isBindingStatic(binding)) {
  49369. return false;
  49370. }
  49371. }
  49372. return true;
  49373. },
  49374. pruneStaticKeys: function() {
  49375. var value = Ext.apply({}, this.lastValue),
  49376. keys = this.staticKeys,
  49377. len = keys.length,
  49378. i;
  49379. for (i = 0; i < len; ++i) {
  49380. delete value[keys[i]];
  49381. }
  49382. return value;
  49383. },
  49384. react: function() {
  49385. this.notify(this.lastValue);
  49386. },
  49387. refresh: function() {},
  49388. privates: {
  49389. sort: function() {
  49390. this.scheduler.sortItems(this.bindings);
  49391. }
  49392. }
  49393. });
  49394. Ext.define('Ext.app.bind.Formula', {
  49395. extend: Ext.util.Schedulable,
  49396. statics: {
  49397. getFormulaParser: function(name) {
  49398. var cache = this.formulaCache,
  49399. parser, s;
  49400. if (!cache) {
  49401. cache = this.formulaCache = new Ext.util.LruCache({
  49402. maxSize: 20
  49403. });
  49404. }
  49405. parser = cache.get(name);
  49406. if (!parser) {
  49407. s = '[^\\.a-z0-9_]' + Ext.String.escapeRegex(name) + '\\(\\s*([\'"])(.*?)\\1\\s*\\)';
  49408. parser = new RegExp(s, 'gi');
  49409. cache.add(name, parser);
  49410. }
  49411. return parser;
  49412. }
  49413. },
  49414. isFormula: true,
  49415. calculation: null,
  49416. explicit: false,
  49417. set: null,
  49418. single: false,
  49419. fnKeywordArgumentNamesRe: /^function\s*[^\(]*\(\s*([^,\)\s]+)/,
  49420. fnKeywordRe: /^\s*function/,
  49421. replaceParenRe: /[\(\)]/g,
  49422. constructor: function(stub, formula) {
  49423. var me = this,
  49424. owner = stub.owner,
  49425. bindTo, expressions, getter, options;
  49426. me.owner = owner;
  49427. me.stub = stub;
  49428. me.callParent();
  49429. if (formula instanceof Function) {
  49430. me.get = getter = formula;
  49431. } else {
  49432. me.get = getter = formula.get;
  49433. me.set = formula.set;
  49434. expressions = formula.bind;
  49435. if (formula.single) {
  49436. me.single = formula.single;
  49437. }
  49438. if (expressions) {
  49439. bindTo = expressions.bindTo;
  49440. if (bindTo) {
  49441. options = Ext.apply({}, expressions);
  49442. delete options.bindTo;
  49443. expressions = bindTo;
  49444. }
  49445. }
  49446. }
  49447. if (!getter) {
  49448. Ext.raise('Must specify a getter method for a formula');
  49449. }
  49450. if (expressions) {
  49451. me.explicit = true;
  49452. } else {
  49453. expressions = getter.$expressions || me.parseFormula(getter);
  49454. }
  49455. me.binding = owner.bind(expressions, me.onChange, me, options);
  49456. },
  49457. destroy: function() {
  49458. var me = this,
  49459. binding = me.binding,
  49460. stub = me.stub;
  49461. if (binding) {
  49462. binding.destroy();
  49463. me.binding = null;
  49464. }
  49465. if (stub) {
  49466. stub.formula = null;
  49467. }
  49468. me.callParent();
  49469. me.getterFn = me.owner = null;
  49470. },
  49471. getFullName: function() {
  49472. return this.fullName || (this.fullName = this.stub.getFullName() + '=' + this.callParent() + ')');
  49473. },
  49474. getRawValue: function() {
  49475. return this.calculation;
  49476. },
  49477. onChange: function() {
  49478. if (!this.scheduled) {
  49479. this.schedule();
  49480. }
  49481. },
  49482. parseFormula: function(formula) {
  49483. var str = Ext.Function.toCode(formula),
  49484. defaultProp = 'get',
  49485. expressions = {
  49486. $literal: true
  49487. },
  49488. match, getterProp, formulaRe, expr;
  49489. if (this.fnKeywordRe.test(str)) {
  49490. match = this.fnKeywordArgumentNamesRe.exec(str);
  49491. if (match) {
  49492. getterProp = match[1];
  49493. }
  49494. } else {
  49495. match = str.split('=>')[0];
  49496. if (match) {
  49497. match = Ext.String.trim(match.replace(this.replaceParenRe, '')).split(',');
  49498. getterProp = match[0];
  49499. }
  49500. }
  49501. getterProp = getterProp || defaultProp;
  49502. formulaRe = Ext.app.bind.Formula.getFormulaParser(getterProp);
  49503. while ((match = formulaRe.exec(str))) {
  49504. expr = match[2];
  49505. expressions[expr] = expr;
  49506. }
  49507. expressions.$literal = true;
  49508. formula.$expressions = expressions;
  49509. return expressions;
  49510. },
  49511. react: function() {
  49512. var me = this,
  49513. owner = me.owner,
  49514. data = me.binding.lastValue,
  49515. arg;
  49516. if (me.explicit) {
  49517. arg = data;
  49518. } else {
  49519. arg = owner.getFormulaFn(data);
  49520. }
  49521. me.settingValue = true;
  49522. me.stub.set(me.calculation = me.get.call(owner, arg));
  49523. me.settingValue = false;
  49524. if (me.single) {
  49525. me.destroy();
  49526. }
  49527. },
  49528. setValue: function(value) {
  49529. this.set.call(this.stub.owner, value);
  49530. },
  49531. privates: {
  49532. getScheduler: function() {
  49533. var owner = this.owner;
  49534. return owner && owner.getScheduler();
  49535. },
  49536. sort: function() {
  49537. var me = this,
  49538. binding = me.binding;
  49539. if (!binding.destroyed) {
  49540. me.scheduler.sortItem(binding);
  49541. }
  49542. }
  49543. }
  49544. });
  49545. Ext.define('Ext.util.Fly', {
  49546. inheritableStatics: {
  49547. flyPoolSize: 2,
  49548. fly: function() {
  49549. var T = this,
  49550. flyweights = T.flyweights || (T.flyweights = []),
  49551. instance = flyweights.length ? flyweights.pop() : new T();
  49552. instance.reset.apply(instance, arguments);
  49553. return instance;
  49554. }
  49555. },
  49556. release: function() {
  49557. var me = this,
  49558. T = me.self,
  49559. flyweights = T.flyweights || (T.flyweights = []);
  49560. me.reset();
  49561. if (flyweights.length < T.flyPoolSize) {
  49562. flyweights.push(me);
  49563. }
  49564. },
  49565. reset: Ext.emptyFn
  49566. });
  49567. Ext.define('Ext.parse.Tokenizer', function(Tokenizer) {
  49568. var flyweights = (Tokenizer.flyweights = []),
  49569. BOOLEAN = {
  49570. literal: true,
  49571. "boolean": true,
  49572. type: 'boolean'
  49573. },
  49574. ERROR = {
  49575. error: true
  49576. },
  49577. IDENT = {
  49578. ident: true
  49579. },
  49580. LITERAL = {
  49581. literal: true
  49582. },
  49583. NULL = {
  49584. literal: true,
  49585. nil: true
  49586. },
  49587. NUMBER = {
  49588. literal: true,
  49589. number: true,
  49590. type: 'number'
  49591. },
  49592. STRING = {
  49593. literal: true,
  49594. string: true,
  49595. type: 'string'
  49596. };
  49597. return {
  49598. extend: Ext.util.Fly,
  49599. isTokenizer: true,
  49600. statics: {
  49601. BOOLEAN: BOOLEAN,
  49602. ERROR: ERROR,
  49603. IDENT: IDENT,
  49604. LITERAL: LITERAL,
  49605. NULL: NULL,
  49606. NUMBER: NUMBER,
  49607. STRING: STRING
  49608. },
  49609. config: {
  49610. keywords: {
  49611. 'null': {
  49612. type: 'literal',
  49613. is: NULL,
  49614. value: null
  49615. },
  49616. 'false': {
  49617. type: 'literal',
  49618. is: BOOLEAN,
  49619. value: false
  49620. },
  49621. 'true': {
  49622. type: 'literal',
  49623. is: BOOLEAN,
  49624. value: true
  49625. }
  49626. },
  49627. operators: {
  49628. '+': 'plus',
  49629. '-': 'minus',
  49630. '*': 'multiply',
  49631. '/': 'divide',
  49632. '!': 'not',
  49633. ',': 'comma',
  49634. ':': 'colon',
  49635. '[': 'arrayOpen',
  49636. ']': 'arrayClose',
  49637. '{': 'curlyOpen',
  49638. '}': 'curlyClose',
  49639. '(': 'parenOpen',
  49640. ')': 'parenClose'
  49641. },
  49642. patterns: null
  49643. },
  49644. error: null,
  49645. index: -1,
  49646. constructor: function(config) {
  49647. this.operators = {};
  49648. this.patterns = [];
  49649. this.initConfig(config);
  49650. },
  49651. next: function() {
  49652. var token = this.peek();
  49653. this.head = undefined;
  49654. return token;
  49655. },
  49656. peek: function() {
  49657. var me = this,
  49658. error = me.error,
  49659. token = me.head;
  49660. if (error) {
  49661. return error;
  49662. }
  49663. if (token === undefined) {
  49664. me.head = token = me.advance();
  49665. }
  49666. return token;
  49667. },
  49668. release: function() {
  49669. this.reset();
  49670. if (flyweights.length < Tokenizer.flyPoolSize) {
  49671. flyweights.push(this);
  49672. }
  49673. },
  49674. reset: function(text, pos, end) {
  49675. var me = this;
  49676. me.error = null;
  49677. me.head = undefined;
  49678. me.index = -1;
  49679. me.text = text || null;
  49680. me.pos = pos || 0;
  49681. me.end = (text && end == null) ? text.length : end;
  49682. return me;
  49683. },
  49684. privates: {
  49685. digitRe: /[0-9]/,
  49686. identFirstRe: /[a-z_$]/i,
  49687. identRe: /[0-9a-z_$]/i,
  49688. spaceRe: /[ \t]/,
  49689. end: 0,
  49690. head: undefined,
  49691. pos: 0,
  49692. text: null,
  49693. applyOperators: function(ops) {
  49694. var operators = this.operators,
  49695. block, c, def, i, len, name, op;
  49696. for (op in ops) {
  49697. block = operators;
  49698. name = ops[op];
  49699. len = op.length;
  49700. for (i = 0; i < len; ++i) {
  49701. c = op.charAt(i);
  49702. block = block[c] || (block[c] = {});
  49703. }
  49704. if (name) {
  49705. block.token = def = {
  49706. type: 'operator',
  49707. name: name,
  49708. value: op,
  49709. is: {
  49710. operator: true
  49711. }
  49712. };
  49713. def.is[name] = true;
  49714. } else {
  49715. block.token = null;
  49716. }
  49717. }
  49718. },
  49719. applyPatterns: function(pat) {
  49720. var patterns = this.patterns,
  49721. def, extract, name, re;
  49722. for (name in pat) {
  49723. def = pat[name];
  49724. extract = def.extract;
  49725. re = def.re;
  49726. delete def.extract;
  49727. delete def.re;
  49728. patterns.push({
  49729. name: name,
  49730. re: re,
  49731. extract: extract,
  49732. token: def
  49733. });
  49734. }
  49735. },
  49736. advance: function() {
  49737. var me = this,
  49738. spaceRe = me.spaceRe,
  49739. text = me.text,
  49740. length = me.end,
  49741. c;
  49742. while (me.pos < length) {
  49743. c = text.charAt(me.pos);
  49744. if (spaceRe.test(c)) {
  49745. ++me.pos;
  49746. continue;
  49747. }
  49748. me.index = me.pos;
  49749. return me.parse(c);
  49750. }
  49751. return null;
  49752. },
  49753. parse: function(c) {
  49754. var me = this,
  49755. digitRe = me.digitRe,
  49756. text = me.text,
  49757. length = me.end,
  49758. patterns = me.patterns,
  49759. i, match, pat, ret;
  49760. if (c === '.' && me.pos + 1 < length) {
  49761. if (digitRe.test(text.charAt(me.pos + 1))) {
  49762. ret = me.parseNumber();
  49763. }
  49764. }
  49765. if (!ret) {
  49766. for (i = 0; i < patterns.length; ++i) {
  49767. pat = patterns[i];
  49768. pat.re.lastIndex = me.pos;
  49769. match = pat.re.exec(text);
  49770. if (match && match.index === me.pos) {
  49771. ret = Ext.apply({
  49772. value: pat.extract ? pat.extract(match) : match[0]
  49773. }, pat.token);
  49774. me.pos += match[0].length;
  49775. break;
  49776. }
  49777. }
  49778. }
  49779. if (!ret && me.operators[c]) {
  49780. ret = me.parseOperator(c);
  49781. }
  49782. if (!ret) {
  49783. if (c === '"' || c === "'") {
  49784. ret = me.parseString();
  49785. } else if (digitRe.test(c)) {
  49786. ret = me.parseNumber();
  49787. } else if (me.identFirstRe.test(c)) {
  49788. ret = me.parseIdent();
  49789. } else {
  49790. ret = me.syntaxError('Unexpected character');
  49791. }
  49792. }
  49793. return ret;
  49794. },
  49795. parseIdent: function() {
  49796. var me = this,
  49797. identRe = me.identRe,
  49798. keywords = me.getKeywords(),
  49799. includeDots = !me.operators['.'],
  49800. text = me.text,
  49801. start = me.pos,
  49802. end = start,
  49803. length = me.end,
  49804. prev = 0,
  49805. c, value;
  49806. while (end < length) {
  49807. c = text.charAt(end);
  49808. if (includeDots && c === '.') {
  49809. if (prev === '.') {
  49810. return me.syntaxError(end, 'Unexpected dot operator');
  49811. }
  49812. ++end;
  49813. } else if (identRe.test(c)) {
  49814. ++end;
  49815. } else {
  49816. break;
  49817. }
  49818. prev = c;
  49819. }
  49820. if (prev === '.') {
  49821. return me.syntaxError(end - 1, 'Unexpected dot operator');
  49822. }
  49823. value = text.substring(start, me.pos = end);
  49824. return (keywords && keywords[value]) || {
  49825. type: 'ident',
  49826. is: IDENT,
  49827. value: value
  49828. };
  49829. },
  49830. parseNumber: function() {
  49831. var me = this,
  49832. digitRe = me.digitRe,
  49833. text = me.text,
  49834. start = me.pos,
  49835. length = me.end,
  49836. c, decimal, exp, token;
  49837. while (me.pos < length) {
  49838. c = text.charAt(me.pos);
  49839. if (c === '-' || c === '+') {
  49840. if (me.pos !== start) {
  49841. break;
  49842. }
  49843. ++me.pos;
  49844. } else if (c === '.') {
  49845. if (decimal) {
  49846. break;
  49847. }
  49848. decimal = true;
  49849. ++me.pos;
  49850. } else if (c === 'e' || c === 'E') {
  49851. if (exp) {
  49852. break;
  49853. }
  49854. decimal = exp = true;
  49855. c = text.charAt(++me.pos);
  49856. if (c === '-' || c === '+') {
  49857. ++me.pos;
  49858. }
  49859. }
  49860. else if (digitRe.test(c)) {
  49861. ++me.pos;
  49862. } else {
  49863. break;
  49864. }
  49865. }
  49866. token = {
  49867. type: 'literal',
  49868. is: NUMBER,
  49869. value: +text.substring(start, me.pos)
  49870. };
  49871. if (!isFinite(token.value)) {
  49872. token = me.syntaxError(start, 'Invalid number');
  49873. }
  49874. return token;
  49875. },
  49876. parseOperator: function(c) {
  49877. var me = this,
  49878. block = me.operators,
  49879. text = me.text,
  49880. length = me.end,
  49881. end = me.pos,
  49882. match, matchEnd, token;
  49883. while (block[c]) {
  49884. block = block[c];
  49885. token = block.token;
  49886. ++end;
  49887. if (token) {
  49888. match = token;
  49889. matchEnd = end;
  49890. }
  49891. if (end < length) {
  49892. c = text.charAt(end);
  49893. } else {
  49894. break;
  49895. }
  49896. }
  49897. if (match) {
  49898. me.pos = matchEnd;
  49899. }
  49900. return match;
  49901. },
  49902. parseString: function() {
  49903. var me = this,
  49904. text = me.text,
  49905. pos = me.pos,
  49906. start = pos,
  49907. length = me.end,
  49908. str = '',
  49909. c, closed, quote;
  49910. quote = text.charAt(pos++);
  49911. while (pos < length) {
  49912. c = text.charAt(pos++);
  49913. if (c === quote) {
  49914. closed = true;
  49915. break;
  49916. }
  49917. if (c === '\\' && pos < length) {
  49918. c = text.charAt(pos++);
  49919. }
  49920. str += c;
  49921. }
  49922. me.pos = pos;
  49923. if (!closed) {
  49924. return me.syntaxError(start, 'Unterminated string');
  49925. }
  49926. return {
  49927. type: 'literal',
  49928. is: STRING,
  49929. value: str
  49930. };
  49931. },
  49932. syntaxError: function(at, message) {
  49933. if (typeof at === 'string') {
  49934. message = at;
  49935. at = this.pos;
  49936. }
  49937. var suffix = (at == null) ? '' : (' (at index ' + at + ')'),
  49938. error = new Error(message + suffix);
  49939. error.type = 'error';
  49940. error.is = ERROR;
  49941. if (suffix) {
  49942. error.at = at;
  49943. }
  49944. return this.error = error;
  49945. }
  49946. }
  49947. };
  49948. });
  49949. Ext.define('Ext.parse.Symbol', {
  49950. priority: 0,
  49951. constructor: function(id, config) {
  49952. var me = this,
  49953. defaultProperty = me.defaultProperty;
  49954. if (config && typeof config === 'object') {
  49955. Ext.apply(me, config);
  49956. } else if (config !== undefined && defaultProperty) {
  49957. me[defaultProperty] = config;
  49958. }
  49959. me.id = id;
  49960. },
  49961. dump: function() {
  49962. var me = this,
  49963. ret = {
  49964. at: me.at,
  49965. arity: me.arity
  49966. },
  49967. i;
  49968. if ('value' in me) {
  49969. ret.value = me.value;
  49970. }
  49971. if (me.lhs) {
  49972. ret.lhs = me.lhs.dump();
  49973. ret.rhs = me.rhs.dump();
  49974. }
  49975. if (me.operand) {
  49976. ret.operand = me.operand.dump();
  49977. }
  49978. if (me.args) {
  49979. ret.args = [];
  49980. for (i = 0; i < me.args.length; ++i) {
  49981. ret.args.push(me.args[i].dump());
  49982. }
  49983. }
  49984. return ret;
  49985. },
  49986. led: function() {
  49987. this.parser.syntaxError(this.at, 'Missing operator');
  49988. },
  49989. nud: function() {
  49990. this.parser.syntaxError(this.at, 'Undefined');
  49991. },
  49992. update: function(config) {
  49993. if (config && typeof config === 'object') {
  49994. var me = this,
  49995. priority = config.priority,
  49996. led = config.led,
  49997. nud = config.nud;
  49998. if (me.priority <= priority) {
  49999. me.priority = priority;
  50000. }
  50001. if (led) {
  50002. me.led = led;
  50003. }
  50004. if (nud) {
  50005. me.nud = nud;
  50006. }
  50007. }
  50008. }
  50009. });
  50010. Ext.define('Ext.parse.symbol.Constant', {
  50011. extend: Ext.parse.Symbol,
  50012. arity: 'literal',
  50013. isLiteral: true,
  50014. defaultProperty: 'value',
  50015. constructor: function(id, config) {
  50016. this.callParent([
  50017. id,
  50018. config
  50019. ]);
  50020. this._value = this.value;
  50021. },
  50022. nud: function() {
  50023. var me = this;
  50024. me.value = me._value;
  50025. me.arity = 'literal';
  50026. me.isLiteral = true;
  50027. return me;
  50028. }
  50029. });
  50030. Ext.define('Ext.parse.symbol.Infix', {
  50031. extend: Ext.parse.Symbol,
  50032. arity: 'binary',
  50033. isBinary: true,
  50034. defaultProperty: 'priority',
  50035. led: function(left) {
  50036. var me = this;
  50037. me.lhs = left;
  50038. me.rhs = me.parser.parseExpression(me.priority);
  50039. me.arity = 'binary';
  50040. me.isBinary = true;
  50041. return me;
  50042. }
  50043. });
  50044. Ext.define('Ext.parse.symbol.InfixRight', {
  50045. extend: Ext.parse.symbol.Infix,
  50046. led: function(left) {
  50047. var me = this;
  50048. me.lhs = left;
  50049. me.rhs = me.parser.parseExpression(me.priority - 1);
  50050. me.arity = 'binary';
  50051. me.isBinary = true;
  50052. return me;
  50053. }
  50054. });
  50055. Ext.define('Ext.parse.symbol.Paren', {
  50056. extend: Ext.parse.Symbol,
  50057. arity: 'binary',
  50058. isBinary: true,
  50059. priority: 80,
  50060. led: function(left) {
  50061. var me = this,
  50062. args = [],
  50063. parser = me.parser,
  50064. id = left.id,
  50065. type = left.arity;
  50066. if (id !== '.' && id !== '[') {
  50067. if ((type !== "unary" || id !== "function") && type !== "ident" && id !== "(" && id !== "&&" && id !== "||" && id !== "?") {
  50068. parser.syntaxError(left.at, "Expected a variable name.");
  50069. }
  50070. }
  50071. me.arity = 'invoke';
  50072. me.isInvoke = true;
  50073. me.operand = left;
  50074. me.args = args;
  50075. while (parser.token.id !== ')') {
  50076. if (args.length) {
  50077. parser.advance(',');
  50078. }
  50079. args.push(parser.parseExpression());
  50080. }
  50081. parser.advance(')');
  50082. return me;
  50083. },
  50084. nud: function() {
  50085. var parser = this.parser,
  50086. ret = parser.parseExpression();
  50087. parser.advance(")");
  50088. return ret;
  50089. }
  50090. });
  50091. Ext.define('Ext.parse.symbol.Prefix', {
  50092. extend: Ext.parse.Symbol,
  50093. arity: 'unary',
  50094. isUnary: true,
  50095. priority: 70,
  50096. nud: function() {
  50097. var me = this;
  50098. me.operand = me.parser.parseExpression(me.priority);
  50099. me.arity = 'unary';
  50100. me.isUnary = true;
  50101. return me;
  50102. }
  50103. });
  50104. Ext.define('Ext.parse.Parser', function() {
  50105. var ITSELF = function() {
  50106. return this;
  50107. };
  50108. return {
  50109. extend: Ext.util.Fly,
  50110. isParser: true,
  50111. config: {
  50112. constants: {
  50113. 'null': null,
  50114. 'false': false,
  50115. 'true': true
  50116. },
  50117. infix: {
  50118. '===': 40,
  50119. '!==': 40,
  50120. '==': 40,
  50121. '!=': 40,
  50122. '<': 40,
  50123. '<=': 40,
  50124. '>': 40,
  50125. '>=': 40,
  50126. '+': 50,
  50127. '-': 50,
  50128. '*': 60,
  50129. '/': 60
  50130. },
  50131. infixRight: {
  50132. '&&': 30,
  50133. '||': 30
  50134. },
  50135. prefix: {
  50136. '!': 0,
  50137. '-': 0,
  50138. '+': 0
  50139. },
  50140. symbols: {
  50141. ':': 0,
  50142. ',': 0,
  50143. ')': 0,
  50144. '[': 0,
  50145. ']': 0,
  50146. '{': 0,
  50147. '}': 0,
  50148. '(end)': 0,
  50149. '(ident)': {
  50150. arity: 'ident',
  50151. isIdent: true,
  50152. nud: ITSELF
  50153. },
  50154. '(literal)': {
  50155. arity: 'literal',
  50156. isLiteral: true,
  50157. nud: ITSELF
  50158. },
  50159. '(': {
  50160. xclass: 'Ext.parse.symbol.Paren'
  50161. }
  50162. },
  50163. tokenizer: {
  50164. keywords: null
  50165. }
  50166. },
  50167. token: null,
  50168. constructor: function(config) {
  50169. this.symbols = {};
  50170. this.initConfig(config);
  50171. },
  50172. advance: function(expected) {
  50173. var me = this,
  50174. tokenizer = me.tokenizer,
  50175. token = tokenizer.peek(),
  50176. symbols = me.symbols,
  50177. index = tokenizer.index,
  50178. is, name, symbol, value;
  50179. if (me.error) {
  50180. throw me.error;
  50181. }
  50182. if (expected) {
  50183. me.expect(expected);
  50184. }
  50185. if (!token) {
  50186. return me.token = symbols['(end)'];
  50187. }
  50188. tokenizer.next();
  50189. is = token.is;
  50190. value = token.value;
  50191. if (is.ident) {
  50192. symbol = symbols[value] || symbols['(ident)'];
  50193. } else if (is.operator) {
  50194. if (!(symbol = symbols[value])) {
  50195. me.syntaxError(token.at, 'Unknown operator "' + value + '"');
  50196. }
  50197. name = token.name;
  50198. } else if (is.literal) {
  50199. symbol = symbols['(literal)'];
  50200. } else {
  50201. me.syntaxError(token.at, 'Unexpected token');
  50202. }
  50203. me.token = symbol = Ext.Object.chain(symbol);
  50204. symbol.at = index;
  50205. symbol.is = is;
  50206. symbol.value = value;
  50207. if (!symbol.arity) {
  50208. symbol.arity = token.type;
  50209. }
  50210. if (name) {
  50211. symbol.name = name;
  50212. }
  50213. return symbol;
  50214. },
  50215. expect: function(expected) {
  50216. var token = this.token;
  50217. if (expected !== token.id) {
  50218. this.syntaxError(token.at, 'Expected "' + expected + '"');
  50219. }
  50220. return this;
  50221. },
  50222. parseExpression: function(rightPriority) {
  50223. var me = this,
  50224. token = me.token,
  50225. left;
  50226. rightPriority = rightPriority || 0;
  50227. me.advance();
  50228. left = token.nud();
  50229. while (rightPriority < (token = me.token).priority) {
  50230. me.advance();
  50231. left = token.led(left);
  50232. }
  50233. return left;
  50234. },
  50235. reset: function(text, pos, end) {
  50236. var me = this;
  50237. me.error = me.token = null;
  50238. me.tokenizer.reset(text, pos, end);
  50239. me.advance();
  50240. return me;
  50241. },
  50242. syntaxError: function(at, message) {
  50243. if (typeof at === 'string') {
  50244. message = at;
  50245. at = this.pos;
  50246. }
  50247. var suffix = (at == null) ? '' : (' (at index ' + at + ')'),
  50248. error = new Error(message + suffix);
  50249. error.type = 'error';
  50250. if (suffix) {
  50251. error.at = at;
  50252. }
  50253. throw this.error = error;
  50254. },
  50255. privates: {
  50256. error: null,
  50257. addSymbol: function(id, config, type, update) {
  50258. var symbols = this.symbols,
  50259. symbol = symbols[id],
  50260. cfg, length, i;
  50261. if (symbol) {
  50262. if (typeof config === 'object') {
  50263. cfg = config;
  50264. } else if (update && type) {
  50265. update = Ext.Array.from(update);
  50266. length = update.length;
  50267. cfg = {};
  50268. for (i = 0; i < length; i++) {
  50269. cfg[update[i]] = type.prototype[update[i]];
  50270. }
  50271. } else {
  50272. return symbol;
  50273. }
  50274. symbol.update(cfg);
  50275. } else {
  50276. if (config && config.xclass) {
  50277. type = Ext.ClassManager.get(config.xclass);
  50278. } else {
  50279. type = type || Ext.parse.Symbol;
  50280. }
  50281. symbols[id] = symbol = new type(id, config);
  50282. symbol.parser = this;
  50283. }
  50284. return symbol;
  50285. },
  50286. addSymbols: function(symbols, type, update) {
  50287. var id;
  50288. for (id in symbols) {
  50289. this.addSymbol(id, symbols[id], type, update);
  50290. }
  50291. },
  50292. applyConstants: function(constants) {
  50293. this.addSymbols(constants, Ext.parse.symbol.Constant, 'nud');
  50294. },
  50295. applyInfix: function(operators) {
  50296. this.addSymbols(operators, Ext.parse.symbol.Infix, 'led');
  50297. },
  50298. applyInfixRight: function(operators) {
  50299. this.addSymbols(operators, Ext.parse.symbol.InfixRight, 'led');
  50300. },
  50301. applyPrefix: function(operators) {
  50302. this.addSymbols(operators, Ext.parse.symbol.Prefix, 'nud');
  50303. },
  50304. applySymbols: function(symbols) {
  50305. this.addSymbols(symbols);
  50306. },
  50307. applyTokenizer: function(config) {
  50308. var ret = config;
  50309. if (config && !config.isTokenizer) {
  50310. ret = new Ext.parse.Tokenizer(config);
  50311. }
  50312. this.tokenizer = ret;
  50313. }
  50314. }
  50315. };
  50316. });
  50317. Ext.define('Ext.app.bind.Parser', {
  50318. extend: Ext.parse.Parser,
  50319. infix: {
  50320. ':': {
  50321. priority: 70,
  50322. dump: function() {
  50323. var me = this,
  50324. ret = {
  50325. at: me.at,
  50326. arity: me.arity,
  50327. value: me.value,
  50328. operand: me.operand.dump(),
  50329. fmt: []
  50330. },
  50331. fmt = me.fmt,
  50332. i;
  50333. for (i = 0; i < fmt.length; ++i) {
  50334. ret.fmt.push(fmt[i].dump());
  50335. }
  50336. return ret;
  50337. },
  50338. led: function(left) {
  50339. var me = this;
  50340. me.arity = 'formatter';
  50341. me.operand = left;
  50342. me.fmt = me.parser.parseFmt();
  50343. return me;
  50344. }
  50345. },
  50346. '?': {
  50347. priority: 20,
  50348. led: function(left) {
  50349. var me = this,
  50350. parser = me.parser,
  50351. symbol = parser.symbols[':'],
  50352. temp;
  50353. me.condition = left;
  50354. temp = symbol.priority;
  50355. symbol.priority = 0;
  50356. me.tv = parser.parseExpression(0);
  50357. me.parser.advance(':');
  50358. symbol.priority = temp;
  50359. me.fv = parser.parseExpression(0);
  50360. me.arity = 'ternary';
  50361. return me;
  50362. }
  50363. }
  50364. },
  50365. symbols: {
  50366. '(': {
  50367. nud: function() {
  50368. var parser = this.parser,
  50369. symbol = parser.symbols[':'],
  50370. ret, temp;
  50371. temp = symbol.priority;
  50372. symbol.priority = 70;
  50373. ret = parser.parseExpression();
  50374. parser.advance(")");
  50375. symbol.priority = temp;
  50376. return ret;
  50377. }
  50378. }
  50379. },
  50380. prefix: {
  50381. '@': 0
  50382. },
  50383. tokenizer: {
  50384. operators: {
  50385. '@': 'at',
  50386. '?': 'qmark',
  50387. '===': 'feq',
  50388. '!==': 'fneq',
  50389. '==': 'eq',
  50390. '!=': 'neq',
  50391. '<': 'lt',
  50392. '<=': 'lte',
  50393. '>': 'gt',
  50394. '>=': 'gte',
  50395. '&&': 'and',
  50396. '||': 'or'
  50397. }
  50398. },
  50399. compileExpression: function(tokens, tokensMaps) {
  50400. var me = this,
  50401. debug, fn;
  50402. me.tokens = tokens;
  50403. me.tokensMap = tokensMaps;
  50404. debug = me.token.value === '@' && me.tokenizer.peek();
  50405. if (debug) {
  50406. debug = debug.value === 'debugger';
  50407. if (debug) {
  50408. me.advance();
  50409. me.advance();
  50410. }
  50411. }
  50412. fn = me.parseSlot(me.parseExpression(), debug);
  50413. me.tokens = me.tokensMap = null;
  50414. return fn;
  50415. },
  50416. compileFormat: function() {
  50417. var me = this,
  50418. fn;
  50419. try {
  50420. fn = me.parseSlot({
  50421. arity: 'formatter',
  50422. fmt: me.parseFmt(),
  50423. operand: {
  50424. arity: 'ident',
  50425. value: 'dummy'
  50426. }
  50427. });
  50428. me.expect('(end)');
  50429. }
  50430. catch (e) {
  50431. Ext.raise('Invalid format expression: "' + me.tokenizer.text + '"');
  50432. }
  50433. return fn;
  50434. },
  50435. privates: {
  50436. useEval: Ext.isGecko,
  50437. escapeRe: /(["'\\])/g,
  50438. parseFmt: function() {
  50439. var me = this,
  50440. fmt = [],
  50441. priority = me.symbols[':'].priority,
  50442. expr;
  50443. do {
  50444. if (fmt.length) {
  50445. me.advance();
  50446. }
  50447. expr = me.parseExpression(priority);
  50448. if (expr.isIdent || expr.isInvoke) {
  50449. fmt.push(expr);
  50450. } else {
  50451. me.syntaxError(expr.at, 'Expected formatter name');
  50452. }
  50453. } while (me.token.id === ':');
  50454. return fmt;
  50455. },
  50456. parseSlot: function(expr, debug) {
  50457. var me = this,
  50458. defs = [],
  50459. body = [],
  50460. tokens = me.tokens || [],
  50461. fn, code, i, length, temp;
  50462. me.definitions = defs;
  50463. me.body = body;
  50464. body.push('return ' + me.compile(expr) + ';');
  50465. length = tokens.length;
  50466. code = 'var fm = Ext.util.Format,\nme,';
  50467. temp = 'var a = Ext.Array.from(values);\nme = scope;\n';
  50468. if (tokens.length) {
  50469. for (i = 0; i < length; i++) {
  50470. code += 'v' + i + ((i === length - 1) ? ';' : ',');
  50471. temp += 'v' + i + ' = a[' + i + ']; ';
  50472. }
  50473. } else {
  50474. code += 'v0;';
  50475. temp += 'v0 = a[0];';
  50476. }
  50477. defs = Ext.Array.insert(defs, 0, [
  50478. code
  50479. ]);
  50480. body = Ext.Array.insert(body, 0, [
  50481. temp
  50482. ]);
  50483. body = body.join('\n');
  50484. if (debug) {
  50485. body = 'debugger;\n' + body;
  50486. }
  50487. defs.push((me.useEval ? '$=' : 'return') + ' function (values, scope) {', body, '}');
  50488. code = defs.join('\n');
  50489. fn = me.useEval ? me.evalFn(code) : (new Function('Ext', code))(Ext);
  50490. me.definitions = me.body = null;
  50491. return fn;
  50492. },
  50493. compile: function(expr) {
  50494. var me = this,
  50495. v;
  50496. switch (expr.arity) {
  50497. case 'ident':
  50498. return me.addToken(expr.value);
  50499. case 'literal':
  50500. v = expr.value;
  50501. return (typeof v === 'string') ? '"' + String(v).replace(me.escapeRe, '\\$1') + '"' : v;
  50502. case 'unary':
  50503. return me.compileUnary(expr);
  50504. case 'binary':
  50505. return me.compileBinary(expr);
  50506. case 'ternary':
  50507. return me.compileTernary(expr);
  50508. case 'formatter':
  50509. return me.compileFormatter(expr);
  50510. }
  50511. return this.syntaxError(expr.at, 'Compile error! Unknown symbol');
  50512. },
  50513. compileUnary: function(expr) {
  50514. var v = expr.value,
  50515. op = expr.operand;
  50516. if (v === '!' || v === '-' || v === '+') {
  50517. return v + '(' + this.compile(op) + ')';
  50518. } else if (v === '@') {
  50519. if (!op.isIdent) {
  50520. return this.syntaxError(expr.at, 'Compile error! Unexpected symbol');
  50521. }
  50522. return op.value;
  50523. }
  50524. return '';
  50525. },
  50526. compileBinary: function(expr) {
  50527. return '(' + this.compile(expr.lhs) + ' ' + expr.value + ' ' + this.compile(expr.rhs) + ')';
  50528. },
  50529. compileTernary: function(expr) {
  50530. return '(' + this.compile(expr.condition) + ' ? ' + this.compile(expr.tv) + ' : ' + this.compile(expr.fv) + ')';
  50531. },
  50532. compileFormatter: function(expr) {
  50533. var me = this,
  50534. fmt = expr.fmt,
  50535. length = fmt.length,
  50536. body = [
  50537. 'var ret;'
  50538. ],
  50539. i;
  50540. if (fmt.length) {
  50541. body.push('ret = ' + me.compileFormatFn(fmt[0], me.compile(expr.operand)) + ';');
  50542. for (i = 1; i < length; i++) {
  50543. body.push('ret = ' + me.compileFormatFn(fmt[i], 'ret') + ';');
  50544. }
  50545. }
  50546. body.push('return ret;');
  50547. return me.addFn(body.join('\n'));
  50548. },
  50549. compileFormatFn: function(expr, value) {
  50550. var fmt,
  50551. args = [],
  50552. code = '',
  50553. length, i;
  50554. if (expr.isIdent) {
  50555. fmt = expr.value;
  50556. } else if (expr.isInvoke) {
  50557. fmt = expr.operand.value;
  50558. args = expr.args;
  50559. }
  50560. if (fmt.substring(0, 5) === 'this.') {
  50561. fmt = 'me.' + fmt.substring(5);
  50562. } else {
  50563. if (!(fmt in Ext.util.Format)) {
  50564. return this.syntaxError(expr.at, 'Compile error! Invalid format specified "' + fmt + '"');
  50565. }
  50566. fmt = 'fm.' + fmt;
  50567. }
  50568. code += value;
  50569. length = args.length;
  50570. for (i = 0; i < length; i++) {
  50571. code += ', ' + this.compile(args[i]);
  50572. }
  50573. return fmt + '(' + code + ')';
  50574. },
  50575. addFn: function(body) {
  50576. var defs = this.definitions,
  50577. name = 'f' + defs.length;
  50578. defs.push('function ' + name + '() {', body, '}');
  50579. return name + '()';
  50580. },
  50581. evalFn: function($) {
  50582. eval($);
  50583. return $;
  50584. },
  50585. addToken: function(token) {
  50586. var tokensMap = this.tokensMap,
  50587. tokens = this.tokens,
  50588. pos = 0;
  50589. if (tokensMap && tokens) {
  50590. if (token in tokensMap) {
  50591. pos = tokensMap[token];
  50592. } else {
  50593. tokensMap[token] = pos = tokens.length;
  50594. tokens.push(token);
  50595. }
  50596. }
  50597. return 'v' + pos;
  50598. }
  50599. }
  50600. });
  50601. Ext.define('Ext.app.bind.Template', {
  50602. escapes: false,
  50603. buffer: null,
  50604. slots: null,
  50605. tokens: null,
  50606. constructor: function(text) {
  50607. var me = this,
  50608. initters = me._initters,
  50609. name;
  50610. me.text = text;
  50611. for (name in initters) {
  50612. me[name] = initters[name];
  50613. }
  50614. },
  50615. _initters: {
  50616. apply: function(values, scope) {
  50617. return this.parse().apply(values, scope);
  50618. },
  50619. getTokens: function() {
  50620. return this.parse().getTokens();
  50621. }
  50622. },
  50623. apply: function(values, scope) {
  50624. var me = this,
  50625. slots = me.slots,
  50626. buffer = me.buffer,
  50627. length = slots.length,
  50628. i, slot;
  50629. for (i = 0; i < length; ++i) {
  50630. slot = slots[i];
  50631. if (slot) {
  50632. buffer[i] = slot(values, scope);
  50633. }
  50634. }
  50635. if (slot && me.single) {
  50636. return buffer[0];
  50637. }
  50638. return buffer.join('');
  50639. },
  50640. getText: function() {
  50641. return this.buffer.join('');
  50642. },
  50643. getTokens: function() {
  50644. return this.tokens;
  50645. },
  50646. isStatic: function() {
  50647. var tokens = this.getTokens(),
  50648. slots = this.slots;
  50649. return (tokens.length === 0 && slots.length === 0);
  50650. },
  50651. privates: {
  50652. literalChar: '~',
  50653. escapeChar: '\\',
  50654. parse: function() {
  50655. var me = this,
  50656. text = me.text,
  50657. parser = Ext.app.bind.Parser.fly(),
  50658. buffer = (me.buffer = []),
  50659. slots = (me.slots = []),
  50660. length = text.length,
  50661. pos = 0,
  50662. escapes = me.escapes,
  50663. current = '',
  50664. i = 0,
  50665. esc = me.escapeChar,
  50666. lit = me.literalChar,
  50667. escaped, lastEscaped, c, prev, key;
  50668. for (key in me._initters) {
  50669. delete me[key];
  50670. }
  50671. me.tokens = [];
  50672. me.tokensMap = {};
  50673. while (i < length) {
  50674. c = text[i];
  50675. lastEscaped = escaped;
  50676. escaped = escapes && c === esc;
  50677. if (escaped) {
  50678. c = text[i + 1];
  50679. ++i;
  50680. } else if (c === lit && prev === lit && !lastEscaped) {
  50681. current = current.slice(0, -1);
  50682. current += text.substring(i + 1);
  50683. break;
  50684. } else if (c === '{') {
  50685. if (current) {
  50686. buffer[pos++] = current;
  50687. current = '';
  50688. }
  50689. parser.reset(text, i + 1);
  50690. i = me.parseExpression(parser, pos);
  50691. ++pos;
  50692. continue;
  50693. }
  50694. current += c;
  50695. ++i;
  50696. prev = c;
  50697. }
  50698. if (current) {
  50699. buffer[pos] = current;
  50700. }
  50701. parser.release();
  50702. me.single = buffer.length === 0 && slots.length === 1;
  50703. return me;
  50704. },
  50705. parseExpression: function(parser, pos) {
  50706. var i;
  50707. this.slots[pos] = parser.compileExpression(this.tokens, this.tokensMap);
  50708. i = parser.token.at + 1;
  50709. parser.expect('}');
  50710. return i;
  50711. }
  50712. }
  50713. });
  50714. Ext.define('Ext.app.bind.TemplateBinding', {
  50715. extend: Ext.app.bind.BaseBinding,
  50716. isTemplateBinding: true,
  50717. lastValue: undefined,
  50718. value: undefined,
  50719. constructor: function(template, owner, callback, scope, options) {
  50720. var me = this,
  50721. tpl = new Ext.app.bind.Template(template),
  50722. tokens = tpl.getTokens();
  50723. me.callParent([
  50724. owner,
  50725. callback,
  50726. scope,
  50727. options
  50728. ]);
  50729. me.tpl = tpl;
  50730. me.tokens = tokens;
  50731. tokens.$literal = true;
  50732. if (!tpl.isStatic()) {
  50733. me.multiBinding = new Ext.app.bind.Multi(tokens, owner, me.onBindData, me);
  50734. } else {
  50735. me.isStatic = true;
  50736. me.onData(tpl.getText());
  50737. }
  50738. },
  50739. destroy: function() {
  50740. var me = this;
  50741. Ext.destroy(me.multiBinding);
  50742. me.tpl = me.multiBinding = null;
  50743. me.callParent();
  50744. },
  50745. getFullName: function() {
  50746. var multi = this.multiBinding;
  50747. return this.fullName || (this.fullName = '$' + (multi ? multi.getFullName() : this.callParent()));
  50748. },
  50749. getRawValue: function() {
  50750. return this.value;
  50751. },
  50752. getTemplateScope: function() {
  50753. return null;
  50754. },
  50755. isAvailable: function() {
  50756. var multi = this.multiBinding;
  50757. return multi ? multi.isAvailable() : false;
  50758. },
  50759. isDescendantOf: function() {
  50760. return false;
  50761. },
  50762. isLoading: function() {
  50763. var multi = this.multiBinding;
  50764. return multi ? multi.isLoading() : false;
  50765. },
  50766. onBindData: function(data) {
  50767. this.onData(this.tpl.apply(data, this.getTemplateScope()));
  50768. },
  50769. onData: function(value) {
  50770. var me = this,
  50771. lastValue = me.value;
  50772. if (lastValue !== (me.value = value)) {
  50773. me.lastValue = lastValue;
  50774. me.schedule();
  50775. }
  50776. },
  50777. react: function() {
  50778. this.notify(this.value);
  50779. },
  50780. refresh: function() {
  50781. var multi = this.multiBinding;
  50782. if (multi) {
  50783. multi.refresh();
  50784. }
  50785. },
  50786. privates: {
  50787. sort: function() {
  50788. var multi = this.multiBinding;
  50789. if (multi) {
  50790. this.scheduler.sortItem(multi);
  50791. }
  50792. }
  50793. }
  50794. });
  50795. Ext.define('Ext.data.ChainedStore', {
  50796. extend: Ext.data.AbstractStore,
  50797. alias: 'store.chained',
  50798. mixins: [
  50799. Ext.data.LocalStore
  50800. ],
  50801. isChainedStore: true,
  50802. config: {
  50803. source: null,
  50804. remoteFilter: false,
  50805. remoteSort: false
  50806. },
  50807. syncSourceGrouping: false,
  50808. updateRemoteFilter: function(remoteFilter, oldRemoteFilter) {
  50809. if (remoteFilter) {
  50810. Ext.raise('Remote filtering cannot be used with chained stores.');
  50811. }
  50812. this.callParent([
  50813. remoteFilter,
  50814. oldRemoteFilter
  50815. ]);
  50816. },
  50817. updateRemoteSort: function(remoteSort, oldRemoteSort) {
  50818. if (remoteSort) {
  50819. Ext.raise('Remote sorting cannot be used with chained stores.');
  50820. }
  50821. this.callParent([
  50822. remoteSort,
  50823. oldRemoteSort
  50824. ]);
  50825. },
  50826. remove: function() {
  50827. var source = this.getSource();
  50828. if (!source) {
  50829. Ext.raise('Cannot remove records with no source.');
  50830. }
  50831. return source.remove.apply(source, arguments);
  50832. },
  50833. removeAll: function() {
  50834. var source = this.getSource();
  50835. if (!source) {
  50836. Ext.raise('Cannot remove records with no source.');
  50837. }
  50838. return source.removeAll();
  50839. },
  50840. getData: function() {
  50841. var me = this,
  50842. data = me.data;
  50843. if (!data) {
  50844. me.data = data = me.constructDataCollection();
  50845. }
  50846. return data;
  50847. },
  50848. getTotalCount: function() {
  50849. return this.getCount();
  50850. },
  50851. getSession: function() {
  50852. return this.getSourceValue('getSession', null);
  50853. },
  50854. applySource: function(source) {
  50855. if (source) {
  50856. var original = source,
  50857. s;
  50858. source = Ext.data.StoreManager.lookup(source);
  50859. if (!source) {
  50860. s = 'Invalid source {0}specified for Ext.data.ChainedStore';
  50861. s = Ext.String.format(s, typeof original === 'string' ? '"' + original + '" ' : '');
  50862. Ext.raise(s);
  50863. }
  50864. }
  50865. return source;
  50866. },
  50867. updateSource: function(source, oldSource) {
  50868. var me = this,
  50869. data;
  50870. if (oldSource && !oldSource.destroyed) {
  50871. oldSource.removeObserver(me);
  50872. }
  50873. if (source) {
  50874. data = me.getData();
  50875. data.setSource(source.getData());
  50876. if (me.syncSourceGrouping) {
  50877. me.setGrouper(source.getGrouper());
  50878. }
  50879. if (!me.isInitializing) {
  50880. me.fireEvent('refresh', me);
  50881. me.fireEvent('datachanged', me);
  50882. }
  50883. source.addObserver(me);
  50884. }
  50885. },
  50886. getModel: function() {
  50887. return this.getSourceValue('getModel', null);
  50888. },
  50889. getProxy: function() {
  50890. return null;
  50891. },
  50892. onCollectionAdd: function(collection, info) {
  50893. var me = this,
  50894. records = info.items,
  50895. lastChunk = !info.next;
  50896. if (me.ignoreCollectionAdd) {
  50897. return;
  50898. }
  50899. if (me.activeRanges) {
  50900. me.syncActiveRanges();
  50901. }
  50902. me.fireEvent('add', me, records, info.at);
  50903. if (lastChunk) {
  50904. me.fireEvent('datachanged', me);
  50905. }
  50906. },
  50907. onCollectionItemChange: function(collection, info) {
  50908. var me = this,
  50909. record = info.item,
  50910. modifiedFieldNames = info.modified || null,
  50911. type = info.meta;
  50912. if (me.activeRanges && info.newIndex !== info.oldIndex) {
  50913. me.syncActiveRanges();
  50914. }
  50915. me.onUpdate(record, type, modifiedFieldNames, info);
  50916. me.fireEvent('update', me, record, type, modifiedFieldNames, info);
  50917. me.fireEvent('datachanged', me);
  50918. },
  50919. onCollectionUpdateKey: function(source, details) {
  50920. this.fireEvent('idchanged', this, details.item, details.oldKey, details.newKey);
  50921. },
  50922. onUpdate: Ext.emptyFn,
  50923. lastCollectionRefesh: null,
  50924. onCollectionRefresh: function(collection) {
  50925. var me = this,
  50926. gen = collection.generation;
  50927. if (!me.isConfiguring && me.lastCollectionRefesh !== gen) {
  50928. me.lastCollectionRefesh = gen;
  50929. me.fireEvent('datachanged', me);
  50930. me.fireEvent('refresh', me);
  50931. }
  50932. },
  50933. onCollectionRemove: function(collection, info) {
  50934. var me = this,
  50935. records = info.items,
  50936. lastChunk = !info.next;
  50937. if (me.ignoreCollectionRemove) {
  50938. return;
  50939. }
  50940. me.fireEvent('remove', me, records, info.at, false);
  50941. if (lastChunk) {
  50942. me.fireEvent('datachanged', me);
  50943. }
  50944. },
  50945. onSourceBeforeLoad: function(source, operation) {
  50946. this.fireEvent('beforeload', this, operation);
  50947. this.callObservers('BeforeLoad', [
  50948. operation
  50949. ]);
  50950. },
  50951. onSourceAfterLoad: function(source, records, successful, operation) {
  50952. this.fireEvent('load', this, records, successful, operation);
  50953. this.callObservers('AfterLoad', [
  50954. records,
  50955. successful,
  50956. operation
  50957. ]);
  50958. },
  50959. onFilterEndUpdate: function() {
  50960. var me = this;
  50961. if (me.getData().generation === me.lastCollectionRefesh && !me.getRemoteFilter()) {
  50962. me.suppressNextFilter = true;
  50963. }
  50964. me.callParent(arguments);
  50965. me.callObservers('Filter');
  50966. },
  50967. onSourceBeforePopulate: function() {
  50968. this.ignoreCollectionAdd = true;
  50969. this.callObservers('BeforePopulate');
  50970. },
  50971. onSourceAfterPopulate: function() {
  50972. var me = this;
  50973. me.ignoreCollectionAdd = false;
  50974. me.fireEvent('datachanged', me);
  50975. me.fireEvent('refresh', me);
  50976. this.callObservers('AfterPopulate');
  50977. },
  50978. onSourceBeforeClear: function() {
  50979. this.ignoreCollectionRemove = true;
  50980. this.callObservers('BeforeClear');
  50981. },
  50982. onSourceAfterClear: function() {
  50983. this.ignoreCollectionRemove = false;
  50984. this.callObservers('AfterClear');
  50985. },
  50986. onSourceBeforeRemoveAll: function() {
  50987. this.ignoreCollectionRemove = true;
  50988. this.callObservers('BeforeRemoveAll');
  50989. },
  50990. onSourceAfterRemoveAll: function(source, silent) {
  50991. var me = this;
  50992. me.ignoreCollectionRemove = false;
  50993. if (!silent) {
  50994. me.fireEvent('clear', me);
  50995. me.fireEvent('datachanged', me);
  50996. }
  50997. this.callObservers('AfterRemoveAll', [
  50998. silent
  50999. ]);
  51000. },
  51001. onSourceFilter: function() {
  51002. var me = this,
  51003. gen = me.getData().generation;
  51004. if (me.lastCollectionRefesh !== gen) {
  51005. me.lastCollectionRefesh = gen;
  51006. me.fireEvent('refresh', me);
  51007. me.fireEvent('datachanged', me);
  51008. }
  51009. },
  51010. onSourceGrouperChange: function(source, grouper) {
  51011. if (this.syncSourceGrouping) {
  51012. this.setGrouper(grouper);
  51013. }
  51014. },
  51015. hasPendingLoad: function() {
  51016. return this.getSourceValue('hasPendingLoad', false);
  51017. },
  51018. isLoaded: function() {
  51019. return this.getSourceValue('isLoaded', false);
  51020. },
  51021. isLoading: function() {
  51022. return this.getSourceValue('isLoading', false);
  51023. },
  51024. doDestroy: function() {
  51025. var me = this;
  51026. me.observers = null;
  51027. me.setSource(null);
  51028. me.getData().destroy(true);
  51029. me.data = null;
  51030. me.callParent();
  51031. },
  51032. privates: {
  51033. getSourceValue: function(method, defaultValue) {
  51034. var source = this.getSource(),
  51035. val = defaultValue;
  51036. if (source && !source.destroyed) {
  51037. val = source[method]();
  51038. }
  51039. return val;
  51040. },
  51041. isMoving: function() {
  51042. var source = this.getSource();
  51043. return source.isMoving ? source.isMoving.apply(source, arguments) : false;
  51044. },
  51045. loadsSynchronously: function() {
  51046. return this.getSource().loadsSynchronously();
  51047. }
  51048. }
  51049. });
  51050. Ext.define('Ext.app.ViewModel', {
  51051. mixins: [
  51052. Ext.mixin.Factoryable,
  51053. Ext.mixin.Identifiable
  51054. ],
  51055. alias: 'viewmodel.default',
  51056. isViewModel: true,
  51057. factoryConfig: {
  51058. name: 'viewModel'
  51059. },
  51060. collectTimeout: 100,
  51061. expressionRe: /^(?:\{(?:(\d+)|([a-z_][\w.]*))\})$/i,
  51062. statics: {
  51063. escape: function(value) {
  51064. var ret = value,
  51065. key;
  51066. if (typeof value === 'string') {
  51067. ret = '~~' + value;
  51068. } else if (value && value.constructor === Object) {
  51069. ret = {};
  51070. for (key in value) {
  51071. ret[key] = this.escape(value[key]);
  51072. }
  51073. }
  51074. return ret;
  51075. }
  51076. },
  51077. $configStrict: false,
  51078. config: {
  51079. data: true,
  51080. formulas: {
  51081. $value: null,
  51082. merge: function(newValue, currentValue, target, mixinClass) {
  51083. return this.mergeNew(newValue, currentValue, target, mixinClass);
  51084. }
  51085. },
  51086. links: null,
  51087. parent: null,
  51088. root: true,
  51089. scheduler: null,
  51090. schema: 'default',
  51091. session: null,
  51092. stores: null,
  51093. view: null
  51094. },
  51095. constructor: function(config) {
  51096. this.bindings = {};
  51097. this.initConfig(config);
  51098. },
  51099. destroy: function() {
  51100. var me = this,
  51101. scheduler = me._scheduler,
  51102. stores = me.storeInfo,
  51103. parent = me.getParent(),
  51104. task = me.collectTask,
  51105. children = me.children,
  51106. bindings = me.bindings,
  51107. key, store, autoDestroy, storeBinding;
  51108. me.destroying = true;
  51109. if (task) {
  51110. task.cancel();
  51111. me.collectTask = null;
  51112. }
  51113. if (children) {
  51114. for (key in children) {
  51115. children[key].destroy();
  51116. }
  51117. }
  51118. if (stores) {
  51119. for (key in stores) {
  51120. store = stores[key];
  51121. storeBinding = store.$binding;
  51122. autoDestroy = store.autoDestroy;
  51123. if (autoDestroy || (!store.$wasInstance && autoDestroy !== false)) {
  51124. store.destroy();
  51125. }
  51126. Ext.destroy(storeBinding);
  51127. }
  51128. }
  51129. if (parent) {
  51130. parent.unregisterChild(me);
  51131. }
  51132. me.getRoot().destroy();
  51133. for (key in bindings) {
  51134. bindings[key].destroy();
  51135. }
  51136. if (scheduler && scheduler.$owner === me) {
  51137. scheduler.$owner = null;
  51138. scheduler.destroy();
  51139. }
  51140. me.children = me.storeInfo = me._session = me._view = me._scheduler = me.bindings = me._root = me._parent = me.formulaFn = me.$formulaData = null;
  51141. me.callParent();
  51142. },
  51143. bind: function(descriptor, callback, scope, options) {
  51144. var me = this,
  51145. track = true,
  51146. binding;
  51147. scope = scope || me;
  51148. if (!options && descriptor.bindTo !== undefined && !Ext.isString(descriptor)) {
  51149. options = descriptor;
  51150. descriptor = options.bindTo;
  51151. }
  51152. if (!Ext.isString(descriptor)) {
  51153. binding = new Ext.app.bind.Multi(descriptor, me, callback, scope, options);
  51154. } else if (me.expressionRe.test(descriptor)) {
  51155. descriptor = descriptor.substring(1, descriptor.length - 1);
  51156. binding = me.bindExpression(descriptor, callback, scope, options);
  51157. track = false;
  51158. } else {
  51159. binding = new Ext.app.bind.TemplateBinding(descriptor, me, callback, scope, options);
  51160. }
  51161. if (track) {
  51162. me.bindings[binding.id] = binding;
  51163. }
  51164. return binding;
  51165. },
  51166. getSession: function() {
  51167. var me = this,
  51168. session = me._session,
  51169. parent;
  51170. if (!session && (parent = me.getParent())) {
  51171. me.setSession(session = parent.getSession());
  51172. }
  51173. return session || null;
  51174. },
  51175. getStore: function(key) {
  51176. var storeInfo = this.storeInfo,
  51177. store;
  51178. if (storeInfo) {
  51179. store = storeInfo[key];
  51180. }
  51181. return store || null;
  51182. },
  51183. linkTo: function(key, reference) {
  51184. var me = this,
  51185. stub, create, id, modelType, linkStub, rec;
  51186. if (key.indexOf('.') > -1) {
  51187. Ext.raise('Links can only be at the top-level: "' + key + '"');
  51188. }
  51189. if (reference.isModel) {
  51190. reference = {
  51191. type: reference.entityName,
  51192. id: reference.id
  51193. };
  51194. }
  51195. modelType = reference.type || reference.reference;
  51196. create = reference.create;
  51197. if (modelType) {
  51198. id = reference.id;
  51199. if (!reference.create && Ext.isEmpty(id)) {
  51200. Ext.raise('No id specified. To create a phantom model, specify "create: true" ' + 'as part of the reference.');
  51201. }
  51202. if (create) {
  51203. id = undefined;
  51204. }
  51205. rec = me.getRecord(modelType, id);
  51206. if (Ext.isObject(create)) {
  51207. rec.set(create);
  51208. rec.commit();
  51209. rec.phantom = true;
  51210. }
  51211. stub = me.getRoot().createStubChild(key);
  51212. stub.set(rec);
  51213. } else {
  51214. stub = me.getStub(key);
  51215. if (!stub.isLinkStub) {
  51216. linkStub = new Ext.app.bind.LinkStub(me, stub.name);
  51217. stub.graft(linkStub);
  51218. stub = linkStub;
  51219. }
  51220. stub.link(reference);
  51221. }
  51222. },
  51223. notify: function() {
  51224. var scheduler = this.getScheduler();
  51225. if (!scheduler.firing) {
  51226. scheduler.notify();
  51227. }
  51228. },
  51229. get: function(path) {
  51230. return this.getStub(path).getValue();
  51231. },
  51232. set: function(path, value) {
  51233. var me = this,
  51234. obj, stub;
  51235. me.getData();
  51236. if (value === undefined && path && path.constructor === Object) {
  51237. stub = me.getRoot();
  51238. value = path;
  51239. } else if (path && path.indexOf('.') < 0) {
  51240. obj = {};
  51241. obj[path] = value;
  51242. value = obj;
  51243. stub = me.getRoot();
  51244. } else {
  51245. stub = me.getStub(path);
  51246. }
  51247. stub.set(value);
  51248. },
  51249. privates: {
  51250. registerChild: function(child) {
  51251. var children = this.children;
  51252. if (!children) {
  51253. this.children = children = {};
  51254. }
  51255. children[child.getId()] = child;
  51256. },
  51257. unregisterChild: function(child) {
  51258. var children = this.children;
  51259. if (!this.destroying && children) {
  51260. delete children[child.getId()];
  51261. }
  51262. },
  51263. getRecord: function(type, id) {
  51264. var session = this.getSession(),
  51265. Model = type,
  51266. hasId = id !== undefined,
  51267. record;
  51268. if (session) {
  51269. if (hasId) {
  51270. record = session.getRecord(type, id);
  51271. } else {
  51272. record = session.createRecord(type);
  51273. }
  51274. } else {
  51275. if (!Model.$isClass) {
  51276. Model = this.getSchema().getEntity(Model);
  51277. if (!Model) {
  51278. Ext.raise('Invalid model name: ' + type);
  51279. }
  51280. }
  51281. if (hasId) {
  51282. record = Model.createWithId(id);
  51283. record.load();
  51284. } else {
  51285. record = new Model();
  51286. }
  51287. }
  51288. return record;
  51289. },
  51290. bindExpression: function(descriptor, callback, scope, options) {
  51291. var stub = this.getStub(descriptor);
  51292. return stub.bind(callback, scope, options);
  51293. },
  51294. applyScheduler: function(scheduler) {
  51295. if (scheduler && !scheduler.isInstance) {
  51296. if (scheduler === true) {
  51297. scheduler = {};
  51298. }
  51299. if (!('preSort' in scheduler)) {
  51300. scheduler = Ext.apply({
  51301. preSort: 'kind,-depth'
  51302. }, scheduler);
  51303. }
  51304. scheduler = new Ext.util.Scheduler(scheduler);
  51305. scheduler.$owner = this;
  51306. }
  51307. return scheduler;
  51308. },
  51309. getScheduler: function() {
  51310. var me = this,
  51311. scheduler = me._scheduler,
  51312. parent;
  51313. if (!scheduler) {
  51314. if (!(parent = me.getParent())) {
  51315. scheduler = new Ext.util.Scheduler({
  51316. preSort: 'kind,-depth'
  51317. });
  51318. scheduler.$owner = me;
  51319. } else {
  51320. scheduler = parent.getScheduler();
  51321. }
  51322. me.setScheduler(scheduler);
  51323. }
  51324. return scheduler;
  51325. },
  51326. getStub: function(bindDescr) {
  51327. var root = this.getRoot();
  51328. return bindDescr ? root.getChild(bindDescr) : root;
  51329. },
  51330. collect: function() {
  51331. var me = this,
  51332. parent = me.getParent(),
  51333. task = me.collectTask;
  51334. if (parent) {
  51335. parent.collect();
  51336. return;
  51337. }
  51338. if (!task) {
  51339. task = me.collectTask = new Ext.util.DelayedTask(me.doCollect, me);
  51340. }
  51341. if (me.collectTimeout === 0) {
  51342. me.doCollect();
  51343. } else {
  51344. task.delay(me.collectTimeout);
  51345. }
  51346. },
  51347. doCollect: function() {
  51348. var children = this.children,
  51349. key;
  51350. if (children) {
  51351. for (key in children) {
  51352. children[key].doCollect();
  51353. }
  51354. }
  51355. this.getRoot().collect();
  51356. },
  51357. invalidateChildLinks: function(name, clear) {
  51358. var children = this.children,
  51359. key;
  51360. if (children) {
  51361. for (key in children) {
  51362. children[key].getRoot().invalidateChildLink(name, clear);
  51363. }
  51364. }
  51365. },
  51366. onBindDestroy: function(binding, fromChild) {
  51367. var me = this,
  51368. parent;
  51369. if (me.destroying) {
  51370. return;
  51371. }
  51372. if (!fromChild) {
  51373. delete me.bindings[binding.id];
  51374. }
  51375. parent = me.getParent();
  51376. if (parent) {
  51377. parent.onBindDestroy(binding, true);
  51378. } else {
  51379. me.collect();
  51380. }
  51381. },
  51382. applyData: function(newData, data) {
  51383. var me = this,
  51384. linkData, parent;
  51385. me.getSession();
  51386. if (!data) {
  51387. parent = me.getParent();
  51388. me.linkData = linkData = parent ? Ext.Object.chain(parent.getData()) : {};
  51389. me.data = me._data = Ext.Object.chain(linkData);
  51390. }
  51391. if (newData && newData.constructor === Object) {
  51392. me.getRoot().set(newData, true);
  51393. }
  51394. },
  51395. applyParent: function(parent) {
  51396. if (parent) {
  51397. parent.registerChild(this);
  51398. }
  51399. return parent;
  51400. },
  51401. applyStores: function(stores) {
  51402. var me = this,
  51403. root = me.getRoot(),
  51404. key, cfg, storeBind, stub, listeners;
  51405. me.storeInfo = {};
  51406. me.listenerScopeFn = function() {
  51407. return me.getView().getInheritedConfig('defaultListenerScope');
  51408. };
  51409. for (key in stores) {
  51410. cfg = stores[key];
  51411. if (cfg.isStore) {
  51412. cfg.$wasInstance = true;
  51413. me.setupStore(cfg, key);
  51414. continue;
  51415. } else if (Ext.isString(cfg)) {
  51416. cfg = {
  51417. source: cfg
  51418. };
  51419. } else {
  51420. cfg = Ext.apply({}, cfg);
  51421. }
  51422. listeners = cfg.listeners;
  51423. delete cfg.listeners;
  51424. storeBind = me.bind(cfg, me.onStoreBind, me, {
  51425. trackStatics: true
  51426. });
  51427. if (storeBind.isStatic()) {
  51428. storeBind.destroy();
  51429. me.createStore(key, cfg, listeners);
  51430. } else {
  51431. storeBind.$storeKey = key;
  51432. storeBind.$listeners = listeners;
  51433. stub = root.createStubChild(key);
  51434. stub.setStore(storeBind);
  51435. }
  51436. }
  51437. },
  51438. onStoreBind: function(cfg, oldValue, binding) {
  51439. var info = this.storeInfo,
  51440. key = binding.$storeKey,
  51441. store = info[key],
  51442. proxy;
  51443. if (!store) {
  51444. this.createStore(key, cfg, binding.$listeners, binding);
  51445. } else {
  51446. cfg = Ext.merge({}, binding.pruneStaticKeys());
  51447. proxy = cfg.proxy;
  51448. delete cfg.type;
  51449. delete cfg.model;
  51450. delete cfg.fields;
  51451. delete cfg.proxy;
  51452. delete cfg.listeners;
  51453. if (proxy) {
  51454. delete proxy.reader;
  51455. delete proxy.writer;
  51456. store.getProxy().setConfig(proxy);
  51457. }
  51458. store.setConfig(cfg);
  51459. }
  51460. },
  51461. createStore: function(key, cfg, listeners, binding) {
  51462. var session = this.getSession(),
  51463. store;
  51464. cfg = Ext.apply({}, cfg);
  51465. if (cfg.session) {
  51466. cfg.session = session;
  51467. }
  51468. if (cfg.source) {
  51469. cfg.type = cfg.type || 'chained';
  51470. }
  51471. cfg.listeners = listeners;
  51472. cfg.resolveListenerScope = this.listenerScopeFn;
  51473. store = Ext.Factory.store(cfg);
  51474. store.$binding = binding;
  51475. this.setupStore(store, key);
  51476. },
  51477. setupStore: function(store, key) {
  51478. var me = this,
  51479. obj = {};
  51480. me.getData();
  51481. store.resolveListenerScope = me.listenerScopeFn;
  51482. me.storeInfo[key] = store;
  51483. obj[key] = store;
  51484. me.setData(obj);
  51485. },
  51486. applyFormulas: function(formulas) {
  51487. var me = this,
  51488. root = me.getRoot(),
  51489. name, stub;
  51490. me.getData();
  51491. for (name in formulas) {
  51492. if (name.indexOf('.') >= 0) {
  51493. Ext.raise('Formula names cannot contain dots: ' + name);
  51494. }
  51495. root.createStubChild(name);
  51496. stub = me.getStub(name);
  51497. stub.setFormula(formulas[name]);
  51498. }
  51499. return formulas;
  51500. },
  51501. applyLinks: function(links) {
  51502. var link;
  51503. for (link in links) {
  51504. this.linkTo(link, links[link]);
  51505. }
  51506. },
  51507. applySchema: function(schema) {
  51508. return Ext.data.schema.Schema.get(schema);
  51509. },
  51510. applyRoot: function() {
  51511. var root = new Ext.app.bind.RootStub(this),
  51512. parent = this.getParent();
  51513. if (parent) {
  51514. root.depth = parent.getRoot().depth - 1000;
  51515. }
  51516. return root;
  51517. },
  51518. getFormulaFn: function(data) {
  51519. var me = this,
  51520. fn = me.formulaFn;
  51521. if (!fn) {
  51522. fn = me.formulaFn = function(name) {
  51523. return me.$formulaData[name];
  51524. };
  51525. }
  51526. me.$formulaData = data;
  51527. return fn;
  51528. }
  51529. }
  51530. });
  51531. Ext.define('Ext.app.domain.Controller', {
  51532. extend: Ext.app.EventDomain,
  51533. singleton: true,
  51534. type: 'controller',
  51535. prefix: 'controller.',
  51536. idMatchRe: /^#/,
  51537. constructor: function() {
  51538. var me = this;
  51539. me.callParent();
  51540. me.monitor(Ext.app.BaseController);
  51541. },
  51542. match: function(target, selector) {
  51543. var result = false,
  51544. alias = target.alias;
  51545. if (selector === '*') {
  51546. result = true;
  51547. } else if (selector === '#') {
  51548. result = !!target.isApplication;
  51549. } else if (this.idMatchRe.test(selector)) {
  51550. result = target.getId() === selector.substring(1);
  51551. } else if (alias) {
  51552. result = Ext.Array.indexOf(alias, this.prefix + selector) > -1;
  51553. }
  51554. return result;
  51555. }
  51556. });
  51557. Ext.define('Ext.direct.Manager', {
  51558. singleton: true,
  51559. mixins: [
  51560. Ext.mixin.Observable
  51561. ],
  51562. exceptions: {
  51563. TRANSPORT: 'xhr',
  51564. PARSE: 'parse',
  51565. DATA: 'data',
  51566. LOGIN: 'login',
  51567. SERVER: 'exception'
  51568. },
  51569. providerClasses: {},
  51570. remotingMethods: {},
  51571. config: {
  51572. varName: 'Ext.REMOTING_API'
  51573. },
  51574. apiNotFoundError: 'Ext Direct API was not found at {0}',
  51575. constructor: function() {
  51576. var me = this;
  51577. me.mixins.observable.constructor.call(me);
  51578. me.transactions = new Ext.util.MixedCollection();
  51579. me.providers = new Ext.util.MixedCollection();
  51580. },
  51581. addProvider: function(provider) {
  51582. var me = this,
  51583. args = arguments,
  51584. relayers = me.relayers || (me.relayers = {}),
  51585. i, len;
  51586. if (args.length > 1) {
  51587. for (i = 0 , len = args.length; i < len; ++i) {
  51588. me.addProvider(args[i]);
  51589. }
  51590. return;
  51591. }
  51592. if (!provider.isProvider) {
  51593. provider = Ext.create('direct.' + provider.type + 'provider', provider);
  51594. }
  51595. me.providers.add(provider);
  51596. provider.on('data', me.onProviderData, me);
  51597. if (provider.relayedEvents) {
  51598. relayers[provider.id] = me.relayEvents(provider, provider.relayedEvents);
  51599. }
  51600. if (!provider.isConnected()) {
  51601. provider.connect();
  51602. }
  51603. return provider;
  51604. },
  51605. loadProvider: function(config, callback, scope) {
  51606. var me = this,
  51607. classes = me.providerClasses,
  51608. type, url, varName, provider, i, len;
  51609. if (Ext.isArray(config)) {
  51610. for (i = 0 , len = config.length; i < len; i++) {
  51611. me.loadProvider(config[i], callback, scope);
  51612. }
  51613. return;
  51614. }
  51615. type = config.type;
  51616. url = config.url;
  51617. if (classes[type] && classes[type].checkConfig(config)) {
  51618. provider = me.addProvider(config);
  51619. me.fireEventArgs('providerload', [
  51620. url,
  51621. provider
  51622. ]);
  51623. Ext.callback(callback, scope, [
  51624. url,
  51625. provider
  51626. ]);
  51627. return;
  51628. }
  51629. varName = config.varName || me.getVarName();
  51630. delete config.varName;
  51631. if (!url) {
  51632. Ext.raise("Need API discovery URL to load a Remoting provider!");
  51633. }
  51634. delete config.url;
  51635. Ext.Loader.loadScript({
  51636. url: url,
  51637. scope: me,
  51638. onLoad: function() {
  51639. this.onApiLoadSuccess({
  51640. url: url,
  51641. varName: varName,
  51642. config: config,
  51643. callback: callback,
  51644. scope: scope
  51645. });
  51646. },
  51647. onError: function() {
  51648. this.onApiLoadFailure({
  51649. url: url,
  51650. callback: callback,
  51651. scope: scope
  51652. });
  51653. }
  51654. });
  51655. },
  51656. getProvider: function(id) {
  51657. return id.isProvider ? id : this.providers.get(id);
  51658. },
  51659. removeProvider: function(provider) {
  51660. var me = this,
  51661. providers = me.providers,
  51662. relayers = me.relayers,
  51663. id;
  51664. provider = provider.isProvider ? provider : providers.get(provider);
  51665. if (provider) {
  51666. provider.un('data', me.onProviderData, me);
  51667. id = provider.id;
  51668. if (relayers[id]) {
  51669. relayers[id].destroy();
  51670. delete relayers[id];
  51671. }
  51672. providers.remove(provider);
  51673. return provider;
  51674. }
  51675. return null;
  51676. },
  51677. addTransaction: function(transaction) {
  51678. this.transactions.add(transaction);
  51679. return transaction;
  51680. },
  51681. removeTransaction: function(transaction) {
  51682. var me = this;
  51683. transaction = me.getTransaction(transaction);
  51684. me.transactions.remove(transaction);
  51685. return transaction;
  51686. },
  51687. getTransaction: function(transaction) {
  51688. return typeof transaction === 'object' ? transaction : this.transactions.get(transaction);
  51689. },
  51690. onProviderData: function(provider, event) {
  51691. var me = this,
  51692. i, len;
  51693. if (Ext.isArray(event)) {
  51694. for (i = 0 , len = event.length; i < len; ++i) {
  51695. me.onProviderData(provider, event[i]);
  51696. }
  51697. return;
  51698. }
  51699. if (event.name && event.name !== 'event' && event.name !== 'exception') {
  51700. me.fireEvent(event.name, event);
  51701. } else if (event.status === false) {
  51702. me.fireEvent('exception', event);
  51703. }
  51704. me.fireEvent('event', event, provider);
  51705. },
  51706. parseMethod: function(fn) {
  51707. var current = Ext.global,
  51708. i = 0,
  51709. resolved, parts, len;
  51710. if (Ext.isFunction(fn)) {
  51711. resolved = fn;
  51712. } else if (Ext.isString(fn)) {
  51713. resolved = this.remotingMethods[fn];
  51714. if (!resolved) {
  51715. parts = fn.split('.');
  51716. len = parts.length;
  51717. while (current && i < len) {
  51718. current = current[parts[i]];
  51719. ++i;
  51720. }
  51721. resolved = Ext.isFunction(current) ? current : null;
  51722. }
  51723. }
  51724. return resolved || null;
  51725. },
  51726. resolveApi: function(api, caller) {
  51727. var prefix, action, method, fullName, fn;
  51728. prefix = api && api.prefix;
  51729. if (prefix && prefix.substr(prefix.length - 1) !== '.') {
  51730. prefix += '.';
  51731. }
  51732. for (action in api) {
  51733. method = api[action];
  51734. if (action !== 'prefix' && typeof method !== 'function') {
  51735. fullName = (prefix || '') + method;
  51736. fn = this.parseMethod(fullName);
  51737. if (typeof fn === 'function') {
  51738. api[action] = fn;
  51739. } else
  51740. {
  51741. Ext.raise("Cannot resolve Direct API method '" + fullName + "' for " + action + " action in " + caller.$className + " instance with id: " + (caller.id != null ? caller.id : 'unknown'));
  51742. }
  51743. }
  51744. }
  51745. return api;
  51746. },
  51747. privates: {
  51748. addProviderClass: function(type, cls) {
  51749. this.providerClasses[type] = cls;
  51750. },
  51751. onApiLoadSuccess: function(options) {
  51752. var me = this,
  51753. url = options.url,
  51754. varName = options.varName,
  51755. api, provider, error;
  51756. try {
  51757. api = Ext.apply(options.config, eval(varName));
  51758. provider = me.addProvider(api);
  51759. } catch (e) {
  51760. error = e + '';
  51761. }
  51762. if (error) {
  51763. me.fireEventArgs('providerloaderror', [
  51764. url,
  51765. error
  51766. ]);
  51767. Ext.callback(options.callback, options.scope, [
  51768. url,
  51769. error
  51770. ]);
  51771. } else {
  51772. me.fireEventArgs('providerload', [
  51773. url,
  51774. provider
  51775. ]);
  51776. Ext.callback(options.callback, options.scope, [
  51777. url,
  51778. provider
  51779. ]);
  51780. }
  51781. },
  51782. onApiLoadFailure: function(options) {
  51783. var url = options.url,
  51784. error;
  51785. error = Ext.String.format(this.apiNotFoundError, url);
  51786. this.fireEventArgs('providerloaderror', [
  51787. url,
  51788. error
  51789. ]);
  51790. Ext.callback(options.callback, options.scope, [
  51791. url,
  51792. error
  51793. ]);
  51794. },
  51795. registerMethod: function(name, method) {
  51796. this.remotingMethods[name] = method;
  51797. },
  51798. clearAllMethods: function() {
  51799. this.remotingMethods = {};
  51800. }
  51801. }
  51802. }, function() {
  51803. Ext.Direct = Ext.direct.Manager;
  51804. });
  51805. Ext.define('Ext.direct.Provider', {
  51806. alias: 'direct.provider',
  51807. mixins: [
  51808. Ext.mixin.Observable
  51809. ],
  51810. isProvider: true,
  51811. $configPrefixed: false,
  51812. $configStrict: false,
  51813. config: {
  51814. headers: undefined
  51815. },
  51816. subscribers: 0,
  51817. constructor: function(config) {
  51818. var me = this;
  51819. me.mixins.observable.constructor.call(me, config);
  51820. me.requests = {};
  51821. if (me.id == null) {
  51822. me.id = Ext.id(null, 'provider-');
  51823. }
  51824. },
  51825. destroy: function() {
  51826. var me = this;
  51827. me.disconnect(true);
  51828. me.callParent();
  51829. },
  51830. isConnected: function() {
  51831. return this.subscribers > 0;
  51832. },
  51833. connect: function() {
  51834. var me = this;
  51835. if (me.subscribers === 0) {
  51836. me.doConnect();
  51837. me.fireEventArgs('connect', [
  51838. me
  51839. ]);
  51840. }
  51841. me.subscribers++;
  51842. },
  51843. doConnect: Ext.emptyFn,
  51844. disconnect: function(
  51845. force) {
  51846. var me = this;
  51847. if (me.subscribers > 0 || force) {
  51848. if (force) {
  51849. me.subscribers = 0;
  51850. } else {
  51851. me.subscribers--;
  51852. }
  51853. if (me.subscribers === 0) {
  51854. me.doDisconnect();
  51855. me.fireEventArgs('disconnect', [
  51856. me
  51857. ]);
  51858. }
  51859. }
  51860. },
  51861. doDisconnect: function() {
  51862. var requests = this.requests,
  51863. request, id;
  51864. for (id in requests) {
  51865. request = requests[id];
  51866. request.abort();
  51867. }
  51868. this.requests = {};
  51869. },
  51870. sendAjaxRequest: function(params) {
  51871. var request = Ext.Ajax.request(params);
  51872. if (request && request.id) {
  51873. this.requests[request.id] = request;
  51874. }
  51875. return request;
  51876. },
  51877. onData: function(options, success, response) {
  51878. if (response && response.request) {
  51879. delete this.requests[response.request.id];
  51880. }
  51881. },
  51882. inheritableStatics: {
  51883. checkConfig: Ext.returnFalse
  51884. },
  51885. onClassExtended: function(cls, data, hooks) {
  51886. if (data.type) {
  51887. Ext.direct.Manager.addProviderClass(data.type, cls);
  51888. }
  51889. }
  51890. });
  51891. Ext.define('Ext.app.domain.Direct', {
  51892. extend: Ext.app.EventDomain,
  51893. singleton: true,
  51894. type: 'direct',
  51895. idProperty: 'id',
  51896. constructor: function() {
  51897. var me = this;
  51898. me.callParent();
  51899. me.monitor(Ext.direct.Provider);
  51900. }
  51901. });
  51902. Ext.define('Ext.data.PageMap', {
  51903. extend: Ext.util.LruCache,
  51904. config: {
  51905. store: null,
  51906. pageSize: 0,
  51907. rootProperty: ''
  51908. },
  51909. clear: function(initial) {
  51910. var me = this;
  51911. me.pageMapGeneration = (me.pageMapGeneration || 0) + 1;
  51912. me.indexMap = {};
  51913. me.callParent([
  51914. initial
  51915. ]);
  51916. },
  51917. updatePageSize: function(value, oldValue) {
  51918. if (oldValue != null) {
  51919. throw "pageMap page size may not be changed";
  51920. }
  51921. },
  51922. forEach: function(fn, scope) {
  51923. var me = this,
  51924. pageNumbers = Ext.Object.getKeys(me.map),
  51925. pageCount = pageNumbers.length,
  51926. pageSize = me.getPageSize(),
  51927. pageNumber, page, i, j, len;
  51928. for (i = 0; i < pageCount; i++) {
  51929. pageNumbers[i] = +pageNumbers[i];
  51930. }
  51931. Ext.Array.sort(pageNumbers, Ext.Array.numericSortFn);
  51932. scope = scope || me;
  51933. for (i = 0; i < pageCount; i++) {
  51934. pageNumber = pageNumbers[i];
  51935. page = me.getPage(pageNumber);
  51936. len = page.length;
  51937. for (j = 0; j < len; j++) {
  51938. if (fn.call(scope, page[j], (pageNumber - 1) * pageSize + j) === false) {
  51939. return;
  51940. }
  51941. }
  51942. }
  51943. },
  51944. findBy: function(fn, scope) {
  51945. var me = this,
  51946. result = null;
  51947. scope = scope || me;
  51948. me.forEach(function(rec, index) {
  51949. if (fn.call(scope, rec, index)) {
  51950. result = rec;
  51951. return false;
  51952. }
  51953. });
  51954. return result;
  51955. },
  51956. findIndexBy: function(fn, scope) {
  51957. var me = this,
  51958. result = -1;
  51959. scope = scope || me;
  51960. me.forEach(function(rec, index) {
  51961. if (fn.call(scope, rec)) {
  51962. result = index;
  51963. return false;
  51964. }
  51965. });
  51966. return result;
  51967. },
  51968. find: function(property, value, start, startsWith, endsWith, ignoreCase) {
  51969. if (Ext.isEmpty(value, false)) {
  51970. return null;
  51971. }
  51972. var regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase),
  51973. root = this.getRootProperty();
  51974. return this.findBy(function(item) {
  51975. return item && regex.test((root ? item[root] : item)[property]);
  51976. }, null, start);
  51977. },
  51978. findIndex: function(property, value, start, startsWith, endsWith, ignoreCase) {
  51979. if (Ext.isEmpty(value, false)) {
  51980. return null;
  51981. }
  51982. var regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase),
  51983. root = this.getRootProperty();
  51984. return this.findIndexBy(function(item) {
  51985. return item && regex.test((root ? item[root] : item)[property]);
  51986. }, null, start);
  51987. },
  51988. getPageFromRecordIndex: function(index) {
  51989. return Math.floor(index / this.getPageSize()) + 1;
  51990. },
  51991. addAll: function(records) {
  51992. if (this.getCount()) {
  51993. Ext.raise('Cannot addAll to a non-empty PageMap');
  51994. }
  51995. this.addPage(1, records);
  51996. },
  51997. addPage: function(pageNumber, records) {
  51998. var me = this,
  51999. pageSize = me.getPageSize(),
  52000. lastPage = pageNumber + Math.floor((records.length - 1) / pageSize),
  52001. storeIndex = (pageNumber - 1) * pageSize,
  52002. indexMap = me.indexMap,
  52003. page, i, len, startIdx;
  52004. for (startIdx = 0; pageNumber <= lastPage; pageNumber++ , startIdx += pageSize) {
  52005. page = Ext.Array.slice(records, startIdx, startIdx + pageSize);
  52006. for (i = 0 , len = page.length; i < len; i++) {
  52007. indexMap[page[i].internalId] = storeIndex++;
  52008. }
  52009. me.add(pageNumber, page);
  52010. me.fireEvent('pageadd', me, pageNumber, page);
  52011. }
  52012. },
  52013. getCount: function() {
  52014. var result = this.callParent();
  52015. if (result) {
  52016. result = (result - 1) * this.getPageSize() + this.last.value.length;
  52017. }
  52018. return result;
  52019. },
  52020. getByInternalId: function(internalId) {
  52021. var index = this.indexMap[internalId];
  52022. if (index != null) {
  52023. return this.getAt(index);
  52024. }
  52025. },
  52026. indexOf: function(record) {
  52027. var result = -1;
  52028. if (record) {
  52029. result = this.indexMap[record.internalId];
  52030. if (result == null) {
  52031. result = -1;
  52032. }
  52033. }
  52034. return result;
  52035. },
  52036. insert: function() {
  52037. Ext.raise('insert operation not suppported into buffered Store');
  52038. },
  52039. remove: function() {
  52040. Ext.raise('remove operation not suppported from buffered Store');
  52041. },
  52042. removeAt: function() {
  52043. Ext.raise('removeAt operation not suppported from buffered Store');
  52044. },
  52045. removeAtKey: function(page) {
  52046. var me = this,
  52047. thePage = me.getPage(page),
  52048. result, i, len;
  52049. if (thePage) {
  52050. if (me.fireEvent('beforepageremove', me, page, thePage) !== false) {
  52051. len = thePage.length;
  52052. for (i = 0; i < len; i++) {
  52053. delete me.indexMap[thePage[i].internalId];
  52054. }
  52055. result = me.callParent(arguments);
  52056. me.fireEvent('pageremove', me, page, thePage);
  52057. thePage.length = 0;
  52058. }
  52059. }
  52060. return result;
  52061. },
  52062. getPage: function(pageNumber) {
  52063. return this.get(pageNumber);
  52064. },
  52065. hasRange: function(start, end) {
  52066. var me = this,
  52067. pageNumber = me.getPageFromRecordIndex(start),
  52068. endPageNumber = me.getPageFromRecordIndex(end);
  52069. for (; pageNumber <= endPageNumber; pageNumber++) {
  52070. if (!me.hasPage(pageNumber)) {
  52071. return false;
  52072. }
  52073. }
  52074. return (endPageNumber - 1) * me._pageSize + me.getPage(endPageNumber).length > end;
  52075. },
  52076. hasPage: function(pageNumber) {
  52077. return !!this.get(pageNumber);
  52078. },
  52079. peekPage: function(pageNumber) {
  52080. return this.map[pageNumber];
  52081. },
  52082. getAt: function(index) {
  52083. return this.getRange(index, index + 1)[0];
  52084. },
  52085. getRange: function(start, end) {
  52086. if (end) {
  52087. end--;
  52088. }
  52089. if (!this.hasRange(start, end)) {
  52090. Ext.raise('PageMap asked for range which it does not have');
  52091. }
  52092. var me = this,
  52093. Array = Ext.Array,
  52094. pageSize = me.getPageSize(),
  52095. startPageNumber = me.getPageFromRecordIndex(start),
  52096. endPageNumber = me.getPageFromRecordIndex(end),
  52097. dataStart = (startPageNumber - 1) * pageSize,
  52098. dataEnd = (endPageNumber * pageSize) - 1,
  52099. pageNumber = startPageNumber,
  52100. result = [],
  52101. sliceBegin, sliceEnd, doSlice;
  52102. for (; pageNumber <= endPageNumber; pageNumber++) {
  52103. if (pageNumber === startPageNumber) {
  52104. sliceBegin = start - dataStart;
  52105. doSlice = sliceBegin > 0;
  52106. } else {
  52107. sliceBegin = 0;
  52108. doSlice = false;
  52109. }
  52110. if (pageNumber === endPageNumber) {
  52111. sliceEnd = pageSize - (dataEnd - end);
  52112. doSlice = doSlice || sliceEnd < pageSize;
  52113. }
  52114. if (doSlice) {
  52115. Array.push(result, Array.slice(me.getPage(pageNumber), sliceBegin, sliceEnd));
  52116. } else {
  52117. Array.push(result, me.getPage(pageNumber));
  52118. }
  52119. }
  52120. return result;
  52121. }
  52122. });
  52123. Ext.define('Ext.data.BufferedStore', {
  52124. extend: Ext.data.ProxyStore,
  52125. alias: 'store.buffered',
  52126. isBufferedStore: true,
  52127. buffered: true,
  52128. config: {
  52129. data: 0,
  52130. pageSize: 25,
  52131. remoteSort: true,
  52132. remoteFilter: true,
  52133. sortOnLoad: false,
  52134. purgePageCount: 5,
  52135. trailingBufferZone: 25,
  52136. leadingBufferZone: 200,
  52137. defaultViewSize: 100,
  52138. viewSize: 0,
  52139. trackRemoved: false
  52140. },
  52141. applyData: function(data) {
  52142. var dataCollection = this.data || (this.data = this.createDataCollection());
  52143. if (data && data !== true) {
  52144. Ext.raise('Cannot load a buffered store with local data - the store is a map ' + 'of remote data');
  52145. }
  52146. return dataCollection;
  52147. },
  52148. applyProxy: function(proxy) {
  52149. proxy = this.callParent([
  52150. proxy
  52151. ]);
  52152. if (proxy && proxy.setEnablePaging) {
  52153. proxy.setEnablePaging(true);
  52154. }
  52155. return proxy;
  52156. },
  52157. applyAutoSort: function() {},
  52158. createFiltersCollection: function() {
  52159. return new Ext.util.FilterCollection();
  52160. },
  52161. createSortersCollection: function() {
  52162. return new Ext.util.SorterCollection();
  52163. },
  52164. updateRemoteFilter: function(remoteFilter, oldRemoteFilter) {
  52165. if (remoteFilter === false) {
  52166. Ext.raise('Buffered stores are always remotely filtered.');
  52167. }
  52168. this.callParent([
  52169. remoteFilter,
  52170. oldRemoteFilter
  52171. ]);
  52172. },
  52173. updateRemoteSort: function(remoteSort, oldRemoteSort) {
  52174. if (remoteSort === false) {
  52175. Ext.raise('Buffered stores are always remotely sorted.');
  52176. }
  52177. this.callParent([
  52178. remoteSort,
  52179. oldRemoteSort
  52180. ]);
  52181. },
  52182. updateTrackRemoved: function(value) {
  52183. if (value !== false) {
  52184. Ext.raise('Cannot use trackRemoved with a buffered store.');
  52185. }
  52186. this.callParent(arguments);
  52187. },
  52188. updateGroupField: function(field) {
  52189. this.group(field);
  52190. },
  52191. getGrouper: function() {
  52192. return this.grouper;
  52193. },
  52194. isGrouped: function() {
  52195. return !!this.grouper;
  52196. },
  52197. createDataCollection: function() {
  52198. var me = this,
  52199. result = new Ext.data.PageMap({
  52200. store: me,
  52201. rootProperty: 'data',
  52202. pageSize: me.getPageSize(),
  52203. maxSize: me.getPurgePageCount(),
  52204. listeners: {
  52205. clear: me.onPageMapClear,
  52206. scope: me
  52207. }
  52208. });
  52209. me.relayEvents(result, [
  52210. 'beforepageremove',
  52211. 'pageadd',
  52212. 'pageremove'
  52213. ]);
  52214. me.pageRequests = {};
  52215. return result;
  52216. },
  52217. add: function() {
  52218. Ext.raise('add method may not be called on a buffered store - the store is a map ' + 'of remote data');
  52219. },
  52220. insert: function() {
  52221. Ext.raise('insert method may not be called on a buffered store - the store is a map ' + 'of remote data');
  52222. },
  52223. removeAll: function(silent) {
  52224. var me = this,
  52225. data = me.getData();
  52226. if (data) {
  52227. if (silent) {
  52228. me.suspendEvent('clear');
  52229. }
  52230. data.clear();
  52231. if (silent) {
  52232. me.resumeEvent('clear');
  52233. }
  52234. }
  52235. },
  52236. flushLoad: function() {
  52237. var me = this,
  52238. options = me.pendingLoadOptions;
  52239. me.clearLoadTask();
  52240. if (!options) {
  52241. return;
  52242. }
  52243. if (!options.preserveOnFlush) {
  52244. me.getData().clear();
  52245. options.page = 1;
  52246. options.start = 0;
  52247. options.limit = me.getViewSize() || me.getDefaultViewSize();
  52248. }
  52249. options.loadCallback = options.callback;
  52250. options.callback = null;
  52251. return me.loadToPrefetch(options);
  52252. },
  52253. reload: function(options) {
  52254. var me = this,
  52255. data = me.getData(),
  52256. lastTotal = Number.MAX_VALUE,
  52257. startIdx, endIdx, startPage, endPage, i, waitForReload, bufferZone, records;
  52258. if (!options) {
  52259. options = {};
  52260. }
  52261. if (me.loading || me.fireEvent('beforeload', me, options) === false) {
  52262. return;
  52263. }
  52264. waitForReload = function() {
  52265. var newCount = me.totalCount,
  52266. oldRequestSize = endIdx - startIdx;
  52267. if (endIdx >= newCount) {
  52268. endIdx = newCount - 1;
  52269. startIdx = Math.max(endIdx - oldRequestSize, 0);
  52270. }
  52271. if (me.rangeCached(startIdx, endIdx, false)) {
  52272. me.loadCount = (me.loadCount || 0) + 1;
  52273. me.loading = false;
  52274. data.un('pageadd', waitForReload);
  52275. records = data.getRange(startIdx, endIdx);
  52276. me.fireEvent('refresh', me);
  52277. me.fireEvent('load', me, records, true);
  52278. }
  52279. };
  52280. bufferZone = Math.ceil((me.getLeadingBufferZone() + me.getTrailingBufferZone()) / 2);
  52281. if (me.lastRequestStart && me.preserveScrollOnReload) {
  52282. startIdx = me.lastRequestStart;
  52283. endIdx = me.lastRequestEnd;
  52284. lastTotal = me.getTotalCount();
  52285. } else
  52286. {
  52287. startIdx = options.start || 0;
  52288. endIdx = startIdx + (options.count || me.getPageSize()) - 1;
  52289. }
  52290. data.clear(true);
  52291. delete me.totalCount;
  52292. startIdx = Math.max(startIdx - bufferZone, 0);
  52293. endIdx = Math.min(endIdx + bufferZone, lastTotal);
  52294. startIdx = startIdx === 0 ? 0 : startIdx - 1;
  52295. endIdx = endIdx === lastTotal ? endIdx : endIdx + 1;
  52296. startPage = me.getPageFromRecordIndex(startIdx);
  52297. endPage = me.getPageFromRecordIndex(endIdx);
  52298. me.loading = true;
  52299. options.waitForReload = waitForReload;
  52300. data.on('pageadd', waitForReload);
  52301. for (i = startPage; i <= endPage; i++) {
  52302. me.prefetchPage(i, options);
  52303. }
  52304. },
  52305. filter: function() {
  52306. if (!this.getRemoteFilter()) {
  52307. Ext.raise('Local filtering may not be used on a buffered store - the store is a map ' + 'of remote data');
  52308. }
  52309. this.callParent(arguments);
  52310. },
  52311. filterBy: function(fn, scope) {
  52312. Ext.raise('Local filtering may not be used on a buffered store - the store is a map ' + 'of remote data');
  52313. },
  52314. loadData: function(data, append) {
  52315. Ext.raise('LoadData may not be used on a buffered store - the store is a map ' + 'of remote data');
  52316. },
  52317. loadPage: function(page, options) {
  52318. var me = this;
  52319. options = options || {};
  52320. options.page = me.currentPage = page;
  52321. options.start = (page - 1) * me.getPageSize();
  52322. options.limit = me.getViewSize() || me.getDefaultViewSize();
  52323. options.loadCallback = options.callback;
  52324. options.callback = null;
  52325. options.preserveOnFlush = true;
  52326. return me.load(options);
  52327. },
  52328. clearData: function(isLoad) {
  52329. var me = this,
  52330. data = me.getData();
  52331. if (data) {
  52332. data.clear();
  52333. }
  52334. },
  52335. getCount: function() {
  52336. return this.totalCount || 0;
  52337. },
  52338. getRange: function(start, end, options) {
  52339. var me = this,
  52340. maxIndex = me.totalCount - 1,
  52341. lastRequestStart = me.lastRequestStart,
  52342. result = [],
  52343. data = me.getData(),
  52344. pageAddHandler, requiredStart, requiredEnd, requiredStartPage, requiredEndPage;
  52345. options = Ext.apply({
  52346. prefetchStart: start,
  52347. prefetchEnd: end
  52348. }, options);
  52349. end = (end >= me.totalCount) ? maxIndex : end;
  52350. if (options.forRender !== false) {
  52351. requiredStart = start === 0 ? 0 : start - 1;
  52352. requiredEnd = end === maxIndex ? end : end + 1;
  52353. } else {
  52354. requiredStart = start;
  52355. requiredEnd = end;
  52356. }
  52357. me.lastRequestStart = start;
  52358. me.lastRequestEnd = end;
  52359. if (me.rangeCached(start, end, options.forRender)) {
  52360. me.onRangeAvailable(options);
  52361. result = data.getRange(start, end + 1);
  52362. } else
  52363. {
  52364. me.fireEvent('cachemiss', me, start, end);
  52365. requiredStartPage = me.getPageFromRecordIndex(requiredStart);
  52366. requiredEndPage = me.getPageFromRecordIndex(requiredEnd);
  52367. pageAddHandler = function(pageMap, page, records) {
  52368. if (page >= requiredStartPage && page <= requiredEndPage && me.rangeCached(start, end)) {
  52369. me.fireEvent('cachefilled', me, start, end);
  52370. data.un('pageadd', pageAddHandler);
  52371. me.onRangeAvailable(options);
  52372. }
  52373. };
  52374. data.on('pageadd', pageAddHandler);
  52375. me.prefetchRange(start, end);
  52376. }
  52377. me.primeCache(start, end, start < lastRequestStart ? -1 : 1);
  52378. return result;
  52379. },
  52380. getById: function(id) {
  52381. var result = this.data.findBy(function(record) {
  52382. return record.getId() === id;
  52383. });
  52384. return result;
  52385. },
  52386. getAt: function(index) {
  52387. var data = this.getData();
  52388. if (data.hasRange(index, index)) {
  52389. return data.getAt(index);
  52390. }
  52391. },
  52392. getByInternalId: function(internalId) {
  52393. return this.data.getByInternalId(internalId);
  52394. },
  52395. contains: function(record) {
  52396. return this.indexOf(record) > -1;
  52397. },
  52398. indexOf: function(record) {
  52399. return this.getData().indexOf(record);
  52400. },
  52401. indexOfId: function(id) {
  52402. return this.indexOf(this.getById(id));
  52403. },
  52404. group: function(grouper, direction) {
  52405. var me = this,
  52406. oldGrouper;
  52407. if (grouper && typeof grouper === 'string') {
  52408. oldGrouper = me.grouper;
  52409. if (oldGrouper && direction !== undefined) {
  52410. oldGrouper.setDirection(direction);
  52411. } else {
  52412. me.grouper = new Ext.util.Grouper({
  52413. property: grouper,
  52414. direction: direction || 'ASC',
  52415. root: 'data'
  52416. });
  52417. }
  52418. } else {
  52419. me.grouper = grouper ? me.getSorters().decodeSorter(grouper, Ext.util.Grouper) : null;
  52420. }
  52421. me.getData().clear();
  52422. me.loadPage(1, {
  52423. callback: function() {
  52424. me.fireEvent('groupchange', me, me.getGrouper());
  52425. }
  52426. });
  52427. },
  52428. getPageFromRecordIndex: function(index) {
  52429. return Math.floor(index / this.getPageSize()) + 1;
  52430. },
  52431. calculatePageCacheSize: function(rangeSizeRequested) {
  52432. var me = this,
  52433. purgePageCount = me.getPurgePageCount();
  52434. return purgePageCount ? Math.max(me.getData().getMaxSize() || 0, Math.ceil((rangeSizeRequested + me.getTrailingBufferZone() + me.getLeadingBufferZone()) / me.getPageSize()) * 2 + purgePageCount) : 0;
  52435. },
  52436. loadToPrefetch: function(options) {
  52437. var me = this,
  52438. prefetchOptions = options,
  52439. i, records, dataSetSize,
  52440. startIdx = options.start,
  52441. endIdx = options.start + options.limit - 1,
  52442. rangeSizeRequested = (me.getViewSize() || options.limit),
  52443. loadEndIdx = Math.min(endIdx, options.start + rangeSizeRequested - 1),
  52444. startPage = me.getPageFromRecordIndex(Math.max(startIdx - me.getTrailingBufferZone(), 0)),
  52445. endPage = me.getPageFromRecordIndex(endIdx + me.getLeadingBufferZone()),
  52446. data = me.getData(),
  52447. callbackFn = function() {
  52448. records = records || [];
  52449. if (options.loadCallback) {
  52450. options.loadCallback.call(options.scope || me, records, operation, true);
  52451. }
  52452. if (options.callback) {
  52453. options.callback.call(options.scope || me, records, startIdx || 0, endIdx || 0, options);
  52454. }
  52455. },
  52456. fireEventsFn = function() {
  52457. me.loadCount = (me.loadCount || 0) + 1;
  52458. me.fireEvent('datachanged', me);
  52459. me.fireEvent('refresh', me);
  52460. me.fireEvent('load', me, records, true);
  52461. },
  52462. waitForRequestedRange = function() {
  52463. if (me.rangeCached(startIdx, loadEndIdx)) {
  52464. me.loading = false;
  52465. records = data.getRange(startIdx, loadEndIdx + 1);
  52466. data.un('pageadd', waitForRequestedRange);
  52467. if (me.hasListeners.guaranteedrange) {
  52468. me.guaranteeRange(startIdx, loadEndIdx, options.callback, options.scope);
  52469. }
  52470. callbackFn();
  52471. fireEventsFn();
  52472. }
  52473. },
  52474. operation;
  52475. if (isNaN(me.pageSize) || !me.pageSize) {
  52476. Ext.raise('Buffered store configured without a pageSize', me);
  52477. }
  52478. data.setMaxSize(me.calculatePageCacheSize(rangeSizeRequested));
  52479. if (me.fireEvent('beforeload', me, options) !== false) {
  52480. delete me.totalCount;
  52481. me.loading = true;
  52482. if (options.callback) {
  52483. prefetchOptions = Ext.apply({}, options);
  52484. delete prefetchOptions.callback;
  52485. }
  52486. me.on('prefetch', function(store, records, successful, op) {
  52487. operation = op;
  52488. if (successful) {
  52489. if ((dataSetSize = me.getTotalCount())) {
  52490. data.on('pageadd', waitForRequestedRange);
  52491. loadEndIdx = Math.min(loadEndIdx, dataSetSize - 1);
  52492. endPage = me.getPageFromRecordIndex(Math.min(loadEndIdx + me.getLeadingBufferZone(), dataSetSize - 1));
  52493. for (i = startPage + 1; i <= endPage; ++i) {
  52494. me.prefetchPage(i, prefetchOptions);
  52495. }
  52496. } else {
  52497. callbackFn();
  52498. fireEventsFn();
  52499. }
  52500. } else
  52501. {
  52502. me.loading = false;
  52503. callbackFn();
  52504. me.fireEvent('load', me, records, false);
  52505. }
  52506. }, null, {
  52507. single: true
  52508. });
  52509. me.prefetchPage(startPage, prefetchOptions);
  52510. }
  52511. },
  52512. prefetch: function(options) {
  52513. var me = this,
  52514. pageSize = me.getPageSize(),
  52515. data = me.getData(),
  52516. operation, existingPageRequest;
  52517. if (pageSize) {
  52518. if (me.lastPageSize && pageSize !== me.lastPageSize) {
  52519. Ext.raise("pageSize cannot be dynamically altered");
  52520. }
  52521. if (!data.getPageSize()) {
  52522. data.setPageSize(pageSize);
  52523. }
  52524. } else
  52525. {
  52526. me.pageSize = data.setPageSize(pageSize = options.limit);
  52527. }
  52528. me.lastPageSize = pageSize;
  52529. if (!options.page) {
  52530. options.page = me.getPageFromRecordIndex(options.start);
  52531. options.start = (options.page - 1) * pageSize;
  52532. options.limit = Math.ceil(options.limit / pageSize) * pageSize;
  52533. }
  52534. existingPageRequest = me.pageRequests[options.page];
  52535. if (!existingPageRequest || existingPageRequest.getOperation().pageMapGeneration !== data.pageMapGeneration) {
  52536. options = Ext.apply({
  52537. action: 'read',
  52538. filters: me.getFilters().items,
  52539. sorters: me.getSorters().items,
  52540. grouper: me.getGrouper(),
  52541. internalCallback: me.onProxyPrefetch,
  52542. internalScope: me
  52543. }, options);
  52544. operation = me.createOperation('read', options);
  52545. operation.pageMapGeneration = data.pageMapGeneration;
  52546. if (me.fireEvent('beforeprefetch', me, operation) !== false) {
  52547. me.pageRequests[options.page] = operation.execute();
  52548. if (me.getProxy().isSynchronous) {
  52549. delete me.pageRequests[options.page];
  52550. }
  52551. }
  52552. }
  52553. return me;
  52554. },
  52555. onPageMapClear: function() {
  52556. var me = this,
  52557. loadingFlag = me.wasLoading,
  52558. reqs = me.pageRequests,
  52559. data = me.getData(),
  52560. page;
  52561. data.clearListeners();
  52562. data.on('clear', me.onPageMapClear, me);
  52563. me.relayEvents(data, [
  52564. 'beforepageremove',
  52565. 'pageadd',
  52566. 'pageremove'
  52567. ]);
  52568. me.loading = true;
  52569. me.totalCount = 0;
  52570. for (page in reqs) {
  52571. if (reqs.hasOwnProperty(page)) {
  52572. reqs[page].getOperation().abort();
  52573. }
  52574. }
  52575. me.fireEvent('clear', me);
  52576. me.loading = loadingFlag;
  52577. },
  52578. prefetchPage: function(page, options) {
  52579. var me = this,
  52580. pageSize = me.getPageSize(),
  52581. start = (page - 1) * pageSize,
  52582. total = me.totalCount;
  52583. if (total !== undefined && me.data.getCount() === total) {
  52584. return;
  52585. }
  52586. me.prefetch(Ext.applyIf({
  52587. page: page,
  52588. start: start,
  52589. limit: pageSize
  52590. }, options));
  52591. },
  52592. onProxyPrefetch: function(operation) {
  52593. if (this.destroying || this.destroyed) {
  52594. return;
  52595. }
  52596. var me = this,
  52597. resultSet = operation.getResultSet(),
  52598. records = operation.getRecords(),
  52599. successful = operation.wasSuccessful(),
  52600. page = operation.getPage(),
  52601. waitForReload = operation.waitForReload,
  52602. oldTotal = me.totalCount,
  52603. requests = me.pageRequests,
  52604. key, op;
  52605. if (operation.pageMapGeneration === me.getData().pageMapGeneration) {
  52606. if (resultSet) {
  52607. me.totalCount = resultSet.getTotal();
  52608. if (me.totalCount !== oldTotal) {
  52609. me.fireEvent('totalcountchange', me.totalCount);
  52610. }
  52611. }
  52612. if (page !== undefined) {
  52613. delete me.pageRequests[page];
  52614. }
  52615. me.loading = false;
  52616. me.fireEvent('prefetch', me, records, successful, operation);
  52617. if (successful) {
  52618. if (me.totalCount === 0) {
  52619. if (waitForReload) {
  52620. for (key in requests) {
  52621. op = requests[key].getOperation();
  52622. if (op.waitForReload === waitForReload) {
  52623. delete op.waitForReload;
  52624. }
  52625. }
  52626. me.getData().un('pageadd', waitForReload);
  52627. me.fireEvent('refresh', me);
  52628. me.fireEvent('load', me, [], true);
  52629. }
  52630. } else {
  52631. me.cachePage(records, operation.getPage());
  52632. }
  52633. }
  52634. Ext.callback(operation.getCallback(), operation.getScope() || me, [
  52635. records,
  52636. operation,
  52637. successful
  52638. ]);
  52639. }
  52640. },
  52641. cachePage: function(records, page) {
  52642. var me = this,
  52643. len = records.length,
  52644. i;
  52645. if (!Ext.isDefined(me.totalCount)) {
  52646. me.totalCount = records.length;
  52647. me.fireEvent('totalcountchange', me.totalCount);
  52648. }
  52649. for (i = 0; i < len; i++) {
  52650. records[i].join(me);
  52651. }
  52652. me.getData().addPage(page, records);
  52653. },
  52654. rangeCached: function(start, end, forRender) {
  52655. var requiredStart = start,
  52656. requiredEnd = end;
  52657. if (forRender !== false) {
  52658. requiredStart = start === 0 ? 0 : start - 1;
  52659. requiredEnd = end === this.totalCount - 1 ? end : end + 1;
  52660. }
  52661. return this.getData().hasRange(requiredStart, requiredEnd);
  52662. },
  52663. pageCached: function(page) {
  52664. return this.getData().hasPage(page);
  52665. },
  52666. pagePending: function(page) {
  52667. return !!this.pageRequests[page];
  52668. },
  52669. rangeSatisfied: function(start, end) {
  52670. return this.rangeCached(start, end);
  52671. },
  52672. onRangeAvailable: function(options) {
  52673. var me = this,
  52674. totalCount = me.getTotalCount(),
  52675. start = options.prefetchStart,
  52676. end = (options.prefetchEnd > totalCount - 1) ? totalCount - 1 : options.prefetchEnd,
  52677. range;
  52678. end = Math.max(0, end);
  52679. if (start > end) {
  52680. Ext.log({
  52681. level: 'warn',
  52682. msg: 'Start (' + start + ') was greater than end (' + end + ') for the range of records requested (' + start + '-' + options.prefetchEnd + ')' + (this.storeId ? ' from store "' + this.storeId + '"' : '')
  52683. });
  52684. }
  52685. range = me.getData().getRange(start, end + 1);
  52686. if (options.fireEvent !== false) {
  52687. me.fireEvent('guaranteedrange', range, start, end, options);
  52688. }
  52689. if (options.callback) {
  52690. options.callback.call(options.scope || me, range, start, end, options);
  52691. }
  52692. },
  52693. guaranteeRange: function(start, end, callback, scope, options) {
  52694. options = Ext.apply({
  52695. callback: callback,
  52696. scope: scope
  52697. }, options);
  52698. this.getRange(start, end + 1, options);
  52699. },
  52700. prefetchRange: function(start, end) {
  52701. var me = this,
  52702. startPage, endPage, page,
  52703. data = me.getData();
  52704. if (!me.rangeCached(start, end)) {
  52705. startPage = me.getPageFromRecordIndex(start);
  52706. endPage = me.getPageFromRecordIndex(end);
  52707. data.setMaxSize(me.calculatePageCacheSize(end - start + 1));
  52708. for (page = startPage; page <= endPage; page++) {
  52709. if (!me.pageCached(page)) {
  52710. me.prefetchPage(page);
  52711. }
  52712. }
  52713. }
  52714. },
  52715. primeCache: function(start, end, direction) {
  52716. var me = this,
  52717. leadingBufferZone = me.getLeadingBufferZone(),
  52718. trailingBufferZone = me.getTrailingBufferZone(),
  52719. pageSize = me.getPageSize(),
  52720. totalCount = me.totalCount;
  52721. if (direction === -1) {
  52722. start = Math.max(start - leadingBufferZone, 0);
  52723. end = Math.min(end + trailingBufferZone, totalCount - 1);
  52724. }
  52725. else if (direction === 1) {
  52726. start = Math.max(Math.min(start - trailingBufferZone, totalCount - pageSize), 0);
  52727. end = Math.min(end + leadingBufferZone, totalCount - 1);
  52728. } else
  52729. {
  52730. start = Math.min(Math.max(Math.floor(start - ((leadingBufferZone + trailingBufferZone) / 2)), 0), totalCount - me.pageSize);
  52731. end = Math.min(Math.max(Math.ceil(end + ((leadingBufferZone + trailingBufferZone) / 2)), 0), totalCount - 1);
  52732. }
  52733. me.prefetchRange(start, end);
  52734. },
  52735. sort: function(field, direction, mode) {
  52736. if (arguments.length === 0) {
  52737. this.clearAndLoad();
  52738. } else {
  52739. this.getSorters().addSort(field, direction, mode);
  52740. }
  52741. },
  52742. onSorterEndUpdate: function() {
  52743. var me = this,
  52744. sorters = me.getSorters().getRange();
  52745. if (sorters.length) {
  52746. me.fireEvent('beforesort', me, sorters);
  52747. me.clearAndLoad({
  52748. callback: function() {
  52749. me.fireEvent('sort', me, sorters);
  52750. }
  52751. });
  52752. } else {
  52753. me.fireEvent('sort', me, sorters);
  52754. }
  52755. },
  52756. clearAndLoad: function(options) {
  52757. var me = this;
  52758. me.clearing = true;
  52759. me.getData().clear();
  52760. me.clearing = false;
  52761. me.loadPage(1, options);
  52762. },
  52763. privates: {
  52764. isLast: function(record) {
  52765. return this.indexOf(record) === this.getTotalCount() - 1;
  52766. },
  52767. isMoving: function() {
  52768. return false;
  52769. }
  52770. }
  52771. });
  52772. Ext.define('Ext.data.ClientStore', {
  52773. extend: Ext.data.Store,
  52774. alias: 'store.clientstorage',
  52775. config: {
  52776. storage: 'local',
  52777. storageKey: null
  52778. },
  52779. trackRemoved: false,
  52780. proxy: {
  52781. type: 'memory',
  52782. clearOnRead: true
  52783. },
  52784. sync: function(options) {
  52785. var me = this,
  52786. key = me._getKey(),
  52787. storage = me.getStorage(),
  52788. source = me.getDataSource(),
  52789. proxy = me.getProxy(),
  52790. writer = proxy.getWriter(),
  52791. writeAll = writer.getWriteAllFields(),
  52792. data = [];
  52793. try {
  52794. me.suspendAutoSync();
  52795. writer.setWriteAllFields(true);
  52796. source.each(function(rec) {
  52797. if (rec.phantom) {
  52798. rec.setId(me.nextId());
  52799. }
  52800. data.push(writer.getRecordData(rec));
  52801. rec.commit();
  52802. });
  52803. if (data.length) {
  52804. data = JSON.stringify(data);
  52805. data = storage.setItem(key, data);
  52806. } else {
  52807. storage.removeItem(key);
  52808. }
  52809. if (options && options.success) {
  52810. Ext.callback(options.success, options.scope || proxy, [
  52811. null,
  52812. options
  52813. ]);
  52814. }
  52815. } catch (e) {
  52816. if (options && options.failure) {
  52817. Ext.callback(options.failure, options.scope || proxy, [
  52818. null,
  52819. options
  52820. ]);
  52821. }
  52822. } finally {
  52823. me.resumeAutoSync();
  52824. writer.setWriteAllFields(writeAll);
  52825. }
  52826. if (options && options.callback) {
  52827. Ext.callback(options.callback, options.scope || proxy, [
  52828. null,
  52829. options
  52830. ]);
  52831. }
  52832. return me;
  52833. },
  52834. applyStorage: function(storage) {
  52835. var ret = Ext.global[storage + 'Storage'];
  52836. if (!ret || !ret.getItem || !ret.setItem) {
  52837. Ext.raise('Invalid storage config "' + storage + '"; ' + 'expected "local" or "session"');
  52838. }
  52839. return ret;
  52840. },
  52841. updateProxy: function(proxy, oldProxy) {
  52842. var me = this,
  52843. key = me._getKey(),
  52844. storage = me.getStorage(),
  52845. data;
  52846. me.callParent([
  52847. proxy,
  52848. oldProxy
  52849. ]);
  52850. data = storage.getItem(key);
  52851. if (data) {
  52852. proxy.setData(JSON.parse(data));
  52853. }
  52854. },
  52855. privates: {
  52856. _getKey: function() {
  52857. var key = this.getStorageKey();
  52858. if (!key) {
  52859. Ext.raise('ClientStore requires a storageKey');
  52860. }
  52861. return key;
  52862. },
  52863. nextId: function() {
  52864. var source = this.getDataSource(),
  52865. id = 1;
  52866. while (source.containsKey(id)) {
  52867. ++id;
  52868. }
  52869. return id;
  52870. }
  52871. }
  52872. });
  52873. Ext.define('Ext.data.proxy.Direct', {
  52874. extend: Ext.data.proxy.Server,
  52875. alternateClassName: 'Ext.data.DirectProxy',
  52876. alias: 'proxy.direct',
  52877. config: {
  52878. paramOrder: undefined,
  52879. paramsAsHash: true,
  52880. directFn: undefined,
  52881. api: undefined,
  52882. metadata: undefined
  52883. },
  52884. paramOrderRe: /[\s,|]/,
  52885. constructor: function(config) {
  52886. this.callParent([
  52887. config
  52888. ]);
  52889. this.canceledOperations = {};
  52890. },
  52891. applyParamOrder: function(paramOrder) {
  52892. if (Ext.isString(paramOrder)) {
  52893. paramOrder = paramOrder.split(this.paramOrderRe);
  52894. }
  52895. return paramOrder;
  52896. },
  52897. updateApi: function() {
  52898. this.methodsResolved = false;
  52899. },
  52900. updateDirectFn: function() {
  52901. this.methodsResolved = false;
  52902. },
  52903. resolveMethods: function() {
  52904. var me = this,
  52905. fn = me.getDirectFn(),
  52906. api = me.getApi(),
  52907. method;
  52908. if (fn) {
  52909. me.setDirectFn(method = Ext.direct.Manager.parseMethod(fn));
  52910. if (!Ext.isFunction(method)) {
  52911. Ext.raise('Cannot resolve directFn ' + fn);
  52912. }
  52913. }
  52914. if (api) {
  52915. api = Ext.direct.Manager.resolveApi(api, me);
  52916. me.setApi(api);
  52917. }
  52918. me.methodsResolved = true;
  52919. },
  52920. doRequest: function(operation) {
  52921. var me = this,
  52922. writer, request, action, params, args, api, fn;
  52923. if (!me.methodsResolved) {
  52924. me.resolveMethods();
  52925. }
  52926. request = me.buildRequest(operation);
  52927. action = request.getAction();
  52928. api = me.getApi();
  52929. if (api) {
  52930. fn = api[action];
  52931. }
  52932. fn = fn || me.getDirectFn();
  52933. if (!fn || !fn.directCfg) {
  52934. Ext.raise({
  52935. msg: 'No Ext Direct function specified for Direct proxy "' + action + '" operation',
  52936. proxy: me
  52937. });
  52938. }
  52939. if (!me.paramOrder && fn.directCfg.method.len > 1) {
  52940. Ext.raise({
  52941. msg: 'Incorrect parameters for Direct proxy "' + action + '" operation',
  52942. proxy: me
  52943. });
  52944. }
  52945. writer = me.getWriter();
  52946. if (writer && operation.allowWrite()) {
  52947. request = writer.write(request);
  52948. }
  52949. if (action === 'read') {
  52950. params = request.getParams();
  52951. } else {
  52952. params = request.getJsonData();
  52953. }
  52954. args = fn.directCfg.method.getArgs({
  52955. params: params,
  52956. allowSingle: writer.getAllowSingle(),
  52957. paramOrder: me.getParamOrder(),
  52958. paramsAsHash: me.getParamsAsHash(),
  52959. paramsAsArray: true,
  52960. metadata: me.getMetadata(),
  52961. callback: me.createRequestCallback(request, operation),
  52962. scope: me
  52963. });
  52964. request.setConfig({
  52965. args: args,
  52966. directFn: fn
  52967. });
  52968. fn.apply(window, args);
  52969. return request;
  52970. },
  52971. abort: function(operation) {
  52972. var id;
  52973. if (operation && operation.isDataRequest) {
  52974. operation = operation.getOperation();
  52975. }
  52976. if (operation && operation.isOperation) {
  52977. id = operation.id;
  52978. }
  52979. if (id != null) {
  52980. this.canceledOperations[id] = true;
  52981. }
  52982. },
  52983. applyEncoding: Ext.identityFn,
  52984. createRequestCallback: function(request, operation) {
  52985. var me = this;
  52986. return function(data, event) {
  52987. if (!me.canceledOperations[operation.id]) {
  52988. me.processResponse(event.status, operation, request, event);
  52989. }
  52990. delete me.canceledOperations[operation.id];
  52991. };
  52992. },
  52993. extractResponseData: function(response) {
  52994. return Ext.isDefined(response.result) ? response.result : response.data;
  52995. },
  52996. setException: function(operation, response) {
  52997. operation.setException(response.message);
  52998. },
  52999. buildUrl: function() {
  53000. return '';
  53001. }
  53002. });
  53003. Ext.define('Ext.data.DirectStore', {
  53004. extend: Ext.data.Store,
  53005. alias: 'store.direct',
  53006. constructor: function(config) {
  53007. var proxy;
  53008. config = Ext.apply({}, config);
  53009. if (!config.proxy) {
  53010. proxy = {
  53011. type: 'direct',
  53012. reader: {
  53013. type: 'json'
  53014. }
  53015. };
  53016. Ext.copyTo(proxy, config, 'paramOrder,paramsAsHash,directFn,api,simpleSortMode,extraParams');
  53017. Ext.copyTo(proxy.reader, config, 'totalProperty,root,rootProperty,idProperty');
  53018. config.proxy = proxy;
  53019. }
  53020. this.callParent([
  53021. config
  53022. ]);
  53023. }
  53024. });
  53025. Ext.define('Ext.data.JsonP', {
  53026. singleton: true,
  53027. requestCount: 0,
  53028. requests: {},
  53029. timeout: 30000,
  53030. disableCaching: true,
  53031. disableCachingParam: '_dc',
  53032. callbackKey: 'callback',
  53033. request: function(options) {
  53034. options = Ext.apply({}, options);
  53035. if (!options.url) {
  53036. Ext.raise('A url must be specified for a JSONP request.');
  53037. }
  53038. var me = this,
  53039. disableCaching = Ext.isDefined(options.disableCaching) ? options.disableCaching : me.disableCaching,
  53040. cacheParam = options.disableCachingParam || me.disableCachingParam,
  53041. id = ++me.requestCount,
  53042. callbackName = options.callbackName || 'callback' + id,
  53043. callbackKey = options.callbackKey || me.callbackKey,
  53044. timeout = Ext.isDefined(options.timeout) ? options.timeout : me.timeout,
  53045. params = Ext.apply({}, options.params),
  53046. url = options.url,
  53047. name = Ext.name,
  53048. request, script;
  53049. if (disableCaching && !params[cacheParam]) {
  53050. params[cacheParam] = Ext.Date.now();
  53051. }
  53052. options.params = params;
  53053. params[callbackKey] = name + '.data.JsonP.' + callbackName;
  53054. script = me.createScript(url, params, options);
  53055. me.requests[id] = request = {
  53056. url: url,
  53057. params: params,
  53058. script: script,
  53059. id: id,
  53060. scope: options.scope,
  53061. success: options.success,
  53062. failure: options.failure,
  53063. callback: options.callback,
  53064. callbackKey: callbackKey,
  53065. callbackName: callbackName
  53066. };
  53067. if (timeout > 0) {
  53068. request.timeout = Ext.defer(me.handleTimeout, timeout, me, [
  53069. request
  53070. ]);
  53071. }
  53072. me.setupErrorHandling(request);
  53073. me[callbackName] = me.bindResponse(request);
  53074. me.loadScript(request);
  53075. return request;
  53076. },
  53077. bindResponse: function(request) {
  53078. var me = this;
  53079. return function(result) {
  53080. Ext.elevate(function() {
  53081. me.handleResponse(result, request);
  53082. });
  53083. };
  53084. },
  53085. abort: function(request) {
  53086. var me = this,
  53087. requests = me.requests,
  53088. key;
  53089. if (request) {
  53090. if (!request.id) {
  53091. request = requests[request];
  53092. }
  53093. me.handleAbort(request);
  53094. } else {
  53095. for (key in requests) {
  53096. if (requests.hasOwnProperty(key)) {
  53097. me.abort(requests[key]);
  53098. }
  53099. }
  53100. }
  53101. },
  53102. setupErrorHandling: function(request) {
  53103. request.script.onerror = Ext.bind(this.handleError, this, [
  53104. request
  53105. ]);
  53106. },
  53107. handleAbort: function(request) {
  53108. request.errorType = 'abort';
  53109. this.handleResponse(null, request);
  53110. },
  53111. handleError: function(request) {
  53112. request.errorType = 'error';
  53113. this.handleResponse(null, request);
  53114. },
  53115. cleanupErrorHandling: function(request) {
  53116. request.script.onerror = null;
  53117. },
  53118. handleTimeout: function(request) {
  53119. request.errorType = 'timeout';
  53120. this.handleResponse(null, request);
  53121. },
  53122. handleResponse: function(result, request) {
  53123. var success = true;
  53124. Ext.undefer(request.timeout);
  53125. delete this[request.callbackName];
  53126. delete this.requests[request.id];
  53127. this.cleanupErrorHandling(request);
  53128. Ext.fly(request.script).destroy();
  53129. if (request.errorType) {
  53130. success = false;
  53131. Ext.callback(request.failure, request.scope, [
  53132. request.errorType
  53133. ]);
  53134. } else {
  53135. Ext.callback(request.success, request.scope, [
  53136. result
  53137. ]);
  53138. }
  53139. Ext.callback(request.callback, request.scope, [
  53140. success,
  53141. result,
  53142. request.errorType
  53143. ]);
  53144. },
  53145. createScript: function(url, params, options) {
  53146. var script = document.createElement('script');
  53147. script.setAttribute("src", Ext.urlAppend(url, Ext.Object.toQueryString(params)));
  53148. script.setAttribute("async", true);
  53149. script.setAttribute("type", "text/javascript");
  53150. return script;
  53151. },
  53152. loadScript: function(request) {
  53153. Ext.getHead().appendChild(request.script);
  53154. }
  53155. });
  53156. Ext.define('Ext.data.proxy.JsonP', {
  53157. extend: Ext.data.proxy.Server,
  53158. alternateClassName: 'Ext.data.ScriptTagProxy',
  53159. alias: [
  53160. 'proxy.jsonp',
  53161. 'proxy.scripttag'
  53162. ],
  53163. config: {
  53164. callbackKey: 'callback',
  53165. recordParam: 'records',
  53166. autoAppendParams: true
  53167. },
  53168. doRequest: function(operation) {
  53169. var me = this,
  53170. request = me.buildRequest(operation),
  53171. params = request.getParams();
  53172. request.setConfig({
  53173. callbackKey: me.callbackKey,
  53174. timeout: me.timeout,
  53175. scope: me,
  53176. disableCaching: false,
  53177. callback: me.createRequestCallback(request, operation)
  53178. });
  53179. if (me.getAutoAppendParams()) {
  53180. request.setParams({});
  53181. }
  53182. request.setRawRequest(Ext.data.JsonP.request(request.getCurrentConfig()));
  53183. request.setParams(params);
  53184. me.lastRequest = request;
  53185. return request;
  53186. },
  53187. createRequestCallback: function(request, operation) {
  53188. var me = this;
  53189. return function(success, response, errorType) {
  53190. if (request === me.lastRequest) {
  53191. me.lastRequest = null;
  53192. }
  53193. me.processResponse(success, operation, request, response);
  53194. };
  53195. },
  53196. setException: function(operation, response) {
  53197. operation.setException(operation.getRequest().getRawRequest().errorType);
  53198. },
  53199. buildUrl: function(request) {
  53200. var me = this,
  53201. url = me.callParent(arguments),
  53202. records = request.getRecords(),
  53203. writer = me.getWriter(),
  53204. params, filters, filter, i, v;
  53205. if (writer && request.getOperation().allowWrite()) {
  53206. request = writer.write(request);
  53207. }
  53208. params = request.getParams();
  53209. filters = params.filters;
  53210. delete params.filters;
  53211. if (filters && filters.length) {
  53212. for (i = 0; i < filters.length; i++) {
  53213. filter = filters[i];
  53214. v = filter.getValue();
  53215. if (v) {
  53216. params[filter.getProperty()] = v;
  53217. }
  53218. }
  53219. }
  53220. if (Ext.isArray(records) && records.length > 0 && (!writer || !writer.getEncode())) {
  53221. params[me.getRecordParam()] = me.encodeRecords(records);
  53222. }
  53223. if (me.getAutoAppendParams()) {
  53224. url = Ext.urlAppend(url, Ext.Object.toQueryString(params));
  53225. }
  53226. return url;
  53227. },
  53228. abort: function(request) {
  53229. request = request || this.lastRequest;
  53230. if (request) {
  53231. Ext.data.JsonP.abort(request.getRawRequest());
  53232. }
  53233. },
  53234. encodeRecords: function(records) {
  53235. var encoded = [],
  53236. i = 0,
  53237. len = records.length;
  53238. for (; i < len; i++) {
  53239. encoded.push(Ext.encode(records[i].getData()));
  53240. }
  53241. return encoded;
  53242. }
  53243. });
  53244. Ext.define('Ext.data.JsonPStore', {
  53245. extend: Ext.data.Store,
  53246. alias: 'store.jsonp',
  53247. constructor: function(config) {
  53248. config = Ext.apply({
  53249. proxy: {
  53250. type: 'jsonp',
  53251. reader: 'json'
  53252. }
  53253. }, config);
  53254. this.callParent([
  53255. config
  53256. ]);
  53257. }
  53258. });
  53259. Ext.define('Ext.data.JsonStore', {
  53260. extend: Ext.data.Store,
  53261. alias: 'store.json',
  53262. constructor: function(config) {
  53263. config = Ext.apply({
  53264. proxy: {
  53265. type: 'ajax',
  53266. reader: 'json',
  53267. writer: 'json'
  53268. }
  53269. }, config);
  53270. this.callParent([
  53271. config
  53272. ]);
  53273. }
  53274. });
  53275. Ext.define('Ext.data.ModelManager', {
  53276. alternateClassName: 'Ext.ModelMgr',
  53277. singleton: true,
  53278. deprecated: {
  53279. 5: {
  53280. methods: {
  53281. clear: null,
  53282. create: function(data, name, id) {
  53283. var T = name;
  53284. if (!T.isEntity) {
  53285. T = this.getModel(name || data.name);
  53286. }
  53287. return T.createWithId(id, data);
  53288. },
  53289. each: function(fn, scope) {
  53290. Ext.data.Model.schema.eachEntity(fn, scope);
  53291. },
  53292. get: function(name) {
  53293. return this.getModel(name);
  53294. },
  53295. getCount: function() {
  53296. return Ext.data.Model.schema.entityCount;
  53297. },
  53298. getModel: function(id) {
  53299. return Ext.data.schema.Schema.lookupEntity(id);
  53300. },
  53301. isRegistered: function(name) {
  53302. return !!this.getModel(name);
  53303. }
  53304. }
  53305. }
  53306. }
  53307. });
  53308. Ext.define('Ext.data.NodeInterface', {
  53309. statics: {
  53310. decorate: function(modelClass) {
  53311. var model = Ext.data.schema.Schema.lookupEntity(modelClass),
  53312. proto = model.prototype,
  53313. idName, idField, idType;
  53314. if (!model.prototype.isObservable) {
  53315. model.mixin(Ext.mixin.Observable.prototype.mixinId, Ext.mixin.Observable);
  53316. }
  53317. if (proto.isNode) {
  53318. return;
  53319. }
  53320. idName = proto.idProperty;
  53321. idField = model.getField(idName);
  53322. idType = idField.type;
  53323. model.override(this.getPrototypeBody());
  53324. model.addFields([
  53325. {
  53326. name: 'parentId',
  53327. type: idType,
  53328. defaultValue: null,
  53329. allowNull: idField.allowNull
  53330. },
  53331. {
  53332. name: 'index',
  53333. type: 'int',
  53334. defaultValue: -1,
  53335. persist: false,
  53336. convert: null
  53337. },
  53338. {
  53339. name: 'depth',
  53340. type: 'int',
  53341. defaultValue: 0,
  53342. persist: false,
  53343. convert: null
  53344. },
  53345. {
  53346. name: 'expanded',
  53347. type: 'bool',
  53348. defaultValue: false,
  53349. persist: false,
  53350. convert: null
  53351. },
  53352. {
  53353. name: 'expandable',
  53354. type: 'bool',
  53355. defaultValue: true,
  53356. persist: false,
  53357. convert: null
  53358. },
  53359. {
  53360. name: 'checked',
  53361. type: 'auto',
  53362. defaultValue: null,
  53363. persist: false,
  53364. convert: null
  53365. },
  53366. {
  53367. name: 'leaf',
  53368. type: 'bool',
  53369. defaultValue: false
  53370. },
  53371. {
  53372. name: 'cls',
  53373. type: 'string',
  53374. defaultValue: '',
  53375. persist: false,
  53376. convert: null
  53377. },
  53378. {
  53379. name: 'iconCls',
  53380. type: 'string',
  53381. defaultValue: '',
  53382. persist: false,
  53383. convert: null
  53384. },
  53385. {
  53386. name: 'icon',
  53387. type: 'string',
  53388. defaultValue: '',
  53389. persist: false,
  53390. convert: null
  53391. },
  53392. {
  53393. name: 'glyph',
  53394. type: 'string',
  53395. defaultValue: '',
  53396. persist: false,
  53397. convert: null
  53398. },
  53399. {
  53400. name: 'root',
  53401. type: 'boolean',
  53402. defaultValue: false,
  53403. persist: false,
  53404. convert: null
  53405. },
  53406. {
  53407. name: 'isLast',
  53408. type: 'boolean',
  53409. defaultValue: false,
  53410. persist: false,
  53411. convert: null
  53412. },
  53413. {
  53414. name: 'isFirst',
  53415. type: 'boolean',
  53416. defaultValue: false,
  53417. persist: false,
  53418. convert: null
  53419. },
  53420. {
  53421. name: 'allowDrop',
  53422. type: 'boolean',
  53423. defaultValue: true,
  53424. persist: false,
  53425. convert: null
  53426. },
  53427. {
  53428. name: 'allowDrag',
  53429. type: 'boolean',
  53430. defaultValue: true,
  53431. persist: false,
  53432. convert: null
  53433. },
  53434. {
  53435. name: 'loaded',
  53436. type: 'boolean',
  53437. defaultValue: false,
  53438. persist: false,
  53439. convert: null
  53440. },
  53441. {
  53442. name: 'loading',
  53443. type: 'boolean',
  53444. defaultValue: false,
  53445. persist: false,
  53446. convert: null
  53447. },
  53448. {
  53449. name: 'href',
  53450. type: 'string',
  53451. defaultValue: '',
  53452. persist: false,
  53453. convert: null
  53454. },
  53455. {
  53456. name: 'hrefTarget',
  53457. type: 'string',
  53458. defaultValue: '',
  53459. persist: false,
  53460. convert: null
  53461. },
  53462. {
  53463. name: 'qtip',
  53464. type: 'string',
  53465. defaultValue: '',
  53466. persist: false,
  53467. convert: null
  53468. },
  53469. {
  53470. name: 'qtitle',
  53471. type: 'string',
  53472. defaultValue: '',
  53473. persist: false,
  53474. convert: null
  53475. },
  53476. {
  53477. name: 'qshowDelay',
  53478. type: 'int',
  53479. defaultValue: 0,
  53480. persist: false,
  53481. convert: null
  53482. },
  53483. {
  53484. name: 'children',
  53485. type: 'auto',
  53486. defaultValue: null,
  53487. persist: false,
  53488. convert: null
  53489. },
  53490. {
  53491. name: 'visible',
  53492. type: 'boolean',
  53493. defaultValue: true,
  53494. persist: false
  53495. },
  53496. {
  53497. name: 'text',
  53498. type: 'string',
  53499. persist: false
  53500. }
  53501. ]);
  53502. },
  53503. getPrototypeBody: function() {
  53504. var bubbledEvents = {
  53505. idchanged: true,
  53506. append: true,
  53507. remove: true,
  53508. move: true,
  53509. insert: true,
  53510. beforeappend: true,
  53511. beforeremove: true,
  53512. beforemove: true,
  53513. beforeinsert: true,
  53514. expand: true,
  53515. collapse: true,
  53516. beforeexpand: true,
  53517. beforecollapse: true,
  53518. sort: true
  53519. },
  53520. silently = {
  53521. silent: true
  53522. };
  53523. return {
  53524. isNode: true,
  53525. firstChild: null,
  53526. lastChild: null,
  53527. parentNode: null,
  53528. previousSibling: null,
  53529. nextSibling: null,
  53530. constructor: function() {
  53531. var me = this;
  53532. me.mixins.observable.constructor.call(me);
  53533. me.callParent(arguments);
  53534. me.childNodes = [];
  53535. return me;
  53536. },
  53537. createNode: function(node) {
  53538. var me = this,
  53539. childType = me.childType,
  53540. store, storeReader, nodeProxy, nodeReader, reader, typeProperty,
  53541. T = me.self;
  53542. if (!node.isModel) {
  53543. if (childType) {
  53544. T = me.schema.getEntity(childType);
  53545. } else
  53546. {
  53547. store = me.getTreeStore();
  53548. storeReader = store && store.getProxy().getReader();
  53549. nodeProxy = me.getProxy();
  53550. nodeReader = nodeProxy ? nodeProxy.getReader() : null;
  53551. reader = !storeReader || (nodeReader && nodeReader.initialConfig.typeProperty) ? nodeReader : storeReader;
  53552. if (reader) {
  53553. typeProperty = reader.getTypeProperty();
  53554. if (typeProperty) {
  53555. T = reader.getChildType(me.schema, node, typeProperty);
  53556. }
  53557. }
  53558. }
  53559. node = new T(node);
  53560. }
  53561. if (!node.childNodes) {
  53562. node.firstChild = node.lastChild = node.parentNode = node.previousSibling = node.nextSibling = null;
  53563. node.childNodes = [];
  53564. }
  53565. return node;
  53566. },
  53567. isLeaf: function() {
  53568. return this.get('leaf') === true;
  53569. },
  53570. setFirstChild: function(node) {
  53571. this.firstChild = node;
  53572. },
  53573. setLastChild: function(node) {
  53574. this.lastChild = node;
  53575. },
  53576. updateInfo: function(commit, info) {
  53577. var me = this,
  53578. phantom = me.phantom,
  53579. result, childInfo, children, childCount, i;
  53580. commit = {
  53581. silent: true,
  53582. commit: commit
  53583. };
  53584. if (info.depth != null && info.depth !== me.data.depth) {
  53585. childInfo = {
  53586. depth: info.depth + 1
  53587. };
  53588. children = me.childNodes;
  53589. childCount = children.length;
  53590. for (i = 0; i < childCount; i++) {
  53591. children[i].updateInfo(commit, childInfo);
  53592. }
  53593. }
  53594. result = me.set(info, commit);
  53595. me.phantom = phantom;
  53596. return result;
  53597. },
  53598. isLast: function() {
  53599. return this.get('isLast');
  53600. },
  53601. isFirst: function() {
  53602. return this.get('isFirst');
  53603. },
  53604. hasChildNodes: function() {
  53605. return !this.isLeaf() && this.childNodes.length > 0;
  53606. },
  53607. isExpandable: function() {
  53608. var me = this;
  53609. if (me.get('expandable')) {
  53610. return !(me.isLeaf() || (me.isLoaded() && !me.phantom && !me.hasChildNodes()));
  53611. }
  53612. return false;
  53613. },
  53614. triggerUIUpdate: function() {
  53615. this.callJoined('afterEdit', []);
  53616. },
  53617. appendChild: function(node, suppressEvents, commit) {
  53618. var me = this,
  53619. treeStore = me.getTreeStore(),
  53620. bulkUpdate = treeStore && treeStore.bulkUpdate,
  53621. childInfo = {
  53622. isLast: true,
  53623. parentId: me.getId(),
  53624. depth: (me.data.depth || 0) + 1
  53625. },
  53626. oldParent, previousSibling, modifiedFields, index, result, i, ln;
  53627. Ext.suspendLayouts();
  53628. if (Ext.isArray(node)) {
  53629. ln = node.length;
  53630. result = new Array(ln);
  53631. me.callTreeStore('beginFill');
  53632. for (i = 0; i < ln; i++) {
  53633. result[i] = me.appendChild(node[i], suppressEvents, commit);
  53634. }
  53635. me.callTreeStore('endFill', [
  53636. result
  53637. ]);
  53638. } else {
  53639. node = me.createNode(node);
  53640. if (suppressEvents !== true && me.fireBubbledEvent('beforeappend', [
  53641. me,
  53642. node
  53643. ]) === false) {
  53644. Ext.resumeLayouts(true);
  53645. return false;
  53646. }
  53647. index = me.childNodes.length;
  53648. oldParent = node.parentNode;
  53649. if (oldParent) {
  53650. if (suppressEvents !== true && node.fireBubbledEvent('beforemove', [
  53651. node,
  53652. oldParent,
  53653. me,
  53654. index
  53655. ]) === false) {
  53656. Ext.resumeLayouts(true);
  53657. return false;
  53658. }
  53659. if (oldParent.removeChild(node, false, suppressEvents, oldParent.getTreeStore() === treeStore) === false) {
  53660. Ext.resumeLayouts(true);
  53661. return false;
  53662. }
  53663. }
  53664. if (treeStore) {
  53665. treeStore.beginUpdate();
  53666. }
  53667. index = me.childNodes.length;
  53668. if (index === 0) {
  53669. me.setFirstChild(node);
  53670. }
  53671. me.childNodes[index] = node;
  53672. node.parentNode = me;
  53673. node.nextSibling = null;
  53674. me.setLastChild(node);
  53675. previousSibling = me.childNodes[index - 1];
  53676. if (previousSibling) {
  53677. node.previousSibling = previousSibling;
  53678. previousSibling.nextSibling = node;
  53679. previousSibling.updateInfo(commit, {
  53680. isLast: false
  53681. });
  53682. if (!bulkUpdate) {
  53683. previousSibling.triggerUIUpdate();
  53684. }
  53685. } else {
  53686. node.previousSibling = null;
  53687. }
  53688. childInfo.isFirst = index === 0;
  53689. childInfo.index = index;
  53690. modifiedFields = node.updateInfo(commit, childInfo);
  53691. if (me.isLeaf()) {
  53692. me.set('leaf', false);
  53693. }
  53694. if (!me.isLoaded()) {
  53695. if (bulkUpdate) {
  53696. me.data.loaded = true;
  53697. } else {
  53698. me.set('loaded', true);
  53699. }
  53700. } else if (me.childNodes.length === 1 && !bulkUpdate) {
  53701. me.triggerUIUpdate();
  53702. }
  53703. if (index && me.childNodes[index - 1].isExpanded() && !bulkUpdate) {
  53704. me.childNodes[index - 1].cascade(me.triggerUIUpdate);
  53705. }
  53706. if (treeStore) {
  53707. treeStore.registerNode(me, !bulkUpdate);
  53708. if (bulkUpdate) {
  53709. treeStore.registerNode(node);
  53710. }
  53711. }
  53712. if (suppressEvents !== true) {
  53713. me.fireBubbledEvent('append', [
  53714. me,
  53715. node,
  53716. index
  53717. ]);
  53718. if (oldParent) {
  53719. node.fireBubbledEvent('move', [
  53720. node,
  53721. oldParent,
  53722. me,
  53723. index
  53724. ]);
  53725. }
  53726. }
  53727. me.callTreeStore('onNodeAppend', [
  53728. node,
  53729. index
  53730. ]);
  53731. if (modifiedFields) {
  53732. node.callJoined('afterEdit', [
  53733. modifiedFields
  53734. ]);
  53735. }
  53736. result = node;
  53737. if (treeStore) {
  53738. treeStore.endUpdate();
  53739. }
  53740. }
  53741. Ext.resumeLayouts(true);
  53742. return result;
  53743. },
  53744. getOwnerTree: function() {
  53745. var store = this.getTreeStore();
  53746. return store && store.ownerTree;
  53747. },
  53748. getTreeStore: function() {
  53749. var root = this;
  53750. while (root && !root.treeStore) {
  53751. root = root.parentNode;
  53752. }
  53753. return root && root.treeStore;
  53754. },
  53755. removeChild: function(node, erase, suppressEvents, isMove) {
  53756. var me = this,
  53757. index = me.indexOf(node),
  53758. i, childCount, previousSibling,
  53759. treeStore = me.getTreeStore(),
  53760. bulkUpdate = treeStore && treeStore.bulkUpdate,
  53761. removeContext,
  53762. removeRange = [];
  53763. if (index === -1 || (suppressEvents !== true && me.fireBubbledEvent('beforeremove', [
  53764. me,
  53765. node,
  53766. !!isMove
  53767. ]) === false)) {
  53768. return false;
  53769. }
  53770. Ext.suspendLayouts();
  53771. if (treeStore) {
  53772. treeStore.beginUpdate();
  53773. }
  53774. Ext.Array.erase(me.childNodes, index, 1);
  53775. if (me.firstChild === node) {
  53776. me.setFirstChild(node.nextSibling);
  53777. }
  53778. if (me.lastChild === node) {
  53779. me.setLastChild(node.previousSibling);
  53780. }
  53781. previousSibling = node.previousSibling;
  53782. if (previousSibling) {
  53783. node.previousSibling.nextSibling = node.nextSibling;
  53784. }
  53785. if (node.nextSibling) {
  53786. node.nextSibling.previousSibling = node.previousSibling;
  53787. if (index === 0) {
  53788. node.nextSibling.updateInfo(false, {
  53789. isFirst: true
  53790. });
  53791. }
  53792. for (i = index , childCount = me.childNodes.length; i < childCount; i++) {
  53793. me.childNodes[i].updateInfo(false, {
  53794. index: i
  53795. });
  53796. }
  53797. }
  53798. else if (previousSibling) {
  53799. previousSibling.updateInfo(false, {
  53800. isLast: true
  53801. });
  53802. if (!bulkUpdate) {
  53803. if (previousSibling.isExpanded()) {
  53804. previousSibling.cascade(me.triggerUIUpdate);
  53805. } else
  53806. {
  53807. previousSibling.triggerUIUpdate();
  53808. }
  53809. }
  53810. }
  53811. if (!me.childNodes.length && !bulkUpdate) {
  53812. me.triggerUIUpdate();
  53813. }
  53814. Ext.resumeLayouts(true);
  53815. if (suppressEvents !== true) {
  53816. removeContext = {
  53817. parentNode: node.parentNode,
  53818. previousSibling: node.previousSibling,
  53819. nextSibling: node.nextSibling
  53820. };
  53821. me.callTreeStore('beforeNodeRemove', [
  53822. [
  53823. node
  53824. ],
  53825. !!isMove,
  53826. removeRange
  53827. ]);
  53828. node.previousSibling = node.nextSibling = node.parentNode = null;
  53829. me.fireBubbledEvent('remove', [
  53830. me,
  53831. node,
  53832. !!isMove,
  53833. removeContext
  53834. ]);
  53835. me.callTreeStore('onNodeRemove', [
  53836. [
  53837. node
  53838. ],
  53839. !!isMove,
  53840. removeRange
  53841. ]);
  53842. }
  53843. if (erase) {
  53844. node.erase(true);
  53845. } else {
  53846. node.clear();
  53847. }
  53848. if (!isMove) {
  53849. node.set({
  53850. parentId: null,
  53851. lastParentId: me.getId()
  53852. }, silently);
  53853. }
  53854. if (treeStore) {
  53855. treeStore.endUpdate();
  53856. }
  53857. return node;
  53858. },
  53859. copy: function(newId, session, deep) {
  53860. var me = this,
  53861. result,
  53862. args = [
  53863. newId
  53864. ],
  53865. len = me.childNodes ? me.childNodes.length : 0,
  53866. i;
  53867. if (session && session.isSession) {
  53868. args.push(session);
  53869. } else if (arguments.length < 3) {
  53870. deep = session;
  53871. }
  53872. result = me.callParent(args);
  53873. if (deep) {
  53874. for (i = 0; i < len; i++) {
  53875. result.appendChild(me.childNodes[i].copy(undefined, true));
  53876. }
  53877. }
  53878. return result;
  53879. },
  53880. clear: function(erase, resetChildren) {
  53881. var me = this;
  53882. me.parentNode = me.previousSibling = me.nextSibling = null;
  53883. if (erase) {
  53884. me.firstChild = me.lastChild = me.childNodes = null;
  53885. }
  53886. if (resetChildren) {
  53887. me.firstChild = me.lastChild = null;
  53888. me.childNodes.length = 0;
  53889. if (me.data) {
  53890. me.data.children = null;
  53891. }
  53892. }
  53893. },
  53894. drop: function() {
  53895. var me = this,
  53896. childNodes = me.childNodes,
  53897. parentNode = me.parentNode,
  53898. treeStore = me.getTreeStore(),
  53899. node, i, len;
  53900. me.callParent();
  53901. if (parentNode) {
  53902. parentNode.removeChild(me);
  53903. }
  53904. else if (me.get('root')) {
  53905. treeStore.setRoot(null);
  53906. }
  53907. if (treeStore) {
  53908. treeStore.beginUpdate();
  53909. }
  53910. for (i = 0 , len = childNodes ? childNodes.length : 0; i < len; i++) {
  53911. node = childNodes[i];
  53912. node.clear();
  53913. node.drop();
  53914. }
  53915. if (treeStore) {
  53916. treeStore.endUpdate();
  53917. }
  53918. },
  53919. erase: function(options) {
  53920. var me = this,
  53921. childNodes = me.childNodes,
  53922. len = childNodes && childNodes.length,
  53923. i, node;
  53924. me.remove();
  53925. me.clear(true);
  53926. me.callParent([
  53927. options
  53928. ]);
  53929. for (i = 0; i < len; i++) {
  53930. node = childNodes[i];
  53931. node.parentNode = null;
  53932. node.erase(options);
  53933. }
  53934. },
  53935. insertBefore: function(node, refNode, suppressEvents) {
  53936. var me = this,
  53937. index = me.indexOf(refNode),
  53938. oldParent = node.parentNode,
  53939. refIndex = index,
  53940. childCount, previousSibling, i,
  53941. treeStore = me.getTreeStore(),
  53942. bulkUpdate = treeStore && treeStore.bulkUpdate,
  53943. modifiedFields, sibling, siblingModifiedFields;
  53944. if (!refNode) {
  53945. return me.appendChild(node);
  53946. }
  53947. if (node === refNode) {
  53948. return false;
  53949. }
  53950. node = me.createNode(node);
  53951. if (suppressEvents !== true && me.fireBubbledEvent('beforeinsert', [
  53952. me,
  53953. node,
  53954. refNode
  53955. ]) === false) {
  53956. return false;
  53957. }
  53958. if (oldParent === me && me.indexOf(node) < index) {
  53959. refIndex--;
  53960. }
  53961. if (oldParent) {
  53962. if (suppressEvents !== true && node.fireBubbledEvent('beforemove', [
  53963. node,
  53964. oldParent,
  53965. me,
  53966. index,
  53967. refNode
  53968. ]) === false) {
  53969. return false;
  53970. }
  53971. if (oldParent.removeChild(node, false, suppressEvents, oldParent.getTreeStore() === treeStore) === false) {
  53972. return false;
  53973. }
  53974. }
  53975. if (treeStore) {
  53976. treeStore.beginUpdate();
  53977. }
  53978. if (refIndex === 0) {
  53979. me.setFirstChild(node);
  53980. }
  53981. Ext.Array.splice(me.childNodes, refIndex, 0, node);
  53982. node.parentNode = me;
  53983. node.nextSibling = refNode;
  53984. refNode.previousSibling = node;
  53985. previousSibling = me.childNodes[refIndex - 1];
  53986. if (previousSibling) {
  53987. node.previousSibling = previousSibling;
  53988. previousSibling.nextSibling = node;
  53989. } else {
  53990. node.previousSibling = null;
  53991. }
  53992. modifiedFields = node.updateInfo(false, {
  53993. parentId: me.getId(),
  53994. index: refIndex,
  53995. isFirst: refIndex === 0,
  53996. isLast: false,
  53997. depth: (me.data.depth || 0) + 1
  53998. });
  53999. for (i = refIndex + 1 , childCount = me.childNodes.length; i < childCount; i++) {
  54000. sibling = me.childNodes[i];
  54001. siblingModifiedFields = sibling.updateInfo(false, {
  54002. index: i
  54003. });
  54004. if (siblingModifiedFields) {
  54005. sibling.callJoined('afterEdit', [
  54006. siblingModifiedFields
  54007. ]);
  54008. }
  54009. }
  54010. if (!me.isLoaded()) {
  54011. if (bulkUpdate) {
  54012. me.data.loaded = true;
  54013. } else {
  54014. me.set('loaded', true);
  54015. }
  54016. }
  54017. else if (me.childNodes.length === 1 && !bulkUpdate) {
  54018. me.triggerUIUpdate();
  54019. }
  54020. if (treeStore) {
  54021. treeStore.registerNode(me, !bulkUpdate);
  54022. }
  54023. if (suppressEvents !== true) {
  54024. me.fireBubbledEvent('insert', [
  54025. me,
  54026. node,
  54027. refNode
  54028. ]);
  54029. if (oldParent) {
  54030. node.fireBubbledEvent('move', [
  54031. node,
  54032. oldParent,
  54033. me,
  54034. refIndex,
  54035. refNode
  54036. ]);
  54037. }
  54038. }
  54039. me.callTreeStore('onNodeInsert', [
  54040. node,
  54041. refIndex
  54042. ]);
  54043. if (modifiedFields) {
  54044. node.callJoined('afterEdit', [
  54045. modifiedFields
  54046. ]);
  54047. }
  54048. if (treeStore) {
  54049. treeStore.endUpdate();
  54050. }
  54051. return node;
  54052. },
  54053. insertChild: function(index, node) {
  54054. var sibling = this.childNodes[index];
  54055. if (sibling) {
  54056. return this.insertBefore(node, sibling);
  54057. } else {
  54058. return this.appendChild(node);
  54059. }
  54060. },
  54061. isLastVisible: function() {
  54062. var me = this,
  54063. result = me.data.isLast,
  54064. next = me.nextSibling;
  54065. if (!result && me.getTreeStore().isFiltered()) {
  54066. while (next) {
  54067. if (next.data.visible) {
  54068. return false;
  54069. }
  54070. next = next.nextSibling;
  54071. }
  54072. return true;
  54073. }
  54074. return result;
  54075. },
  54076. remove: function(erase, suppressEvents) {
  54077. var me = this,
  54078. parentNode = me.parentNode;
  54079. if (parentNode) {
  54080. parentNode.removeChild(me, erase, suppressEvents);
  54081. } else if (erase) {
  54082. me.erase(true);
  54083. }
  54084. return me;
  54085. },
  54086. removeAll: function(erase, suppressEvents, fromParent) {
  54087. var me = this,
  54088. childNodes = me.childNodes,
  54089. len = childNodes.length,
  54090. node, treeStore, i,
  54091. removeRange = [];
  54092. if (!len) {
  54093. return me;
  54094. }
  54095. if (!fromParent) {
  54096. treeStore = me.getTreeStore();
  54097. if (treeStore) {
  54098. treeStore.beginUpdate();
  54099. treeStore.suspendEvent('remove');
  54100. me.callTreeStore('beforeNodeRemove', [
  54101. childNodes,
  54102. false,
  54103. removeRange
  54104. ]);
  54105. }
  54106. }
  54107. for (i = 0; i < len; ++i) {
  54108. node = childNodes[i];
  54109. node.previousSibling = node.nextSibling = node.parentNode = null;
  54110. me.fireBubbledEvent('remove', [
  54111. me,
  54112. node,
  54113. false
  54114. ]);
  54115. if (erase) {
  54116. node.erase(true);
  54117. } else
  54118. {
  54119. node.removeAll(false, suppressEvents, true);
  54120. }
  54121. }
  54122. if (!fromParent && treeStore) {
  54123. treeStore.resumeEvent('remove');
  54124. me.callTreeStore('onNodeRemove', [
  54125. childNodes,
  54126. false,
  54127. removeRange
  54128. ]);
  54129. treeStore.endUpdate();
  54130. }
  54131. me.firstChild = me.lastChild = null;
  54132. childNodes.length = 0;
  54133. if (!fromParent) {
  54134. me.triggerUIUpdate();
  54135. }
  54136. return me;
  54137. },
  54138. getChildAt: function(index) {
  54139. return this.childNodes[index];
  54140. },
  54141. replaceChild: function(newChild, oldChild, suppressEvents) {
  54142. var s = oldChild ? oldChild.nextSibling : null;
  54143. this.removeChild(oldChild, false, suppressEvents);
  54144. this.insertBefore(newChild, s, suppressEvents);
  54145. return oldChild;
  54146. },
  54147. indexOf: function(child) {
  54148. return Ext.Array.indexOf(this.childNodes, child);
  54149. },
  54150. indexOfId: function(id) {
  54151. var childNodes = this.childNodes,
  54152. len = childNodes.length,
  54153. i = 0;
  54154. for (; i < len; ++i) {
  54155. if (childNodes[i].getId() === id) {
  54156. return i;
  54157. }
  54158. }
  54159. return -1;
  54160. },
  54161. getPath: function(field, separator) {
  54162. field = field || this.idProperty;
  54163. separator = separator || '/';
  54164. var path = [
  54165. this.get(field)
  54166. ],
  54167. parent = this.parentNode;
  54168. while (parent) {
  54169. path.unshift(parent.get(field));
  54170. parent = parent.parentNode;
  54171. }
  54172. return separator + path.join(separator);
  54173. },
  54174. getDepth: function() {
  54175. return this.get('depth');
  54176. },
  54177. bubble: function(fn, scope, args) {
  54178. var p = this;
  54179. while (p) {
  54180. if (fn.apply(scope || p, args || [
  54181. p
  54182. ]) === false) {
  54183. break;
  54184. }
  54185. p = p.parentNode;
  54186. }
  54187. },
  54188. cascade: function(spec, scope, args, after) {
  54189. var me = this,
  54190. before = spec,
  54191. childNodes, length, i;
  54192. if (arguments.length === 1 && !Ext.isFunction(spec)) {
  54193. after = spec.after;
  54194. scope = spec.scope;
  54195. args = spec.args;
  54196. before = spec.before;
  54197. }
  54198. if (!before || before.apply(scope || me, args || [
  54199. me
  54200. ]) !== false) {
  54201. childNodes = me.childNodes;
  54202. for (i = 0 , length = childNodes.length; i < length; i++) {
  54203. childNodes[i].cascade.call(childNodes[i], before, scope, args, after);
  54204. }
  54205. if (after) {
  54206. after.apply(scope || me, args || [
  54207. me
  54208. ]);
  54209. }
  54210. }
  54211. },
  54212. cascadeBy: function() {
  54213. return this.cascade.apply(this, arguments);
  54214. },
  54215. eachChild: function(fn, scope, args) {
  54216. var childNodes = this.childNodes,
  54217. length = childNodes.length,
  54218. i;
  54219. for (i = 0; i < length; i++) {
  54220. if (fn.apply(scope || this, args || [
  54221. childNodes[i]
  54222. ]) === false) {
  54223. break;
  54224. }
  54225. }
  54226. },
  54227. findChild: function(attribute, value, deep) {
  54228. return this.findChildBy(function() {
  54229. return this.get(attribute) == value;
  54230. },
  54231. null, deep);
  54232. },
  54233. findChildBy: function(fn, scope, deep) {
  54234. var cs = this.childNodes,
  54235. i, len, n, res;
  54236. for (i = 0 , len = cs.length; i < len; i++) {
  54237. n = cs[i];
  54238. if (fn.call(scope || n, n) === true) {
  54239. return n;
  54240. } else if (deep) {
  54241. res = n.findChildBy(fn, scope, deep);
  54242. if (res !== null) {
  54243. return res;
  54244. }
  54245. }
  54246. }
  54247. return null;
  54248. },
  54249. contains: function(node) {
  54250. return node.isAncestor(this);
  54251. },
  54252. isAncestor: function(node) {
  54253. var p = this.parentNode;
  54254. while (p) {
  54255. if (p === node) {
  54256. return true;
  54257. }
  54258. p = p.parentNode;
  54259. }
  54260. return false;
  54261. },
  54262. sort: function(sortFn, recursive, suppressEvent) {
  54263. var me = this,
  54264. childNodes = me.childNodes,
  54265. ln = childNodes.length,
  54266. info = {
  54267. isFirst: true
  54268. },
  54269. i, n;
  54270. if (ln > 0) {
  54271. if (!sortFn) {
  54272. sortFn = me.getTreeStore().getSortFn();
  54273. }
  54274. Ext.Array.sort(childNodes, sortFn);
  54275. me.setFirstChild(childNodes[0]);
  54276. me.setLastChild(childNodes[ln - 1]);
  54277. for (i = 0; i < ln; i++) {
  54278. n = childNodes[i];
  54279. n.previousSibling = childNodes[i - 1];
  54280. n.nextSibling = childNodes[i + 1];
  54281. info.isLast = (i === ln - 1);
  54282. info.index = i;
  54283. n.updateInfo(false, info);
  54284. info.isFirst = false;
  54285. if (recursive && !n.isLeaf()) {
  54286. n.sort(sortFn, true, true);
  54287. }
  54288. }
  54289. if (suppressEvent !== true) {
  54290. me.fireBubbledEvent('sort', [
  54291. me,
  54292. childNodes
  54293. ]);
  54294. me.callTreeStore('onNodeSort', [
  54295. childNodes
  54296. ]);
  54297. }
  54298. }
  54299. },
  54300. isExpanded: function() {
  54301. return this.get('expanded');
  54302. },
  54303. isLoaded: function() {
  54304. return this.get('loaded');
  54305. },
  54306. isBranchLoaded: function() {
  54307. var isBranchLoaded = !this.isLeaf() && this.isLoaded();
  54308. if (isBranchLoaded) {
  54309. this.cascade(function(node) {
  54310. if (!node.isLeaf()) {
  54311. isBranchLoaded = isBranchLoaded || node.isBranchLoaded();
  54312. }
  54313. return isBranchLoaded;
  54314. });
  54315. }
  54316. return isBranchLoaded;
  54317. },
  54318. isLoading: function() {
  54319. return this.get('loading');
  54320. },
  54321. isRoot: function() {
  54322. return !this.parentNode;
  54323. },
  54324. isVisible: function() {
  54325. var parent = this.parentNode;
  54326. while (parent) {
  54327. if (!parent.isExpanded()) {
  54328. return false;
  54329. }
  54330. parent = parent.parentNode;
  54331. }
  54332. return true;
  54333. },
  54334. expand: function(recursive, callback, scope) {
  54335. var me = this,
  54336. treeStore, resumeAddEvent;
  54337. if (!me.isLeaf()) {
  54338. if (me.isLoading()) {
  54339. me.on('expand', function() {
  54340. me.expand(recursive, callback, scope);
  54341. }, me, {
  54342. single: true
  54343. });
  54344. } else {
  54345. if (!me.isExpanded()) {
  54346. if (me.fireBubbledEvent('beforeexpand', [
  54347. me
  54348. ]) !== false) {
  54349. if (recursive) {
  54350. if (me.parentNode && me.parentNode.isSynchronousRecursiveExpand) {
  54351. me.isSynchronousRecursiveExpand = true;
  54352. } else {
  54353. treeStore = me.getTreeStore();
  54354. if (treeStore.getProxy().isSynchronous || me.isBranchLoaded()) {
  54355. me.isSynchronousRecursiveExpand = true;
  54356. treeStore.suspendEvent('add', 'datachanged');
  54357. resumeAddEvent = true;
  54358. }
  54359. }
  54360. }
  54361. me.callTreeStore('onBeforeNodeExpand', [
  54362. me.onChildNodesAvailable,
  54363. me,
  54364. [
  54365. recursive,
  54366. callback,
  54367. scope
  54368. ]
  54369. ]);
  54370. if (resumeAddEvent) {
  54371. treeStore.resumeEvent('add', 'datachanged');
  54372. treeStore.fireEvent('datachanged', treeStore);
  54373. treeStore.fireEvent('refresh', treeStore);
  54374. }
  54375. me.isSynchronousRecursiveExpand = false;
  54376. }
  54377. } else if (recursive) {
  54378. me.expandChildren(true, callback, scope);
  54379. } else {
  54380. Ext.callback(callback, scope || me, [
  54381. me.childNodes
  54382. ]);
  54383. }
  54384. }
  54385. } else {
  54386. Ext.callback(callback, scope || me);
  54387. }
  54388. },
  54389. onChildNodesAvailable: function(records, recursive, callback, scope) {
  54390. var me = this,
  54391. treeStore = me.getTreeStore(),
  54392. bulkUpdate = treeStore && treeStore.bulkUpdate,
  54393. ancestor, collapsedAncestors, i;
  54394. Ext.suspendLayouts();
  54395. for (ancestor = me.parentNode; ancestor; ancestor = ancestor.parentNode) {
  54396. if (!ancestor.isExpanded()) {
  54397. (collapsedAncestors || (collapsedAncestors = [])).unshift(ancestor);
  54398. }
  54399. }
  54400. if (bulkUpdate || !treeStore.isVisible(me)) {
  54401. me.data.expanded = true;
  54402. } else {
  54403. me.set('expanded', true);
  54404. }
  54405. if (collapsedAncestors) {
  54406. for (i = 1; i < collapsedAncestors.length; i++) {
  54407. ancestor = collapsedAncestors[i];
  54408. if (bulkUpdate || !treeStore.isVisible(ancestor)) {
  54409. ancestor.data.expanded = true;
  54410. } else {
  54411. ancestor.set('expanded', true);
  54412. }
  54413. }
  54414. collapsedAncestors[0].expand();
  54415. for (i = 1; i < collapsedAncestors.length; i++) {
  54416. ancestor = collapsedAncestors[i];
  54417. ancestor.fireBubbledEvent('expand', [
  54418. ancestor,
  54419. ancestor.childNodes
  54420. ]);
  54421. }
  54422. } else {
  54423. me.callTreeStore('onNodeExpand', [
  54424. records,
  54425. false
  54426. ]);
  54427. }
  54428. me.fireBubbledEvent('expand', [
  54429. me,
  54430. records
  54431. ]);
  54432. if (recursive) {
  54433. me.expandChildren(true, callback, scope);
  54434. } else {
  54435. Ext.callback(callback, scope || me, [
  54436. me.childNodes
  54437. ]);
  54438. }
  54439. Ext.resumeLayouts(true);
  54440. },
  54441. expandChildren: function(recursive, callback, scope, singleExpand) {
  54442. var me = this,
  54443. origCallback, i, allNodes, expandNodes, ln, node, treeStore;
  54444. if (Ext.isBoolean(callback)) {
  54445. origCallback = callback;
  54446. callback = scope;
  54447. scope = singleExpand;
  54448. singleExpand = origCallback;
  54449. }
  54450. if (singleExpand === undefined) {
  54451. treeStore = me.getTreeStore();
  54452. singleExpand = treeStore && treeStore.singleExpand;
  54453. }
  54454. allNodes = me.childNodes;
  54455. expandNodes = [];
  54456. ln = singleExpand ? Math.min(allNodes.length, 1) : allNodes.length;
  54457. for (i = 0; i < ln; ++i) {
  54458. node = allNodes[i];
  54459. if (!node.isLeaf()) {
  54460. expandNodes[expandNodes.length] = node;
  54461. }
  54462. }
  54463. ln = expandNodes.length;
  54464. for (i = 0; i < ln; ++i) {
  54465. expandNodes[i].expand(recursive);
  54466. }
  54467. if (callback) {
  54468. Ext.callback(callback, scope || me, [
  54469. me.childNodes
  54470. ]);
  54471. }
  54472. },
  54473. collapse: function(recursive, callback, scope) {
  54474. var me = this,
  54475. expanded = me.isExpanded(),
  54476. treeStore = me.getTreeStore(),
  54477. bulkUpdate = treeStore && treeStore.bulkUpdate,
  54478. len = me.childNodes.length,
  54479. i, collapseChildren;
  54480. if (!me.isLeaf() && ((!expanded && recursive) || me.fireBubbledEvent('beforecollapse', [
  54481. me
  54482. ]) !== false)) {
  54483. Ext.suspendLayouts();
  54484. if (me.isExpanded()) {
  54485. if (recursive) {
  54486. collapseChildren = function() {
  54487. for (i = 0; i < len; i++) {
  54488. me.childNodes[i].setCollapsed(true);
  54489. }
  54490. };
  54491. if (callback) {
  54492. callback = Ext.Function.createSequence(collapseChildren, Ext.Function.bind(callback, scope, [
  54493. me.childNodes
  54494. ]));
  54495. } else {
  54496. callback = collapseChildren;
  54497. }
  54498. } else if (callback) {
  54499. callback = Ext.Function.bind(callback, scope, [
  54500. me.childNodes
  54501. ]);
  54502. }
  54503. if (bulkUpdate || !treeStore.contains(me)) {
  54504. me.data.expanded = false;
  54505. } else {
  54506. me.set('expanded', false);
  54507. }
  54508. me.callTreeStore('onNodeCollapse', [
  54509. me.childNodes,
  54510. callback,
  54511. scope
  54512. ]);
  54513. me.fireBubbledEvent('collapse', [
  54514. me,
  54515. me.childNodes
  54516. ]);
  54517. callback = null;
  54518. }
  54519. else if (recursive) {
  54520. for (i = 0; i < len; i++) {
  54521. me.childNodes[i].setCollapsed(true);
  54522. }
  54523. }
  54524. Ext.resumeLayouts(true);
  54525. }
  54526. Ext.callback(callback, scope || me, [
  54527. me.childNodes
  54528. ]);
  54529. },
  54530. setCollapsed: function(recursive) {
  54531. var me = this,
  54532. len = me.childNodes.length,
  54533. i;
  54534. if (!me.isLeaf() && me.fireBubbledEvent('beforecollapse', [
  54535. me
  54536. ]) !== false) {
  54537. me.data.expanded = false;
  54538. me.fireBubbledEvent('collapse', [
  54539. me,
  54540. me.childNodes
  54541. ]);
  54542. if (recursive) {
  54543. for (i = 0; i < len; i++) {
  54544. me.childNodes[i].setCollapsed(true);
  54545. }
  54546. }
  54547. }
  54548. },
  54549. collapseChildren: function(recursive, callback, scope) {
  54550. var me = this,
  54551. allNodes = me.childNodes,
  54552. ln = allNodes.length,
  54553. collapseNodes = [],
  54554. node, i;
  54555. for (i = 0; i < ln; ++i) {
  54556. node = allNodes[i];
  54557. if (!node.isLeaf() && node.isLoaded() && node.isExpanded()) {
  54558. collapseNodes.push(node);
  54559. }
  54560. }
  54561. ln = collapseNodes.length;
  54562. if (ln) {
  54563. for (i = 0; i < ln; ++i) {
  54564. node = collapseNodes[i];
  54565. if (i === ln - 1) {
  54566. node.collapse(recursive, callback, scope);
  54567. } else {
  54568. node.collapse(recursive);
  54569. }
  54570. }
  54571. } else {
  54572. Ext.callback(callback, scope);
  54573. }
  54574. },
  54575. fireEvent: function(eventName) {
  54576. return this.fireBubbledEvent(eventName, Ext.Array.slice(arguments, 1));
  54577. },
  54578. fireBubbledEvent: function(eventName, args) {
  54579. var result, eventSource, topNode;
  54580. if (bubbledEvents[eventName]) {
  54581. for (eventSource = this; result !== false && eventSource; eventSource = (topNode = eventSource).parentNode) {
  54582. result = eventSource.fireEventArgs.call(eventSource, eventName, args);
  54583. }
  54584. if (result !== false) {
  54585. eventSource = topNode.getTreeStore();
  54586. if (eventSource && eventSource.hasListeners && eventSource.hasListeners[eventName = 'node' + eventName]) {
  54587. result = eventSource.fireEventArgs(eventName, args);
  54588. }
  54589. }
  54590. return result;
  54591. } else
  54592. {
  54593. return this.fireEventArgs.apply(this, arguments);
  54594. }
  54595. },
  54596. serialize: function(writerParam) {
  54597. var writer = writerParam || new Ext.data.writer.Json({
  54598. writeAllFields: true
  54599. }),
  54600. result = writer.getRecordData(this),
  54601. childNodes = this.childNodes,
  54602. len = childNodes.length,
  54603. children, i;
  54604. if (len > 0) {
  54605. result.children = children = [];
  54606. for (i = 0; i < len; i++) {
  54607. children.push(childNodes[i].serialize(writer));
  54608. }
  54609. }
  54610. return result;
  54611. },
  54612. callTreeStore: function(funcName, args) {
  54613. var me = this,
  54614. target = me.getTreeStore(),
  54615. fn = target && target[funcName];
  54616. if (target && fn) {
  54617. args = args || [];
  54618. if (args[0] !== me) {
  54619. args.unshift(me);
  54620. }
  54621. fn.apply(target, args);
  54622. }
  54623. },
  54624. addCls: function(cls) {
  54625. this.replaceCls(null, cls);
  54626. },
  54627. removeCls: function(cls) {
  54628. this.replaceCls(cls);
  54629. },
  54630. replaceCls: function(oldCls, newCls) {
  54631. var pieces = this._parseCls(this.data.cls),
  54632. parts = this._parseCls(oldCls);
  54633. if (parts.length) {
  54634. pieces = Ext.Array.difference(pieces, parts);
  54635. }
  54636. parts = this._parseCls(newCls);
  54637. if (parts.length) {
  54638. pieces = Ext.Array.unique(pieces.concat(parts));
  54639. }
  54640. this.set('cls', pieces.join(' '));
  54641. },
  54642. toggleCls: function(cls, state) {
  54643. var pieces, parts, len, i, p;
  54644. if (state === undefined) {
  54645. pieces = this._parseCls(this.data.cls);
  54646. parts = this._parseCls(cls);
  54647. for (i = 0 , len = parts.length; i < len; ++i) {
  54648. p = parts[i];
  54649. if (Ext.Array.contains(pieces, p)) {
  54650. Ext.Array.remove(pieces, p);
  54651. } else {
  54652. pieces.push(p);
  54653. }
  54654. }
  54655. this.set('cls', pieces.join(' '));
  54656. } else if (state) {
  54657. this.addCls(cls);
  54658. } else {
  54659. this.removeCls(cls);
  54660. }
  54661. },
  54662. privates: {
  54663. _noCls: [],
  54664. spacesRe: /\s+/,
  54665. join: function(store) {
  54666. if (store.isTreeStore) {
  54667. if (this.isRoot()) {
  54668. this.treeStore = this.store = store;
  54669. }
  54670. } else
  54671. {
  54672. this.callParent([
  54673. store
  54674. ]);
  54675. }
  54676. },
  54677. callJoined: function(funcName, args) {
  54678. this.callParent([
  54679. funcName,
  54680. args
  54681. ]);
  54682. this.callTreeStore(funcName, args);
  54683. },
  54684. _parseCls: function(cls) {
  54685. if (!cls) {
  54686. return this._noCls;
  54687. }
  54688. if (typeof cls === 'string') {
  54689. return cls.split(this.spacesRe);
  54690. }
  54691. return cls;
  54692. }
  54693. }
  54694. };
  54695. }
  54696. }
  54697. });
  54698. Ext.define('Ext.data.TreeModel', {
  54699. extend: Ext.data.Model,
  54700. mixins: [
  54701. Ext.mixin.Queryable
  54702. ],
  54703. getRefItems: function() {
  54704. return this.childNodes;
  54705. },
  54706. getRefOwner: function() {
  54707. return this.parentNode;
  54708. },
  54709. statics: {
  54710. defaultProxy: 'memory'
  54711. }
  54712. }, function() {
  54713. Ext.data.NodeInterface.decorate(this);
  54714. });
  54715. Ext.define('Ext.data.NodeStore', {
  54716. extend: Ext.data.Store,
  54717. alias: 'store.node',
  54718. isNodeStore: true,
  54719. config: {
  54720. node: null,
  54721. recursive: false,
  54722. rootVisible: false,
  54723. folderSort: false
  54724. },
  54725. implicitModel: 'Ext.data.TreeModel',
  54726. getTotalCount: function() {
  54727. return this.getCount();
  54728. },
  54729. updateFolderSort: function(folderSort) {
  54730. var data = this.getData();
  54731. data.setTrackGroups(false);
  54732. if (folderSort) {
  54733. data.setGrouper({
  54734. groupFn: this.folderSortFn
  54735. });
  54736. } else {
  54737. data.setGrouper(null);
  54738. }
  54739. },
  54740. folderSortFn: function(node) {
  54741. return node.data.leaf ? 1 : 0;
  54742. },
  54743. afterReject: function(record) {
  54744. var me = this;
  54745. if (me.contains(record)) {
  54746. me.onUpdate(record, Ext.data.Model.REJECT, null);
  54747. me.fireEvent('update', me, record, Ext.data.Model.REJECT, null);
  54748. }
  54749. },
  54750. afterCommit: function(record, modifiedFieldNames) {
  54751. var me = this;
  54752. if (!modifiedFieldNames) {
  54753. modifiedFieldNames = null;
  54754. }
  54755. if (me.contains(record)) {
  54756. me.onUpdate(record, Ext.data.Model.COMMIT, modifiedFieldNames);
  54757. me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
  54758. }
  54759. },
  54760. onNodeAppend: function(parent, node) {
  54761. if (parent === this.getNode()) {
  54762. this.add([
  54763. node
  54764. ].concat(this.retrieveChildNodes(node)));
  54765. }
  54766. },
  54767. onNodeInsert: function(parent, node, refNode) {
  54768. var me = this;
  54769. if (parent === me.getNode()) {
  54770. me.insert(0, [
  54771. node
  54772. ].concat(me.retrieveChildNodes(node)));
  54773. }
  54774. },
  54775. onNodeRemove: function(parent, node) {
  54776. if (parent === this.getNode()) {
  54777. this.remove([
  54778. node
  54779. ].concat(this.retrieveChildNodes(node)));
  54780. }
  54781. },
  54782. onNodeExpand: function(parent, records) {
  54783. if (parent === this.getNode()) {
  54784. this.loadRecords(records);
  54785. }
  54786. },
  54787. applyNode: function(node) {
  54788. if (node) {
  54789. if (!node.isModel) {
  54790. node = new (this.getModel())(node);
  54791. }
  54792. if (!node.isNode) {
  54793. Ext.data.NodeInterface.decorate(node);
  54794. }
  54795. }
  54796. return node;
  54797. },
  54798. updateNode: function(node, oldNode) {
  54799. var me = this,
  54800. data;
  54801. if (oldNode && !oldNode.destroyed) {
  54802. oldNode.un({
  54803. append: 'onNodeAppend',
  54804. insert: 'onNodeInsert',
  54805. remove: 'onNodeRemove',
  54806. scope: me
  54807. });
  54808. oldNode.unjoin(me);
  54809. }
  54810. if (node) {
  54811. node.on({
  54812. scope: me,
  54813. append: 'onNodeAppend',
  54814. insert: 'onNodeInsert',
  54815. remove: 'onNodeRemove'
  54816. });
  54817. node.join(me);
  54818. data = [];
  54819. if (node.childNodes.length) {
  54820. data = data.concat(me.retrieveChildNodes(node));
  54821. }
  54822. if (me.getRootVisible()) {
  54823. data.push(node);
  54824. } else if (node.isLoaded() || node.isLoading()) {
  54825. node.set('expanded', true);
  54826. }
  54827. me.getData().clear();
  54828. me.fireEvent('clear', me);
  54829. me.suspendEvents();
  54830. if (me.isInitializing) {
  54831. me.inlineData = data;
  54832. } else {
  54833. me.add(data);
  54834. }
  54835. me.resumeEvents();
  54836. if (data.length === 0) {
  54837. me.loaded = node.loaded = true;
  54838. }
  54839. me.fireEvent('refresh', me, me.data);
  54840. }
  54841. },
  54842. isVisible: function(node) {
  54843. var parent = node.parentNode;
  54844. if (!this.getRecursive() && parent !== this.getNode()) {
  54845. return false;
  54846. }
  54847. while (parent) {
  54848. if (!parent.isExpanded()) {
  54849. return false;
  54850. }
  54851. if (parent === this.getNode()) {
  54852. break;
  54853. }
  54854. parent = parent.parentNode;
  54855. }
  54856. return true;
  54857. },
  54858. privates: {
  54859. retrieveChildNodes: function(root) {
  54860. var node = this.getNode(),
  54861. recursive = this.getRecursive(),
  54862. added = [],
  54863. child = root;
  54864. if (!root.childNodes.length || (!recursive && root !== node)) {
  54865. return added;
  54866. }
  54867. if (!recursive) {
  54868. return root.childNodes;
  54869. }
  54870. while (child) {
  54871. if (child._added) {
  54872. delete child._added;
  54873. if (child === root) {
  54874. break;
  54875. } else {
  54876. child = child.nextSibling || child.parentNode;
  54877. }
  54878. } else {
  54879. if (child !== root) {
  54880. added.push(child);
  54881. }
  54882. if (child.firstChild) {
  54883. child._added = true;
  54884. child = child.firstChild;
  54885. } else {
  54886. child = child.nextSibling || child.parentNode;
  54887. }
  54888. }
  54889. }
  54890. return added;
  54891. }
  54892. }
  54893. });
  54894. Ext.define('Ext.data.query.Compiler', {
  54895. compile: function() {
  54896. var me = this,
  54897. ast = me.ast,
  54898. body, factory, vars;
  54899. me.error = null;
  54900. if (!ast) {
  54901. me.fn = Ext.returnTrue;
  54902. } else {
  54903. body = [
  54904. 'return function (item) {',
  54905. '\tvar rec = item.isEntity && item;',
  54906. '\treturn '
  54907. ];
  54908. vars = [];
  54909. me.query = me;
  54910. me.assemble(body, vars, '\t', ast);
  54911. body.push('}');
  54912. body = vars.concat(body).join('\n');
  54913. try {
  54914. factory = new Function('Ext', 'O', 'F', body);
  54915. me.fn = factory(Ext, me.operators, me.getFunctions());
  54916. me.fn.generation = me.generation;
  54917. } catch (e) {
  54918. me.error = e;
  54919. e.message = 'Failed to compile: ' + e.message;
  54920. throw e;
  54921. } finally {
  54922. me.query = null;
  54923. }
  54924. }
  54925. },
  54926. privates: {
  54927. asmOps: {
  54928. '>': 'gt',
  54929. '<': 'lt',
  54930. '==': 'eq',
  54931. '>=': 'ge',
  54932. '<=': 'le',
  54933. '!=': 'ne'
  54934. },
  54935. assemblers: {
  54936. binary: function(me, body, vars, indent, node, last, childIndent) {
  54937. var op = me.operatorTypeMap[node.type][1],
  54938. asmOp = me.asmOps[op],
  54939. operands = node.on,
  54940. close = '',
  54941. i;
  54942. if (asmOp) {
  54943. body[last] += 'O.' + asmOp + '(';
  54944. op = ', ';
  54945. close = ')';
  54946. } else {
  54947. op = ' ' + op + ' ';
  54948. }
  54949. body[last] += '(';
  54950. for (i = 0; i < operands.length; ++i) {
  54951. if (i) {
  54952. body.push(indent + ')' + op + '(');
  54953. }
  54954. body.push(childIndent);
  54955. me.assemble(body, vars, childIndent, operands[i]);
  54956. }
  54957. body.push(indent + ')' + close);
  54958. },
  54959. between: function(me, body, vars, indent, node, last, childIndent) {
  54960. var operands = node.on,
  54961. i;
  54962. body[last] += 'O.between(';
  54963. for (i = 0; i < 3; ++i) {
  54964. if (i) {
  54965. last = body.length - 1;
  54966. body[last] += ', ';
  54967. }
  54968. me.assemble(body, vars, childIndent, operands[i]);
  54969. }
  54970. body.push(indent + ')');
  54971. },
  54972. fn: function(me, body, vars, indent, node, last, childIndent) {
  54973. var fn = node.fn.toLowerCase(),
  54974. func = me.query.getFunctions(),
  54975. exprs, i;
  54976. if (!func[fn]) {
  54977. Ext.raise('Unsupported function "' + node.fn + '"');
  54978. }
  54979. func = func[fn];
  54980. if (func.vargs) {
  54981. body[last] += 'F.' + fn + '.fn([';
  54982. } else {
  54983. body[last] += 'F.' + fn + '.fn(';
  54984. }
  54985. exprs = node.args;
  54986. for (i = 0; i < exprs.length; ++i) {
  54987. if (i) {
  54988. last = body.length - 1;
  54989. body[last] += ', ';
  54990. }
  54991. body.push(childIndent);
  54992. me.assemble(body, vars, childIndent, exprs[i]);
  54993. }
  54994. if (func.vargs) {
  54995. body.push(indent + '])');
  54996. } else {
  54997. body.push(indent + ')');
  54998. }
  54999. },
  55000. id: function(me, body, vars, indent, node, last, childIndent) {
  55001. var v = node.value,
  55002. exprs = v.split('.');
  55003. if (exprs.length === 1) {
  55004. body[last] += 'rec ? rec.interpret(' + Ext.JSON.encode(v) + ') : item.' + v;
  55005. } else {
  55006. v = 'p' + vars.length;
  55007. vars.push('var ' + v + ' = ' + Ext.JSON.encode(exprs) + ';');
  55008. body[last] += 'O.dots(item, ' + v + ')';
  55009. }
  55010. },
  55011. 'in': function(me, body, vars, indent, node, last, childIndent) {
  55012. var operands = node.on;
  55013. body[last] += 'O.in(';
  55014. me.assemble(body, vars, childIndent, operands[0]);
  55015. last = body.length - 1;
  55016. body[last] += ', ';
  55017. me.assemble(body, vars, childIndent, operands[1]);
  55018. body.push(indent + ')');
  55019. },
  55020. like: function(me, body, vars, indent, node, last, childIndent) {
  55021. var operands = node.on,
  55022. rhs;
  55023. body[last] += 'O.like(';
  55024. me.assemble(body, vars, childIndent, operands[0]);
  55025. last = body.length - 1;
  55026. body[last] += ', ';
  55027. rhs = operands[1];
  55028. if (rhs.re) {
  55029. rhs = {
  55030. type: 'regexp',
  55031. value: rhs.re,
  55032. flags: rhs.flags
  55033. };
  55034. }
  55035. me.assemble(body, vars, childIndent, rhs);
  55036. last = body.length - 1;
  55037. body[last] += ') ';
  55038. },
  55039. list: function(me, body, vars, indent, node, last, childIndent) {
  55040. body[last] += '[';
  55041. for (var i = 0,
  55042. exprs = node.value; i < exprs.length; ++i) {
  55043. if (i) {
  55044. last = body.length - 1;
  55045. body[last] += ', ';
  55046. }
  55047. body.push(childIndent);
  55048. me.assemble(body, vars, childIndent, exprs[i]);
  55049. }
  55050. body.push(indent + ']');
  55051. },
  55052. string: 'regexp',
  55053. regexp: function(me, body, vars, indent, node, last) {
  55054. var re = 're' + vars.length;
  55055. vars.push('var ' + re + ' = /' + (node.re || node.value) + '/' + (node.flags || '') + ';');
  55056. body[last] += re;
  55057. },
  55058. unary: function(me, body, vars, indent, node, last, childIndent) {
  55059. var op = me.operatorTypeMap[node.type][1],
  55060. operands = node.on;
  55061. body[last] += op + '(';
  55062. body.push(childIndent);
  55063. me.assemble(body, vars, childIndent, operands);
  55064. body.push(indent + ')');
  55065. }
  55066. },
  55067. operators: {
  55068. between: function(val, lo, hi) {
  55069. return lo <= val && val <= hi;
  55070. },
  55071. dots: function(item, names) {
  55072. var i, ret;
  55073. if (item.isEntity) {
  55074. for (ret = item , i = 0; i < names.length; ++i) {
  55075. if (!ret || !ret.interpret) {
  55076. ret = undefined;
  55077. break;
  55078. }
  55079. ret = ret.interpret(names[i]);
  55080. }
  55081. } else {
  55082. for (ret = item , i = 0; i < names.length; ++i) {
  55083. if (!ret) {
  55084. ret = undefined;
  55085. break;
  55086. }
  55087. ret = ret[names[i]];
  55088. }
  55089. }
  55090. return ret;
  55091. },
  55092. 'in': function(val, values) {
  55093. return Ext.Array.contains(values, val);
  55094. },
  55095. like: function(val, pat) {
  55096. val = String(val);
  55097. if (typeof pat === 'string') {
  55098. return !!val && val.toLowerCase().indexOf(pat.toLowerCase()) > -1;
  55099. }
  55100. return pat.test(val);
  55101. },
  55102. eq: function(lhs, rhs) {
  55103. if (lhs && rhs && (lhs instanceof Date || rhs instanceof Date)) {
  55104. return !Ext.Date.compare(lhs, rhs);
  55105. }
  55106. return lhs == rhs;
  55107. },
  55108. ge: function(lhs, rhs) {
  55109. if (lhs && rhs && (lhs instanceof Date || rhs instanceof Date)) {
  55110. return Ext.Date.compare(lhs, rhs) >= 0;
  55111. }
  55112. return lhs >= rhs;
  55113. },
  55114. gt: function(lhs, rhs) {
  55115. if (lhs && rhs && (lhs instanceof Date || rhs instanceof Date)) {
  55116. return Ext.Date.compare(lhs, rhs) > 0;
  55117. }
  55118. return lhs > rhs;
  55119. },
  55120. le: function(lhs, rhs) {
  55121. if (lhs && rhs && (lhs instanceof Date || rhs instanceof Date)) {
  55122. return Ext.Date.compare(lhs, rhs) <= 0;
  55123. }
  55124. return lhs <= rhs;
  55125. },
  55126. lt: function(lhs, rhs) {
  55127. if (lhs && rhs && (lhs instanceof Date || rhs instanceof Date)) {
  55128. return Ext.Date.compare(lhs, rhs) < 0;
  55129. }
  55130. return lhs < rhs;
  55131. },
  55132. ne: function(lhs, rhs) {
  55133. if (lhs && rhs && (lhs instanceof Date || rhs instanceof Date)) {
  55134. return !!Ext.Date.compare(lhs, rhs);
  55135. }
  55136. return lhs != rhs;
  55137. }
  55138. },
  55139. assemble: function(body, vars, indent, node) {
  55140. var me = this,
  55141. assemblers = me.assemblers,
  55142. t = typeof node,
  55143. last = body.length - 1,
  55144. childIndent = indent + '\t',
  55145. type = node.type,
  55146. arity, asm;
  55147. if (t === 'boolean' || t === 'number') {
  55148. body[last] += node;
  55149. } else if (t === 'string') {
  55150. body[last] += Ext.JSON.encode(node);
  55151. } else {
  55152. arity = me.operatorTypeMap[type];
  55153. asm = assemblers[type] || (arity && assemblers[arity[0]]);
  55154. if (typeof asm === 'string') {
  55155. asm = assemblers[asm];
  55156. }
  55157. asm(me, body, vars, indent, node, body.length - 1, childIndent);
  55158. }
  55159. }
  55160. }
  55161. });
  55162. Ext.define('Ext.data.query.Converter', {
  55163. getFilters: function() {
  55164. var me = this,
  55165. ast = me.ast,
  55166. exprToFilter = me.exprToFilter,
  55167. operatorTypeMap = me.operatorTypeMap,
  55168. fn = me.fn,
  55169. on = ast && ast.on,
  55170. expr, filter, filters, i, ident, n, op, ret, value, xlat;
  55171. if (ast) {
  55172. if (fn.hasOwnProperty('$filters')) {
  55173. ret = fn.$filters;
  55174. } else {
  55175. if (ast.type === 'and' && on) {
  55176. filters = [];
  55177. for (i = 0 , n = on.length; i < n; ++i) {
  55178. expr = on[i];
  55179. ident = expr.on;
  55180. if (!ident || ident.length !== 2) {
  55181. break;
  55182. }
  55183. value = ident[1];
  55184. ident = ident[0];
  55185. if (ident.type !== 'id') {
  55186. break;
  55187. }
  55188. if (!(xlat = exprToFilter[expr.type])) {
  55189. op = operatorTypeMap[expr.type];
  55190. if (!op || !(xlat = exprToFilter[op[0]])) {
  55191. break;
  55192. }
  55193. }
  55194. if (!(filter = xlat(expr, ident.value, value, op))) {
  55195. break;
  55196. }
  55197. filters.push(filter);
  55198. }
  55199. if (i === n) {
  55200. ret = filters;
  55201. }
  55202. }
  55203. fn.$filters = ret;
  55204. }
  55205. } else {
  55206. ret = null;
  55207. }
  55208. return ret;
  55209. },
  55210. setFilters: function(filters) {
  55211. var me = this,
  55212. ast = null,
  55213. n = filters && filters.length,
  55214. expr, filter, i, op, xlat;
  55215. if (n) {
  55216. ast = {
  55217. type: 'and',
  55218. on: []
  55219. };
  55220. for (i = 0; i < n; ++i) {
  55221. filter = filters[i];
  55222. if (!(xlat = me.filterToExpr[op = filter.operator])) {
  55223. expr = {
  55224. type: me.getOperatorType(op),
  55225. on: [
  55226. {
  55227. type: 'id',
  55228. value: filter.property
  55229. },
  55230. filter.value
  55231. ]
  55232. };
  55233. } else {
  55234. expr = xlat(filter);
  55235. }
  55236. ast.on.push(expr);
  55237. }
  55238. }
  55239. me.ast = ast;
  55240. me.refresh();
  55241. },
  55242. privates: {
  55243. exprToFilter: {
  55244. binary: function(expr, ident, value, info) {
  55245. return Ext.isPrimitive(value) && {
  55246. property: ident,
  55247. operator: info[1],
  55248. value: value
  55249. };
  55250. },
  55251. 'in': function(expr, ident, value) {
  55252. var i = 0,
  55253. list = value.value;
  55254. if (value.type === 'list' && Ext.isArray(list)) {
  55255. for (i = list.length; i-- > 0; )
  55256. {
  55257. if (!Ext.isPrimitive(list[i])) {
  55258. break;
  55259. }
  55260. }
  55261. }
  55262. return (i < 0) && {
  55263. property: ident,
  55264. operator: 'in',
  55265. value: list
  55266. };
  55267. },
  55268. like: function(expr, ident, value) {
  55269. if (value.type === 'regexp') {
  55270. return {
  55271. property: ident,
  55272. operator: '/=',
  55273. value: value.value
  55274. };
  55275. }
  55276. return (value.type === 'string') && {
  55277. property: ident,
  55278. operator: 'like',
  55279. value: value.value
  55280. };
  55281. }
  55282. },
  55283. filterToExpr: {
  55284. '/=': function(filter) {
  55285. return {
  55286. type: 'like',
  55287. on: [
  55288. {
  55289. type: 'id',
  55290. value: filter.property
  55291. },
  55292. {
  55293. type: 'regexp',
  55294. value: filter.value
  55295. }
  55296. ]
  55297. };
  55298. },
  55299. 'in': function(filter) {
  55300. return {
  55301. type: 'in',
  55302. on: [
  55303. {
  55304. type: 'id',
  55305. value: filter.property
  55306. },
  55307. {
  55308. type: 'list',
  55309. value: filter.value
  55310. }
  55311. ]
  55312. };
  55313. },
  55314. like: function(filter) {
  55315. return {
  55316. type: 'like',
  55317. on: [
  55318. {
  55319. type: 'id',
  55320. value: filter.property
  55321. },
  55322. {
  55323. type: 'string',
  55324. value: filter.value,
  55325. re: filter.value,
  55326. flags: 'i'
  55327. }
  55328. ]
  55329. };
  55330. }
  55331. }
  55332. }
  55333. });
  55334. Ext.define('Ext.data.query.Stringifier', {
  55335. stringify: function(node) {
  55336. var me = this,
  55337. t = typeof node,
  55338. type = node.type,
  55339. operatorTypeMap = me.operatorTypeMap,
  55340. priority = me.getPriority(node),
  55341. stringifiers = me.stringifiers,
  55342. op, stringifier;
  55343. if (t === 'boolean' || t === 'number') {
  55344. return String(node);
  55345. }
  55346. if (t === 'string') {
  55347. return Ext.JSON.encode(node);
  55348. }
  55349. stringifier = stringifiers[type];
  55350. if (!stringifier && type in operatorTypeMap) {
  55351. op = operatorTypeMap[type];
  55352. stringifier = stringifiers[op[0]];
  55353. op = op[2] || op[1];
  55354. }
  55355. if (typeof stringifier === 'string') {
  55356. stringifier = stringifiers[stringifier];
  55357. }
  55358. return stringifier(me, node, priority, op);
  55359. },
  55360. privates: {
  55361. getPriority: function(node) {
  55362. var symbols = this.symbols,
  55363. operatorTypeMap = this.operatorTypeMap,
  55364. type = node.type,
  55365. ret = 1000000000,
  55366. op;
  55367. if (type === 'between') {
  55368. ret = 0;
  55369. ret = symbols[type].priority;
  55370. } else if (type === 'and' || type === 'or' || type === 'in' || type === 'like') {
  55371. ret = symbols[type].priority;
  55372. } else if (type in operatorTypeMap) {
  55373. op = operatorTypeMap[type];
  55374. ret = symbols[op[1]].priority;
  55375. }
  55376. return ret;
  55377. },
  55378. stringifiers: {
  55379. and: 'or',
  55380. or: function(me, node, priority) {
  55381. var op = (node.type === 'or') ? ' or ' : ' and ',
  55382. s = '',
  55383. on = node.on,
  55384. i, lhs, parenL;
  55385. for (i = 0; i < on.length; ++i) {
  55386. if (s) {
  55387. s += op;
  55388. }
  55389. lhs = on[i];
  55390. parenL = me.getPriority(lhs) < priority;
  55391. lhs = me.stringify(lhs);
  55392. if (parenL) {
  55393. lhs = '(' + lhs + ')';
  55394. }
  55395. s += lhs;
  55396. }
  55397. return s;
  55398. },
  55399. between: function(me, node, priority) {
  55400. var on = node.on,
  55401. lhs = on[0],
  55402. parenL = me.getPriority(lhs) < priority,
  55403. i, parenR, rhs, s;
  55404. lhs = me.stringify(lhs);
  55405. if (parenL) {
  55406. lhs = '(' + lhs + ')';
  55407. }
  55408. s = lhs + ' between ';
  55409. priority = me.symbols.and.priority;
  55410. for (i = 0; i < 2; ++i) {
  55411. if (i) {
  55412. s += ' and ';
  55413. }
  55414. rhs = on[i + 1];
  55415. parenR = i ? (rhs.type !== 'id' && !Ext.isPrimitive(rhs)) : (me.getPriority(rhs) < priority);
  55416. rhs = me.stringify(rhs);
  55417. if (parenR) {
  55418. rhs = '(' + rhs + ')';
  55419. }
  55420. s += rhs;
  55421. }
  55422. return s;
  55423. },
  55424. binary: function(me, node, priority, op) {
  55425. var on = node.on,
  55426. lhs = on[0],
  55427. rhs = on[1],
  55428. parenL = me.getPriority(lhs) < priority,
  55429. parenR = me.getPriority(rhs) < priority;
  55430. lhs = me.stringify(lhs);
  55431. rhs = me.stringify(rhs);
  55432. if (parenL) {
  55433. lhs = '(' + lhs + ')';
  55434. }
  55435. if (parenR) {
  55436. rhs = '(' + rhs + ')';
  55437. }
  55438. return lhs + ' ' + op + ' ' + rhs;
  55439. },
  55440. fn: function(me, node) {
  55441. return node.fn + '(' + me.stringifyArray(node.args) + ')';
  55442. },
  55443. id: function(me, node) {
  55444. return node.value;
  55445. },
  55446. list: function(me, node) {
  55447. return '(' + me.stringifyArray(node.value) + ')';
  55448. },
  55449. regexp: function(me, node) {
  55450. return '/' + node.value + '/' + (node.flags || '');
  55451. },
  55452. string: function(me, node) {
  55453. return Ext.JSON.encode(node.value);
  55454. },
  55455. unary: function(me, node, priority, op) {
  55456. var on = node.on,
  55457. rhs = me.stringify(on),
  55458. t = on.type;
  55459. if (t !== 'fn' && t !== 'id' && t !== 'unary') {
  55460. rhs = '(' + rhs + ')';
  55461. }
  55462. return op + rhs;
  55463. }
  55464. },
  55465. stringifyArray: function(array) {
  55466. var s = '',
  55467. i, expr;
  55468. for (i = 0; i < array.length; ++i) {
  55469. if (s) {
  55470. s += ', ';
  55471. }
  55472. expr = array[i];
  55473. expr = this.stringify(expr);
  55474. s += expr;
  55475. }
  55476. return s;
  55477. }
  55478. }
  55479. });
  55480. Ext.define('Ext.data.query.Parser', function(QueryParser) {
  55481. var LIST = {
  55482. list: true,
  55483. literal: true,
  55484. type: 'list'
  55485. };
  55486. return {
  55487. extend: Ext.parse.Parser,
  55488. tokenizer: {
  55489. keywords: {
  55490. and: {
  55491. type: 'operator',
  55492. name: 'and',
  55493. value: '&&',
  55494. is: {
  55495. operator: true
  55496. }
  55497. },
  55498. or: {
  55499. type: 'operator',
  55500. name: 'or',
  55501. value: '||',
  55502. is: {
  55503. operator: true
  55504. }
  55505. },
  55506. not: {
  55507. type: 'operator',
  55508. name: 'not',
  55509. value: '!',
  55510. is: {
  55511. operator: true
  55512. }
  55513. },
  55514. between: {
  55515. type: 'operator',
  55516. name: 'between',
  55517. value: 'between',
  55518. is: {
  55519. operator: true
  55520. }
  55521. },
  55522. like: {
  55523. type: 'operator',
  55524. name: 'like',
  55525. value: 'like',
  55526. is: {
  55527. operator: true
  55528. }
  55529. },
  55530. 'in': {
  55531. type: 'operator',
  55532. name: 'in',
  55533. value: 'in',
  55534. is: {
  55535. operator: true
  55536. }
  55537. }
  55538. },
  55539. operators: {
  55540. '=': 'eq',
  55541. '==': 'seq',
  55542. '===': 'seq',
  55543. '!==': 'sne',
  55544. '!=': 'neq',
  55545. '<>': 'neq',
  55546. '<': 'lt',
  55547. '<=': 'lte',
  55548. '>': 'gt',
  55549. '>=': 'gte',
  55550. '&&': 'and',
  55551. '||': 'or',
  55552. ',': 'comma'
  55553. },
  55554. patterns: {
  55555. regex: {
  55556. type: 'literal',
  55557. is: {
  55558. literal: true,
  55559. regexp: true,
  55560. type: 'regexp'
  55561. },
  55562. re: /\/(?!\/)((?:\[.+?]|\\.|[^/\\\r\n])+)\/([gimyu]{0,5})/g,
  55563. extract: function(match) {
  55564. var body = match[1],
  55565. flags = match[2];
  55566. return flags ? [
  55567. body,
  55568. flags
  55569. ] : body;
  55570. }
  55571. }
  55572. }
  55573. },
  55574. infix: {
  55575. '=': 40,
  55576. '<>': 40,
  55577. like: 40,
  55578. between: {
  55579. priority: 70,
  55580. led: function(left) {
  55581. var me = this,
  55582. parser = me.parser;
  55583. me.arity = 'between';
  55584. me.operand = left;
  55585. me.low = parser.parseExpression(parser.symbols.and.priority);
  55586. parser.advance('&&');
  55587. me.high = parser.parseExpression(80);
  55588. return me;
  55589. }
  55590. },
  55591. 'in': {
  55592. priority: 40,
  55593. led: function(left) {
  55594. var me = this,
  55595. parser = me.parser;
  55596. parser.advance('(');
  55597. me.arity = 'binary';
  55598. me.lhs = left;
  55599. me.rhs = {
  55600. arity: 'literal',
  55601. value: parser.parseList(),
  55602. is: LIST
  55603. };
  55604. parser.advance(')');
  55605. return me;
  55606. }
  55607. }
  55608. },
  55609. infixRight: {
  55610. 'and': 30,
  55611. 'or': 30
  55612. },
  55613. prefix: {
  55614. not: 0
  55615. },
  55616. parse: function() {
  55617. var expr = this.parseExpression();
  55618. return this.convert(expr);
  55619. },
  55620. privates: {
  55621. opCodes: {
  55622. binary: {
  55623. '=': 'eq',
  55624. '>': 'gt',
  55625. '<': 'lt',
  55626. '>=': 'ge',
  55627. '<=': 'le',
  55628. '!=': 'ne',
  55629. '<>': 'ne',
  55630. '+': 'add',
  55631. '/': 'div',
  55632. '*': 'mul',
  55633. '-': 'sub'
  55634. },
  55635. unary: {
  55636. '-': 'neg',
  55637. '!': 'not'
  55638. }
  55639. },
  55640. convert: function(node) {
  55641. var me = this,
  55642. arity = node.arity,
  55643. is = node.is,
  55644. name = node.name,
  55645. opCodes = me.opCodes,
  55646. value = node.value,
  55647. exprs, lhs, rhs, ret;
  55648. switch (arity) {
  55649. case 'between':
  55650. ret = {
  55651. type: 'between',
  55652. on: [
  55653. me.convert(node.operand),
  55654. me.convert(node.low),
  55655. me.convert(node.high)
  55656. ]
  55657. };
  55658. break;
  55659. case 'ident':
  55660. ret = {
  55661. type: 'id',
  55662. value: value
  55663. };
  55664. break;
  55665. case 'invoke':
  55666. ret = {
  55667. type: 'fn',
  55668. fn: node.operand.value,
  55669. args: me.convertArray(node.args)
  55670. };
  55671. break;
  55672. case 'unary':
  55673. ret = {
  55674. type: opCodes.unary[value],
  55675. on: me.convert(node.operand)
  55676. };
  55677. break;
  55678. case 'binary':
  55679. if (name === 'and' || name === 'or') {
  55680. lhs = me.convert(node.lhs);
  55681. rhs = me.convert(node.rhs);
  55682. if (rhs.type === name) {
  55683. exprs = rhs.on;
  55684. exprs.unshift(lhs);
  55685. } else {
  55686. exprs = [
  55687. lhs,
  55688. rhs
  55689. ];
  55690. }
  55691. ret = {
  55692. type: name,
  55693. on: exprs
  55694. };
  55695. } else {
  55696. if (value === 'or') {
  55697. value = '||';
  55698. }
  55699. ret = {
  55700. type: opCodes.binary[value] || name,
  55701. on: [
  55702. me.convert(node.lhs),
  55703. me.convert(node.rhs)
  55704. ]
  55705. };
  55706. if (name === 'like') {
  55707. ret.on[1] = me.likeToRe(ret.on[1], node.rhs.at);
  55708. }
  55709. };
  55710. break;
  55711. case 'literal':
  55712. if (is.string || is.number || is.boolean) {
  55713. ret = value;
  55714. } else {
  55715. ret = {
  55716. type: is.type,
  55717. value: value
  55718. };
  55719. if (is.list) {
  55720. ret.value = me.convertArray(value);
  55721. } else if (is.regexp && typeof value !== 'string') {
  55722. ret.value = value[0];
  55723. ret.flags = value[1];
  55724. }
  55725. };
  55726. break;
  55727. }
  55728. if (ret && typeof ret === 'object' && !ret.type) {
  55729. ret.type = arity;
  55730. }
  55731. return ret;
  55732. },
  55733. convertArray: function(array) {
  55734. var ret = [],
  55735. i = array.length;
  55736. for (; i-- > 0; )
  55737. {
  55738. ret[i] = this.convert(array[i]);
  55739. }
  55740. return ret;
  55741. },
  55742. likeToRe: function(node, at) {
  55743. if (typeof node === 'string') {
  55744. node = {
  55745. type: 'string',
  55746. value: node
  55747. };
  55748. } else if (node.type === 'regexp') {
  55749. return node;
  55750. }
  55751. var specialChars = this.specialChars || (QueryParser.prototype.specialChars = Ext.Array.toMap('.+*?^$=!|:-<>[](){}\\'.split(''))),
  55752. like = node.value,
  55753. n = like.length,
  55754. re = '',
  55755. simple = true,
  55756. escape, c, i, start;
  55757. outer: for (i = 0; i < n; ++i) {
  55758. c = like[i];
  55759. if (!escape) {
  55760. if (c === '\\') {
  55761. escape = c;
  55762. continue;
  55763. }
  55764. if (c === '*' || c === '%') {
  55765. re += '.*';
  55766. simple = false;
  55767. continue;
  55768. }
  55769. if (c === '?' || c === '_') {
  55770. re += '.';
  55771. simple = false;
  55772. continue;
  55773. }
  55774. if (c === '[') {
  55775. re += c;
  55776. simple = false;
  55777. start = i;
  55778. while (++i < n) {
  55779. c = like[i];
  55780. if (escape) {
  55781. re += escape + c;
  55782. escape = 0;
  55783. } else if (c === '\\') {
  55784. escape = c;
  55785. } else {
  55786. re += c;
  55787. if (c === ']') {
  55788. continue outer;
  55789. }
  55790. }
  55791. }
  55792. this.syntaxError(start + (node.at || at || 0), 'Incomplete character set');
  55793. }
  55794. }
  55795. escape = 0;
  55796. if (specialChars[c]) {
  55797. re += '\\';
  55798. }
  55799. re += c;
  55800. }
  55801. node.re = re || '.*';
  55802. if (simple) {
  55803. node.flags = 'i';
  55804. } else {
  55805. node.re = '^' + re + '$';
  55806. }
  55807. return node;
  55808. },
  55809. parseList: function() {
  55810. var me = this,
  55811. list = [];
  55812. do {
  55813. if (list.length) {
  55814. me.advance();
  55815. }
  55816. list.push(me.parseExpression());
  55817. } while (
  55818. me.token.id === ',');
  55819. return list;
  55820. }
  55821. }
  55822. };
  55823. });
  55824. Ext.define('Ext.data.Query', {
  55825. extend: Ext.util.BasicFilter,
  55826. mixins: [
  55827. Ext.mixin.Factoryable,
  55828. Ext.data.query.Compiler,
  55829. Ext.data.query.Converter,
  55830. Ext.data.query.Stringifier
  55831. ],
  55832. alias: 'query.default',
  55833. config: {
  55834. format: 'ast',
  55835. functions: {
  55836. cached: true,
  55837. $value: {
  55838. abs: function(arg) {
  55839. return Math.abs(arg);
  55840. },
  55841. 'avg...': function(args) {
  55842. var count = 0,
  55843. sum = 0,
  55844. i = args.length,
  55845. v;
  55846. for (; i-- > 0; )
  55847. {
  55848. v = args[i];
  55849. if (v != null) {
  55850. sum += v;
  55851. ++count;
  55852. }
  55853. }
  55854. return count ? sum / count : 0;
  55855. },
  55856. date: function(arg) {
  55857. return (arg instanceof Date) ? arg : Ext.Date.parse(arg);
  55858. },
  55859. lower: function(arg) {
  55860. return (arg == null) ? '' : String(arg).toLowerCase();
  55861. },
  55862. 'max...': function(args) {
  55863. var ret = null,
  55864. i = args.length,
  55865. v;
  55866. for (; i-- > 0; )
  55867. {
  55868. v = args[i];
  55869. if (v != null) {
  55870. ret = (ret === null) ? v : (ret < v ? v : ret);
  55871. }
  55872. }
  55873. return ret;
  55874. },
  55875. 'min...': function(args) {
  55876. var ret = null,
  55877. i = args.length,
  55878. v;
  55879. for (; i-- > 0; )
  55880. {
  55881. v = args[i];
  55882. if (v != null) {
  55883. ret = (ret === null) ? v : (ret < v ? ret : v);
  55884. }
  55885. }
  55886. return ret;
  55887. },
  55888. 'sum...': function(args) {
  55889. var ret = null,
  55890. i = args.length,
  55891. v;
  55892. for (; i-- > 0; )
  55893. {
  55894. v = args[i];
  55895. if (v != null) {
  55896. ret = (ret === null) ? v : (ret + v);
  55897. }
  55898. }
  55899. return ret === null ? 0 : ret;
  55900. },
  55901. upper: function(arg) {
  55902. return (arg == null) ? '' : String(arg).toUpperCase();
  55903. }
  55904. }
  55905. },
  55906. source: ''
  55907. },
  55908. ast: null,
  55909. error: null,
  55910. generation: 0,
  55911. constructor: function(config) {
  55912. if (typeof config === 'string') {
  55913. config = {
  55914. source: config
  55915. };
  55916. }
  55917. var parser = Ext.data.query.Parser.fly();
  55918. this.symbols = parser.symbols;
  55919. parser.release();
  55920. this.callParent([
  55921. config
  55922. ]);
  55923. },
  55924. filter: function(item) {
  55925. var me = this,
  55926. error = me.error;
  55927. if (error) {
  55928. throw error;
  55929. }
  55930. return !!me.fn(item);
  55931. },
  55932. refresh: function() {
  55933. ++this.generation;
  55934. this.compile();
  55935. },
  55936. serialize: function() {
  55937. var me = this,
  55938. format = me.getFormat(),
  55939. serializer = me.getSerializer(),
  55940. ret, serialized;
  55941. switch (format) {
  55942. case 'ast':
  55943. ret = me.ast;
  55944. if (serializer) {
  55945. ret = Ext.clone(ret);
  55946. };
  55947. break;
  55948. case 'filters':
  55949. ret = me.getFilters() || null;
  55950. break;
  55951. case 'query':
  55952. ret = me.toString();
  55953. break;
  55954. }
  55955. if (ret && serializer) {
  55956. serialized = serializer.call(this, ret);
  55957. if (serialized) {
  55958. ret = serialized;
  55959. }
  55960. }
  55961. return ret;
  55962. },
  55963. serializeTo: function(out) {
  55964. var filters = this.serialize(),
  55965. ret;
  55966. if (filters && filters.length) {
  55967. out.push.apply(out, filters);
  55968. ret = true;
  55969. }
  55970. return ret;
  55971. },
  55972. sync: function() {
  55973. var me = this,
  55974. fn = me.fn;
  55975. if (!fn || fn.generation !== me.generation) {
  55976. me.compile();
  55977. }
  55978. },
  55979. toString: function() {
  55980. var ast = this.ast;
  55981. return ast ? this.stringify(ast) : '';
  55982. },
  55983. validFormatsRe: /^(ast|filters|query)$/,
  55984. applyFormat: function(format) {
  55985. if (!this.validFormatsRe.test(format)) {
  55986. Ext.raise('Invalid query format');
  55987. }
  55988. return format;
  55989. },
  55990. applyFunctions: function(funcs) {
  55991. var ret = {},
  55992. vargsRe = this.vargsRe,
  55993. def, key, name;
  55994. for (key in funcs) {
  55995. def = {
  55996. fn: funcs[name = key],
  55997. vargs: vargsRe.test(key)
  55998. };
  55999. if (def.vargs) {
  56000. name = key.substr(0, key.length - 3);
  56001. }
  56002. ret[name.toLowerCase()] = def;
  56003. }
  56004. return ret;
  56005. },
  56006. applySource: function(source) {
  56007. if (source) {
  56008. return source;
  56009. }
  56010. ++this.generation;
  56011. this.ast = null;
  56012. this.compile();
  56013. },
  56014. updateSource: function(source) {
  56015. var me = this,
  56016. parser = Ext.data.query.Parser.fly(source);
  56017. ++me.generation;
  56018. try {
  56019. me.error = me.fn = null;
  56020. me.ast = parser.parse();
  56021. } catch (e) {
  56022. me.error = e;
  56023. e.message = 'Failed to parse: ' + e.message;
  56024. throw e;
  56025. } finally {
  56026. parser.release();
  56027. }
  56028. me.compile();
  56029. },
  56030. privates: {
  56031. operatorTypeMap: {
  56032. and: [
  56033. 'binary',
  56034. '&&',
  56035. 'and'
  56036. ],
  56037. or: [
  56038. 'binary',
  56039. '||',
  56040. 'or'
  56041. ],
  56042. eq: [
  56043. 'binary',
  56044. '==',
  56045. '='
  56046. ],
  56047. ge: [
  56048. 'binary',
  56049. '>=',
  56050. null
  56051. ],
  56052. gt: [
  56053. 'binary',
  56054. '>',
  56055. null
  56056. ],
  56057. le: [
  56058. 'binary',
  56059. '<=',
  56060. null
  56061. ],
  56062. lt: [
  56063. 'binary',
  56064. '<',
  56065. null
  56066. ],
  56067. ne: [
  56068. 'binary',
  56069. '!=',
  56070. null
  56071. ],
  56072. add: [
  56073. 'binary',
  56074. '+',
  56075. null
  56076. ],
  56077. div: [
  56078. 'binary',
  56079. '/',
  56080. null
  56081. ],
  56082. mul: [
  56083. 'binary',
  56084. '*',
  56085. null
  56086. ],
  56087. sub: [
  56088. 'binary',
  56089. '-',
  56090. null
  56091. ],
  56092. 'in': [
  56093. 'binary',
  56094. null,
  56095. 'in'
  56096. ],
  56097. like: [
  56098. 'binary',
  56099. null,
  56100. 'like'
  56101. ],
  56102. seq: [
  56103. 'binary',
  56104. '===',
  56105. '=='
  56106. ],
  56107. sne: [
  56108. 'binary',
  56109. '!==',
  56110. null
  56111. ],
  56112. neg: [
  56113. 'unary',
  56114. '-',
  56115. null
  56116. ],
  56117. not: [
  56118. 'unary',
  56119. '!',
  56120. null
  56121. ]
  56122. },
  56123. vargsRe: /\.\.\.$/,
  56124. getOperatorType: function(op) {
  56125. var map = this.operatorTypeMap,
  56126. key;
  56127. for (key in map) {
  56128. if (map[key][1] === op || map[key][2] === op) {
  56129. return key;
  56130. }
  56131. }
  56132. Ext.raise('Unrecognized filter operator: "' + op + '"');
  56133. return null;
  56134. }
  56135. }
  56136. });
  56137. Ext.define('Ext.data.Request', {
  56138. isDataRequest: true,
  56139. config: {
  56140. action: undefined,
  56141. params: undefined,
  56142. method: 'GET',
  56143. url: null,
  56144. operation: null,
  56145. proxy: null,
  56146. disableCaching: false,
  56147. headers: {},
  56148. callbackKey: null,
  56149. rawRequest: null,
  56150. jsonData: undefined,
  56151. xmlData: undefined,
  56152. withCredentials: false,
  56153. username: null,
  56154. password: null,
  56155. binary: false,
  56156. callback: null,
  56157. scope: null,
  56158. timeout: 30000,
  56159. records: null,
  56160. directFn: null,
  56161. args: null,
  56162. useDefaultXhrHeader: null,
  56163. responseType: null
  56164. },
  56165. constructor: function(config) {
  56166. this.initConfig(config);
  56167. },
  56168. getParam: function(key) {
  56169. var params = this.getParams(),
  56170. val;
  56171. if (params) {
  56172. return params[key];
  56173. }
  56174. return val;
  56175. },
  56176. setParam: function(key, value) {
  56177. var params = this.getParams() || {};
  56178. params[key] = value;
  56179. this.setParams(params);
  56180. }
  56181. });
  56182. Ext.define('Ext.data.TreeStore', {
  56183. extend: Ext.data.Store,
  56184. alias: 'store.tree',
  56185. isTreeStore: true,
  56186. config: {
  56187. root: null,
  56188. rootVisible: false,
  56189. defaultRootProperty: 'children',
  56190. parentIdProperty: null,
  56191. clearOnLoad: true,
  56192. clearRemovedOnLoad: true,
  56193. nodeParam: 'node',
  56194. defaultRootId: 'root',
  56195. defaultRootText: 'Root',
  56196. folderSort: false,
  56197. pageSize: null
  56198. },
  56199. filterer: 'topdown',
  56200. lazyFill: false,
  56201. fillCount: 0,
  56202. bulkUpdate: 0,
  56203. nodesToUnregister: 0,
  56204. _silentOptions: {
  56205. silent: true
  56206. },
  56207. implicitModel: 'Ext.data.TreeModel',
  56208. groupField: null,
  56209. groupDir: null,
  56210. grouper: null,
  56211. constructor: function(config) {
  56212. var me = this;
  56213. me.byIdMap = {};
  56214. me.callParent([
  56215. config
  56216. ]);
  56217. if (Ext.isDefined(me.nodeParameter)) {
  56218. if (Ext.isDefined(Ext.global.console)) {
  56219. Ext.global.console.warn('Ext.data.TreeStore: nodeParameter has been deprecated. ' + 'Please use nodeParam instead.');
  56220. }
  56221. me.nodeParam = me.nodeParameter;
  56222. delete me.nodeParameter;
  56223. }
  56224. },
  56225. applyFields: function(fields, oldFields) {
  56226. var me = this;
  56227. if (fields) {
  56228. if (me.defaultRootProperty !== me.self.prototype.config.defaultRootProperty) {
  56229. fields = fields.concat({
  56230. name: me.defaultRootProperty,
  56231. type: 'auto',
  56232. defaultValue: null,
  56233. persist: false
  56234. });
  56235. }
  56236. }
  56237. me.callParent([
  56238. fields,
  56239. oldFields
  56240. ]);
  56241. },
  56242. applyGroupField: function(field) {
  56243. return null;
  56244. },
  56245. applyGroupDir: function(dir) {
  56246. return null;
  56247. },
  56248. applyGrouper: function(grouper) {
  56249. if (grouper) {
  56250. Ext.raise('You can\'t group a TreeStore');
  56251. }
  56252. return null;
  56253. },
  56254. group: Ext.emptyFn,
  56255. onSorterEndUpdate: function() {
  56256. var me = this,
  56257. sorterCollection = me.getSorters(),
  56258. sorters = sorterCollection.getRange(),
  56259. rootNode = me.getRoot(),
  56260. folderSort = me.getFolderSort();
  56261. me.fireEvent('beforesort', me, sorters);
  56262. if (rootNode && (folderSort || sorters.length)) {
  56263. if (me.getRemoteSort()) {
  56264. if (sorters.length) {
  56265. me.load({
  56266. callback: function() {
  56267. me.fireEvent('sort', me, sorters);
  56268. }
  56269. });
  56270. }
  56271. } else {
  56272. rootNode.sort(this.getSortFn(), true);
  56273. me.fireEvent('datachanged', me);
  56274. me.fireEvent('refresh', me);
  56275. me.fireEvent('sort', me, sorters);
  56276. }
  56277. } else
  56278. {
  56279. me.fireEvent('sort', me, sorters);
  56280. }
  56281. },
  56282. updateFolderSort: function(folderSort) {
  56283. this.needsFolderSort = folderSort;
  56284. this.onSorterEndUpdate();
  56285. },
  56286. getSortFn: function() {
  56287. return this._sortFn || (this._sortFn = this.createSortFn());
  56288. },
  56289. createSortFn: function() {
  56290. var me = this,
  56291. sortersSortFn = this.sorters.getSortFn();
  56292. return function(node1, node2) {
  56293. var node1FolderOrder, node2FolderOrder,
  56294. result = 0;
  56295. if (me.needsFolderSort) {
  56296. node1FolderOrder = node1.data.leaf ? 1 : 0;
  56297. node2FolderOrder = node2.data.leaf ? 1 : 0;
  56298. result = node1FolderOrder - node2FolderOrder;
  56299. }
  56300. if (me.needsIndexSort && result === 0) {
  56301. result = node1.data.index - node2.data.index;
  56302. }
  56303. return result || sortersSortFn(node1, node2);
  56304. };
  56305. },
  56306. getTotalCount: function() {
  56307. return this.getCount();
  56308. },
  56309. afterEdit: function(node, modifiedFieldNames) {
  56310. var me = this,
  56311. parentNode = node.parentNode,
  56312. rootVisible = me.getRootVisible(),
  56313. isHiddenRoot = !parentNode && !rootVisible,
  56314. prevVisibleNodeIndex,
  56315. isVisible = node.get('visible'),
  56316. toAdd, removeStart;
  56317. if (!isHiddenRoot && isVisible !== me.contains(node)) {
  56318. if (isVisible) {
  56319. if (!parentNode || me.isVisible(node)) {
  56320. toAdd = [
  56321. node
  56322. ];
  56323. if (node.isExpanded()) {
  56324. me.handleNodeExpand(node, node.childNodes, toAdd);
  56325. }
  56326. prevVisibleNodeIndex = node.previousSibling ? me.indexOfPreviousVisibleNode(node.previousSibling) : (parentNode ? me.indexOf(parentNode) : -1);
  56327. me.insert(prevVisibleNodeIndex + 1, toAdd);
  56328. }
  56329. } else
  56330. {
  56331. removeStart = me.indexOf(node);
  56332. me.removeAt(removeStart, me.indexOfNextVisibleNode(node) - removeStart);
  56333. }
  56334. }
  56335. else if (me.getRoot() && me.needsLocalFilter()) {
  56336. me.onFilterEndUpdate(me.getFilters());
  56337. }
  56338. me.callParent([
  56339. node,
  56340. modifiedFieldNames
  56341. ]);
  56342. },
  56343. afterReject: function(record) {
  56344. var me = this;
  56345. if (me.contains(record)) {
  56346. me.onUpdate(record, Ext.data.Model.REJECT, null);
  56347. me.fireEvent('update', me, record, Ext.data.Model.REJECT, null);
  56348. }
  56349. },
  56350. afterCommit: function(record, modifiedFieldNames) {
  56351. var me = this;
  56352. if (!modifiedFieldNames) {
  56353. modifiedFieldNames = null;
  56354. }
  56355. if (me.contains(record)) {
  56356. me.onUpdate(record, Ext.data.Model.COMMIT, modifiedFieldNames);
  56357. me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
  56358. }
  56359. },
  56360. updateRootVisible: function(rootVisible) {
  56361. var rootNode = this.getRoot(),
  56362. data;
  56363. if (rootNode) {
  56364. data = this.getData();
  56365. if (rootVisible) {
  56366. data.insert(0, rootNode);
  56367. } else {
  56368. data.remove(rootNode);
  56369. }
  56370. }
  56371. },
  56372. updateTrackRemoved: function(trackRemoved) {
  56373. this.callParent(arguments);
  56374. this.removedNodes = this.removed;
  56375. this.removed = null;
  56376. },
  56377. onDestroyRecords: function(records, operation, success) {
  56378. if (success) {
  56379. this.removedNodes.length = 0;
  56380. }
  56381. },
  56382. updateProxy: function(proxy) {
  56383. var reader;
  56384. if (proxy) {
  56385. if (proxy.setIdParam) {
  56386. proxy.setIdParam(this.getNodeParam());
  56387. }
  56388. reader = proxy.getReader();
  56389. if (Ext.isEmpty(reader.getRootProperty())) {
  56390. reader.setRootProperty(this.getDefaultRootProperty());
  56391. }
  56392. }
  56393. },
  56394. setProxy: function(proxy) {
  56395. this.changingProxy = true;
  56396. this.callParent([
  56397. proxy
  56398. ]);
  56399. this.changingProxy = false;
  56400. },
  56401. updateModel: function(model) {
  56402. var isNode;
  56403. if (model) {
  56404. isNode = model.prototype.isNode;
  56405. Ext.data.NodeInterface.decorate(model);
  56406. if (!isNode && !this.changingProxy) {
  56407. this.getProxy().getReader().buildExtractors(true);
  56408. }
  56409. }
  56410. },
  56411. onCollectionFilter: Ext.emptyFn,
  56412. onFilterEndUpdate: function(filters) {
  56413. var me = this,
  56414. length = filters.length,
  56415. root = me.getRoot(),
  56416. childNodes, childNode, filteredNodes, i;
  56417. if (!me.getRemoteFilter()) {
  56418. if (length) {
  56419. me.doFilter(root);
  56420. } else {
  56421. root.cascade({
  56422. after: function(node) {
  56423. node.set('visible', true, me._silentOptions);
  56424. }
  56425. });
  56426. }
  56427. if (length) {
  56428. filteredNodes = [];
  56429. childNodes = root.childNodes;
  56430. for (i = 0 , length = childNodes.length; i < length; i++) {
  56431. childNode = childNodes[i];
  56432. if (childNode.get('visible')) {
  56433. filteredNodes.push(childNode);
  56434. }
  56435. }
  56436. } else {
  56437. filteredNodes = root.childNodes;
  56438. }
  56439. me.onNodeFilter(root, filteredNodes);
  56440. root.fireEvent('filterchange', root, filteredNodes);
  56441. me.suppressNextFilter = true;
  56442. me.callParent([
  56443. filters
  56444. ]);
  56445. me.suppressNextFilter = false;
  56446. } else {
  56447. me.callParent([
  56448. filters
  56449. ]);
  56450. }
  56451. },
  56452. onNodeFilter: function(root, childNodes) {
  56453. var me = this,
  56454. data = me.getData(),
  56455. toAdd = [];
  56456. if (me.getRootVisible() && root.get('visible')) {
  56457. toAdd.push(root);
  56458. }
  56459. me.handleNodeExpand(root, childNodes, toAdd);
  56460. me.suspendEvents();
  56461. data.splice(0, data.getCount(), toAdd);
  56462. me.resumeEvents();
  56463. if (!me.suppressNextFilter) {
  56464. me.fireEvent('datachanged', me);
  56465. me.fireEvent('refresh', me);
  56466. }
  56467. },
  56468. onBeforeNodeExpand: function(node, callback, scope, args) {
  56469. var me = this,
  56470. storeReader, nodeProxy, nodeReader, reader, children, callbackArgs;
  56471. if (node.isLoaded()) {
  56472. callbackArgs = [
  56473. node.childNodes
  56474. ];
  56475. if (args) {
  56476. callbackArgs.push.apply(callbackArgs, args);
  56477. }
  56478. Ext.callback(callback, scope || node, callbackArgs);
  56479. }
  56480. else if (node.isLoading()) {
  56481. me.on('load', function() {
  56482. callbackArgs = [
  56483. node.childNodes
  56484. ];
  56485. if (args) {
  56486. callbackArgs.push.apply(callbackArgs, args);
  56487. }
  56488. Ext.callback(callback, scope || node, callbackArgs);
  56489. }, me, {
  56490. single: true,
  56491. priority: 1001
  56492. });
  56493. } else
  56494. {
  56495. storeReader = me.getProxy().getReader();
  56496. nodeProxy = node.getProxy();
  56497. nodeReader = nodeProxy ? nodeProxy.getReader() : null;
  56498. reader = nodeReader && nodeReader.initialConfig.rootProperty ? nodeReader : storeReader;
  56499. children = reader.getRoot(node.raw || node.data);
  56500. if (children || (node.phantom && !node.isRoot())) {
  56501. me.fillNode(node, reader.extractData(children || [], {
  56502. model: node.childType,
  56503. recordCreator: me.recordCreator
  56504. }));
  56505. callbackArgs = [
  56506. node.childNodes
  56507. ];
  56508. if (args) {
  56509. callbackArgs.push.apply(callbackArgs, args);
  56510. }
  56511. Ext.callback(callback, scope || node, callbackArgs);
  56512. } else
  56513. {
  56514. me.read({
  56515. node: node,
  56516. onChildNodesAvailable: function() {
  56517. delete me.lastOptions.onChildNodesAvailable;
  56518. callbackArgs = [
  56519. node.childNodes
  56520. ];
  56521. if (args) {
  56522. callbackArgs.push.apply(callbackArgs, args);
  56523. }
  56524. Ext.callback(callback, scope || node, callbackArgs);
  56525. }
  56526. });
  56527. me.flushLoad();
  56528. }
  56529. }
  56530. },
  56531. onNodeExpand: function(parent, records) {
  56532. var me = this,
  56533. insertIndex = me.indexOf(parent) + 1,
  56534. toAdd = [];
  56535. me.handleNodeExpand(parent, records, toAdd);
  56536. if (!me.refreshCounter && parent.isRoot() && !parent.get('visible')) {
  56537. me.loadRecords(toAdd);
  56538. } else
  56539. {
  56540. ++me.loadCount;
  56541. me.insert(insertIndex, toAdd);
  56542. }
  56543. },
  56544. handleNodeExpand: function(parent, records, toAdd) {
  56545. var me = this,
  56546. ln = records ? records.length : 0,
  56547. i, record;
  56548. if (parent !== this.getRoot() && !me.isVisible(parent)) {
  56549. return;
  56550. }
  56551. if (ln) {
  56552. for (i = 0; i < ln; i++) {
  56553. record = records[i];
  56554. if (record.get('visible')) {
  56555. toAdd.push(record);
  56556. if (record.isExpanded()) {
  56557. if (record.isLoaded()) {
  56558. me.handleNodeExpand(record, record.childNodes, toAdd);
  56559. } else {
  56560. record.set('expanded', false, {
  56561. silent: true
  56562. });
  56563. record.expand();
  56564. }
  56565. }
  56566. }
  56567. }
  56568. }
  56569. },
  56570. onNodeCollapse: function(parent, records, callback, scope) {
  56571. var me = this,
  56572. collapseIndex = me.indexOf(parent) + 1,
  56573. lastNodeIndexPlus;
  56574. if (me.needsLocalFilter()) {
  56575. records = Ext.Array.filter(records, me.filterVisible);
  56576. }
  56577. if (records.length && me.isVisible(parent)) {
  56578. lastNodeIndexPlus = me.indexOfNextVisibleNode(parent);
  56579. me.removeAt(collapseIndex, lastNodeIndexPlus - collapseIndex);
  56580. }
  56581. Ext.callback(callback, scope);
  56582. },
  56583. indexOfNextVisibleNode: function(node) {
  56584. var result;
  56585. while (node.parentNode) {
  56586. for (result = node.nextSibling; result && !result.get('visible'); result = result.nextSibling) {}
  56587. if (result) {
  56588. return this.indexOf(result);
  56589. }
  56590. node = node.parentNode;
  56591. }
  56592. return this.getCount();
  56593. },
  56594. indexOfPreviousVisibleNode: function(node) {
  56595. var result;
  56596. for (result = node; result && !result.get('visible'); result = result.previousSibling) {}
  56597. if (result) {
  56598. if (result.isExpanded() && result.lastChild) {
  56599. return this.indexOfPreviousVisibleNode(result.lastChild);
  56600. }
  56601. } else
  56602. {
  56603. result = node.parentNode;
  56604. }
  56605. return this.indexOf(result);
  56606. },
  56607. filterNew: function(item) {
  56608. return !item.get('root') && this.callParent([
  56609. item
  56610. ]);
  56611. },
  56612. filterRejects: function(item) {
  56613. return !item.get('root') && this.callParent([
  56614. item
  56615. ]);
  56616. },
  56617. getNewRecords: function() {
  56618. return Ext.Array.filter(Ext.Object.getValues(this.byIdMap), this.filterNew, this);
  56619. },
  56620. getRejectRecords: function() {
  56621. return Ext.Array.filter(Ext.Object.getValues(this.byIdMap), this.filterRejects, this);
  56622. },
  56623. getUpdatedRecords: function() {
  56624. return Ext.Array.filter(Ext.Object.getValues(this.byIdMap), this.filterUpdated);
  56625. },
  56626. beforeNodeRemove: function(parentNode, childNodes, isMove, removeRange) {
  56627. if (!Ext.isArray(childNodes)) {
  56628. childNodes = [
  56629. childNodes
  56630. ];
  56631. }
  56632. var me = this,
  56633. len = childNodes.length,
  56634. removed = me.removedNodes,
  56635. startNode, i;
  56636. for (i = 0; !startNode && i < len; i++) {
  56637. if (childNodes[i].get('visible')) {
  56638. startNode = childNodes[i];
  56639. }
  56640. }
  56641. if (startNode) {
  56642. removeRange[0] = me.indexOf(childNodes[0]);
  56643. removeRange[1] = me.indexOfNextVisibleNode(childNodes[childNodes.length - 1]) - removeRange[0];
  56644. } else {
  56645. removeRange[0] = -1;
  56646. removeRange[1] = 0;
  56647. }
  56648. for (i = 0; i < len; i++) {
  56649. childNodes[i].cascade(function(node) {
  56650. me.unregisterNode(node, true);
  56651. if (removed && !isMove) {
  56652. if (!node.phantom && !node.erasing && !me.loading) {
  56653. node.removedFrom = me.indexOf(node);
  56654. removed.push(node);
  56655. me.needsSync = true;
  56656. }
  56657. }
  56658. });
  56659. }
  56660. },
  56661. afterDrop: Ext.emptyFn,
  56662. onNodeRemove: function(parentNode, childNodes, isMove, removeRange) {
  56663. var me = this;
  56664. me.suspendAutoSync();
  56665. if (removeRange[0] !== -1) {
  56666. me.removeIsMove = isMove;
  56667. me.removeAt.apply(me, removeRange);
  56668. me.removeIsMove = false;
  56669. }
  56670. me.resumeAutoSync();
  56671. },
  56672. onNodeAppend: function(parent, node, index) {
  56673. this.onNodeInsert(parent, node, index);
  56674. },
  56675. onNodeInsert: function(parent, node, index) {
  56676. var me = this,
  56677. data = node.raw || node.data,
  56678. removed = me.removedNodes,
  56679. storeReader, nodeProxy, nodeReader, reader, dataRoot, storeInsertionPoint;
  56680. if (parent && me.needsLocalFilter()) {
  56681. me.doFilter(parent);
  56682. }
  56683. me.beginUpdate();
  56684. if (me.isVisible(node)) {
  56685. if (index === 0 || !node.previousSibling) {
  56686. storeInsertionPoint = me.indexOf(parent);
  56687. } else
  56688. {
  56689. storeInsertionPoint = me.indexOfPreviousVisibleNode(node.previousSibling);
  56690. }
  56691. me.insert(storeInsertionPoint + 1, node);
  56692. if (!node.isLeaf() && node.isExpanded()) {
  56693. if (node.isLoaded()) {
  56694. me.onNodeExpand(node, node.childNodes);
  56695. } else if (!me.fillCount) {
  56696. node.set('expanded', false);
  56697. node.expand();
  56698. }
  56699. }
  56700. }
  56701. Ext.Array.remove(removed, node);
  56702. me.needsSync = me.needsSync || node.phantom || node.dirty;
  56703. if (!node.isLeaf() && !node.isLoaded() && !me.lazyFill) {
  56704. storeReader = me.getProxy().getReader();
  56705. nodeProxy = node.getProxy();
  56706. nodeReader = nodeProxy ? nodeProxy.getReader() : null;
  56707. reader = nodeReader && nodeReader.initialConfig.rootProperty ? nodeReader : storeReader;
  56708. dataRoot = reader.getRoot(data);
  56709. if (dataRoot) {
  56710. me.fillNode(node, reader.extractData(dataRoot, {
  56711. model: node.childType,
  56712. recordCreator: me.recordCreator
  56713. }));
  56714. }
  56715. }
  56716. me.endUpdate();
  56717. },
  56718. registerNode: function(node, includeChildren) {
  56719. var me = this,
  56720. was = me.byIdMap[node.id],
  56721. children, length, i;
  56722. me.byIdMap[node.id] = node;
  56723. if (node.onRegisterTreeNode && node !== was) {
  56724. node.onRegisterTreeNode(me);
  56725. }
  56726. if (node.onUnregisterTreeNode) {
  56727. me.nodesToUnregister++;
  56728. }
  56729. if (includeChildren === true) {
  56730. children = node.childNodes;
  56731. length = children.length;
  56732. for (i = 0; i < length; i++) {
  56733. me.registerNode(children[i], true);
  56734. }
  56735. }
  56736. },
  56737. unregisterNode: function(node, includeChildren) {
  56738. var me = this,
  56739. was = me.byIdMap[node.id],
  56740. children, length, i;
  56741. delete me.byIdMap[node.id];
  56742. if (includeChildren === true) {
  56743. children = node.childNodes;
  56744. length = children.length;
  56745. for (i = 0; i < length; i++) {
  56746. me.unregisterNode(children[i], true);
  56747. }
  56748. }
  56749. if (node.onUnregisterTreeNode && node === was) {
  56750. node.onUnregisterTreeNode(me);
  56751. me.nodesToUnregister--;
  56752. }
  56753. },
  56754. onNodeSort: function(node, childNodes) {
  56755. var me = this;
  56756. me.suspendAutoSync();
  56757. if ((me.indexOf(node) !== -1 && node.isExpanded()) || (node === me.getRoot() && !me.getRootVisible())) {
  56758. Ext.suspendLayouts();
  56759. me.onNodeCollapse(node, childNodes);
  56760. me.onNodeExpand(node, childNodes);
  56761. Ext.resumeLayouts(true);
  56762. }
  56763. me.resumeAutoSync(me.autoSync);
  56764. },
  56765. applyRoot: function(newRoot) {
  56766. var me = this,
  56767. Model = me.getModel(),
  56768. idProperty = Model.prototype.idProperty,
  56769. defaultRootId = me.getDefaultRootId();
  56770. if (newRoot && !newRoot.isNode) {
  56771. newRoot = Ext.apply({
  56772. text: me.getDefaultRootText(),
  56773. root: true,
  56774. isFirst: true,
  56775. isLast: true,
  56776. depth: 0,
  56777. index: 0,
  56778. parentId: null,
  56779. allowDrag: false
  56780. }, newRoot);
  56781. if (defaultRootId && newRoot[idProperty] === undefined) {
  56782. newRoot[idProperty] = defaultRootId;
  56783. }
  56784. newRoot = new Model(newRoot);
  56785. }
  56786. return newRoot;
  56787. },
  56788. updateRoot: function(newRoot, oldRoot) {
  56789. var me = this,
  56790. removeRange = [],
  56791. initial = me.isConfiguring,
  56792. oldOwner, toRemove;
  56793. me.getTrackRemoved();
  56794. me.suspendEvent('add', 'remove');
  56795. if (initial) {
  56796. me.suspendEvent('refresh', 'datachanged');
  56797. }
  56798. if (oldRoot && oldRoot.isModel) {
  56799. if (me.getRootVisible()) {
  56800. toRemove = [
  56801. oldRoot
  56802. ];
  56803. } else {
  56804. toRemove = oldRoot.childNodes;
  56805. }
  56806. me.beforeNodeRemove(null, toRemove, false, removeRange);
  56807. oldRoot.set('root', false);
  56808. me.onNodeRemove(null, toRemove, false, removeRange);
  56809. oldRoot.fireEvent('remove', null, oldRoot, false);
  56810. oldRoot.fireEvent('rootchange', null);
  56811. oldRoot.clearListeners();
  56812. oldRoot.store = oldRoot.treeStore = null;
  56813. me.unregisterNode(oldRoot);
  56814. }
  56815. me.getData().clear();
  56816. if (newRoot) {
  56817. if (newRoot.fireEventArgs('beforeappend', [
  56818. null,
  56819. newRoot
  56820. ]) === false) {
  56821. newRoot = null;
  56822. } else {
  56823. oldOwner = newRoot.parentNode;
  56824. if (oldOwner) {
  56825. if (!oldOwner.removeChild(newRoot, false, false, oldOwner.getTreeStore() === me)) {
  56826. return;
  56827. }
  56828. }
  56829. else if ((oldOwner = newRoot.getTreeStore()) && oldOwner !== me && newRoot === oldOwner.getRoot()) {
  56830. oldOwner.setRoot(null);
  56831. }
  56832. newRoot.store = newRoot.treeStore = me;
  56833. newRoot.set('root', true);
  56834. newRoot.updateInfo(true, {
  56835. isFirst: true,
  56836. isLast: true,
  56837. depth: 0,
  56838. index: 0,
  56839. parentId: null
  56840. });
  56841. me.registerNode(newRoot, true);
  56842. newRoot.fireEvent('append', null, newRoot, false);
  56843. newRoot.fireEvent('rootchange', newRoot);
  56844. me.onNodeAppend(null, newRoot, 0);
  56845. newRoot.phantom = true;
  56846. }
  56847. }
  56848. if (!initial) {
  56849. me.fireEvent('rootchange', newRoot, oldRoot);
  56850. }
  56851. if (newRoot && (me.getAutoLoad() || newRoot.isExpanded())) {
  56852. if (newRoot.isLoaded()) {
  56853. me.onNodeExpand(newRoot, newRoot.childNodes);
  56854. if (!initial) {
  56855. me.fireEvent('datachanged', me);
  56856. me.fireEvent('refresh', me);
  56857. }
  56858. } else
  56859. {
  56860. newRoot.data.expanded = false;
  56861. newRoot.expand(false);
  56862. if (newRoot.isLoaded && !me.getProxy().isSynchronous && !initial) {
  56863. me.fireEvent('datachanged', me);
  56864. me.fireEvent('refresh', me);
  56865. }
  56866. }
  56867. } else if (!initial) {
  56868. me.fireEvent('datachanged', me);
  56869. me.fireEvent('refresh', me);
  56870. }
  56871. me.resumeEvent('add', 'remove');
  56872. if (initial) {
  56873. me.resumeEvent('refresh', 'datachanged');
  56874. }
  56875. },
  56876. doDestroy: function() {
  56877. var me = this,
  56878. root = me.getRoot();
  56879. if (root && me.nodesToUnregister) {
  56880. root.cascade(function(node) {
  56881. if (node.onUnregisterTreeNode) {
  56882. node.onUnregisterTreeNode(me);
  56883. }
  56884. });
  56885. }
  56886. me.callParent();
  56887. },
  56888. each: function(fn, scope, includeOptions) {
  56889. var i = 0,
  56890. filtered = includeOptions,
  56891. includeCollapsed;
  56892. if (includeOptions && typeof includeOptions === 'object') {
  56893. includeCollapsed = includeOptions.collapsed;
  56894. filtered = includeOptions.filtered;
  56895. }
  56896. if (includeCollapsed) {
  56897. this.getRoot().cascade(function(node) {
  56898. if (filtered === true || node.get('visible')) {
  56899. return fn.call(scope || node, node, i++);
  56900. }
  56901. });
  56902. } else {
  56903. return this.callParent([
  56904. fn,
  56905. scope,
  56906. filtered
  56907. ]);
  56908. }
  56909. },
  56910. collect: function(dataIndex, options, filtered) {
  56911. var includeCollapsed,
  56912. map = {},
  56913. result = [],
  56914. allowNull = options,
  56915. strValue, value;
  56916. if (options && typeof options === 'object') {
  56917. includeCollapsed = options.collapsed;
  56918. filtered = options.filtered;
  56919. allowNull = options.allowNull;
  56920. }
  56921. if (includeCollapsed || filtered) {
  56922. this.getRoot().cascade(function(node) {
  56923. if (filtered === true || node.get('visible')) {
  56924. value = node.get(dataIndex);
  56925. strValue = String(value);
  56926. if ((allowNull || !Ext.isEmpty(value)) && !map[strValue]) {
  56927. map[strValue] = 1;
  56928. result.push(value);
  56929. }
  56930. }
  56931. if (!includeCollapsed && !node.isExpanded()) {
  56932. return false;
  56933. }
  56934. });
  56935. } else {
  56936. result = this.callParent([
  56937. dataIndex,
  56938. allowNull,
  56939. filtered
  56940. ]);
  56941. }
  56942. return result;
  56943. },
  56944. getNodeById: function(id) {
  56945. return this.byIdMap[id] || null;
  56946. },
  56947. findNode: function(fieldName, value, startsWith, endsWith, ignoreCase) {
  56948. var result = null,
  56949. regex;
  56950. if (Ext.isEmpty(value, false)) {
  56951. return result;
  56952. }
  56953. if (fieldName === this.model.idProperty && arguments.length < 3) {
  56954. return this.byIdMap[value];
  56955. }
  56956. regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase);
  56957. Ext.Object.eachValue(this.byIdMap, function(node) {
  56958. if (node && regex.test(node.get(fieldName))) {
  56959. result = node;
  56960. return false;
  56961. }
  56962. });
  56963. return result;
  56964. },
  56965. load: function(options) {
  56966. var node = options && options.node;
  56967. if (!node && !(node = this.getRoot())) {
  56968. node = this.setRoot({
  56969. expanded: true,
  56970. autoRoot: true
  56971. });
  56972. return;
  56973. }
  56974. if (node.isLoading()) {
  56975. return;
  56976. }
  56977. return this.callParent([
  56978. options
  56979. ]);
  56980. },
  56981. reload: function(options) {
  56982. var o = Ext.apply({}, options, this.lastOptions);
  56983. o.node = this.getRoot();
  56984. return this.load(o);
  56985. },
  56986. flushLoad: function() {
  56987. var me = this,
  56988. options = me.pendingLoadOptions,
  56989. clearOnLoad = me.getClearOnLoad(),
  56990. node, callback, scope, isRootLoad, operation, doClear;
  56991. me.clearLoadTask();
  56992. if (!options) {
  56993. return;
  56994. }
  56995. node = options.node || me.getRoot();
  56996. isRootLoad = node && node.isRoot();
  56997. callback = options.callback;
  56998. scope = options.scope;
  56999. options.params = options.params || {};
  57000. if (node.data.expanded && !isRootLoad) {
  57001. node.data.loaded = false;
  57002. if (clearOnLoad) {
  57003. node.data.expanded = false;
  57004. }
  57005. options.callback = function(loadedNodes, operation, success) {
  57006. if (!clearOnLoad) {
  57007. node.collapse();
  57008. }
  57009. node.expand();
  57010. Ext.callback(callback, scope, [
  57011. loadedNodes,
  57012. operation,
  57013. success
  57014. ]);
  57015. };
  57016. }
  57017. options.id = node.getId();
  57018. me.setLoadOptions(options);
  57019. if (me.getRemoteSort() && options.sorters) {
  57020. me.fireEvent('beforesort', me, options.sorters);
  57021. }
  57022. options = Ext.apply({
  57023. node: options.node || node,
  57024. internalScope: me,
  57025. internalCallback: me.onProxyLoad
  57026. }, options);
  57027. me.lastOptions = Ext.apply({}, options);
  57028. options.isRootLoad = isRootLoad;
  57029. operation = me.createOperation('read', options);
  57030. if (me.fireEvent('beforeload', me, operation) !== false) {
  57031. me.loading = true;
  57032. if (isRootLoad) {
  57033. if (me.getClearRemovedOnLoad()) {
  57034. me.removedNodes.length = 0;
  57035. }
  57036. if (clearOnLoad) {
  57037. me.unregisterNode(node, true);
  57038. node.clear(false, true);
  57039. me.registerNode(node);
  57040. doClear = true;
  57041. }
  57042. } else
  57043. {
  57044. if (me.loading) {
  57045. node.data.loaded = false;
  57046. }
  57047. if (me.getTrackRemoved() && me.getClearRemovedOnLoad()) {
  57048. me.clearRemoved(node);
  57049. }
  57050. if (clearOnLoad) {
  57051. node.removeAll(false);
  57052. }
  57053. }
  57054. if (me.loading && node) {
  57055. node.set('loading', true, {
  57056. silent: !(me.contains(node) || node === me.getRoot())
  57057. });
  57058. }
  57059. if (doClear) {
  57060. me.clearData(true);
  57061. if (me.getRootVisible()) {
  57062. me.suspendEvents();
  57063. me.add(node);
  57064. me.resumeEvents();
  57065. }
  57066. }
  57067. operation.execute();
  57068. }
  57069. return me;
  57070. },
  57071. onProxyLoad: function(operation) {
  57072. var me = this,
  57073. options = operation.initialConfig,
  57074. successful = operation.wasSuccessful(),
  57075. records = operation.getRecords(),
  57076. node = options.node,
  57077. isRootLoad = options.isRootLoad,
  57078. scope = operation.getScope() || me,
  57079. args = [
  57080. records,
  57081. operation,
  57082. successful
  57083. ];
  57084. if (me.destroyed) {
  57085. return;
  57086. }
  57087. me.loading = false;
  57088. node.set('loading', false);
  57089. if (successful) {
  57090. ++me.loadCount;
  57091. if (!me.getClearOnLoad()) {
  57092. records = me.cleanRecords(node, records);
  57093. }
  57094. if (me.getParentIdProperty()) {
  57095. records = me.treeify(node, records);
  57096. }
  57097. if (isRootLoad) {
  57098. me.suspendEvent('add', 'update');
  57099. }
  57100. records = me.fillNode(node, records);
  57101. }
  57102. Ext.callback(options.onChildNodesAvailable, scope, args);
  57103. if (isRootLoad) {
  57104. me.resumeEvent('add', 'update');
  57105. me.callObservers('BeforePopulate');
  57106. me.fireEvent('datachanged', me);
  57107. me.fireEvent('refresh', me);
  57108. me.callObservers('AfterPopulate');
  57109. }
  57110. me.fireEvent('load', me, records, successful, operation, node);
  57111. },
  57112. clearRemoved: function(node) {
  57113. var me = this,
  57114. removed = me.removedNodes,
  57115. id = node.getId(),
  57116. removedLength = removed.length,
  57117. i = removedLength,
  57118. recordsToClear = {},
  57119. newRemoved = [],
  57120. removedHash = {},
  57121. removedNode, targetNode, targetId;
  57122. if (node === me.getRoot()) {
  57123. me.removedNodes.length = 0;
  57124. return;
  57125. }
  57126. for (; i--; ) {
  57127. removedNode = removed[i];
  57128. removedHash[removedNode.getId()] = removedNode;
  57129. }
  57130. for (i = removedLength; i--; ) {
  57131. removedNode = removed[i];
  57132. targetNode = removedNode;
  57133. while (targetNode && targetNode.getId() !== id) {
  57134. targetId = targetNode.get('parentId') || targetNode.get('lastParentId');
  57135. targetNode = targetNode.parentNode || me.getNodeById(targetId) || removedHash[targetId];
  57136. }
  57137. if (targetNode) {
  57138. recordsToClear[removedNode.getId()] = removedNode;
  57139. }
  57140. }
  57141. for (i = 0; i < removedLength; i++) {
  57142. removedNode = removed[i];
  57143. if (!recordsToClear[removedNode.getId()]) {
  57144. newRemoved.push(removedNode);
  57145. }
  57146. }
  57147. me.removedNodes = newRemoved;
  57148. },
  57149. fillNode: function(node, newNodes) {
  57150. var me = this,
  57151. newNodeCount = newNodes ? newNodes.length : 0;
  57152. if (++me.bulkUpdate === 1) {
  57153. me.suspendEvent('datachanged');
  57154. }
  57155. if (newNodeCount) {
  57156. me.setupNodes(newNodes);
  57157. node.appendChild(newNodes, undefined, true);
  57158. } else
  57159. {
  57160. if (me.bulkUpdate === 1) {
  57161. node.set('loaded', true);
  57162. } else {
  57163. node.data.loaded = true;
  57164. }
  57165. }
  57166. if (!--me.bulkUpdate) {
  57167. me.resumeEvent('datachanged');
  57168. }
  57169. return newNodes;
  57170. },
  57171. setupNodes: function(newNodes) {
  57172. var me = this,
  57173. sorters = me.getSorters(),
  57174. needsIndexSort = false,
  57175. newNodeCount = newNodes.length,
  57176. performLocalSort = me.sortOnLoad && newNodeCount > 1 && !me.getRemoteSort() && me.getFolderSort() || sorters.length,
  57177. performLocalFilter = me.needsLocalFilter(),
  57178. node1, node2, i;
  57179. if (performLocalFilter) {
  57180. me.doFilter(newNodes[0]);
  57181. }
  57182. for (i = 1; i < newNodeCount; i++) {
  57183. node1 = newNodes[i];
  57184. node2 = newNodes[i - 1];
  57185. if (performLocalFilter) {
  57186. me.doFilter(node1);
  57187. }
  57188. needsIndexSort = node1.data.index !== node2.data.index;
  57189. }
  57190. if (performLocalSort) {
  57191. me.needsIndexSort = true;
  57192. Ext.Array.sort(newNodes, me.getSortFn());
  57193. me.needsIndexSort = false;
  57194. } else if (needsIndexSort) {
  57195. Ext.Array.sort(newNodes, me.sortByIndex);
  57196. }
  57197. },
  57198. beginFill: function() {
  57199. var me = this;
  57200. if (!me.fillCount++) {
  57201. me.beginUpdate();
  57202. me.suspendEvent('add', 'update');
  57203. me.suspendAutoSync();
  57204. me.fillArray = [];
  57205. }
  57206. },
  57207. endFill: function(parent, nodes) {
  57208. var me = this,
  57209. fillArray = me.fillArray,
  57210. i, len, index;
  57211. fillArray.push(nodes);
  57212. if (!--me.fillCount) {
  57213. me.resumeAutoSync();
  57214. me.resumeEvent('add', 'update');
  57215. for (i = 0 , len = fillArray.length; i < len; i++) {
  57216. index = me.indexOf(fillArray[i][0]);
  57217. if (index !== -1) {
  57218. me.fireEvent('add', me, fillArray[i], index);
  57219. }
  57220. }
  57221. me.fillArray = null;
  57222. me.endUpdate();
  57223. }
  57224. },
  57225. sortByIndex: function(node1, node2) {
  57226. return node1.data.index - node2.data.index;
  57227. },
  57228. onIdChanged: function(node, oldId, newId) {
  57229. var childNodes = node.childNodes,
  57230. len = childNodes && childNodes.length,
  57231. i;
  57232. this.callParent(arguments);
  57233. delete this.byIdMap[oldId];
  57234. this.byIdMap[newId] = node;
  57235. for (i = 0; i < len; i++) {
  57236. childNodes[i].set('parentId', newId);
  57237. }
  57238. },
  57239. treeify: function(parentNode, records) {
  57240. var me = this,
  57241. loadParentNodeId = parentNode.getId(),
  57242. parentIdProperty = me.getParentIdProperty(),
  57243. len = records.length,
  57244. result = [],
  57245. nodeMap = {},
  57246. i, node, parentId, parent, id, children;
  57247. for (i = 0; i < len; i++) {
  57248. node = records[i];
  57249. node.data.depth = 1;
  57250. nodeMap[node.id] = node;
  57251. }
  57252. for (i = 0; i < len; i++) {
  57253. node = records[i];
  57254. parentId = node.data[parentIdProperty];
  57255. if (!(parentId || parentId === 0) || parentId === loadParentNodeId) {
  57256. result.push(node);
  57257. } else {
  57258. if (!nodeMap[parentId]) {
  57259. Ext.raise('Ext.data.TreeStore, Invalid parentId "' + parentId + '"');
  57260. }
  57261. parent = nodeMap[parentId];
  57262. parent.$children = parent.$children || [];
  57263. parent.$children.push(node);
  57264. node.data.depth = parent.data.depth + 1;
  57265. }
  57266. }
  57267. for (id in nodeMap) {
  57268. node = nodeMap[id];
  57269. children = node.$children;
  57270. if (children) {
  57271. delete node.$children;
  57272. me.setupNodes(children);
  57273. node.appendChild(children);
  57274. }
  57275. me.registerNode(node);
  57276. }
  57277. me.setupNodes(result);
  57278. return result;
  57279. },
  57280. cleanRecords: function(node, records) {
  57281. var nodeHash = {},
  57282. childNodes = node.childNodes,
  57283. i = 0,
  57284. len = childNodes.length,
  57285. out = [],
  57286. rec;
  57287. for (; i < len; ++i) {
  57288. nodeHash[childNodes[i].getId()] = true;
  57289. }
  57290. for (i = 0 , len = records.length; i < len; ++i) {
  57291. rec = records[i];
  57292. if (!nodeHash[rec.getId()]) {
  57293. out.push(rec);
  57294. }
  57295. }
  57296. return out;
  57297. },
  57298. removeAll: function() {
  57299. var me = this,
  57300. root = me.getRoot(),
  57301. ln = me.getData().length;
  57302. me.suspendEvents();
  57303. me.setRoot(null);
  57304. me.resumeEvents();
  57305. me.callParent();
  57306. if (ln) {
  57307. me.fireEvent('clear', me);
  57308. me.fireEvent('rootchange', root, null);
  57309. }
  57310. },
  57311. doSort: function(sorterFn) {
  57312. var me = this;
  57313. if (me.getRemoteSort()) {
  57314. me.load();
  57315. } else {
  57316. me.tree.sort(sorterFn, true);
  57317. me.fireEvent('datachanged', me);
  57318. me.fireEvent('refresh', me);
  57319. }
  57320. me.fireEvent('sort', me, me.sorters.getRange());
  57321. },
  57322. filterVisible: function(node) {
  57323. return node.get('visible');
  57324. },
  57325. isVisible: function(node) {
  57326. var parentNode = node.parentNode,
  57327. visible = node.data.visible,
  57328. root = this.getRoot();
  57329. while (visible && parentNode) {
  57330. visible = parentNode.data.expanded && parentNode.data.visible;
  57331. parentNode = parentNode.parentNode;
  57332. }
  57333. return visible && !(node === root && !this.getRootVisible());
  57334. },
  57335. commitChanges: function() {
  57336. var removed = this.removedNodes;
  57337. if (removed) {
  57338. removed.length = 0;
  57339. }
  57340. this.callParent();
  57341. },
  57342. getRootNode: function() {
  57343. return this.getRoot();
  57344. },
  57345. setRootNode: function(root) {
  57346. this.setRoot(root);
  57347. return this.getRoot();
  57348. },
  57349. privates: {
  57350. fireChangeEvent: function(record) {
  57351. return !!this.byIdMap[record.id];
  57352. },
  57353. getRawRemovedRecords: function() {
  57354. return this.removedNodes;
  57355. },
  57356. createOperation: function(type, options) {
  57357. var me = this,
  57358. node = options.node,
  57359. proxy;
  57360. if (me.useModelProxy && node && node !== me.getRootNode()) {
  57361. proxy = node.getProxy();
  57362. }
  57363. if (proxy && proxy !== me.getProxy()) {
  57364. return proxy.createOperation(type, options);
  57365. } else {
  57366. return me.callParent([
  57367. type,
  57368. options
  57369. ]);
  57370. }
  57371. },
  57372. recordCreator: function(data, Model) {
  57373. return new Model(data);
  57374. },
  57375. doFilter: function(node) {
  57376. this.filterNodes(node, this.getFilters().getFilterFn(), true);
  57377. },
  57378. filterNodes: function(node, filterFn, parentVisible) {
  57379. var me = this,
  57380. bottomUpFiltering = me.filterer === 'bottomup',
  57381. match = filterFn(node) && parentVisible || (node.isRoot() && !me.getRootVisible()),
  57382. childNodes = node.childNodes,
  57383. len = childNodes && childNodes.length,
  57384. i, matchingChildren;
  57385. if (len) {
  57386. for (i = 0; i < len; ++i) {
  57387. matchingChildren = me.filterNodes(childNodes[i], filterFn, match || bottomUpFiltering) || matchingChildren;
  57388. }
  57389. if (bottomUpFiltering) {
  57390. match = matchingChildren || match;
  57391. }
  57392. }
  57393. node.set("visible", match, me._silentOptions);
  57394. return match;
  57395. },
  57396. needsLocalFilter: function() {
  57397. return !this.getRemoteFilter() && this.getFilters().length;
  57398. },
  57399. onRemoteFilterSet: function(filters, remoteFilter) {
  57400. var data = this.getData();
  57401. data.setFilters(null);
  57402. if (filters) {
  57403. filters.on('endupdate', this.onFilterEndUpdate, this);
  57404. }
  57405. },
  57406. onRemoteSortSet: function(sorters, remoteSort) {
  57407. var data = this.getData();
  57408. data.setSorters(null);
  57409. if (sorters) {
  57410. sorters.on('endupdate', this.onSorterEndUpdate, this);
  57411. }
  57412. }
  57413. },
  57414. deprecated: {
  57415. 5: {
  57416. properties: {
  57417. tree: null
  57418. }
  57419. }
  57420. }
  57421. });
  57422. Ext.define('Ext.data.Types', {
  57423. singleton: true
  57424. }, function(Types) {
  57425. var SortTypes = Ext.data.SortTypes;
  57426. Ext.apply(Types, {
  57427. stripRe: /[$,%]/g,
  57428. AUTO: {
  57429. sortType: SortTypes.none,
  57430. type: 'auto'
  57431. },
  57432. STRING: {
  57433. convert: function(v) {
  57434. var defaultValue = this.getAllowNull() ? null : '';
  57435. return (v === undefined || v === null) ? defaultValue : String(v);
  57436. },
  57437. sortType: SortTypes.asUCString,
  57438. type: 'string'
  57439. },
  57440. INT: {
  57441. convert: function(v) {
  57442. if (typeof v === 'number') {
  57443. return parseInt(v, 10);
  57444. }
  57445. return v !== undefined && v !== null && v !== '' ? parseInt(String(v).replace(Types.stripRe, ''), 10) : (this.getAllowNull() ? null : 0);
  57446. },
  57447. sortType: SortTypes.none,
  57448. type: 'int'
  57449. },
  57450. FLOAT: {
  57451. convert: function(v) {
  57452. if (typeof v === 'number') {
  57453. return v;
  57454. }
  57455. return v !== undefined && v !== null && v !== '' ? parseFloat(String(v).replace(Types.stripRe, ''), 10) : (this.getAllowNull() ? null : 0);
  57456. },
  57457. sortType: SortTypes.none,
  57458. type: 'float'
  57459. },
  57460. BOOL: {
  57461. convert: function(v) {
  57462. if (typeof v === 'boolean') {
  57463. return v;
  57464. }
  57465. if (this.getAllowNull() && (v === undefined || v === null || v === '')) {
  57466. return null;
  57467. }
  57468. return v === 'true' || v == 1;
  57469. },
  57470. sortType: SortTypes.none,
  57471. type: 'bool'
  57472. },
  57473. DATE: {
  57474. convert: function(v) {
  57475. var df = this.getDateReadFormat() || this.getDateFormat(),
  57476. parsed;
  57477. if (!v) {
  57478. return null;
  57479. }
  57480. if (v instanceof Date) {
  57481. return v;
  57482. }
  57483. if (df) {
  57484. return Ext.Date.parse(v, df);
  57485. }
  57486. parsed = Date.parse(v);
  57487. return parsed ? new Date(parsed) : null;
  57488. },
  57489. sortType: SortTypes.asDate,
  57490. type: 'date'
  57491. }
  57492. });
  57493. Types.BOOLEAN = Types.BOOL;
  57494. Types.INTEGER = Types.INT;
  57495. Types.NUMBER = Types.FLOAT;
  57496. });
  57497. Ext.define('Ext.data.Validation', {
  57498. extend: Ext.data.Model,
  57499. isValidation: true,
  57500. syncGeneration: 0,
  57501. attach: function(record) {
  57502. this.record = record;
  57503. this.isBase = record.self === Ext.data.Model;
  57504. delete this.data.id;
  57505. },
  57506. getValidation: function() {
  57507. return null;
  57508. },
  57509. isValid: function() {
  57510. var me = this;
  57511. if (me.syncGeneration !== me.record.generation) {
  57512. me.refresh();
  57513. }
  57514. return !me.dirty;
  57515. },
  57516. refresh: function(force) {
  57517. if (this.isBase) {
  57518. return;
  57519. }
  57520. var me = this,
  57521. data = me.data,
  57522. record = me.record,
  57523. fields = record.fields,
  57524. generation = record.generation,
  57525. recordData = record.data,
  57526. sep = record.validationSeparator,
  57527. values = null,
  57528. defaultMessage, currentValue, error, field, i, len, msg, val, name;
  57529. if (force || me.syncGeneration !== generation) {
  57530. me.syncGeneration = generation;
  57531. for (i = 0 , len = fields.length; i < len; ++i) {
  57532. field = fields[i];
  57533. name = field.name;
  57534. val = recordData[name];
  57535. defaultMessage = field.defaultInvalidMessage;
  57536. error = 0;
  57537. if (!(name in data)) {
  57538. data[name] = currentValue = true;
  57539. } else
  57540. {
  57541. currentValue = data[name];
  57542. }
  57543. if (field.validate !== Ext.emptyFn) {
  57544. msg = field.validate(val, sep, null, record);
  57545. if (msg !== true) {
  57546. error = msg || defaultMessage;
  57547. }
  57548. }
  57549. if (!error) {
  57550. error = true;
  57551. }
  57552. if (error !== currentValue) {
  57553. (values || (values = {}))[name] = error;
  57554. }
  57555. }
  57556. if (values) {
  57557. me.set(values);
  57558. }
  57559. }
  57560. }
  57561. });
  57562. Ext.define('Ext.dom.Helper', function() {
  57563. var afterbegin = 'afterbegin',
  57564. afterend = 'afterend',
  57565. beforebegin = 'beforebegin',
  57566. beforeend = 'beforeend',
  57567. bbValues = [
  57568. 'BeforeBegin',
  57569. 'previousSibling'
  57570. ],
  57571. aeValues = [
  57572. 'AfterEnd',
  57573. 'nextSibling'
  57574. ],
  57575. bb_ae_PositionHash = {
  57576. beforebegin: bbValues,
  57577. afterend: aeValues
  57578. },
  57579. fullPositionHash = {
  57580. beforebegin: bbValues,
  57581. afterend: aeValues,
  57582. afterbegin: [
  57583. 'AfterBegin',
  57584. 'firstChild'
  57585. ],
  57586. beforeend: [
  57587. 'BeforeEnd',
  57588. 'lastChild'
  57589. ]
  57590. };
  57591. return {
  57592. singleton: true,
  57593. alternateClassName: [
  57594. 'Ext.DomHelper',
  57595. 'Ext.core.DomHelper'
  57596. ],
  57597. emptyTags: /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
  57598. confRe: /^(?:tag|children|cn|html|tpl|tplData)$/i,
  57599. endRe: /end/i,
  57600. attributeTransform: {
  57601. cls: 'class',
  57602. htmlFor: 'for'
  57603. },
  57604. closeTags: {},
  57605. detachedDiv: document.createElement('div'),
  57606. decamelizeName: function() {
  57607. var camelCaseRe = /([a-z])([A-Z])/g,
  57608. cache = {};
  57609. function decamel(match, p1, p2) {
  57610. return p1 + '-' + p2.toLowerCase();
  57611. }
  57612. return function(s) {
  57613. return cache[s] || (cache[s] = s.replace(camelCaseRe, decamel));
  57614. };
  57615. }(),
  57616. generateMarkup: function(spec, buffer) {
  57617. var me = this,
  57618. specType = typeof spec,
  57619. attr, val, tag, i, closeTags;
  57620. if (specType === "string" || specType === "number") {
  57621. buffer.push(spec);
  57622. } else if (Ext.isArray(spec)) {
  57623. for (i = 0; i < spec.length; i++) {
  57624. if (spec[i]) {
  57625. me.generateMarkup(spec[i], buffer);
  57626. }
  57627. }
  57628. } else {
  57629. tag = spec.tag || 'div';
  57630. buffer.push('<', tag);
  57631. for (attr in spec) {
  57632. if (spec.hasOwnProperty(attr)) {
  57633. val = spec[attr];
  57634. if (val !== undefined && !me.confRe.test(attr)) {
  57635. if (val && val.join) {
  57636. val = val.join(' ');
  57637. }
  57638. if (typeof val === "object") {
  57639. buffer.push(' ', attr, '="');
  57640. me.generateStyles(val, buffer, true).push('"');
  57641. } else {
  57642. buffer.push(' ', me.attributeTransform[attr] || attr, '="', val, '"');
  57643. }
  57644. }
  57645. }
  57646. }
  57647. if (me.emptyTags.test(tag)) {
  57648. buffer.push('/>');
  57649. } else {
  57650. buffer.push('>');
  57651. if ((val = spec.tpl)) {
  57652. val.applyOut(spec.tplData, buffer);
  57653. }
  57654. if ((val = spec.html)) {
  57655. buffer.push(val);
  57656. }
  57657. if ((val = spec.cn || spec.children)) {
  57658. me.generateMarkup(val, buffer);
  57659. }
  57660. closeTags = me.closeTags;
  57661. buffer.push(closeTags[tag] || (closeTags[tag] = '</' + tag + '>'));
  57662. }
  57663. }
  57664. return buffer;
  57665. },
  57666. generateStyles: function(styles, buffer, encode) {
  57667. var a = buffer || [],
  57668. name, val;
  57669. for (name in styles) {
  57670. if (styles.hasOwnProperty(name)) {
  57671. val = styles[name];
  57672. name = this.decamelizeName(name);
  57673. if (encode && Ext.String.hasHtmlCharacters(val)) {
  57674. val = Ext.String.htmlEncode(val);
  57675. }
  57676. a.push(name, ':', val, ';');
  57677. }
  57678. }
  57679. return buffer || a.join('');
  57680. },
  57681. markup: function(spec) {
  57682. var buf;
  57683. if (typeof spec === "string") {
  57684. return spec;
  57685. }
  57686. buf = this.generateMarkup(spec, []);
  57687. return buf.join('');
  57688. },
  57689. applyStyles: function(el, styles) {
  57690. Ext.fly(el).applyStyles(styles);
  57691. },
  57692. createContextualFragment: function(html) {
  57693. var div = this.detachedDiv,
  57694. fragment = document.createDocumentFragment(),
  57695. length, childNodes;
  57696. div.innerHTML = html;
  57697. childNodes = div.childNodes;
  57698. length = childNodes.length;
  57699. while (length--) {
  57700. fragment.appendChild(childNodes[0]);
  57701. }
  57702. return fragment;
  57703. },
  57704. createDom: function(o) {
  57705. var me = this,
  57706. markup = me.markup(o),
  57707. div = me.detachedDiv,
  57708. child;
  57709. div.innerHTML = markup;
  57710. child = div.firstChild;
  57711. return Ext.supports.ChildContentClearedWhenSettingInnerHTML ? child.cloneNode(true) : child;
  57712. },
  57713. insertHtml: function(where, el, html) {
  57714. var me = this,
  57715. hashVal, range, rangeEl, setStart, frag;
  57716. where = where.toLowerCase();
  57717. if (el.insertAdjacentHTML) {
  57718. if (me.ieInsertHtml) {
  57719. frag = me.ieInsertHtml(where, el, html);
  57720. if (frag) {
  57721. return frag;
  57722. }
  57723. }
  57724. hashVal = fullPositionHash[where];
  57725. if (hashVal) {
  57726. el.insertAdjacentHTML(hashVal[0], html);
  57727. return el[hashVal[1]];
  57728. }
  57729. } else
  57730. {
  57731. if (el.nodeType === 3) {
  57732. where = where === afterbegin ? beforebegin : where;
  57733. where = where === beforeend ? afterend : where;
  57734. }
  57735. range = Ext.supports.CreateContextualFragment ? el.ownerDocument.createRange() : undefined;
  57736. setStart = 'setStart' + (this.endRe.test(where) ? 'After' : 'Before');
  57737. if (bb_ae_PositionHash[where]) {
  57738. if (range) {
  57739. range[setStart](el);
  57740. frag = range.createContextualFragment(html);
  57741. } else {
  57742. frag = this.createContextualFragment(html);
  57743. }
  57744. el.parentNode.insertBefore(frag, where === beforebegin ? el : el.nextSibling);
  57745. return el[(where === beforebegin ? 'previous' : 'next') + 'Sibling'];
  57746. } else {
  57747. rangeEl = (where === afterbegin ? 'first' : 'last') + 'Child';
  57748. if (el.firstChild) {
  57749. if (range) {
  57750. try {
  57751. range[setStart](el[rangeEl]);
  57752. frag = range.createContextualFragment(html);
  57753. } catch (e) {
  57754. frag = this.createContextualFragment(html);
  57755. }
  57756. } else {
  57757. frag = this.createContextualFragment(html);
  57758. }
  57759. if (where === afterbegin) {
  57760. el.insertBefore(frag, el.firstChild);
  57761. } else {
  57762. el.appendChild(frag);
  57763. }
  57764. } else {
  57765. el.innerHTML = html;
  57766. }
  57767. return el[rangeEl];
  57768. }
  57769. }
  57770. Ext.raise({
  57771. sourceClass: 'Ext.DomHelper',
  57772. sourceMethod: 'insertHtml',
  57773. htmlToInsert: html,
  57774. targetElement: el,
  57775. msg: 'Illegal insertion point reached: "' + where + '"'
  57776. });
  57777. },
  57778. insertBefore: function(el, o, returnElement) {
  57779. return this.doInsert(el, o, returnElement, beforebegin);
  57780. },
  57781. insertAfter: function(el, o, returnElement) {
  57782. return this.doInsert(el, o, returnElement, afterend);
  57783. },
  57784. insertFirst: function(el, o, returnElement) {
  57785. return this.doInsert(el, o, returnElement, afterbegin);
  57786. },
  57787. append: function(el, o, returnElement) {
  57788. return this.doInsert(el, o, returnElement, beforeend);
  57789. },
  57790. overwrite: function(el, html, returnElement) {
  57791. var me = this,
  57792. newNode;
  57793. el = Ext.getDom(el);
  57794. html = me.markup(html);
  57795. if (me.ieOverwrite) {
  57796. newNode = me.ieOverwrite(el, html);
  57797. }
  57798. if (!newNode) {
  57799. el.innerHTML = html;
  57800. newNode = el.firstChild;
  57801. }
  57802. return returnElement ? Ext.get(newNode) : newNode;
  57803. },
  57804. doInsert: function(el, o, returnElement, where) {
  57805. var me = this,
  57806. newNode;
  57807. el = el.dom || Ext.getDom(el);
  57808. if ('innerHTML' in el) {
  57809. newNode = me.insertHtml(where, el, me.markup(o));
  57810. } else {
  57811. newNode = me.createDom(o, null);
  57812. if (el.nodeType === 3) {
  57813. where = where === afterbegin ? beforebegin : where;
  57814. where = where === beforeend ? afterend : where;
  57815. }
  57816. if (bb_ae_PositionHash[where]) {
  57817. el.parentNode.insertBefore(newNode, where === beforebegin ? el : el.nextSibling);
  57818. }
  57819. else if (el.firstChild && where === afterbegin) {
  57820. el.insertBefore(newNode, el.firstChild);
  57821. } else {
  57822. el.appendChild(newNode);
  57823. }
  57824. }
  57825. return returnElement ? Ext.get(newNode) : newNode;
  57826. },
  57827. createTemplate: function(o) {
  57828. var html = this.markup(o);
  57829. return new Ext.Template(html);
  57830. },
  57831. createHtml: function(spec) {
  57832. return this.markup(spec);
  57833. }
  57834. };
  57835. });
  57836. Ext.define('Ext.dom.Query', function() {
  57837. var DQ,
  57838. doc = document,
  57839. cache, simpleCache, valueCache,
  57840. useClassList = !!doc.documentElement.classList,
  57841. useElementPointer = !!doc.documentElement.firstElementChild,
  57842. useChildrenCollection = (function() {
  57843. var d = doc.createElement('div');
  57844. d.innerHTML = '<!-- -->text<!-- -->';
  57845. return d.children && (d.children.length === 0);
  57846. })(),
  57847. nonSpace = /\S/,
  57848. trimRe = /^\s+|\s+$/g,
  57849. tplRe = /\{(\d+)\}/g,
  57850. modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
  57851. tagTokenRe = /^(#)?([\w\-\*\|\\]+)/,
  57852. nthRe = /(\d*)n\+?(\d*)/,
  57853. nthRe2 = /\D/,
  57854. startIdRe = /^\s*#/,
  57855. isIE = window.ActiveXObject ? true : false,
  57856. key = 30803,
  57857. longHex = /\\([0-9a-fA-F]{6})/g,
  57858. shortHex = /\\([0-9a-fA-F]{1,6})\s{0,1}/g,
  57859. nonHex = /\\([^0-9a-fA-F]{1})/g,
  57860. escapes = /\\/g,
  57861. num, hasEscapes,
  57862. supportsColonNsSeparator = (function() {
  57863. var xmlDoc,
  57864. xmlString = '<r><a:b xmlns:a="n"></a:b></r>';
  57865. if (window.DOMParser) {
  57866. xmlDoc = (new DOMParser()).parseFromString(xmlString, "application/xml");
  57867. } else {
  57868. xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  57869. xmlDoc.loadXML(xmlString);
  57870. }
  57871. return !!xmlDoc.getElementsByTagName('a:b').length;
  57872. })(),
  57873. longHexToChar = function($0, $1) {
  57874. return String.fromCharCode(parseInt($1, 16));
  57875. },
  57876. shortToLongHex = function($0, $1) {
  57877. while ($1.length < 6) {
  57878. $1 = '0' + $1;
  57879. }
  57880. return '\\' + $1;
  57881. },
  57882. charToLongHex = function($0, $1) {
  57883. num = $1.charCodeAt(0).toString(16);
  57884. if (num.length === 1) {
  57885. num = '0' + num;
  57886. }
  57887. return '\\0000' + num;
  57888. },
  57889. unescapeCssSelector = function(selector) {
  57890. return (hasEscapes) ? selector.replace(longHex, longHexToChar) : selector;
  57891. },
  57892. setupEscapes = function(path) {
  57893. hasEscapes = (path.indexOf('\\') > -1);
  57894. if (hasEscapes) {
  57895. path = path.replace(shortHex, shortToLongHex).replace(nonHex, charToLongHex).replace(escapes, '\\\\');
  57896. }
  57897. return path;
  57898. };
  57899. eval("var batch = 30803, child, next, prev, byClassName;");
  57900. child = useChildrenCollection ? function child(parent, index) {
  57901. return parent.children[index];
  57902. } : function child(parent, index) {
  57903. var i = 0,
  57904. n = parent.firstChild;
  57905. while (n) {
  57906. if (n.nodeType == 1) {
  57907. if (++i == index) {
  57908. return n;
  57909. }
  57910. }
  57911. n = n.nextSibling;
  57912. }
  57913. return null;
  57914. };
  57915. next = useElementPointer ? function(n) {
  57916. return n.nextElementSibling;
  57917. } : function(n) {
  57918. while ((n = n.nextSibling) && n.nodeType != 1) {}
  57919. return n;
  57920. };
  57921. prev = useElementPointer ? function(n) {
  57922. return n.previousElementSibling;
  57923. } : function(n) {
  57924. while ((n = n.previousSibling) && n.nodeType != 1) {}
  57925. return n;
  57926. };
  57927. function children(parent) {
  57928. var n = parent.firstChild,
  57929. nodeIndex = -1,
  57930. nextNode;
  57931. while (n) {
  57932. nextNode = n.nextSibling;
  57933. if (n.nodeType == 3 && !nonSpace.test(n.nodeValue)) {
  57934. parent.removeChild(n);
  57935. } else {
  57936. n.nodeIndex = ++nodeIndex;
  57937. }
  57938. n = nextNode;
  57939. }
  57940. return this;
  57941. }
  57942. byClassName = useClassList ? function(nodeSet, cls) {
  57943. cls = unescapeCssSelector(cls);
  57944. if (!cls) {
  57945. return nodeSet;
  57946. }
  57947. var result = [],
  57948. ri = -1,
  57949. i, ci, classList;
  57950. for (i = 0; ci = nodeSet[i]; i++) {
  57951. classList = ci.classList;
  57952. if (classList) {
  57953. if (classList.contains(cls)) {
  57954. result[++ri] = ci;
  57955. }
  57956. } else if ((' ' + ci.className + ' ').indexOf(cls) !== -1) {
  57957. result[++ri] = ci;
  57958. }
  57959. }
  57960. return result;
  57961. } : function(nodeSet, cls) {
  57962. cls = unescapeCssSelector(cls);
  57963. if (!cls) {
  57964. return nodeSet;
  57965. }
  57966. var result = [],
  57967. ri = -1,
  57968. i, ci;
  57969. for (i = 0; ci = nodeSet[i]; i++) {
  57970. if ((' ' + ci.className + ' ').indexOf(cls) !== -1) {
  57971. result[++ri] = ci;
  57972. }
  57973. }
  57974. return result;
  57975. };
  57976. function attrValue(n, attr) {
  57977. if (!n.tagName && typeof n.length != "undefined") {
  57978. n = n[0];
  57979. }
  57980. if (!n) {
  57981. return null;
  57982. }
  57983. if (attr == "for") {
  57984. return n.htmlFor;
  57985. }
  57986. if (attr == "class" || attr == "className") {
  57987. return n.className;
  57988. }
  57989. return n.getAttribute(attr) || n[attr];
  57990. }
  57991. function getNodes(ns, mode, tagName) {
  57992. var result = [],
  57993. ri = -1,
  57994. cs, i, ni, j, ci, cn, utag, n, cj;
  57995. if (!ns) {
  57996. return result;
  57997. }
  57998. tagName = tagName.replace('|', ':') || "*";
  57999. if (typeof ns.getElementsByTagName != "undefined") {
  58000. ns = [
  58001. ns
  58002. ];
  58003. }
  58004. if (!mode) {
  58005. tagName = unescapeCssSelector(tagName);
  58006. if (!supportsColonNsSeparator && DQ.isXml(ns[0]) && tagName.indexOf(':') !== -1) {
  58007. for (i = 0; ni = ns[i]; i++) {
  58008. cs = ni.getElementsByTagName(tagName.split(':').pop());
  58009. for (j = 0; ci = cs[j]; j++) {
  58010. if (ci.tagName === tagName) {
  58011. result[++ri] = ci;
  58012. }
  58013. }
  58014. }
  58015. } else {
  58016. for (i = 0; ni = ns[i]; i++) {
  58017. cs = ni.getElementsByTagName(tagName);
  58018. for (j = 0; ci = cs[j]; j++) {
  58019. result[++ri] = ci;
  58020. }
  58021. }
  58022. }
  58023. }
  58024. else if (mode == "/" || mode == ">") {
  58025. utag = tagName.toUpperCase();
  58026. for (i = 0; ni = ns[i]; i++) {
  58027. cn = ni.childNodes;
  58028. for (j = 0; cj = cn[j]; j++) {
  58029. if (cj.nodeName == utag || cj.nodeName == tagName || tagName == '*') {
  58030. result[++ri] = cj;
  58031. }
  58032. }
  58033. }
  58034. }
  58035. else if (mode == "+") {
  58036. utag = tagName.toUpperCase();
  58037. for (i = 0; n = ns[i]; i++) {
  58038. while ((n = n.nextSibling) && n.nodeType != 1) {}
  58039. if (n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')) {
  58040. result[++ri] = n;
  58041. }
  58042. }
  58043. }
  58044. else if (mode == "~") {
  58045. utag = tagName.toUpperCase();
  58046. for (i = 0; n = ns[i]; i++) {
  58047. while ((n = n.nextSibling)) {
  58048. if (n.nodeName == utag || n.nodeName == tagName || tagName == '*') {
  58049. result[++ri] = n;
  58050. }
  58051. }
  58052. }
  58053. }
  58054. return result;
  58055. }
  58056. function concat(a, b) {
  58057. a.push.apply(a, b);
  58058. return a;
  58059. }
  58060. function byTag(cs, tagName) {
  58061. if (cs.tagName || cs === doc) {
  58062. cs = [
  58063. cs
  58064. ];
  58065. }
  58066. if (!tagName) {
  58067. return cs;
  58068. }
  58069. var result = [],
  58070. ri = -1,
  58071. i, ci;
  58072. tagName = tagName.toLowerCase();
  58073. for (i = 0; ci = cs[i]; i++) {
  58074. if (ci.nodeType == 1 && ci.tagName.toLowerCase() == tagName) {
  58075. result[++ri] = ci;
  58076. }
  58077. }
  58078. return result;
  58079. }
  58080. function byId(cs, id) {
  58081. id = unescapeCssSelector(id);
  58082. if (cs.tagName || cs === doc) {
  58083. cs = [
  58084. cs
  58085. ];
  58086. }
  58087. if (!id) {
  58088. return cs;
  58089. }
  58090. var result = [],
  58091. ri = -1,
  58092. i, ci;
  58093. for (i = 0; ci = cs[i]; i++) {
  58094. if (ci && ci.id == id) {
  58095. result[++ri] = ci;
  58096. return result;
  58097. }
  58098. }
  58099. return result;
  58100. }
  58101. function byAttribute(cs, attr, value, op, custom) {
  58102. var result = [],
  58103. ri = -1,
  58104. useGetStyle = custom == "{",
  58105. fn = DQ.operators[op],
  58106. a, xml, hasXml, i, ci;
  58107. value = unescapeCssSelector(value);
  58108. for (i = 0; ci = cs[i]; i++) {
  58109. if (ci.nodeType === 1) {
  58110. if (!hasXml) {
  58111. xml = DQ.isXml(ci);
  58112. hasXml = true;
  58113. }
  58114. if (!xml) {
  58115. if (useGetStyle) {
  58116. a = DQ.getStyle(ci, attr);
  58117. } else if (attr == "class" || attr == "className") {
  58118. a = ci.className;
  58119. } else if (attr == "for") {
  58120. a = ci.htmlFor;
  58121. } else if (attr == "href") {
  58122. a = ci.getAttribute("href", 2);
  58123. } else {
  58124. a = ci.getAttribute(attr);
  58125. }
  58126. } else {
  58127. a = ci.getAttribute(attr);
  58128. }
  58129. if ((fn && fn(a, value)) || (!fn && a)) {
  58130. result[++ri] = ci;
  58131. }
  58132. }
  58133. }
  58134. return result;
  58135. }
  58136. function byPseudo(cs, name, value) {
  58137. value = unescapeCssSelector(value);
  58138. return DQ.pseudos[name](cs, value);
  58139. }
  58140. function nodupIEXml(cs) {
  58141. var d = ++key,
  58142. r, i, len, c;
  58143. cs[0].setAttribute("_nodup", d);
  58144. r = [
  58145. cs[0]
  58146. ];
  58147. for (i = 1 , len = cs.length; i < len; i++) {
  58148. c = cs[i];
  58149. if (!c.getAttribute("_nodup") != d) {
  58150. c.setAttribute("_nodup", d);
  58151. r[r.length] = c;
  58152. }
  58153. }
  58154. for (i = 0 , len = cs.length; i < len; i++) {
  58155. cs[i].removeAttribute("_nodup");
  58156. }
  58157. return r;
  58158. }
  58159. function nodup(cs) {
  58160. if (!cs) {
  58161. return [];
  58162. }
  58163. var len = cs.length,
  58164. r = cs,
  58165. ri = -1,
  58166. c, cj, i, d, j;
  58167. if (!len || typeof cs.nodeType != "undefined" || len == 1) {
  58168. return cs;
  58169. }
  58170. if (isIE && typeof cs[0].selectSingleNode != "undefined") {
  58171. return nodupIEXml(cs);
  58172. }
  58173. d = ++key;
  58174. cs[0]._nodup = d;
  58175. for (i = 1; c = cs[i]; i++) {
  58176. if (c._nodup != d) {
  58177. c._nodup = d;
  58178. } else {
  58179. r = [];
  58180. for (j = 0; j < i; j++) {
  58181. r[++ri] = cs[j];
  58182. }
  58183. for (j = i + 1; cj = cs[j]; j++) {
  58184. if (cj._nodup != d) {
  58185. cj._nodup = d;
  58186. r[++ri] = cj;
  58187. }
  58188. }
  58189. return r;
  58190. }
  58191. }
  58192. return r;
  58193. }
  58194. function quickDiffIEXml(c1, c2) {
  58195. var d = ++key,
  58196. r = [],
  58197. i, len;
  58198. for (i = 0 , len = c1.length; i < len; i++) {
  58199. c1[i].setAttribute("_qdiff", d);
  58200. }
  58201. for (i = 0 , len = c2.length; i < len; i++) {
  58202. if (c2[i].getAttribute("_qdiff") != d) {
  58203. r[r.length] = c2[i];
  58204. }
  58205. }
  58206. for (i = 0 , len = c1.length; i < len; i++) {
  58207. c1[i].removeAttribute("_qdiff");
  58208. }
  58209. return r;
  58210. }
  58211. function quickDiff(c1, c2) {
  58212. var len1 = c1.length,
  58213. d = ++key,
  58214. r = [],
  58215. i, len;
  58216. if (!len1) {
  58217. return c2;
  58218. }
  58219. if (isIE && typeof c1[0].selectSingleNode != "undefined") {
  58220. return quickDiffIEXml(c1, c2);
  58221. }
  58222. for (i = 0; i < len1; i++) {
  58223. c1[i]._qdiff = d;
  58224. }
  58225. for (i = 0 , len = c2.length; i < len; i++) {
  58226. if (c2[i]._qdiff != d) {
  58227. r[r.length] = c2[i];
  58228. }
  58229. }
  58230. return r;
  58231. }
  58232. function quickId(ns, mode, root, id) {
  58233. var d;
  58234. if (ns == root) {
  58235. id = unescapeCssSelector(id);
  58236. d = root.ownerDocument || root;
  58237. return d.getElementById(id);
  58238. }
  58239. ns = getNodes(ns, mode, "*");
  58240. return byId(ns, id);
  58241. }
  58242. return {
  58243. singleton: true,
  58244. alternateClassName: [
  58245. 'Ext.core.DomQuery',
  58246. 'Ext.DomQuery'
  58247. ],
  58248. _init: function() {
  58249. DQ = this;
  58250. DQ.operators = Ext.Object.chain(Ext.util.Operators);
  58251. DQ._cache = cache = new Ext.util.LruCache({
  58252. maxSize: 200
  58253. });
  58254. DQ._valueCache = valueCache = new Ext.util.LruCache({
  58255. maxSize: 200
  58256. });
  58257. DQ._simpleCache = simpleCache = new Ext.util.LruCache({
  58258. maxSize: 200
  58259. });
  58260. },
  58261. clearCache: function() {
  58262. cache.clear();
  58263. valueCache.clear();
  58264. simpleCache.clear();
  58265. },
  58266. getStyle: function(el, name) {
  58267. return Ext.fly(el, '_DomQuery').getStyle(name);
  58268. },
  58269. compile: function(path, type) {
  58270. type = type || "select";
  58271. var fn = [
  58272. "var f = function(root) {\n var mode; ++batch; var n = root || document;\n"
  58273. ],
  58274. lastPath,
  58275. matchers = DQ.matchers,
  58276. matchersLn = matchers.length,
  58277. lmode = path.match(modeRe),
  58278. modeMatch, tokenMatch, matched, j, t, m;
  58279. path = setupEscapes(path);
  58280. if (lmode && lmode[1]) {
  58281. fn[fn.length] = 'mode="' + lmode[1].replace(trimRe, "") + '";';
  58282. path = path.replace(lmode[1], "");
  58283. }
  58284. while (path.substr(0, 1) == "/") {
  58285. path = path.substr(1);
  58286. }
  58287. while (path && lastPath != path) {
  58288. lastPath = path;
  58289. tokenMatch = path.match(tagTokenRe);
  58290. if (type == "select") {
  58291. if (tokenMatch) {
  58292. if (tokenMatch[1] == "#") {
  58293. fn[fn.length] = 'n = quickId(n, mode, root, "' + tokenMatch[2] + '");';
  58294. } else {
  58295. fn[fn.length] = 'n = getNodes(n, mode, "' + tokenMatch[2] + '");';
  58296. }
  58297. path = path.replace(tokenMatch[0], "");
  58298. } else if (path.substr(0, 1) != '@') {
  58299. fn[fn.length] = 'n = getNodes(n, mode, "*");';
  58300. }
  58301. } else
  58302. {
  58303. if (tokenMatch) {
  58304. if (tokenMatch[1] == "#") {
  58305. fn[fn.length] = 'n = byId(n, "' + tokenMatch[2] + '");';
  58306. } else {
  58307. fn[fn.length] = 'n = byTag(n, "' + tokenMatch[2] + '");';
  58308. }
  58309. path = path.replace(tokenMatch[0], "");
  58310. }
  58311. }
  58312. while (!(modeMatch = path.match(modeRe))) {
  58313. matched = false;
  58314. for (j = 0; j < matchersLn; j++) {
  58315. t = matchers[j];
  58316. m = path.match(t.re);
  58317. if (m) {
  58318. fn[fn.length] = t.select.replace(tplRe, function(x, i) {
  58319. return m[i];
  58320. });
  58321. path = path.replace(m[0], "");
  58322. matched = true;
  58323. break;
  58324. }
  58325. }
  58326. if (!matched) {
  58327. Ext.raise({
  58328. sourceClass: 'Ext.DomQuery',
  58329. sourceMethod: 'compile',
  58330. msg: 'Error parsing selector. Parsing failed at "' + path + '"'
  58331. });
  58332. }
  58333. }
  58334. if (modeMatch[1]) {
  58335. fn[fn.length] = 'mode="' + modeMatch[1].replace(trimRe, "") + '";';
  58336. path = path.replace(modeMatch[1], "");
  58337. }
  58338. }
  58339. fn[fn.length] = "return nodup(n);\n}";
  58340. eval(fn.join(""));
  58341. return f;
  58342. },
  58343. jsSelect: function(path, root, type) {
  58344. root = root || doc;
  58345. if (typeof root == "string") {
  58346. root = doc.getElementById(root);
  58347. }
  58348. var paths = Ext.splitAndUnescape(path, ","),
  58349. results = [],
  58350. query, i, len, subPath, result;
  58351. for (i = 0 , len = paths.length; i < len; i++) {
  58352. subPath = paths[i].replace(trimRe, "");
  58353. query = cache.get(subPath);
  58354. if (!query) {
  58355. query = DQ.compile(subPath, type);
  58356. if (!query) {
  58357. Ext.raise({
  58358. sourceClass: 'Ext.DomQuery',
  58359. sourceMethod: 'jsSelect',
  58360. msg: subPath + ' is not a valid selector'
  58361. });
  58362. }
  58363. cache.add(subPath, query);
  58364. } else {
  58365. setupEscapes(subPath);
  58366. }
  58367. result = query(root);
  58368. if (result && result !== doc) {
  58369. results = results.concat(result);
  58370. }
  58371. }
  58372. if (paths.length > 1) {
  58373. return nodup(results);
  58374. }
  58375. return results;
  58376. },
  58377. isXml: function(el) {
  58378. var docEl = (el ? el.ownerDocument || el : 0).documentElement;
  58379. return docEl ? docEl.nodeName !== "HTML" : false;
  58380. },
  58381. select: doc.querySelectorAll ? function(path, root, type, single) {
  58382. root = root || doc;
  58383. if (!DQ.isXml(root)) {
  58384. try {
  58385. if (root.parentNode && (root.nodeType !== 9) && path.indexOf(',') === -1 && !startIdRe.test(path)) {
  58386. path = Ext.makeIdSelector(Ext.id(root)) + ' ' + path;
  58387. root = root.parentNode;
  58388. }
  58389. return single ? [
  58390. root.querySelector(path)
  58391. ] : Ext.Array.toArray(root.querySelectorAll(path));
  58392. } catch (e) {}
  58393. }
  58394. return DQ.jsSelect.call(this, path, root, type);
  58395. } : function(path, root, type) {
  58396. return DQ.jsSelect.call(this, path, root, type);
  58397. },
  58398. selectNode: function(path, root) {
  58399. return Ext.DomQuery.select(path, root, null, true)[0];
  58400. },
  58401. selectValue: function(path, root, defaultValue) {
  58402. path = path.replace(trimRe, "");
  58403. var query = valueCache.get(path),
  58404. n;
  58405. if (!query) {
  58406. query = DQ.compile(path, "select");
  58407. valueCache.add(path, query);
  58408. } else {
  58409. setupEscapes(path);
  58410. }
  58411. n = query(root);
  58412. return DQ.getNodeValue(n[0] || n, defaultValue);
  58413. },
  58414. getNodeValue: function(node, defaultValue) {
  58415. if (typeof node.normalize == 'function') {
  58416. node.normalize();
  58417. }
  58418. var firstChild = node && node.firstChild,
  58419. v = firstChild ? firstChild.nodeValue : null;
  58420. if (defaultValue !== undefined && (v == null || v === '')) {
  58421. v = defaultValue;
  58422. }
  58423. return v;
  58424. },
  58425. selectNumber: function(path, root, defaultValue) {
  58426. var v = DQ.selectValue(path, root, defaultValue || 0);
  58427. return parseFloat(v);
  58428. },
  58429. is: function(el, ss) {
  58430. if (typeof el == "string") {
  58431. el = doc.getElementById(el);
  58432. }
  58433. var isArray = Ext.isArray(el),
  58434. result = DQ.filter(isArray ? el : [
  58435. el
  58436. ], ss);
  58437. return isArray ? (result.length == el.length) : (result.length > 0);
  58438. },
  58439. filter: function(els, ss, nonMatches) {
  58440. ss = ss.replace(trimRe, "");
  58441. var query = simpleCache.get(ss),
  58442. result;
  58443. if (!query) {
  58444. query = DQ.compile(ss, "simple");
  58445. simpleCache.add(ss, query);
  58446. } else {
  58447. setupEscapes(ss);
  58448. }
  58449. result = query(els);
  58450. return nonMatches ? quickDiff(result, els) : result;
  58451. },
  58452. matchers: [
  58453. {
  58454. re: /^\.([\w\-\\]+)/,
  58455. select: useClassList ? 'n = byClassName(n, "{1}");' : 'n = byClassName(n, " {1} ");'
  58456. },
  58457. {
  58458. re: /^\:([\w\-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
  58459. select: 'n = byPseudo(n, "{1}", "{2}");'
  58460. },
  58461. {
  58462. re: /^(?:([\[\{])(?:@)?([\w\-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
  58463. select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
  58464. },
  58465. {
  58466. re: /^#([\w\-\\]+)/,
  58467. select: 'n = byId(n, "{1}");'
  58468. },
  58469. {
  58470. re: /^@([\w\-\.]+)/,
  58471. select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
  58472. }
  58473. ],
  58474. pseudos: {
  58475. "first-child": function(c) {
  58476. var r = [],
  58477. ri = -1,
  58478. n, i, ci;
  58479. for (i = 0; (ci = n = c[i]); i++) {
  58480. while ((n = n.previousSibling) && n.nodeType != 1) {}
  58481. if (!n) {
  58482. r[++ri] = ci;
  58483. }
  58484. }
  58485. return r;
  58486. },
  58487. "last-child": function(c) {
  58488. var r = [],
  58489. ri = -1,
  58490. n, i, ci;
  58491. for (i = 0; (ci = n = c[i]); i++) {
  58492. while ((n = n.nextSibling) && n.nodeType != 1) {}
  58493. if (!n) {
  58494. r[++ri] = ci;
  58495. }
  58496. }
  58497. return r;
  58498. },
  58499. "nth-child": function(c, a) {
  58500. var r = [],
  58501. ri = -1,
  58502. m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
  58503. f = (m[1] || 1) - 0,
  58504. l = m[2] - 0,
  58505. i, n, j, cn, pn;
  58506. for (i = 0; n = c[i]; i++) {
  58507. pn = n.parentNode;
  58508. if (batch != pn._batch) {
  58509. j = 0;
  58510. for (cn = pn.firstChild; cn; cn = cn.nextSibling) {
  58511. if (cn.nodeType == 1) {
  58512. cn.nodeIndex = ++j;
  58513. }
  58514. }
  58515. pn._batch = batch;
  58516. }
  58517. if (f == 1) {
  58518. if (l === 0 || n.nodeIndex == l) {
  58519. r[++ri] = n;
  58520. }
  58521. } else if ((n.nodeIndex + l) % f === 0) {
  58522. r[++ri] = n;
  58523. }
  58524. }
  58525. return r;
  58526. },
  58527. "only-child": function(c) {
  58528. var r = [],
  58529. ri = -1,
  58530. i, ci;
  58531. for (i = 0; ci = c[i]; i++) {
  58532. if (!prev(ci) && !next(ci)) {
  58533. r[++ri] = ci;
  58534. }
  58535. }
  58536. return r;
  58537. },
  58538. "empty": function(c) {
  58539. var r = [],
  58540. ri = -1,
  58541. i, ci, cns, j, cn, empty;
  58542. for (i = 0; ci = c[i]; i++) {
  58543. cns = ci.childNodes;
  58544. j = 0;
  58545. empty = true;
  58546. while (cn = cns[j]) {
  58547. ++j;
  58548. if (cn.nodeType == 1 || cn.nodeType == 3) {
  58549. empty = false;
  58550. break;
  58551. }
  58552. }
  58553. if (empty) {
  58554. r[++ri] = ci;
  58555. }
  58556. }
  58557. return r;
  58558. },
  58559. "contains": function(c, v) {
  58560. var r = [],
  58561. ri = -1,
  58562. i, ci;
  58563. for (i = 0; ci = c[i]; i++) {
  58564. if ((ci.textContent || ci.innerText || ci.text || '').indexOf(v) != -1) {
  58565. r[++ri] = ci;
  58566. }
  58567. }
  58568. return r;
  58569. },
  58570. "nodeValue": function(c, v) {
  58571. var r = [],
  58572. ri = -1,
  58573. i, ci;
  58574. for (i = 0; ci = c[i]; i++) {
  58575. if (ci.firstChild && ci.firstChild.nodeValue == v) {
  58576. r[++ri] = ci;
  58577. }
  58578. }
  58579. return r;
  58580. },
  58581. "checked": function(c) {
  58582. var r = [],
  58583. ri = -1,
  58584. i, ci;
  58585. for (i = 0; ci = c[i]; i++) {
  58586. if (ci.checked === true) {
  58587. r[++ri] = ci;
  58588. }
  58589. }
  58590. return r;
  58591. },
  58592. "not": function(c, ss) {
  58593. return DQ.filter(c, ss, true);
  58594. },
  58595. "any": function(c, selectors) {
  58596. var ss = selectors.split('|'),
  58597. r = [],
  58598. ri = -1,
  58599. s, i, ci, j;
  58600. for (i = 0; ci = c[i]; i++) {
  58601. for (j = 0; s = ss[j]; j++) {
  58602. if (DQ.is(ci, s)) {
  58603. r[++ri] = ci;
  58604. break;
  58605. }
  58606. }
  58607. }
  58608. return r;
  58609. },
  58610. "odd": function(c) {
  58611. return this["nth-child"](c, "odd");
  58612. },
  58613. "even": function(c) {
  58614. return this["nth-child"](c, "even");
  58615. },
  58616. "nth": function(c, a) {
  58617. return c[a - 1] || [];
  58618. },
  58619. "first": function(c) {
  58620. return c[0] || [];
  58621. },
  58622. "last": function(c) {
  58623. return c[c.length - 1] || [];
  58624. },
  58625. "has": function(c, ss) {
  58626. var s = DQ.select,
  58627. r = [],
  58628. ri = -1,
  58629. i, ci;
  58630. for (i = 0; ci = c[i]; i++) {
  58631. if (s(ss, ci).length > 0) {
  58632. r[++ri] = ci;
  58633. }
  58634. }
  58635. return r;
  58636. },
  58637. "next": function(c, ss) {
  58638. var is = DQ.is,
  58639. r = [],
  58640. ri = -1,
  58641. i, ci, n;
  58642. for (i = 0; ci = c[i]; i++) {
  58643. n = next(ci);
  58644. if (n && is(n, ss)) {
  58645. r[++ri] = ci;
  58646. }
  58647. }
  58648. return r;
  58649. },
  58650. "prev": function(c, ss) {
  58651. var is = DQ.is,
  58652. r = [],
  58653. ri = -1,
  58654. i, ci, n;
  58655. for (i = 0; ci = c[i]; i++) {
  58656. n = prev(ci);
  58657. if (n && is(n, ss)) {
  58658. r[++ri] = ci;
  58659. }
  58660. }
  58661. return r;
  58662. },
  58663. focusable: function(candidates) {
  58664. var len = candidates.length,
  58665. results = [],
  58666. i = 0,
  58667. c;
  58668. for (; i < len; i++) {
  58669. c = candidates[i];
  58670. if (Ext.fly(c, '_DomQuery').isFocusable()) {
  58671. results.push(c);
  58672. }
  58673. }
  58674. return results;
  58675. },
  58676. visible: function(candidates, deep) {
  58677. var len = candidates.length,
  58678. results = [],
  58679. i = 0,
  58680. c;
  58681. for (; i < len; i++) {
  58682. c = candidates[i];
  58683. if (Ext.fly(c, '_DomQuery').isVisible(deep)) {
  58684. results.push(c);
  58685. }
  58686. }
  58687. return results;
  58688. },
  58689. isScrolled: function(c) {
  58690. var r = [],
  58691. ri = -1,
  58692. i, ci, s;
  58693. for (i = 0; ci = c[i]; i++) {
  58694. s = Ext.fly(ci, '_DomQuery').getScroll();
  58695. if (s.top > 0 || s.left > 0) {
  58696. r[++ri] = ci;
  58697. }
  58698. }
  58699. return r;
  58700. }
  58701. }
  58702. };
  58703. }, function() {
  58704. this._init();
  58705. });
  58706. Ext.define('Ext.data.reader.Xml', {
  58707. extend: Ext.data.reader.Reader,
  58708. alternateClassName: 'Ext.data.XmlReader',
  58709. alias: 'reader.xml',
  58710. config: {
  58711. record: '',
  58712. namespace: ''
  58713. },
  58714. responseType: 'document',
  58715. createAccessor: function(expr) {
  58716. if (Ext.isEmpty(expr)) {
  58717. return Ext.emptyFn;
  58718. }
  58719. if (Ext.isFunction(expr)) {
  58720. return expr;
  58721. }
  58722. return function(root) {
  58723. return this.getNodeValue(Ext.DomQuery.selectNode(expr, root));
  58724. };
  58725. },
  58726. getNodeValue: function(node) {
  58727. if (node) {
  58728. if (typeof node.normalize === 'function') {
  58729. node.normalize();
  58730. }
  58731. node = node.firstChild;
  58732. if (node) {
  58733. return node.nodeValue;
  58734. }
  58735. }
  58736. return undefined;
  58737. },
  58738. getResponseData: function(response) {
  58739. var xml = response.responseXML,
  58740. error = 'XML data not found in the response';
  58741. if (!xml) {
  58742. Ext.Logger.warn(error);
  58743. return this.createReadError(error);
  58744. }
  58745. return xml;
  58746. },
  58747. getData: function(data) {
  58748. return data.documentElement || data;
  58749. },
  58750. getRoot: function(data) {
  58751. return this.getRootValue(data, this.getRootProperty());
  58752. },
  58753. extractData: function(root, readOptions) {
  58754. var recordName = this.getRecord();
  58755. if (!recordName) {
  58756. Ext.raise('Record is a required parameter');
  58757. }
  58758. if (recordName !== root.nodeName) {
  58759. root = Ext.DomQuery.select(recordName, root);
  58760. } else {
  58761. root = [
  58762. root
  58763. ];
  58764. }
  58765. return this.callParent([
  58766. root,
  58767. readOptions
  58768. ]);
  58769. },
  58770. readRecords: function(doc, readOptions, internalReadOptions) {
  58771. if (Ext.isArray(doc)) {
  58772. doc = doc[0];
  58773. }
  58774. return this.callParent([
  58775. doc,
  58776. readOptions,
  58777. internalReadOptions
  58778. ]);
  58779. },
  58780. createFieldAccessor: function(field) {
  58781. var namespace = this.getNamespace(),
  58782. selector, autoMapping, result;
  58783. if (field.mapping) {
  58784. selector = field.mapping;
  58785. } else {
  58786. selector = (namespace ? namespace + '|' : '') + field.name;
  58787. autoMapping = true;
  58788. }
  58789. if (typeof selector === 'function') {
  58790. result = function(raw, self) {
  58791. return field.mapping(raw, self);
  58792. };
  58793. } else {
  58794. if (autoMapping && !namespace && Ext.supports.XmlQuerySelector) {
  58795. result = function(raw, self) {
  58796. return self.getNodeValue(raw.querySelector(selector));
  58797. };
  58798. }
  58799. if (!result) {
  58800. result = function(raw, self) {
  58801. return self.getNodeValue(Ext.DomQuery.selectNode(selector, raw));
  58802. };
  58803. }
  58804. }
  58805. return result;
  58806. },
  58807. privates: {
  58808. getGroupRoot: function(data) {
  58809. return this.getRootValue(data, this.getGroupRootProperty());
  58810. },
  58811. getRootValue: function(data, prop) {
  58812. var nodeName = data.nodeName;
  58813. if (!prop || (nodeName && nodeName === prop)) {
  58814. return data;
  58815. } else if (typeof prop === 'function') {
  58816. return prop(data);
  58817. } else if (Ext.DomQuery.isXml(data)) {
  58818. return Ext.DomQuery.selectNode(prop, data);
  58819. }
  58820. },
  58821. getSummaryRoot: function(data) {
  58822. return this.getRootValue(data, this.getSummaryRootProperty());
  58823. }
  58824. },
  58825. deprecated: {
  58826. '5.1.1': {
  58827. properties: {
  58828. xmlData: null
  58829. }
  58830. }
  58831. }
  58832. });
  58833. Ext.define('Ext.data.writer.Xml', {
  58834. extend: Ext.data.writer.Writer,
  58835. alternateClassName: 'Ext.data.XmlWriter',
  58836. alias: 'writer.xml',
  58837. config: {
  58838. documentRoot: 'xmlData',
  58839. defaultDocumentRoot: 'xmlData',
  58840. header: '',
  58841. record: 'record'
  58842. },
  58843. selectorRe: /[^>\s]+/g,
  58844. writeRecords: function(request, data) {
  58845. var me = this,
  58846. xml = [],
  58847. i = 0,
  58848. len = data.length,
  58849. root = me.getDocumentRoot(),
  58850. recordName = me.getRecord(),
  58851. record = recordName.match(this.selectorRe),
  58852. recLen = record.length,
  58853. needsRoot = data.length !== 1 && recLen === 1,
  58854. transform;
  58855. transform = this.getTransform();
  58856. if (transform) {
  58857. data = transform(data, request);
  58858. }
  58859. xml.push(me.getHeader() || '');
  58860. if (!root && needsRoot) {
  58861. root = me.getDefaultDocumentRoot();
  58862. }
  58863. if (root) {
  58864. xml.push('<', root, '>');
  58865. }
  58866. for (i = 0; i < recLen - 1; i++) {
  58867. xml.push('<', record[i], '>');
  58868. }
  58869. recordName = record[i];
  58870. for (i = 0; i < len; ++i) {
  58871. this.objectToElement(recordName, data[i], xml);
  58872. }
  58873. for (i = recLen - 2; i > -1; i--) {
  58874. xml.push('</', record[i], '>');
  58875. }
  58876. if (root) {
  58877. xml.push('</', root, '>');
  58878. }
  58879. request.setXmlData(xml.join(''));
  58880. return request;
  58881. },
  58882. objectToElement: function(name, o, output) {
  58883. var subOutput = [],
  58884. key, datum, subKeys, subKeyLen, subObject, subObjects, lastObject, lastKey, i;
  58885. if (!output) {
  58886. output = [];
  58887. }
  58888. output.push('<', name);
  58889. for (key in o) {
  58890. datum = o[key];
  58891. if (key[0] === '@') {
  58892. output.push(' ', key.substr(1), '="', datum, '"');
  58893. } else
  58894. {
  58895. if (typeof datum === 'object') {
  58896. this.objectToElement(key, datum, subOutput);
  58897. } else {
  58898. subKeys = key.match(this.selectorRe);
  58899. if ((subKeyLen = subKeys.length) > 1) {
  58900. subObjects = subObjects || {};
  58901. for (subObject = subObjects , i = 0; i < subKeyLen; i++) {
  58902. lastObject = subObject;
  58903. lastKey = subKeys[i];
  58904. subObject = subObject[lastKey] || (subObject[lastKey] = {});
  58905. }
  58906. lastObject[lastKey] = datum;
  58907. } else {
  58908. subOutput.push('<', key, '>', datum, '</', key, '>');
  58909. }
  58910. }
  58911. }
  58912. }
  58913. output.push('>');
  58914. output.push.apply(output, subOutput);
  58915. if (subObjects) {
  58916. for (key in subObjects) {
  58917. datum = subObjects[key];
  58918. this.objectToElement(key, datum, output);
  58919. }
  58920. }
  58921. output.push('</', name, '>');
  58922. return output;
  58923. }
  58924. });
  58925. Ext.define('Ext.data.XmlStore', {
  58926. extend: Ext.data.Store,
  58927. alias: 'store.xml',
  58928. constructor: function(config) {
  58929. config = Ext.apply({
  58930. proxy: {
  58931. type: 'ajax',
  58932. reader: 'xml',
  58933. writer: 'xml'
  58934. }
  58935. }, config);
  58936. this.callParent([
  58937. config
  58938. ]);
  58939. }
  58940. });
  58941. Ext.define('Ext.data.identifier.Negative', {
  58942. extend: Ext.data.identifier.Sequential,
  58943. alias: 'data.identifier.negative',
  58944. config: {
  58945. increment: -1,
  58946. seed: -1
  58947. }
  58948. });
  58949. Ext.define('Ext.data.identifier.Uuid', {
  58950. extend: Ext.data.identifier.Generator,
  58951. alias: 'data.identifier.uuid',
  58952. isUnique: true,
  58953. config: {
  58954. id: null
  58955. },
  58956. constructor: function(config) {
  58957. this.callParent([
  58958. config
  58959. ]);
  58960. this.reconfigure(config);
  58961. },
  58962. reconfigure: function(config) {
  58963. var cls = this.self;
  58964. this.generate = (config && config.version === 1) ? cls.createSequential(config.salt, config.timestamp, config.clockSeq) : cls.createRandom();
  58965. },
  58966. clone: null,
  58967. statics: {
  58968. createRandom: function() {
  58969. var pattern = 'xxxxxxxx-xxxx-4xxx-Rxxx-xMxxxxxxxxxx'.split(''),
  58970. hex = '0123456789abcdef'.split(''),
  58971. length = pattern.length,
  58972. parts = [];
  58973. return function() {
  58974. var r, c, i;
  58975. for (i = 0; i < length; ++i) {
  58976. c = pattern[i];
  58977. if (c !== '-' && c !== '4') {
  58978. r = Math.random() * 16;
  58979. r = (c === 'R') ? (r & 3 | 8) : (r | ((c === 'M') ? 1 : 0));
  58980. c = hex[r];
  58981. }
  58982. parts[i] = c;
  58983. }
  58984. return parts.join('');
  58985. };
  58986. },
  58987. createSequential: function(salt, time, clockSeq) {
  58988. var parts = [],
  58989. twoPow32 = Math.pow(2, 32),
  58990. saltLo = salt.lo,
  58991. saltHi = salt.hi,
  58992. timeLo = time.lo,
  58993. timeHi = time.hi,
  58994. toHex;
  58995. toHex = function(value, length) {
  58996. var ret = value.toString(16).toLowerCase();
  58997. if (ret.length > length) {
  58998. ret = ret.substring(ret.length - length);
  58999. }
  59000. else if (ret.length < length) {
  59001. ret = Ext.String.leftPad(ret, length, '0');
  59002. }
  59003. return ret;
  59004. };
  59005. if (typeof salt === 'number') {
  59006. saltHi = Math.floor(salt / twoPow32);
  59007. saltLo = Math.floor(salt - saltHi * twoPow32);
  59008. }
  59009. if (typeof time === 'number') {
  59010. timeHi = Math.floor(time / twoPow32);
  59011. timeLo = Math.floor(time - timeHi * twoPow32);
  59012. }
  59013. saltHi |= 256;
  59014. parts[3] = toHex(128 | ((clockSeq >>> 8) & 63), 2) + toHex(clockSeq & 255, 2);
  59015. parts[4] = toHex(saltHi, 4) + toHex(saltLo, 8);
  59016. return function() {
  59017. parts[0] = toHex(timeLo, 8);
  59018. parts[1] = toHex(timeHi & 65535, 4);
  59019. parts[2] = toHex(((timeHi >>> 16) & 4095) | (1 << 12), 4);
  59020. ++timeLo;
  59021. if (timeLo >= twoPow32) {
  59022. timeLo = 0;
  59023. ++timeHi;
  59024. }
  59025. return parts.join('-');
  59026. };
  59027. }
  59028. }
  59029. }, function() {
  59030. this.Global = new this({
  59031. id: 'uuid'
  59032. });
  59033. });
  59034. Ext.define('Ext.data.proxy.WebStorage', {
  59035. extend: Ext.data.proxy.Client,
  59036. alternateClassName: 'Ext.data.WebStorageProxy',
  59037. config: {
  59038. id: undefined
  59039. },
  59040. constructor: function(config) {
  59041. this.callParent(arguments);
  59042. this.cache = {};
  59043. if (this.getStorageObject() === undefined) {
  59044. Ext.raise("Local Storage is not supported in this browser, please use another type " + "of data proxy");
  59045. }
  59046. if (this.getId() === undefined) {
  59047. Ext.raise("No unique id was provided to the local storage proxy. " + "See Ext.data.proxy.LocalStorage documentation for details");
  59048. }
  59049. this.initialize();
  59050. },
  59051. create: function(operation) {
  59052. var me = this,
  59053. records = operation.getRecords(),
  59054. length = records.length,
  59055. ids = me.getIds(),
  59056. id, record, i, identifier;
  59057. if (me.isHierarchical === undefined) {
  59058. me.isHierarchical = !!records[0].isNode;
  59059. if (me.isHierarchical) {
  59060. me.getStorageObject().setItem(me.getTreeKey(), true);
  59061. }
  59062. }
  59063. for (i = 0; i < length; i++) {
  59064. record = records[i];
  59065. if (record.phantom) {
  59066. identifier = record.identifier;
  59067. if (identifier && identifier.isUnique) {
  59068. id = record.getId();
  59069. } else {
  59070. id = me.getNextId();
  59071. }
  59072. } else {
  59073. id = record.getId();
  59074. }
  59075. me.setRecord(record, id);
  59076. record.commit();
  59077. ids.push(id);
  59078. }
  59079. me.setIds(ids);
  59080. operation.setSuccessful(true);
  59081. },
  59082. read: function(operation) {
  59083. var me = this,
  59084. allRecords,
  59085. records = [],
  59086. success = true,
  59087. Model = me.getModel(),
  59088. validCount = 0,
  59089. recordCreator = operation.getRecordCreator(),
  59090. filters, sorters, limit, filterLen, valid, record, ids, length, data, id, i, j;
  59091. if (me.isHierarchical) {
  59092. records = me.getTreeData();
  59093. } else {
  59094. ids = me.getIds();
  59095. length = ids.length;
  59096. id = operation.getId();
  59097. if (id) {
  59098. data = me.getRecord(id);
  59099. if (data !== null) {
  59100. record = recordCreator ? recordCreator(data, Model) : new Model(data);
  59101. }
  59102. if (record) {
  59103. records.push(record);
  59104. } else {
  59105. success = false;
  59106. }
  59107. } else {
  59108. sorters = operation.getSorters();
  59109. filters = operation.getFilters();
  59110. limit = operation.getLimit();
  59111. allRecords = [];
  59112. for (i = 0; i < length; i++) {
  59113. data = me.getRecord(ids[i]);
  59114. record = recordCreator ? recordCreator(data, Model) : new Model(data);
  59115. allRecords.push(record);
  59116. }
  59117. if (sorters) {
  59118. Ext.Array.sort(allRecords, Ext.util.Sorter.createComparator(sorters));
  59119. }
  59120. for (i = operation.getStart() || 0; i < length; i++) {
  59121. record = allRecords[i];
  59122. valid = true;
  59123. if (filters) {
  59124. for (j = 0 , filterLen = filters.length; j < filterLen; j++) {
  59125. valid = filters[j].filter(record);
  59126. }
  59127. }
  59128. if (valid) {
  59129. records.push(record);
  59130. validCount++;
  59131. }
  59132. if (limit && validCount === limit) {
  59133. break;
  59134. }
  59135. }
  59136. }
  59137. }
  59138. if (success) {
  59139. operation.setResultSet(new Ext.data.ResultSet({
  59140. records: records,
  59141. total: records.length,
  59142. loaded: true
  59143. }));
  59144. operation.setSuccessful(true);
  59145. } else {
  59146. operation.setException('Unable to load records');
  59147. }
  59148. },
  59149. update: function(operation) {
  59150. var records = operation.getRecords(),
  59151. length = records.length,
  59152. ids = this.getIds(),
  59153. record, id, i;
  59154. for (i = 0; i < length; i++) {
  59155. record = records[i];
  59156. this.setRecord(record);
  59157. record.commit();
  59158. id = record.getId();
  59159. if (id !== undefined && Ext.Array.indexOf(ids, id) === -1) {
  59160. ids.push(id);
  59161. }
  59162. }
  59163. this.setIds(ids);
  59164. operation.setSuccessful(true);
  59165. },
  59166. erase: function(operation) {
  59167. var me = this,
  59168. records = operation.getRecords(),
  59169. ids = me.getIds(),
  59170. idLength = ids.length,
  59171. newIds = [],
  59172. removedHash = {},
  59173. i = records.length,
  59174. id;
  59175. for (; i--; ) {
  59176. Ext.apply(removedHash, me.removeRecord(records[i]));
  59177. }
  59178. for (i = 0; i < idLength; i++) {
  59179. id = ids[i];
  59180. if (!removedHash[id]) {
  59181. newIds.push(id);
  59182. }
  59183. }
  59184. me.setIds(newIds);
  59185. operation.setSuccessful(true);
  59186. },
  59187. getRecord: function(id) {
  59188. var me = this,
  59189. cache = me.cache,
  59190. data;
  59191. data = !cache[id] ? Ext.decode(me.getStorageObject().getItem(me.getRecordKey(id))) : cache[id];
  59192. if (!data) {
  59193. return null;
  59194. }
  59195. cache[id] = data;
  59196. data[me.getModel().prototype.idProperty] = id;
  59197. return Ext.merge({}, data);
  59198. },
  59199. setRecord: function(record, id) {
  59200. if (id) {
  59201. record.set('id', id, {
  59202. commit: true
  59203. });
  59204. } else {
  59205. id = record.getId();
  59206. }
  59207. var me = this,
  59208. rawData = record.getData(),
  59209. data = {},
  59210. model = me.getModel(),
  59211. fields = model.getFields(),
  59212. length = fields.length,
  59213. i = 0,
  59214. field, name, obj, key, value;
  59215. for (; i < length; i++) {
  59216. field = fields[i];
  59217. name = field.name;
  59218. if (field.persist) {
  59219. value = rawData[name];
  59220. if (field.isDateField && field.dateFormat && Ext.isDate(value)) {
  59221. value = Ext.Date.format(value, field.dateFormat);
  59222. } else if (field.serialize) {
  59223. value = field.serialize(value, record);
  59224. }
  59225. data[name] = value;
  59226. }
  59227. }
  59228. delete data[model.prototype.idProperty];
  59229. if (record.isNode && record.get('depth') === 1) {
  59230. delete data.parentId;
  59231. }
  59232. obj = me.getStorageObject();
  59233. key = me.getRecordKey(id);
  59234. me.cache[id] = data;
  59235. obj.removeItem(key);
  59236. obj.setItem(key, Ext.encode(data));
  59237. },
  59238. removeRecord: function(record) {
  59239. var me = this,
  59240. id = record.getId(),
  59241. records = {},
  59242. i, childNodes;
  59243. records[id] = record;
  59244. me.getStorageObject().removeItem(me.getRecordKey(id));
  59245. delete me.cache[id];
  59246. if (record.childNodes) {
  59247. childNodes = record.childNodes;
  59248. for (i = childNodes.length; i--; ) {
  59249. Ext.apply(records, me.removeRecord(childNodes[i]));
  59250. }
  59251. }
  59252. return records;
  59253. },
  59254. getRecordKey: function(id) {
  59255. if (id.isModel) {
  59256. id = id.getId();
  59257. }
  59258. return Ext.String.format("{0}-{1}", this.getId(), id);
  59259. },
  59260. getRecordCounterKey: function() {
  59261. return Ext.String.format("{0}-counter", this.getId());
  59262. },
  59263. getTreeKey: function() {
  59264. return Ext.String.format("{0}-tree", this.getId());
  59265. },
  59266. getIds: function() {
  59267. var me = this,
  59268. ids = (me.getStorageObject().getItem(me.getId()) || "").split(","),
  59269. length = ids.length,
  59270. isString = this.getIdField().isStringField,
  59271. i;
  59272. if (length === 1 && ids[0] === "") {
  59273. ids = [];
  59274. } else {
  59275. for (i = 0; i < length; i++) {
  59276. ids[i] = isString ? ids[i] : +ids[i];
  59277. }
  59278. }
  59279. return ids;
  59280. },
  59281. getIdField: function() {
  59282. return this.getModel().prototype.idField;
  59283. },
  59284. setIds: function(ids) {
  59285. var obj = this.getStorageObject(),
  59286. str = ids.join(","),
  59287. id = this.getId();
  59288. obj.removeItem(id);
  59289. if (!Ext.isEmpty(str)) {
  59290. obj.setItem(id, str);
  59291. }
  59292. },
  59293. getNextId: function() {
  59294. var me = this,
  59295. obj = me.getStorageObject(),
  59296. key = me.getRecordCounterKey(),
  59297. isString = me.getIdField().isStringField,
  59298. id;
  59299. id = me.idGenerator.generate();
  59300. obj.setItem(key, id);
  59301. if (isString) {
  59302. id = id + '';
  59303. }
  59304. return id;
  59305. },
  59306. getTreeData: function() {
  59307. var me = this,
  59308. ids = me.getIds(),
  59309. length = ids.length,
  59310. records = [],
  59311. recordHash = {},
  59312. root = [],
  59313. i = 0,
  59314. Model = me.getModel(),
  59315. idProperty = Model.prototype.idProperty,
  59316. rootLength, record, parent, parentId, children, id;
  59317. for (; i < length; i++) {
  59318. id = ids[i];
  59319. record = me.getRecord(id);
  59320. records.push(record);
  59321. recordHash[id] = record;
  59322. if (!record.parentId) {
  59323. root.push(record);
  59324. }
  59325. }
  59326. rootLength = root.length;
  59327. Ext.Array.sort(records, me.sortByParentId);
  59328. for (i = rootLength; i < length; i++) {
  59329. record = records[i];
  59330. parentId = record.parentId;
  59331. if (!parent || parent[idProperty] !== parentId) {
  59332. parent = recordHash[parentId];
  59333. parent.children = children = [];
  59334. }
  59335. children.push(record);
  59336. }
  59337. for (i = length; i--; ) {
  59338. record = records[i];
  59339. if (!record.children && !record.leaf) {
  59340. record.loaded = true;
  59341. }
  59342. }
  59343. for (i = rootLength; i--; ) {
  59344. record = root[i];
  59345. root[i] = new Model(record);
  59346. }
  59347. return root;
  59348. },
  59349. sortByParentId: function(node1, node2) {
  59350. return (node1.parentId || 0) - (node2.parentId || 0);
  59351. },
  59352. initialize: function() {
  59353. var me = this,
  59354. storageObject = me.getStorageObject(),
  59355. lastId = +storageObject.getItem(me.getRecordCounterKey()),
  59356. id = me.getId();
  59357. storageObject.setItem(id, storageObject.getItem(id) || "");
  59358. if (storageObject.getItem(me.getTreeKey())) {
  59359. me.isHierarchical = true;
  59360. }
  59361. me.idGenerator = new Ext.data.identifier.Sequential({
  59362. seed: lastId ? lastId + 1 : 1
  59363. });
  59364. },
  59365. clear: function() {
  59366. var me = this,
  59367. obj = me.getStorageObject(),
  59368. ids = me.getIds(),
  59369. len = ids.length,
  59370. i;
  59371. for (i = 0; i < len; i++) {
  59372. obj.removeItem(me.getRecordKey(ids[i]));
  59373. }
  59374. obj.removeItem(me.getRecordCounterKey());
  59375. obj.removeItem(me.getTreeKey());
  59376. obj.removeItem(me.getId());
  59377. me.cache = {};
  59378. },
  59379. getStorageObject: function() {
  59380. Ext.raise("The getStorageObject function has not been defined in your " + "Ext.data.proxy.WebStorage subclass");
  59381. }
  59382. });
  59383. Ext.define('Ext.data.proxy.LocalStorage', {
  59384. extend: Ext.data.proxy.WebStorage,
  59385. alias: 'proxy.localstorage',
  59386. alternateClassName: 'Ext.data.LocalStorageProxy',
  59387. getStorageObject: function() {
  59388. return window.localStorage;
  59389. }
  59390. });
  59391. Ext.define('Ext.data.proxy.Rest', {
  59392. extend: Ext.data.proxy.Ajax,
  59393. alternateClassName: 'Ext.data.RestProxy',
  59394. alias: 'proxy.rest',
  59395. defaultActionMethods: {
  59396. create: 'POST',
  59397. read: 'GET',
  59398. update: 'PUT',
  59399. destroy: 'DELETE'
  59400. },
  59401. slashRe: /\/$/,
  59402. periodRe: /\.$/,
  59403. config: {
  59404. appendId: true,
  59405. format: null,
  59406. batchActions: false,
  59407. actionMethods: {
  59408. create: 'POST',
  59409. read: 'GET',
  59410. update: 'PUT',
  59411. destroy: 'DELETE'
  59412. }
  59413. },
  59414. buildUrl: function(request) {
  59415. var me = this,
  59416. operation = request.getOperation(),
  59417. records = operation.getRecords(),
  59418. record = records ? records[0] : null,
  59419. format = me.getFormat(),
  59420. url = me.getUrl(request),
  59421. id, params;
  59422. if (record && !record.phantom) {
  59423. id = record.getId();
  59424. } else {
  59425. id = operation.getId();
  59426. }
  59427. if (me.getAppendId() && me.isValidId(id)) {
  59428. if (!url.match(me.slashRe)) {
  59429. url += '/';
  59430. }
  59431. url += encodeURIComponent(id);
  59432. params = request.getParams();
  59433. if (params) {
  59434. delete params[me.getIdParam()];
  59435. }
  59436. }
  59437. if (format) {
  59438. if (!url.match(me.periodRe)) {
  59439. url += '.';
  59440. }
  59441. url += format;
  59442. }
  59443. request.setUrl(url);
  59444. return me.callParent([
  59445. request
  59446. ]);
  59447. },
  59448. isValidId: function(id) {
  59449. return id || id === 0;
  59450. }
  59451. });
  59452. Ext.define('Ext.data.proxy.SessionStorage', {
  59453. extend: Ext.data.proxy.WebStorage,
  59454. alias: 'proxy.sessionstorage',
  59455. alternateClassName: 'Ext.data.SessionStorageProxy',
  59456. getStorageObject: function() {
  59457. return window.sessionStorage;
  59458. }
  59459. });
  59460. Ext.define('Ext.data.summary.Base', {
  59461. mixins: [
  59462. Ext.mixin.Factoryable
  59463. ],
  59464. alias: 'data.summary.base',
  59465. isAggregator: true,
  59466. factoryConfig: {
  59467. defaultType: 'base',
  59468. cacheable: true
  59469. },
  59470. constructor: function(config) {
  59471. var calculate = config && config.calculate;
  59472. if (calculate) {
  59473. config = Ext.apply({}, config);
  59474. delete config.calculate;
  59475. this.calculate = calculate;
  59476. }
  59477. this.initConfig(config);
  59478. },
  59479. extractValue: function(record, property, root) {
  59480. var ret;
  59481. if (record) {
  59482. if (root) {
  59483. record = record[root];
  59484. }
  59485. ret = record[property];
  59486. }
  59487. return ret;
  59488. }
  59489. }, function() {
  59490. Ext.Factory.on('dataSummary', function(factory, config) {
  59491. if (typeof config === 'function') {
  59492. return factory({
  59493. calculate: config
  59494. });
  59495. }
  59496. });
  59497. });
  59498. Ext.define('Ext.data.summary.Sum', {
  59499. extend: Ext.data.summary.Base,
  59500. alias: 'data.summary.sum',
  59501. calculate: function(records, property, root, begin, end) {
  59502. var n = end - begin,
  59503. i, sum, v;
  59504. for (i = 0; i < n; ++i) {
  59505. v = this.extractValue(records[begin + i], property, root);
  59506. sum = i ? sum + v : v;
  59507. }
  59508. return sum;
  59509. }
  59510. });
  59511. Ext.define('Ext.data.summary.Average', {
  59512. extend: Ext.data.summary.Sum,
  59513. alias: 'data.summary.average',
  59514. calculate: function(records, property, root, begin, end) {
  59515. var len = end - begin,
  59516. value;
  59517. if (len > 0) {
  59518. value = this.callParent([
  59519. records,
  59520. property,
  59521. root,
  59522. begin,
  59523. end
  59524. ]) / len;
  59525. }
  59526. return value;
  59527. }
  59528. });
  59529. Ext.define('Ext.data.summary.Count', {
  59530. extend: Ext.data.summary.Base,
  59531. alias: 'data.summary.count',
  59532. calculate: function(records, property, root, begin, end) {
  59533. return end - begin;
  59534. }
  59535. });
  59536. Ext.define('Ext.data.summary.Max', {
  59537. extend: Ext.data.summary.Base,
  59538. alias: 'data.summary.max',
  59539. calculate: function(records, property, root, begin, end) {
  59540. var max = this.extractValue(records[begin], property, root),
  59541. i, v;
  59542. for (i = begin; i < end; ++i) {
  59543. v = this.extractValue(records[i], property, root);
  59544. if (v > max) {
  59545. max = v;
  59546. }
  59547. }
  59548. return max;
  59549. }
  59550. });
  59551. Ext.define('Ext.data.summary.Min', {
  59552. extend: Ext.data.summary.Base,
  59553. alias: 'data.summary.min',
  59554. calculate: function(records, property, root, begin, end) {
  59555. var min = this.extractValue(records[begin], property, root),
  59556. i, v;
  59557. for (i = begin; i < end; ++i) {
  59558. v = this.extractValue(records[i], property, root);
  59559. if (v < min) {
  59560. min = v;
  59561. }
  59562. }
  59563. return min;
  59564. }
  59565. });
  59566. Ext.define('Ext.data.summary.None', {
  59567. extend: Ext.data.summary.Base,
  59568. alias: 'data.summary.none',
  59569. config: {
  59570. value: null
  59571. },
  59572. calculate: function() {
  59573. return this.getValue();
  59574. }
  59575. });
  59576. Ext.define('Ext.data.validator.AbstractDate', {
  59577. extend: Ext.data.validator.Validator,
  59578. config: {
  59579. message: null,
  59580. format: ''
  59581. },
  59582. applyFormat: function(format) {
  59583. if (!format) {
  59584. format = this.getDefaultFormat();
  59585. }
  59586. if (!Ext.isArray(format)) {
  59587. format = [
  59588. format
  59589. ];
  59590. }
  59591. return format;
  59592. },
  59593. parse: function(value) {
  59594. if (Ext.isDate(value)) {
  59595. return value;
  59596. }
  59597. var me = this,
  59598. format = me.getFormat(),
  59599. len = format.length,
  59600. ret = null,
  59601. i;
  59602. for (i = 0; i < len && !ret; ++i) {
  59603. ret = Ext.Date.parse(value, format[i], true);
  59604. }
  59605. return ret;
  59606. },
  59607. validate: function(value) {
  59608. return this.parse(value) ? true : this.getMessage();
  59609. }
  59610. });
  59611. Ext.define('Ext.data.validator.Bound', {
  59612. extend: Ext.data.validator.Validator,
  59613. alias: 'data.validator.bound',
  59614. type: 'bound',
  59615. config: {
  59616. min: undefined,
  59617. max: undefined,
  59618. emptyMessage: 'Must be present',
  59619. minOnlyMessage: 'Value must be greater than {0}',
  59620. maxOnlyMessage: 'Value must be less than {0}',
  59621. bothMessage: 'Value must be between {0} and {1}'
  59622. },
  59623. resetMessages: function() {
  59624. this._bothMsg = this._minMsg = this._maxMsg = null;
  59625. },
  59626. updateMin: function() {
  59627. this.resetMessages();
  59628. },
  59629. updateMax: function() {
  59630. this.resetMessages();
  59631. },
  59632. updateMinOnlyMessage: function() {
  59633. this.resetMessages();
  59634. },
  59635. updateMaxOnlyMessage: function() {
  59636. this.resetMessages();
  59637. },
  59638. updateBothMessage: function() {
  59639. this.resetMessages();
  59640. },
  59641. validate: function(value) {
  59642. var me = this,
  59643. min = me.getMin(),
  59644. max = me.getMax(),
  59645. hasMin = (min != null),
  59646. hasMax = (max != null),
  59647. msg = this.validateValue(value);
  59648. if (msg !== true) {
  59649. return msg;
  59650. }
  59651. value = me.getValue(value);
  59652. if (hasMin && hasMax) {
  59653. if (value < min || value > max) {
  59654. msg = me._bothMsg || (me._bothMsg = Ext.String.format(me.getBothMessage(), min, max));
  59655. }
  59656. } else if (hasMin) {
  59657. if (value < min) {
  59658. msg = me._minMsg || (me._minMsg = Ext.String.format(me.getMinOnlyMessage(), min));
  59659. }
  59660. } else if (hasMax) {
  59661. if (value > max) {
  59662. msg = me._maxMsg || (me._maxMsg = Ext.String.format(me.getMaxOnlyMessage(), max));
  59663. }
  59664. }
  59665. return msg;
  59666. },
  59667. validateValue: function(value) {
  59668. if (value === undefined || value === null) {
  59669. return this.getEmptyMessage();
  59670. }
  59671. return true;
  59672. },
  59673. getValue: Ext.identityFn
  59674. });
  59675. Ext.define('Ext.data.validator.Format', {
  59676. extend: Ext.data.validator.Validator,
  59677. alias: 'data.validator.format',
  59678. type: 'format',
  59679. config: {
  59680. message: 'Is in the wrong format',
  59681. matcher: undefined
  59682. },
  59683. constructor: function() {
  59684. this.callParent(arguments);
  59685. if (!this.getMatcher()) {
  59686. Ext.raise('validator.Format must be configured with a matcher');
  59687. }
  59688. },
  59689. validate: function(value) {
  59690. var matcher = this.getMatcher(),
  59691. result = matcher && matcher.test(value);
  59692. return result ? result : this.getMessage();
  59693. }
  59694. });
  59695. Ext.define('Ext.data.validator.CIDRv4', {
  59696. extend: Ext.data.validator.Format,
  59697. alias: 'data.validator.cidrv4',
  59698. type: 'cidrv4',
  59699. message: 'Is not a valid CIDR block',
  59700. matcher: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/
  59701. });
  59702. Ext.define('Ext.data.validator.CIDRv6', {
  59703. extend: Ext.data.validator.Format,
  59704. alias: 'data.validator.cidrv6',
  59705. type: 'cidrv6',
  59706. message: 'Is not a valid CIDR block',
  59707. matcher: /^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/
  59708. });
  59709. Ext.define('Ext.data.validator.Number', {
  59710. extend: Ext.data.validator.Validator,
  59711. alias: 'data.validator.number',
  59712. type: 'number',
  59713. config: {
  59714. decimalSeparator: undefined,
  59715. message: 'Is not a valid number',
  59716. thousandSeparator: undefined
  59717. },
  59718. constructor: function(config) {
  59719. this.callParent([
  59720. config
  59721. ]);
  59722. this.rebuildMatcher();
  59723. },
  59724. applyDecimalSeparator: function(v) {
  59725. return v === undefined ? Ext.util.Format.decimalSeparator : v;
  59726. },
  59727. updateDecimalSeparator: function() {
  59728. this.rebuildMatcher();
  59729. },
  59730. applyThousandSeparator: function(v) {
  59731. return v === undefined ? Ext.util.Format.thousandSeparator : v;
  59732. },
  59733. updateThousandSeparator: function() {
  59734. this.rebuildMatcher();
  59735. },
  59736. parse: function(v) {
  59737. var sep = this.getDecimalSeparator(),
  59738. N = Ext.Number;
  59739. if (typeof v === 'string') {
  59740. if (!this.matcher.test(v)) {
  59741. return null;
  59742. }
  59743. v = this.parseValue(v);
  59744. }
  59745. return sep ? N.parseFloat(v) : N.parseInt(v);
  59746. },
  59747. validate: function(value) {
  59748. return this.parse(value) === null ? this.getMessage() : true;
  59749. },
  59750. privates: {
  59751. getMatcherText: function(preventSign) {
  59752. var t = this.getThousandSeparator(),
  59753. d = this.getDecimalSeparator(),
  59754. s = '(?:';
  59755. if (t) {
  59756. t = Ext.String.escapeRegex(t);
  59757. s += '(?:\\d{1,3}(' + t + '\\d{3})*)|';
  59758. }
  59759. s += '\\d*)';
  59760. if (d) {
  59761. d = Ext.String.escapeRegex(d);
  59762. s += '(?:' + d + '\\d*)?';
  59763. }
  59764. if (!preventSign) {
  59765. s = this.getSignPart() + s;
  59766. }
  59767. return s;
  59768. },
  59769. getSignPart: function() {
  59770. return '(\\+|\\-)?';
  59771. },
  59772. parseValue: function(v) {
  59773. var thousandMatcher = this.thousandMatcher,
  59774. decimal;
  59775. if (thousandMatcher) {
  59776. v = v.replace(thousandMatcher, '');
  59777. }
  59778. decimal = this.getDecimalSeparator();
  59779. if (decimal && decimal !== '.') {
  59780. v = v.replace(decimal, '.');
  59781. }
  59782. return v;
  59783. },
  59784. rebuildMatcher: function() {
  59785. var me = this,
  59786. sep;
  59787. if (!me.isConfiguring) {
  59788. sep = me.getThousandSeparator();
  59789. me.matcher = new RegExp('^' + me.getMatcherText() + '$');
  59790. if (sep) {
  59791. me.thousandMatcher = sep ? new RegExp(Ext.String.escapeRegex(sep), 'g') : null;
  59792. }
  59793. }
  59794. }
  59795. }
  59796. });
  59797. Ext.define('Ext.data.validator.Currency', {
  59798. extend: Ext.data.validator.Number,
  59799. alias: 'data.validator.currency',
  59800. type: 'currency',
  59801. config: {
  59802. symbolAtEnd: undefined,
  59803. spacer: undefined,
  59804. symbol: undefined
  59805. },
  59806. message: 'Is not a valid currency amount',
  59807. applySymbolAtEnd: function(value) {
  59808. return value === undefined ? Ext.util.Format.currencyAtEnd : value;
  59809. },
  59810. updateSymbolAtEnd: function() {
  59811. this.rebuildMatcher();
  59812. },
  59813. applySpacer: function(value) {
  59814. return value === undefined ? Ext.util.Format.currencySpacer : value;
  59815. },
  59816. updateSpacer: function() {
  59817. this.rebuildMatcher();
  59818. },
  59819. applySymbol: function(value) {
  59820. return value === undefined ? Ext.util.Format.currencySign : value;
  59821. },
  59822. updateSymbol: function() {
  59823. this.rebuildMatcher();
  59824. },
  59825. privates: {
  59826. getMatcherText: function() {
  59827. var me = this,
  59828. ret = me.callParent([
  59829. true
  59830. ]),
  59831. symbolPart = me.getSymbolMatcher();
  59832. if (me.getSymbolAtEnd()) {
  59833. ret += symbolPart;
  59834. } else {
  59835. ret = symbolPart + ret;
  59836. }
  59837. return me.getSignPart() + ret;
  59838. },
  59839. getSymbolMatcher: function() {
  59840. var symbol = Ext.String.escapeRegex(this.getSymbol()),
  59841. spacer = Ext.String.escapeRegex(this.getSpacer() || ''),
  59842. s = this.getSymbolAtEnd() ? (spacer + symbol) : (symbol + spacer);
  59843. return '(?:' + s + ')?';
  59844. },
  59845. parseValue: function(v) {
  59846. v = v.replace(this.currencyMatcher, this.atEnd ? '' : '$1');
  59847. return this.callParent([
  59848. v
  59849. ]);
  59850. },
  59851. rebuildMatcher: function() {
  59852. var me = this,
  59853. symbolPart, atEnd, sign;
  59854. me.callParent();
  59855. if (!me.isConfiguring) {
  59856. atEnd = me.getSymbolAtEnd();
  59857. symbolPart = me.getSymbolMatcher();
  59858. sign = me.getSignPart();
  59859. me.atEnd = atEnd;
  59860. me.currencyMatcher = new RegExp(atEnd ? (symbolPart + '$') : ('^' + sign + symbolPart));
  59861. }
  59862. }
  59863. }
  59864. });
  59865. Ext.define('Ext.data.validator.CurrencyUS', {
  59866. extend: Ext.data.validator.Currency,
  59867. alias: 'data.validator.currency-us',
  59868. type: 'currency-us',
  59869. thousandSeparator: ',',
  59870. decimalSeparator: '.',
  59871. symbol: '$',
  59872. spacer: '',
  59873. symbolAtEnd: false
  59874. });
  59875. Ext.define('Ext.data.validator.Date', {
  59876. extend: Ext.data.validator.AbstractDate,
  59877. alias: 'data.validator.date',
  59878. type: 'date',
  59879. isDateValidator: true,
  59880. message: 'Is not a valid date',
  59881. privates: {
  59882. getDefaultFormat: function() {
  59883. return [
  59884. Ext.Date.defaultFormat,
  59885. 'm/d/Y',
  59886. 'n/j/Y',
  59887. 'n/j/y',
  59888. 'm/j/y',
  59889. 'n/d/y',
  59890. 'm/j/Y',
  59891. 'n/d/Y',
  59892. 'm-d-y',
  59893. 'n-d-y',
  59894. 'm-d-Y',
  59895. 'mdy',
  59896. 'mdY',
  59897. 'Y-m-d'
  59898. ];
  59899. }
  59900. }
  59901. });
  59902. Ext.define('Ext.data.validator.DateTime', {
  59903. extend: Ext.data.validator.AbstractDate,
  59904. alias: 'data.validator.datetime',
  59905. type: 'datetime',
  59906. isDateTimeValidator: true,
  59907. message: 'Is not a valid date and time',
  59908. privates: {
  59909. getDefaultFormat: function() {
  59910. var D = Ext.Date;
  59911. return D.defaultFormat + ' ' + D.defaultTimeFormat;
  59912. }
  59913. }
  59914. });
  59915. Ext.define('Ext.data.validator.Email', {
  59916. extend: Ext.data.validator.Format,
  59917. alias: 'data.validator.email',
  59918. type: 'email',
  59919. message: 'Is not a valid email address',
  59920. matcher: /^(")?(?:[^\."])(?:(?:[\.])?(?:[\w\-!#$%&'*+\/=?\^_`{|}~]))*\1@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/
  59921. });
  59922. Ext.define('Ext.data.validator.List', {
  59923. extend: Ext.data.validator.Validator,
  59924. alias: 'data.validator.list',
  59925. type: 'list',
  59926. config: {
  59927. list: null,
  59928. message: null
  59929. },
  59930. inclusion: null,
  59931. validate: function(value) {
  59932. var contains = Ext.Array.contains(this.getList(), value),
  59933. inclusion = this.inclusion,
  59934. exclusion = !inclusion,
  59935. result;
  59936. result = (inclusion && contains) || (exclusion && !contains);
  59937. return result || this.getMessage();
  59938. }
  59939. });
  59940. Ext.define('Ext.data.validator.Exclusion', {
  59941. extend: Ext.data.validator.List,
  59942. alias: 'data.validator.exclusion',
  59943. type: 'exclusion',
  59944. message: 'Is a value that has been excluded',
  59945. constructor: function() {
  59946. this.callParent(arguments);
  59947. if (!this.getList()) {
  59948. Ext.raise('validator.Exclusion requires a list');
  59949. }
  59950. },
  59951. inclusion: false
  59952. });
  59953. Ext.define('Ext.data.validator.IPAddress', {
  59954. extend: Ext.data.validator.Format,
  59955. alias: 'data.validator.ipaddress',
  59956. type: 'ipaddress',
  59957. message: 'Is not a valid IP address',
  59958. matcher: new RegExp('^(' +
  59959. '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + '|' +
  59960. '((([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])))' + ')$')
  59961. });
  59962. Ext.define('Ext.data.validator.Inclusion', {
  59963. extend: Ext.data.validator.List,
  59964. alias: 'data.validator.inclusion',
  59965. type: 'inclusion',
  59966. message: 'Is not in the list of acceptable values',
  59967. constructor: function() {
  59968. this.callParent(arguments);
  59969. if (!this.getList()) {
  59970. Ext.raise('validator.Inclusion requires a list');
  59971. }
  59972. },
  59973. inclusion: true
  59974. });
  59975. Ext.define('Ext.data.validator.Length', {
  59976. extend: Ext.data.validator.Bound,
  59977. alias: 'data.validator.length',
  59978. type: 'length',
  59979. minOnlyMessage: 'Length must be at least {0}',
  59980. maxOnlyMessage: 'Length must be no more than {0}',
  59981. bothMessage: 'Length must be between {0} and {1}',
  59982. getValue: function(v) {
  59983. return String(v).length;
  59984. }
  59985. });
  59986. Ext.define('Ext.data.validator.Presence', {
  59987. extend: Ext.data.validator.Validator,
  59988. alias: 'data.validator.presence',
  59989. type: 'presence',
  59990. isPresence: true,
  59991. config: {
  59992. message: 'Must be present',
  59993. allowEmpty: false
  59994. },
  59995. validate: function(value) {
  59996. var valid = !(value === undefined || value === null);
  59997. if (valid && !this.getAllowEmpty()) {
  59998. valid = value !== '';
  59999. }
  60000. return valid ? true : this.getMessage();
  60001. }
  60002. });
  60003. Ext.define('Ext.data.validator.NotNull', {
  60004. extend: Ext.data.validator.Presence,
  60005. alias: 'data.validator.notnull',
  60006. type: 'notnull',
  60007. allowEmpty: true
  60008. });
  60009. Ext.define('Ext.data.validator.Phone', {
  60010. extend: Ext.data.validator.Format,
  60011. alias: 'data.validator.phone',
  60012. type: 'phone',
  60013. message: 'Is not a valid phone number',
  60014. matcher: new RegExp('^ *' +
  60015. '(?:' + '\\+?' +
  60016. '(\\d{1,3})' +
  60017. '[- .]?' + ')?' +
  60018. '(?:' + '(?:' + '(\\d{3})' +
  60019. '|' + '\\((\\d{3})\\)' +
  60020. ')?' +
  60021. '[- .]?' + ')' +
  60022. '(?:' + '([2-9]\\d{2})' +
  60023. '[- .]?' + ')' +
  60024. '(\\d{4})' +
  60025. '(?: *(?:e?xt?) *(\\d*))?' + ' *$')
  60026. });
  60027. Ext.define('Ext.data.validator.Range', {
  60028. extend: Ext.data.validator.Bound,
  60029. alias: 'data.validator.range',
  60030. type: 'range',
  60031. minOnlyMessage: 'Must be at least {0}',
  60032. maxOnlyMessage: 'Must be no more than than {0}',
  60033. bothMessage: 'Must be between {0} and {1}',
  60034. config: {
  60035. nanMessage: 'Must be numeric'
  60036. },
  60037. validateValue: function(value) {
  60038. var msg = this.callParent([
  60039. value
  60040. ]);
  60041. if (msg === true && isNaN(value)) {
  60042. msg = this.getNanMessage();
  60043. }
  60044. return msg;
  60045. }
  60046. });
  60047. Ext.define('Ext.data.validator.Time', {
  60048. extend: Ext.data.validator.AbstractDate,
  60049. alias: 'data.validator.time',
  60050. type: 'time',
  60051. isTimeValidator: true,
  60052. message: 'Is not a valid time',
  60053. privates: {
  60054. getDefaultFormat: function() {
  60055. return Ext.Date.defaultTimeFormat;
  60056. }
  60057. }
  60058. });
  60059. Ext.define('Ext.data.validator.Url', {
  60060. extend: Ext.data.validator.Format,
  60061. alias: 'data.validator.url',
  60062. type: 'url',
  60063. message: 'Is not a valid URL',
  60064. matcher: /^(http:\/\/|https:\/\/|ftp:\/\/|\/\/)([-a-zA-Z0-9@:%_\+.~#?&//=])+$/
  60065. });
  60066. Ext.define('Ext.data.virtual.Group', {
  60067. isVirtualGroup: true,
  60068. firstRecords: null,
  60069. id: '',
  60070. summaryRecord: null,
  60071. constructor: function(key) {
  60072. this.id = key;
  60073. this.firstRecords = [];
  60074. },
  60075. first: function() {
  60076. return this.firstRecords[0] || null;
  60077. },
  60078. getGroupKey: function() {
  60079. return this.id;
  60080. },
  60081. getSummaryRecord: function() {
  60082. return this.summaryRecord;
  60083. }
  60084. });
  60085. Ext.define('Ext.data.virtual.Page', {
  60086. isVirtualPage: true,
  60087. begin: 0,
  60088. end: 0,
  60089. error: null,
  60090. locked: null,
  60091. number: 0,
  60092. operation: null,
  60093. pageMap: null,
  60094. records: null,
  60095. state: null,
  60096. constructor: function(config) {
  60097. var me = this,
  60098. pageSize;
  60099. Ext.apply(me, config);
  60100. pageSize = me.pageMap.store.getPageSize();
  60101. me.begin = me.number * pageSize;
  60102. me.end = me.begin + pageSize;
  60103. me.locks = {
  60104. active: 0,
  60105. prefetch: 0
  60106. };
  60107. },
  60108. destroy: function() {
  60109. var me = this,
  60110. operation = me.operation;
  60111. me.state = 'destroyed';
  60112. if (operation) {
  60113. operation.abort();
  60114. }
  60115. me.callParent();
  60116. },
  60117. adjustLock: function(kind, delta) {
  60118. var me = this,
  60119. locks = me.locks,
  60120. pageMap = me.pageMap,
  60121. locked = null,
  60122. lockedWas = me.locked;
  60123. if (!(kind in locks)) {
  60124. Ext.raise('Bad lock type (expected "active" or "prefetch"): "' + kind + '"');
  60125. }
  60126. if (delta !== 1 && delta !== -1) {
  60127. Ext.raise('Invalid lock count delta (should be 1 or -1): ' + delta);
  60128. }
  60129. locks[kind] += delta;
  60130. if (locks.active) {
  60131. locked = 'active';
  60132. } else if (locks.prefetch) {
  60133. locked = 'prefetch';
  60134. }
  60135. if (locked !== lockedWas) {
  60136. me.locked = locked;
  60137. if (pageMap) {
  60138. pageMap.onPageLockChange(me, locked, lockedWas);
  60139. }
  60140. }
  60141. },
  60142. clearRecords: function(out, by) {
  60143. var me = this,
  60144. begin = me.begin,
  60145. records = me.records,
  60146. i, n;
  60147. if (records) {
  60148. n = records.length;
  60149. if (by) {
  60150. for (i = 0; i < n; ++i) {
  60151. delete out[records[i][by]];
  60152. }
  60153. } else {
  60154. for (i = 0; i < n; ++i) {
  60155. delete out[begin + i];
  60156. }
  60157. }
  60158. }
  60159. },
  60160. fillRecords: function(out, by, withIndex) {
  60161. var me = this,
  60162. records = me.records,
  60163. begin = me.begin,
  60164. store = me.pageMap.store,
  60165. i, n, record;
  60166. if (records) {
  60167. n = records.length;
  60168. if (by) {
  60169. for (i = 0; i < n; ++i) {
  60170. record = records[i];
  60171. record.join(store);
  60172. out[record[by]] = withIndex ? begin + i : record;
  60173. }
  60174. } else {
  60175. for (i = 0; i < n; ++i) {
  60176. records[i].join(store);
  60177. out[begin + i] = records[i];
  60178. }
  60179. }
  60180. }
  60181. },
  60182. isInitial: function() {
  60183. return this.state === null;
  60184. },
  60185. isLoaded: function() {
  60186. return this.state === 'loaded';
  60187. },
  60188. isLoading: function() {
  60189. return this.state === 'loading';
  60190. },
  60191. load: function() {
  60192. var me = this,
  60193. operation;
  60194. me.state = 'loading';
  60195. operation = me.pageMap.store.loadVirtualPage(me, me.onLoad, me);
  60196. if (me.state === 'loading') {
  60197. me.operation = operation;
  60198. }
  60199. },
  60200. privates: {
  60201. onLoad: function(operation) {
  60202. var me = this;
  60203. me.operation = null;
  60204. if (!me.destroyed) {
  60205. if (!(me.error = operation.getError())) {
  60206. me.records = operation.getRecords();
  60207. me.state = 'loaded';
  60208. } else {
  60209. me.state = 'error';
  60210. }
  60211. me.pageMap.onPageLoad(me);
  60212. }
  60213. }
  60214. }
  60215. });
  60216. Ext.define('Ext.data.virtual.PageMap', {
  60217. isVirtualPageMap: true,
  60218. config: {
  60219. cacheSize: 10,
  60220. concurrentLoading: 1,
  60221. pageCount: null
  60222. },
  60223. generation: 0,
  60224. store: null,
  60225. constructor: function(config) {
  60226. var me = this;
  60227. me.prefetchSortFn = me.prefetchSortFn.bind(me);
  60228. me.initConfig(config);
  60229. me.clear();
  60230. },
  60231. destroy: function() {
  60232. this.clear(true);
  60233. this.callParent();
  60234. },
  60235. canSatisfy: function(range) {
  60236. var end = this.getPageIndex(range.end),
  60237. pageCount = this.getPageCount();
  60238. return pageCount === null || end < pageCount;
  60239. },
  60240. clear: function(destroy) {
  60241. var me = this,
  60242. alive = !destroy || null,
  60243. pages = me.pages,
  60244. pg;
  60245. ++me.generation;
  60246. me.byId = alive && {};
  60247. me.byInternalId = alive && {};
  60248. me.cache = alive && [];
  60249. me.indexMap = alive && {};
  60250. me.pages = alive && {};
  60251. me.loading = alive && [];
  60252. me.loadQueues = alive && {
  60253. active: [],
  60254. prefetch: []
  60255. };
  60256. if (pages) {
  60257. for (pg in pages) {
  60258. me.destroyPage(pages[pg]);
  60259. }
  60260. }
  60261. },
  60262. getPage: function(number, autoCreate) {
  60263. var me = this,
  60264. pageCount = me.getPageCount(),
  60265. pages = me.pages,
  60266. page;
  60267. if (pageCount === null || number < pageCount) {
  60268. page = pages[number];
  60269. if (!page && autoCreate !== false) {
  60270. pages[number] = page = new Ext.data.virtual.Page({
  60271. pageMap: me,
  60272. number: number
  60273. });
  60274. }
  60275. } else
  60276. {
  60277. Ext.raise('Invalid page number ' + number + ' when limit is ' + pageCount);
  60278. }
  60279. return page || null;
  60280. },
  60281. getPageIndex: function(index) {
  60282. if (index.isEntity) {
  60283. index = this.indexOf(index);
  60284. }
  60285. return Math.floor(index / this.store.getPageSize());
  60286. },
  60287. getPageOf: function(index, autoCreate) {
  60288. var pageSize = this.store.getPageSize(),
  60289. n = Math.floor(index / pageSize);
  60290. return this.getPage(n, autoCreate);
  60291. },
  60292. getPages: function(begin, end) {
  60293. var pageSize = this.store.getPageSize(),
  60294. first = Math.floor(begin / pageSize),
  60295. last = Math.ceil(end / pageSize),
  60296. ret = {},
  60297. n;
  60298. for (n = first; n < last; ++n) {
  60299. ret[n] = this.getPage(n);
  60300. }
  60301. return ret;
  60302. },
  60303. flushNextLoad: function() {
  60304. var me = this,
  60305. queueTimer = me.queueTimer;
  60306. if (queueTimer) {
  60307. Ext.unasap(queueTimer);
  60308. }
  60309. me.loadNext();
  60310. },
  60311. indexOf: function(record) {
  60312. var ret;
  60313. if (record) {
  60314. ret = this.indexMap[record.internalId];
  60315. }
  60316. return (ret || ret === 0) ? ret : -1;
  60317. },
  60318. getByInternalId: function(internalId) {
  60319. var index = this.indexMap[internalId],
  60320. page;
  60321. if (index || index === 0) {
  60322. page = this.pages[Math.floor(index / this.store.getPageSize())];
  60323. if (page) {
  60324. return page.records[index - page.begin];
  60325. }
  60326. }
  60327. },
  60328. updatePageCount: function(pageCount, oldPageCount) {
  60329. var pages = this.pages,
  60330. pageNumber, page;
  60331. if (oldPageCount === null || pageCount < oldPageCount) {
  60332. for (pageNumber in pages) {
  60333. page = pages[pageNumber];
  60334. if (page.number >= pageCount) {
  60335. this.clearPage(page);
  60336. this.destroyPage(page);
  60337. }
  60338. }
  60339. }
  60340. },
  60341. privates: {
  60342. queueTimer: null,
  60343. clearPage: function(page, fromCache) {
  60344. var me = this,
  60345. A = Ext.Array,
  60346. loadQueues = me.loadQueues;
  60347. delete me.pages[page.number];
  60348. page.clearRecords(me.byId, 'id');
  60349. page.clearRecords(me.byInternalId, 'internalId');
  60350. page.clearRecords(me.indexMap, 'internalId');
  60351. A.remove(loadQueues.active, page);
  60352. A.remove(loadQueues.prefetch, page);
  60353. if (!fromCache) {
  60354. Ext.Array.remove(me.cache, page);
  60355. }
  60356. },
  60357. destroyPage: function(page) {
  60358. this.store.onPageDestroy(page);
  60359. page.destroy();
  60360. },
  60361. loadNext: function() {
  60362. var me = this,
  60363. concurrency = me.getConcurrentLoading(),
  60364. loading = me.loading,
  60365. loadQueues = me.loadQueues,
  60366. page;
  60367. me.queueTimer = null;
  60368. while (loading.length < concurrency) {
  60369. if (!(page = loadQueues.active.shift() || loadQueues.prefetch.shift())) {
  60370. break;
  60371. }
  60372. loading.push(page);
  60373. page.load();
  60374. }
  60375. },
  60376. onPageLoad: function(page) {
  60377. var me = this,
  60378. store = me.store,
  60379. activeRanges = store.activeRanges,
  60380. n = activeRanges.length,
  60381. i;
  60382. Ext.Array.remove(me.loading, page);
  60383. if (!page.error) {
  60384. page.fillRecords(me.byId, 'id');
  60385. page.fillRecords(me.byInternalId, 'internalId');
  60386. page.fillRecords(me.indexMap, 'internalId', true);
  60387. store.onPageDataAcquired(page);
  60388. for (i = 0; i < n; ++i) {
  60389. activeRanges[i].onPageLoad(page);
  60390. }
  60391. }
  60392. me.flushNextLoad();
  60393. },
  60394. onPageLockChange: function(page, state, oldState) {
  60395. var me = this,
  60396. cache = me.cache,
  60397. loadQueues = me.loadQueues,
  60398. store = me.store,
  60399. cacheSize, concurrency;
  60400. if (page.isInitial()) {
  60401. if (oldState) {
  60402. Ext.Array.remove(loadQueues[oldState], page);
  60403. }
  60404. if (state) {
  60405. loadQueues[state].push(page);
  60406. concurrency = me.getConcurrentLoading();
  60407. if (!me.queueTimer && me.loading.length < concurrency) {
  60408. me.queueTimer = Ext.asap(me.loadNext, me);
  60409. }
  60410. }
  60411. }
  60412. if (state) {
  60413. if (!oldState) {
  60414. Ext.Array.remove(cache, page);
  60415. }
  60416. } else {
  60417. cache.push(page);
  60418. for (cacheSize = me.getCacheSize(); cache.length > cacheSize; ) {
  60419. page = cache.shift();
  60420. me.clearPage(page, true);
  60421. store.onPageEvicted(page);
  60422. me.destroyPage(page);
  60423. }
  60424. }
  60425. },
  60426. prefetchSortFn: function(a, b) {
  60427. a = a.number;
  60428. b = b.number;
  60429. var M = Math,
  60430. firstPage = this.sortFirstPage,
  60431. lastPage = this.sortLastPage,
  60432. direction = this.sortDirection,
  60433. aDir = a < firstPage,
  60434. bDir = b < firstPage,
  60435. ret;
  60436. a = aDir ? M.abs(firstPage - a) : M.abs(lastPage - a);
  60437. b = bDir ? M.abs(firstPage - b) : M.abs(lastPage - b);
  60438. if (a === b) {
  60439. ret = aDir ? direction : -direction;
  60440. } else {
  60441. ret = a - b;
  60442. }
  60443. return ret;
  60444. },
  60445. prioritizePrefetch: function(direction, firstPage, lastPage) {
  60446. var me = this;
  60447. me.sortDirection = direction;
  60448. me.sortFirstPage = firstPage;
  60449. me.sortLastPage = lastPage;
  60450. me.loadQueues.prefetch.sort(me.prefetchSortFn);
  60451. }
  60452. }
  60453. });
  60454. Ext.define('Ext.data.virtual.Range', {
  60455. extend: Ext.data.Range,
  60456. isVirtualRange: true,
  60457. callback: null,
  60458. prefetch: false,
  60459. scope: null,
  60460. direction: 1,
  60461. constructor: function(config) {
  60462. this.adjustingPages = [];
  60463. this.callParent([
  60464. config
  60465. ]);
  60466. },
  60467. reset: function() {
  60468. var me = this;
  60469. me.records = {};
  60470. me.activePages = me.prefetchPages = null;
  60471. },
  60472. privates: {
  60473. adjustPageLocks: function(kind, adjustment) {
  60474. var me = this,
  60475. pages = me.adjustingPages,
  60476. n = pages.length,
  60477. i;
  60478. if (n > 1) {
  60479. pages.sort(me.direction < 0 ? me.pageSortBackFn : me.pageSortFwdFn);
  60480. }
  60481. for (i = 0; i < n; ++i) {
  60482. pages[i].adjustLock(kind, adjustment);
  60483. }
  60484. pages.length = 0;
  60485. },
  60486. doGoto: function() {
  60487. var me = this,
  60488. begin = me.begin,
  60489. end = me.end,
  60490. prefetch = me.prefetch,
  60491. records = me.records,
  60492. store = me.store,
  60493. pageMap = store.pageMap,
  60494. limit = store.totalCount,
  60495. beginWas = me.lastBegin,
  60496. endWas = me.lastEnd,
  60497. activePagesWas = me.activePages,
  60498. prefetchPagesWas = me.prefetchPages,
  60499. beginBufferZone = me.trailingBufferZone,
  60500. endBufferZone = me.leadingBufferZone,
  60501. adjustingPages = me.adjustingPages,
  60502. activePages, page, pg, direction, prefetchBegin, prefetchEnd, prefetchPages;
  60503. if (limit === 0) {
  60504. return;
  60505. }
  60506. adjustingPages.length = 0;
  60507. if ((begin > beginWas && end < endWas) || (begin < beginWas && end > endWas)) {
  60508. direction = me.direction;
  60509. } else {
  60510. direction = (begin < beginWas) ? -1 : ((begin > beginWas) ? 1 : me.direction);
  60511. }
  60512. if (direction < 0) {
  60513. pg = beginBufferZone;
  60514. beginBufferZone = endBufferZone;
  60515. endBufferZone = pg;
  60516. }
  60517. me.direction = direction;
  60518. me.activePages = activePages = pageMap.getPages(begin, end);
  60519. if (prefetch) {
  60520. me.prefetchBegin = prefetchBegin = Math.max(0, begin - beginBufferZone);
  60521. if (limit === null) {
  60522. limit = Number.MAX_VALUE;
  60523. }
  60524. me.prefetchEnd = prefetchEnd = Math.min(limit, end + endBufferZone);
  60525. me.prefetchPages = prefetchPages = pageMap.getPages(prefetchBegin, prefetchEnd);
  60526. }
  60527. for (pg in activePages) {
  60528. page = activePages[pg];
  60529. if (prefetchPages) {
  60530. delete prefetchPages[pg];
  60531. }
  60532. if (activePagesWas && pg in activePagesWas) {
  60533. delete activePagesWas[pg];
  60534. } else {
  60535. page.adjustLock('active', 1);
  60536. page.fillRecords(records);
  60537. }
  60538. }
  60539. if (prefetchPages) {
  60540. for (pg in prefetchPages) {
  60541. if (prefetchPagesWas && pg in prefetchPagesWas) {
  60542. delete prefetchPagesWas[pg];
  60543. } else {
  60544. prefetchPages[pg].adjustLock('prefetch', 1);
  60545. }
  60546. }
  60547. }
  60548. if (prefetchPagesWas) {
  60549. for (pg in prefetchPagesWas) {
  60550. adjustingPages.push(prefetchPagesWas[pg]);
  60551. }
  60552. if (adjustingPages.length) {
  60553. me.adjustPageLocks('prefetch', -1);
  60554. }
  60555. }
  60556. if (activePagesWas) {
  60557. for (pg in activePagesWas) {
  60558. adjustingPages.push(page = activePagesWas[pg]);
  60559. page.clearRecords(records);
  60560. }
  60561. if (adjustingPages.length) {
  60562. me.adjustPageLocks('active', -1);
  60563. }
  60564. }
  60565. if (prefetchPages) {
  60566. pageMap.prioritizePrefetch(direction, pageMap.getPageIndex(begin), pageMap.getPageIndex(end - 1));
  60567. }
  60568. me.lastBegin = begin;
  60569. me.lastEnd = end;
  60570. },
  60571. onPageDestroy: function(page) {
  60572. var n = page.number,
  60573. activePages = this.activePages,
  60574. prefetchPages = this.prefetchPages;
  60575. if (activePages) {
  60576. delete activePages[n];
  60577. }
  60578. if (prefetchPages) {
  60579. delete prefetchPages[n];
  60580. }
  60581. },
  60582. onPageLoad: function(page) {
  60583. var me = this,
  60584. callback = me.callback,
  60585. first, last;
  60586. if (me.activePages[page.number]) {
  60587. page.fillRecords(me.records);
  60588. if (callback) {
  60589. first = Math.max(me.begin, page.begin);
  60590. last = Math.min(me.end, page.end);
  60591. Ext.callback(callback, me.scope, [
  60592. me,
  60593. first,
  60594. last
  60595. ]);
  60596. }
  60597. }
  60598. },
  60599. pageSortBackFn: function(page1, page2) {
  60600. return page2.number - page1.number;
  60601. },
  60602. pageSortFwdFn: function(page1, page2) {
  60603. return page1.number - page2.number;
  60604. },
  60605. refresh: function() {
  60606. this.records = this.records || {};
  60607. },
  60608. reload: function() {
  60609. var me = this,
  60610. begin = me.begin,
  60611. end = me.end;
  60612. me.begin = me.end = 0;
  60613. me.direction = 1;
  60614. me.prefetchPages = me.activePages = null;
  60615. me.goto(begin, end);
  60616. }
  60617. }
  60618. });
  60619. Ext.define('Ext.data.virtual.Store', {
  60620. extend: Ext.data.ProxyStore,
  60621. alias: 'store.virtual',
  60622. isVirtualStore: true,
  60623. config: {
  60624. data: null,
  60625. totalCount: null,
  60626. leadingBufferZone: 200,
  60627. trailingBufferZone: 50
  60628. },
  60629. remoteSort: true,
  60630. remoteFilter: true,
  60631. sortOnLoad: false,
  60632. trackRemoved: false,
  60633. constructor: function(config) {
  60634. var me = this;
  60635. me.sortByPage = me.sortByPage.bind(me);
  60636. me.activeRanges = [];
  60637. me.pageMap = new Ext.data.virtual.PageMap({
  60638. store: me
  60639. });
  60640. me.callParent([
  60641. config
  60642. ]);
  60643. },
  60644. doDestroy: function() {
  60645. this.pageMap.destroy();
  60646. this.callParent();
  60647. },
  60648. applyGrouper: function(grouper) {
  60649. this.group(grouper);
  60650. return this.grouper;
  60651. },
  60652. contains: function(record) {
  60653. return this.indexOf(record) > -1;
  60654. },
  60655. createActiveRange: function(config) {
  60656. var range = Ext.apply({
  60657. leadingBufferZone: this.getLeadingBufferZone(),
  60658. trailingBufferZone: this.getTrailingBufferZone(),
  60659. store: this
  60660. }, config);
  60661. return new Ext.data.virtual.Range(range);
  60662. },
  60663. getAt: function(index) {
  60664. var page = this.pageMap.getPageOf(index,
  60665. false),
  60666. ret;
  60667. if (page && page.records) {
  60668. ret = page.records[index - page.begin];
  60669. }
  60670. return ret || null;
  60671. },
  60672. getById: function(id) {
  60673. return this.pageMap.byId[id] || null;
  60674. },
  60675. getCount: function() {
  60676. return this.totalCount || 0;
  60677. },
  60678. getGrouper: function() {
  60679. return this.grouper;
  60680. },
  60681. getGroups: function() {
  60682. var me = this,
  60683. groups = me.groupCollection;
  60684. if (!groups) {
  60685. me.groupCollection = groups = new Ext.util.Collection();
  60686. }
  60687. return groups;
  60688. },
  60689. getSummaryRecord: function() {
  60690. return this.summaryRecord || null;
  60691. },
  60692. isGrouped: function() {
  60693. return !!this.grouper;
  60694. },
  60695. group: function(grouper, direction) {
  60696. var me = this;
  60697. grouper = grouper || null;
  60698. if (grouper) {
  60699. if (typeof grouper === 'string') {
  60700. grouper = {
  60701. property: grouper,
  60702. direction: direction || 'ASC'
  60703. };
  60704. }
  60705. if (!grouper.isGrouper) {
  60706. grouper = new Ext.util.Grouper(grouper);
  60707. }
  60708. grouper.setRoot('data');
  60709. me.getGroups().getSorters().splice(0, 1, {
  60710. property: 'id',
  60711. direction: grouper.getDirection()
  60712. });
  60713. }
  60714. me.grouper = grouper;
  60715. if (!me.isConfiguring) {
  60716. me.reload();
  60717. me.fireGroupChange(grouper);
  60718. }
  60719. },
  60720. getByInternalId: function(internalId) {
  60721. return this.pageMap.getByInternalId(internalId);
  60722. },
  60723. indexOf: function(record) {
  60724. return this.pageMap.indexOf(record);
  60725. },
  60726. indexOfId: function(id) {
  60727. var rec = this.getById(id);
  60728. return rec ? this.indexOf(rec) : -1;
  60729. },
  60730. isLoaded: function() {
  60731. return Ext.isNumber(this.totalCount);
  60732. },
  60733. load: function(options) {
  60734. if (typeof options === 'function') {
  60735. options = {
  60736. callback: options
  60737. };
  60738. }
  60739. var me = this,
  60740. page = (options && options.page) || 1,
  60741. pageSize = me.getPageSize(),
  60742. operation = me.createOperation('read', Ext.apply({
  60743. start: (page - 1) * pageSize,
  60744. limit: pageSize,
  60745. page: page,
  60746. filters: me.getFilters().items,
  60747. sorters: me.getSorters().items,
  60748. grouper: me.getGrouper()
  60749. }, options));
  60750. if (me.fireEvent('beforeload', me, operation) !== false) {
  60751. me.onBeforeLoad(operation);
  60752. operation.execute();
  60753. } else {
  60754. operation.setCompleted();
  60755. }
  60756. return operation;
  60757. },
  60758. reload: function(options) {
  60759. var me = this;
  60760. if (typeof options === 'function') {
  60761. options = {
  60762. callback: options
  60763. };
  60764. }
  60765. if (me.fireEvent('beforereload') === false) {
  60766. return null;
  60767. }
  60768. options = Ext.apply({
  60769. internalScope: me,
  60770. internalCallback: me.handleReload,
  60771. page: 1
  60772. }, options);
  60773. me.pageMap.clear();
  60774. me.getGroups().clear();
  60775. return me.load(options);
  60776. },
  60777. removeAll: function() {
  60778. var me = this,
  60779. activeRanges = me.activeRanges,
  60780. i;
  60781. me.pageMap.clear();
  60782. for (i = activeRanges.length; i-- > 0; ) {
  60783. activeRanges[i].reset();
  60784. }
  60785. me.fireEvent('clear', me);
  60786. },
  60787. applyProxy: function(proxy) {
  60788. proxy = this.callParent([
  60789. proxy
  60790. ]);
  60791. if (proxy && proxy.setEnablePaging) {
  60792. proxy.setEnablePaging(true);
  60793. }
  60794. return proxy;
  60795. },
  60796. createFiltersCollection: function() {
  60797. return new Ext.util.FilterCollection();
  60798. },
  60799. createSortersCollection: function() {
  60800. return new Ext.util.SorterCollection();
  60801. },
  60802. onFilterEndUpdate: function() {
  60803. var me = this,
  60804. filters = me.getFilters(false);
  60805. if (!me.isConfiguring) {
  60806. me.reload();
  60807. me.fireEvent('filterchange', me, filters.getRange());
  60808. }
  60809. },
  60810. onSorterEndUpdate: function() {
  60811. var me = this,
  60812. sorters = me.getSorters().getRange(),
  60813. fire = !me.isConfiguring;
  60814. if (fire) {
  60815. me.fireEvent('beforesort', me, sorters);
  60816. }
  60817. if (fire) {
  60818. me.reload();
  60819. me.fireEvent('sort', me, sorters);
  60820. }
  60821. },
  60822. updatePageSize: function(pageSize) {
  60823. var totalCount = this.totalCount;
  60824. if (totalCount !== null) {
  60825. this.pageMap.setPageCount(Math.ceil(totalCount / pageSize));
  60826. }
  60827. },
  60828. updateTotalCount: function(totalCount, oldTotalCount) {
  60829. var me = this,
  60830. pageMap = me.pageMap;
  60831. me.totalCount = totalCount;
  60832. pageMap.setPageCount(Math.ceil(totalCount / me.getPageSize()));
  60833. me.fireEvent('totalcountchange', me, totalCount, oldTotalCount);
  60834. },
  60835. add: function() {
  60836. Ext.raise('Virtual stores do not support the add() method');
  60837. },
  60838. insert: function() {
  60839. Ext.raise('Virtual stores do not support the insert() method');
  60840. },
  60841. filter: function() {
  60842. if (!this.getRemoteFilter()) {
  60843. Ext.raise('Virtual stores do not support local filtering');
  60844. }
  60845. this.callParent(arguments);
  60846. },
  60847. filterBy: function() {
  60848. Ext.raise('Virtual stores do not support local filtering');
  60849. },
  60850. loadData: function() {
  60851. Ext.raise('Virtual stores do not support the loadData() method');
  60852. },
  60853. applyData: function() {
  60854. Ext.raise('Virtual stores do not support direct data loading');
  60855. },
  60856. updateRemoteFilter: function(remoteFilter, oldRemoteFilter) {
  60857. if (remoteFilter === false) {
  60858. Ext.raise('Virtual stores are always remotely filtered.');
  60859. }
  60860. this.callParent([
  60861. remoteFilter,
  60862. oldRemoteFilter
  60863. ]);
  60864. },
  60865. updateRemoteSort: function(remoteSort, oldRemoteSort) {
  60866. if (remoteSort === false) {
  60867. Ext.raise('Virtual stores are always remotely sorted.');
  60868. }
  60869. this.callParent([
  60870. remoteSort,
  60871. oldRemoteSort
  60872. ]);
  60873. },
  60874. updateTrackRemoved: function(value) {
  60875. if (value !== false) {
  60876. Ext.raise('Virtual stores do not support trackRemoved.');
  60877. }
  60878. this.callParent(arguments);
  60879. },
  60880. afterEdit: function(record, modifiedFieldNames) {
  60881. var me = this;
  60882. me.fireEvent('update', me, record, Ext.data.Model.EDIT, modifiedFieldNames);
  60883. me.fireEvent('datachanged', me);
  60884. },
  60885. privates: {
  60886. attachSummaryData: function(resultSet) {
  60887. var me = this,
  60888. summary = resultSet.getSummaryData(),
  60889. grouper, len, i, data, rec;
  60890. if (summary) {
  60891. me.summaryRecord = summary;
  60892. }
  60893. summary = resultSet.getGroupData();
  60894. if (summary) {
  60895. grouper = me.getGrouper();
  60896. if (grouper) {
  60897. me.groupSummaryData = data = {};
  60898. for (i = 0 , len = summary.length; i < len; ++i) {
  60899. rec = summary[i];
  60900. data[grouper.getGroupString(rec)] = rec;
  60901. }
  60902. }
  60903. }
  60904. },
  60905. handleReload: function(op) {
  60906. var me = this,
  60907. activeRanges = me.activeRanges,
  60908. len = activeRanges.length,
  60909. pageMap = me.pageMap,
  60910. resultSet = op.getResultSet(),
  60911. wasSuccessful = op.wasSuccessful(),
  60912. rsRecords = [],
  60913. i, range;
  60914. if (wasSuccessful) {
  60915. me.readTotalCount(resultSet);
  60916. me.fireEvent('reload', me, op);
  60917. for (i = 0; i < len; ++i) {
  60918. range = activeRanges[i];
  60919. if (pageMap.canSatisfy(range)) {
  60920. range.reload();
  60921. }
  60922. }
  60923. }
  60924. if (resultSet) {
  60925. rsRecords = resultSet.records;
  60926. }
  60927. me.fireEvent('load', me, rsRecords, wasSuccessful, op);
  60928. },
  60929. loadVirtualPage: function(page, callback, scope) {
  60930. var me = this,
  60931. pageMapGeneration = me.pageMap.generation;
  60932. return me.load({
  60933. page: page.number + 1,
  60934. internalCallback: function(op) {
  60935. var resultSet = op.getResultSet(),
  60936. rsRecords = [];
  60937. if (pageMapGeneration === me.pageMap.generation) {
  60938. if (op.wasSuccessful()) {
  60939. me.readTotalCount(resultSet);
  60940. me.attachSummaryData(resultSet);
  60941. }
  60942. callback.call(scope || page, op);
  60943. me.groupSummaryData = null;
  60944. if (resultSet) {
  60945. rsRecords = resultSet.records;
  60946. }
  60947. me.fireEvent('load', me, rsRecords, op.wasSuccessful(), op);
  60948. }
  60949. }
  60950. });
  60951. },
  60952. lockGroups: function(grouper, page) {
  60953. var groups = this.getGroups(),
  60954. groupInfo = page.groupInfo = {},
  60955. records = page.records,
  60956. len = records.length,
  60957. groupSummaryData = this.groupSummaryData,
  60958. pageMap = this.pageMap,
  60959. n = page.number,
  60960. group, i, groupKey, summaryRec, rec, firstRecords, first;
  60961. for (i = 0; i < len; ++i) {
  60962. rec = records[i];
  60963. groupKey = grouper.getGroupString(rec);
  60964. if (!groupInfo[groupKey]) {
  60965. groupInfo[groupKey] = rec;
  60966. group = groups.get(groupKey);
  60967. if (!group) {
  60968. group = new Ext.data.virtual.Group(groupKey);
  60969. groups.add(group);
  60970. }
  60971. firstRecords = group.firstRecords;
  60972. first = firstRecords[0];
  60973. if (first && n < pageMap.getPageIndex(first)) {
  60974. firstRecords.unshift(rec);
  60975. } else {
  60976. firstRecords.push(rec);
  60977. }
  60978. summaryRec = groupSummaryData && groupSummaryData[groupKey];
  60979. if (summaryRec) {
  60980. group.summaryRecord = summaryRec;
  60981. }
  60982. }
  60983. }
  60984. },
  60985. onPageDataAcquired: function(page) {
  60986. var grouper = this.getGrouper();
  60987. if (grouper) {
  60988. this.lockGroups(grouper, page);
  60989. }
  60990. },
  60991. onPageDestroy: function(page) {
  60992. var ranges = this.activeRanges,
  60993. len = ranges.length,
  60994. i;
  60995. for (i = 0; i < len; ++i) {
  60996. ranges[i].onPageDestroy(page);
  60997. }
  60998. },
  60999. onPageEvicted: function(page) {
  61000. var grouper = this.getGrouper();
  61001. if (grouper) {
  61002. this.releaseGroups(grouper, page);
  61003. }
  61004. },
  61005. readTotalCount: function(resultSet) {
  61006. var total = resultSet.getRemoteTotal();
  61007. if (!isNaN(total)) {
  61008. this.setTotalCount(total);
  61009. }
  61010. },
  61011. releaseGroups: function(grouper, page) {
  61012. var groups = this.getGroups(),
  61013. groupInfo = page.groupInfo,
  61014. first, firstRecords, key, group;
  61015. for (key in groupInfo) {
  61016. first = groupInfo[key];
  61017. group = groups.get(key);
  61018. firstRecords = group.firstRecords;
  61019. if (firstRecords.length === 1) {
  61020. groups.remove(group);
  61021. } else if (firstRecords[0] === first) {
  61022. firstRecords.shift();
  61023. firstRecords.sort(this.sortByPage);
  61024. } else {
  61025. Ext.Array.remove(firstRecords, first);
  61026. }
  61027. }
  61028. },
  61029. sortByPage: function(rec1, rec2) {
  61030. var map = this.pageMap;
  61031. return map.getPageIndex(rec1) - map.getPageIndex(rec2);
  61032. }
  61033. }
  61034. });
  61035. Ext.define('Ext.direct.Event', {
  61036. alias: 'direct.event',
  61037. status: true,
  61038. constructor: function(config) {
  61039. Ext.apply(this, config);
  61040. },
  61041. getName: function() {
  61042. return this.name;
  61043. },
  61044. getData: function() {
  61045. return this.data;
  61046. }
  61047. });
  61048. Ext.define('Ext.direct.RemotingEvent', {
  61049. extend: Ext.direct.Event,
  61050. alias: 'direct.rpc',
  61051. getTransaction: function() {
  61052. var me = this;
  61053. return me.transaction || Ext.direct.Manager.getTransaction(me.tid);
  61054. }
  61055. });
  61056. Ext.define('Ext.direct.ExceptionEvent', {
  61057. extend: Ext.direct.RemotingEvent,
  61058. alias: 'direct.exception',
  61059. status: false
  61060. });
  61061. Ext.define('Ext.direct.JsonProvider', {
  61062. extend: Ext.direct.Provider,
  61063. alias: 'direct.jsonprovider',
  61064. parseResponse: function(response) {
  61065. var text = response && response.responseText;
  61066. if (text != null) {
  61067. if (Ext.isObject(text) || Ext.isArray(text)) {
  61068. return text;
  61069. }
  61070. return Ext.decode(text);
  61071. }
  61072. return null;
  61073. },
  61074. createEvents: function(response) {
  61075. var me = this,
  61076. data = null,
  61077. events = [],
  61078. event, i, len;
  61079. try {
  61080. data = me.parseResponse(response);
  61081. } catch (e) {
  61082. event = new Ext.direct.ExceptionEvent({
  61083. parsingError: true,
  61084. data: e,
  61085. xhr: response,
  61086. code: Ext.direct.Manager.exceptions.PARSE,
  61087. message: 'Error parsing json response: \n\n ' + e
  61088. });
  61089. return [
  61090. event
  61091. ];
  61092. }
  61093. if (Ext.isArray(data)) {
  61094. for (i = 0 , len = data.length; i < len; ++i) {
  61095. events.push(me.createEvent(data[i]));
  61096. }
  61097. } else if (Ext.isObject(data)) {
  61098. events.push(me.createEvent(data));
  61099. }
  61100. return events;
  61101. },
  61102. createEvent: function(response) {
  61103. if (typeof response !== 'object' || !('type' in response)) {
  61104. return new Ext.direct.ExceptionEvent({
  61105. data: response,
  61106. code: Ext.direct.Manager.exceptions.DATA,
  61107. message: 'Invalid data: event type is not specified'
  61108. });
  61109. }
  61110. return Ext.create('direct.' + response.type, response);
  61111. }
  61112. });
  61113. Ext.define('Ext.util.TaskRunner', {
  61114. fireIdleEvent: null,
  61115. interval: 10,
  61116. timerId: null,
  61117. constructor: function(interval) {
  61118. var me = this;
  61119. if (typeof interval === 'number') {
  61120. me.interval = interval;
  61121. } else if (interval) {
  61122. Ext.apply(me, interval);
  61123. }
  61124. me.tasks = [];
  61125. me.timerFn = me.onTick.bind(me);
  61126. },
  61127. newTask: function(config) {
  61128. var task = new Ext.util.TaskRunner.Task(config);
  61129. task.manager = this;
  61130. if (Ext.Timer.track) {
  61131. task.creator = new Error().stack;
  61132. }
  61133. return task;
  61134. },
  61135. start: function(task) {
  61136. var me = this,
  61137. now = Ext.Date.now();
  61138. if (!task.pending) {
  61139. me.tasks.push(task);
  61140. task.pending = true;
  61141. }
  61142. task.stopped = false;
  61143. task.taskStartTime = now;
  61144. task.taskRunTime = task.fireOnStart !== false ? 0 : task.taskStartTime;
  61145. task.taskRunCount = 0;
  61146. if (!me.firing) {
  61147. if (task.fireOnStart !== false) {
  61148. me.startTimer(0, now);
  61149. } else {
  61150. me.startTimer(task.interval, now);
  61151. }
  61152. }
  61153. return task;
  61154. },
  61155. stop: function(task, andRemove) {
  61156. var me = this,
  61157. tasks = me.tasks,
  61158. pendingCount = 0,
  61159. i;
  61160. if (!task.stopped) {
  61161. task.stopped = true;
  61162. task.pending = false;
  61163. if (task.onStop) {
  61164. task.onStop.call(task.scope || task, task);
  61165. }
  61166. }
  61167. if (andRemove) {
  61168. Ext.Array.remove(tasks, task);
  61169. }
  61170. for (i = 0; !pendingCount && i < tasks.length; i++) {
  61171. if (!tasks[i].stopped) {
  61172. pendingCount++;
  61173. }
  61174. }
  61175. if (!pendingCount) {
  61176. Ext.undefer(me.timerId);
  61177. me.timerId = null;
  61178. }
  61179. return task;
  61180. },
  61181. stopAll: function(andRemove) {
  61182. var me = this;
  61183. Ext.each(this.tasks, function(task) {
  61184. me.stop(task, andRemove);
  61185. }, null, true);
  61186. },
  61187. firing: false,
  61188. nextExpires: 1.0E99,
  61189. onTick: function() {
  61190. var me = this,
  61191. tasks = me.tasks,
  61192. fireIdleEvent = me.fireIdleEvent,
  61193. now = Ext.Date.now(),
  61194. nextExpires = 1.0E99,
  61195. len = tasks.length,
  61196. expires, newTasks, i, task, rt, remove, args;
  61197. var timer = Ext.Timer.get(me.timerId);
  61198. if (timer) {
  61199. timer.tasks = [];
  61200. }
  61201. me.timerId = null;
  61202. me.firing = true;
  61203. for (i = 0; i < len || i < (len = tasks.length); ++i) {
  61204. task = tasks[i];
  61205. if (!(remove = task.stopped)) {
  61206. expires = task.taskRunTime + task.interval;
  61207. if (expires <= now) {
  61208. rt = 1;
  61209. if (fireIdleEvent === null && task.fireIdleEvent !== false) {
  61210. fireIdleEvent = true;
  61211. }
  61212. task.taskRunCount++;
  61213. if (task.args) {
  61214. args = task.addCountToArgs ? task.args.concat([
  61215. task.taskRunCount
  61216. ]) : task.args;
  61217. } else {
  61218. args = [
  61219. task.taskRunCount
  61220. ];
  61221. }
  61222. if (timer) {
  61223. timer.tasks.push(task);
  61224. }
  61225. if (me.disableTryCatch) {
  61226. rt = task.run.apply(task.scope || task, args);
  61227. } else {
  61228. try {
  61229. rt = task.run.apply(task.scope || task, args);
  61230. } catch (taskError) {
  61231. try {
  61232. Ext.log({
  61233. fn: task.run,
  61234. prefix: 'Error while running task',
  61235. stack: taskError.stack,
  61236. msg: taskError,
  61237. level: 'error'
  61238. });
  61239. if (task.onError) {
  61240. rt = task.onError.call(task.scope || task, task, taskError);
  61241. }
  61242. } catch (e) {}
  61243. }
  61244. }
  61245. task.taskRunTime = now;
  61246. if (rt === false || task.taskRunCount === task.repeat) {
  61247. me.stop(task);
  61248. remove = true;
  61249. } else {
  61250. remove = task.stopped;
  61251. expires = now + task.interval;
  61252. }
  61253. }
  61254. if (!remove && task.duration && task.duration <= (now - task.taskStartTime)) {
  61255. me.stop(task);
  61256. remove = true;
  61257. }
  61258. }
  61259. if (remove) {
  61260. task.pending = false;
  61261. if (!newTasks) {
  61262. newTasks = tasks.slice(0, i);
  61263. }
  61264. } else
  61265. {
  61266. if (newTasks) {
  61267. newTasks.push(task);
  61268. }
  61269. if (nextExpires > expires) {
  61270. nextExpires = expires;
  61271. }
  61272. }
  61273. }
  61274. if (newTasks) {
  61275. me.tasks = newTasks;
  61276. }
  61277. me.firing = false;
  61278. if (me.tasks.length) {
  61279. me.startTimer(nextExpires - now, Ext.Date.now());
  61280. }
  61281. if (fireIdleEvent === null) {
  61282. fireIdleEvent = false;
  61283. }
  61284. Ext._suppressIdle = !fireIdleEvent;
  61285. },
  61286. startTimer: function(timeout, now) {
  61287. var me = this,
  61288. expires = now + timeout,
  61289. timerId = me.timerId;
  61290. if (timerId && me.nextExpires - expires > me.interval) {
  61291. timerId = Ext.undefer(timerId);
  61292. }
  61293. if (!timerId) {
  61294. if (timeout < me.interval) {
  61295. timeout = me.interval;
  61296. }
  61297. me.timerId = Ext.defer(me.timerFn, timeout);
  61298. me.nextExpires = expires;
  61299. var timer = Ext.Timer.get(me.timerId);
  61300. if (timer) {
  61301. timer.runner = me;
  61302. }
  61303. }
  61304. }
  61305. },
  61306. function() {
  61307. var me = this,
  61308. proto = me.prototype;
  61309. proto.destroy = proto.stopAll;
  61310. me.Task = new Ext.Class({
  61311. isTask: true,
  61312. stopped: true,
  61313. fireOnStart: false,
  61314. constructor: function(config) {
  61315. Ext.apply(this, config);
  61316. },
  61317. restart: function(interval) {
  61318. if (interval !== undefined) {
  61319. this.interval = interval;
  61320. }
  61321. this.manager.start(this);
  61322. },
  61323. start: function(interval) {
  61324. if (this.stopped) {
  61325. this.restart(interval);
  61326. }
  61327. },
  61328. stop: function(andRemove) {
  61329. this.manager.stop(this, andRemove);
  61330. },
  61331. destroy: function() {
  61332. this.stop(true);
  61333. }
  61334. });
  61335. proto = me.Task.prototype;
  61336. proto.destroy = proto.stop;
  61337. });
  61338. Ext.define('Ext.direct.PollingProvider', {
  61339. extend: Ext.direct.JsonProvider,
  61340. alias: 'direct.pollingprovider',
  61341. type: 'polling',
  61342. interval: 3000,
  61343. constructor: function(config) {
  61344. var me = this;
  61345. me.callParent([
  61346. config
  61347. ]);
  61348. me.pollTask = Ext.TaskManager.newTask({
  61349. run: me.runPoll,
  61350. interval: me.interval,
  61351. scope: me
  61352. });
  61353. },
  61354. destroy: function() {
  61355. this.pollTask.stop(true);
  61356. this.callParent();
  61357. },
  61358. doConnect: function() {
  61359. var me = this,
  61360. url = me.url,
  61361. pollFn = me.pollFn;
  61362. if (pollFn && Ext.isString(pollFn)) {
  61363. var fnName = pollFn;
  61364. me.pollFn = pollFn = Ext.direct.Manager.parseMethod(pollFn);
  61365. if (!Ext.isFunction(pollFn)) {
  61366. Ext.raise("Cannot resolve Ext Direct API method " + fnName + " for PollingProvider");
  61367. }
  61368. }
  61369. else if (Ext.isFunction(url)) {
  61370. Ext.log.warn('Using a function for url is deprecated, use pollFn instead.');
  61371. me.pollFn = pollFn = url;
  61372. me.url = url = null;
  61373. }
  61374. if (url || pollFn) {
  61375. me.setInterval(me.interval);
  61376. me.pollTask.start();
  61377. }
  61378. },
  61379. doDisconnect: function() {
  61380. if (this.pollTask) {
  61381. this.pollTask.stop();
  61382. }
  61383. },
  61384. getInterval: function() {
  61385. return this.pollTask && this.pollTask.interval;
  61386. },
  61387. setInterval: function(interval) {
  61388. var me = this,
  61389. pollTask = me.pollTask;
  61390. if (interval < 100) {
  61391. Ext.raise("Attempting to configure PollProvider " + me.id + " with interval that is less than 100ms.");
  61392. }
  61393. me.interval = pollTask.interval = interval;
  61394. if (me.isConnected()) {
  61395. pollTask.restart(interval);
  61396. }
  61397. },
  61398. runPoll: function() {
  61399. var me = this,
  61400. url = me.url,
  61401. pollFn = me.pollFn,
  61402. baseParams = me.baseParams,
  61403. args, request;
  61404. if (me.fireEvent('beforepoll', me) !== false) {
  61405. if (pollFn) {
  61406. args = pollFn.directCfg.method.getArgs({
  61407. params: baseParams !== undefined ? baseParams : {},
  61408. callback: me.onPollFn,
  61409. scope: me
  61410. });
  61411. pollFn.apply(window, args);
  61412. } else {
  61413. request = {
  61414. url: url,
  61415. callback: me.onData,
  61416. scope: me,
  61417. params: baseParams,
  61418. headers: me.getHeaders()
  61419. };
  61420. if (me.timeout != null) {
  61421. request.timeout = me.timeout;
  61422. }
  61423. me.sendAjaxRequest(request);
  61424. }
  61425. me.fireEvent('poll', me);
  61426. }
  61427. },
  61428. onData: function(opt, success, response) {
  61429. var me = this,
  61430. i, len, events, event;
  61431. if (success) {
  61432. events = me.createEvents(response);
  61433. for (i = 0 , len = events.length; i < len; ++i) {
  61434. event = events[i];
  61435. me.fireEvent('data', me, event);
  61436. if (!event.status) {
  61437. me.fireEvent('exception', me, event);
  61438. }
  61439. }
  61440. } else {
  61441. event = new Ext.direct.ExceptionEvent({
  61442. data: null,
  61443. code: Ext.direct.Manager.exceptions.TRANSPORT,
  61444. message: 'Unable to connect to the server.',
  61445. xhr: response
  61446. });
  61447. me.fireEvent('data', me, event);
  61448. me.fireEvent('exception', me, event);
  61449. }
  61450. me.callParent([
  61451. opt,
  61452. success,
  61453. response
  61454. ]);
  61455. },
  61456. onPollFn: function(result, event, success, options) {
  61457. this.onData(null, success, {
  61458. responseText: result
  61459. });
  61460. },
  61461. inheritableStatics: {
  61462. checkConfig: function(config) {
  61463. return config && config.type === 'polling' && (config.url || config.pollFn);
  61464. }
  61465. }
  61466. });
  61467. Ext.define('Ext.direct.RemotingMethod', {
  61468. constructor: function(config) {
  61469. var me = this,
  61470. params = config.params,
  61471. len = config.len,
  61472. metadataCfg = config.metadata,
  61473. metadata = {},
  61474. name, pLen, p, param;
  61475. me.name = config.name;
  61476. me.disableBatching = config.batched != null ? !config.batched : false;
  61477. if (config.formHandler) {
  61478. me.formHandler = config.formHandler;
  61479. } else if (Ext.isNumeric(len)) {
  61480. me.len = len;
  61481. me.ordered = true;
  61482. } else {
  61483. me.named = true;
  61484. me.strict = config.strict !== undefined ? config.strict : true;
  61485. me.params = {};
  61486. pLen = params && params.length;
  61487. for (p = 0; p < pLen; p++) {
  61488. param = params[p];
  61489. name = Ext.isObject(param) ? param.name : param;
  61490. me.params[name] = true;
  61491. }
  61492. }
  61493. if (metadataCfg) {
  61494. params = metadataCfg.params;
  61495. len = metadataCfg.len;
  61496. if (Ext.isNumeric(len)) {
  61497. if (len === 0) {
  61498. Ext.raise('metadata.len cannot be 0 ' + 'for Ext Direct method ' + me.name);
  61499. }
  61500. metadata.ordered = true;
  61501. metadata.len = len;
  61502. } else if (Ext.isArray(params)) {
  61503. metadata.named = true;
  61504. metadata.params = {};
  61505. for (p = 0 , pLen = params.length; p < pLen; p++) {
  61506. param = params[p];
  61507. metadata.params[param] = true;
  61508. }
  61509. metadata.strict = metadataCfg.strict !== undefined ? metadataCfg.strict : true;
  61510. } else
  61511. {
  61512. Ext.raise('metadata is neither named nor ordered ' + 'for Ext Direct method ' + me.name);
  61513. }
  61514. me.metadata = metadata;
  61515. }
  61516. },
  61517. getArgs: function(config) {
  61518. var me = this,
  61519. params = config.params,
  61520. paramOrder = config.paramOrder,
  61521. metadata = config.metadata,
  61522. options = config.options,
  61523. args = [],
  61524. flatten, i, len;
  61525. if (me.ordered) {
  61526. if (me.len > 0) {
  61527. if (paramOrder) {
  61528. flatten = config.paramsAsArray && me.len === 1 && (paramOrder.length > 1 || Ext.isArray(params));
  61529. if (flatten) {
  61530. if (Ext.isArray(params)) {
  61531. for (i = 0 , len = params.length; i < len; i++) {
  61532. args.push(me.convertParams(params[i], paramOrder, paramOrder.length, true));
  61533. }
  61534. } else {
  61535. args = me.convertParams(params, paramOrder, paramOrder.length, true);
  61536. }
  61537. if (!params.allowSingle || args.length > 1) {
  61538. args = [
  61539. args
  61540. ];
  61541. }
  61542. } else {
  61543. args = me.convertParams(params, paramOrder, me.len, false);
  61544. }
  61545. } else {
  61546. args.push(params);
  61547. }
  61548. }
  61549. } else {
  61550. args.push(params);
  61551. }
  61552. args.push(config.callback, config.scope || window);
  61553. if (options || metadata) {
  61554. options = Ext.apply({}, options);
  61555. if (metadata) {
  61556. options.metadata = metadata;
  61557. }
  61558. args.push(options);
  61559. }
  61560. return args;
  61561. },
  61562. convertParams: function(params, paramOrder, count, flatten) {
  61563. var ret = [],
  61564. paramName, i, len;
  61565. for (i = 0 , len = count; i < len; i++) {
  61566. paramName = paramOrder[i];
  61567. ret.push(params[paramName]);
  61568. }
  61569. if (flatten) {
  61570. return ret.length === 0 ? undefined : ret.length === 1 ? ret[0] : ret;
  61571. } else {
  61572. return ret;
  61573. }
  61574. },
  61575. getCallData: function(args) {
  61576. var me = this,
  61577. data = null,
  61578. len = me.len,
  61579. params = me.params,
  61580. strict = me.strict,
  61581. form, callback, scope, name, options, metadata;
  61582. if (me.ordered) {
  61583. callback = args[len];
  61584. scope = args[len + 1];
  61585. options = args[len + 2];
  61586. if (len !== 0) {
  61587. data = args.slice(0, len);
  61588. }
  61589. } else if (me.formHandler) {
  61590. form = args[0];
  61591. callback = args[1];
  61592. scope = args[2];
  61593. options = args[3];
  61594. } else {
  61595. data = Ext.apply({}, args[0]);
  61596. callback = args[1];
  61597. scope = args[2];
  61598. options = args[3];
  61599. if (strict) {
  61600. for (name in data) {
  61601. if (data.hasOwnProperty(name) && !params[name]) {
  61602. delete data[name];
  61603. }
  61604. }
  61605. }
  61606. }
  61607. if (me.metadata && options && options.metadata) {
  61608. if (me.metadata.ordered) {
  61609. if (!Ext.isArray(options.metadata)) {
  61610. Ext.raise('options.metadata is not an Array ' + 'for Ext Direct method ' + me.name);
  61611. } else if (options.metadata.length < me.metadata.len) {
  61612. Ext.raise('Not enough parameters in options.metadata ' + 'for Ext Direct method ' + me.name);
  61613. }
  61614. metadata = options.metadata.slice(0, me.metadata.len);
  61615. } else {
  61616. if (!Ext.isObject(options.metadata)) {
  61617. Ext.raise('options.metadata is not an Object ' + 'for Ext Direct method ' + me.name);
  61618. }
  61619. metadata = Ext.apply({}, options.metadata);
  61620. if (me.metadata.strict) {
  61621. for (name in metadata) {
  61622. if (metadata.hasOwnProperty(name) && !me.metadata.params[name]) {
  61623. delete metadata[name];
  61624. }
  61625. }
  61626. }
  61627. for (name in me.metadata.params) {
  61628. if (!metadata.hasOwnProperty(name)) {
  61629. Ext.raise('Named parameter ' + name + ' is missing ' + 'in options.metadata for Ext Direct method ' + me.name);
  61630. }
  61631. }
  61632. }
  61633. delete options.metadata;
  61634. }
  61635. return {
  61636. form: form,
  61637. data: data,
  61638. metadata: metadata,
  61639. callback: callback,
  61640. scope: scope,
  61641. options: options
  61642. };
  61643. }
  61644. });
  61645. Ext.define('Ext.direct.Transaction', {
  61646. alias: 'direct.transaction',
  61647. statics: {
  61648. TRANSACTION_ID: 0
  61649. },
  61650. constructor: function(config) {
  61651. var me = this;
  61652. Ext.apply(me, config);
  61653. me.id = me.tid = ++me.self.TRANSACTION_ID;
  61654. me.retryCount = 0;
  61655. },
  61656. send: function() {
  61657. var me = this;
  61658. me.provider.queueTransaction(me);
  61659. },
  61660. retry: function() {
  61661. var me = this;
  61662. me.retryCount++;
  61663. me.send();
  61664. },
  61665. getProvider: function() {
  61666. return this.provider;
  61667. }
  61668. });
  61669. Ext.define('Ext.direct.RemotingProvider', {
  61670. extend: Ext.direct.JsonProvider,
  61671. alias: 'direct.remotingprovider',
  61672. type: 'remoting',
  61673. enableBuffer: 10,
  61674. bufferLimit: Number.MAX_VALUE,
  61675. maxRetries: 1,
  61676. constructor: function(config) {
  61677. var me = this;
  61678. me.callParent([
  61679. config
  61680. ]);
  61681. me.namespace = (Ext.isString(me.namespace) ? Ext.ns(me.namespace) : me.namespace) || Ext.global;
  61682. me.callBuffer = [];
  61683. },
  61684. destroy: function() {
  61685. if (this.callTask) {
  61686. this.callTask.cancel();
  61687. }
  61688. this.callParent();
  61689. },
  61690. connect: function() {
  61691. var me = this;
  61692. if (!me.url) {
  61693. Ext.raise('Error initializing RemotingProvider "' + me.id + '", no url configured.');
  61694. }
  61695. me.callParent();
  61696. },
  61697. doConnect: function() {
  61698. if (!this.apiCreated) {
  61699. this.initAPI();
  61700. this.apiCreated = true;
  61701. }
  61702. },
  61703. getNamespace: function(root, action) {
  61704. var parts, ns, i, len;
  61705. root = root || Ext.global;
  61706. parts = action.toString().split('.');
  61707. for (i = 0 , len = parts.length; i < len; i++) {
  61708. ns = parts[i];
  61709. root = root[ns];
  61710. if (typeof root === 'undefined') {
  61711. return root;
  61712. }
  61713. }
  61714. return root;
  61715. },
  61716. createNamespaces: function(root, action) {
  61717. var parts, ns, i, len;
  61718. root = root || Ext.global;
  61719. parts = action.toString().split('.');
  61720. for (i = 0 , len = parts.length; i < len; i++) {
  61721. ns = parts[i];
  61722. root[ns] = root[ns] || {};
  61723. root = root[ns];
  61724. }
  61725. return root;
  61726. },
  61727. initAPI: function() {
  61728. var me = this,
  61729. actions = me.actions,
  61730. namespace = me.namespace,
  61731. Manager = Ext.direct.Manager,
  61732. action, cls, methods, i, len, method, handler;
  61733. for (action in actions) {
  61734. if (actions.hasOwnProperty(action)) {
  61735. if (me.disableNestedActions) {
  61736. cls = namespace[action];
  61737. if (!cls) {
  61738. cls = namespace[action] = {};
  61739. }
  61740. } else {
  61741. cls = me.getNamespace(namespace, action);
  61742. if (!cls) {
  61743. cls = me.createNamespaces(namespace, action);
  61744. }
  61745. }
  61746. methods = actions[action];
  61747. for (i = 0 , len = methods.length; i < len; ++i) {
  61748. method = new Ext.direct.RemotingMethod(methods[i]);
  61749. cls[method.name] = handler = me.createHandler(action, method);
  61750. Manager.registerMethod(handler.$name, handler);
  61751. }
  61752. }
  61753. }
  61754. },
  61755. createHandler: function(action, method) {
  61756. var me = this,
  61757. handler;
  61758. handler = function() {
  61759. me.invokeFunction(action, method, Array.prototype.slice.call(arguments, 0));
  61760. };
  61761. handler.name = handler.$name = action + '.' + method.name;
  61762. handler.$directFn = true;
  61763. handler.directCfg = handler.$directCfg = {
  61764. action: action,
  61765. method: method
  61766. };
  61767. return handler;
  61768. },
  61769. invokeFunction: function(action, method, args) {
  61770. var me = this,
  61771. transaction, form, isUpload, postParams;
  61772. transaction = me.configureTransaction(action, method, args);
  61773. if (me.fireEvent('beforecall', me, transaction, method) !== false) {
  61774. Ext.direct.Manager.addTransaction(transaction);
  61775. if (transaction.isForm) {
  61776. form = transaction.form;
  61777. isUpload = String(form.getAttribute("enctype")).toLowerCase() === 'multipart/form-data';
  61778. postParams = {
  61779. extTID: transaction.id,
  61780. extAction: action,
  61781. extMethod: method.name,
  61782. extType: 'rpc',
  61783. extUpload: String(isUpload)
  61784. };
  61785. if (transaction.metadata) {
  61786. postParams.extMetadata = Ext.JSON.encode(transaction.metadata);
  61787. }
  61788. Ext.apply(transaction, {
  61789. form: form,
  61790. isUpload: isUpload,
  61791. params: postParams
  61792. });
  61793. }
  61794. me.queueTransaction(transaction);
  61795. me.fireEvent('call', me, transaction, method);
  61796. }
  61797. },
  61798. configureTransaction: function(action, method, args, isForm) {
  61799. var data, cb, scope, options, params;
  61800. data = method.getCallData(args);
  61801. cb = data.callback;
  61802. scope = data.scope;
  61803. options = data.options;
  61804. if (cb && !Ext.isFunction(cb)) {
  61805. Ext.raise("Callback argument is not a function " + "for Ext Direct method " + action + "." + method.name);
  61806. }
  61807. cb = cb && scope ? cb.bind(scope) : cb;
  61808. params = Ext.apply({}, {
  61809. provider: this,
  61810. args: args,
  61811. action: action,
  61812. method: method.name,
  61813. form: data.form,
  61814. data: data.data,
  61815. metadata: data.metadata,
  61816. callbackOptions: options,
  61817. callback: cb,
  61818. isForm: !!method.formHandler,
  61819. disableBatching: method.disableBatching
  61820. });
  61821. if (options && options.timeout != null) {
  61822. params.timeout = options.timeout;
  61823. }
  61824. return new Ext.direct.Transaction(params);
  61825. },
  61826. queueTransaction: function(transaction) {
  61827. var me = this,
  61828. callBuffer = me.callBuffer,
  61829. enableBuffer = me.enableBuffer;
  61830. if (transaction.isForm || enableBuffer === false || transaction.disableBatching || transaction.timeout != null) {
  61831. me.sendTransaction(transaction);
  61832. return;
  61833. }
  61834. callBuffer.push(transaction);
  61835. if (enableBuffer && callBuffer.length < me.bufferLimit) {
  61836. if (!me.callTask) {
  61837. me.callTask = new Ext.util.DelayedTask(me.combineAndSend, me);
  61838. }
  61839. me.callTask.delay(Ext.isNumber(enableBuffer) ? enableBuffer : 10);
  61840. } else {
  61841. me.combineAndSend();
  61842. }
  61843. },
  61844. combineAndSend: function() {
  61845. var me = this,
  61846. buffer = me.callBuffer,
  61847. len = buffer.length;
  61848. if (len > 0) {
  61849. me.sendTransaction(len === 1 ? buffer[0] : buffer);
  61850. me.callBuffer = [];
  61851. }
  61852. },
  61853. sendTransaction: function(transaction) {
  61854. var me = this,
  61855. request, callData, params,
  61856. enableUrlEncode = me.enableUrlEncode,
  61857. payload, i, len;
  61858. request = {
  61859. url: me.url,
  61860. callback: me.onData,
  61861. scope: me,
  61862. transaction: transaction,
  61863. headers: me.getHeaders()
  61864. };
  61865. if (transaction.timeout != null) {
  61866. request.timeout = transaction.timeout;
  61867. } else if (me.timeout != null) {
  61868. request.timeout = me.timeout;
  61869. }
  61870. if (transaction.isForm) {
  61871. Ext.apply(request, {
  61872. params: transaction.params,
  61873. form: transaction.form,
  61874. isUpload: transaction.isUpload
  61875. });
  61876. } else {
  61877. if (Ext.isArray(transaction)) {
  61878. callData = [];
  61879. for (i = 0 , len = transaction.length; i < len; ++i) {
  61880. payload = me.getPayload(transaction[i]);
  61881. callData.push(payload);
  61882. }
  61883. } else {
  61884. callData = me.getPayload(transaction);
  61885. }
  61886. if (enableUrlEncode) {
  61887. params = {};
  61888. params[Ext.isString(enableUrlEncode) ? enableUrlEncode : 'data'] = Ext.encode(callData);
  61889. request.params = params;
  61890. } else {
  61891. request.jsonData = callData;
  61892. }
  61893. }
  61894. return me.sendAjaxRequest(request);
  61895. },
  61896. getPayload: function(transaction) {
  61897. var result = {
  61898. action: transaction.action,
  61899. method: transaction.method,
  61900. data: transaction.data,
  61901. type: 'rpc',
  61902. tid: transaction.id
  61903. };
  61904. if (transaction.metadata) {
  61905. result.metadata = transaction.metadata;
  61906. }
  61907. return result;
  61908. },
  61909. onData: function(options, success, response) {
  61910. var me = this,
  61911. i, len, events, event, transaction, transactions;
  61912. if (me.destroying || me.destroyed) {
  61913. return;
  61914. }
  61915. events = success && me.createEvents(response);
  61916. success = events && events.length && !events[0].parsingError;
  61917. if (success) {
  61918. for (i = 0 , len = events.length; i < len; ++i) {
  61919. event = events[i];
  61920. me.fireEvent('data', me, event);
  61921. transaction = me.getTransaction(event);
  61922. if (transaction) {
  61923. if (me.fireEvent('beforecallback', me, event, transaction) !== false) {
  61924. me.runCallback(transaction, event, true);
  61925. }
  61926. Ext.direct.Manager.removeTransaction(transaction);
  61927. }
  61928. }
  61929. } else {
  61930. transactions = [].concat(options.transaction);
  61931. event = events[0] || new Ext.direct.ExceptionEvent({
  61932. data: null,
  61933. transaction: transaction,
  61934. code: Ext.direct.Manager.exceptions.TRANSPORT,
  61935. message: 'Unable to connect to the server.',
  61936. xhr: response
  61937. });
  61938. for (i = 0 , len = transactions.length; i < len; ++i) {
  61939. transaction = me.getTransaction(transactions[i]);
  61940. if (transaction && transaction.retryCount < me.maxRetries) {
  61941. transaction.retry();
  61942. } else {
  61943. me.fireEvent('data', me, event);
  61944. me.fireEvent('exception', me, event);
  61945. if (transaction && me.fireEvent('beforecallback', me, event, transaction) !== false) {
  61946. me.runCallback(transaction, event, false);
  61947. }
  61948. Ext.direct.Manager.removeTransaction(transaction);
  61949. }
  61950. }
  61951. }
  61952. me.callParent([
  61953. options,
  61954. success,
  61955. response
  61956. ]);
  61957. },
  61958. getTransaction: function(options) {
  61959. return options && options.tid ? Ext.direct.Manager.getTransaction(options.tid) : null;
  61960. },
  61961. runCallback: function(transaction, event) {
  61962. var success = !!event.status,
  61963. funcName = success ? 'success' : 'failure',
  61964. callback, options, result;
  61965. if (transaction && transaction.callback) {
  61966. callback = transaction.callback;
  61967. options = transaction.callbackOptions;
  61968. result = typeof event.result !== 'undefined' ? event.result : event.data;
  61969. if (Ext.isFunction(callback)) {
  61970. callback(result, event, success, options);
  61971. } else {
  61972. Ext.callback(callback[funcName], callback.scope, [
  61973. result,
  61974. event,
  61975. success,
  61976. options
  61977. ]);
  61978. Ext.callback(callback.callback, callback.scope, [
  61979. result,
  61980. event,
  61981. success,
  61982. options
  61983. ]);
  61984. }
  61985. }
  61986. },
  61987. inheritableStatics: {
  61988. checkConfig: function(config) {
  61989. return config && config.type === 'remoting' && config.url && Ext.isArray(config.actions);
  61990. }
  61991. }
  61992. });
  61993. Ext.define('Ext.dom.Fly', {
  61994. extend: Ext.dom.Element,
  61995. alternateClassName: 'Ext.dom.Element.Fly',
  61996. validNodeTypes: {
  61997. 1: 1,
  61998. 9: 1,
  61999. 11: 1
  62000. },
  62001. isFly: true,
  62002. constructor: function(dom) {
  62003. this.dom = dom;
  62004. this.el = this;
  62005. },
  62006. attach: function(dom) {
  62007. var me = this,
  62008. data;
  62009. if (!dom) {
  62010. return me.detach();
  62011. }
  62012. me.dom = Ext.getDom(dom);
  62013. if (!Ext.cache[dom.id]) {
  62014. data = me.peekData();
  62015. if (data) {
  62016. data.isSynchronized = false;
  62017. }
  62018. }
  62019. return me;
  62020. },
  62021. detach: function() {
  62022. return (this.dom = null);
  62023. },
  62024. addListener:
  62025. function() {
  62026. Ext.raise("Cannot use addListener() on Ext.dom.Fly instances. " + "Please use Ext.get() to retrieve an Ext.dom.Element instance instead.");
  62027. } ||
  62028. null,
  62029. removeListener:
  62030. function() {
  62031. Ext.raise("Cannot use removeListener() on Ext.dom.Fly instances. " + "Please use Ext.get() to retrieve an Ext.dom.Element instance instead.");
  62032. } ||
  62033. null
  62034. }, function(Fly) {
  62035. var flyweights = {},
  62036. detachedBodyEl;
  62037. Fly.cache = flyweights;
  62038. Ext.fly = function(dom, named) {
  62039. var fly = null,
  62040. fn = Ext.fly,
  62041. nodeType, data;
  62042. named = named || (fn.caller && (fn.caller.$name || fn.caller.name)) || '_global';
  62043. dom = Ext.getDom(dom);
  62044. if (dom) {
  62045. nodeType = dom.nodeType;
  62046. if (Fly.prototype.validNodeTypes[nodeType] || (!nodeType && (dom.window == dom))) {
  62047. fly = Ext.cache[dom.id];
  62048. if (!fly || fly.dom !== dom) {
  62049. if (named === 'constructor') {
  62050. named = '$constructor';
  62051. }
  62052. fly = flyweights[named] || (flyweights[named] = new Fly());
  62053. fly.dom = dom;
  62054. data = fly.peekData();
  62055. if (data) {
  62056. data.isSynchronized = false;
  62057. }
  62058. }
  62059. }
  62060. }
  62061. return fly;
  62062. };
  62063. Ext.getDetachedBody = function() {
  62064. if (!detachedBodyEl) {
  62065. Ext.detachedBodyEl = detachedBodyEl = new Fly(document.createElement('div'));
  62066. detachedBodyEl.isDetachedBody = true;
  62067. }
  62068. return detachedBodyEl;
  62069. };
  62070. });
  62071. Ext.define('Ext.dom.CompositeElementLite', {
  62072. alternateClassName: [
  62073. 'Ext.CompositeElementLite'
  62074. ],
  62075. isComposite: true,
  62076. isLite: true,
  62077. statics: {
  62078. importElementMethods: function() {
  62079. var Element = Ext.dom.Element,
  62080. prototype = this.prototype;
  62081. Ext.Object.each(Element.prototype, function(name, member) {
  62082. if (typeof member === 'function' && !prototype[name]) {
  62083. prototype[name] = function() {
  62084. return this.invoke(name, arguments);
  62085. };
  62086. }
  62087. });
  62088. }
  62089. },
  62090. constructor: function(elements, skipValidation) {
  62091. if (skipValidation) {
  62092. this.elements = elements || [];
  62093. } else {
  62094. this.elements = [];
  62095. this.add(elements);
  62096. }
  62097. },
  62098. getElement: function(el) {
  62099. var fly = this._fly || (this._fly = new Ext.dom.Fly());
  62100. return fly.attach(el);
  62101. },
  62102. transformElement: function(el) {
  62103. return Ext.getDom(el);
  62104. },
  62105. getCount: function() {
  62106. return this.elements.length;
  62107. },
  62108. add: function(els, root) {
  62109. var elements = this.elements,
  62110. i, ln;
  62111. if (!els) {
  62112. return this;
  62113. }
  62114. if (typeof els === "string") {
  62115. els = Ext.fly(root || document).query(els);
  62116. } else if (els.isComposite) {
  62117. els = els.elements;
  62118. } else if (!Ext.isIterable(els)) {
  62119. els = [
  62120. els
  62121. ];
  62122. }
  62123. for (i = 0 , ln = els.length; i < ln; ++i) {
  62124. elements.push(this.transformElement(els[i]));
  62125. }
  62126. return this;
  62127. },
  62128. invoke: function(fn, args) {
  62129. var me = this,
  62130. elements = me.elements,
  62131. ln = elements.length,
  62132. prototype, element, i;
  62133. if (i !== 0) {
  62134. prototype = (me.isLite ? Ext.dom.Fly : Ext.dom.Element).prototype;
  62135. for (i = 0; i < ln; i++) {
  62136. element = elements[i];
  62137. if (element) {
  62138. prototype[fn].apply(me.getElement(element), args);
  62139. }
  62140. }
  62141. }
  62142. return me;
  62143. },
  62144. item: function(index) {
  62145. var el = this.elements[index],
  62146. out = null;
  62147. if (el) {
  62148. out = this.getElement(el);
  62149. }
  62150. return out;
  62151. },
  62152. slice: function(start, end) {
  62153. return Ext.Array.slice(this.elements, start, end);
  62154. },
  62155. each: function(fn, scope) {
  62156. var me = this,
  62157. els = me.elements,
  62158. len = els.length,
  62159. i, e;
  62160. for (i = 0; i < len; i++) {
  62161. e = els[i];
  62162. if (e) {
  62163. e = this.getElement(e);
  62164. if (fn.call(scope || e, e, me, i) === false) {
  62165. break;
  62166. }
  62167. }
  62168. }
  62169. return me;
  62170. },
  62171. fill: function(els) {
  62172. var me = this;
  62173. me.elements = [];
  62174. me.add(els);
  62175. return me;
  62176. },
  62177. insert: function(index, nodes) {
  62178. Ext.Array.insert(this.elements, index, nodes);
  62179. },
  62180. filter: function(selector) {
  62181. var me = this,
  62182. els = me.elements,
  62183. len = els.length,
  62184. out = [],
  62185. i = 0,
  62186. isFunc = typeof selector === 'function',
  62187. add, el;
  62188. for (; i < len; i++) {
  62189. el = els[i];
  62190. add = false;
  62191. if (el) {
  62192. el = me.getElement(el);
  62193. if (isFunc) {
  62194. add = selector.call(el, el, me, i) !== false;
  62195. } else {
  62196. add = el.is(selector);
  62197. }
  62198. if (add) {
  62199. out.push(me.transformElement(el));
  62200. }
  62201. }
  62202. }
  62203. me.elements = out;
  62204. return me;
  62205. },
  62206. indexOf: function(el) {
  62207. return Ext.Array.indexOf(this.elements, this.transformElement(el));
  62208. },
  62209. replaceElement: function(el, replacement, domReplace) {
  62210. var index = !isNaN(el) ? el : this.indexOf(el),
  62211. d;
  62212. if (index > -1) {
  62213. replacement = Ext.getDom(replacement);
  62214. if (domReplace) {
  62215. d = this.elements[index];
  62216. d.parentNode.insertBefore(replacement, d);
  62217. Ext.removeNode(d);
  62218. }
  62219. Ext.Array.splice(this.elements, index, 1, replacement);
  62220. }
  62221. return this;
  62222. },
  62223. clear: function(removeDom) {
  62224. var me = this,
  62225. els = me.elements,
  62226. i = els.length - 1;
  62227. if (removeDom) {
  62228. for (; i >= 0; i--) {
  62229. Ext.removeNode(els[i]);
  62230. }
  62231. }
  62232. this.elements = [];
  62233. },
  62234. addElements: function(els, root) {
  62235. if (!els) {
  62236. return this;
  62237. }
  62238. if (typeof els === "string") {
  62239. els = Ext.dom.Element.selectorFunction(els, root);
  62240. }
  62241. var yels = this.elements,
  62242. eLen = els.length,
  62243. e;
  62244. for (e = 0; e < eLen; e++) {
  62245. yels.push(Ext.get(els[e]));
  62246. }
  62247. return this;
  62248. },
  62249. first: function() {
  62250. return this.item(0);
  62251. },
  62252. last: function() {
  62253. return this.item(this.getCount() - 1);
  62254. },
  62255. contains: function(el) {
  62256. return this.indexOf(el) !== -1;
  62257. },
  62258. removeElement: function(keys, removeDom) {
  62259. var me = this,
  62260. elements = me.elements,
  62261. val, el, k, kLen;
  62262. keys = [].concat(keys);
  62263. for (k = 0 , kLen = keys.length; k < kLen; k++) {
  62264. val = keys[k];
  62265. if ((el = (elements[val] || elements[val = me.indexOf(val)]))) {
  62266. if (removeDom) {
  62267. if (el.dom) {
  62268. el.destroy();
  62269. } else {
  62270. Ext.removeNode(el);
  62271. }
  62272. }
  62273. Ext.Array.erase(elements, val, 1);
  62274. }
  62275. }
  62276. return me;
  62277. },
  62278. destroy: function() {
  62279. this.invoke('destroy', arguments);
  62280. this.callParent();
  62281. }
  62282. }, function(CompositeElementLite) {
  62283. var prototype = CompositeElementLite.prototype;
  62284. CompositeElementLite.importElementMethods();
  62285. prototype.on = prototype.addListener;
  62286. });
  62287. Ext.define('Ext.dom.CompositeElement', {
  62288. alternateClassName: 'Ext.CompositeElement',
  62289. extend: Ext.dom.CompositeElementLite,
  62290. isLite: false,
  62291. getElement: function(el) {
  62292. return el;
  62293. },
  62294. transformElement: function(el) {
  62295. return Ext.get(el);
  62296. }
  62297. });
  62298. Ext.define('Ext.dom.GarbageCollector', {
  62299. singleton: true,
  62300. interval: 30000,
  62301. constructor: function() {
  62302. var me = this;
  62303. me.lastTime = Ext.now();
  62304. me.onTick = me.onTick.bind(me);
  62305. me.onTick.$skipTimerCheck = true;
  62306. me.resume();
  62307. },
  62308. collect: function() {
  62309. var me = this,
  62310. cache = Ext.cache,
  62311. eid, dom, el, t, isGarbage, tagName;
  62312. var collectedIds = [];
  62313. for (eid in cache) {
  62314. if (!cache.hasOwnProperty(eid)) {
  62315. continue;
  62316. }
  62317. el = cache[eid];
  62318. if (el.skipGarbageCollection) {
  62319. continue;
  62320. }
  62321. dom = el.dom;
  62322. if (!dom) {
  62323. Ext.raise('Missing DOM node in element garbage collection: ' + eid);
  62324. }
  62325. try {
  62326. isGarbage = Ext.isGarbage(dom);
  62327. } catch (e) {
  62328. delete cache[eid];
  62329. collectedIds.push('#' + el.id);
  62330. continue;
  62331. }
  62332. if (isGarbage) {
  62333. isGarbage = false;
  62334. if (el && el.dom) {
  62335. tagName = el.dom.tagName;
  62336. el.collect();
  62337. collectedIds.push((tagName ? tagName : '') + '#' + el.id);
  62338. }
  62339. }
  62340. }
  62341. if (Ext.isIE9m) {
  62342. t = {};
  62343. for (eid in cache) {
  62344. if (cache.hasOwnProperty(eid)) {
  62345. t[eid] = cache[eid];
  62346. }
  62347. }
  62348. Ext.cache = Ext.dom.Element.cache = t;
  62349. }
  62350. me.lastTime = Ext.now();
  62351. return collectedIds;
  62352. },
  62353. onTick: function() {
  62354. this.timerId = null;
  62355. if (Ext.enableGarbageCollector) {
  62356. this.collect();
  62357. }
  62358. this.resume();
  62359. },
  62360. pause: function() {
  62361. var timerId = this.timerId;
  62362. if (timerId) {
  62363. this.timerId = null;
  62364. Ext.undefer(timerId);
  62365. }
  62366. },
  62367. resume: function() {
  62368. var me = this,
  62369. lastTime = me.lastTime;
  62370. if (Ext.enableGarbageCollector && (Ext.now() - lastTime) > me.interval) {
  62371. me.collect();
  62372. }
  62373. if (!me.timerId) {
  62374. me.timerId = Ext.defer(me.onTick, me.interval);
  62375. }
  62376. }
  62377. });
  62378. Ext.define('Ext.dom.TouchAction', {
  62379. singleton: true,
  62380. lastTouchStartTime: 0,
  62381. minMoveDistance: 8,
  62382. spaceRe: /\s+/,
  62383. preventSingle: null,
  62384. preventMulti: null,
  62385. disabledOverflowDom: null,
  62386. panXCls: Ext.baseCSSPrefix + 'touch-action-pan-x',
  62387. panYCls: Ext.baseCSSPrefix + 'touch-action-pan-y',
  62388. cssValues: [
  62389. 'none',
  62390. 'pan-x',
  62391. 'pan-y',
  62392. 'pan-x pan-y',
  62393. 'pinch-zoom',
  62394. 'pan-x pinch-zoom',
  62395. 'pan-y pinch-zoom',
  62396. 'pan-x pan-y pinch-zoom',
  62397. 'double-tap-zoom',
  62398. 'pan-x double-tap-zoom',
  62399. 'pan-y double-tap-zoom',
  62400. 'pan-x pan-y double-tap-zoom',
  62401. 'pinch-zoom double-tap-zoom',
  62402. 'pan-x pinch-zoom double-tap-zoom',
  62403. 'pan-y pinch-zoom double-tap-zoom',
  62404. ''
  62405. ],
  62406. objectValues: [
  62407. {
  62408. panX: false,
  62409. panY: false,
  62410. pinchZoom: false,
  62411. doubleTapZoom: false
  62412. },
  62413. {
  62414. panX: true,
  62415. panY: false,
  62416. pinchZoom: false,
  62417. doubleTapZoom: false
  62418. },
  62419. {
  62420. panX: false,
  62421. panY: true,
  62422. pinchZoom: false,
  62423. doubleTapZoom: false
  62424. },
  62425. {
  62426. panX: true,
  62427. panY: true,
  62428. pinchZoom: false,
  62429. doubleTapZoom: false
  62430. },
  62431. {
  62432. panX: false,
  62433. panY: false,
  62434. pinchZoom: true,
  62435. doubleTapZoom: false
  62436. },
  62437. {
  62438. panX: true,
  62439. panY: false,
  62440. pinchZoom: true,
  62441. doubleTapZoom: false
  62442. },
  62443. {
  62444. panX: false,
  62445. panY: true,
  62446. pinchZoom: true,
  62447. doubleTapZoom: false
  62448. },
  62449. {
  62450. panX: true,
  62451. panY: true,
  62452. pinchZoom: true,
  62453. doubleTapZoom: false
  62454. },
  62455. {
  62456. panX: false,
  62457. panY: false,
  62458. pinchZoom: false,
  62459. doubleTapZoom: true
  62460. },
  62461. {
  62462. panX: true,
  62463. panY: false,
  62464. pinchZoom: false,
  62465. doubleTapZoom: true
  62466. },
  62467. {
  62468. panX: false,
  62469. panY: true,
  62470. pinchZoom: false,
  62471. doubleTapZoom: true
  62472. },
  62473. {
  62474. panX: true,
  62475. panY: true,
  62476. pinchZoom: false,
  62477. doubleTapZoom: true
  62478. },
  62479. {
  62480. panX: false,
  62481. panY: false,
  62482. pinchZoom: true,
  62483. doubleTapZoom: true
  62484. },
  62485. {
  62486. panX: true,
  62487. panY: false,
  62488. pinchZoom: true,
  62489. doubleTapZoom: true
  62490. },
  62491. {
  62492. panX: false,
  62493. panY: true,
  62494. pinchZoom: true,
  62495. doubleTapZoom: true
  62496. },
  62497. {
  62498. panX: true,
  62499. panY: true,
  62500. pinchZoom: true,
  62501. doubleTapZoom: true
  62502. }
  62503. ],
  62504. attributeName: 'data-extTouchAction',
  62505. constructor: function() {
  62506. var me = this,
  62507. supports = Ext.supports;
  62508. if (supports.TouchAction) {
  62509. me.cssProp = 'touch-action';
  62510. } else if (supports.MSPointerEvents) {
  62511. me.cssProp = '-ms-touch-action';
  62512. }
  62513. if (supports.TouchEvents) {
  62514. Ext.getWin().on({
  62515. touchstart: 'onTouchStart',
  62516. touchmove: 'onTouchMove',
  62517. touchend: 'onTouchEnd',
  62518. scope: me,
  62519. delegated: false,
  62520. translate: false,
  62521. capture: true,
  62522. priority: 5000
  62523. });
  62524. Ext.on({
  62525. scroll: 'onScroll',
  62526. scope: me,
  62527. destroyable: true
  62528. });
  62529. }
  62530. if (Ext.isFunction(Object.freeze)) {
  62531. var objectValues = me.objectValues,
  62532. i, ln;
  62533. for (i = 0 , ln = objectValues.length; i < ln; i++) {
  62534. Object.freeze(objectValues[i]);
  62535. }
  62536. }
  62537. },
  62538. containsTargets: function(dom, e) {
  62539. var contains = true,
  62540. event = e.browserEvent,
  62541. touches = e.type === 'touchend' ? event.changedTouches : event.touches,
  62542. i, ln;
  62543. for (i = 0 , ln = touches.length; i < ln; i++) {
  62544. if (!dom.contains(touches[i].target)) {
  62545. contains = false;
  62546. break;
  62547. }
  62548. }
  62549. return contains;
  62550. },
  62551. disableOverflow: function(dom, vertical) {
  62552. var me = this,
  62553. overflowName = vertical ? 'overflow-y' : 'overflow-x',
  62554. overflowStyle, cls;
  62555. if (!me.disabledOverflowDom && !Ext.isiOS && !Ext.scrollbar.width()) {
  62556. me.disabledOverflowDom = dom;
  62557. cls = vertical ? me.panXCls : me.panYCls;
  62558. while (dom) {
  62559. overflowStyle = Ext.fly(dom).getStyle(overflowName);
  62560. if (overflowStyle === 'auto' || overflowStyle === 'scroll') {
  62561. Ext.fly(dom).addCls(cls);
  62562. }
  62563. dom = dom.parentNode;
  62564. }
  62565. }
  62566. },
  62567. get: function(dom) {
  62568. var flags = dom.getAttribute(this.attributeName),
  62569. ret = null;
  62570. if (flags != null) {
  62571. ret = this.objectValues[flags];
  62572. }
  62573. return ret;
  62574. },
  62575. getFlags: function(touchAction) {
  62576. var flags;
  62577. if (typeof touchAction === 'number') {
  62578. flags = touchAction;
  62579. } else {
  62580. flags = 0;
  62581. if (touchAction.panX !== false) {
  62582. flags |= 1;
  62583. }
  62584. if (touchAction.panY !== false) {
  62585. flags |= 2;
  62586. }
  62587. if (touchAction.pinchZoom !== false) {
  62588. flags |= 4;
  62589. }
  62590. if (touchAction.doubleTapZoom !== false) {
  62591. flags |= 8;
  62592. }
  62593. }
  62594. return flags;
  62595. },
  62596. isScrollable: function(el, vertical, forward) {
  62597. var overflowStyle = Ext.fly(el).getStyle(vertical ? 'overflow-y' : 'overflow-x'),
  62598. isScrollable = (overflowStyle === 'auto' || overflowStyle === 'scroll');
  62599. if (isScrollable) {
  62600. if (vertical) {
  62601. isScrollable = forward ? (el.scrollTop + el.clientHeight) < el.scrollHeight : el.scrollTop > 0;
  62602. } else {
  62603. isScrollable = forward ? (el.scrollLeft + el.clientWidth) < el.scrollWidth : el.scrollLeft > 0;
  62604. }
  62605. }
  62606. return isScrollable;
  62607. },
  62608. lookupFlags: function(dom) {
  62609. return parseInt((dom.getAttribute && dom.getAttribute(this.attributeName)) || 15, 10);
  62610. },
  62611. onScroll: function() {
  62612. this.scrollOccurred = true;
  62613. this.isDoubleTap = false;
  62614. },
  62615. onTouchEnd: function(e) {
  62616. var me = this,
  62617. dom = e.target,
  62618. touchCount, flags, doubleTapZoom;
  62619. touchCount = e.browserEvent.touches.length;
  62620. if (touchCount === 0) {
  62621. if (me.isDoubleTap) {
  62622. while (dom) {
  62623. flags = me.lookupFlags(dom);
  62624. if (flags != null) {
  62625. doubleTapZoom = flags & 8;
  62626. if (!doubleTapZoom) {
  62627. e.preventDefault();
  62628. }
  62629. }
  62630. dom = dom.parentNode;
  62631. }
  62632. }
  62633. me.isDoubleTap = false;
  62634. me.preventSingle = null;
  62635. me.preventMulti = null;
  62636. me.resetOverflow();
  62637. }
  62638. },
  62639. onTouchMove: function(e) {
  62640. var me = this,
  62641. prevent = null,
  62642. dom = e.target,
  62643. flags, touchCount, panX, panY, point, startPoint, isVertical, scale, distance, deltaX, deltaY, preventSingle, preventMulti;
  62644. preventSingle = me.preventSingle;
  62645. preventMulti = me.preventMulti;
  62646. touchCount = e.browserEvent.touches.length;
  62647. if ((touchCount === 1 && (preventSingle === false)) || (preventMulti === false)) {
  62648. return;
  62649. }
  62650. if ((touchCount > 1 && (preventMulti === true)) || (touchCount === 1 && (preventSingle === true))) {
  62651. prevent = true;
  62652. } else {
  62653. if (touchCount === 1) {
  62654. point = e.getPoint();
  62655. startPoint = me.startPoint;
  62656. scale = Ext.Element.getViewportScale();
  62657. distance = point.getDistanceTo(me.startPoint) * scale;
  62658. deltaX = point.x - startPoint.x;
  62659. deltaY = point.y - startPoint.y;
  62660. isVertical = Math.abs(deltaY) >= Math.abs(deltaX);
  62661. }
  62662. while (dom && (dom.nodeType === 1)) {
  62663. flags = me.lookupFlags(dom);
  62664. if (flags & 0) {
  62665. prevent = true;
  62666. } else if (touchCount === 1) {
  62667. panX = !!(flags & 1);
  62668. panY = !!(flags & 2);
  62669. if (panX && panY) {
  62670. prevent = false;
  62671. } else if (!panX && !panY) {
  62672. prevent = true;
  62673. } else if (distance >= me.minMoveDistance) {
  62674. prevent = !!((panX && isVertical) || (panY && !isVertical));
  62675. }
  62676. if (!prevent && me.isScrollable(dom, isVertical, (isVertical ? deltaY : deltaX) < 0)) {
  62677. break;
  62678. }
  62679. } else if (me.containsTargets(dom, e)) {
  62680. prevent = !(flags & 4);
  62681. } else {
  62682. prevent = false;
  62683. }
  62684. if (prevent) {
  62685. break;
  62686. }
  62687. dom = dom.parentNode;
  62688. }
  62689. }
  62690. if (touchCount === 1) {
  62691. me.preventSingle = prevent;
  62692. } else if (touchCount > 1) {
  62693. me.preventMulti = prevent;
  62694. }
  62695. if (prevent) {
  62696. e.preventDefault();
  62697. }
  62698. },
  62699. onTouchStart: function(e) {
  62700. var me = this,
  62701. time, flags, dom, panX, panY;
  62702. if (e.browserEvent.touches.length === 1) {
  62703. time = e.time;
  62704. if (!me.scrollOccurred && ((time - me.lastTouchStartTime) <= 500)) {
  62705. me.isDoubleTap = true;
  62706. }
  62707. me.lastTouchStartTime = time;
  62708. me.scrollOccurred = false;
  62709. me.startPoint = e.getPoint();
  62710. dom = e.target;
  62711. while (dom) {
  62712. flags = me.lookupFlags(dom);
  62713. if (flags != null) {
  62714. panX = !!(flags & 1);
  62715. panY = !!(flags & 2);
  62716. if (panX !== panY) {
  62717. me.disableOverflow(dom, panX);
  62718. break;
  62719. }
  62720. }
  62721. dom = dom.parentNode;
  62722. }
  62723. } else {
  62724. me.isDoubleTap = false;
  62725. }
  62726. },
  62727. resetOverflow: function() {
  62728. var me = this,
  62729. dom = me.disabledOverflowDom;
  62730. while (dom) {
  62731. Ext.fly(dom).removeCls([
  62732. me.panXCls,
  62733. me.panYCls
  62734. ]);
  62735. dom = dom.parentNode;
  62736. }
  62737. me.disabledOverflowDom = null;
  62738. },
  62739. set: function(dom, value) {
  62740. var me = this,
  62741. cssProp = me.cssProp,
  62742. flags = me.getFlags(value),
  62743. supportedFlags = (flags & Ext.supports.TouchAction),
  62744. attributeName = me.attributeName;
  62745. if (cssProp) {
  62746. Ext.fly(dom).setStyle(cssProp, me.cssValues[supportedFlags]);
  62747. }
  62748. if (flags === 15) {
  62749. dom.removeAttribute(attributeName);
  62750. } else {
  62751. dom.setAttribute(attributeName, flags);
  62752. }
  62753. }
  62754. });
  62755. Ext.define('Ext.drag.Constraint', {
  62756. alias: 'drag.constraint.base',
  62757. mixins: [
  62758. Ext.mixin.Factoryable
  62759. ],
  62760. factoryConfig: {
  62761. defaultType: 'base',
  62762. type: 'drag.constraint'
  62763. },
  62764. config: {
  62765. element: null,
  62766. horizontal: null,
  62767. region: null,
  62768. snap: null,
  62769. source: null,
  62770. vertical: null,
  62771. x: null,
  62772. y: null
  62773. },
  62774. constructor: function(config) {
  62775. this.initConfig(config);
  62776. },
  62777. applyElement: function(element) {
  62778. if (element && typeof element !== 'boolean') {
  62779. element = Ext.get(element);
  62780. }
  62781. return element || null;
  62782. },
  62783. applySnap: function(snap) {
  62784. if (typeof snap === 'number') {
  62785. snap = {
  62786. x: snap,
  62787. y: snap
  62788. };
  62789. }
  62790. return snap;
  62791. },
  62792. constrain: function(xy, info) {
  62793. var me = this,
  62794. x = xy[0],
  62795. y = xy[1],
  62796. constrainInfo = me.constrainInfo,
  62797. initial = constrainInfo.initial,
  62798. constrainX = constrainInfo.x,
  62799. constrainY = constrainInfo.y,
  62800. snap = constrainInfo.snap,
  62801. min, max;
  62802. if (!constrainInfo.vertical) {
  62803. if (snap && snap.x) {
  62804. if (snap.xFn) {
  62805. x = snap.x.call(me, info, x);
  62806. } else {
  62807. x = me.doSnap(x, initial.x, snap.x);
  62808. }
  62809. }
  62810. if (constrainX) {
  62811. min = constrainX[0];
  62812. max = constrainX[1];
  62813. if (min !== null && x < min) {
  62814. x = min;
  62815. }
  62816. if (max !== null && x > max) {
  62817. x = max;
  62818. }
  62819. }
  62820. } else {
  62821. x = initial.x;
  62822. }
  62823. if (!constrainInfo.horizontal) {
  62824. if (snap && snap.y) {
  62825. if (snap.yFn) {
  62826. y = snap.y.call(me, info, y);
  62827. } else {
  62828. y = me.doSnap(y, initial.y, snap.y);
  62829. }
  62830. }
  62831. if (constrainY) {
  62832. min = constrainY[0];
  62833. max = constrainY[1];
  62834. if (min !== null && y < min) {
  62835. y = min;
  62836. }
  62837. if (max !== null && y > max) {
  62838. y = max;
  62839. }
  62840. }
  62841. } else {
  62842. y = initial.y;
  62843. }
  62844. return [
  62845. x,
  62846. y
  62847. ];
  62848. },
  62849. destroy: function() {
  62850. this.setSource(null);
  62851. this.setElement(null);
  62852. this.callParent();
  62853. },
  62854. privates: {
  62855. constrainValue: function(a, b, resolver) {
  62856. var val = null,
  62857. aNull = a === null,
  62858. bNull = b === null;
  62859. if (!(aNull && bNull)) {
  62860. if (aNull) {
  62861. val = b;
  62862. } else if (bNull) {
  62863. val = a;
  62864. } else {
  62865. val = resolver(a, b);
  62866. }
  62867. }
  62868. return val;
  62869. },
  62870. doSnap: function(position, initial, snap) {
  62871. if (!snap) {
  62872. return position;
  62873. }
  62874. var ratio = (position - initial) / snap,
  62875. floor = Math.floor(ratio);
  62876. if (ratio - floor <= 0.5) {
  62877. ratio = floor;
  62878. } else {
  62879. ratio = floor + 1;
  62880. }
  62881. return initial + (snap * ratio);
  62882. },
  62883. onDragStart: function(info) {
  62884. var me = this,
  62885. snap = me.getSnap(),
  62886. vertical = !!me.getVertical(),
  62887. horizontal = !!me.getHorizontal(),
  62888. element = me.getElement(),
  62889. region = me.getRegion(),
  62890. proxy = info.proxy,
  62891. proxyEl = proxy.element,
  62892. x = me.getX(),
  62893. y = me.getY(),
  62894. minX = null,
  62895. maxX = null,
  62896. minY = null,
  62897. maxY = null,
  62898. rminX = null,
  62899. rmaxX = null,
  62900. rminY = null,
  62901. rmaxY = null,
  62902. pos, size;
  62903. if (element) {
  62904. if (typeof element === 'boolean') {
  62905. element = me.getSource().getElement().parent();
  62906. }
  62907. if (info.local) {
  62908. pos = element.getStyle('position');
  62909. if (pos === 'relative' || pos === 'absolute') {
  62910. size = element.getSize();
  62911. region = new Ext.util.Region(0, size.width, size.height, 0);
  62912. } else {
  62913. region = element.getRegion(true, true);
  62914. }
  62915. } else {
  62916. region = element.getRegion(true);
  62917. }
  62918. }
  62919. if (region) {
  62920. if (!vertical) {
  62921. rminX = region.left;
  62922. rmaxX = region.right - (proxyEl ? proxy.width : 0);
  62923. }
  62924. if (!horizontal) {
  62925. rminY = region.top;
  62926. rmaxY = region.bottom - (proxyEl ? proxy.height : 0);
  62927. }
  62928. }
  62929. if (!vertical && (region || x)) {
  62930. if (x) {
  62931. minX = x[0];
  62932. maxX = x[1];
  62933. }
  62934. if (minX !== null || maxX !== null || rminX !== null || rmaxX !== null) {
  62935. minX = me.constrainValue(minX, rminX, Math.max);
  62936. maxX = me.constrainValue(maxX, rmaxX, Math.min);
  62937. x = [
  62938. minX,
  62939. maxX
  62940. ];
  62941. }
  62942. }
  62943. if (!horizontal && (region || y)) {
  62944. if (y) {
  62945. minY = y[0];
  62946. maxY = y[1];
  62947. }
  62948. if (minY !== null || maxY !== null || rminY !== null || rmaxY !== null) {
  62949. minY = me.constrainValue(minY, rminY, Math.max);
  62950. maxY = me.constrainValue(maxY, rmaxY, Math.min);
  62951. y = [
  62952. minY,
  62953. maxY
  62954. ];
  62955. }
  62956. }
  62957. if (snap) {
  62958. snap = {
  62959. x: snap.x,
  62960. xFn: typeof snap.x === 'function',
  62961. y: snap.y,
  62962. yFn: typeof snap.y === 'function'
  62963. };
  62964. }
  62965. me.constrainInfo = {
  62966. initial: info.element.initial,
  62967. vertical: vertical,
  62968. horizontal: horizontal,
  62969. x: x,
  62970. y: y,
  62971. snap: snap
  62972. };
  62973. }
  62974. }
  62975. });
  62976. Ext.define('Ext.drag.Info', {
  62977. constructor: function(source, e) {
  62978. if (!source) {
  62979. return;
  62980. }
  62981. var me = this,
  62982. local = source.getLocal(),
  62983. el, proxyEl, proxy, x, xy, y, pageXY, elPageXY;
  62984. me.source = source;
  62985. me.local = local;
  62986. xy = me.getEventXY(e);
  62987. pageXY = e.getXY();
  62988. el = source.getElement();
  62989. elPageXY = el.getXY();
  62990. xy = local ? el.getLocalXY() : elPageXY;
  62991. x = xy[0];
  62992. y = xy[1];
  62993. me.initialEvent = e;
  62994. me.eventTarget = e.target;
  62995. me.cursor = {
  62996. current: {
  62997. x: x,
  62998. y: y
  62999. },
  63000. delta: {
  63001. x: 0,
  63002. y: 0
  63003. },
  63004. initial: {
  63005. x: pageXY[0],
  63006. y: pageXY[1]
  63007. },
  63008. offset: {
  63009. x: pageXY[0] - elPageXY[0],
  63010. y: pageXY[1] - elPageXY[1]
  63011. }
  63012. };
  63013. me.element = {
  63014. current: {
  63015. x: x,
  63016. y: y
  63017. },
  63018. delta: {
  63019. x: 0,
  63020. y: 0
  63021. },
  63022. initial: {
  63023. x: x,
  63024. y: y
  63025. }
  63026. };
  63027. me.proxy = {
  63028. instance: source.getProxy(),
  63029. current: {
  63030. x: x,
  63031. y: y
  63032. },
  63033. delta: {
  63034. x: 0,
  63035. y: 0
  63036. },
  63037. initial: {
  63038. x: x,
  63039. y: y
  63040. },
  63041. element: el,
  63042. isUnderCursor: false,
  63043. isElement: true
  63044. };
  63045. me.types = [];
  63046. me.data = {};
  63047. source.describe(me);
  63048. proxy = me.proxy;
  63049. proxyEl = proxy.instance.setupElement(me);
  63050. proxy.isElement = proxyEl === source.getElement();
  63051. proxy.element = proxyEl;
  63052. if (proxyEl) {
  63053. proxy.width = proxyEl.getWidth();
  63054. proxy.height = proxyEl.getHeight();
  63055. }
  63056. if (proxy.isElement) {
  63057. el = me.element;
  63058. el.current = proxy.current;
  63059. el.delta = proxy.delta;
  63060. }
  63061. me.needsCursorCheck = proxy.element && source.manager && source.manager.pointerBug;
  63062. },
  63063. cursor: null,
  63064. element: null,
  63065. eventTarget: null,
  63066. files: null,
  63067. isNative: false,
  63068. proxy: null,
  63069. source: null,
  63070. target: null,
  63071. types: null,
  63072. valid: false,
  63073. clearData: function(type) {
  63074. Ext.Array.remove(this.types, type);
  63075. delete this.data[type];
  63076. },
  63077. clone: function() {
  63078. var me = this,
  63079. ret = new Ext.drag.Info();
  63080. ret.cursor = Ext.merge({}, me.cursor);
  63081. ret.data = Ext.apply({}, me.data);
  63082. ret.element = Ext.merge({}, me.element);
  63083. ret.eventTarget = me.eventTarget;
  63084. ret.proxy = Ext.merge({}, me.proxy);
  63085. ret.source = me.source;
  63086. ret.target = me.target;
  63087. ret.types = Ext.Array.clone(me.types);
  63088. ret.valid = me.valid;
  63089. return ret;
  63090. },
  63091. getData: function(type) {
  63092. var me = this,
  63093. data = me.data,
  63094. dt = me.dataTransfer,
  63095. ret;
  63096. if (dt) {
  63097. ret = dt.getData(type);
  63098. } else {
  63099. if (!me.finalized) {
  63100. Ext.raise('Unable to call getData until the drop is complete');
  63101. }
  63102. ret = data[type];
  63103. if (typeof ret === 'function') {
  63104. data[type] = ret = ret.call(me.source, me);
  63105. }
  63106. if (!ret && ret !== 0) {
  63107. ret = '';
  63108. }
  63109. }
  63110. return Ext.Promise.resolve(ret);
  63111. },
  63112. setData: function(type, value) {
  63113. Ext.Array.include(this.types, type);
  63114. this.data[type] = value;
  63115. },
  63116. destroy: function() {
  63117. var me = this;
  63118. me.eventTarget = me.data = me.proxy = me.targetMap = me.targetMap = me.types = me.elementMap = me.possibleTargets = me.target = null;
  63119. me.callParent();
  63120. },
  63121. privates: {
  63122. data: null,
  63123. dataTransfer: null,
  63124. elementMap: null,
  63125. possibleTargets: null,
  63126. targetMap: null,
  63127. copyNativeData: function(target, e) {
  63128. var dt = e.browserEvent.dataTransfer;
  63129. this.target = target;
  63130. this.dataTransfer = dt;
  63131. this.files = dt.files;
  63132. },
  63133. finalize: function() {
  63134. var me = this,
  63135. target = me.target;
  63136. me.finalized = true;
  63137. if (target) {
  63138. target.info = null;
  63139. target.handleDrop(me);
  63140. }
  63141. },
  63142. getAlignXY: function(x, y) {
  63143. var me = this,
  63144. source = me.source,
  63145. cursorOffset = me.cursor.offset,
  63146. proxy = source.getProxy(),
  63147. proxyEl = me.proxy.element,
  63148. constrain = source.getConstrain(),
  63149. xy = [
  63150. x,
  63151. y
  63152. ];
  63153. if (proxyEl) {
  63154. if (me.proxy.isElement) {
  63155. xy[0] -= cursorOffset.x;
  63156. xy[1] -= cursorOffset.y;
  63157. } else {
  63158. xy = proxy.adjustCursorOffset(me, xy);
  63159. }
  63160. if (constrain) {
  63161. xy = constrain.constrain(xy, me);
  63162. }
  63163. }
  63164. return xy;
  63165. },
  63166. getEventXY: function(e) {
  63167. var xy = e.getXY(),
  63168. source = this.source;
  63169. if (this.local) {
  63170. xy = source.convertToLocalXY(xy);
  63171. }
  63172. return xy;
  63173. },
  63174. onNativeDragEnter: function(target, e) {
  63175. var me = this;
  63176. me.valid = target.accepts(me);
  63177. target.info = me;
  63178. me.copyNativeData(target, e);
  63179. },
  63180. onNativeDragLeave: function(target, e) {
  63181. var me = this;
  63182. if (me.target === target) {
  63183. target.info = null;
  63184. me.valid = false;
  63185. me.target = me.dataTransfer = me.files = null;
  63186. }
  63187. },
  63188. onNativeDragMove: function(target, e) {
  63189. this.copyNativeData(target, e);
  63190. },
  63191. onNativeDrop: function(target, e) {
  63192. this.copyNativeData(target, e);
  63193. target.info = null;
  63194. },
  63195. setActive: function(target) {
  63196. var me = this,
  63197. source = me.source,
  63198. current = me.target,
  63199. changed = current !== target;
  63200. if (current && changed) {
  63201. current.handleDragLeave(me);
  63202. current.info = null;
  63203. }
  63204. me.target = target;
  63205. if (target) {
  63206. if (changed) {
  63207. me.valid = !!me.possibleTargets[target.getId()] && target.accepts(me) !== false;
  63208. target.handleDragEnter(me);
  63209. target.info = me;
  63210. }
  63211. target.handleDragMove(me);
  63212. } else {
  63213. me.valid = false;
  63214. }
  63215. if (changed) {
  63216. source.getProxy().update(me);
  63217. }
  63218. },
  63219. update: function(event, beforeStart) {
  63220. var me = this,
  63221. xy = me.getEventXY(event),
  63222. x = xy[0],
  63223. y = xy[1],
  63224. alignXY = me.getAlignXY(x, y),
  63225. alignX = alignXY[0],
  63226. alignY = alignXY[1],
  63227. proxyData = me.proxy,
  63228. cursor = me.cursor,
  63229. current = cursor.current,
  63230. delta = cursor.delta,
  63231. initial = cursor.initial,
  63232. proxy = proxyData.instance;
  63233. current.x = x;
  63234. current.y = y;
  63235. delta.x = x - initial.x;
  63236. delta.y = y - initial.y;
  63237. current = proxyData.current;
  63238. delta = proxyData.delta;
  63239. initial = proxyData.initial;
  63240. current.x = alignX;
  63241. current.y = alignY;
  63242. delta.x = alignX - initial.x;
  63243. delta.y = alignY - initial.y;
  63244. if (me.needsCursorCheck) {
  63245. proxyData.isUnderCursor = !(x < alignX || y < alignY || x > proxyData.width + alignX || y > proxyData.height + alignY);
  63246. }
  63247. if (!beforeStart && proxy) {
  63248. proxy.setXY(me, alignXY);
  63249. }
  63250. }
  63251. }
  63252. });
  63253. Ext.define('Ext.drag.Item', {
  63254. mixins: [
  63255. Ext.mixin.Observable,
  63256. Ext.mixin.Identifiable
  63257. ],
  63258. config: {
  63259. autoDestroy: true,
  63260. component: null,
  63261. element: null,
  63262. groups: null
  63263. },
  63264. constructor: function(config) {
  63265. this.mixins.observable.constructor.call(this, config);
  63266. },
  63267. isDisabled: function() {
  63268. return this.disabled;
  63269. },
  63270. disable: function() {
  63271. this.disabled = true;
  63272. },
  63273. enable: function() {
  63274. this.disabled = false;
  63275. },
  63276. updateComponent: function(comp, was) {
  63277. var el;
  63278. if (comp) {
  63279. el = comp.el;
  63280. } else if (was && was.el === this.getElement()) {
  63281. el = null;
  63282. } else {
  63283. return;
  63284. }
  63285. this.setElement(el);
  63286. },
  63287. applyElement: function(element) {
  63288. return element ? Ext.get(element) : null;
  63289. },
  63290. updateElement: function() {
  63291. this.setupListeners();
  63292. },
  63293. applyGroups: function(group) {
  63294. if (typeof group === 'string') {
  63295. group = [
  63296. group
  63297. ];
  63298. }
  63299. return group;
  63300. },
  63301. destroy: function() {
  63302. var me = this,
  63303. el = me.getElement();
  63304. me.destroying = true;
  63305. me.setElement(null);
  63306. if (el && me.getAutoDestroy()) {
  63307. el.destroy();
  63308. }
  63309. me.callParent();
  63310. },
  63311. privates: {
  63312. disabled: false,
  63313. convertToLocalXY: function(xy) {
  63314. var c = this.getComponent();
  63315. if (c) {
  63316. xy = c.convertToLocalXY(xy);
  63317. } else {
  63318. xy = this.getElement().translateXY(xy[0], xy[1]);
  63319. xy = [
  63320. xy.x,
  63321. xy.y
  63322. ];
  63323. }
  63324. return xy;
  63325. },
  63326. getElListeners: Ext.privateFn,
  63327. setupListeners: function(element) {
  63328. var me = this,
  63329. elListeners = me.elListeners;
  63330. element = element || me.getElement();
  63331. if (elListeners) {
  63332. elListeners.destroy();
  63333. me.elListeners = null;
  63334. }
  63335. if (element) {
  63336. me.elListeners = element.on(Ext.apply({
  63337. scope: me,
  63338. destroyable: true
  63339. }, me.getElListeners()));
  63340. }
  63341. }
  63342. }
  63343. });
  63344. Ext.define('Ext.drag.Manager', {
  63345. singleton: true,
  63346. dragCls: Ext.baseCSSPrefix + 'drag-body',
  63347. pointerBug: Ext.isTouch || (!Ext.supports.CSSPointerEvents || Ext.isIE10m || Ext.isOpera),
  63348. constructor: function() {
  63349. this.targets = {};
  63350. this.nativeTargets = [];
  63351. Ext.onReady(this.init, this);
  63352. },
  63353. init: function() {
  63354. Ext.getDoc().on({
  63355. scope: this,
  63356. dragenter: {
  63357. capture: true,
  63358. fn: 'onNativeDragEnter'
  63359. },
  63360. dragleave: 'onNativeDragLeave',
  63361. dragover: 'onNativeDragOver',
  63362. drop: 'onNativeDrop'
  63363. });
  63364. },
  63365. destroy: function() {
  63366. var me = this,
  63367. targets = me.targets,
  63368. key;
  63369. me.destroying = true;
  63370. for (key in targets) {
  63371. targets[key].destroy();
  63372. }
  63373. me.targets = null;
  63374. me.callParent();
  63375. },
  63376. privates: {
  63377. elementFromPoint: function(x, y) {
  63378. if (Ext.rootInheritedState.rtl) {
  63379. x = Ext.Element.getViewportWidth() - x;
  63380. }
  63381. return Ext.dom.Element.fromPagePoint(x, y, true);
  63382. },
  63383. getAtPoint: function(info) {
  63384. var current = info.cursor.current,
  63385. elementMap = info.elementMap,
  63386. isUnderCursor = info.proxy.isUnderCursor,
  63387. proxyEl = this.pointerBug && isUnderCursor ? info.proxy.element.dom : null,
  63388. target, el;
  63389. if (proxyEl) {
  63390. proxyEl.style.visibility = 'hidden';
  63391. }
  63392. el = this.elementFromPoint(current.x, current.y);
  63393. if (proxyEl) {
  63394. proxyEl.style.visibility = 'visible';
  63395. }
  63396. while (el) {
  63397. target = elementMap[el.id];
  63398. if (target) {
  63399. return target;
  63400. }
  63401. el = el.parentNode;
  63402. }
  63403. return null;
  63404. },
  63405. getNativeDragInfo: function(e) {
  63406. var info = this.nativeDragInfo;
  63407. if (!info) {
  63408. this.nativeDragInfo = info = new Ext.drag.Info();
  63409. info.isNative = true;
  63410. }
  63411. return info;
  63412. },
  63413. onDragCancel: function() {
  63414. Ext.getBody().removeCls(this.dragCls);
  63415. },
  63416. onDragEnd: function(info, e) {
  63417. info.finalize();
  63418. Ext.getBody().removeCls(this.dragCls);
  63419. },
  63420. onDragMove: function(info, e) {
  63421. this.processDrag(info);
  63422. },
  63423. onDragStart: function(info, e) {
  63424. var me = this,
  63425. source = info.source,
  63426. targets = me.targets,
  63427. groups = source.getGroups(),
  63428. targetMap = {},
  63429. possibleTargets = {},
  63430. elementMap = {},
  63431. id, target, targetGroups, groupMap, groupOk, len, i;
  63432. elementMap = {};
  63433. possibleTargets = {};
  63434. if (groups) {
  63435. groupMap = Ext.Array.toMap(groups);
  63436. }
  63437. for (id in targets) {
  63438. target = targets[id];
  63439. if (!target.isDisabled()) {
  63440. groupOk = false;
  63441. targetGroups = target.getGroups();
  63442. if (!groupMap && !targetGroups) {
  63443. groupOk = true;
  63444. } else if (groupMap && targetGroups) {
  63445. for (i = 0 , len = targetGroups.length; i < len; ++i) {
  63446. if (groupMap[targetGroups[i]]) {
  63447. groupOk = true;
  63448. break;
  63449. }
  63450. }
  63451. }
  63452. if (groupOk) {
  63453. possibleTargets[id] = target;
  63454. }
  63455. }
  63456. targetMap[id] = target;
  63457. elementMap[target.getElement().id] = target;
  63458. }
  63459. info.possibleTargets = possibleTargets;
  63460. info.targetMap = targetMap;
  63461. info.elementMap = elementMap;
  63462. Ext.getBody().addCls(me.dragCls);
  63463. me.processDrag(info);
  63464. },
  63465. onNativeDragEnter: function(e) {
  63466. var nativeTargets = this.nativeTargets,
  63467. target = e.target;
  63468. e.preventDefault();
  63469. if (nativeTargets[nativeTargets.length - 1] !== target) {
  63470. nativeTargets.push(target);
  63471. }
  63472. },
  63473. onNativeDragLeave: function(e) {
  63474. var nativeTargets = this.nativeTargets;
  63475. Ext.Array.remove(nativeTargets, e.target);
  63476. if (nativeTargets.length === 0) {
  63477. this.nativeDragInfo = null;
  63478. }
  63479. },
  63480. onNativeDragOver: function(e) {
  63481. e.preventDefault();
  63482. },
  63483. onNativeDrop: function(e) {
  63484. e.preventDefault();
  63485. this.nativeTargets.length = 0;
  63486. this.nativeDragInfo = null;
  63487. },
  63488. processDrag: function(info) {
  63489. info.setActive(this.getAtPoint(info));
  63490. },
  63491. register: function(target) {
  63492. this.targets[target.getId()] = target;
  63493. },
  63494. unregister: function(target) {
  63495. var id;
  63496. if (this.destroying) {
  63497. return;
  63498. }
  63499. id = target.getId();
  63500. this.targets[id] = null;
  63501. delete this.targets[id];
  63502. }
  63503. }
  63504. });
  63505. Ext.define('Ext.drag.Source', {
  63506. extend: Ext.drag.Item,
  63507. defaultIdPrefix: 'source-',
  63508. config: {
  63509. activateOnLongPress: false,
  63510. activeCls: null,
  63511. constrain: null,
  63512. handle: null,
  63513. local: null,
  63514. proxy: 'original',
  63515. revert: false
  63516. },
  63517. dragging: false,
  63518. constructor: function(config) {
  63519. var describe = config && config.describe;
  63520. if (describe) {
  63521. this.describe = describe;
  63522. config = Ext.apply({}, config);
  63523. delete config.describe;
  63524. }
  63525. this.callParent([
  63526. config
  63527. ]);
  63528. this.manager = Ext.drag['Manager'];
  63529. },
  63530. describe: Ext.emptyFn,
  63531. isDragging: function() {
  63532. return this.dragging;
  63533. },
  63534. beforeDragStart: Ext.emptyFn,
  63535. onDragCancel: Ext.emptyFn,
  63536. onDragEnd: Ext.emptyFn,
  63537. onDragMove: Ext.emptyFn,
  63538. onDragStart: Ext.emptyFn,
  63539. applyActivateOnLongPress: function(activateOnLongPress) {
  63540. if (typeof activateOnLongPress === 'string') {
  63541. activateOnLongPress = [
  63542. activateOnLongPress
  63543. ];
  63544. }
  63545. return activateOnLongPress;
  63546. },
  63547. updateActivateOnLongPress: function(activateOnLongPress) {
  63548. if (!this.isConfiguring) {
  63549. this.setupListeners();
  63550. }
  63551. },
  63552. updateActiveCls: function(cls, oldCls) {
  63553. var el;
  63554. if (this.dragging) {
  63555. el = this.getElement();
  63556. el.replaceCls(oldCls, cls);
  63557. }
  63558. },
  63559. applyConstrain: function(constrain) {
  63560. if (constrain && !constrain.$isClass) {
  63561. if (constrain.isRegion) {
  63562. constrain = {
  63563. region: constrain
  63564. };
  63565. } else if (constrain.isElement || !Ext.isObject(constrain)) {
  63566. constrain = {
  63567. element: constrain
  63568. };
  63569. }
  63570. constrain = Ext.apply({
  63571. source: this
  63572. }, constrain);
  63573. constrain = Ext.Factory.dragConstraint(constrain);
  63574. }
  63575. return constrain;
  63576. },
  63577. updateElement: function(element, oldElement) {
  63578. if (oldElement && !oldElement.destroyed) {
  63579. oldElement.un('dragstart', 'stopNativeDrag', this);
  63580. }
  63581. if (element && !this.getHandle()) {
  63582. element.setTouchAction({
  63583. panX: false,
  63584. panY: false
  63585. });
  63586. element.on('dragstart', 'stopNativeDrag', this, {
  63587. translate: false,
  63588. delegated: false
  63589. });
  63590. }
  63591. this.callParent([
  63592. element,
  63593. oldElement
  63594. ]);
  63595. },
  63596. updateHandle: function() {
  63597. if (!this.isConfiguring) {
  63598. this.setupListeners();
  63599. }
  63600. },
  63601. applyProxy: function(proxy) {
  63602. if (proxy) {
  63603. proxy = Ext.Factory.dragproxy(proxy);
  63604. }
  63605. return proxy;
  63606. },
  63607. updateProxy: function(proxy, oldProxy) {
  63608. if (oldProxy) {
  63609. oldProxy.destroy();
  63610. }
  63611. if (proxy) {
  63612. proxy.setSource(this);
  63613. }
  63614. },
  63615. resolveListenerScope: function() {
  63616. var ownerCmp = this.ownerCmp,
  63617. a = arguments;
  63618. if (ownerCmp) {
  63619. return ownerCmp.resolveListenerScope.apply(ownerCmp, a);
  63620. }
  63621. return this.callParent(a);
  63622. },
  63623. destroy: function() {
  63624. var me = this;
  63625. me.manager = me.initialEvent = null;
  63626. me.setConstrain(null);
  63627. me.setProxy(null);
  63628. me.callParent();
  63629. },
  63630. privates: {
  63631. draggingCls: Ext.baseCSSPrefix + 'drag-dragging',
  63632. info: null,
  63633. revertCls: Ext.baseCSSPrefix + 'drag-revert',
  63634. canActivateOnLongPress: function(e) {
  63635. var activate = this.getActivateOnLongPress();
  63636. return !!(activate && (activate === true || Ext.Array.contains(activate, e.pointerType)));
  63637. },
  63638. dragCleanup: function(info) {
  63639. var me = this,
  63640. cls = me.getActiveCls(),
  63641. proxy = me.getProxy(),
  63642. el = me.getElement(),
  63643. proxyEl = info ? info.proxy.element : null;
  63644. if (cls) {
  63645. el.removeCls(cls);
  63646. }
  63647. if (proxyEl) {
  63648. proxyEl.removeCls(me.draggingCls);
  63649. }
  63650. proxy.cleanup(info);
  63651. me.dragging = false;
  63652. me.initialEvent = me.info = null;
  63653. },
  63654. getElListeners: function() {
  63655. var handle = this.getHandle(),
  63656. o = {
  63657. touchstart: 'handleTouchStart',
  63658. dragstart: 'handleDragStart',
  63659. drag: 'handleDragMove',
  63660. dragend: 'handleDragEnd',
  63661. dragcancel: 'handleDragCancel'
  63662. };
  63663. if (handle) {
  63664. o.dragstart = {
  63665. fn: o.dragstart,
  63666. delegate: handle
  63667. };
  63668. }
  63669. if (this.getActivateOnLongPress()) {
  63670. o.longpress = 'handleLongPress';
  63671. }
  63672. return o;
  63673. },
  63674. handleDragCancel: function(e) {
  63675. var me = this,
  63676. info = me.info,
  63677. manager = me.manager;
  63678. if (manager) {
  63679. manager.onDragCancel(info, e);
  63680. }
  63681. me.onDragCancel(info);
  63682. if (me.hasListeners.dragcancel) {
  63683. me.fireEvent('dragcancel', me, info, e);
  63684. }
  63685. Ext.fireEvent('dragcancel', me, info, e);
  63686. me.dragCleanup(info);
  63687. },
  63688. handleDragEnd: function(e) {
  63689. if (!this.dragging) {
  63690. return;
  63691. }
  63692. var me = this,
  63693. manager = me.manager,
  63694. revert = me.getRevert(),
  63695. info = me.info,
  63696. proxy = info.proxy;
  63697. info.update(e);
  63698. if (manager) {
  63699. manager.onDragEnd(info, e);
  63700. }
  63701. me.onDragEnd(info);
  63702. if (me.hasListeners.dragend) {
  63703. me.fireEvent('dragend', me, info, e);
  63704. }
  63705. Ext.fireEvent('dragend', me, info, e);
  63706. proxy = proxy.instance;
  63707. if (revert && proxy) {
  63708. proxy.dragRevert(info, me.revertCls, revert, function() {
  63709. me.dragCleanup(info);
  63710. });
  63711. } else {
  63712. me.dragCleanup(info);
  63713. }
  63714. },
  63715. handleDragMove: function(e) {
  63716. var me = this,
  63717. info = me.info,
  63718. manager = me.manager;
  63719. if (!me.dragging) {
  63720. return;
  63721. }
  63722. e.stopPropagation();
  63723. e.claimGesture();
  63724. info.update(e);
  63725. if (manager) {
  63726. manager.onDragMove(info, e);
  63727. }
  63728. me.onDragMove(info);
  63729. if (me.hasListeners.dragmove) {
  63730. me.fireEvent('dragmove', me, info, e);
  63731. }
  63732. },
  63733. handleDragStart: function(e) {
  63734. var me = this,
  63735. hasListeners = me.hasListeners,
  63736. manager = me.manager,
  63737. constrain = me.getConstrain(),
  63738. initialEvent = me.initialEvent,
  63739. el, cls, info, cancel, proxyEl;
  63740. if (me.preventStart(e)) {
  63741. return false;
  63742. }
  63743. if (hasListeners.initdragconstraints) {
  63744. me.fireEvent('initdragconstraints', me, e);
  63745. }
  63746. me.info = info = new Ext.drag.Info(me, initialEvent);
  63747. me.setup(info);
  63748. if (constrain) {
  63749. constrain.onDragStart(info);
  63750. }
  63751. info.update(e, true);
  63752. cancel = me.beforeDragStart(info) === false;
  63753. if (!cancel && hasListeners.beforedragstart) {
  63754. cancel = me.fireEvent('beforedragstart', me, info, e) === false;
  63755. }
  63756. if (cancel) {
  63757. me.dragCleanup();
  63758. return false;
  63759. }
  63760. e.claimGesture();
  63761. me.dragging = true;
  63762. cls = me.getActiveCls();
  63763. el = me.getElement();
  63764. if (cls) {
  63765. el.addCls(cls);
  63766. }
  63767. proxyEl = info.proxy.element;
  63768. if (proxyEl) {
  63769. proxyEl.addCls(me.draggingCls);
  63770. }
  63771. info.update(e);
  63772. if (manager) {
  63773. manager.onDragStart(info, e);
  63774. }
  63775. me.onDragStart(info);
  63776. if (hasListeners.dragstart) {
  63777. me.fireEvent('dragstart', me, info, e);
  63778. }
  63779. Ext.fireEvent('dragstart', me, info, e);
  63780. },
  63781. handleLongPress: function(e) {
  63782. if (!this.isDisabled() && this.canActivateOnLongPress(e)) {
  63783. this.initialEvent = e;
  63784. e.startDrag();
  63785. }
  63786. },
  63787. handleTouchStart: function(e) {
  63788. if (!this.isDisabled()) {
  63789. this.initialEvent = e;
  63790. }
  63791. },
  63792. preventStart: function(e) {
  63793. return this.isDisabled() || (!e.longpress && this.canActivateOnLongPress(e));
  63794. },
  63795. setup: Ext.privateFn,
  63796. stopNativeDrag: function(e) {
  63797. e.preventDefault();
  63798. }
  63799. }
  63800. });
  63801. Ext.define('Ext.drag.Target', {
  63802. extend: Ext.drag.Item,
  63803. defaultIdPrefix: 'target-',
  63804. config: {
  63805. invalidCls: '',
  63806. validCls: ''
  63807. },
  63808. constructor: function(config) {
  63809. var me = this,
  63810. accepts = config && config.accepts;
  63811. if (accepts) {
  63812. me.accepts = accepts;
  63813. config = Ext.apply({}, config);
  63814. delete config.accepts;
  63815. }
  63816. me.callParent([
  63817. config
  63818. ]);
  63819. Ext.drag.Manager.register(me);
  63820. },
  63821. accepts: function(info) {
  63822. return true;
  63823. },
  63824. disable: function() {
  63825. this.callParent();
  63826. this.setupListeners(null);
  63827. },
  63828. enable: function() {
  63829. this.callParent();
  63830. this.setupListeners();
  63831. },
  63832. beforeDrop: Ext.emptyFn,
  63833. onDrop: Ext.emptyFn,
  63834. onDragEnter: Ext.emptyFn,
  63835. onDragLeave: Ext.emptyFn,
  63836. onDragMove: Ext.emptyFn,
  63837. updateInvalidCls: function(invalidCls, oldInvalidCls) {
  63838. var info = this.info;
  63839. this.doUpdateCls(info && !info.valid, invalidCls, oldInvalidCls);
  63840. },
  63841. updateValidCls: function(validCls, oldValidCls) {
  63842. var info = this.info;
  63843. this.doUpdateCls(info && info.valid, validCls, oldValidCls);
  63844. },
  63845. destroy: function() {
  63846. Ext.drag.Manager.unregister(this);
  63847. this.callParent();
  63848. },
  63849. privates: {
  63850. doUpdateCls: function(needsAdd, cls, oldCls) {
  63851. var el = this.getElement();
  63852. if (oldCls) {
  63853. el.removeCls(oldCls);
  63854. }
  63855. if (cls && needsAdd) {
  63856. el.addCls(cls);
  63857. }
  63858. },
  63859. getElListeners: function() {
  63860. return {
  63861. dragenter: 'handleNativeDragEnter',
  63862. dragleave: 'handleNativeDragLeave',
  63863. dragover: 'handleNativeDragMove',
  63864. drop: 'handleNativeDrop'
  63865. };
  63866. },
  63867. handleDrop: function(info) {
  63868. var me = this,
  63869. hasListeners = me.hasListeners,
  63870. valid = info.valid;
  63871. me.getElement().removeCls([
  63872. me.getInvalidCls(),
  63873. me.getValidCls()
  63874. ]);
  63875. if (valid && me.beforeDrop(info) !== false) {
  63876. if (hasListeners.beforedrop && me.fireEvent('beforedrop', me, info) === false) {
  63877. return false;
  63878. }
  63879. me.onDrop(info);
  63880. if (hasListeners.drop) {
  63881. me.fireEvent('drop', me, info);
  63882. }
  63883. } else {
  63884. return false;
  63885. }
  63886. },
  63887. handleDragEnter: function(info) {
  63888. var me = this,
  63889. cls = info.valid ? me.getValidCls() : me.getInvalidCls();
  63890. if (cls) {
  63891. me.getElement().addCls(cls);
  63892. }
  63893. me.onDragEnter(info);
  63894. if (me.hasListeners.dragenter) {
  63895. me.fireEvent('dragenter', me, info);
  63896. }
  63897. },
  63898. handleDragLeave: function(info) {
  63899. var me = this;
  63900. me.getElement().removeCls([
  63901. me.getInvalidCls(),
  63902. me.getValidCls()
  63903. ]);
  63904. me.onDragLeave(info);
  63905. if (me.hasListeners.dragleave) {
  63906. me.fireEvent('dragleave', me, info);
  63907. }
  63908. },
  63909. handleDragMove: function(info) {
  63910. var me = this;
  63911. me.onDragMove(info);
  63912. if (me.hasListeners.dragmove) {
  63913. me.fireEvent('dragmove', me, info);
  63914. }
  63915. },
  63916. handleNativeDragEnter: function(e) {
  63917. var me = this,
  63918. info = Ext.drag.Manager.getNativeDragInfo(e);
  63919. info.onNativeDragEnter(me, e);
  63920. if (me.hasListeners.dragenter) {
  63921. me.fireEvent('dragenter', me, info);
  63922. }
  63923. },
  63924. handleNativeDragLeave: function(e) {
  63925. var me = this,
  63926. info = Ext.drag.Manager.getNativeDragInfo(e);
  63927. info.onNativeDragLeave(me, e);
  63928. if (me.hasListeners.dragleave) {
  63929. me.fireEvent('dragleave', me, info);
  63930. }
  63931. },
  63932. handleNativeDragMove: function(e) {
  63933. var me = this,
  63934. info = Ext.drag.Manager.getNativeDragInfo(e);
  63935. info.onNativeDragMove(me, e);
  63936. if (me.hasListeners.dragmove) {
  63937. me.fireEvent('dragmove', me, info);
  63938. }
  63939. },
  63940. handleNativeDrop: function(e) {
  63941. var me = this,
  63942. hasListeners = me.hasListeners,
  63943. info = Ext.drag.Manager.getNativeDragInfo(e),
  63944. valid = info.valid;
  63945. info.onNativeDrop(me, e);
  63946. if (valid) {
  63947. if (hasListeners.beforedrop && me.fireEvent('beforedrop', me, info) === false) {
  63948. return;
  63949. }
  63950. if (hasListeners.drop) {
  63951. me.fireEvent('drop', me, info);
  63952. }
  63953. }
  63954. }
  63955. }
  63956. });
  63957. Ext.define('Ext.drag.proxy.None', {
  63958. mixins: [
  63959. Ext.mixin.Factoryable
  63960. ],
  63961. alias: 'drag.proxy.none',
  63962. factoryConfig: {
  63963. aliasPrefix: 'drag.proxy.',
  63964. type: 'dragproxy'
  63965. },
  63966. config: {
  63967. source: null
  63968. },
  63969. constructor: function(config) {
  63970. var getElement = config && config.getElement;
  63971. if (getElement) {
  63972. this.getElement = getElement;
  63973. config = Ext.apply({}, config);
  63974. delete config.getElement;
  63975. }
  63976. this.initConfig(config);
  63977. },
  63978. cleanup: Ext.emptyFn,
  63979. dragRevert: function(info, revertCls, options, callback) {
  63980. var positionable = this.getPositionable(info),
  63981. initial = info.proxy.initial;
  63982. positionable.addCls(revertCls);
  63983. positionable.setXY([
  63984. initial.x,
  63985. initial.y
  63986. ], Ext.apply({
  63987. callback: function() {
  63988. positionable.removeCls(revertCls);
  63989. callback();
  63990. }
  63991. }, options));
  63992. },
  63993. getElement: function() {
  63994. return null;
  63995. },
  63996. getPositionable: function() {
  63997. return this.element;
  63998. },
  63999. setXY: function(info, xy, animation) {
  64000. var positionable = this.getPositionable(info);
  64001. if (positionable) {
  64002. positionable.setXY(xy, animation);
  64003. }
  64004. },
  64005. update: Ext.emptyFn,
  64006. privates: {
  64007. setupElement: function(info) {
  64008. return (this.element = this.getElement(info));
  64009. },
  64010. adjustCursorOffset: function(info, pos) {
  64011. return pos;
  64012. }
  64013. }
  64014. });
  64015. Ext.define('Ext.drag.proxy.Original', {
  64016. extend: Ext.drag.proxy.None,
  64017. alias: 'drag.proxy.original',
  64018. getElement: function(info) {
  64019. return info.source.getElement();
  64020. },
  64021. getPositionable: function(info) {
  64022. var source = info.source;
  64023. return source.getComponent() || source.getElement();
  64024. }
  64025. });
  64026. Ext.define('Ext.drag.proxy.Placeholder', {
  64027. extend: Ext.drag.proxy.None,
  64028. alias: 'drag.proxy.placeholder',
  64029. config: {
  64030. cls: '',
  64031. cursorOffset: [
  64032. 12,
  64033. 20
  64034. ],
  64035. html: null,
  64036. invalidCls: '',
  64037. validCls: ''
  64038. },
  64039. placeholderCls: Ext.baseCSSPrefix + 'drag-proxy-placeholder',
  64040. cleanup: function() {
  64041. this.element = Ext.destroy(this.element);
  64042. },
  64043. getElement: function() {
  64044. var el = Ext.getBody().createChild({
  64045. cls: this.getCls(),
  64046. html: this.getHtml()
  64047. });
  64048. el.addCls(this.placeholderCls);
  64049. el.setTouchAction({
  64050. panX: false,
  64051. panY: false
  64052. });
  64053. return el;
  64054. },
  64055. update: function(info) {
  64056. var el = this.element,
  64057. invalidCls = this.getInvalidCls(),
  64058. validCls = this.getValidCls(),
  64059. valid = info.valid;
  64060. if (info.target) {
  64061. el.replaceCls(valid ? invalidCls : validCls, valid ? validCls : invalidCls);
  64062. } else {
  64063. el.removeCls([
  64064. invalidCls,
  64065. validCls
  64066. ]);
  64067. }
  64068. },
  64069. updateCls: function(cls, oldCls) {
  64070. var el = this.element;
  64071. if (el) {
  64072. if (oldCls) {
  64073. el.removeCls(oldCls);
  64074. }
  64075. if (cls) {
  64076. el.addCls(cls);
  64077. }
  64078. }
  64079. },
  64080. updateHtml: function(html) {
  64081. var el = this.element;
  64082. if (el) {
  64083. el.setHtml(html || '');
  64084. }
  64085. },
  64086. updateInvalidCls: function(invalidCls, oldInvalidCls) {
  64087. this.doUpdateCls(invalidCls, oldInvalidCls);
  64088. },
  64089. updateValidCls: function(validCls, oldValidCls) {
  64090. this.doUpdateCls(validCls, oldValidCls);
  64091. },
  64092. destroy: function() {
  64093. this.element = Ext.destroy(this.element);
  64094. this.callParent();
  64095. },
  64096. privates: {
  64097. adjustCursorOffset: function(info, xy) {
  64098. var offset = this.getCursorOffset();
  64099. if (offset) {
  64100. xy[0] += (offset[0] || 0);
  64101. xy[1] += (offset[1] || 0);
  64102. }
  64103. return xy;
  64104. },
  64105. doUpdateCls: function(cls, oldCls) {
  64106. var el = this.element,
  64107. hasCls;
  64108. if (el) {
  64109. if (oldCls) {
  64110. hasCls = cls && el.hasCls(oldCls);
  64111. el.removeCls(oldCls);
  64112. }
  64113. if (cls && hasCls) {
  64114. el.addCls(cls);
  64115. }
  64116. }
  64117. }
  64118. }
  64119. });
  64120. Ext.define('Ext.event.gesture.Recognizer', {
  64121. mixins: [
  64122. Ext.mixin.Identifiable
  64123. ],
  64124. priority: 0,
  64125. handledEvents: [],
  64126. isStarted: false,
  64127. config: {
  64128. onRecognized: Ext.emptyFn,
  64129. callbackScope: null
  64130. },
  64131. constructor: function(config) {
  64132. this.initConfig(config);
  64133. Ext.event.publisher.Gesture.instance.registerRecognizer(this);
  64134. },
  64135. onStart: Ext.emptyFn,
  64136. onEnd: Ext.emptyFn,
  64137. onTouchStart: Ext.emptyFn,
  64138. onTouchMove: Ext.emptyFn,
  64139. onTouchEnd: function() {
  64140. return this.reset();
  64141. },
  64142. onTouchCancel: function(e) {
  64143. return this.cancel(e);
  64144. },
  64145. fire: function(eventName, e, info, isCancel) {
  64146. this.getOnRecognized().call(this.getCallbackScope(), this, eventName, e, info, isCancel);
  64147. },
  64148. cancel: function(e) {
  64149. if (this.isStarted) {
  64150. this.onCancel(e);
  64151. }
  64152. return this.reset();
  64153. },
  64154. onCancel: Ext.emptyFn,
  64155. reset: function() {
  64156. this.isStarted = false;
  64157. return false;
  64158. }
  64159. });
  64160. Ext.define('Ext.event.gesture.SingleTouch', {
  64161. extend: Ext.event.gesture.Recognizer,
  64162. isSingleTouch: true,
  64163. onTouchStart: function(e) {
  64164. if (e.touches.length > 1) {
  64165. return this.cancel(e);
  64166. }
  64167. }
  64168. });
  64169. Ext.define('Ext.event.gesture.DoubleTap', {
  64170. extend: Ext.event.gesture.SingleTouch,
  64171. priority: 300,
  64172. config: {
  64173. moveDistance: 8,
  64174. tapDistance: 24,
  64175. maxDuration: 300
  64176. },
  64177. handledEvents: [
  64178. 'singletap',
  64179. 'doubletap'
  64180. ],
  64181. singleTapTimer: null,
  64182. startTime: 0,
  64183. lastTapTime: 0,
  64184. onTouchStart: function(e) {
  64185. var me = this,
  64186. ret = me.callParent([
  64187. e
  64188. ]),
  64189. lastStartPoint;
  64190. if (ret !== false) {
  64191. me.isStarted = true;
  64192. lastStartPoint = me.lastStartPoint = e.changedTouches[0].point;
  64193. me.startPoint = me.startPoint || lastStartPoint;
  64194. me.startTime = e.time;
  64195. Ext.undefer(me.singleTapTimer);
  64196. }
  64197. return ret;
  64198. },
  64199. onTouchMove: function(e) {
  64200. var me = this,
  64201. point = e.changedTouches[0].point,
  64202. scale = Ext.Element.getViewportScale(),
  64203. distance = Math.round(Math.abs(point.getDistanceTo(me.lastStartPoint) * scale));
  64204. if (distance >= me.getMoveDistance()) {
  64205. return me.cancel(e);
  64206. }
  64207. },
  64208. onTouchEnd: function(e) {
  64209. var me = this,
  64210. maxDuration = me.getMaxDuration(),
  64211. time = e.time,
  64212. target = e.target,
  64213. lastTapTime = me.lastTapTime,
  64214. lastTarget = me.lastTarget,
  64215. point = e.changedTouches[0].point,
  64216. duration, scale, distance;
  64217. me.lastTapTime = time;
  64218. me.lastTarget = target;
  64219. if (lastTapTime) {
  64220. duration = time - lastTapTime;
  64221. if (duration <= maxDuration) {
  64222. scale = Ext.Element.getViewportScale();
  64223. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  64224. if (distance <= me.getTapDistance()) {
  64225. if (target !== lastTarget) {
  64226. return me.cancel(e);
  64227. }
  64228. me.lastTarget = null;
  64229. me.lastTapTime = 0;
  64230. me.fire('doubletap', e, {
  64231. touch: e.changedTouches[0],
  64232. duration: duration
  64233. });
  64234. return me.callParent([
  64235. e
  64236. ]);
  64237. }
  64238. }
  64239. }
  64240. if (time - me.startTime > maxDuration) {
  64241. me.fire('singletap', e);
  64242. me.reset();
  64243. } else {
  64244. me.setSingleTapTimer(e);
  64245. }
  64246. },
  64247. setSingleTapTimer: function(e) {
  64248. var me = this;
  64249. me.singleTapTimer = Ext.defer(function() {
  64250. me.fire('singletap', e);
  64251. me.reset();
  64252. }, me.getMaxDuration());
  64253. },
  64254. reset: function() {
  64255. var me = this;
  64256. Ext.undefer(me.singleTapTimer);
  64257. me.startTime = me.lastTapTime = 0;
  64258. me.lastStartPoint = me.startPoint = me.singleTapTimer = null;
  64259. return me.callParent();
  64260. }
  64261. }, function(DoubleTap) {
  64262. var gestures = Ext.manifest.gestures;
  64263. DoubleTap.instance = new DoubleTap(gestures && gestures.doubleTap);
  64264. });
  64265. Ext.define('Ext.event.gesture.Drag', {
  64266. extend: Ext.event.gesture.SingleTouch,
  64267. priority: 100,
  64268. startPoint: null,
  64269. previousPoint: null,
  64270. lastPoint: null,
  64271. handledEvents: [
  64272. 'dragstart',
  64273. 'drag',
  64274. 'dragend',
  64275. 'dragcancel'
  64276. ],
  64277. config: {
  64278. minDistance: 8
  64279. },
  64280. constructor: function() {
  64281. this.callParent(arguments);
  64282. this.initInfo();
  64283. },
  64284. initInfo: function() {
  64285. this.info = {
  64286. touch: null,
  64287. previous: {
  64288. x: 0,
  64289. y: 0
  64290. },
  64291. x: 0,
  64292. y: 0,
  64293. delta: {
  64294. x: 0,
  64295. y: 0
  64296. },
  64297. absDelta: {
  64298. x: 0,
  64299. y: 0
  64300. },
  64301. flick: {
  64302. velocity: {
  64303. x: 0,
  64304. y: 0
  64305. }
  64306. },
  64307. direction: {
  64308. x: 0,
  64309. y: 0
  64310. },
  64311. time: 0,
  64312. previousTime: {
  64313. x: 0,
  64314. y: 0
  64315. },
  64316. longpress: false
  64317. };
  64318. },
  64319. onTouchStart: function(e) {
  64320. var me = this,
  64321. ret = me.callParent([
  64322. e
  64323. ]);
  64324. if (ret !== false) {
  64325. me.startTime = e.time;
  64326. me.startPoint = e.changedTouches[0].point;
  64327. }
  64328. return ret;
  64329. },
  64330. tryDragStart: function(e) {
  64331. var me = this,
  64332. point = e.changedTouches[0].point,
  64333. minDistance = me.getMinDistance(),
  64334. scale = Ext.Element.getViewportScale(),
  64335. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  64336. if (distance >= minDistance) {
  64337. me.doDragStart(e);
  64338. }
  64339. },
  64340. doDragStart: function(e, isLongPress) {
  64341. var me = this,
  64342. touch = e.changedTouches[0],
  64343. point = touch.point,
  64344. info = me.info,
  64345. time;
  64346. if (isLongPress) {
  64347. time = Ext.now();
  64348. me.startTime = time;
  64349. me.startPoint = point;
  64350. info.longpress = true;
  64351. } else {
  64352. time = e.time;
  64353. }
  64354. me.isStarted = true;
  64355. me.previousPoint = me.lastPoint = point;
  64356. me.resetInfo('x', e, touch);
  64357. me.resetInfo('y', e, touch);
  64358. info.time = time;
  64359. me.fire('dragstart', e, info);
  64360. },
  64361. onTouchMove: function(e) {
  64362. var me = this,
  64363. touch, point;
  64364. if (!me.startPoint) {
  64365. return;
  64366. }
  64367. if (!me.isStarted) {
  64368. me.tryDragStart(e);
  64369. }
  64370. if (!me.isStarted) {
  64371. return;
  64372. }
  64373. touch = e.changedTouches[0];
  64374. point = touch.point;
  64375. if (me.lastPoint) {
  64376. me.previousPoint = me.lastPoint;
  64377. }
  64378. me.lastPoint = point;
  64379. me.lastMoveEvent = e;
  64380. me.updateInfo('x', e, touch);
  64381. me.updateInfo('y', e, touch);
  64382. me.info.time = e.time;
  64383. me.fire('drag', e, me.info);
  64384. },
  64385. onAxisDragEnd: function(axis, info) {
  64386. var duration = info.time - info.previousTime[axis];
  64387. if (duration > 0) {
  64388. info.flick.velocity[axis] = (info[axis] - info.previous[axis]) / duration;
  64389. }
  64390. },
  64391. resetInfo: function(axis, e, touch) {
  64392. var me = this,
  64393. value = me.lastPoint[axis],
  64394. startValue = me.startPoint[axis],
  64395. delta = value - startValue,
  64396. capAxis = axis.toUpperCase(),
  64397. info = me.info;
  64398. info.touch = touch;
  64399. info.delta[axis] = delta;
  64400. info.absDelta[axis] = Math.abs(delta);
  64401. info.previousTime[axis] = me.startTime;
  64402. info.previous[axis] = startValue;
  64403. info[axis] = value;
  64404. info.direction[axis] = 0;
  64405. info['start' + capAxis] = me.startPoint[axis];
  64406. info['previous' + capAxis] = info.previous[axis];
  64407. info['page' + capAxis] = info[axis];
  64408. info['delta' + capAxis] = info.delta[axis];
  64409. info['absDelta' + capAxis] = info.absDelta[axis];
  64410. info['previousDelta' + capAxis] = 0;
  64411. info.startTime = me.startTime;
  64412. },
  64413. updateInfo: function(axis, e, touch) {
  64414. var me = this,
  64415. value = me.lastPoint[axis],
  64416. previousValue = me.previousPoint[axis],
  64417. startValue = me.startPoint[axis],
  64418. delta = value - startValue,
  64419. info = me.info,
  64420. direction = info.direction,
  64421. capAxis = axis.toUpperCase(),
  64422. previousFlick = info.previous[axis];
  64423. info.touch = touch;
  64424. info.delta[axis] = delta;
  64425. info.absDelta[axis] = Math.abs(delta);
  64426. if (value !== previousFlick && value !== info[axis]) {
  64427. info.previous[axis] = info[axis];
  64428. info.previousTime[axis] = info.time;
  64429. }
  64430. info[axis] = value;
  64431. if (value > previousValue) {
  64432. direction[axis] = 1;
  64433. } else if (value < previousValue) {
  64434. direction[axis] = -1;
  64435. }
  64436. info['start' + capAxis] = startValue;
  64437. info['previous' + capAxis] = info.previous[axis];
  64438. info['page' + capAxis] = info[axis];
  64439. info['delta' + capAxis] = info.delta[axis];
  64440. info['absDelta' + capAxis] = info.absDelta[axis];
  64441. info['previousDelta' + capAxis] = info.previous[axis] - startValue;
  64442. info.startTime = me.startTime;
  64443. },
  64444. onTouchEnd: function(e) {
  64445. var me = this,
  64446. touch, point, info;
  64447. if (me.isStarted) {
  64448. touch = e.changedTouches[0];
  64449. point = touch.point;
  64450. info = me.info;
  64451. me.lastPoint = point;
  64452. me.updateInfo('x', e, touch);
  64453. me.updateInfo('y', e, touch);
  64454. info.time = e.time;
  64455. me.onAxisDragEnd('x', info);
  64456. me.onAxisDragEnd('y', info);
  64457. me.fire('dragend', e, info);
  64458. }
  64459. return this.callParent([
  64460. e
  64461. ]);
  64462. },
  64463. onCancel: function(e) {
  64464. var me = this,
  64465. touch = e.changedTouches[0],
  64466. info = me.info;
  64467. if (!e.touches.length) {
  64468. me.lastPoint = touch.point;
  64469. }
  64470. me.updateInfo('x', e, touch);
  64471. me.updateInfo('y', e, touch);
  64472. info.time = e.time;
  64473. me.fire('dragcancel', e, info, true);
  64474. },
  64475. reset: function() {
  64476. var me = this;
  64477. me.lastPoint = me.startPoint = me.previousPoint = me.lastPoint = me.lastMoveEvent = null;
  64478. me.initInfo();
  64479. return me.callParent();
  64480. }
  64481. }, function(Drag) {
  64482. var gestures = Ext.manifest.gestures;
  64483. Drag.instance = new Drag(gestures && gestures.drag);
  64484. });
  64485. Ext.define('Ext.event.gesture.Swipe', {
  64486. extend: Ext.event.gesture.SingleTouch,
  64487. priority: 600,
  64488. handledEvents: [
  64489. 'swipestart',
  64490. 'swipe',
  64491. 'swipecancel'
  64492. ],
  64493. config: {
  64494. minDistance: 80,
  64495. maxOffset: 35,
  64496. maxDuration: 1000
  64497. },
  64498. onTouchStart: function(e) {
  64499. var me = this,
  64500. ret = me.callParent([
  64501. e
  64502. ]),
  64503. touch;
  64504. if (ret !== false) {
  64505. touch = e.changedTouches[0];
  64506. me.startTime = e.time;
  64507. me.isHorizontal = true;
  64508. me.isVertical = true;
  64509. me.startX = touch.pageX;
  64510. me.startY = touch.pageY;
  64511. }
  64512. return ret;
  64513. },
  64514. onTouchMove: function(e) {
  64515. var me = this,
  64516. touch = e.changedTouches[0],
  64517. x = touch.pageX,
  64518. y = touch.pageY,
  64519. deltaX = x - me.startX,
  64520. deltaY = y - me.startY,
  64521. absDeltaX = Math.abs(x - me.startX),
  64522. absDeltaY = Math.abs(y - me.startY),
  64523. duration = e.time - me.startTime,
  64524. minDistance, direction, distance;
  64525. if ((absDeltaX === 0 && absDeltaY === 0) || (duration > me.getMaxDuration())) {
  64526. return me.cancel(e);
  64527. }
  64528. if (me.isHorizontal && absDeltaY > me.getMaxOffset()) {
  64529. me.isHorizontal = false;
  64530. }
  64531. if (me.isVertical && absDeltaX > me.getMaxOffset()) {
  64532. me.isVertical = false;
  64533. }
  64534. if (!me.isVertical || !me.isHorizontal) {
  64535. minDistance = me.getMinDistance();
  64536. if (me.isHorizontal && absDeltaX < minDistance) {
  64537. direction = (deltaX < 0) ? 'left' : 'right';
  64538. distance = absDeltaX;
  64539. } else if (me.isVertical && absDeltaY < minDistance) {
  64540. direction = (deltaY < 0) ? 'up' : 'down';
  64541. distance = absDeltaY;
  64542. }
  64543. }
  64544. if (!me.isHorizontal && !me.isVertical) {
  64545. return me.cancel(e);
  64546. }
  64547. if (direction && !me.isStarted) {
  64548. me.isStarted = true;
  64549. me.fire('swipestart', e, {
  64550. touch: touch,
  64551. direction: direction,
  64552. distance: distance,
  64553. duration: duration
  64554. });
  64555. }
  64556. },
  64557. onTouchEnd: function(e) {
  64558. var me = this,
  64559. touch, x, y, deltaX, deltaY, absDeltaX, absDeltaY, minDistance, duration, direction, distance;
  64560. if (me.onTouchMove(e) !== false) {
  64561. touch = e.changedTouches[0];
  64562. x = touch.pageX;
  64563. y = touch.pageY;
  64564. deltaX = x - me.startX;
  64565. deltaY = y - me.startY;
  64566. absDeltaX = Math.abs(deltaX);
  64567. absDeltaY = Math.abs(deltaY);
  64568. minDistance = me.getMinDistance();
  64569. duration = e.time - me.startTime;
  64570. if (me.isVertical && absDeltaY < minDistance) {
  64571. me.isVertical = false;
  64572. }
  64573. if (me.isHorizontal && absDeltaX < minDistance) {
  64574. me.isHorizontal = false;
  64575. }
  64576. if (me.isHorizontal) {
  64577. direction = (deltaX < 0) ? 'left' : 'right';
  64578. distance = absDeltaX;
  64579. } else if (me.isVertical) {
  64580. direction = (deltaY < 0) ? 'up' : 'down';
  64581. distance = absDeltaY;
  64582. }
  64583. me.fire('swipe', e, {
  64584. touch: touch,
  64585. direction: direction,
  64586. distance: distance,
  64587. duration: duration
  64588. });
  64589. }
  64590. return this.callParent([
  64591. e
  64592. ]);
  64593. },
  64594. onCancel: function(e) {
  64595. this.fire('swipecancel', e, null, true);
  64596. },
  64597. reset: function() {
  64598. var me = this;
  64599. me.startTime = me.isHorizontal = me.isVertical = me.startX = me.startY = null;
  64600. return me.callParent();
  64601. }
  64602. }, function(Swipe) {
  64603. var gestures = Ext.manifest.gestures;
  64604. Swipe.instance = new Swipe(gestures && gestures.swipe);
  64605. });
  64606. Ext.define('Ext.event.gesture.EdgeSwipe', {
  64607. extend: Ext.event.gesture.Swipe,
  64608. priority: 500,
  64609. handledEvents: [
  64610. 'edgeswipe',
  64611. 'edgeswipestart',
  64612. 'edgeswipeend',
  64613. 'edgeswipecancel'
  64614. ],
  64615. config: {
  64616. minDistance: 60
  64617. },
  64618. onTouchStart: function(e) {
  64619. var me = this,
  64620. ret = me.callParent([
  64621. e
  64622. ]),
  64623. touch;
  64624. if (ret !== false) {
  64625. touch = e.changedTouches[0];
  64626. me.direction = null;
  64627. me.isHorizontal = true;
  64628. me.isVertical = true;
  64629. me.startX = touch.pageX;
  64630. me.startY = touch.pageY;
  64631. }
  64632. return ret;
  64633. },
  64634. onTouchMove: function(e) {
  64635. var me = this,
  64636. touch = e.changedTouches[0],
  64637. x = touch.pageX,
  64638. y = touch.pageY,
  64639. deltaX = x - me.startX,
  64640. deltaY = y - me.startY,
  64641. absDeltaY = Math.abs(y - me.startY),
  64642. absDeltaX = Math.abs(x - me.startX),
  64643. minDistance = me.getMinDistance(),
  64644. maxOffset = me.getMaxOffset(),
  64645. duration = e.time - me.startTime,
  64646. elementWidth = Ext.Viewport && Ext.Element.getViewportWidth(),
  64647. elementHeight = Ext.Viewport && Ext.Element.getViewportHeight(),
  64648. direction, distance;
  64649. if (me.isVertical && absDeltaX > maxOffset) {
  64650. me.isVertical = false;
  64651. }
  64652. if (me.isHorizontal && absDeltaY > maxOffset) {
  64653. me.isHorizontal = false;
  64654. }
  64655. if (me.isVertical && me.isHorizontal) {
  64656. if (absDeltaY > absDeltaX) {
  64657. me.isHorizontal = false;
  64658. } else {
  64659. me.isVertical = false;
  64660. }
  64661. }
  64662. if (me.isHorizontal) {
  64663. direction = (deltaX < 0) ? 'left' : 'right';
  64664. distance = deltaX;
  64665. } else if (me.isVertical) {
  64666. direction = (deltaY < 0) ? 'up' : 'down';
  64667. distance = deltaY;
  64668. }
  64669. direction = me.direction || (me.direction = direction);
  64670. if (direction === 'up') {
  64671. distance = deltaY * -1;
  64672. } else if (direction === 'left') {
  64673. distance = deltaX * -1;
  64674. }
  64675. me.distance = distance;
  64676. if (!distance) {
  64677. return me.cancel(e);
  64678. }
  64679. if (!me.isStarted) {
  64680. if ((direction === 'right' && me.startX > minDistance) || (direction === 'down' && me.startY > minDistance) || (direction === 'left' && (elementWidth - me.startX) > minDistance) || (direction === 'up' && (elementHeight - me.startY) > minDistance)) {
  64681. return me.cancel(e);
  64682. }
  64683. me.isStarted = true;
  64684. me.startTime = e.time;
  64685. me.fire('edgeswipestart', e, {
  64686. touch: touch,
  64687. direction: direction,
  64688. distance: distance,
  64689. duration: duration
  64690. });
  64691. } else {
  64692. me.fire('edgeswipe', e, {
  64693. touch: touch,
  64694. direction: direction,
  64695. distance: distance,
  64696. duration: duration
  64697. });
  64698. }
  64699. },
  64700. onTouchEnd: function(e) {
  64701. var me = this,
  64702. duration;
  64703. if (me.onTouchMove(e) !== false) {
  64704. duration = e.time - me.startTime;
  64705. me.fire('edgeswipeend', e, {
  64706. touch: e.changedTouches[0],
  64707. direction: me.direction,
  64708. distance: me.distance,
  64709. duration: duration
  64710. });
  64711. }
  64712. return this.reset();
  64713. },
  64714. onCancel: function(e) {
  64715. this.fire('edgeswipecancel', e, {
  64716. touch: e.changedTouches[0]
  64717. }, true);
  64718. },
  64719. reset: function() {
  64720. var me = this;
  64721. me.direction = me.isHorizontal = me.isVertical = me.startX = me.startY = me.startTime = me.distance = null;
  64722. return me.callParent();
  64723. }
  64724. }, function(EdgeSwipe) {
  64725. var gestures = Ext.manifest.gestures;
  64726. EdgeSwipe.instance = new EdgeSwipe(gestures && gestures.edgeSwipe);
  64727. });
  64728. Ext.define('Ext.event.gesture.LongPress', {
  64729. extend: Ext.event.gesture.SingleTouch,
  64730. priority: 400,
  64731. config: {
  64732. moveDistance: 8,
  64733. minDuration: 1000
  64734. },
  64735. handledEvents: [
  64736. 'longpress',
  64737. 'taphold'
  64738. ],
  64739. onTouchStart: function(e) {
  64740. var me = this,
  64741. ret = me.callParent([
  64742. e
  64743. ]);
  64744. if (ret !== false) {
  64745. me.startPoint = e.changedTouches[0].point;
  64746. me.setLongPressTimer(e);
  64747. }
  64748. return ret;
  64749. },
  64750. setLongPressTimer: function(e) {
  64751. var me = this;
  64752. Ext.undefer(me.timer);
  64753. me.timer = Ext.defer(me.fireLongPress, me.getMinDuration(), me, [
  64754. e
  64755. ]);
  64756. },
  64757. onTouchMove: function(e) {
  64758. var me = this,
  64759. point = e.changedTouches[0].point,
  64760. scale = Ext.Element.getViewportScale(),
  64761. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  64762. if (distance >= me.getMoveDistance()) {
  64763. return me.cancel(e);
  64764. }
  64765. },
  64766. reset: function() {
  64767. var me = this;
  64768. me.timer = me.startPoint = Ext.undefer(me.timer);
  64769. return me.callParent();
  64770. },
  64771. fireLongPress: function(e) {
  64772. var me = this,
  64773. info = {
  64774. touch: e.changedTouches[0],
  64775. duration: me.getMinDuration(),
  64776. startDrag: me.startDrag
  64777. };
  64778. this.fire('taphold', e, info);
  64779. this.fire('longpress', e, info);
  64780. this.reset();
  64781. },
  64782. startDrag: function() {
  64783. var dragRecognizer = Ext.event.gesture.Drag.instance,
  64784. touchStartEvent = this.parentEvent;
  64785. dragRecognizer.doDragStart(touchStartEvent, true);
  64786. Ext.event.publisher.Gesture.instance.claimRecognizer(dragRecognizer, touchStartEvent);
  64787. }
  64788. }, function(LongPress) {
  64789. var gestures = Ext.manifest.gestures;
  64790. LongPress.instance = new LongPress(gestures && gestures.longPress);
  64791. });
  64792. Ext.define('Ext.event.gesture.MultiTouch', {
  64793. extend: Ext.event.gesture.Recognizer,
  64794. requiredTouchesCount: 2,
  64795. isTracking: false,
  64796. isMultiTouch: true,
  64797. onTouchStart: function(e) {
  64798. var me = this,
  64799. requiredTouchesCount = me.requiredTouchesCount,
  64800. touches = e.touches,
  64801. touchesCount = touches.length;
  64802. if (touchesCount === requiredTouchesCount) {
  64803. me.isTracking = true;
  64804. } else if (touchesCount > requiredTouchesCount) {
  64805. return me.cancel(e);
  64806. }
  64807. },
  64808. reset: function() {
  64809. this.isTracking = false;
  64810. return this.callParent();
  64811. }
  64812. });
  64813. Ext.define('Ext.event.gesture.Pinch', {
  64814. extend: Ext.event.gesture.MultiTouch,
  64815. priority: 700,
  64816. handledEvents: [
  64817. 'pinchstart',
  64818. 'pinch',
  64819. 'pinchend',
  64820. 'pinchcancel'
  64821. ],
  64822. startDistance: 0,
  64823. lastTouches: null,
  64824. onTouchMove: function(e) {
  64825. var me = this,
  64826. touches, firstPoint, secondPoint, distance;
  64827. if (me.isTracking) {
  64828. touches = e.touches;
  64829. firstPoint = touches[0].point;
  64830. secondPoint = touches[1].point;
  64831. distance = firstPoint.getDistanceTo(secondPoint);
  64832. if (distance === 0) {
  64833. return;
  64834. }
  64835. if (!me.isStarted) {
  64836. me.isStarted = true;
  64837. me.startDistance = distance;
  64838. me.fire('pinchstart', e, {
  64839. touches: touches,
  64840. distance: distance,
  64841. scale: 1
  64842. });
  64843. } else {
  64844. me.fire('pinch', e, {
  64845. touches: touches,
  64846. distance: distance,
  64847. scale: distance / me.startDistance
  64848. });
  64849. }
  64850. }
  64851. },
  64852. onTouchEnd: function(e) {
  64853. if (this.isStarted) {
  64854. this.fire('pinchend', e);
  64855. }
  64856. return this.callParent([
  64857. e
  64858. ]);
  64859. },
  64860. onCancel: function(e) {
  64861. this.fire('pinchcancel', e, null, true);
  64862. },
  64863. reset: function() {
  64864. this.lastTouches = null;
  64865. this.startDistance = 0;
  64866. return this.callParent();
  64867. }
  64868. }, function(Pinch) {
  64869. var gestures = Ext.manifest.gestures;
  64870. Pinch.instance = new Pinch(gestures && gestures.pinch);
  64871. });
  64872. Ext.define('Ext.event.gesture.Rotate', {
  64873. extend: Ext.event.gesture.MultiTouch,
  64874. priority: 800,
  64875. handledEvents: [
  64876. 'rotatestart',
  64877. 'rotate',
  64878. 'rotateend',
  64879. 'rotatecancel'
  64880. ],
  64881. startAngle: 0,
  64882. lastTouches: null,
  64883. lastAngle: null,
  64884. onTouchMove: function(e) {
  64885. var me = this,
  64886. touches, lastAngle, firstPoint, secondPoint, angle, nextAngle, previousAngle, diff;
  64887. if (me.isTracking) {
  64888. touches = e.touches;
  64889. lastAngle = me.lastAngle;
  64890. firstPoint = touches[0].point;
  64891. secondPoint = touches[1].point;
  64892. angle = firstPoint.getAngleTo(secondPoint);
  64893. if (lastAngle !== null) {
  64894. diff = Math.abs(lastAngle - angle);
  64895. nextAngle = angle + 360;
  64896. previousAngle = angle - 360;
  64897. if (Math.abs(nextAngle - lastAngle) < diff) {
  64898. angle = nextAngle;
  64899. } else if (Math.abs(previousAngle - lastAngle) < diff) {
  64900. angle = previousAngle;
  64901. }
  64902. }
  64903. me.lastAngle = angle;
  64904. if (!me.isStarted) {
  64905. me.isStarted = true;
  64906. me.startAngle = angle;
  64907. me.fire('rotatestart', e, {
  64908. touches: touches,
  64909. angle: angle,
  64910. rotation: 0
  64911. });
  64912. } else {
  64913. me.fire('rotate', e, {
  64914. touches: touches,
  64915. angle: angle,
  64916. rotation: angle - me.startAngle
  64917. });
  64918. }
  64919. me.lastTouches = Ext.Array.clone(touches);
  64920. }
  64921. },
  64922. onTouchEnd: function(e) {
  64923. if (this.isStarted) {
  64924. this.fire('rotateend', e);
  64925. }
  64926. return this.callParent([
  64927. e
  64928. ]);
  64929. },
  64930. onCancel: function(e) {
  64931. this.fire('rotatecancel', e, null, true);
  64932. },
  64933. reset: function() {
  64934. var me = this;
  64935. me.lastTouches = me.lastAngle = me.startAngle = null;
  64936. return this.callParent();
  64937. }
  64938. }, function(Rotate) {
  64939. var gestures = Ext.manifest.gestures;
  64940. Rotate.instance = new Rotate(gestures && gestures.rotate);
  64941. });
  64942. Ext.define('Ext.event.gesture.Tap', {
  64943. extend: Ext.event.gesture.SingleTouch,
  64944. priority: 200,
  64945. handledEvents: [
  64946. 'tap',
  64947. 'tapcancel'
  64948. ],
  64949. config: {
  64950. moveDistance: 8
  64951. },
  64952. onTouchStart: function(e) {
  64953. var me = this,
  64954. ret = me.callParent([
  64955. e
  64956. ]);
  64957. if (ret !== false) {
  64958. me.isStarted = true;
  64959. me.startPoint = e.changedTouches[0].point;
  64960. }
  64961. return ret;
  64962. },
  64963. onTouchMove: function(e) {
  64964. var me = this,
  64965. point = e.changedTouches[0].point,
  64966. scale = Ext.Element.getViewportScale(),
  64967. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  64968. if (distance >= me.getMoveDistance()) {
  64969. return me.cancel(e);
  64970. }
  64971. },
  64972. onTouchEnd: function(e) {
  64973. this.fire('tap', e, {
  64974. touch: e.changedTouches[0]
  64975. });
  64976. return this.callParent([
  64977. e
  64978. ]);
  64979. },
  64980. onCancel: function(e) {
  64981. this.fire('tapcancel', e, {
  64982. touch: e.changedTouches[0]
  64983. }, true);
  64984. },
  64985. reset: function() {
  64986. this.startPoint = null;
  64987. return this.callParent();
  64988. }
  64989. }, function(Tap) {
  64990. var gestures = Ext.manifest.gestures;
  64991. Tap.instance = new Tap(gestures && gestures.tap);
  64992. });
  64993. Ext.define('Ext.event.publisher.Focus', {
  64994. extend: Ext.event.publisher.Dom,
  64995. type: 'focus',
  64996. handledEvents: [
  64997. 'focusenter',
  64998. 'focusleave',
  64999. 'focusmove'
  65000. ],
  65001. handledDomEvents: [
  65002. 'focusin',
  65003. 'focusout'
  65004. ],
  65005. publishDelegatedDomEvent: function(e) {
  65006. var me = this,
  65007. relatedTarget = e.relatedTarget;
  65008. if (me.$suppressEvents) {
  65009. return;
  65010. }
  65011. if (e.type === 'focusout') {
  65012. if (relatedTarget == null) {
  65013. me.processFocusIn(e, e.target, document.body);
  65014. }
  65015. } else {
  65016. if (relatedTarget == null || !relatedTarget.tagName) {
  65017. relatedTarget = document.body;
  65018. }
  65019. me.processFocusIn(e, relatedTarget, e.target);
  65020. }
  65021. },
  65022. processFocusIn: function(e, fromElement, toElement) {
  65023. var me = this,
  65024. focusFly = me.focusFly,
  65025. targets = [],
  65026. commonAncestor, node, backwards, event, focusEnterEvent;
  65027. if ((fromElement && focusFly.attach(fromElement).isFocusSuspended()) || (toElement && focusFly.attach(toElement).isFocusSuspended())) {
  65028. return;
  65029. }
  65030. if (toElement.compareDocumentPosition) {
  65031. backwards = !!(toElement.compareDocumentPosition(fromElement) & 4);
  65032. }
  65033. for (node = fromElement , commonAncestor = Ext.dom.Element.getCommonAncestor(toElement, fromElement, true); node && node !== commonAncestor; node = node.parentNode) {
  65034. targets.push(node);
  65035. }
  65036. if (targets.length) {
  65037. event = me.createSyntheticEvent('focusleave', e, fromElement, toElement, fromElement, toElement, backwards);
  65038. me.publish(event, targets);
  65039. if (event.stopped) {
  65040. return;
  65041. }
  65042. }
  65043. targets.length = 0;
  65044. for (node = toElement; node && node !== commonAncestor; node = node.parentNode) {
  65045. targets.push(node);
  65046. }
  65047. focusEnterEvent = me.createSyntheticEvent('focusenter', e, toElement, fromElement, fromElement, toElement, backwards);
  65048. if (targets.length) {
  65049. me.publish(focusEnterEvent, targets);
  65050. if (focusEnterEvent.stopped) {
  65051. return;
  65052. }
  65053. }
  65054. targets = me.getPropagatingTargets(commonAncestor);
  65055. if (targets.length) {
  65056. event = me.createSyntheticEvent('focusmove', e, toElement, fromElement, fromElement, toElement, backwards);
  65057. me.publish(event, targets);
  65058. if (event.stopped) {
  65059. return;
  65060. }
  65061. }
  65062. if (Ext.GlobalEvents.hasListeners.focus) {
  65063. Ext.GlobalEvents.fireEvent('focus', {
  65064. event: focusEnterEvent,
  65065. toElement: toElement,
  65066. fromElement: fromElement,
  65067. backwards: backwards
  65068. });
  65069. }
  65070. },
  65071. createSyntheticEvent: function(eventName, browserEvent, target, relatedTarget, fromElement, toElement, backwards) {
  65072. var event = new Ext.event.Event(browserEvent);
  65073. event.type = eventName;
  65074. event.relatedTarget = relatedTarget;
  65075. event.target = target;
  65076. event.fromElement = fromElement;
  65077. event.toElement = toElement;
  65078. event.backwards = backwards;
  65079. return event;
  65080. }
  65081. }, function(Focus) {
  65082. var focusTimeout;
  65083. Focus.prototype.focusFly = new Ext.dom.Fly();
  65084. Focus.instance = new Focus();
  65085. if (!Ext.supports.FocusinFocusoutEvents) {
  65086. this.override({
  65087. handledDomEvents: [
  65088. 'focus',
  65089. 'blur'
  65090. ],
  65091. publishDelegatedDomEvent: function(e) {
  65092. var me = this,
  65093. targetIsElement;
  65094. me.callSuper([
  65095. e
  65096. ]);
  65097. targetIsElement = e.target !== window && e.target !== document;
  65098. if (e.type === 'blur') {
  65099. if (!targetIsElement) {
  65100. if (e.explicitOriginalTarget === Focus.previousActiveElement) {
  65101. if (e.target === window) {
  65102. Ext.undefer(focusTimeout);
  65103. focusTimeout = 0;
  65104. me.processFocusIn(e, Focus.previousActiveElement, document.body);
  65105. Focus.previousActiveElement = null;
  65106. }
  65107. }
  65108. } else {
  65109. focusTimeout = Ext.defer(function() {
  65110. focusTimeout = 0;
  65111. me.processFocusIn(e, e.target, document.body);
  65112. Focus.previousActiveElement = null;
  65113. }, 1);
  65114. if (targetIsElement && Ext.cache[e.target.id]) {
  65115. Ext.cache[e.target.id].focusinTimeout = focusTimeout;
  65116. }
  65117. }
  65118. Focus.previousActiveElement = targetIsElement ? e.target : null;
  65119. } else {
  65120. Ext.undefer(focusTimeout);
  65121. focusTimeout = 0;
  65122. me.processFocusIn(e, Focus.previousActiveElement || document.body, targetIsElement ? e.target : document.body);
  65123. }
  65124. }
  65125. });
  65126. Ext.define(null, {
  65127. override: 'Ext.dom.Element',
  65128. destroy: function() {
  65129. if (this.focusinTimeout) {
  65130. Ext.undefer(this.focusinTimeout);
  65131. this.focusinTimeout = null;
  65132. }
  65133. this.callParent();
  65134. }
  65135. });
  65136. }
  65137. });
  65138. Ext.define('Ext.field.InputMask', function(InputMask) {
  65139. return {
  65140. cachedConfig: {
  65141. blank: '_',
  65142. characters: {
  65143. '*': '[A-Za-z0-9]',
  65144. 'a': '[a-z]',
  65145. 'A': '[A-Z]',
  65146. '0': '[0-9]',
  65147. '9': '[0-9]'
  65148. },
  65149. ignoreCase: true
  65150. },
  65151. config: {
  65152. pattern: null
  65153. },
  65154. _cached: false,
  65155. _lastEditablePos: null,
  65156. _mask: null,
  65157. statics: {
  65158. active: {},
  65159. from: function(value, existing) {
  65160. var active = InputMask.active,
  65161. ret;
  65162. if (value === null) {
  65163. ret = null;
  65164. } else if (typeof value !== 'string') {
  65165. if (existing && !existing._cached) {
  65166. ret = existing;
  65167. ret.setConfig(value);
  65168. } else {
  65169. ret = new InputMask(value);
  65170. }
  65171. } else if (!(ret = active[value])) {
  65172. if (!(ret = InputMask.cache.remove(value))) {
  65173. ret = new InputMask({
  65174. pattern: value
  65175. });
  65176. }
  65177. active[value] = ret;
  65178. ret._cached = 1;
  65179. } else
  65180. {
  65181. ++ret._cached;
  65182. }
  65183. return ret;
  65184. }
  65185. },
  65186. constructor: function(config) {
  65187. this.initConfig(config);
  65188. },
  65189. release: function() {
  65190. var me = this,
  65191. cache = InputMask.cache,
  65192. key;
  65193. if (me._cached && !--me._cached) {
  65194. key = me.getPattern();
  65195. if (InputMask.active[key] !== me) {
  65196. Ext.raise('Invalid call to InputMask#release (not active)');
  65197. }
  65198. if (cache.map[key]) {
  65199. Ext.raise('Invalid call to InputMask#release (already cached)');
  65200. }
  65201. delete InputMask.active[key];
  65202. cache.add(key, me);
  65203. cache.trim(cache.maxSize);
  65204. }
  65205. else if (me._cached === 0) {
  65206. Ext.raise('Invalid call to InputMask#release (already released)');
  65207. }
  65208. },
  65209. clearRange: function(value, start, len) {
  65210. var me = this,
  65211. blank = me.getBlank(),
  65212. end = start + len,
  65213. n = value.length,
  65214. s = '',
  65215. i, mask, prefixLen;
  65216. if (!blank) {
  65217. prefixLen = me._prefix.length;
  65218. for (i = 0; i < n; ++i) {
  65219. if (i < prefixLen || i < start || i >= end) {
  65220. s += value[i];
  65221. }
  65222. }
  65223. s = me.formatValue(s);
  65224. } else {
  65225. mask = me.getPattern();
  65226. for (i = 0; i < n; ++i) {
  65227. if (i < start || i >= end) {
  65228. s += value[i];
  65229. } else if (me.isFixedChar(i)) {
  65230. s += mask[i];
  65231. } else {
  65232. s += blank;
  65233. }
  65234. }
  65235. }
  65236. return s;
  65237. },
  65238. formatValue: function(value) {
  65239. var me = this,
  65240. blank = me.getBlank(),
  65241. i, length, mask, prefix, s;
  65242. if (!blank) {
  65243. prefix = me._prefix;
  65244. length = prefix.length;
  65245. s = this.insertRange('', value, 0);
  65246. for (i = s.length; i > length && me.isFixedChar(i - 1); ) {
  65247. --i;
  65248. }
  65249. s = (i < length) ? prefix : s.slice(0, i - 1);
  65250. } else if (value) {
  65251. s = me.formatValue('');
  65252. s = me.insertRange(s, value, 0);
  65253. } else {
  65254. mask = me.getPattern();
  65255. s = '';
  65256. for (i = 0 , length = mask.length; i < length; ++i) {
  65257. if (me.isFixedChar(i)) {
  65258. s += mask[i];
  65259. } else {
  65260. s += blank;
  65261. }
  65262. }
  65263. }
  65264. return s;
  65265. },
  65266. getEditPosLeft: function(pos) {
  65267. var i;
  65268. for (i = pos; i >= 0; --i) {
  65269. if (!this.isFixedChar(i)) {
  65270. return i;
  65271. }
  65272. }
  65273. return null;
  65274. },
  65275. getEditPosRight: function(pos) {
  65276. var mask = this._mask,
  65277. len = mask.length,
  65278. i;
  65279. for (i = pos; i < len; ++i) {
  65280. if (!this.isFixedChar(i)) {
  65281. return i;
  65282. }
  65283. }
  65284. return null;
  65285. },
  65286. getFilledLength: function(value) {
  65287. var me = this,
  65288. blank = me.getBlank(),
  65289. c, i;
  65290. if (!blank) {
  65291. return value.length;
  65292. }
  65293. for (i = value && value.length; i-- > 0; ) {
  65294. c = value[i];
  65295. if (!me.isFixedChar(i) && me.isAllowedChar(c, i)) {
  65296. break;
  65297. }
  65298. }
  65299. return ++i || me._prefix.length;
  65300. },
  65301. getSubLength: function(value, substr, pos) {
  65302. var me = this,
  65303. mask = me.getPattern(),
  65304. k = 0,
  65305. maskLen = mask.length,
  65306. substrLen = substr.length,
  65307. i;
  65308. for (i = pos; i < maskLen && k < substrLen; ) {
  65309. if (!me.isFixedChar(i) || mask[i] === substr[k]) {
  65310. if (me.isAllowedChar(substr[k++], i, true)) {
  65311. ++i;
  65312. }
  65313. } else {
  65314. ++i;
  65315. }
  65316. }
  65317. return i - pos;
  65318. },
  65319. insertRange: function(value, substr, pos) {
  65320. var me = this,
  65321. mask = me.getPattern(),
  65322. blank = me.getBlank(),
  65323. filled = me.isFilled(value),
  65324. prefixLen = me._prefix.length,
  65325. maskLen = mask.length,
  65326. substrLen = substr.length,
  65327. s = value,
  65328. ch, fixed, i, k;
  65329. if (!blank && pos > s.length) {
  65330. s += mask.slice(s.length, pos);
  65331. }
  65332. for (i = pos , k = 0; i < maskLen && k < substrLen; ) {
  65333. fixed = me.isFixedChar(i);
  65334. if (!fixed || mask[i] === substr[k]) {
  65335. ch = substr[k++];
  65336. if (me.isAllowedChar(ch, i, true)) {
  65337. if (i < s.length) {
  65338. if (blank || filled || i < prefixLen) {
  65339. s = s.slice(0, i) + ch + s.slice(i + 1);
  65340. } else {
  65341. s = me.formatValue(s.substr(0, i) + ch + s.substr(i));
  65342. }
  65343. } else if (!blank) {
  65344. s += ch;
  65345. }
  65346. ++i;
  65347. }
  65348. } else {
  65349. if (!blank && i >= s.length) {
  65350. s += mask[i];
  65351. } else if (blank && fixed && substr[k] === blank) {
  65352. ++k;
  65353. }
  65354. ++i;
  65355. }
  65356. }
  65357. return s;
  65358. },
  65359. isAllowedChar: function(character, pos, allowBlankChar) {
  65360. var me = this,
  65361. mask = me.getPattern(),
  65362. c, characters, rule;
  65363. if (me.isFixedChar(pos)) {
  65364. return mask[pos] === character;
  65365. }
  65366. c = mask[pos];
  65367. characters = me.getCharacters();
  65368. rule = characters[c];
  65369. return !rule || rule.test(character || '') || (allowBlankChar && character === me.getBlank());
  65370. },
  65371. isEmpty: function(value) {
  65372. var i, len;
  65373. for (i = 0 , len = value.length; i < len; ++i) {
  65374. if (!this.isFixedChar(i) && this.isAllowedChar(value[i], i)) {
  65375. return false;
  65376. }
  65377. }
  65378. return true;
  65379. },
  65380. isFilled: function(value) {
  65381. return this.getFilledLength(value) === this._mask.length;
  65382. },
  65383. isFixedChar: function(pos) {
  65384. return Ext.Array.indexOf(this._fixedCharPositions, pos) > -1;
  65385. },
  65386. setCaretToEnd: function(field, value) {
  65387. var filledLen = this.getFilledLength(value),
  65388. pos = this.getEditPosRight(filledLen);
  65389. if (pos !== null) {
  65390. Ext.raf(function() {
  65391. if (!field.destroyed) {
  65392. field.setCaretPos(pos);
  65393. Ext.raf(function() {
  65394. if (!field.destroyed) {
  65395. field.setCaretPos(pos);
  65396. }
  65397. });
  65398. }
  65399. });
  65400. }
  65401. },
  65402. onBlur: function(field, value) {
  65403. if (field.getAutoHideInputMask() !== false) {
  65404. if (this.isEmpty(value)) {
  65405. field.maskProcessed = true;
  65406. field.setValue('');
  65407. }
  65408. }
  65409. },
  65410. onFocus: function(field, value) {
  65411. if (field.getAutoHideInputMask() !== false) {
  65412. if (!value) {
  65413. field.maskProcessed = true;
  65414. field.setValue(this._mask);
  65415. }
  65416. }
  65417. this.setCaretToEnd(field, value);
  65418. },
  65419. onChange: function(field, value, oldValue) {
  65420. var me = this,
  65421. s;
  65422. if (field.maskProcessed || value === oldValue) {
  65423. field.maskProcessed = false;
  65424. return true;
  65425. }
  65426. if (value) {
  65427. s = me.formatValue(value);
  65428. field.maskProcessed = true;
  65429. field.setValue(s);
  65430. }
  65431. },
  65432. processAutocomplete: function(field, value) {
  65433. var me = this,
  65434. s;
  65435. if (value) {
  65436. if (value.length > me._mask.length) {
  65437. value = value.substr(0, me._mask.length);
  65438. }
  65439. s = me.formatValue(value);
  65440. field.maskProcessed = true;
  65441. field.inputElement.dom.value = s;
  65442. field.setValue(s);
  65443. this.setCaretToEnd(field, value);
  65444. }
  65445. },
  65446. showEmptyMask: function(field, adjustCaret) {
  65447. var s = this.formatValue();
  65448. field.maskProcessed = true;
  65449. field.setValue(s);
  65450. if (adjustCaret) {
  65451. this.setCaretToEnd(field);
  65452. }
  65453. },
  65454. onKeyDown: function(field, value, event) {
  65455. if (event.ctrlKey || event.metaKey) {
  65456. return;
  65457. }
  65458. var me = this,
  65459. key = event.keyCode === event.DELETE,
  65460. del = key === 'Delete',
  65461. handled = del || (event.keyCode === event.BACKSPACE),
  65462. s = value,
  65463. caret, editPos, len, prefixLen, textSelection, start;
  65464. if (handled) {
  65465. caret = field.getCaretPos();
  65466. prefixLen = me._prefix.length;
  65467. textSelection = field.getTextSelection();
  65468. start = textSelection[0];
  65469. len = textSelection[1] - start;
  65470. if (len) {
  65471. s = me.clearRange(value, start, len);
  65472. } else if (caret < prefixLen || (!del && caret === prefixLen)) {
  65473. caret = prefixLen;
  65474. } else {
  65475. editPos = del ? me.getEditPosRight(caret) : me.getEditPosLeft(caret - 1);
  65476. if (editPos !== null) {
  65477. s = me.clearRange(value, editPos, 1);
  65478. caret = editPos;
  65479. }
  65480. }
  65481. if (s !== value) {
  65482. field.maskProcessed = true;
  65483. field.setValue(s);
  65484. }
  65485. event.preventDefault();
  65486. field.setCaretPos(caret);
  65487. }
  65488. },
  65489. onKeyPress: function(field, value, event) {
  65490. var me = this,
  65491. key = event.keyCode,
  65492. ch = event.getChar(),
  65493. mask = me.getPattern(),
  65494. prefixLen = me._prefix.length,
  65495. s = value,
  65496. caretPos, pos, start, textSelection;
  65497. if (key === event.ENTER || key === event.TAB || event.ctrlKey || event.metaKey) {
  65498. return;
  65499. }
  65500. caretPos = field.getCaretPos();
  65501. textSelection = field.getTextSelection();
  65502. if (me.isFixedChar(caretPos) && mask[caretPos] === ch) {
  65503. s = me.insertRange(s, ch, caretPos);
  65504. ++caretPos;
  65505. } else {
  65506. pos = me.getEditPosRight(caretPos);
  65507. if (pos !== null && me.isAllowedChar(ch, pos)) {
  65508. start = textSelection[0];
  65509. s = me.clearRange(s, start, textSelection[1] - start);
  65510. s = me.insertRange(s, ch, pos);
  65511. caretPos = pos + 1;
  65512. }
  65513. }
  65514. if (s !== value) {
  65515. field.maskProcessed = true;
  65516. field.setValue(s);
  65517. }
  65518. event.preventDefault();
  65519. if (caretPos < me._lastEditablePos && caretPos > prefixLen) {
  65520. caretPos = me.getEditPosRight(caretPos);
  65521. }
  65522. field.setCaretPos(caretPos);
  65523. },
  65524. onPaste: function(field, value, event) {
  65525. var text,
  65526. clipdData = event.browserEvent.clipboardData;
  65527. if (clipdData && clipdData.getData) {
  65528. text = clipdData.getData('text/plain');
  65529. } else if (Ext.global.clipboardData && Ext.global.clipboardData.getData) {
  65530. text = Ext.global.clipboardData.getData('Text');
  65531. }
  65532. if (text) {
  65533. this.paste(field, value, text, field.getTextSelection());
  65534. }
  65535. event.preventDefault();
  65536. },
  65537. paste: function(field, value, text, selection) {
  65538. var me = this,
  65539. caretPos = selection[0],
  65540. len = selection[1] - caretPos,
  65541. s = len ? me.clearRange(value, caretPos, len) : value,
  65542. textLen = me.getSubLength(s, text, caretPos);
  65543. s = me.insertRange(s, text, caretPos);
  65544. caretPos += textLen;
  65545. caretPos = me.getEditPosRight(caretPos) || caretPos;
  65546. if (s !== value) {
  65547. field.maskProcessed = true;
  65548. field.setValue(s);
  65549. }
  65550. field.setCaretPos(caretPos);
  65551. },
  65552. syncPattern: function(field) {
  65553. var fieldValue = field.getValue(),
  65554. s;
  65555. if (field.getAutoHideInputMask() === false) {
  65556. if (!fieldValue) {
  65557. this.showEmptyMask(field);
  65558. } else {
  65559. s = this.formatValue(fieldValue);
  65560. field.maskProcessed = true;
  65561. field.setValue(s);
  65562. }
  65563. } else {
  65564. if (fieldValue) {
  65565. s = this.formatValue(fieldValue);
  65566. field.maskProcessed = true;
  65567. field.setValue(s);
  65568. }
  65569. }
  65570. },
  65571. applyCharacters: function(map) {
  65572. var ret = {},
  65573. flags = this.getIgnoreCase() ? 'i' : '',
  65574. c, v;
  65575. for (c in map) {
  65576. v = map[c];
  65577. if (typeof v === 'string') {
  65578. v = new RegExp(v, flags);
  65579. }
  65580. ret[c] = v;
  65581. }
  65582. return ret;
  65583. },
  65584. updatePattern: function(mask) {
  65585. var me = this,
  65586. characters = me.getCharacters(),
  65587. lastEditablePos = 0,
  65588. n = mask && mask.length,
  65589. blank = me.getBlank(),
  65590. fixedPosArr = [],
  65591. prefix = '',
  65592. str = '',
  65593. c, i;
  65594. for (i = 0; i < n; ++i) {
  65595. c = mask[i];
  65596. if (!characters[c]) {
  65597. fixedPosArr.push(str.length);
  65598. str += c;
  65599. } else {
  65600. lastEditablePos = str.length + 1;
  65601. str += blank;
  65602. }
  65603. }
  65604. me._lastEditablePos = lastEditablePos;
  65605. me._mask = str;
  65606. me._fixedCharPositions = fixedPosArr;
  65607. for (i = 0; i < str.length && me.isFixedChar(i); ++i) {
  65608. prefix += str[i];
  65609. }
  65610. me._prefix = prefix;
  65611. }
  65612. };
  65613. }, function(InputMask) {
  65614. InputMask.cache = new Ext.util.LRU();
  65615. InputMask.cache.maxSize = 100;
  65616. });
  65617. Ext.define('Ext.fx.runner.Css', {
  65618. extend: Ext.Evented,
  65619. prefixedProperties: {
  65620. 'transform': true,
  65621. 'transform-origin': true,
  65622. 'perspective': true,
  65623. 'transform-style': true,
  65624. 'transition': true,
  65625. 'transition-property': true,
  65626. 'transition-duration': true,
  65627. 'transition-timing-function': true,
  65628. 'transition-delay': true,
  65629. 'animation': true,
  65630. 'animation-name': true,
  65631. 'animation-duration': true,
  65632. 'animation-iteration-count': true,
  65633. 'animation-direction': true,
  65634. 'animation-timing-function': true,
  65635. 'animation-delay': true
  65636. },
  65637. lengthProperties: {
  65638. 'top': true,
  65639. 'right': true,
  65640. 'bottom': true,
  65641. 'left': true,
  65642. 'width': true,
  65643. 'height': true,
  65644. 'max-height': true,
  65645. 'max-width': true,
  65646. 'min-height': true,
  65647. 'min-width': true,
  65648. 'margin-bottom': true,
  65649. 'margin-left': true,
  65650. 'margin-right': true,
  65651. 'margin-top': true,
  65652. 'padding-bottom': true,
  65653. 'padding-left': true,
  65654. 'padding-right': true,
  65655. 'padding-top': true,
  65656. 'border-bottom-width': true,
  65657. 'border-left-width': true,
  65658. 'border-right-width': true,
  65659. 'border-spacing': true,
  65660. 'border-top-width': true,
  65661. 'border-width': true,
  65662. 'outline-width': true,
  65663. 'letter-spacing': true,
  65664. 'line-height': true,
  65665. 'text-indent': true,
  65666. 'word-spacing': true,
  65667. 'font-size': true,
  65668. 'translate': true,
  65669. 'translateX': true,
  65670. 'translateY': true,
  65671. 'translateZ': true,
  65672. 'translate3d': true,
  65673. 'x': true,
  65674. 'y': true
  65675. },
  65676. durationProperties: {
  65677. 'transition-duration': true,
  65678. 'transition-delay': true,
  65679. 'animation-duration': true,
  65680. 'animation-delay': true
  65681. },
  65682. angleProperties: {
  65683. rotate: true,
  65684. rotateX: true,
  65685. rotateY: true,
  65686. rotateZ: true,
  65687. skew: true,
  65688. skewX: true,
  65689. skewY: true
  65690. },
  65691. DEFAULT_UNIT_LENGTH: 'px',
  65692. DEFAULT_UNIT_ANGLE: 'deg',
  65693. DEFAULT_UNIT_DURATION: 'ms',
  65694. customProperties: {
  65695. x: true,
  65696. y: true
  65697. },
  65698. formattedNameCache: {
  65699. 'x': 'left',
  65700. 'y': 'top'
  65701. },
  65702. transformMethods3d: [
  65703. 'translateX',
  65704. 'translateY',
  65705. 'translateZ',
  65706. 'rotate',
  65707. 'rotateX',
  65708. 'rotateY',
  65709. 'rotateZ',
  65710. 'skewX',
  65711. 'skewY',
  65712. 'scaleX',
  65713. 'scaleY',
  65714. 'scaleZ'
  65715. ],
  65716. transformMethodsNo3d: [
  65717. 'translateX',
  65718. 'translateY',
  65719. 'rotate',
  65720. 'skewX',
  65721. 'skewY',
  65722. 'scaleX',
  65723. 'scaleY'
  65724. ],
  65725. constructor: function() {
  65726. var me = this;
  65727. me.transformMethods = Ext.feature.has.Css3dTransforms ? me.transformMethods3d : me.transformMethodsNo3d;
  65728. me.vendorPrefix = Ext.browser.getStyleDashPrefix();
  65729. me.ruleStylesCache = {};
  65730. me.callParent();
  65731. },
  65732. getStyleSheet: function() {
  65733. var styleSheet = this.styleSheet,
  65734. styleElement, styleSheets;
  65735. if (!styleSheet) {
  65736. styleElement = document.createElement('style');
  65737. styleElement.type = 'text/css';
  65738. (document.head || document.getElementsByTagName('head')[0]).appendChild(styleElement);
  65739. styleSheets = document.styleSheets;
  65740. this.styleSheet = styleSheet = styleSheets[styleSheets.length - 1];
  65741. }
  65742. return styleSheet;
  65743. },
  65744. applyRules: function(selectors) {
  65745. var styleSheet = this.getStyleSheet(),
  65746. ruleStylesCache = this.ruleStylesCache,
  65747. rules = styleSheet.cssRules,
  65748. selector, properties, ruleStyle, ruleStyleCache, rulesLength, name, value;
  65749. for (selector in selectors) {
  65750. properties = selectors[selector];
  65751. ruleStyle = ruleStylesCache[selector];
  65752. if (ruleStyle === undefined) {
  65753. rulesLength = rules.length;
  65754. styleSheet.insertRule(selector + '{}', rulesLength);
  65755. ruleStyle = ruleStylesCache[selector] = rules.item(rulesLength).style;
  65756. }
  65757. ruleStyleCache = ruleStyle.$cache;
  65758. if (!ruleStyleCache) {
  65759. ruleStyleCache = ruleStyle.$cache = {};
  65760. }
  65761. for (name in properties) {
  65762. value = this.formatValue(properties[name], name);
  65763. name = this.formatName(name);
  65764. if (ruleStyleCache[name] !== value) {
  65765. ruleStyleCache[name] = value;
  65766. if (value === null) {
  65767. ruleStyle.removeProperty(name);
  65768. } else {
  65769. ruleStyle.setProperty(name, value);
  65770. }
  65771. }
  65772. }
  65773. }
  65774. return this;
  65775. },
  65776. applyStyles: function(styles) {
  65777. var id, element, elementStyle, properties, name, value;
  65778. for (id in styles) {
  65779. if (styles.hasOwnProperty(id)) {
  65780. this.activeElement = element = document.getElementById(id);
  65781. if (!element) {
  65782. continue;
  65783. }
  65784. elementStyle = element.style;
  65785. properties = styles[id];
  65786. for (name in properties) {
  65787. if (properties.hasOwnProperty(name)) {
  65788. value = this.formatValue(properties[name], name);
  65789. name = this.formatName(name);
  65790. if (value === null) {
  65791. elementStyle.removeProperty(name);
  65792. } else {
  65793. elementStyle.setProperty(name, value);
  65794. }
  65795. }
  65796. }
  65797. }
  65798. }
  65799. this.activeElement = null;
  65800. return this;
  65801. },
  65802. formatName: function(name) {
  65803. var cache = this.formattedNameCache,
  65804. formattedName = cache[name];
  65805. if (!formattedName) {
  65806. if ((Ext.os.is.Tizen || !Ext.feature.has.CssTransformNoPrefix) && this.prefixedProperties[name]) {
  65807. formattedName = this.vendorPrefix + name;
  65808. } else {
  65809. formattedName = name;
  65810. }
  65811. cache[name] = formattedName;
  65812. }
  65813. return formattedName;
  65814. },
  65815. formatValue: function(value, name) {
  65816. var type = typeof value,
  65817. defaultLengthUnit = this.DEFAULT_UNIT_LENGTH,
  65818. isCustom = this.customProperties[name],
  65819. transformMethods, method, i, ln, transformValues, values;
  65820. if (value === null) {
  65821. return '';
  65822. }
  65823. if (type === 'string') {
  65824. if (this.lengthProperties[name]) {
  65825. if (!Ext.dom.Element.hasUnit(value)) {
  65826. value = value + defaultLengthUnit;
  65827. if (isCustom) {
  65828. value = this.getCustomValue(value, name);
  65829. }
  65830. }
  65831. }
  65832. return value;
  65833. } else if (type === 'number') {
  65834. if (value === 0) {
  65835. return '0';
  65836. }
  65837. if (this.lengthProperties[name]) {
  65838. value = value + defaultLengthUnit;
  65839. if (isCustom) {
  65840. value = this.getCustomValue(value, name);
  65841. }
  65842. return value;
  65843. }
  65844. if (this.angleProperties[name]) {
  65845. return value + this.DEFAULT_UNIT_ANGLE;
  65846. }
  65847. if (this.durationProperties[name]) {
  65848. return value + this.DEFAULT_UNIT_DURATION;
  65849. }
  65850. } else if (name === 'transform') {
  65851. transformMethods = this.transformMethods;
  65852. transformValues = [];
  65853. for (i = 0 , ln = transformMethods.length; i < ln; i++) {
  65854. method = transformMethods[i];
  65855. transformValues.push(method + '(' + this.formatValue(value[method], method) + ')');
  65856. }
  65857. return transformValues.join(' ');
  65858. } else if (Ext.isArray(value)) {
  65859. values = [];
  65860. for (i = 0 , ln = value.length; i < ln; i++) {
  65861. values.push(this.formatValue(value[i], name));
  65862. }
  65863. return (values.length > 0) ? values.join(', ') : 'none';
  65864. }
  65865. return value;
  65866. },
  65867. getCustomValue: function(value, name) {
  65868. var el = Ext.fly(this.activeElement);
  65869. if (name === 'x') {
  65870. value = el.translateXY(parseInt(value, 10)).x;
  65871. } else if (name === 'y') {
  65872. value = el.translateXY(null, parseInt(value, 10)).y;
  65873. }
  65874. return value + this.DEFAULT_UNIT_LENGTH;
  65875. }
  65876. });
  65877. Ext.define('Ext.fx.runner.CssTransition', {
  65878. extend: Ext.fx.runner.Css,
  65879. alternateClassName: 'Ext.Animator',
  65880. singleton: true,
  65881. listenersAttached: false,
  65882. constructor: function() {
  65883. this.runningAnimationsData = {};
  65884. this.transitionQueue = {
  65885. toData: {},
  65886. transitionData: {}
  65887. };
  65888. return this.callParent(arguments);
  65889. },
  65890. attachListeners: function() {
  65891. var target = (top === window) ? Ext.getWin() : Ext.getBody();
  65892. this.listenersAttached = true;
  65893. target.on('transitionend', 'onTransitionEnd', this);
  65894. },
  65895. onTransitionEnd: function(e) {
  65896. var target = e.target,
  65897. id = target.id;
  65898. if (id && this.runningAnimationsData.hasOwnProperty(id)) {
  65899. this.refreshRunningAnimationsData(Ext.get(target), [
  65900. e.browserEvent.propertyName
  65901. ]);
  65902. }
  65903. },
  65904. getElementId: function(element) {
  65905. return element.getId ? element.getId() : element.id;
  65906. },
  65907. onAnimationEnd: function(element, data, animation, isInterrupted, isReplaced) {
  65908. var id = this.getElementId(element),
  65909. runningData = this.runningAnimationsData[id],
  65910. endRules = {},
  65911. endData = {},
  65912. runningNameMap, toPropertyNames, i, ln, name;
  65913. animation.un('stop', 'onAnimationStop', this);
  65914. if (runningData) {
  65915. runningNameMap = runningData.nameMap;
  65916. }
  65917. endRules[id] = endData;
  65918. if (data.onBeforeEnd) {
  65919. data.onBeforeEnd.call(data.scope || this, element, isInterrupted);
  65920. }
  65921. animation.fireEvent('animationbeforeend', animation, element, isInterrupted);
  65922. this.fireEvent('animationbeforeend', this, animation, element, isInterrupted);
  65923. if (isReplaced || (!isInterrupted && !data.preserveEndState)) {
  65924. toPropertyNames = data.toPropertyNames;
  65925. for (i = 0 , ln = toPropertyNames.length; i < ln; i++) {
  65926. name = toPropertyNames[i];
  65927. if (runningNameMap && !runningNameMap.hasOwnProperty(name)) {
  65928. endData[name] = null;
  65929. }
  65930. }
  65931. }
  65932. if (data.after) {
  65933. Ext.merge(endData, data.after);
  65934. }
  65935. this.applyStyles(endRules);
  65936. if (data.onEnd) {
  65937. data.onEnd.call(data.scope || this, element, isInterrupted);
  65938. }
  65939. animation.fireEvent('animationend', animation, element, isInterrupted);
  65940. this.fireEvent('animationend', this, animation, element, isInterrupted);
  65941. Ext.AnimationQueue.stop(Ext.emptyFn, animation);
  65942. },
  65943. onAllAnimationsEnd: function(element) {
  65944. var id = this.getElementId(element),
  65945. transitionQueue = this.transitionQueue,
  65946. endRules = {};
  65947. delete this.runningAnimationsData[id];
  65948. endRules[id] = {
  65949. 'transition-property': null,
  65950. 'transition-duration': null,
  65951. 'transition-timing-function': null,
  65952. 'transition-delay': null
  65953. };
  65954. delete transitionQueue.toData[id];
  65955. delete transitionQueue.transitionData[id];
  65956. this.applyStyles(endRules);
  65957. this.fireEvent('animationallend', this, element);
  65958. },
  65959. hasRunningAnimations: function(element) {
  65960. var id = this.getElementId(element),
  65961. runningAnimationsData = this.runningAnimationsData;
  65962. return runningAnimationsData.hasOwnProperty(id) && runningAnimationsData[id].sessions.length > 0;
  65963. },
  65964. refreshRunningAnimationsData: function(element, propertyNames, interrupt, replace) {
  65965. var id = this.getElementId(element),
  65966. runningAnimationsData = this.runningAnimationsData,
  65967. runningData = runningAnimationsData[id],
  65968. hasCompletedSession = false,
  65969. nameMap, nameList, sessions, name, session, map, list, i, ln, j, subLn;
  65970. if (!runningData) {
  65971. return;
  65972. }
  65973. nameMap = runningData.nameMap;
  65974. nameList = runningData.nameList;
  65975. sessions = runningData.sessions;
  65976. interrupt = Boolean(interrupt);
  65977. replace = Boolean(replace);
  65978. if (!sessions) {
  65979. return this;
  65980. }
  65981. ln = sessions.length;
  65982. if (ln === 0) {
  65983. return this;
  65984. }
  65985. if (replace) {
  65986. runningData.nameMap = {};
  65987. nameList.length = 0;
  65988. for (i = 0; i < ln; i++) {
  65989. session = sessions[i];
  65990. this.onAnimationEnd(element, session.data, session.animation, interrupt, replace);
  65991. }
  65992. sessions.length = 0;
  65993. } else {
  65994. for (i = 0; i < ln; i++) {
  65995. session = sessions[i];
  65996. map = session.map;
  65997. list = session.list;
  65998. for (j = 0 , subLn = propertyNames.length; j < subLn; j++) {
  65999. name = propertyNames[j];
  66000. if (map[name]) {
  66001. delete map[name];
  66002. Ext.Array.remove(list, name);
  66003. session.length--;
  66004. if (--nameMap[name] === 0) {
  66005. delete nameMap[name];
  66006. Ext.Array.remove(nameList, name);
  66007. }
  66008. }
  66009. }
  66010. if (session.length === 0) {
  66011. sessions.splice(i, 1);
  66012. i--;
  66013. ln--;
  66014. hasCompletedSession = true;
  66015. this.onAnimationEnd(element, session.data, session.animation, interrupt);
  66016. }
  66017. }
  66018. }
  66019. if (!replace && !interrupt && sessions.length === 0 && hasCompletedSession) {
  66020. this.onAllAnimationsEnd(element);
  66021. }
  66022. },
  66023. getRunningData: function(id) {
  66024. var runningAnimationsData = this.runningAnimationsData;
  66025. if (!runningAnimationsData.hasOwnProperty(id)) {
  66026. runningAnimationsData[id] = {
  66027. nameMap: {},
  66028. nameList: [],
  66029. sessions: []
  66030. };
  66031. }
  66032. return runningAnimationsData[id];
  66033. },
  66034. getTestElement: function() {
  66035. var me = this,
  66036. testElement = me.testElement,
  66037. iframe = me.iframe,
  66038. iframeDocument, iframeStyle;
  66039. if (testElement) {
  66040. if (testElement.ownerDocument.defaultView !== iframe.contentWindow) {
  66041. iframeDocument = iframe.contentDocument;
  66042. iframeDocument.body.appendChild(testElement);
  66043. me.testElementComputedStyle = iframeDocument.defaultView.getComputedStyle(testElement);
  66044. }
  66045. } else {
  66046. iframe = me.iframe = document.createElement('iframe');
  66047. iframe.setAttribute('data-sticky', true);
  66048. iframe.setAttribute('tabIndex', -1);
  66049. iframeStyle = iframe.style;
  66050. iframeStyle.setProperty('visibility', 'hidden', 'important');
  66051. iframeStyle.setProperty('width', '0px', 'important');
  66052. iframeStyle.setProperty('height', '0px', 'important');
  66053. iframeStyle.setProperty('position', 'absolute', 'important');
  66054. iframeStyle.setProperty('border', '0px', 'important');
  66055. iframeStyle.setProperty('zIndex', '-1000', 'important');
  66056. document.body.appendChild(iframe);
  66057. iframeDocument = iframe.contentDocument;
  66058. iframeDocument.open();
  66059. iframeDocument.writeln('</body>');
  66060. iframeDocument.close();
  66061. me.testElement = testElement = iframeDocument.createElement('div');
  66062. testElement.style.setProperty('position', 'absolute', 'important');
  66063. iframeDocument.body.appendChild(testElement);
  66064. me.testElementComputedStyle = iframeDocument.defaultView.getComputedStyle(testElement);
  66065. }
  66066. return testElement;
  66067. },
  66068. getCssStyleValue: function(name, value) {
  66069. var testElement = this.getTestElement(),
  66070. computedStyle = this.testElementComputedStyle,
  66071. style = testElement.style;
  66072. style.setProperty(name, value);
  66073. if (Ext.browser.is.Firefox) {
  66074. testElement.offsetHeight;
  66075. }
  66076. value = computedStyle.getPropertyValue(name);
  66077. style.removeProperty(name);
  66078. return value;
  66079. },
  66080. run: function(animations) {
  66081. var me = this,
  66082. ret = [],
  66083. isLengthPropertyMap = me.lengthProperties,
  66084. fromData = {},
  66085. toData = me.transitionQueue.toData,
  66086. data = {},
  66087. transitionData = me.transitionQueue.transitionData,
  66088. element, elementId, from, to, before, fromPropertyNames, toPropertyNames, doApplyTo, message, runningData, elementData, i, j, ln, animation, propertiesLength, sessionNameMap, computedStyle, formattedName, name, toFormattedValue, computedValue, fromFormattedValue, isLengthProperty, runningNameMap, runningNameList, runningSessions, runningSession, messageTimerFn, onBeforeStart;
  66089. if (!me.listenersAttached) {
  66090. me.attachListeners();
  66091. }
  66092. animations = Ext.Array.from(animations);
  66093. for (i = 0 , ln = animations.length; i < ln; i++) {
  66094. animation = animations[i];
  66095. animation = Ext.factory(animation, Ext.fx.Animation);
  66096. ret.push(animation);
  66097. me.activeElement = element = animation.getElement();
  66098. Ext.AnimationQueue.start(Ext.emptyFn, animation);
  66099. computedStyle = window.getComputedStyle(element.dom);
  66100. elementId = me.getElementId(element);
  66101. data[elementId] = data = Ext.merge({}, animation.getData());
  66102. onBeforeStart = animation.getOnBeforeStart();
  66103. if (onBeforeStart) {
  66104. onBeforeStart.call(animation.scope || me, element);
  66105. }
  66106. animation.fireEvent('animationstart', animation, data);
  66107. me.fireEvent('animationstart', me, animation, data);
  66108. before = data.before;
  66109. from = data.from;
  66110. to = data.to;
  66111. data.fromPropertyNames = fromPropertyNames = [];
  66112. data.toPropertyNames = toPropertyNames = [];
  66113. for (name in to) {
  66114. if (to.hasOwnProperty(name)) {
  66115. to[name] = toFormattedValue = me.formatValue(to[name], name);
  66116. formattedName = me.formatName(name);
  66117. isLengthProperty = isLengthPropertyMap.hasOwnProperty(name);
  66118. if (!isLengthProperty) {
  66119. toFormattedValue = me.getCssStyleValue(formattedName, toFormattedValue);
  66120. }
  66121. if (from.hasOwnProperty(name)) {
  66122. from[name] = fromFormattedValue = me.formatValue(from[name], name);
  66123. if (!isLengthProperty) {
  66124. fromFormattedValue = me.getCssStyleValue(formattedName, fromFormattedValue);
  66125. }
  66126. if (toFormattedValue !== fromFormattedValue) {
  66127. fromPropertyNames.push(formattedName);
  66128. toPropertyNames.push(formattedName);
  66129. }
  66130. } else {
  66131. computedValue = computedStyle.getPropertyValue(formattedName);
  66132. if (toFormattedValue !== computedValue) {
  66133. toPropertyNames.push(formattedName);
  66134. }
  66135. }
  66136. }
  66137. }
  66138. propertiesLength = toPropertyNames.length;
  66139. if (propertiesLength === 0) {
  66140. me.onAnimationEnd(element, data, animation);
  66141. continue;
  66142. }
  66143. runningData = me.getRunningData(elementId);
  66144. runningSessions = runningData.sessions;
  66145. if (runningSessions.length > 0) {
  66146. me.refreshRunningAnimationsData(element, Ext.Array.merge(fromPropertyNames, toPropertyNames), true, data.replacePrevious);
  66147. }
  66148. runningNameMap = runningData.nameMap;
  66149. runningNameList = runningData.nameList;
  66150. sessionNameMap = {};
  66151. for (j = 0; j < propertiesLength; j++) {
  66152. name = toPropertyNames[j];
  66153. sessionNameMap[name] = true;
  66154. if (!runningNameMap.hasOwnProperty(name)) {
  66155. runningNameMap[name] = 1;
  66156. runningNameList.push(name);
  66157. } else {
  66158. runningNameMap[name]++;
  66159. }
  66160. }
  66161. runningSession = {
  66162. element: element,
  66163. map: sessionNameMap,
  66164. list: toPropertyNames.slice(),
  66165. length: propertiesLength,
  66166. data: data,
  66167. animation: animation
  66168. };
  66169. runningSessions.push(runningSession);
  66170. animation.on('stop', 'onAnimationStop', me);
  66171. elementData = Ext.apply({}, before);
  66172. Ext.apply(elementData, from);
  66173. if (runningNameList.length > 0) {
  66174. fromPropertyNames = Ext.Array.difference(runningNameList, fromPropertyNames);
  66175. toPropertyNames = Ext.Array.merge(fromPropertyNames, toPropertyNames);
  66176. elementData['transition-property'] = fromPropertyNames;
  66177. }
  66178. fromData[elementId] = elementData;
  66179. toData[elementId] = Ext.apply({}, to);
  66180. transitionData[elementId] = {
  66181. 'transition-property': toPropertyNames,
  66182. 'transition-duration': data.duration,
  66183. 'transition-timing-function': data.easing,
  66184. 'transition-delay': data.delay
  66185. };
  66186. animation.startTime = Date.now();
  66187. }
  66188. me.activeElement = null;
  66189. message = me.$className;
  66190. me.applyStyles(fromData);
  66191. doApplyTo = function(e) {
  66192. if (e.data === message && e.source === window) {
  66193. window.removeEventListener('message', doApplyTo, false);
  66194. me.applyStyles(me.transitionQueue.toData);
  66195. }
  66196. };
  66197. if (!me.messageTimerId) {
  66198. messageTimerFn = function() {
  66199. var messageFollowupFn;
  66200. me.messageTimerId = null;
  66201. if (Ext.isIE) {
  66202. me.applyStyles(me.transitionQueue.transitionData);
  66203. if (!me.messageFollowupId) {
  66204. messageFollowupFn = function() {
  66205. me.messageFollowupId = null;
  66206. window.addEventListener('message', doApplyTo, false);
  66207. window.postMessage(message, '*');
  66208. };
  66209. messageFollowupFn.$skipTimerCheck = true;
  66210. me.messageFollowupId = Ext.raf(messageFollowupFn);
  66211. }
  66212. } else {
  66213. Ext.merge(me.transitionQueue.toData, me.transitionQueue.transitionData);
  66214. window.addEventListener('message', doApplyTo, false);
  66215. window.postMessage(message, '*');
  66216. }
  66217. };
  66218. messageTimerFn.$skipTimerCheck = true;
  66219. me.messageTimerId = Ext.raf(messageTimerFn);
  66220. }
  66221. return ret;
  66222. },
  66223. onAnimationStop: function(animation) {
  66224. var me = this,
  66225. runningAnimationsData = me.runningAnimationsData,
  66226. activeAnimations = 0,
  66227. stoppedAnimations = 0,
  66228. id, runningData, sessions, i, ln, session;
  66229. for (id in runningAnimationsData) {
  66230. if (runningAnimationsData.hasOwnProperty(id)) {
  66231. runningData = runningAnimationsData[id];
  66232. sessions = runningData.sessions;
  66233. activeAnimations++;
  66234. for (i = 0 , ln = sessions.length; i < ln; i++) {
  66235. session = sessions[i];
  66236. if (session.animation === animation) {
  66237. me.refreshRunningAnimationsData(session.element, session.list.slice(), false);
  66238. if (animation.destroying) {
  66239. stoppedAnimations++;
  66240. }
  66241. }
  66242. }
  66243. }
  66244. }
  66245. if (activeAnimations === stoppedAnimations) {
  66246. if (me.messageFollowupId) {
  66247. Ext.unraf(me.messageFollowupId);
  66248. me.messageFollowupId = null;
  66249. }
  66250. if (me.messageTimerId) {
  66251. Ext.unraf(me.messageTimerId);
  66252. me.messageTimerId = null;
  66253. }
  66254. Ext.apply(me.transitionQueue, {
  66255. toData: {},
  66256. transitionData: {}
  66257. });
  66258. }
  66259. }
  66260. });
  66261. Ext.define('Ext.fx.Runner', {
  66262. constructor: function() {
  66263. return new Ext.fx.runner.CssTransition();
  66264. }
  66265. });
  66266. Ext.define('Ext.fx.animation.Cube', {
  66267. extend: Ext.fx.animation.Abstract,
  66268. alias: 'animation.cube',
  66269. config: {
  66270. before: {},
  66271. after: {},
  66272. direction: 'right',
  66273. out: false
  66274. },
  66275. getData: function() {
  66276. var to = this.getTo(),
  66277. from = this.getFrom(),
  66278. before = this.getBefore(),
  66279. after = this.getAfter(),
  66280. out = this.getOut(),
  66281. direction = this.getDirection(),
  66282. el = this.getElement(),
  66283. elW = el.getWidth(),
  66284. origin = out ? '100% 100%' : '0% 0%',
  66285. fromOpacity = 1,
  66286. toOpacity = 1,
  66287. transformFrom = {
  66288. rotateY: 0,
  66289. translateZ: 0
  66290. },
  66291. transformTo = {
  66292. rotateY: 0,
  66293. translateZ: 0
  66294. };
  66295. if (direction === "left" || direction === "right") {
  66296. if (out) {
  66297. toOpacity = 0.5;
  66298. transformTo.translateZ = elW;
  66299. transformTo.rotateY = -90;
  66300. } else {
  66301. fromOpacity = 0.5;
  66302. transformFrom.translateZ = elW;
  66303. transformFrom.rotateY = 90;
  66304. }
  66305. }
  66306. before['transform-origin'] = origin;
  66307. after['transform-origin'] = null;
  66308. to.set('transform', transformTo);
  66309. from.set('transform', transformFrom);
  66310. from.set('opacity', fromOpacity);
  66311. to.set('opacity', toOpacity);
  66312. return this.callParent(arguments);
  66313. }
  66314. });
  66315. Ext.define('Ext.fx.animation.Wipe', {
  66316. extend: Ext.fx.Animation,
  66317. alternateClassName: 'Ext.fx.animation.WipeIn',
  66318. config: {
  66319. easing: 'ease-out',
  66320. direction: 'right',
  66321. out: false
  66322. },
  66323. refresh: function() {
  66324. var me = this,
  66325. el = me.getElement(),
  66326. elBox = el.dom.getBoundingClientRect(),
  66327. elWidth = elBox.width,
  66328. elHeight = elBox.height,
  66329. from = me.getFrom(),
  66330. to = me.getTo(),
  66331. out = me.getOut(),
  66332. direction = me.getDirection(),
  66333. maskFromX = 0,
  66334. maskFromY = 0,
  66335. maskToX = 0,
  66336. maskToY = 0,
  66337. mask, tmp;
  66338. switch (direction) {
  66339. case 'up':
  66340. if (out) {
  66341. mask = '-webkit-gradient(linear, left top, left bottom, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  66342. maskFromY = elHeight * 3 + 'px';
  66343. maskToY = elHeight + 'px';
  66344. } else {
  66345. mask = '-webkit-gradient(linear, left top, left bottom, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  66346. maskFromY = -elHeight * 2 + 'px';
  66347. maskToY = 0;
  66348. };
  66349. break;
  66350. case 'down':
  66351. if (out) {
  66352. mask = '-webkit-gradient(linear, left top, left bottom, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  66353. maskFromY = -elHeight * 2 + 'px';
  66354. maskToY = 0;
  66355. } else {
  66356. mask = '-webkit-gradient(linear, left top, left bottom, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  66357. maskFromY = elHeight * 3 + 'px';
  66358. maskToY = elHeight + 'px';
  66359. };
  66360. break;
  66361. case 'right':
  66362. if (out) {
  66363. mask = '-webkit-gradient(linear, right top, left top, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  66364. maskFromX = -elWidth * 2 + 'px';
  66365. maskToX = 0;
  66366. } else {
  66367. mask = '-webkit-gradient(linear, right top, left top, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  66368. maskToX = -elWidth * 2 + 'px';
  66369. };
  66370. break;
  66371. case 'left':
  66372. if (out) {
  66373. mask = '-webkit-gradient(linear, right top, left top, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  66374. maskToX = -elWidth * 2 + 'px';
  66375. } else {
  66376. mask = '-webkit-gradient(linear, right top, left top, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  66377. maskFromX = -elWidth * 2 + 'px';
  66378. maskToX = 0;
  66379. };
  66380. break;
  66381. }
  66382. if (!out) {
  66383. tmp = maskFromY;
  66384. maskFromY = maskToY;
  66385. maskToY = tmp;
  66386. tmp = maskFromX;
  66387. maskFromX = maskToX;
  66388. maskToX = tmp;
  66389. }
  66390. from.set('mask-image', mask);
  66391. from.set('mask-size', elWidth * 3 + 'px ' + elHeight * 3 + 'px');
  66392. from.set('mask-position-x', maskFromX);
  66393. from.set('mask-position-y', maskFromY);
  66394. to.set('mask-position-x', maskToX);
  66395. to.set('mask-position-y', maskToY);
  66396. }
  66397. });
  66398. Ext.define('Ext.fx.animation.WipeOut', {
  66399. extend: Ext.fx.animation.Wipe,
  66400. config: {
  66401. out: true
  66402. }
  66403. });
  66404. Ext.define('Ext.fx.easing.Bounce', {
  66405. extend: Ext.fx.easing.Abstract,
  66406. config: {
  66407. springTension: 0.3,
  66408. acceleration: 30,
  66409. startVelocity: 0
  66410. },
  66411. getValue: function() {
  66412. var deltaTime = Ext.Date.now() - this.getStartTime(),
  66413. theta = (deltaTime / this.getAcceleration()),
  66414. powTime = theta * Math.pow(Math.E, -this.getSpringTension() * theta);
  66415. return this.getStartValue() + (this.getStartVelocity() * powTime);
  66416. }
  66417. });
  66418. Ext.define('Ext.fx.easing.Momentum', {
  66419. extend: Ext.fx.easing.Abstract,
  66420. config: {
  66421. acceleration: 30,
  66422. friction: 0,
  66423. startVelocity: 0
  66424. },
  66425. alpha: 0,
  66426. updateFriction: function(friction) {
  66427. var theta = Math.log(1 - (friction / 10));
  66428. this.theta = theta;
  66429. this.alpha = theta / this.getAcceleration();
  66430. },
  66431. updateStartVelocity: function(velocity) {
  66432. this.velocity = velocity * this.getAcceleration();
  66433. },
  66434. updateAcceleration: function(acceleration) {
  66435. this.velocity = this.getStartVelocity() * acceleration;
  66436. this.alpha = this.theta / acceleration;
  66437. },
  66438. getValue: function() {
  66439. return this.getStartValue() - this.velocity * (1 - this.getFrictionFactor()) / this.theta;
  66440. },
  66441. getFrictionFactor: function() {
  66442. var deltaTime = Ext.Date.now() - this.getStartTime();
  66443. return Math.exp(deltaTime * this.alpha);
  66444. },
  66445. getVelocity: function() {
  66446. return this.getFrictionFactor() * this.velocity;
  66447. }
  66448. });
  66449. Ext.define('Ext.fx.easing.BoundMomentum', {
  66450. extend: Ext.fx.easing.Abstract,
  66451. config: {
  66452. momentum: null,
  66453. bounce: null,
  66454. minMomentumValue: 0,
  66455. maxMomentumValue: 0,
  66456. minVelocity: 0.01,
  66457. startVelocity: 0
  66458. },
  66459. applyMomentum: function(config, currentEasing) {
  66460. return Ext.factory(config, Ext.fx.easing.Momentum, currentEasing);
  66461. },
  66462. applyBounce: function(config, currentEasing) {
  66463. return Ext.factory(config, Ext.fx.easing.Bounce, currentEasing);
  66464. },
  66465. updateStartTime: function(startTime) {
  66466. this.getMomentum().setStartTime(startTime);
  66467. this.callParent(arguments);
  66468. },
  66469. updateStartVelocity: function(startVelocity) {
  66470. this.getMomentum().setStartVelocity(startVelocity);
  66471. },
  66472. updateStartValue: function(startValue) {
  66473. this.getMomentum().setStartValue(startValue);
  66474. },
  66475. reset: function() {
  66476. this.lastValue = null;
  66477. this.isBouncingBack = false;
  66478. this.isOutOfBound = false;
  66479. return this.callParent(arguments);
  66480. },
  66481. getValue: function() {
  66482. var momentum = this.getMomentum(),
  66483. bounce = this.getBounce(),
  66484. startVelocity = momentum.getStartVelocity(),
  66485. direction = startVelocity > 0 ? 1 : -1,
  66486. minValue = this.getMinMomentumValue(),
  66487. maxValue = this.getMaxMomentumValue(),
  66488. boundedValue = (direction === 1) ? maxValue : minValue,
  66489. lastValue = this.lastValue,
  66490. value, velocity;
  66491. if (startVelocity === 0) {
  66492. return this.getStartValue();
  66493. }
  66494. if (!this.isOutOfBound) {
  66495. value = momentum.getValue();
  66496. velocity = momentum.getVelocity();
  66497. if (Math.abs(velocity) < this.getMinVelocity()) {
  66498. this.isEnded = true;
  66499. }
  66500. if (value >= minValue && value <= maxValue) {
  66501. return value;
  66502. }
  66503. this.isOutOfBound = true;
  66504. bounce.setStartTime(Ext.Date.now()).setStartVelocity(velocity).setStartValue(boundedValue);
  66505. }
  66506. value = bounce.getValue();
  66507. if (!this.isEnded) {
  66508. if (!this.isBouncingBack) {
  66509. if (lastValue !== null) {
  66510. if ((direction === 1 && value < lastValue) || (direction === -1 && value > lastValue)) {
  66511. this.isBouncingBack = true;
  66512. }
  66513. }
  66514. } else {
  66515. if (Math.round(value) === boundedValue) {
  66516. this.isEnded = true;
  66517. }
  66518. }
  66519. }
  66520. this.lastValue = value;
  66521. return value;
  66522. }
  66523. });
  66524. Ext.define('Ext.fx.easing.EaseIn', {
  66525. extend: Ext.fx.easing.Linear,
  66526. alias: 'easing.ease-in',
  66527. config: {
  66528. exponent: 4,
  66529. duration: 1500
  66530. },
  66531. getValue: function() {
  66532. var deltaTime = Ext.Date.now() - this.getStartTime(),
  66533. duration = this.getDuration(),
  66534. startValue = this.getStartValue(),
  66535. endValue = this.getEndValue(),
  66536. distance = this.distance,
  66537. theta = deltaTime / duration,
  66538. thetaEnd = Math.pow(theta, this.getExponent()),
  66539. currentValue = startValue + (thetaEnd * distance);
  66540. if (deltaTime >= duration) {
  66541. this.isEnded = true;
  66542. return endValue;
  66543. }
  66544. return currentValue;
  66545. }
  66546. });
  66547. Ext.define('Ext.fx.easing.EaseOut', {
  66548. extend: Ext.fx.easing.Linear,
  66549. alias: 'easing.ease-out',
  66550. config: {
  66551. exponent: 4,
  66552. duration: 1500
  66553. },
  66554. getValue: function() {
  66555. var deltaTime = Ext.Date.now() - this.getStartTime(),
  66556. duration = this.getDuration(),
  66557. startValue = this.getStartValue(),
  66558. endValue = this.getEndValue(),
  66559. distance = this.distance,
  66560. theta = deltaTime / duration,
  66561. thetaC = 1 - theta,
  66562. thetaEnd = 1 - Math.pow(thetaC, this.getExponent()),
  66563. currentValue = startValue + (thetaEnd * distance);
  66564. if (deltaTime >= duration) {
  66565. this.isEnded = true;
  66566. return endValue;
  66567. }
  66568. return currentValue;
  66569. }
  66570. });
  66571. Ext.define('Ext.fx.easing.Easing', {
  66572. constructor: function(easing) {
  66573. return Ext.factory(easing, Ext.fx.easing.Linear, null, 'easing');
  66574. }
  66575. });
  66576. Ext.define('Ext.fx.runner.CssAnimation', {
  66577. extend: Ext.fx.runner.Css,
  66578. constructor: function() {
  66579. this.runningAnimationsMap = {};
  66580. this.elementEndStates = {};
  66581. this.animationElementMap = {};
  66582. this.keyframesRulesCache = {};
  66583. this.uniqueId = 0;
  66584. return this.callParent(arguments);
  66585. },
  66586. attachListeners: function() {
  66587. this.listenersAttached = true;
  66588. Ext.getWin().on({
  66589. animationstart: 'onAnimationStart',
  66590. animationend: 'onAnimationEnd',
  66591. scope: this
  66592. });
  66593. },
  66594. onAnimationStart: function(e) {
  66595. var name = e.browserEvent.animationName,
  66596. elementId = this.animationElementMap[name],
  66597. animation = this.runningAnimationsMap[elementId][name],
  66598. elementEndStates = this.elementEndStates,
  66599. elementEndState = elementEndStates[elementId],
  66600. data = {};
  66601. if (elementEndState) {
  66602. delete elementEndStates[elementId];
  66603. data[elementId] = elementEndState;
  66604. this.applyStyles(data);
  66605. }
  66606. if (animation.before) {
  66607. data[elementId] = animation.before;
  66608. this.applyStyles(data);
  66609. }
  66610. },
  66611. onAnimationEnd: function(e) {
  66612. var element = e.target,
  66613. name = e.browserEvent.animationName,
  66614. animationElementMap = this.animationElementMap,
  66615. elementId = animationElementMap[name],
  66616. runningAnimationsMap = this.runningAnimationsMap,
  66617. runningAnimations = runningAnimationsMap[elementId],
  66618. animation = runningAnimations[name];
  66619. if (animation.onBeforeEnd) {
  66620. animation.onBeforeEnd.call(animation.scope || this, element);
  66621. }
  66622. if (animation.onEnd) {
  66623. animation.onEnd.call(animation.scope || this, element);
  66624. }
  66625. delete animationElementMap[name];
  66626. delete runningAnimations[name];
  66627. this.removeKeyframesRule(name);
  66628. },
  66629. generateAnimationId: function() {
  66630. return 'animation-' + (++this.uniqueId);
  66631. },
  66632. run: function(animations) {
  66633. var data = {},
  66634. elementEndStates = this.elementEndStates,
  66635. animationElementMap = this.animationElementMap,
  66636. runningAnimationsMap = this.runningAnimationsMap,
  66637. runningAnimations, states, elementId, animationId, i, ln, animation, name, runningAnimation, names, durations, easings, delays, directions, iterations;
  66638. if (!this.listenersAttached) {
  66639. this.attachListeners();
  66640. }
  66641. animations = Ext.Array.from(animations);
  66642. for (i = 0 , ln = animations.length; i < ln; i++) {
  66643. animation = animations[i];
  66644. animation = Ext.factory(animation, Ext.fx.Animation);
  66645. elementId = animation.getElement().getId();
  66646. animationId = animation.getName() || this.generateAnimationId();
  66647. animationElementMap[animationId] = elementId;
  66648. animation = animation.getData();
  66649. states = animation.states;
  66650. this.addKeyframesRule(animationId, states);
  66651. runningAnimations = runningAnimationsMap[elementId];
  66652. if (!runningAnimations) {
  66653. runningAnimations = runningAnimationsMap[elementId] = {};
  66654. }
  66655. runningAnimations[animationId] = animation;
  66656. names = [];
  66657. durations = [];
  66658. easings = [];
  66659. delays = [];
  66660. directions = [];
  66661. iterations = [];
  66662. for (name in runningAnimations) {
  66663. if (runningAnimations.hasOwnProperty(name)) {
  66664. runningAnimation = runningAnimations[name];
  66665. names.push(name);
  66666. durations.push(runningAnimation.duration);
  66667. easings.push(runningAnimation.easing);
  66668. delays.push(runningAnimation.delay);
  66669. directions.push(runningAnimation.direction);
  66670. iterations.push(runningAnimation.iteration);
  66671. }
  66672. }
  66673. data[elementId] = {
  66674. 'animation-name': names,
  66675. 'animation-duration': durations,
  66676. 'animation-timing-function': easings,
  66677. 'animation-delay': delays,
  66678. 'animation-direction': directions,
  66679. 'animation-iteration-count': iterations
  66680. };
  66681. if (animation.preserveEndState) {
  66682. elementEndStates[elementId] = states['100%'];
  66683. }
  66684. }
  66685. this.applyStyles(data);
  66686. },
  66687. addKeyframesRule: function(name, keyframes) {
  66688. var percentage, properties, keyframesRule, styleSheet, rules, styles, rulesLength, key, value;
  66689. styleSheet = this.getStyleSheet();
  66690. rules = styleSheet.cssRules;
  66691. rulesLength = rules.length;
  66692. styleSheet.insertRule('@' + this.vendorPrefix + 'keyframes ' + name + '{}', rulesLength);
  66693. keyframesRule = rules[rulesLength];
  66694. for (percentage in keyframes) {
  66695. properties = keyframes[percentage];
  66696. rules = keyframesRule.cssRules;
  66697. rulesLength = rules.length;
  66698. styles = [];
  66699. for (key in properties) {
  66700. value = this.formatValue(properties[key], key);
  66701. key = this.formatName(key);
  66702. styles.push(key + ':' + value);
  66703. }
  66704. keyframesRule.insertRule(percentage + '{' + styles.join(';') + '}', rulesLength);
  66705. }
  66706. return this;
  66707. },
  66708. removeKeyframesRule: function(name) {
  66709. var styleSheet = this.getStyleSheet(),
  66710. rules = styleSheet.cssRules,
  66711. i, ln, rule;
  66712. for (i = 0 , ln = rules.length; i < ln; i++) {
  66713. rule = rules[i];
  66714. if (rule.name === name) {
  66715. styleSheet.removeRule(i);
  66716. break;
  66717. }
  66718. }
  66719. return this;
  66720. }
  66721. });
  66722. Ext.define('Ext.list.AbstractTreeItem', {
  66723. extend: Ext.Widget,
  66724. isTreeListItem: true,
  66725. cachedConfig: {
  66726. expandable: false,
  66727. expanded: false,
  66728. iconCls: '',
  66729. leaf: true,
  66730. loading: false,
  66731. selected: false,
  66732. selectedParent: false
  66733. },
  66734. config: {
  66735. iconClsProperty: 'iconCls',
  66736. indent: null,
  66737. owner: null,
  66738. node: null,
  66739. over: null,
  66740. parentItem: null,
  66741. text: {
  66742. lazy: true,
  66743. $value: ''
  66744. },
  66745. textProperty: 'text'
  66746. },
  66747. updateNode: function(node) {
  66748. if (node) {
  66749. var me = this,
  66750. map = me.itemMap,
  66751. childNodes, owner, len, i, item, child;
  66752. me.element.dom.setAttribute('data-recordId', node.internalId);
  66753. if (!map) {
  66754. childNodes = node.childNodes;
  66755. owner = me.getOwner();
  66756. me.itemMap = map = {};
  66757. for (i = 0 , len = childNodes.length; i < len; ++i) {
  66758. child = childNodes[i];
  66759. if (child.data.visible) {
  66760. item = owner.createItem(child, me);
  66761. map[child.internalId] = item;
  66762. me.insertItem(item, null);
  66763. }
  66764. }
  66765. }
  66766. me.setExpanded(node.isExpanded());
  66767. me.doNodeUpdate(node);
  66768. }
  66769. },
  66770. updateSelected: function(selected) {
  66771. var parent;
  66772. if (!this.isConfiguring) {
  66773. parent = this.getParentItem();
  66774. while (parent && !parent.isRootListItem) {
  66775. parent.setSelectedParent(selected);
  66776. parent = parent.getParentItem();
  66777. }
  66778. }
  66779. },
  66780. collapse: function() {
  66781. this.getNode().collapse();
  66782. },
  66783. expand: function() {
  66784. this.getNode().expand();
  66785. },
  66786. getToolElement: Ext.emptyFn,
  66787. insertItem: Ext.emptyFn,
  66788. isExpanded: function() {
  66789. return this.getExpanded();
  66790. },
  66791. isSelectionEvent: Ext.emptyFn,
  66792. isToggleEvent: Ext.emptyFn,
  66793. nodeCollapse: function(node, collapsingForExpand) {
  66794. var me = this,
  66795. owner = me.getOwner(),
  66796. animation = me.preventAnimation ? null : owner.getAnimation();
  66797. me.nodeCollapseBegin(animation, collapsingForExpand);
  66798. if (!animation) {
  66799. me.nodeCollapseEnd(collapsingForExpand);
  66800. }
  66801. },
  66802. nodeCollapseBegin: function(animation, collapsingForExpand) {
  66803. var me = this,
  66804. owner = me.getOwner();
  66805. me.setExpanded(false);
  66806. owner.fireEvent('itemcollapse', owner, me);
  66807. },
  66808. nodeCollapseEnd: function(collapsingForExpand) {
  66809. if (!collapsingForExpand && !this.destroying) {
  66810. this.getOwner().updateLayout();
  66811. }
  66812. },
  66813. nodeExpand: function(node) {
  66814. var me = this,
  66815. owner = me.getOwner(),
  66816. floated = me.getFloated(),
  66817. animation = !floated && owner.getAnimation();
  66818. me.nodeExpandBegin(animation);
  66819. if (!animation) {
  66820. me.nodeExpandEnd();
  66821. }
  66822. },
  66823. nodeExpandBegin: function(animation) {
  66824. var me = this,
  66825. owner = me.getOwner();
  66826. me.setExpanded(true);
  66827. owner.fireEvent('itemexpand', owner, me);
  66828. },
  66829. nodeExpandEnd: function() {
  66830. if (!this.destroying) {
  66831. this.getOwner().updateLayout();
  66832. }
  66833. },
  66834. nodeInsert: function(node, refNode) {
  66835. var me = this,
  66836. owner = me.getOwner(),
  66837. map = me.itemMap,
  66838. id = node.internalId,
  66839. item = owner.getItem(node),
  66840. refItem = null,
  66841. oldParent;
  66842. if (item) {
  66843. oldParent = item.getParentItem();
  66844. oldParent.removeItem(item);
  66845. if (oldParent !== me) {
  66846. oldParent.doUpdateExpandable();
  66847. item.setParentItem(me);
  66848. }
  66849. } else {
  66850. item = me.getOwner().createItem(node, me);
  66851. }
  66852. map[id] = item;
  66853. if (refNode) {
  66854. refItem = map[refNode.internalId];
  66855. }
  66856. me.insertItem(item, refItem);
  66857. me.doUpdateExpandable();
  66858. owner.fireEvent('iteminsert', owner, me, item, refItem);
  66859. owner.updateLayout();
  66860. },
  66861. nodeRemove: function(node) {
  66862. var me = this,
  66863. map = me.itemMap,
  66864. owner = me.getOwner(),
  66865. id = node.internalId,
  66866. item = map[id];
  66867. if (item) {
  66868. delete map[id];
  66869. me.removeItem(item);
  66870. item.destroy();
  66871. me.doUpdateExpandable();
  66872. owner.fireEvent('itemremove', owner, me, item);
  66873. owner.updateLayout();
  66874. }
  66875. },
  66876. nodeUpdate: function(node, modifiedFieldNames) {
  66877. this.doNodeUpdate(node);
  66878. },
  66879. onClick: function(e) {
  66880. var me = this,
  66881. owner = me.getOwner(),
  66882. node = me.getNode(),
  66883. info = {
  66884. event: e,
  66885. item: me,
  66886. node: node,
  66887. tree: owner,
  66888. select: node.get('selectable') !== false && me.isSelectionEvent(e),
  66889. toggle: me.isToggleEvent(e)
  66890. };
  66891. if (owner.fireEvent('itemclick', owner, info) !== false) {
  66892. if (info.toggle) {
  66893. me.toggleExpanded();
  66894. e.preventDefault();
  66895. }
  66896. if (info.select) {
  66897. owner.setSelection(me.getNode());
  66898. }
  66899. }
  66900. },
  66901. removeItem: Ext.emptyFn,
  66902. destroy: function() {
  66903. var me = this,
  66904. map = me.itemMap,
  66905. owner = me.getOwner(),
  66906. key;
  66907. if (map) {
  66908. for (key in map) {
  66909. map[key].destroy();
  66910. }
  66911. me.itemMap = null;
  66912. }
  66913. if (owner) {
  66914. owner.removeItem(me.getNode());
  66915. }
  66916. me.setNode(null);
  66917. me.setParentItem(null);
  66918. me.setOwner(null);
  66919. me.callParent();
  66920. },
  66921. privates: {
  66922. doNodeUpdate: function(node, modifiedFieldNames) {
  66923. var me = this,
  66924. textProperty = this.getTextProperty(),
  66925. iconClsProperty = this.getIconClsProperty();
  66926. if (textProperty) {
  66927. me.setText(node.data[textProperty]);
  66928. }
  66929. if (iconClsProperty) {
  66930. me.setIconCls(node.data[iconClsProperty]);
  66931. }
  66932. me.setLoading(node.isLoading());
  66933. me.setLeaf(node.isLeaf());
  66934. me.doUpdateExpandable();
  66935. },
  66936. doUpdateExpandable: function() {
  66937. var node = this.getNode();
  66938. this.setExpandable(node.isExpandable());
  66939. },
  66940. toggleExpanded: function() {
  66941. if (this.isExpanded()) {
  66942. this.collapse();
  66943. } else {
  66944. this.expand();
  66945. }
  66946. },
  66947. updateIndent: function(value) {
  66948. var items = this.itemMap,
  66949. id;
  66950. for (id in items) {
  66951. items[id].setIndent(value);
  66952. }
  66953. },
  66954. updateOwner: function(owner) {
  66955. this.parent = owner;
  66956. }
  66957. }
  66958. });
  66959. Ext.define('Ext.list.RootTreeItem', {
  66960. extend: Ext.list.AbstractTreeItem,
  66961. isRootListItem: true,
  66962. element: {
  66963. reference: 'element',
  66964. tag: 'ul',
  66965. cls: Ext.baseCSSPrefix + 'treelist-root-container'
  66966. },
  66967. insertItem: function(item, refItem) {
  66968. if (refItem) {
  66969. item.element.insertBefore(refItem.element);
  66970. } else {
  66971. this.element.appendChild(item.element);
  66972. }
  66973. },
  66974. isToggleEvent: function(e) {
  66975. return false;
  66976. }
  66977. });
  66978. Ext.define('Ext.mixin.ItemRippler', {
  66979. mixinId: 'itemrippler',
  66980. config: {
  66981. itemRipple: null
  66982. },
  66983. shouldRippleItem: function(item, e) {
  66984. var itemRipple, ripple;
  66985. if (e.getTarget(this.noItemRippleSelector, this.element)) {
  66986. return false;
  66987. }
  66988. itemRipple = item && this.getItemRipple();
  66989. if (itemRipple && item.isWidget) {
  66990. ripple = item.shouldRipple(e);
  66991. if (ripple) {
  66992. itemRipple = Ext.apply({}, itemRipple, ripple);
  66993. }
  66994. }
  66995. return itemRipple;
  66996. },
  66997. rippleItem: function(item, e) {
  66998. if (!item) {
  66999. return;
  67000. }
  67001. var me = this,
  67002. start = e.type.match(me.rippleStateRe),
  67003. itemRipple = me.shouldRippleItem(item, e),
  67004. release = itemRipple && itemRipple.release,
  67005. isRelease = release === true,
  67006. el = item.isWidget ? item.el : item,
  67007. pos, delta, rs, rippledItems;
  67008. if (itemRipple && start && isRelease) {
  67009. me.$rippleStart = e.getXY();
  67010. }
  67011. if (itemRipple && el && ((!start && isRelease) || (start && release !== true))) {
  67012. rippledItems = me.$rippledItems || (me.$rippledItems = []);
  67013. rs = me.$rippleStart;
  67014. if (rs) {
  67015. pos = e.getXY();
  67016. delta = Math.sqrt(Math.pow((pos[0] - rs[0]), 2) + Math.pow((pos[1] - rs[1]), 2));
  67017. if (delta <= 8) {
  67018. el.ripple(e, itemRipple);
  67019. rippledItems.push(el);
  67020. }
  67021. } else {
  67022. el.ripple(e, itemRipple);
  67023. rippledItems.push(el);
  67024. }
  67025. me.$rippleStart = null;
  67026. }
  67027. },
  67028. destroyAllRipples: function() {
  67029. var items;
  67030. for (items = this.$rippledItems; items && items.length; ) {
  67031. items.pop().destroyAllRipples();
  67032. }
  67033. },
  67034. privates: {
  67035. noItemRippleSelector: '.' + Ext.baseCSSPrefix + 'item-no-ripple, ' + '.' + Ext.baseCSSPrefix + 'item-no-tap',
  67036. rippleStateRe: /start|down/
  67037. }
  67038. });
  67039. Ext.define('Ext.list.TreeItem', {
  67040. extend: Ext.list.AbstractTreeItem,
  67041. xtype: 'treelistitem',
  67042. collapsedCls: Ext.baseCSSPrefix + 'treelist-item-collapsed',
  67043. expandedCls: Ext.baseCSSPrefix + 'treelist-item-expanded',
  67044. floatedToolCls: Ext.baseCSSPrefix + 'treelist-item-tool-floated',
  67045. leafCls: Ext.baseCSSPrefix + 'treelist-item-leaf',
  67046. expandableCls: Ext.baseCSSPrefix + 'treelist-item-expandable',
  67047. hideIconCls: Ext.baseCSSPrefix + 'treelist-item-hide-icon',
  67048. loadingCls: Ext.baseCSSPrefix + 'treelist-item-loading',
  67049. selectedCls: Ext.baseCSSPrefix + 'treelist-item-selected',
  67050. selectedParentCls: Ext.baseCSSPrefix + 'treelist-item-selected-parent',
  67051. withIconCls: Ext.baseCSSPrefix + 'treelist-item-with-icon',
  67052. hoverCls: Ext.baseCSSPrefix + 'treelist-item-over',
  67053. rowHoverCls: Ext.baseCSSPrefix + 'treelist-row-over',
  67054. isTreeListItem: true,
  67055. config: {
  67056. rowCls: null
  67057. },
  67058. rowClsProperty: 'rowCls',
  67059. element: {
  67060. reference: 'element',
  67061. tag: 'li',
  67062. cls: Ext.baseCSSPrefix + 'treelist-item',
  67063. children: [
  67064. {
  67065. reference: 'rowElement',
  67066. cls: Ext.baseCSSPrefix + 'treelist-row',
  67067. children: [
  67068. {
  67069. reference: 'wrapElement',
  67070. cls: Ext.baseCSSPrefix + 'treelist-item-wrap',
  67071. children: [
  67072. {
  67073. reference: 'iconElement',
  67074. cls: Ext.baseCSSPrefix + 'treelist-item-icon'
  67075. },
  67076. {
  67077. reference: 'textElement',
  67078. cls: Ext.baseCSSPrefix + 'treelist-item-text'
  67079. },
  67080. {
  67081. reference: 'expanderElement',
  67082. cls: Ext.baseCSSPrefix + 'treelist-item-expander'
  67083. }
  67084. ]
  67085. }
  67086. ]
  67087. },
  67088. {
  67089. reference: 'itemContainer',
  67090. tag: 'ul',
  67091. cls: Ext.baseCSSPrefix + 'treelist-container'
  67092. },
  67093. {
  67094. reference: 'toolElement',
  67095. cls: Ext.baseCSSPrefix + 'treelist-item-tool'
  67096. }
  67097. ]
  67098. },
  67099. constructor: function(config) {
  67100. var toolDom;
  67101. this.callParent([
  67102. config
  67103. ]);
  67104. toolDom = this.toolElement.dom;
  67105. toolDom.parentNode.removeChild(toolDom);
  67106. },
  67107. getToolElement: function() {
  67108. return this.toolElement;
  67109. },
  67110. insertItem: function(item, refItem) {
  67111. if (refItem) {
  67112. item.element.insertBefore(refItem.element);
  67113. } else {
  67114. this.itemContainer.appendChild(item.element);
  67115. }
  67116. },
  67117. isSelectionEvent: function(e) {
  67118. var owner = this.getOwner();
  67119. return (!this.isToggleEvent(e) || !owner.getExpanderOnly() || owner.getSelectOnExpander());
  67120. },
  67121. isToggleEvent: function(e) {
  67122. var isExpand = false;
  67123. if (this.getOwner().getExpanderOnly()) {
  67124. isExpand = e.target === this.expanderElement.dom;
  67125. } else {
  67126. isExpand = !this.itemContainer.contains(e.target);
  67127. }
  67128. return isExpand;
  67129. },
  67130. nodeCollapseBegin: function(animation, collapsingForExpand) {
  67131. var me = this,
  67132. itemContainer = me.itemContainer,
  67133. height;
  67134. if (me.expanding) {
  67135. me.stopAnimation(me.expanding);
  67136. }
  67137. height = animation && itemContainer.getHeight();
  67138. me.callParent([
  67139. animation,
  67140. collapsingForExpand
  67141. ]);
  67142. if (animation) {
  67143. itemContainer.dom.style.display = 'block';
  67144. me.collapsingForExpand = collapsingForExpand;
  67145. me.collapsing = this.runAnimation(Ext.merge({
  67146. from: {
  67147. height: height
  67148. },
  67149. to: {
  67150. height: 0
  67151. },
  67152. callback: me.nodeCollapseDone,
  67153. scope: me
  67154. }, animation));
  67155. }
  67156. },
  67157. nodeCollapseDone: function(animation) {
  67158. var me = this,
  67159. itemContainer = me.itemContainer;
  67160. if (!me.destroying && !me.destroyed) {
  67161. me.collapsing = null;
  67162. itemContainer.dom.style.display = '';
  67163. itemContainer.setHeight(null);
  67164. me.nodeCollapseEnd(me.collapsingForExpand);
  67165. }
  67166. },
  67167. nodeExpandBegin: function(animation) {
  67168. var me = this,
  67169. itemContainer = me.itemContainer,
  67170. height;
  67171. if (me.collapsing) {
  67172. me.stopAnimation(me.collapsing);
  67173. }
  67174. me.callParent([
  67175. animation
  67176. ]);
  67177. if (animation) {
  67178. height = itemContainer.getHeight();
  67179. itemContainer.setHeight(0);
  67180. me.expanding = me.runAnimation(Ext.merge({
  67181. to: {
  67182. height: height
  67183. },
  67184. callback: me.nodeExpandDone,
  67185. scope: me
  67186. }, animation));
  67187. }
  67188. },
  67189. nodeExpandDone: function() {
  67190. this.expanding = null;
  67191. this.itemContainer.setHeight(null);
  67192. this.nodeExpandEnd();
  67193. },
  67194. removeItem: function(item) {
  67195. this.itemContainer.removeChild(item.element);
  67196. },
  67197. updateNode: function(node, oldNode) {
  67198. this.syncIndent();
  67199. this.callParent([
  67200. node,
  67201. oldNode
  67202. ]);
  67203. },
  67204. updateExpandable: function(expandable) {
  67205. this.updateExpandCls();
  67206. },
  67207. updateExpanded: function(expanded) {
  67208. var node = this.getNode();
  67209. this.updateExpandCls();
  67210. if (node) {
  67211. node.set('expanded', expanded);
  67212. }
  67213. },
  67214. updateIconCls: function(iconCls, oldIconCls) {
  67215. var me = this,
  67216. el = me.element;
  67217. me.doIconCls(me.iconElement, iconCls, oldIconCls);
  67218. me.doIconCls(me.toolElement, iconCls, oldIconCls);
  67219. el.toggleCls(me.withIconCls, !!iconCls);
  67220. el.toggleCls(me.hideIconCls, iconCls === null);
  67221. },
  67222. updateLeaf: function(leaf) {
  67223. this.element.toggleCls(this.leafCls, leaf);
  67224. },
  67225. updateLoading: function(loading) {
  67226. this.element.toggleCls(this.loadingCls, loading);
  67227. },
  67228. updateOver: function(over) {
  67229. var me = this;
  67230. me.element.toggleCls(me.hoverCls, !!over);
  67231. me.rowElement.toggleCls(me.rowHoverCls, over > 1);
  67232. },
  67233. updateRowCls: function(value, oldValue) {
  67234. this.rowElement.replaceCls(oldValue, value);
  67235. },
  67236. updateSelected: function(selected, oldSelected) {
  67237. var me = this,
  67238. cls = me.selectedCls,
  67239. tool = me.getToolElement();
  67240. me.callParent([
  67241. selected,
  67242. oldSelected
  67243. ]);
  67244. me.element.toggleCls(cls, selected);
  67245. if (tool) {
  67246. tool.toggleCls(cls, selected);
  67247. }
  67248. },
  67249. updateSelectedParent: function(selectedParent) {
  67250. var me = this,
  67251. tool;
  67252. me.element.toggleCls(me.selectedParentCls, selectedParent);
  67253. tool = me.getToolElement();
  67254. if (tool) {
  67255. tool.toggleCls(me.selectedCls, selectedParent);
  67256. }
  67257. },
  67258. updateText: function(text) {
  67259. this.textElement.update(text);
  67260. },
  67261. privates: {
  67262. doNodeUpdate: function(node) {
  67263. this.callParent([
  67264. node
  67265. ]);
  67266. this.setRowCls(node && node.data[this.rowClsProperty]);
  67267. },
  67268. doIconCls: function(element, iconCls, oldIconCls) {
  67269. if (oldIconCls) {
  67270. element.removeCls(oldIconCls);
  67271. }
  67272. if (iconCls) {
  67273. element.addCls(iconCls);
  67274. }
  67275. },
  67276. syncIndent: function() {
  67277. var me = this,
  67278. indent = me.getIndent(),
  67279. node = me.getNode(),
  67280. depth;
  67281. if (node) {
  67282. depth = node.data.depth - 1;
  67283. me.wrapElement.dom.style.marginLeft = (depth * indent) + 'px';
  67284. }
  67285. },
  67286. updateExpandCls: function() {
  67287. if (!this.updatingExpandCls) {
  67288. var me = this,
  67289. expandable = me.getExpandable(),
  67290. element = me.element,
  67291. expanded = me.getExpanded(),
  67292. expandedCls = me.expandedCls,
  67293. collapsedCls = me.collapsedCls;
  67294. me.updatingExpandCls = true;
  67295. element.toggleCls(me.expandableCls, expandable);
  67296. if (expandable) {
  67297. element.toggleCls(expandedCls, expanded);
  67298. element.toggleCls(collapsedCls, !expanded);
  67299. } else {
  67300. element.removeCls([
  67301. expandedCls,
  67302. collapsedCls
  67303. ]);
  67304. }
  67305. me.updatingExpandCls = false;
  67306. }
  67307. },
  67308. updateIndent: function(value, oldValue) {
  67309. this.syncIndent();
  67310. this.callParent([
  67311. value,
  67312. oldValue
  67313. ]);
  67314. }
  67315. }
  67316. }, function(TreeItem) {
  67317. TreeItem.prototype.floatedCls = [
  67318. Ext.Widget.prototype.floatedCls,
  67319. Ext.baseCSSPrefix + 'treelist-item-floated'
  67320. ];
  67321. });
  67322. Ext.define('Ext.list.Tree', {
  67323. extend: Ext.Gadget,
  67324. xtype: 'treelist',
  67325. mixins: [
  67326. Ext.mixin.ItemRippler
  67327. ],
  67328. expanderFirstCls: Ext.baseCSSPrefix + 'treelist-expander-first',
  67329. expanderOnlyCls: Ext.baseCSSPrefix + 'treelist-expander-only',
  67330. highlightPathCls: Ext.baseCSSPrefix + 'treelist-highlight-path',
  67331. microCls: Ext.baseCSSPrefix + 'treelist-micro',
  67332. uiPrefix: Ext.baseCSSPrefix + 'treelist-',
  67333. element: {
  67334. reference: 'element',
  67335. cls: Ext.baseCSSPrefix + 'treelist ' + Ext.baseCSSPrefix + 'unselectable',
  67336. listeners: {
  67337. click: 'onClick',
  67338. touchstart: 'onTouchStart',
  67339. touchend: 'onTouchEnd',
  67340. mouseenter: 'onMouseEnter',
  67341. mouseleave: 'onMouseLeave',
  67342. mouseover: 'onMouseOver'
  67343. },
  67344. children: [
  67345. {
  67346. reference: 'toolsElement',
  67347. cls: Ext.baseCSSPrefix + 'treelist-toolstrip',
  67348. listeners: {
  67349. click: 'onToolStripClick',
  67350. mouseover: 'onToolStripMouseOver'
  67351. }
  67352. }
  67353. ]
  67354. },
  67355. cachedConfig: {
  67356. animation: {
  67357. duration: 500,
  67358. easing: 'ease'
  67359. },
  67360. expanderFirst: true,
  67361. expanderOnly: true
  67362. },
  67363. config: {
  67364. floatLeafItems: false,
  67365. defaults: {
  67366. xtype: 'treelistitem'
  67367. },
  67368. highlightPath: null,
  67369. iconSize: null,
  67370. indent: null,
  67371. micro: false,
  67372. overItem: null,
  67373. selection: null,
  67374. selectOnExpander: false,
  67375. singleExpand: null,
  67376. store: null,
  67377. ui: null
  67378. },
  67379. twoWayBindable: {
  67380. selection: 1
  67381. },
  67382. publishes: {
  67383. selection: 1
  67384. },
  67385. defaultBindProperty: 'store',
  67386. constructor: function(config) {
  67387. this.callParent([
  67388. config
  67389. ]);
  67390. this.publishState('selection', this.getSelection());
  67391. },
  67392. destroy: function() {
  67393. var me = this;
  67394. me.unfloatAll();
  67395. me.activeFloater = null;
  67396. me.setSelection(null);
  67397. me.setStore(null);
  67398. me.callParent();
  67399. },
  67400. updateOverItem: function(over, wasOver) {
  67401. var map = {},
  67402. state = 2,
  67403. c, node;
  67404. for (c = over; c; c = this.getItem(node.parentNode)) {
  67405. node = c.getNode();
  67406. map[node.internalId] = true;
  67407. c.setOver(state);
  67408. state = 1;
  67409. }
  67410. if (wasOver && !wasOver.destroyed) {
  67411. for (c = wasOver; c; c = this.getItem(node.parentNode)) {
  67412. node = c.getNode();
  67413. if (map[node.internalId]) {
  67414. break;
  67415. }
  67416. c.setOver(0);
  67417. }
  67418. }
  67419. },
  67420. applyMicro: function(micro) {
  67421. return Boolean(micro);
  67422. },
  67423. applySelection: function(selection, oldSelection) {
  67424. var store = this.getStore();
  67425. if (!store) {
  67426. selection = null;
  67427. }
  67428. if (store && selection !== null && !(selection instanceof Ext.data.Model)) {
  67429. selection = store.getNodeById(selection);
  67430. }
  67431. if (selection && selection.get('selectable') === false) {
  67432. selection = oldSelection;
  67433. }
  67434. return selection;
  67435. },
  67436. updateSelection: function(selection, oldSelection) {
  67437. var me = this,
  67438. item, parent;
  67439. if (!me.destroying) {
  67440. item = me.getItem(oldSelection);
  67441. if (item) {
  67442. item.setSelected(false);
  67443. }
  67444. item = me.getItem(selection);
  67445. if (item) {
  67446. item.setSelected(true);
  67447. while (parent = item.getParentItem()) {
  67448. parent.setExpanded(true);
  67449. item = parent;
  67450. }
  67451. }
  67452. me.fireEvent('selectionchange', me, selection);
  67453. }
  67454. },
  67455. applyStore: function(store) {
  67456. return store && Ext.StoreManager.lookup(store, 'tree');
  67457. },
  67458. updateStore: function(store, oldStore) {
  67459. var me = this,
  67460. root;
  67461. if (oldStore) {
  67462. if (!oldStore.destroyed) {
  67463. if (oldStore.getAutoDestroy()) {
  67464. oldStore.destroy();
  67465. } else {
  67466. me.storeListeners.destroy();
  67467. }
  67468. }
  67469. me.removeRoot();
  67470. me.storeListeners = null;
  67471. }
  67472. if (store) {
  67473. me.storeListeners = store.on({
  67474. destroyable: true,
  67475. scope: me,
  67476. nodeappend: 'onNodeAppend',
  67477. nodecollapse: 'onNodeCollapse',
  67478. nodeexpand: 'onNodeExpand',
  67479. nodeinsert: 'onNodeInsert',
  67480. noderemove: 'onNodeRemove',
  67481. rootchange: 'onRootChange',
  67482. update: 'onNodeUpdate',
  67483. refresh: 'onRefresh'
  67484. });
  67485. root = store.getRoot();
  67486. if (root) {
  67487. me.createRootItem(root);
  67488. }
  67489. }
  67490. if (!me.destroying) {
  67491. me.updateLayout();
  67492. }
  67493. },
  67494. updateExpanderFirst: function(expanderFirst) {
  67495. this.element.toggleCls(this.expanderFirstCls, expanderFirst);
  67496. },
  67497. updateExpanderOnly: function(value) {
  67498. this.element.toggleCls(this.expanderOnlyCls, !value);
  67499. },
  67500. updateHighlightPath: function(updatePath) {
  67501. this.element.toggleCls(this.highlightPathCls, updatePath);
  67502. },
  67503. updateMicro: function(micro) {
  67504. var me = this;
  67505. if (!micro) {
  67506. me.unfloatAll();
  67507. me.activeFloater = null;
  67508. }
  67509. me.element.toggleCls(me.microCls, micro);
  67510. },
  67511. updateUi: function(ui, oldValue) {
  67512. var me = this,
  67513. el = me.element,
  67514. uiPrefix = me.uiPrefix;
  67515. if (oldValue) {
  67516. el.removeCls(uiPrefix + oldValue);
  67517. }
  67518. if (ui) {
  67519. el.addCls(uiPrefix + ui);
  67520. }
  67521. delete me.iconSize;
  67522. me.syncIconSize();
  67523. },
  67524. getItem: function(node) {
  67525. var map = this.itemMap,
  67526. ret;
  67527. if (node && map) {
  67528. ret = map[node.internalId];
  67529. }
  67530. return ret || null;
  67531. },
  67532. getItemConfig: function(node, parent) {
  67533. return Ext.apply({
  67534. parentItem: parent.isRootListItem ? null : parent,
  67535. owner: this,
  67536. node: node,
  67537. indent: this.getIndent()
  67538. }, this.getDefaults());
  67539. },
  67540. privates: {
  67541. checkForOutsideClick: function(e) {
  67542. var floater = this.activeFloater;
  67543. if (!floater.element.contains(e.target)) {
  67544. this.unfloatAll();
  67545. }
  67546. },
  67547. collapsingForExpand: false,
  67548. createItem: function(node, parent) {
  67549. var me = this,
  67550. item = Ext.create(me.getItemConfig(node, parent)),
  67551. toolsElement = me.toolsElement,
  67552. toolEl, previousSibling;
  67553. if (parent.isRootListItem) {
  67554. toolEl = item.getToolElement();
  67555. if (toolEl) {
  67556. previousSibling = me.findVisiblePreviousSibling(node);
  67557. if (!previousSibling) {
  67558. toolsElement.insertFirst(toolEl);
  67559. } else {
  67560. previousSibling = me.getItem(previousSibling);
  67561. toolEl.insertAfter(previousSibling.getToolElement());
  67562. }
  67563. toolEl.dom.setAttribute('data-recordId', node.internalId);
  67564. toolEl.isTool = true;
  67565. }
  67566. }
  67567. me.itemMap[node.internalId] = item;
  67568. return item;
  67569. },
  67570. createRootItem: function(root) {
  67571. var me = this,
  67572. item;
  67573. me.itemMap = {};
  67574. me.rootItem = item = new Ext.list.RootTreeItem({
  67575. indent: me.getIndent(),
  67576. node: root,
  67577. owner: me
  67578. });
  67579. me.element.appendChild(item.element);
  67580. me.itemMap[root.internalId] = item;
  67581. },
  67582. findVisiblePreviousSibling: function(node) {
  67583. var sibling = node.previousSibling;
  67584. while (sibling) {
  67585. if (sibling.data.visible) {
  67586. return sibling;
  67587. }
  67588. sibling = sibling.previousSibling;
  67589. }
  67590. return null;
  67591. },
  67592. floatItem: function(item, byHover) {
  67593. var me = this,
  67594. floater;
  67595. if (item.getFloated()) {
  67596. return;
  67597. }
  67598. if (me.toolMouseListeners) {
  67599. me.toolMouseListeners.destroy();
  67600. me.floaterMouseListeners.destroy();
  67601. me.floaterMouseListeners = me.toolMouseListeners = null;
  67602. }
  67603. me.unfloatAll();
  67604. if (!byHover && !me.getFloatLeafItems() && item.getNode().isLeaf()) {
  67605. return;
  67606. }
  67607. me.activeFloater = floater = item;
  67608. me.floatedByHover = byHover;
  67609. item.setFloated(true);
  67610. if (byHover) {
  67611. me.toolMouseListeners = item.getToolElement().monitorMouseLeave(300, me.checkForMouseLeave, me);
  67612. me.floaterMouseListeners = (item.floater || item).el.monitorMouseLeave(300, me.checkForMouseLeave, me);
  67613. floater.element.on('mouseover', 'onMouseOver', me);
  67614. } else {
  67615. Ext.on('mousedown', 'checkForOutsideClick', me);
  67616. }
  67617. },
  67618. shouldRippleItem: function(item, e) {
  67619. if (item && item.getSelected()) {
  67620. return false;
  67621. }
  67622. return this.mixins.itemrippler.shouldRippleItem.call(this, item, e);
  67623. },
  67624. onTouchStart: function(e) {
  67625. this.doItemRipple(e);
  67626. },
  67627. onTouchEnd: function(e) {
  67628. this.doItemRipple(e);
  67629. },
  67630. doItemRipple: function(e) {
  67631. var me = this,
  67632. item = e.getTarget('[data-recordId]'),
  67633. id;
  67634. if (item) {
  67635. id = item.getAttribute('data-recordId');
  67636. item = me.itemMap[id];
  67637. if (item && me.shouldRippleItem(item, e)) {
  67638. this.rippleItem(item, e);
  67639. }
  67640. }
  67641. },
  67642. onClick: function(e) {
  67643. var item = e.getTarget('[data-recordId]'),
  67644. id;
  67645. if (item) {
  67646. id = item.getAttribute('data-recordId');
  67647. item = this.itemMap[id];
  67648. if (item) {
  67649. item.onClick(e);
  67650. }
  67651. }
  67652. },
  67653. onMouseEnter: function(e) {
  67654. this.onMouseOver(e);
  67655. },
  67656. onMouseLeave: function() {
  67657. this.setOverItem(null);
  67658. },
  67659. onMouseOver: function(e) {
  67660. var comp = Ext.Component.from(e);
  67661. this.setOverItem(comp && comp.isTreeListItem && comp);
  67662. },
  67663. checkForMouseLeave: function(e) {
  67664. var floater = this.activeFloater,
  67665. relatedTarget = e.getRelatedTarget();
  67666. if (floater) {
  67667. if (relatedTarget !== floater.getToolElement().dom && !floater.element.contains(relatedTarget)) {
  67668. this.unfloatAll();
  67669. }
  67670. }
  67671. },
  67672. onNodeAppend: function(parentNode, node) {
  67673. var item;
  67674. if (parentNode) {
  67675. item = this.itemMap[parentNode.internalId];
  67676. if (item) {
  67677. item.nodeInsert(node, null);
  67678. }
  67679. }
  67680. },
  67681. onNodeCollapse: function(node) {
  67682. var item = this.itemMap[node.internalId];
  67683. if (item) {
  67684. item.nodeCollapse(node, this.collapsingForExpand);
  67685. }
  67686. },
  67687. onNodeExpand: function(node) {
  67688. var me = this,
  67689. item = me.itemMap[node.internalId],
  67690. childNodes, len, i, parentNode, child;
  67691. if (item) {
  67692. if (!item.isRootItem && me.getSingleExpand()) {
  67693. me.collapsingForExpand = true;
  67694. parentNode = (item.getParentItem() || me.rootItem).getNode();
  67695. childNodes = parentNode.childNodes;
  67696. for (i = 0 , len = childNodes.length; i < len; ++i) {
  67697. child = childNodes[i];
  67698. if (child !== node) {
  67699. child.collapse();
  67700. }
  67701. }
  67702. me.collapsing = false;
  67703. }
  67704. item.nodeExpand(node);
  67705. }
  67706. },
  67707. onNodeInsert: function(parentNode, node, refNode) {
  67708. var item = this.itemMap[parentNode.internalId];
  67709. if (item) {
  67710. item.nodeInsert(node, refNode);
  67711. }
  67712. },
  67713. onNodeRemove: function(parentNode, node, isMove) {
  67714. var item;
  67715. if (parentNode && !isMove) {
  67716. item = this.itemMap[parentNode.internalId];
  67717. if (item) {
  67718. item.nodeRemove(node);
  67719. }
  67720. }
  67721. },
  67722. onNodeUpdate: function(store, node, type, modifiedFieldNames) {
  67723. var item = this.itemMap[node.internalId];
  67724. if (item) {
  67725. item.nodeUpdate(node, modifiedFieldNames);
  67726. }
  67727. },
  67728. onRefresh: function(store) {
  67729. this.onRootChange(store.getRoot());
  67730. },
  67731. onRootChange: function(root) {
  67732. var me = this;
  67733. me.removeRoot();
  67734. if (root) {
  67735. me.createRootItem(root);
  67736. }
  67737. me.updateLayout();
  67738. me.fireEvent('refresh', me);
  67739. },
  67740. removeItem: function(node) {
  67741. var map = this.itemMap,
  67742. id = node.internalId,
  67743. item, toolEl;
  67744. if (map) {
  67745. item = map[id];
  67746. if (item.getParentItem() === null) {
  67747. toolEl = item.getToolElement();
  67748. if (toolEl) {
  67749. this.toolsElement.removeChild(toolEl);
  67750. }
  67751. }
  67752. delete map[id];
  67753. }
  67754. },
  67755. removeRoot: function() {
  67756. var me = this,
  67757. rootItem = me.rootItem;
  67758. if (rootItem) {
  67759. me.element.removeChild(rootItem.element);
  67760. me.rootItem = me.itemMap = Ext.destroy(rootItem);
  67761. }
  67762. },
  67763. onToolStripClick: function(e) {
  67764. var item = e.getTarget('[data-recordId]'),
  67765. id;
  67766. if (item) {
  67767. id = item.getAttribute('data-recordId');
  67768. item = this.itemMap[id];
  67769. if (item) {
  67770. if (item === this.activeFloater) {
  67771. this.unfloatAll();
  67772. } else {
  67773. this.floatItem(item, false);
  67774. }
  67775. }
  67776. }
  67777. },
  67778. onToolStripMouseOver: function(e) {
  67779. var item = e.getTarget('[data-recordId]'),
  67780. id;
  67781. if (item) {
  67782. id = item.getAttribute('data-recordId');
  67783. item = this.itemMap[id];
  67784. if (item) {
  67785. this.floatItem(item, true);
  67786. }
  67787. }
  67788. },
  67789. syncIconSize: function() {
  67790. var me = this,
  67791. size = me.iconSize || (me.iconSize = parseInt(me.element.getStyle('background-position'), 10));
  67792. me.setIconSize(size);
  67793. },
  67794. unfloatAll: function() {
  67795. var me = this,
  67796. floater = me.activeFloater;
  67797. if (floater) {
  67798. floater.setFloated(false);
  67799. me.activeFloater = null;
  67800. if (me.floatedByHover) {
  67801. if (me.toolMouseListeners) {
  67802. me.toolMouseListeners.destroy();
  67803. me.floaterMouseListeners.destroy();
  67804. me.floaterMouseListeners = me.toolMouseListeners = null;
  67805. }
  67806. floater.element.un('mouseover', 'onMouseOver', me);
  67807. } else {
  67808. Ext.un('mousedown', 'checkForOutsideClick', me);
  67809. }
  67810. }
  67811. },
  67812. defaultIconSize: 22,
  67813. updateIconSize: function(value) {
  67814. this.setIndent(value || this.defaultIconSize);
  67815. },
  67816. updateIndent: function(value) {
  67817. var rootItem = this.rootItem;
  67818. if (rootItem) {
  67819. rootItem.setIndent(value);
  67820. }
  67821. }
  67822. }
  67823. });
  67824. Ext.define('Ext.mixin.ConfigProxy', function(ConfigProxy) {
  67825. return {
  67826. extend: Ext.Mixin,
  67827. mixinConfig: {
  67828. id: 'configproxy',
  67829. extended: function(baseClass, derivedClass, classBody) {
  67830. var proxyConfig = classBody.proxyConfig;
  67831. derivedClass.$configProxies = Ext.apply({}, derivedClass.superclass.self.$configProxies);
  67832. if (proxyConfig) {
  67833. delete classBody.proxyConfig;
  67834. ConfigProxy.processClass(derivedClass, proxyConfig);
  67835. }
  67836. }
  67837. },
  67838. onClassMixedIn: function(targetClass) {
  67839. var prototype = targetClass.prototype,
  67840. proxyConfig = prototype.proxyConfig,
  67841. initConfig = prototype.initConfig;
  67842. prototype.$proxiedConfigs = null;
  67843. targetClass.$configProxies = {};
  67844. prototype.initConfig = function(config) {
  67845. initConfig.apply(this, arguments);
  67846. this.$proxiedConfigs = null;
  67847. return this;
  67848. };
  67849. if (proxyConfig) {
  67850. delete prototype.proxyConfig;
  67851. ConfigProxy.processClass(targetClass, proxyConfig);
  67852. }
  67853. },
  67854. getProxiedConfigs: function(name) {
  67855. var me = this,
  67856. configs = me.config,
  67857. configProxies = me.self.$configProxies[name],
  67858. i = configProxies && configProxies.length,
  67859. cfg, proxiedConfigs, ret, s, v;
  67860. if (i && me.isConfiguring) {
  67861. proxiedConfigs = me.$proxiedConfigs || (me.$proxiedConfigs = {});
  67862. while (i-- > 0) {
  67863. cfg = configProxies[i];
  67864. proxiedConfigs[s = cfg.name] = cfg;
  67865. if ((v = configs[s]) !== undefined) {
  67866. (ret || (ret = {}))[s] = v;
  67867. }
  67868. }
  67869. }
  67870. return ret;
  67871. },
  67872. mergeProxiedConfigs: function(name, itemConfig, alwaysClone) {
  67873. var me = this,
  67874. ret = itemConfig,
  67875. proxied = me.getProxiedConfigs(name),
  67876. configurator;
  67877. if (proxied) {
  67878. if (!itemConfig) {
  67879. ret = proxied;
  67880. } else if (itemConfig.constructor === Object) {
  67881. configurator = me.self.getConfigurator();
  67882. ret = configurator.merge(me, Ext.clone(itemConfig), proxied);
  67883. }
  67884. }
  67885. if (alwaysClone && ret === itemConfig) {
  67886. ret = Ext.clone(ret);
  67887. }
  67888. return ret;
  67889. },
  67890. statics: {
  67891. processClass: function(targetClass, proxyConfig) {
  67892. var ExtConfig = Ext.Config,
  67893. targetProto = targetClass.prototype,
  67894. add = {},
  67895. proxies = targetClass.$configProxies,
  67896. cfg, configs, itemGetter, i, item, methods, n, name, proxiedConfigs, s;
  67897. for (item in proxyConfig) {
  67898. itemGetter = ExtConfig.get(item).names.get;
  67899. configs = proxyConfig[item];
  67900. if (Ext.isArray(configs)) {
  67901. methods = null;
  67902. } else {
  67903. methods = configs.methods;
  67904. configs = configs.configs;
  67905. }
  67906. if (!(proxiedConfigs = proxies[item])) {
  67907. proxies[item] = proxiedConfigs = [];
  67908. } else {
  67909. proxies[item] = proxiedConfigs = proxiedConfigs.slice();
  67910. }
  67911. for (i = 0 , n = methods && methods.length; i < n; ++i) {
  67912. if (!targetProto[name = methods[i]]) {
  67913. targetProto[name] = ConfigProxy.wrapFn(itemGetter, name);
  67914. } else
  67915. {
  67916. Ext.raise('Cannot proxy method "' + name + '"');
  67917. }
  67918. }
  67919. for (i = 0 , n = configs && configs.length; i < n; ++i) {
  67920. cfg = ExtConfig.get(s = configs[i]);
  67921. if (s in add) {
  67922. Ext.raise('Duplicate proxy config definitions for "' + s + '"');
  67923. }
  67924. if (s in targetProto.config) {
  67925. Ext.raise('Config "' + s + '" already defined for class ' + targetProto.$className);
  67926. }
  67927. add[s] = undefined;
  67928. proxiedConfigs.push(cfg);
  67929. if (!targetProto[name = cfg.names.get]) {
  67930. targetProto[name] = ConfigProxy.wrapGet(itemGetter, name);
  67931. } else
  67932. {
  67933. Ext.raise('Cannot proxy "' + s + '" config getter');
  67934. }
  67935. if (!targetProto[name = cfg.names.set]) {
  67936. targetProto[name] = ConfigProxy.wrapSet(itemGetter, name, s);
  67937. } else
  67938. {
  67939. Ext.raise('Cannot proxy "' + s + '" config setter');
  67940. }
  67941. }
  67942. }
  67943. targetClass.addConfig(add);
  67944. },
  67945. wrapFn: function(itemGetter, name) {
  67946. return function() {
  67947. var item = this[itemGetter]();
  67948. return item && item[name].apply(item, arguments);
  67949. };
  67950. },
  67951. wrapGet: function(itemGetter, configGetter) {
  67952. return function() {
  67953. var item = this[itemGetter]();
  67954. return item && item[configGetter]();
  67955. };
  67956. },
  67957. wrapSet: function(itemGetter, configSetter, itemName) {
  67958. return function(value) {
  67959. var me = this,
  67960. item, proxiedConfigs;
  67961. if (!me.isConfiguring || value !== undefined) {
  67962. item = me[itemGetter]();
  67963. proxiedConfigs = me.$proxiedConfigs;
  67964. if (proxiedConfigs && proxiedConfigs[itemName]) {
  67965. delete proxiedConfigs[itemName];
  67966. item = null;
  67967. }
  67968. if (item) {
  67969. item[configSetter](value);
  67970. }
  67971. }
  67972. return me;
  67973. };
  67974. }
  67975. }
  67976. };
  67977. });
  67978. Ext.define('Ext.mixin.ConfigState', {
  67979. extend: Ext.Mixin,
  67980. mixinConfig: {
  67981. id: 'configstate'
  67982. },
  67983. alternateStateConfig: '',
  67984. toggleConfigState: function(isAlternate) {
  67985. var me = this,
  67986. state = me.capturedConfigState,
  67987. cfg = me.getConfig(me.alternateStateConfig),
  67988. key;
  67989. if (!cfg) {
  67990. return;
  67991. }
  67992. if (isAlternate) {
  67993. state = {};
  67994. for (key in cfg) {
  67995. state[key] = me.getConfig(key);
  67996. }
  67997. me.capturedConfigState = state;
  67998. me.setConfig(cfg);
  67999. }
  68000. else if (!me.isConfiguring && state) {
  68001. me.setConfig(state);
  68002. delete me.capturedConfigState;
  68003. }
  68004. }
  68005. });
  68006. Ext.define('Ext.mixin.Mashup', function(Mashup) {
  68007. return {
  68008. extend: 'Ext.Mixin',
  68009. mixinConfig: {
  68010. id: 'mashup',
  68011. extended: function(baseClass, derivedClass) {
  68012. Mashup.process(derivedClass);
  68013. }
  68014. },
  68015. statics: {
  68016. process: function(targetClass) {
  68017. var body = targetClass.prototype,
  68018. requiredScripts = body.requiredScripts,
  68019. hooks = targetClass._classHooks,
  68020. onCreated = hooks.onCreated,
  68021. xtypes = targetClass.prototype.xtypes,
  68022. mashup = Ext.manifest.mashup || {},
  68023. options = body.mashupConfig,
  68024. i, script;
  68025. if (requiredScripts) {
  68026. delete body.requiredScripts;
  68027. hooks.onCreated = function() {
  68028. var me = this,
  68029. scripts = [],
  68030. args = Ext.Array.slice(arguments),
  68031. redirect = mashup.redirect || {};
  68032. requiredScripts = scripts.concat(requiredScripts);
  68033. options = options && mashup[options.key];
  68034. if (xtypes) {
  68035. for (i = 0; !options && i < xtypes.length; ++i) {
  68036. options = mashup[xtypes[i]];
  68037. }
  68038. }
  68039. for (i = 0; i < requiredScripts.length; i++) {
  68040. script = requiredScripts[i];
  68041. if (redirect[script] === false) {
  68042. continue;
  68043. }
  68044. script = redirect[script] || script;
  68045. if (script.indexOf('{') > -1) {
  68046. if (options) {
  68047. script = new Ext.Template(script).apply(options);
  68048. } else
  68049. {
  68050. Ext.log.error('Missing mashup options for ' + body.$className + ' script "' + script + '"');
  68051. }
  68052. }
  68053. scripts.push(script);
  68054. }
  68055. if (!scripts.length) {
  68056. hooks.onCreated = onCreated;
  68057. hooks.onCreated.call(me, args);
  68058. return;
  68059. }
  68060. Ext.Loader.loadScripts({
  68061. url: scripts,
  68062. cache: true,
  68063. onError: function(opts, error) {
  68064. targetClass.scriptError = targetClass.prototype.scriptError = error;
  68065. hooks.onCreated = onCreated;
  68066. hooks.onCreated.call(me, args);
  68067. },
  68068. onLoad: function() {
  68069. hooks.onCreated = onCreated;
  68070. hooks.onCreated.call(me, args);
  68071. }
  68072. });
  68073. };
  68074. }
  68075. }
  68076. },
  68077. onClassMixedIn: function(targetClass) {
  68078. Mashup.process(targetClass);
  68079. }
  68080. };
  68081. });
  68082. Ext.define('Ext.mixin.Selectable', {
  68083. extend: Ext.Mixin,
  68084. mixinConfig: {
  68085. id: 'selectable',
  68086. after: {
  68087. updateStore: 'updateStore'
  68088. }
  68089. },
  68090. config: {
  68091. disableSelection: null,
  68092. mode: 'SINGLE',
  68093. allowDeselect: false,
  68094. lastSelected: null,
  68095. lastFocused: null,
  68096. deselectOnContainerClick: true,
  68097. selected: true,
  68098. pruneRemoved: true,
  68099. selection: null,
  68100. twoWayBindable: {
  68101. selection: 1
  68102. },
  68103. publishes: {
  68104. selection: 1
  68105. }
  68106. },
  68107. modes: {
  68108. SINGLE: true,
  68109. SIMPLE: true,
  68110. MULTI: true
  68111. },
  68112. onNavigate: function(event) {},
  68113. selectableEventHooks: {
  68114. add: 'onSelectionStoreAdd',
  68115. remove: 'onSelectionStoreRemove',
  68116. update: 'onSelectionStoreUpdate',
  68117. clear: {
  68118. fn: 'onSelectionStoreClear',
  68119. priority: 1000
  68120. },
  68121. load: 'refreshSelection',
  68122. refresh: 'refreshSelection'
  68123. },
  68124. initSelectable: function() {
  68125. this.publishState('selection', this.getSelection());
  68126. },
  68127. applySelected: function(selected) {
  68128. if (!selected.isCollection) {
  68129. selected = new Ext.util.Collection(selected);
  68130. }
  68131. selected.addObserver(this);
  68132. return selected;
  68133. },
  68134. applyMode: function(mode) {
  68135. mode = mode ? mode.toUpperCase() : 'SINGLE';
  68136. return this.modes[mode] ? mode : 'SINGLE';
  68137. },
  68138. updateStore: function(newStore, oldStore) {
  68139. var me = this,
  68140. bindEvents = Ext.apply({}, me.selectableEventHooks, {
  68141. scope: me
  68142. });
  68143. if (oldStore && Ext.isObject(oldStore) && oldStore.isStore) {
  68144. if (oldStore.autoDestroy) {
  68145. oldStore.destroy();
  68146. } else {
  68147. oldStore.un(bindEvents);
  68148. }
  68149. }
  68150. if (newStore) {
  68151. newStore.on(bindEvents);
  68152. me.refreshSelection();
  68153. }
  68154. },
  68155. selectAll: function(silent) {
  68156. var me = this,
  68157. selections = me.getStore().getRange();
  68158. me.select(selections, true, silent);
  68159. },
  68160. deselectAll: function(supress) {
  68161. var me = this;
  68162. me.deselect(me.getSelected().getRange(), supress);
  68163. me.setLastSelected(null);
  68164. me.setLastFocused(null);
  68165. },
  68166. updateSelection: function(selection) {
  68167. if (this.changingSelection) {
  68168. return;
  68169. }
  68170. if (selection) {
  68171. this.select(selection);
  68172. } else {
  68173. this.deselectAll();
  68174. }
  68175. },
  68176. selectWithEvent: function(record) {
  68177. var me = this,
  68178. isSelected = me.isSelected(record);
  68179. switch (me.getMode()) {
  68180. case 'MULTI':
  68181. case 'SIMPLE':
  68182. if (isSelected) {
  68183. me.deselect(record);
  68184. } else {
  68185. me.select(record, true);
  68186. };
  68187. break;
  68188. case 'SINGLE':
  68189. if (me.getAllowDeselect() && isSelected) {
  68190. me.deselect(record);
  68191. } else {
  68192. me.select(record, false);
  68193. };
  68194. break;
  68195. }
  68196. },
  68197. selectRange: function(startRecord, endRecord, keepExisting) {
  68198. var me = this,
  68199. store = me.getStore(),
  68200. records = [],
  68201. tmp, i;
  68202. if (me.getDisableSelection()) {
  68203. return;
  68204. }
  68205. if (startRecord > endRecord) {
  68206. tmp = endRecord;
  68207. endRecord = startRecord;
  68208. startRecord = tmp;
  68209. }
  68210. for (i = startRecord; i <= endRecord; i++) {
  68211. records.push(store.getAt(i));
  68212. }
  68213. this.doMultiSelect(records, keepExisting);
  68214. },
  68215. select: function(records, keepExisting, suppressEvent) {
  68216. var me = this,
  68217. record;
  68218. if (me.getDisableSelection()) {
  68219. return;
  68220. }
  68221. if (typeof records === "number") {
  68222. records = [
  68223. me.getStore().getAt(records)
  68224. ];
  68225. }
  68226. if (!records) {
  68227. return;
  68228. }
  68229. if (me.getMode() === "SINGLE" && records) {
  68230. record = records.length ? records[0] : records;
  68231. me.doSingleSelect(record, suppressEvent);
  68232. } else {
  68233. me.doMultiSelect(records, keepExisting, suppressEvent);
  68234. }
  68235. },
  68236. doSingleSelect: function(record, suppressEvent) {
  68237. this.doMultiSelect([
  68238. record
  68239. ], false, suppressEvent);
  68240. },
  68241. doMultiSelect: function(records, keepExisting, suppressEvent) {
  68242. if (records === null || this.getDisableSelection()) {
  68243. return;
  68244. }
  68245. records = !Ext.isArray(records) ? [
  68246. records
  68247. ] : records;
  68248. var me = this,
  68249. selected = me.getSelected(),
  68250. selectionCount = selected.getCount(),
  68251. store = me.getStore(),
  68252. toRemove = [],
  68253. record, i, len;
  68254. if (!keepExisting && selectionCount) {
  68255. toRemove = selected.getRange();
  68256. }
  68257. for (i = 0 , len = records.length; i < len; i++) {
  68258. record = records[i];
  68259. if (typeof record === 'number') {
  68260. records[i] = store.getAt(record);
  68261. }
  68262. }
  68263. selected.suppressEvent = suppressEvent;
  68264. selected.splice(selectionCount, toRemove, records);
  68265. selected.suppressEvent = false;
  68266. },
  68267. deselect: function(records, suppressEvent) {
  68268. var me = this,
  68269. selected, store, record, i, len;
  68270. if (me.getDisableSelection()) {
  68271. return;
  68272. }
  68273. records = Ext.isArray(records) ? records : [
  68274. records
  68275. ];
  68276. selected = me.getSelected();
  68277. store = me.getStore();
  68278. for (i = 0 , len = records.length; i < len; i++) {
  68279. record = records[i];
  68280. if (typeof record === 'number') {
  68281. records[i] = store.getAt(record);
  68282. }
  68283. }
  68284. selected.suppressEvent = suppressEvent;
  68285. selected.remove(records);
  68286. selected.suppressEvent = false;
  68287. },
  68288. onCollectionRemove: function(selectedCollection, chunk) {
  68289. var me = this,
  68290. lastSelected = me.getLastSelected(),
  68291. records = chunk.items;
  68292. if (lastSelected && !selectedCollection.contains(lastSelected)) {
  68293. me.setLastSelected(selectedCollection.last());
  68294. }
  68295. me.onItemDeselect(records, selectedCollection.suppressEvent);
  68296. if (!selectedCollection.suppressEvent) {
  68297. me.fireSelectionChange(records);
  68298. }
  68299. },
  68300. onCollectionAdd: function(selectedCollection, adds) {
  68301. var me = this,
  68302. records = adds.items;
  68303. me.setLastSelected(selectedCollection.last());
  68304. me.onItemSelect(records, selectedCollection.suppressEvent);
  68305. if (!selectedCollection.suppressEvent) {
  68306. me.fireSelectionChange(records);
  68307. }
  68308. },
  68309. updateLastFocused: function(newRecord, oldRecord) {
  68310. this.onLastFocusChanged(oldRecord, newRecord);
  68311. },
  68312. fireSelectionChange: function(records) {
  68313. var me = this;
  68314. me.changingSelection = true;
  68315. me.setSelection(me.getLastSelected() || null);
  68316. me.changingSelection = false;
  68317. me.fireAction('selectionchange', [
  68318. me,
  68319. records
  68320. ], 'getSelections');
  68321. },
  68322. getSelections: function() {
  68323. return this.getSelected().getRange();
  68324. },
  68325. isSelected: function(record) {
  68326. record = Ext.isNumber(record) ? this.getStore().getAt(record) : record;
  68327. return this.getSelected().indexOf(record) !== -1;
  68328. },
  68329. hasSelection: function() {
  68330. return this.getSelected().getCount() > 0;
  68331. },
  68332. refreshSelection: function() {
  68333. var me = this,
  68334. selected = me.getSelected(),
  68335. selections = selected.getRange(),
  68336. selectionLength = selections.length,
  68337. storeCollection = me.getStore().getData(),
  68338. toDeselect = [],
  68339. toReselect = [],
  68340. i, rec, matchingSelection;
  68341. if (me.getPruneRemoved()) {
  68342. storeCollection = storeCollection.getSource() || storeCollection;
  68343. for (i = 0; i < selectionLength; i++) {
  68344. rec = selections[i];
  68345. matchingSelection = storeCollection.get(storeCollection.getKey(rec));
  68346. if (matchingSelection) {
  68347. if (matchingSelection !== rec) {
  68348. toDeselect.push(rec);
  68349. toReselect.push(matchingSelection);
  68350. }
  68351. } else {
  68352. toDeselect.push(rec);
  68353. }
  68354. }
  68355. }
  68356. selected.suppressEvent = true;
  68357. selected.splice(selected.getCount(), toDeselect, toReselect);
  68358. selected.suppressEvent = false;
  68359. },
  68360. onSelectionStoreRemove: function(store, records) {
  68361. var me = this,
  68362. selected = me.getSelected(),
  68363. ln = records.length,
  68364. removed, record, i;
  68365. if (me.getDisableSelection()) {
  68366. return;
  68367. }
  68368. for (i = 0; i < ln; i++) {
  68369. record = records[i];
  68370. if (selected.remove(record)) {
  68371. if (me.getLastSelected() == record) {
  68372. me.setLastSelected(null);
  68373. }
  68374. if (me.getLastFocused() == record) {
  68375. me.setLastFocused(null);
  68376. }
  68377. removed = removed || [];
  68378. removed.push(record);
  68379. }
  68380. }
  68381. if (removed) {
  68382. me.fireSelectionChange([
  68383. removed
  68384. ]);
  68385. }
  68386. },
  68387. onSelectionStoreClear: function(store) {
  68388. var records = store.getData().items;
  68389. this.onSelectionStoreRemove(store, records);
  68390. },
  68391. getSelectionCount: function() {
  68392. return this.getSelected().getCount();
  68393. },
  68394. onSelectionStoreAdd: Ext.emptyFn,
  68395. onSelectionStoreUpdate: Ext.emptyFn,
  68396. onItemSelect: Ext.emptyFn,
  68397. onItemDeselect: Ext.emptyFn,
  68398. onLastFocusChanged: Ext.emptyFn,
  68399. onEditorKey: Ext.emptyFn
  68400. }, function() {});
  68401. Ext.define('Ext.mixin.StoreWatcher', {
  68402. mixinId: 'storewatcher',
  68403. config: {
  68404. dataSource: null,
  68405. owner: null,
  68406. ownerListeners: {
  68407. destroyable: true,
  68408. storechange: 'onOwnerStoreChange'
  68409. },
  68410. sourceListeners: null,
  68411. store: null,
  68412. storeListeners: null
  68413. },
  68414. afterClassMixedIn: function(targetClass) {
  68415. var configurator = this.getConfigurator(),
  68416. prototype = targetClass.prototype,
  68417. config = {},
  68418. prop;
  68419. for (prop in configurator.configs) {
  68420. if (prototype.hasOwnProperty(prop)) {
  68421. config[prop] = prototype[prop];
  68422. delete prototype[prop];
  68423. }
  68424. }
  68425. targetClass.addConfig(config);
  68426. },
  68427. onOwnerStoreChange: function(comp, store) {
  68428. this.setStore(store);
  68429. },
  68430. updateDataSource: function(source) {
  68431. this.syncListeners(source, '$sourceListeners', 'getSourceListeners');
  68432. },
  68433. updateOwner: function(owner) {
  68434. var me = this,
  68435. ownerProperty = me.ownerProperty;
  68436. if (ownerProperty) {
  68437. me[ownerProperty] = owner;
  68438. }
  68439. me.syncListeners(owner, '$ownerListeners', 'getOwnerListeners');
  68440. me.setStore(owner ? owner.getStore() : null);
  68441. },
  68442. applyStore: function(store) {
  68443. return (store && !store.isEmptyStore) ? store : null;
  68444. },
  68445. updateStore: function(store) {
  68446. this.syncListeners(store, '$storeListeners', 'getStoreListeners');
  68447. this.syncDataSource();
  68448. },
  68449. privates: {
  68450. syncDataSource: function() {
  68451. var store = this.getStore(),
  68452. source;
  68453. if (!store) {
  68454. source = null;
  68455. } else if (store.getDataSource) {
  68456. source = store.getDataSource();
  68457. } else {
  68458. source = store.getData();
  68459. }
  68460. this.setDataSource(source);
  68461. },
  68462. syncListeners: function(instance, token, listeners) {
  68463. var me = this,
  68464. old = me[token];
  68465. if (old) {
  68466. me[token] = null;
  68467. old.destroy();
  68468. }
  68469. if (instance) {
  68470. listeners = me[listeners]();
  68471. listeners = Ext.applyIf({
  68472. destroyable: true,
  68473. scope: me
  68474. }, listeners);
  68475. me[token] = instance.on(listeners);
  68476. }
  68477. }
  68478. }
  68479. });
  68480. Ext.define('Ext.mixin.StyleCacher', {
  68481. extend: Ext.Mixin,
  68482. mixinConfig: {
  68483. id: 'stylecacher'
  68484. },
  68485. getCachedStyle: function(el, style) {
  68486. var cache = this.$styleCache;
  68487. if (!cache) {
  68488. cache = this.$styleCache = {};
  68489. }
  68490. if (!(style in cache)) {
  68491. cache[style] = Ext.fly(el).getStyle(style);
  68492. }
  68493. return cache[style];
  68494. }
  68495. });
  68496. Ext.define('Ext.perf.Accumulator', function() {
  68497. var currentFrame = null,
  68498. khrome = Ext.global['chrome'],
  68499. formatTpl,
  68500. getTimestamp = function() {
  68501. var interval, toolbox;
  68502. getTimestamp = Ext.now;
  68503. if (Ext.isChrome && khrome && khrome.Interval) {
  68504. interval = new khrome.Interval();
  68505. interval.start();
  68506. getTimestamp = function() {
  68507. return interval.microseconds() / 1000;
  68508. };
  68509. } else if (window.ActiveXObject) {
  68510. try {
  68511. toolbox = new ActiveXObject('SenchaToolbox.Toolbox');
  68512. Ext.senchaToolbox = toolbox;
  68513. getTimestamp = function() {
  68514. return toolbox.milliseconds;
  68515. };
  68516. } catch (e) {}
  68517. }
  68518. Ext.perf.getTimestamp = Ext.perf.Accumulator.getTimestamp = getTimestamp;
  68519. return getTimestamp();
  68520. };
  68521. function adjustSet(set, time) {
  68522. set.sum += time;
  68523. set.min = Math.min(set.min, time);
  68524. set.max = Math.max(set.max, time);
  68525. }
  68526. function leaveFrame(time) {
  68527. var totalTime = time ? time : (getTimestamp() - this.time),
  68528. me = this,
  68529. accum = me.accum;
  68530. ++accum.count;
  68531. if (!--accum.depth) {
  68532. adjustSet(accum.total, totalTime);
  68533. }
  68534. adjustSet(accum.pure, totalTime - me.childTime);
  68535. currentFrame = me.parent;
  68536. if (currentFrame) {
  68537. ++currentFrame.accum.childCount;
  68538. currentFrame.childTime += totalTime;
  68539. }
  68540. }
  68541. function makeSet() {
  68542. return {
  68543. min: Number.MAX_VALUE,
  68544. max: 0,
  68545. sum: 0
  68546. };
  68547. }
  68548. function makeTap(me, fn) {
  68549. return function() {
  68550. var frame = me.enter(),
  68551. ret = fn.apply(this, arguments);
  68552. frame.leave();
  68553. return ret;
  68554. };
  68555. }
  68556. function setToJSON(count, childCount, calibration, set) {
  68557. var data = {
  68558. avg: 0,
  68559. min: set.min,
  68560. max: set.max,
  68561. sum: 0
  68562. };
  68563. if (count) {
  68564. calibration = calibration || 0;
  68565. data.sum = set.sum - childCount * calibration;
  68566. data.avg = data.sum / count;
  68567. }
  68568. return data;
  68569. }
  68570. return {
  68571. constructor: function(name) {
  68572. var me = this;
  68573. me.count = me.childCount = me.depth = me.maxDepth = 0;
  68574. me.pure = makeSet();
  68575. me.total = makeSet();
  68576. me.name = name;
  68577. },
  68578. statics: {
  68579. getTimestamp: getTimestamp
  68580. },
  68581. format: function(calibration) {
  68582. var data;
  68583. if (!formatTpl) {
  68584. formatTpl = new Ext.XTemplate([
  68585. '{name} - {count} call(s)',
  68586. '<tpl if="count">',
  68587. '<tpl if="childCount">',
  68588. ' ({childCount} children)',
  68589. '</tpl>',
  68590. '<tpl if="depth - 1">',
  68591. ' ({depth} deep)',
  68592. '</tpl>',
  68593. '<tpl for="times">',
  68594. ', {type}: {[this.time(values.sum)]} msec (',
  68595. 'avg={[this.time(values.sum / parent.count)]}',
  68596. ')',
  68597. '</tpl>',
  68598. '</tpl>'
  68599. ].join(''), {
  68600. time: function(t) {
  68601. return Math.round(t * 100) / 100;
  68602. }
  68603. });
  68604. }
  68605. data = this.getData(calibration);
  68606. data.name = this.name;
  68607. data.pure.type = 'Pure';
  68608. data.total.type = 'Total';
  68609. data.times = [
  68610. data.pure,
  68611. data.total
  68612. ];
  68613. return formatTpl.apply(data);
  68614. },
  68615. getData: function(calibration) {
  68616. var me = this;
  68617. return {
  68618. count: me.count,
  68619. childCount: me.childCount,
  68620. depth: me.maxDepth,
  68621. pure: setToJSON(me.count, me.childCount, calibration, me.pure),
  68622. total: setToJSON(me.count, me.childCount, calibration, me.total)
  68623. };
  68624. },
  68625. enter: function() {
  68626. var me = this,
  68627. frame = {
  68628. accum: me,
  68629. leave: leaveFrame,
  68630. childTime: 0,
  68631. parent: currentFrame
  68632. };
  68633. ++me.depth;
  68634. if (me.maxDepth < me.depth) {
  68635. me.maxDepth = me.depth;
  68636. }
  68637. currentFrame = frame;
  68638. frame.time = getTimestamp();
  68639. return frame;
  68640. },
  68641. monitor: function(fn, scope, args) {
  68642. var frame = this.enter();
  68643. if (args) {
  68644. fn.apply(scope, args);
  68645. } else {
  68646. fn.call(scope);
  68647. }
  68648. frame.leave();
  68649. },
  68650. report: function() {
  68651. Ext.log(this.format());
  68652. },
  68653. tap: function(className, methodName) {
  68654. var me = this,
  68655. methods = typeof methodName === 'string' ? [
  68656. methodName
  68657. ] : methodName,
  68658. klass, statik, i, parts, length, name, src, tapFunc;
  68659. tapFunc = function() {
  68660. if (typeof className === 'string') {
  68661. klass = Ext.global;
  68662. parts = className.split('.');
  68663. for (i = 0 , length = parts.length; i < length; ++i) {
  68664. klass = klass[parts[i]];
  68665. }
  68666. } else {
  68667. klass = className;
  68668. }
  68669. for (i = 0 , length = methods.length; i < length; ++i) {
  68670. name = methods[i];
  68671. statik = name.charAt(0) === '!';
  68672. if (statik) {
  68673. name = name.substring(1);
  68674. } else {
  68675. statik = !(name in klass.prototype);
  68676. }
  68677. src = statik ? klass : klass.prototype;
  68678. src[name] = makeTap(me, src[name]);
  68679. }
  68680. };
  68681. Ext.ClassManager.onCreated(tapFunc, me, className);
  68682. return me;
  68683. }
  68684. };
  68685. },
  68686. function() {
  68687. Ext.perf.getTimestamp = this.getTimestamp;
  68688. });
  68689. Ext.define('Ext.perf.Monitor', {
  68690. singleton: true,
  68691. alternateClassName: 'Ext.Perf',
  68692. constructor: function() {
  68693. this.accumulators = [];
  68694. this.accumulatorsByName = {};
  68695. },
  68696. calibrate: function() {
  68697. var accum = new Ext.perf.Accumulator('$'),
  68698. total = accum.total,
  68699. getTimestamp = Ext.perf.Accumulator.getTimestamp,
  68700. count = 0,
  68701. frame, endTime, startTime;
  68702. startTime = getTimestamp();
  68703. do {
  68704. frame = accum.enter();
  68705. frame.leave();
  68706. ++count;
  68707. } while (total.sum < 100);
  68708. endTime = getTimestamp();
  68709. return (endTime - startTime) / count;
  68710. },
  68711. get: function(name) {
  68712. var me = this,
  68713. accum = me.accumulatorsByName[name];
  68714. if (!accum) {
  68715. me.accumulatorsByName[name] = accum = new Ext.perf.Accumulator(name);
  68716. me.accumulators.push(accum);
  68717. }
  68718. return accum;
  68719. },
  68720. enter: function(name) {
  68721. return this.get(name).enter();
  68722. },
  68723. monitor: function(name, fn, scope) {
  68724. this.get(name).monitor(fn, scope);
  68725. },
  68726. report: function() {
  68727. var me = this,
  68728. accumulators = me.accumulators,
  68729. calibration = me.calibrate();
  68730. accumulators.sort(function(a, b) {
  68731. return (a.name < b.name) ? -1 : ((b.name < a.name) ? 1 : 0);
  68732. });
  68733. me.updateGC();
  68734. Ext.log('Calibration: ' + Math.round(calibration * 100) / 100 + ' msec/sample');
  68735. Ext.each(accumulators, function(accum) {
  68736. Ext.log(accum.format(calibration));
  68737. });
  68738. },
  68739. getData: function(all) {
  68740. var ret = {},
  68741. accumulators = this.accumulators;
  68742. Ext.each(accumulators, function(accum) {
  68743. if (all || accum.count) {
  68744. ret[accum.name] = accum.getData();
  68745. }
  68746. });
  68747. return ret;
  68748. },
  68749. reset: function() {
  68750. Ext.each(this.accumulators, function(accum) {
  68751. var me = accum;
  68752. me.count = me.childCount = me.depth = me.maxDepth = 0;
  68753. me.pure = {
  68754. min: Number.MAX_VALUE,
  68755. max: 0,
  68756. sum: 0
  68757. };
  68758. me.total = {
  68759. min: Number.MAX_VALUE,
  68760. max: 0,
  68761. sum: 0
  68762. };
  68763. });
  68764. },
  68765. updateGC: function() {
  68766. var accumGC = this.accumulatorsByName.GC,
  68767. toolbox = Ext.senchaToolbox,
  68768. bucket;
  68769. if (accumGC) {
  68770. accumGC.count = toolbox.garbageCollectionCounter || 0;
  68771. if (accumGC.count) {
  68772. bucket = accumGC.pure;
  68773. accumGC.total.sum = bucket.sum = toolbox.garbageCollectionMilliseconds;
  68774. bucket.min = bucket.max = bucket.sum / accumGC.count;
  68775. bucket = accumGC.total;
  68776. bucket.min = bucket.max = bucket.sum / accumGC.count;
  68777. }
  68778. }
  68779. },
  68780. watchGC: function() {
  68781. var toolbox = Ext.senchaToolbox;
  68782. Ext.perf.getTimestamp();
  68783. if (toolbox) {
  68784. this.get("GC");
  68785. toolbox.watchGarbageCollector(false);
  68786. }
  68787. },
  68788. setup: function(config) {
  68789. var key, prop, accum, className, methods;
  68790. if (!config) {
  68791. config = {
  68792. render: {
  68793. 'Ext.Component': 'render'
  68794. },
  68795. layout: {
  68796. 'Ext.layout.Context': 'run'
  68797. }
  68798. };
  68799. }
  68800. this.currentConfig = config;
  68801. for (key in config) {
  68802. if (config.hasOwnProperty(key)) {
  68803. prop = config[key];
  68804. accum = Ext.Perf.get(key);
  68805. for (className in prop) {
  68806. if (prop.hasOwnProperty(className)) {
  68807. methods = prop[className];
  68808. accum.tap(className, methods);
  68809. }
  68810. }
  68811. }
  68812. }
  68813. this.watchGC();
  68814. },
  68815. setupLog: function(config) {
  68816. var className, cls, methods, method, override;
  68817. for (className in config) {
  68818. if (config.hasOwnProperty(className)) {
  68819. cls = Ext.ClassManager.get(className);
  68820. if (cls) {
  68821. methods = config[className];
  68822. override = {};
  68823. for (method in methods) {
  68824. override[method] = (function(methodName, idProp) {
  68825. return function() {
  68826. var before, diff, id, idHolder, ret;
  68827. before = +Date.now();
  68828. ret = this.callParent(arguments);
  68829. diff = +Date.now() - before;
  68830. if (window.console && diff > 0) {
  68831. idHolder = idProp === 'this' ? this : typeof idProp === 'string' ? this[idProp] : typeof idProp === 'number' ? arguments[idProp] : null;
  68832. if (idHolder) {
  68833. id = idHolder.id;
  68834. }
  68835. if (id != null) {
  68836. console.log(methodName + ' for ' + id + ': ' + diff + 'ms');
  68837. } else {
  68838. console.log(methodName + ' for unknown: ' + diff + 'ms');
  68839. }
  68840. if (console.trace) {
  68841. console.trace();
  68842. }
  68843. }
  68844. return ret;
  68845. };
  68846. })(method, methods[method]);
  68847. }
  68848. Ext.override(cls, override);
  68849. }
  68850. }
  68851. }
  68852. }
  68853. });
  68854. Ext.define('Ext.plugin.AbstractClipboard', {
  68855. extend: Ext.plugin.Abstract,
  68856. cachedConfig: {
  68857. formats: {
  68858. text: {
  68859. get: 'getTextData',
  68860. put: 'putTextData'
  68861. }
  68862. }
  68863. },
  68864. config: {
  68865. memory: null,
  68866. source: 'system',
  68867. system: 'text',
  68868. gridListeners: null
  68869. },
  68870. destroy: function() {
  68871. var me = this,
  68872. keyMap = me.keyMap,
  68873. shared = me.shared;
  68874. Ext.destroy(me.destroyListener);
  68875. if (keyMap) {
  68876. me.keyMap = Ext.destroy(keyMap);
  68877. if (!--shared.counter) {
  68878. shared.textArea = Ext.destroy(shared.textArea);
  68879. }
  68880. } else {
  68881. me.renderListener = Ext.destroy(me.renderListener);
  68882. }
  68883. me.callParent();
  68884. },
  68885. init: function(comp) {
  68886. var me = this,
  68887. listeners = me.getGridListeners();
  68888. if (comp.rendered) {
  68889. me.finishInit(comp);
  68890. } else if (listeners) {
  68891. me.renderListener = comp.on(Ext.apply({
  68892. scope: me,
  68893. destroyable: true,
  68894. single: true
  68895. }, listeners));
  68896. }
  68897. },
  68898. onCmpReady: function() {
  68899. this.renderListener = null;
  68900. this.finishInit(this.getCmp());
  68901. },
  68902. getTarget: function(comp) {
  68903. return comp.el;
  68904. },
  68905. privates: {
  68906. shared: {
  68907. counter: 0,
  68908. data: null,
  68909. textArea: null
  68910. },
  68911. applyMemory: function(value) {
  68912. value = this.applySource(value);
  68913. if (value) {
  68914. for (var i = value.length; i-- > 0; ) {
  68915. if (value[i] === 'system') {
  68916. Ext.raise('Invalid clipboard format "' + value[i] + '"');
  68917. }
  68918. }
  68919. }
  68920. return value;
  68921. },
  68922. applySource: function(value) {
  68923. if (value) {
  68924. if (Ext.isString(value)) {
  68925. value = [
  68926. value
  68927. ];
  68928. } else if (value.length === 0) {
  68929. value = null;
  68930. }
  68931. }
  68932. if (value) {
  68933. var formats = this.getFormats(),
  68934. i;
  68935. for (i = value.length; i-- > 0; ) {
  68936. if (value[i] !== 'system' && !formats[value[i]]) {
  68937. Ext.raise('Invalid clipboard format "' + value[i] + '"');
  68938. }
  68939. }
  68940. }
  68941. return value || null;
  68942. },
  68943. applySystem: function(value) {
  68944. var formats = this.getFormats();
  68945. if (!formats[value]) {
  68946. Ext.raise('Invalid clipboard format "' + value + '"');
  68947. }
  68948. return value;
  68949. },
  68950. doCutCopy: function(event, erase) {
  68951. var me = this,
  68952. formats = me.allFormats || me.syncFormats(),
  68953. data = me.getData(erase, formats),
  68954. memory = me.getMemory(),
  68955. system = me.getSystem(),
  68956. sys;
  68957. if (me.validateAction(event) === false) {
  68958. return;
  68959. }
  68960. me.shared.data = memory && data;
  68961. if (system) {
  68962. sys = data[system];
  68963. if (formats[system] < 3) {
  68964. delete data[system];
  68965. }
  68966. me.setClipboardData(sys);
  68967. }
  68968. },
  68969. doPaste: function(format, data) {
  68970. var formats = this.getFormats();
  68971. this[formats[format].put](data, format);
  68972. },
  68973. finishInit: function(comp) {
  68974. var me = this;
  68975. me.keyMap = new Ext.util.KeyMap({
  68976. target: me.getTarget(comp),
  68977. ignoreInputFields: true,
  68978. binding: [
  68979. {
  68980. ctrl: true,
  68981. key: 'x',
  68982. fn: me.onCut,
  68983. scope: me
  68984. },
  68985. {
  68986. ctrl: true,
  68987. key: 'c',
  68988. fn: me.onCopy,
  68989. scope: me
  68990. },
  68991. {
  68992. ctrl: true,
  68993. key: 'v',
  68994. fn: me.onPaste,
  68995. scope: me
  68996. }
  68997. ]
  68998. });
  68999. ++me.shared.counter;
  69000. me.destroyListener = comp.on({
  69001. destroyable: true,
  69002. destroy: 'destroy',
  69003. scope: me
  69004. });
  69005. },
  69006. getData: function(erase, format) {
  69007. var me = this,
  69008. formats = me.getFormats(),
  69009. data, i, name, names;
  69010. if (Ext.isString(format)) {
  69011. if (!formats[format]) {
  69012. Ext.raise('Invalid clipboard format "' + format + '"');
  69013. }
  69014. data = me[formats[format].get](format, erase);
  69015. } else {
  69016. data = {};
  69017. names = [];
  69018. if (format) {
  69019. for (name in format) {
  69020. if (!formats[name]) {
  69021. Ext.raise('Invalid clipboard format "' + name + '"');
  69022. }
  69023. names.push(name);
  69024. }
  69025. } else {
  69026. names = Ext.Object.getAllKeys(formats);
  69027. }
  69028. for (i = names.length; i-- > 0; ) {
  69029. data[name] = me[formats[name].get](name, erase && !i);
  69030. }
  69031. }
  69032. return data;
  69033. },
  69034. getHiddenTextArea: function() {
  69035. var shared = this.shared,
  69036. el;
  69037. el = shared.textArea;
  69038. if (!el) {
  69039. el = shared.textArea = Ext.getBody().createChild({
  69040. tag: 'textarea',
  69041. tabIndex: -1,
  69042. style: {
  69043. position: 'absolute',
  69044. top: '-1000px',
  69045. width: '1px',
  69046. height: '1px'
  69047. }
  69048. });
  69049. el.suspendFocusEvents();
  69050. }
  69051. return el;
  69052. },
  69053. onCopy: function(keyCode, event) {
  69054. this.doCutCopy(event, false);
  69055. },
  69056. onCut: function(keyCode, event) {
  69057. this.doCutCopy(event, true);
  69058. },
  69059. onPaste: function(keyCode, event) {
  69060. var me = this,
  69061. sharedData = me.shared.data,
  69062. source = me.getSource(),
  69063. i, n, s;
  69064. if (me.validateAction(event) === false) {
  69065. return;
  69066. }
  69067. if (source) {
  69068. for (i = 0 , n = source.length; i < n; ++i) {
  69069. s = source[i];
  69070. if (s === 'system') {
  69071. s = me.getSystem();
  69072. me.pasteClipboardData(s);
  69073. break;
  69074. } else if (sharedData && (s in sharedData)) {
  69075. me.doPaste(s, sharedData[s]);
  69076. break;
  69077. }
  69078. }
  69079. }
  69080. },
  69081. pasteClipboardData: function(format) {
  69082. var me = this,
  69083. clippy = window.clipboardData,
  69084. area, focusEl;
  69085. if (clippy && clippy.getData) {
  69086. me.doPaste(format, clippy.getData("text"));
  69087. } else {
  69088. focusEl = Ext.Element.getActiveElement(true);
  69089. area = me.getHiddenTextArea().dom;
  69090. area.value = '';
  69091. if (focusEl) {
  69092. focusEl.suspendFocusEvents();
  69093. }
  69094. area.focus();
  69095. Ext.defer(function() {
  69096. if (focusEl) {
  69097. focusEl.focus();
  69098. focusEl.resumeFocusEvents();
  69099. }
  69100. me.doPaste(format, area.value);
  69101. area.value = '';
  69102. }, 100, me);
  69103. }
  69104. },
  69105. setClipboardData: function(data) {
  69106. var me = this,
  69107. clippy = window.clipboardData,
  69108. area, focusEl;
  69109. if (clippy && clippy.setData) {
  69110. clippy.setData("text", data);
  69111. } else {
  69112. area = me.getHiddenTextArea().dom;
  69113. focusEl = Ext.Element.getActiveElement(true);
  69114. area.value = data;
  69115. if (focusEl) {
  69116. focusEl.suspendFocusEvents();
  69117. }
  69118. area.focus();
  69119. area.select();
  69120. Ext.defer(function() {
  69121. area.value = '';
  69122. if (focusEl) {
  69123. focusEl.focus();
  69124. focusEl.resumeFocusEvents();
  69125. }
  69126. }, 50);
  69127. }
  69128. },
  69129. syncFormats: function() {
  69130. var me = this,
  69131. map = {},
  69132. memory = me.getMemory(),
  69133. system = me.getSystem(),
  69134. i, s;
  69135. if (system) {
  69136. map[system] = 1;
  69137. }
  69138. if (memory) {
  69139. for (i = memory.length; i-- > 0; ) {
  69140. s = memory[i];
  69141. map[s] = map[s] ? 3 : 2;
  69142. }
  69143. }
  69144. return me.allFormats = map;
  69145. },
  69146. updateMemory: function() {
  69147. this.allFormats = null;
  69148. },
  69149. updateSystem: function() {
  69150. this.allFormats = null;
  69151. },
  69152. validateAction: Ext.privateFn
  69153. }
  69154. });
  69155. Ext.define('Ext.plugin.MouseEnter', {
  69156. extend: Ext.plugin.Abstract,
  69157. alias: 'plugin.mouseenter',
  69158. element: 'el',
  69159. init: function(component) {
  69160. if (!this.delegate) {
  69161. Ext.raise('mouseenter plugin must be configured with a delegate selector');
  69162. }
  69163. if (!this.handler) {
  69164. Ext.raise('mouseenter plugin must be configured with handler callback');
  69165. }
  69166. var me = this,
  69167. listeners = {
  69168. mouseover: 'onMouseEvent',
  69169. scope: me,
  69170. destroyable: true
  69171. },
  69172. element = me.element;
  69173. if (me.leaveHandler || me.delay) {
  69174. listeners.mouseout = 'onMouseEvent';
  69175. }
  69176. if (typeof element === 'string') {
  69177. element = component[me.element];
  69178. }
  69179. if (element) {
  69180. me.mouseListener = Ext.get(element).on(listeners);
  69181. } else
  69182. {
  69183. component.on({
  69184. render: function() {
  69185. me.mouseListener = component[me.element].on(listeners);
  69186. },
  69187. single: true
  69188. });
  69189. }
  69190. },
  69191. onMouseEvent: function(e) {
  69192. var me = this,
  69193. delegate = e.getTarget(me.delegate);
  69194. if (delegate && delegate !== e.getRelatedTarget(me.delegate)) {
  69195. if (me.delay) {
  69196. Ext.undefer(me.mouseEventTimer);
  69197. me.mouseEventTimer = Ext.defer(me.handleMouseEvent, me.delay, me, [
  69198. e,
  69199. delegate
  69200. ]);
  69201. } else {
  69202. me.handleMouseEvent(e, delegate);
  69203. }
  69204. }
  69205. },
  69206. handleMouseEvent: function(e, delegate) {
  69207. var me = this;
  69208. if (e.type === 'mouseover') {
  69209. Ext.callback(me.handler, null, [
  69210. e,
  69211. delegate
  69212. ], 0, me.cmp, me.scope);
  69213. } else if (me.leaveHandler) {
  69214. Ext.callback(me.leaveHandler, null, [
  69215. e,
  69216. delegate
  69217. ], 0, me.cmp, me.scope);
  69218. }
  69219. },
  69220. destroy: function() {
  69221. Ext.destroy(this.mouseListener);
  69222. this.callParent();
  69223. }
  69224. });
  69225. Ext.define('Ext.sparkline.Shape', {
  69226. constructor: function(target, id, type, args) {
  69227. var me = this;
  69228. me.target = target;
  69229. me.id = id;
  69230. me.type = type;
  69231. me.args = args;
  69232. },
  69233. append: function() {
  69234. this.target.appendShape(this);
  69235. return this;
  69236. }
  69237. });
  69238. Ext.define('Ext.sparkline.CanvasBase', {
  69239. shapeCount: 0,
  69240. _pxregex: /(\d+)(px)?\s*$/i,
  69241. constructor: function(ownerSparkLine) {
  69242. this.owner = ownerSparkLine;
  69243. this.rtl = this.owner.getInherited().rtl;
  69244. },
  69245. setWidth: function(width) {
  69246. this.pixelWidth = width;
  69247. },
  69248. setHeight: function(height) {
  69249. this.pixelHeight = height;
  69250. },
  69251. drawLine: function(x1, y1, x2, y2, lineColor, lineWidth) {
  69252. return this.drawShape([
  69253. [
  69254. x1,
  69255. y1
  69256. ],
  69257. [
  69258. x2,
  69259. y2
  69260. ]
  69261. ], lineColor, lineWidth);
  69262. },
  69263. drawShape: function(path, lineColor, fillColor, lineWidth) {
  69264. return this._genShape('Shape', [
  69265. path,
  69266. lineColor,
  69267. fillColor,
  69268. lineWidth
  69269. ]);
  69270. },
  69271. drawCircle: function(x, y, radius, lineColor, fillColor, lineWidth) {
  69272. return this._genShape('Circle', [
  69273. x,
  69274. y,
  69275. radius,
  69276. lineColor,
  69277. fillColor,
  69278. lineWidth
  69279. ]);
  69280. },
  69281. drawPieSlice: function(x, y, radius, startAngle, endAngle, lineColor, fillColor) {
  69282. return this._genShape('PieSlice', [
  69283. x,
  69284. y,
  69285. radius,
  69286. startAngle,
  69287. endAngle,
  69288. lineColor,
  69289. fillColor
  69290. ]);
  69291. },
  69292. drawRect: function(x, y, width, height, lineColor, fillColor) {
  69293. return this._genShape('Rect', [
  69294. x,
  69295. y,
  69296. width,
  69297. height,
  69298. lineColor,
  69299. fillColor
  69300. ]);
  69301. },
  69302. getElement: function() {
  69303. return this.el;
  69304. },
  69305. getLastShapeId: function() {
  69306. return this.lastShapeId;
  69307. },
  69308. reset: function() {
  69309. Ext.raise('reset not implemented');
  69310. },
  69311. _genShape: function(shapetype, shapeargs) {
  69312. var id = this.shapeCount++;
  69313. shapeargs.unshift(id);
  69314. return new Ext.sparkline.Shape(this, id, shapetype, shapeargs);
  69315. },
  69316. appendShape: function(shape) {
  69317. Ext.raise('appendShape not implemented');
  69318. },
  69319. replaceWithShape: function(shapeid, shape) {
  69320. Ext.raise('replaceWithShape not implemented');
  69321. },
  69322. insertAfterShape: function(shapeid, shape) {
  69323. Ext.raise('insertAfterShape not implemented');
  69324. },
  69325. removeShapeId: function(shapeid) {
  69326. Ext.raise('removeShapeId not implemented');
  69327. },
  69328. getShapeAt: function(x, y) {
  69329. Ext.raise('getShapeAt not implemented');
  69330. },
  69331. render: function() {
  69332. Ext.raise('render not implemented');
  69333. }
  69334. });
  69335. Ext.define('Ext.sparkline.CanvasCanvas', {
  69336. extend: Ext.sparkline.CanvasBase,
  69337. statics: {
  69338. contextOverrides: (function() {
  69339. var ratio = window.devicePixelRatio || 1;
  69340. return {
  69341. moveTo: function(x, y) {
  69342. if (this.rtl) {
  69343. x = this.canvas.width - x - 1;
  69344. }
  69345. this.$moveTo(x * ratio, y * ratio);
  69346. },
  69347. lineTo: function(x, y) {
  69348. if (this.rtl) {
  69349. x = this.canvas.width - x - 1;
  69350. }
  69351. this.$lineTo(x * ratio, y * ratio);
  69352. },
  69353. arc: function(x, y, radius, startAngle, endAngle, counterclockwise) {
  69354. if (this.rtl) {
  69355. x = this.canvas.width - x - 1;
  69356. }
  69357. this.$arc(x * ratio, y * ratio, radius * ratio, startAngle, endAngle, counterclockwise);
  69358. },
  69359. clearRect: function(x, y, width, height) {
  69360. if (this.rtl) {
  69361. x = this.canvas.width - x - width;
  69362. }
  69363. this.$clearRect(x * ratio, y * ratio, width * ratio, height * ratio);
  69364. }
  69365. };
  69366. })()
  69367. },
  69368. setWidth: function(width) {
  69369. this.callParent(arguments);
  69370. this.owner.element.dom.width = width * (window.devicePixelRatio || 1);
  69371. },
  69372. setHeight: function(height) {
  69373. this.callParent(arguments);
  69374. this.owner.element.dom.height = height * (window.devicePixelRatio || 1);
  69375. },
  69376. onOwnerUpdate: function() {
  69377. var me = this;
  69378. me.el = me.owner.element;
  69379. me.interact = !me.owner.initialConfig.disableInteraction;
  69380. me.shapes = {};
  69381. me.shapeseq = [];
  69382. me.currentTargetShapeId = me.lastShapeId = null;
  69383. },
  69384. _getContext: function(lineColor, fillColor, lineWidth) {
  69385. var context = this.context,
  69386. overrides, name;
  69387. if (!context) {
  69388. this.context = context = this.el.dom.getContext('2d');
  69389. overrides = Ext.sparkline.CanvasCanvas.contextOverrides;
  69390. for (name in overrides) {
  69391. context['$' + name] = context[name];
  69392. }
  69393. Ext.apply(context, overrides);
  69394. context.rtl = this.rtl;
  69395. }
  69396. if (lineColor != null) {
  69397. context.strokeStyle = lineColor;
  69398. }
  69399. context.lineWidth = lineWidth || 1;
  69400. if (fillColor != null) {
  69401. context.fillStyle = fillColor;
  69402. }
  69403. return context;
  69404. },
  69405. reset: function() {
  69406. var context = this._getContext();
  69407. context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
  69408. this.shapes = {};
  69409. this.shapeseq = [];
  69410. this.currentTargetShapeId = this.lastShapeId = null;
  69411. },
  69412. _drawShape: function(shapeid, path, lineColor, fillColor, lineWidth) {
  69413. var context = this._getContext(lineColor, fillColor, lineWidth),
  69414. xIncr = this.rtl ? -0.5 : 0.5,
  69415. i, plen;
  69416. context.beginPath();
  69417. context.moveTo(path[0][0] + xIncr, path[0][1] + 0.5);
  69418. for (i = 1 , plen = path.length; i < plen; i++) {
  69419. context.lineTo(path[i][0] + xIncr, path[i][1] + 0.5);
  69420. }
  69421. if (lineColor != null) {
  69422. context.stroke();
  69423. }
  69424. if (fillColor != null) {
  69425. context.fill();
  69426. }
  69427. if (this.targetX != null && this.targetY != null && context.isPointInPath(this.targetX, this.targetY)) {
  69428. this.currentTargetShapeId = shapeid;
  69429. }
  69430. },
  69431. _drawCircle: function(shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
  69432. var context = this._getContext(lineColor, fillColor, lineWidth);
  69433. context.beginPath();
  69434. context.arc(x, y, radius, 0, 2 * Math.PI, false);
  69435. if (this.targetX != null && this.targetY != null && context.isPointInPath(this.targetX, this.targetY)) {
  69436. this.currentTargetShapeId = shapeid;
  69437. }
  69438. if (lineColor != null) {
  69439. context.stroke();
  69440. }
  69441. if (fillColor != null) {
  69442. context.fill();
  69443. }
  69444. },
  69445. _drawPieSlice: function(shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
  69446. var context = this._getContext(lineColor, fillColor);
  69447. context.beginPath();
  69448. context.moveTo(x, y);
  69449. context.arc(x, y, radius, startAngle, endAngle, false);
  69450. context.lineTo(x, y);
  69451. context.closePath();
  69452. if (lineColor != null) {
  69453. context.stroke();
  69454. }
  69455. if (fillColor) {
  69456. context.fill();
  69457. }
  69458. if (this.targetX !== undefined && this.targetY !== undefined && context.isPointInPath(this.targetX, this.targetY)) {
  69459. this.currentTargetShapeId = shapeid;
  69460. }
  69461. },
  69462. _drawRect: function(shapeid, x, y, width, height, lineColor, fillColor) {
  69463. return this._drawShape(shapeid, [
  69464. [
  69465. x,
  69466. y
  69467. ],
  69468. [
  69469. x + width,
  69470. y
  69471. ],
  69472. [
  69473. x + width,
  69474. y + height
  69475. ],
  69476. [
  69477. x,
  69478. y + height
  69479. ],
  69480. [
  69481. x,
  69482. y
  69483. ]
  69484. ], lineColor, fillColor);
  69485. },
  69486. appendShape: function(shape) {
  69487. this.shapes[shape.id] = shape;
  69488. this.shapeseq.push(shape.id);
  69489. this.lastShapeId = shape.id;
  69490. return shape.id;
  69491. },
  69492. replaceWithShape: function(shapeid, shape) {
  69493. var shapeseq = this.shapeseq,
  69494. i;
  69495. this.shapes[shape.id] = shape;
  69496. for (i = shapeseq.length; i--; ) {
  69497. if (shapeseq[i] === shapeid) {
  69498. shapeseq[i] = shape.id;
  69499. }
  69500. }
  69501. delete this.shapes[shapeid];
  69502. },
  69503. replaceWithShapes: function(shapeids, shapes) {
  69504. var shapeseq = this.shapeseq,
  69505. shapemap = {},
  69506. sid, i, first;
  69507. for (i = shapeids.length; i--; ) {
  69508. shapemap[shapeids[i]] = true;
  69509. }
  69510. for (i = shapeseq.length; i--; ) {
  69511. sid = shapeseq[i];
  69512. if (shapemap[sid]) {
  69513. shapeseq.splice(i, 1);
  69514. delete this.shapes[sid];
  69515. first = i;
  69516. }
  69517. }
  69518. for (i = shapes.length; i--; ) {
  69519. shapeseq.splice(first, 0, shapes[i].id);
  69520. this.shapes[shapes[i].id] = shapes[i];
  69521. }
  69522. },
  69523. insertAfterShape: function(shapeid, shape) {
  69524. var shapeseq = this.shapeseq,
  69525. i;
  69526. for (i = shapeseq.length; i--; ) {
  69527. if (shapeseq[i] === shapeid) {
  69528. shapeseq.splice(i + 1, 0, shape.id);
  69529. this.shapes[shape.id] = shape;
  69530. return;
  69531. }
  69532. }
  69533. },
  69534. removeShapeId: function(shapeid) {
  69535. var shapeseq = this.shapeseq,
  69536. i;
  69537. for (i = shapeseq.length; i--; ) {
  69538. if (shapeseq[i] === shapeid) {
  69539. shapeseq.splice(i, 1);
  69540. break;
  69541. }
  69542. }
  69543. delete this.shapes[shapeid];
  69544. },
  69545. getShapeAt: function(x, y) {
  69546. if (this.rtl) {
  69547. x = this.el.dom.width - x - 1;
  69548. }
  69549. this.targetX = x;
  69550. this.targetY = y;
  69551. this.render();
  69552. return this.currentTargetShapeId;
  69553. },
  69554. render: function() {
  69555. var shapeseq = this.shapeseq,
  69556. shapes = this.shapes,
  69557. shapeCount = shapeseq.length,
  69558. context = this._getContext(),
  69559. shapeid, shape, i;
  69560. context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
  69561. for (i = 0; i < shapeCount; i++) {
  69562. shapeid = shapeseq[i];
  69563. shape = shapes[shapeid];
  69564. this['_draw' + shape.type].apply(this, shape.args);
  69565. }
  69566. if (!this.interact) {
  69567. this.shapes = {};
  69568. this.shapeseq = [];
  69569. }
  69570. }
  69571. });
  69572. Ext.define('Ext.sparkline.VmlCanvas', {
  69573. extend: Ext.sparkline.CanvasBase,
  69574. setWidth: function(width) {
  69575. var me = this;
  69576. me.callParent(arguments);
  69577. me.owner.groupEl.dom.coordsize = me.width + ' ' + (me.height || 0);
  69578. me.owner.groupEl.dom.style.width = width + 'px';
  69579. },
  69580. setHeight: function(height) {
  69581. var me = this;
  69582. me.callParent(arguments);
  69583. me.owner.groupEl.dom.coordsize = (me.width || 0) + ' ' + me.height;
  69584. me.owner.groupEl.dom.style.height = height + 'px';
  69585. },
  69586. onOwnerUpdate: function() {
  69587. var me = this;
  69588. me.group = me.owner.groupEl;
  69589. me.el = me.owner.element;
  69590. me.prerender = [];
  69591. },
  69592. _drawShape: function(shapeid, path, lineColor, fillColor, lineWidth) {
  69593. var vpath = [],
  69594. initial, stroke, fill, closed, plen, i;
  69595. for (i = 0 , plen = path.length; i < plen; i++) {
  69596. vpath[i] = (path[i][0]) + ',' + (path[i][1]);
  69597. }
  69598. initial = vpath.splice(0, 1);
  69599. lineWidth = lineWidth == null ? 1 : lineWidth;
  69600. stroke = lineColor == null ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
  69601. fill = fillColor == null ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
  69602. closed = vpath[0] === vpath[vpath.length - 1] ? 'x ' : '';
  69603. return [
  69604. '<svml:shape coordorigin="0 0" coordsize="',
  69605. this.pixelWidth,
  69606. ' ',
  69607. this.pixelHeight,
  69608. '" id="jqsshape',
  69609. shapeid,
  69610. '" ',
  69611. stroke,
  69612. fill,
  69613. ' style="position:absolute;height:',
  69614. this.pixelHeight,
  69615. 'px;width:',
  69616. this.pixelWidth,
  69617. 'px" ',
  69618. ' path="m ',
  69619. initial,
  69620. ' l ',
  69621. vpath.join(', '),
  69622. ' ',
  69623. closed,
  69624. 'e"></svml:shape>'
  69625. ].join('');
  69626. },
  69627. _drawCircle: function(shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
  69628. var circumference = radius * 2,
  69629. stroke, fill;
  69630. x -= radius;
  69631. y -= radius;
  69632. stroke = lineColor == null ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
  69633. fill = fillColor == null ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
  69634. return [
  69635. '<svml:oval id="jqsshape',
  69636. shapeid,
  69637. '" ',
  69638. stroke,
  69639. fill,
  69640. ' style="position:absolute;top:',
  69641. y,
  69642. 'px; left:',
  69643. x,
  69644. 'px;width:',
  69645. circumference,
  69646. 'px;height:',
  69647. circumference,
  69648. 'px"></svml:oval>'
  69649. ].join('');
  69650. },
  69651. _drawPieSlice: function(shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
  69652. var vpath,
  69653. width = this.pixelWidth,
  69654. height = this.pixelHeight,
  69655. startx, starty, endx, endy, stroke, fill;
  69656. stroke = lineColor == null ? ' stroked="false" ' : ' strokeWeight="1px" strokeColor="' + lineColor + '" ';
  69657. fill = fillColor == null ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
  69658. if (startAngle === endAngle) {
  69659. return '';
  69660. }
  69661. if ((endAngle - startAngle) === (2 * Math.PI)) {
  69662. startAngle = 0;
  69663. endAngle = (2 * Math.PI);
  69664. }
  69665. startx = x + Math.round(Math.cos(startAngle) * radius);
  69666. starty = y + Math.round(Math.sin(startAngle) * radius);
  69667. endx = x + Math.round(Math.cos(endAngle) * radius);
  69668. endy = y + Math.round(Math.sin(endAngle) * radius);
  69669. if (startx === endx && starty === endy) {
  69670. if ((endAngle - startAngle) < Math.PI) {
  69671. return '';
  69672. }
  69673. startx = endx = x + radius;
  69674. starty = endy = y;
  69675. }
  69676. if (startx === endx && starty === endy && (endAngle - startAngle) < Math.PI) {
  69677. return '';
  69678. }
  69679. vpath = [
  69680. x - radius,
  69681. y - radius,
  69682. x + radius,
  69683. y + radius,
  69684. startx,
  69685. starty,
  69686. endx,
  69687. endy
  69688. ];
  69689. return [
  69690. '<svml:shape coordorigin="0 0" coordsize="',
  69691. width,
  69692. ' ',
  69693. height,
  69694. '" id="jqsshape',
  69695. shapeid,
  69696. '" ',
  69697. stroke,
  69698. fill,
  69699. ' style="position:absolute;height:',
  69700. height,
  69701. 'px;width:',
  69702. width,
  69703. 'px" path="m ',
  69704. x,
  69705. ',',
  69706. y,
  69707. ' wa ',
  69708. vpath.join(', '),
  69709. ' x e"></svml:shape>'
  69710. ].join('');
  69711. },
  69712. _drawRect: function(shapeid, x, y, width, height, lineColor, fillColor) {
  69713. return this._drawShape(shapeid, [
  69714. [
  69715. x,
  69716. y
  69717. ],
  69718. [
  69719. x,
  69720. y + height
  69721. ],
  69722. [
  69723. x + width,
  69724. y + height
  69725. ],
  69726. [
  69727. x + width,
  69728. y
  69729. ],
  69730. [
  69731. x,
  69732. y
  69733. ]
  69734. ], lineColor, fillColor);
  69735. },
  69736. reset: function() {
  69737. Ext.fly(this.group).empty();
  69738. },
  69739. appendShape: function(shape) {
  69740. this.prerender.push(this['_draw' + shape.type].apply(this, shape.args));
  69741. this.lastShapeId = shape.id;
  69742. return shape.id;
  69743. },
  69744. replaceWithShape: function(shapeid, shape) {
  69745. var existing = this.el.getById('jqsshape' + shapeid, true),
  69746. vel = this['_draw' + shape.type].apply(this, shape.args);
  69747. existing.outerHTML = vel;
  69748. },
  69749. replaceWithShapes: function(shapeids, shapes) {
  69750. var existing = this.el.getById('jqsshape' + shapeids[0], true),
  69751. replace = '',
  69752. slen = shapes.length,
  69753. i;
  69754. for (i = 0; i < slen; i++) {
  69755. replace += this['_draw' + shapes[i].type].apply(this, shapes[i].args);
  69756. }
  69757. existing.outerHTML = replace;
  69758. for (i = 1; i < shapeids.length; i++) {
  69759. this.el.getById('jqsshape' + shapeids[i]).destroy();
  69760. }
  69761. },
  69762. insertAfterShape: function(shapeid, shape) {
  69763. var existing = this.el.getById('jqsshape' + shapeid, true),
  69764. vel = this['_draw' + shape.type].apply(this, shape.args);
  69765. existing.insertAdjacentHTML('afterEnd', vel);
  69766. },
  69767. removeShapeId: function(shapeid) {
  69768. var existing = this.el.getById('jqsshape' + shapeid, true);
  69769. this.group.removeChild(existing);
  69770. },
  69771. getShapeAt: function(x, y) {
  69772. var shapeid = this.el.id.substr(8);
  69773. return shapeid;
  69774. },
  69775. render: function() {
  69776. this.group.dom.innerHTML = this.prerender.join('');
  69777. }
  69778. }, function() {
  69779. Ext.onInternalReady(function() {
  69780. var doc = document;
  69781. if (doc.namespaces && !doc.namespaces.svml) {
  69782. doc.namespaces.add("svml", "urn:schemas-microsoft-com:vml", '#default#VML');
  69783. }
  69784. });
  69785. });
  69786. Ext.define('Ext.util.Color', {
  69787. alternateClassName: 'Ext.draw.Color',
  69788. statics: {
  69789. colorToHexRe: /(.*?)rgb\((\d+),\s*(\d+),\s*(\d+)\)/,
  69790. rgbToHexRe: /\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/,
  69791. rgbaToHexRe: /\s*rgba\((\d+),\s*(\d+),\s*(\d+),\s*([.\d]+)\)/,
  69792. hexRe: /\s*#([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)\s*/,
  69793. NONE: 'none',
  69794. RGBA_NONE: 'rgba(0, 0, 0, 0)'
  69795. },
  69796. isColor: true,
  69797. lightnessFactor: 0.2,
  69798. constructor: function(red, green, blue, alpha) {
  69799. this.setRGB(red, green, blue, alpha);
  69800. },
  69801. clone: function() {
  69802. var me = this;
  69803. return new this.self(me.r, me.g, me.b, me.a);
  69804. },
  69805. setRGB: function(red, green, blue, alpha) {
  69806. var me = this;
  69807. me.r = Math.min(255, Math.max(0, red));
  69808. me.g = Math.min(255, Math.max(0, green));
  69809. me.b = Math.min(255, Math.max(0, blue));
  69810. if (alpha === undefined) {
  69811. me.a = 1;
  69812. } else {
  69813. me.a = Math.min(1, Math.max(0, alpha));
  69814. }
  69815. },
  69816. getBrightness: function() {
  69817. var r = this.r / 255 * 100,
  69818. g = this.g / 255 * 100,
  69819. b = this.b / 255 * 100;
  69820. return ((r * 299) + (g * 587) + (b * 114)) / 1000;
  69821. },
  69822. getGrayscale: function() {
  69823. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  69824. },
  69825. getHSL: function() {
  69826. var me = this,
  69827. r = me.r / 255,
  69828. g = me.g / 255,
  69829. b = me.b / 255,
  69830. max = Math.max(r, g, b),
  69831. min = Math.min(r, g, b),
  69832. delta = max - min,
  69833. h,
  69834. s = 0,
  69835. l = 0.5 * (max + min);
  69836. if (min !== max) {
  69837. s = (l <= 0.5) ? delta / (max + min) : delta / (2 - max - min);
  69838. if (r === max) {
  69839. h = 60 * (g - b) / delta;
  69840. } else if (g === max) {
  69841. h = 120 + 60 * (b - r) / delta;
  69842. } else {
  69843. h = 240 + 60 * (r - g) / delta;
  69844. }
  69845. if (h < 0) {
  69846. h += 360;
  69847. }
  69848. if (h >= 360) {
  69849. h -= 360;
  69850. }
  69851. }
  69852. return [
  69853. h,
  69854. s,
  69855. l
  69856. ];
  69857. },
  69858. getHSV: function() {
  69859. var me = this,
  69860. r = me.r / 255,
  69861. g = me.g / 255,
  69862. b = me.b / 255,
  69863. max = Math.max(r, g, b),
  69864. min = Math.min(r, g, b),
  69865. C = max - min,
  69866. h,
  69867. s = 0,
  69868. v = max;
  69869. if (min != max) {
  69870. s = v ? C / v : 0;
  69871. if (r === max) {
  69872. h = 60 * (g - b) / C;
  69873. } else if (g === max) {
  69874. h = 60 * (b - r) / C + 120;
  69875. } else {
  69876. h = 60 * (r - g) / C + 240;
  69877. }
  69878. if (h < 0) {
  69879. h += 360;
  69880. }
  69881. if (h >= 360) {
  69882. h -= 360;
  69883. }
  69884. }
  69885. return [
  69886. h,
  69887. s,
  69888. v
  69889. ];
  69890. },
  69891. setHSL: function(h, s, l) {
  69892. var me = this,
  69893. abs = Math.abs,
  69894. c, x, m;
  69895. h = (h % 360 + 360) % 360;
  69896. s = s > 1 ? 1 : s < 0 ? 0 : s;
  69897. l = l > 1 ? 1 : l < 0 ? 0 : l;
  69898. if (s === 0 || h === null) {
  69899. l *= 255;
  69900. me.setRGB(l, l, l);
  69901. } else {
  69902. h /= 60;
  69903. c = s * (1 - abs(2 * l - 1));
  69904. x = c * (1 - abs(h % 2 - 1));
  69905. m = l - c / 2;
  69906. m *= 255;
  69907. c *= 255;
  69908. x *= 255;
  69909. switch (Math.floor(h)) {
  69910. case 0:
  69911. me.setRGB(c + m, x + m, m);
  69912. break;
  69913. case 1:
  69914. me.setRGB(x + m, c + m, m);
  69915. break;
  69916. case 2:
  69917. me.setRGB(m, c + m, x + m);
  69918. break;
  69919. case 3:
  69920. me.setRGB(m, x + m, c + m);
  69921. break;
  69922. case 4:
  69923. me.setRGB(x + m, m, c + m);
  69924. break;
  69925. case 5:
  69926. me.setRGB(c + m, m, x + m);
  69927. break;
  69928. }
  69929. }
  69930. return me;
  69931. },
  69932. setHSV: function(h, s, v) {
  69933. var me = this,
  69934. c, x, m;
  69935. h = (h % 360 + 360) % 360;
  69936. s = s > 1 ? 1 : s < 0 ? 0 : s;
  69937. v = v > 1 ? 1 : v < 0 ? 0 : v;
  69938. if (s === 0 || h === null) {
  69939. v *= 255;
  69940. me.setRGB(v, v, v);
  69941. } else {
  69942. h /= 60;
  69943. c = v * s;
  69944. x = c * (1 - Math.abs(h % 2 - 1));
  69945. m = v - c;
  69946. m *= 255;
  69947. c *= 255;
  69948. x *= 255;
  69949. switch (Math.floor(h)) {
  69950. case 0:
  69951. me.setRGB(c + m, x + m, m);
  69952. break;
  69953. case 1:
  69954. me.setRGB(x + m, c + m, m);
  69955. break;
  69956. case 2:
  69957. me.setRGB(m, c + m, x + m);
  69958. break;
  69959. case 3:
  69960. me.setRGB(m, x + m, c + m);
  69961. break;
  69962. case 4:
  69963. me.setRGB(x + m, m, c + m);
  69964. break;
  69965. case 5:
  69966. me.setRGB(c + m, m, x + m);
  69967. break;
  69968. }
  69969. }
  69970. return me;
  69971. },
  69972. createLighter: function(factor) {
  69973. var color = this.clone();
  69974. color.lighten(factor);
  69975. return color;
  69976. },
  69977. lighten: function(factor) {
  69978. var hsl;
  69979. if (!factor && factor !== 0) {
  69980. factor = this.lightnessFactor;
  69981. }
  69982. hsl = this.getHSL();
  69983. this.setHSL(hsl[0], hsl[1], Ext.Number.constrain(hsl[2] + factor, 0, 1));
  69984. },
  69985. createDarker: function(factor) {
  69986. var color = this.clone();
  69987. color.darken(factor);
  69988. return color;
  69989. },
  69990. darken: function(factor) {
  69991. if (!factor && factor !== 0) {
  69992. factor = this.lightnessFactor;
  69993. }
  69994. return this.lighten(-factor);
  69995. },
  69996. toString: function() {
  69997. var me = this,
  69998. round = Math.round,
  69999. r, g, b;
  70000. if (me.a === 1) {
  70001. r = round(me.r).toString(16);
  70002. g = round(me.g).toString(16);
  70003. b = round(me.b).toString(16);
  70004. r = (r.length === 1) ? '0' + r : r;
  70005. g = (g.length === 1) ? '0' + g : g;
  70006. b = (b.length === 1) ? '0' + b : b;
  70007. return [
  70008. '#',
  70009. r,
  70010. g,
  70011. b
  70012. ].join('');
  70013. } else {
  70014. return 'rgba(' + [
  70015. round(me.r),
  70016. round(me.g),
  70017. round(me.b),
  70018. me.a === 0 ? 0 : me.a.toFixed(15)
  70019. ].join(', ') + ')';
  70020. }
  70021. },
  70022. toHex: function(color) {
  70023. var r = this.r,
  70024. g = this.g,
  70025. b = this.b,
  70026. rgb = b | (g << 8) | (r << 16);
  70027. return '#' + ('000000' + rgb.toString(16)).slice(-6);
  70028. },
  70029. setFromString: function(str) {
  70030. var values, r, g, b,
  70031. a = 1,
  70032. parse = parseInt;
  70033. if (str === Ext.util.Color.NONE) {
  70034. this.r = this.g = this.b = this.a = 0;
  70035. return this;
  70036. }
  70037. if ((str.length === 4 || str.length === 7) && str.substr(0, 1) === '#') {
  70038. values = str.match(Ext.util.Color.hexRe);
  70039. if (values) {
  70040. r = parse(values[1], 16) >> 0;
  70041. g = parse(values[2], 16) >> 0;
  70042. b = parse(values[3], 16) >> 0;
  70043. if (str.length === 4) {
  70044. r += (r * 16);
  70045. g += (g * 16);
  70046. b += (b * 16);
  70047. }
  70048. }
  70049. } else if ((values = str.match(Ext.util.Color.rgbToHexRe))) {
  70050. r = +values[1];
  70051. g = +values[2];
  70052. b = +values[3];
  70053. } else if ((values = str.match(Ext.util.Color.rgbaToHexRe))) {
  70054. r = +values[1];
  70055. g = +values[2];
  70056. b = +values[3];
  70057. a = +values[4];
  70058. } else {
  70059. if (Ext.util.Color.ColorList.hasOwnProperty(str.toLowerCase())) {
  70060. return this.setFromString(Ext.util.Color.ColorList[str.toLowerCase()]);
  70061. }
  70062. }
  70063. if (typeof r === 'undefined') {
  70064. return this;
  70065. }
  70066. this.r = r;
  70067. this.g = g;
  70068. this.b = b;
  70069. this.a = a;
  70070. return this;
  70071. }
  70072. }, function() {
  70073. var flyColor = new this();
  70074. this.addStatics({
  70075. fly: function(red, green, blue, alpha) {
  70076. switch (arguments.length) {
  70077. case 1:
  70078. flyColor.setFromString(red);
  70079. break;
  70080. case 3:
  70081. case 4:
  70082. flyColor.setRGB(red, green, blue, alpha);
  70083. break;
  70084. default:
  70085. return null;
  70086. }
  70087. return flyColor;
  70088. },
  70089. ColorList: {
  70090. aliceblue: '#f0f8ff',
  70091. antiquewhite: '#faebd7',
  70092. aqua: '#00ffff',
  70093. aquamarine: '#7fffd4',
  70094. azure: '#f0ffff',
  70095. beige: '#f5f5dc',
  70096. bisque: '#ffe4c4',
  70097. black: '#000000',
  70098. blanchedalmond: '#ffebcd',
  70099. blue: '#0000ff',
  70100. blueviolet: '#8a2be2',
  70101. brown: '#a52a2a',
  70102. burlywood: '#deb887',
  70103. cadetblue: '#5f9ea0',
  70104. chartreuse: '#7fff00',
  70105. chocolate: '#d2691e',
  70106. coral: '#ff7f50',
  70107. cornflowerblue: '#6495ed',
  70108. cornsilk: '#fff8dc',
  70109. crimson: '#dc143c',
  70110. cyan: '#00ffff',
  70111. darkblue: '#00008b',
  70112. darkcyan: '#008b8b',
  70113. darkgoldenrod: '#b8860b',
  70114. darkgray: '#a9a9a9',
  70115. darkgreen: '#006400',
  70116. darkkhaki: '#bdb76b',
  70117. darkmagenta: '#8b008b',
  70118. darkolivegreen: '#556b2f',
  70119. darkorange: '#ff8c00',
  70120. darkorchid: '#9932cc',
  70121. darkred: '#8b0000',
  70122. darksalmon: '#e9967a',
  70123. darkseagreen: '#8fbc8f',
  70124. darkslateblue: '#483d8b',
  70125. darkslategray: '#2f4f4f',
  70126. darkturquoise: '#00ced1',
  70127. darkviolet: '#9400d3',
  70128. deeppink: '#ff1493',
  70129. deepskyblue: '#00bfff',
  70130. dimgray: '#696969',
  70131. dodgerblue: '#1e90ff',
  70132. firebrick: '#b22222',
  70133. floralwhite: '#fffaf0',
  70134. forestgreen: '#228b22',
  70135. fuchsia: '#ff00ff',
  70136. gainsboro: '#dcdcdc',
  70137. ghostwhite: '#f8f8ff',
  70138. gold: '#ffd700',
  70139. goldenrod: '#daa520',
  70140. gray: '#808080',
  70141. green: '#008000',
  70142. greenyellow: '#adff2f',
  70143. honeydew: '#f0fff0',
  70144. hotpink: '#ff69b4',
  70145. indianred: '#cd5c5c',
  70146. indigo: '#4b0082',
  70147. ivory: '#fffff0',
  70148. khaki: '#f0e68c',
  70149. lavender: '#e6e6fa',
  70150. lavenderblush: '#fff0f5',
  70151. lawngreen: '#7cfc00',
  70152. lemonchiffon: '#fffacd',
  70153. lightblue: '#add8e6',
  70154. lightcoral: '#f08080',
  70155. lightcyan: '#e0ffff',
  70156. lightgoldenrodyellow: '#fafad2',
  70157. lightgray: '#d3d3d3',
  70158. lightgrey: '#d3d3d3',
  70159. lightgreen: '#90ee90',
  70160. lightpink: '#ffb6c1',
  70161. lightsalmon: '#ffa07a',
  70162. lightseagreen: '#20b2aa',
  70163. lightskyblue: '#87cefa',
  70164. lightslategray: '#778899',
  70165. lightsteelblue: '#b0c4de',
  70166. lightyellow: '#ffffe0',
  70167. lime: '#00ff00',
  70168. limegreen: '#32cd32',
  70169. linen: '#faf0e6',
  70170. magenta: '#ff00ff',
  70171. maroon: '#800000',
  70172. mediumaquamarine: '#66cdaa',
  70173. mediumblue: '#0000cd',
  70174. mediumorchid: '#ba55d3',
  70175. mediumpurple: '#9370d8',
  70176. mediumseagreen: '#3cb371',
  70177. mediumslateblue: '#7b68ee',
  70178. mediumspringgreen: '#00fa9a',
  70179. mediumturquoise: '#48d1cc',
  70180. mediumvioletred: '#c71585',
  70181. midnightblue: '#191970',
  70182. mintcream: '#f5fffa',
  70183. mistyrose: '#ffe4e1',
  70184. moccasin: '#ffe4b5',
  70185. navajowhite: '#ffdead',
  70186. navy: '#000080',
  70187. oldlace: '#fdf5e6',
  70188. olive: '#808000',
  70189. olivedrab: '#6b8e23',
  70190. orange: '#ffa500',
  70191. orangered: '#ff4500',
  70192. orchid: '#da70d6',
  70193. palegoldenrod: '#eee8aa',
  70194. palegreen: '#98fb98',
  70195. paleturquoise: '#afeeee',
  70196. palevioletred: '#d87093',
  70197. papayawhip: '#ffefd5',
  70198. peachpuff: '#ffdab9',
  70199. peru: '#cd853f',
  70200. pink: '#ffc0cb',
  70201. plum: '#dda0dd',
  70202. powderblue: '#b0e0e6',
  70203. purple: '#800080',
  70204. red: '#ff0000',
  70205. rosybrown: '#bc8f8f',
  70206. royalblue: '#4169e1',
  70207. saddlebrown: '#8b4513',
  70208. salmon: '#fa8072',
  70209. sandybrown: '#f4a460',
  70210. seagreen: '#2e8b57',
  70211. seashell: '#fff5ee',
  70212. sienna: '#a0522d',
  70213. silver: '#c0c0c0',
  70214. skyblue: '#87ceeb',
  70215. slateblue: '#6a5acd',
  70216. slategray: '#708090',
  70217. snow: '#fffafa',
  70218. springgreen: '#00ff7f',
  70219. steelblue: '#4682b4',
  70220. tan: '#d2b48c',
  70221. teal: '#008080',
  70222. thistle: '#d8bfd8',
  70223. tomato: '#ff6347',
  70224. turquoise: '#40e0d0',
  70225. violet: '#ee82ee',
  70226. wheat: '#f5deb3',
  70227. white: '#ffffff',
  70228. whitesmoke: '#f5f5f5',
  70229. yellow: '#ffff00',
  70230. yellowgreen: '#9acd32'
  70231. },
  70232. fromHSL: function(h, s, l) {
  70233. return (new this(0, 0, 0, 0)).setHSL(h, s, l);
  70234. },
  70235. fromHSV: function(h, s, v) {
  70236. return (new this(0, 0, 0, 0)).setHSL(h, s, v);
  70237. },
  70238. fromString: function(color) {
  70239. return (new this(0, 0, 0, 0)).setFromString(color);
  70240. },
  70241. create: function(arg) {
  70242. if (arg instanceof this) {
  70243. return arg;
  70244. } else if (Ext.isArray(arg)) {
  70245. return new Ext.util.Color(arg[0], arg[1], arg[2], arg[3]);
  70246. } else if (Ext.isString(arg)) {
  70247. return Ext.util.Color.fromString(arg);
  70248. } else if (arguments.length > 2) {
  70249. return new Ext.util.Color(arguments[0], arguments[1], arguments[2], arguments[3]);
  70250. } else {
  70251. return new Ext.util.Color(0, 0, 0, 0);
  70252. }
  70253. }
  70254. });
  70255. });
  70256. Ext.define('Ext.sparkline.Base', {
  70257. extend: Ext.Gadget,
  70258. xtype: 'sparkline',
  70259. cachedConfig: {
  70260. lineColor: '#157fcc',
  70261. defaultPixelsPerValue: 3,
  70262. tagValuesAttribute: 'values',
  70263. enableTagOptions: false,
  70264. enableHighlight: true,
  70265. highlightColor: null,
  70266. highlightLighten: 0.1,
  70267. tooltipSkipNull: true,
  70268. tooltipPrefix: '',
  70269. tooltipSuffix: '',
  70270. disableTooltips: false,
  70271. disableInteraction: false,
  70272. tipTpl: null
  70273. },
  70274. config: {
  70275. values: null
  70276. },
  70277. baseCls: Ext.baseCSSPrefix + 'sparkline',
  70278. element: {
  70279. tag: 'canvas',
  70280. reference: 'element',
  70281. style: {
  70282. display: 'inline-block',
  70283. verticalAlign: 'top'
  70284. },
  70285. listeners: {
  70286. mouseenter: 'onMouseEnter',
  70287. mouseleave: 'onMouseLeave',
  70288. mousemove: 'onMouseMove'
  70289. },
  70290. width: 0,
  70291. height: 0
  70292. },
  70293. defaultBindProperty: 'values',
  70294. redrawQueue: {},
  70295. inheritableStatics: {
  70296. onClassCreated: function(cls) {
  70297. var configUpdater = cls.prototype.updateConfigChange,
  70298. proto = cls.prototype,
  70299. configs = cls.getConfigurator().configs,
  70300. config, updaterName;
  70301. for (config in configs) {
  70302. if (config !== 'tipTpl') {
  70303. updaterName = Ext.Config.get(config).names.update;
  70304. if (proto[updaterName]) {
  70305. proto[updaterName] = Ext.Function.createSequence(proto[updaterName], configUpdater);
  70306. } else {
  70307. proto[updaterName] = configUpdater;
  70308. }
  70309. }
  70310. }
  70311. }
  70312. },
  70313. constructor: function(config) {
  70314. var me = this,
  70315. ns = Ext.sparkline;
  70316. me.canvas = Ext.supports.Canvas ? new ns.CanvasCanvas(me) : new ns.VmlCanvas(me);
  70317. me.callParent([
  70318. config
  70319. ]);
  70320. },
  70321. all: function(val, arr, ignoreNull) {
  70322. var i;
  70323. for (i = arr.length; i--; ) {
  70324. if (ignoreNull && arr[i] === null) {
  70325. continue;
  70326. }
  70327. if (arr[i] !== val) {
  70328. return false;
  70329. }
  70330. }
  70331. return true;
  70332. },
  70333. updateConfigChange: function(newValue) {
  70334. var me = this;
  70335. if (me.bufferRedraw || !me.height || !me.width) {
  70336. me.redrawQueue[me.getId()] = me;
  70337. if (!me.redrawTimer) {
  70338. Ext.sparkline.Base.prototype.redrawTimer = Ext.raf(me.processRedrawQueue);
  70339. }
  70340. } else {
  70341. me.redraw();
  70342. }
  70343. return newValue;
  70344. },
  70345. applyTipTpl: function(tipTpl) {
  70346. if (tipTpl && !tipTpl.isTemplate) {
  70347. tipTpl = new Ext.XTemplate(tipTpl);
  70348. }
  70349. return tipTpl;
  70350. },
  70351. normalizeValue: function(val) {
  70352. var nf;
  70353. switch (val) {
  70354. case 'undefined':
  70355. val = undefined;
  70356. break;
  70357. case 'null':
  70358. val = null;
  70359. break;
  70360. case 'true':
  70361. val = true;
  70362. break;
  70363. case 'false':
  70364. val = false;
  70365. break;
  70366. default:
  70367. nf = parseFloat(val);
  70368. if (val == nf) {
  70369. val = nf;
  70370. };
  70371. }
  70372. return val;
  70373. },
  70374. normalizeValues: function(vals) {
  70375. var i,
  70376. result = [];
  70377. for (i = vals.length; i--; ) {
  70378. result[i] = this.normalizeValue(vals[i]);
  70379. }
  70380. return result;
  70381. },
  70382. updateWidth: function(width, oldWidth) {
  70383. var me = this,
  70384. dom = me.element.dom,
  70385. measurer = me.measurer;
  70386. me.callParent([
  70387. width,
  70388. oldWidth
  70389. ]);
  70390. me.canvas.setWidth(width);
  70391. me.width = width;
  70392. if (me.height == null && measurer) {
  70393. me.setHeight(parseInt(measurer.getCachedStyle(dom.parentNode, 'line-height'), 10));
  70394. }
  70395. },
  70396. updateHeight: function(height, oldHeight) {
  70397. var me = this;
  70398. me.callParent([
  70399. height,
  70400. oldHeight
  70401. ]);
  70402. me.canvas.setHeight(height);
  70403. me.height = height;
  70404. },
  70405. setValues: function(values) {
  70406. var me = this,
  70407. oldValues = me.getValues();
  70408. values = values == null ? [] : Ext.Array.from(values);
  70409. me.values = values;
  70410. me.callParent([
  70411. values
  70412. ]);
  70413. if (values === oldValues) {
  70414. me.updateValues([
  70415. values,
  70416. oldValues
  70417. ]);
  70418. }
  70419. },
  70420. redraw: function() {
  70421. var me = this;
  70422. if (!me.destroyed) {
  70423. me.canvas.onOwnerUpdate();
  70424. me.canvas.reset();
  70425. if (me.getValues()) {
  70426. me.onUpdate();
  70427. me.renderGraph();
  70428. }
  70429. }
  70430. },
  70431. onUpdate: Ext.emptyFn,
  70432. renderGraph: function() {
  70433. var ret = true;
  70434. if (this.disabled) {
  70435. this.canvas.reset();
  70436. ret = false;
  70437. }
  70438. return ret;
  70439. },
  70440. onMouseEnter: function(e) {
  70441. this.onMouseMove(e);
  70442. },
  70443. onMouseMove: function(e) {
  70444. var me = this;
  70445. me.canvasRegion = me.canvasRegion || me.canvas.el.getRegion();
  70446. me.currentPageXY = e.getPoint();
  70447. me.redraw();
  70448. },
  70449. onMouseLeave: function() {
  70450. var me = this;
  70451. me.canvasRegion = me.currentPageXY = me.targetX = me.targetY = null;
  70452. me.redraw();
  70453. me.hideTip();
  70454. },
  70455. updateDisplay: function() {
  70456. var me = this,
  70457. values = me.getValues(),
  70458. tipHtml, region;
  70459. if (values && values.length && me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  70460. region = me.getRegion(me.currentPageXY[0] - me.canvasRegion.left, (me.canvasRegion.bottom - 1) - me.currentPageXY[1]);
  70461. if (region != null && me.isValidRegion(region, values)) {
  70462. if (!me.disableHighlight) {
  70463. me.renderHighlight(region);
  70464. }
  70465. if (!me.getDisableTooltips()) {
  70466. tipHtml = me.getRegionTooltip(region);
  70467. }
  70468. }
  70469. if (me.hasListeners.sparklineregionchange) {
  70470. me.fireEvent('sparklineregionchange', me);
  70471. }
  70472. if (tipHtml) {
  70473. me.getSharedTooltip().setHtml(tipHtml);
  70474. me.showTip();
  70475. }
  70476. }
  70477. if (!tipHtml) {
  70478. me.hideTip();
  70479. }
  70480. },
  70481. getRegion: Ext.emptyFn,
  70482. getRegionTooltip: function(region) {
  70483. var me = this,
  70484. entries = [],
  70485. tipTpl = me.getTipTpl(),
  70486. fields, showFields, showFieldsKey, newFields, fv, formatter, fieldlen, i, j;
  70487. fields = me.getRegionFields(region);
  70488. formatter = me.tooltipFormatter;
  70489. if (formatter) {
  70490. return formatter(me, me, fields);
  70491. }
  70492. if (!tipTpl) {
  70493. return '';
  70494. }
  70495. if (!Ext.isArray(fields)) {
  70496. fields = [
  70497. fields
  70498. ];
  70499. }
  70500. showFields = me.tooltipFormatFieldlist;
  70501. showFieldsKey = me.tooltipFormatFieldlistKey;
  70502. if (showFields && showFieldsKey) {
  70503. newFields = [];
  70504. for (i = fields.length; i--; ) {
  70505. fv = fields[i][showFieldsKey];
  70506. if ((j = Ext.Array.indexOf(fv, showFields)) !== -1) {
  70507. newFields[j] = fields[i];
  70508. }
  70509. }
  70510. fields = newFields;
  70511. }
  70512. fieldlen = fields.length;
  70513. for (j = 0; j < fieldlen; j++) {
  70514. if (!fields[j].isNull || !me.getTooltipSkipNull()) {
  70515. Ext.apply(fields[j], {
  70516. prefix: me.getTooltipPrefix(),
  70517. suffix: me.getTooltipSuffix()
  70518. });
  70519. entries.push(tipTpl.apply(fields[j]));
  70520. }
  70521. }
  70522. if (entries.length) {
  70523. return entries.join('<br>');
  70524. }
  70525. return '';
  70526. },
  70527. getRegionFields: Ext.emptyFn,
  70528. calcHighlightColor: function(color) {
  70529. var me = this,
  70530. highlightColor = me.getHighlightColor(),
  70531. lighten = me.getHighlightLighten(),
  70532. o;
  70533. if (highlightColor) {
  70534. return highlightColor;
  70535. }
  70536. if (lighten) {
  70537. o = Ext.util.Color.fromString(color);
  70538. if (o) {
  70539. o.lighten(lighten);
  70540. color = o.toHex();
  70541. }
  70542. }
  70543. return color;
  70544. },
  70545. destroy: function() {
  70546. delete this.redrawQueue[this.getId()];
  70547. this.callParent();
  70548. },
  70549. privates: {
  70550. hideTip: Ext.privateFn,
  70551. isValidRegion: function(region, values) {
  70552. return region < values.length;
  70553. },
  70554. showTip: Ext.privateFn
  70555. }
  70556. }, function(SparklineBase) {
  70557. var proto = SparklineBase.prototype;
  70558. proto.getSharedTooltip = function() {
  70559. var me = this,
  70560. tooltip = me.tooltip;
  70561. if (!tooltip) {
  70562. proto.tooltip = tooltip = SparklineBase.constructTip();
  70563. }
  70564. return tooltip;
  70565. };
  70566. SparklineBase.onClassCreated(SparklineBase);
  70567. proto.processRedrawQueue = function() {
  70568. var redrawQueue = proto.redrawQueue,
  70569. id;
  70570. for (id in redrawQueue) {
  70571. redrawQueue[id].redraw();
  70572. }
  70573. proto.redrawQueue = {};
  70574. proto.redrawTimer = 0;
  70575. };
  70576. });
  70577. Ext.define('Ext.sparkline.BarBase', {
  70578. extend: Ext.sparkline.Base,
  70579. renderHighlight: function(region) {
  70580. this.renderRegion(region, true);
  70581. },
  70582. renderGraph: function() {
  70583. var me = this,
  70584. values = me.values,
  70585. canvas = me.canvas,
  70586. regionShapes = me.regionShapes || (me.regionShapes = {}),
  70587. shapes, ids, i, j;
  70588. if (!me.callParent()) {
  70589. return;
  70590. }
  70591. for (i = values.length; i--; ) {
  70592. shapes = me.renderRegion(i);
  70593. if (shapes) {
  70594. if (Ext.isArray(shapes)) {
  70595. ids = [];
  70596. for (j = shapes.length; j--; ) {
  70597. shapes[j].append();
  70598. ids.push(shapes[j].id);
  70599. }
  70600. regionShapes[i] = ids;
  70601. } else {
  70602. shapes.append();
  70603. regionShapes[i] = shapes.id;
  70604. }
  70605. } else
  70606. {
  70607. regionShapes[i] = null;
  70608. }
  70609. }
  70610. if (me.currentPageXY) {
  70611. me.currentRegion = null;
  70612. me.updateDisplay();
  70613. }
  70614. canvas.render();
  70615. }
  70616. });
  70617. Ext.define('Ext.sparkline.RangeMap', {
  70618. constructor: function(map) {
  70619. var key, range,
  70620. rangelist = [];
  70621. for (key in map) {
  70622. if (map.hasOwnProperty(key) && typeof key === 'string' && key.indexOf(':') > -1) {
  70623. range = key.split(':');
  70624. range[0] = range[0].length === 0 ? -Infinity : parseFloat(range[0]);
  70625. range[1] = range[1].length === 0 ? Infinity : parseFloat(range[1]);
  70626. range[2] = map[key];
  70627. rangelist.push(range);
  70628. }
  70629. }
  70630. this.map = map;
  70631. this.rangelist = rangelist || false;
  70632. },
  70633. get: function(value) {
  70634. var rangelist = this.rangelist,
  70635. i, range, result;
  70636. if ((result = this.map[value]) !== undefined) {
  70637. return result;
  70638. }
  70639. if (rangelist) {
  70640. for (i = rangelist.length; i--; ) {
  70641. range = rangelist[i];
  70642. if (range[0] <= value && range[1] >= value) {
  70643. return range[2];
  70644. }
  70645. }
  70646. }
  70647. }
  70648. });
  70649. Ext.define('Ext.sparkline.Bar', {
  70650. extend: Ext.sparkline.BarBase,
  70651. alias: 'widget.sparklinebar',
  70652. config: {
  70653. barColor: '#3366cc',
  70654. negBarColor: '#f44',
  70655. stackedBarColor: [
  70656. '#3366cc',
  70657. '#dc3912',
  70658. '#ff9900',
  70659. '#109618',
  70660. '#66aa00',
  70661. '#dd4477',
  70662. '#0099c6',
  70663. '#990099'
  70664. ],
  70665. zeroColor: null,
  70666. nullColor: null,
  70667. zeroAxis: true,
  70668. barWidth: 4,
  70669. barSpacing: 1,
  70670. chartRangeMin: null,
  70671. chartRangeMax: null,
  70672. chartRangeClip: false,
  70673. colorMap: null
  70674. },
  70675. tipTpl: '&#9679; {prefix}{value}{suffix}',
  70676. remove: function(vals, filter) {
  70677. var result = [],
  70678. i, vl;
  70679. for (i = 0 , vl = vals.length; i < vl; i++) {
  70680. if (vals[i] !== filter) {
  70681. result.push(vals[i]);
  70682. }
  70683. }
  70684. return result;
  70685. },
  70686. all: function(arr, val, ignoreNull) {
  70687. var i;
  70688. for (i = arr.length; i--; ) {
  70689. if (ignoreNull && arr[i] === null) {
  70690. continue;
  70691. }
  70692. if (arr[i] !== val) {
  70693. return false;
  70694. }
  70695. }
  70696. return true;
  70697. },
  70698. applyColorMap: function(colorMap) {
  70699. var me = this;
  70700. if (Ext.isArray(colorMap)) {
  70701. me.colorMapByIndex = colorMap;
  70702. me.colorMapByValue = null;
  70703. } else {
  70704. me.colorMapByIndex = null;
  70705. me.colorMapByValue = colorMap;
  70706. if (me.colorMapByValue && me.colorMapByValue.get == null) {
  70707. me.colorMapByValue = new Ext.sparkline.RangeMap(colorMap);
  70708. }
  70709. }
  70710. me.updateConfigChange();
  70711. return colorMap;
  70712. },
  70713. onUpdate: function() {
  70714. var me = this,
  70715. values = me.values,
  70716. barWidth = me.getBarWidth(),
  70717. barSpacing = me.getBarSpacing(),
  70718. chartRangeMin = me.getChartRangeMin(),
  70719. chartRangeMax = me.getChartRangeMax(),
  70720. chartRangeClip = me.getChartRangeClip(),
  70721. stackMin = Infinity,
  70722. stackMax = -Infinity,
  70723. zeroAxis = me.getZeroAxis(),
  70724. stackTotals = [],
  70725. stackRangesNeg = [],
  70726. isStackString, groupMin, groupMax, stackRanges, numValues, i, vlen, range, xAxisOffset, min, max, clipMin, clipMax, stacked, vlist, j, slen, svals, val, yoffset, yMaxCalc;
  70727. for (i = 0 , vlen = values.length; i < vlen; i++) {
  70728. val = values[i];
  70729. isStackString = typeof (val) === 'string' && val.indexOf(':') > -1;
  70730. if (isStackString || Ext.isArray(val)) {
  70731. stacked = true;
  70732. if (isStackString) {
  70733. val = values[i] = me.normalizeValues(val.split(':'));
  70734. }
  70735. val = me.remove(val, null);
  70736. groupMin = Math.min.apply(Math, val);
  70737. groupMax = Math.max.apply(Math, val);
  70738. if (groupMin < stackMin) {
  70739. stackMin = groupMin;
  70740. }
  70741. if (groupMax > stackMax) {
  70742. stackMax = groupMax;
  70743. }
  70744. }
  70745. }
  70746. me.stacked = stacked;
  70747. me.regionShapes = {};
  70748. me.totalBarWidth = barWidth + barSpacing;
  70749. if (values.length) {
  70750. me.width = (values.length * barWidth) + ((values.length - 1) * barSpacing);
  70751. }
  70752. if (chartRangeClip) {
  70753. clipMin = chartRangeMin == null ? -Infinity : chartRangeMin;
  70754. clipMax = chartRangeMax == null ? Infinity : chartRangeMax;
  70755. }
  70756. numValues = [];
  70757. stackRanges = stacked ? [] : numValues;
  70758. for (i = 0 , vlen = values.length; i < vlen; i++) {
  70759. if (stacked) {
  70760. vlist = values[i];
  70761. values[i] = svals = [];
  70762. stackTotals[i] = 0;
  70763. stackRanges[i] = stackRangesNeg[i] = 0;
  70764. for (j = 0 , slen = vlist.length; j < slen; j++) {
  70765. val = svals[j] = chartRangeClip ? Ext.Number.constrain(vlist[j], clipMin, clipMax) : vlist[j];
  70766. if (val !== null) {
  70767. if (val > 0) {
  70768. stackTotals[i] += val;
  70769. }
  70770. if (stackMin < 0 && stackMax > 0) {
  70771. if (val < 0) {
  70772. stackRangesNeg[i] += Math.abs(val);
  70773. } else {
  70774. stackRanges[i] += val;
  70775. }
  70776. } else {
  70777. stackRanges[i] += Math.abs(val - (val < 0 ? stackMax : stackMin));
  70778. }
  70779. numValues.push(val);
  70780. }
  70781. }
  70782. } else {
  70783. val = chartRangeClip ? Ext.Number.constrain(values[i], clipMin, clipMax) : values[i];
  70784. val = values[i] = me.normalizeValue(val);
  70785. if (val !== null) {
  70786. numValues.push(val);
  70787. }
  70788. }
  70789. }
  70790. me.max = max = Math.max.apply(Math, numValues);
  70791. me.min = min = Math.min.apply(Math, numValues);
  70792. me.stackMax = stackMax = stacked ? Math.max.apply(Math, stackTotals) : max;
  70793. me.stackMin = stackMin = stacked ? Math.min.apply(Math, numValues) : min;
  70794. if (chartRangeMin != null && (chartRangeClip || chartRangeMin < min)) {
  70795. min = chartRangeMin;
  70796. }
  70797. if (chartRangeMax != null && (chartRangeClip || chartRangeMax > max)) {
  70798. max = chartRangeMax;
  70799. }
  70800. if (min <= 0 && max >= 0 && zeroAxis) {
  70801. xAxisOffset = 0;
  70802. } else if (!zeroAxis) {
  70803. xAxisOffset = min;
  70804. } else if (min > 0) {
  70805. xAxisOffset = min;
  70806. } else {
  70807. xAxisOffset = max;
  70808. }
  70809. me.xAxisOffset = xAxisOffset;
  70810. range = stacked ? (Math.max.apply(Math, stackRanges) + Math.max.apply(Math, stackRangesNeg)) : max - min;
  70811. me.canvasHeightEf = (zeroAxis && min < 0) ? me.getHeight() - 2 : me.getHeight() - 1;
  70812. if (min < xAxisOffset) {
  70813. yMaxCalc = (stacked && max >= 0) ? stackMax : max;
  70814. yoffset = (yMaxCalc - xAxisOffset) / range * me.getHeight();
  70815. if (yoffset !== Math.ceil(yoffset)) {
  70816. me.canvasHeightEf -= 2;
  70817. yoffset = Math.ceil(yoffset);
  70818. }
  70819. } else {
  70820. yoffset = me.getHeight();
  70821. }
  70822. me.yoffset = yoffset;
  70823. me.range = range;
  70824. },
  70825. getRegion: function(x, y) {
  70826. var result = Math.floor(x / this.totalBarWidth);
  70827. return (result < 0 || result >= this.values.length) ? undefined : result;
  70828. },
  70829. getRegionFields: function(region) {
  70830. var values = Ext.Array.from(this.values[region]),
  70831. result = [],
  70832. value, i;
  70833. for (i = values.length; i--; ) {
  70834. value = values[i];
  70835. result.push({
  70836. isNull: value === null,
  70837. value: value,
  70838. color: this.calcColor(i, value, region),
  70839. offset: region
  70840. });
  70841. }
  70842. return result;
  70843. },
  70844. calcColor: function(stacknum, value, valuenum) {
  70845. var me = this,
  70846. colorMapByIndex = me.colorMapByIndex,
  70847. colorMapByValue = me.colorMapByValue,
  70848. color, newColor,
  70849. zeroColor = me.getZeroColor();
  70850. if (this.stacked) {
  70851. color = me.getStackedBarColor();
  70852. } else {
  70853. color = (value < 0) ? me.getNegBarColor() : me.getBarColor();
  70854. }
  70855. if (value === 0 && zeroColor != null) {
  70856. color = zeroColor;
  70857. }
  70858. if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
  70859. color = newColor;
  70860. } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
  70861. color = colorMapByIndex[valuenum];
  70862. }
  70863. return Ext.isArray(color) ? color[stacknum % color.length] : color;
  70864. },
  70865. renderRegion: function(valuenum, highlight) {
  70866. var me = this,
  70867. vals = me.values[valuenum],
  70868. xaxisOffset = me.xAxisOffset,
  70869. range = me.range,
  70870. stacked = me.stacked,
  70871. canvas = me.canvas,
  70872. barWidth = me.getBarWidth(),
  70873. x = valuenum * me.totalBarWidth,
  70874. canvasHeightEf = me.canvasHeightEf,
  70875. yoffset = me.yoffset,
  70876. y, height, color, isNull, yoffsetNeg, i, valcount, val, minPlotted, allMin,
  70877. nullColor = me.getNullColor();
  70878. vals = Ext.isArray(vals) ? vals : [
  70879. vals
  70880. ];
  70881. valcount = vals.length;
  70882. val = vals[0];
  70883. isNull = me.all(vals, null);
  70884. allMin = me.all(vals, xaxisOffset, true);
  70885. if (isNull) {
  70886. if (nullColor) {
  70887. color = highlight ? nullColor : me.calcHighlightColor(nullColor, me);
  70888. y = (yoffset > 0) ? yoffset - 1 : yoffset;
  70889. canvas.drawRect(x, y, barWidth - 1, 0, color, color).append();
  70890. }
  70891. return;
  70892. }
  70893. yoffsetNeg = yoffset;
  70894. for (i = 0; i < valcount; i++) {
  70895. val = vals[i];
  70896. if (stacked && val === xaxisOffset) {
  70897. if (!allMin || minPlotted) {
  70898. continue;
  70899. }
  70900. minPlotted = true;
  70901. }
  70902. if (range > 0) {
  70903. height = Math.floor(canvasHeightEf * ((Math.abs(val - xaxisOffset) / range))) + 1;
  70904. } else {
  70905. height = 1;
  70906. }
  70907. if (val < xaxisOffset || (val === xaxisOffset && yoffset === 0)) {
  70908. y = yoffsetNeg;
  70909. yoffsetNeg += height;
  70910. } else {
  70911. y = yoffset - height;
  70912. yoffset -= height;
  70913. }
  70914. color = me.calcColor(i, val, valuenum);
  70915. if (highlight) {
  70916. color = me.calcHighlightColor(color, me);
  70917. }
  70918. canvas.drawRect(x, y, barWidth - 1, height - 1, color, color).append();
  70919. }
  70920. }
  70921. }, function(cls) {
  70922. cls.onClassCreated(cls);
  70923. });
  70924. Ext.define('Ext.sparkline.Box', {
  70925. extend: Ext.sparkline.Base,
  70926. alias: 'widget.sparklinebox',
  70927. config: {
  70928. raw: false,
  70929. boxLineColor: '#000',
  70930. boxFillColor: '#cdf',
  70931. whiskerColor: '#000',
  70932. outlierLineColor: '#333',
  70933. outlierFillColor: '#fff',
  70934. medianColor: '#f00',
  70935. showOutliers: true,
  70936. outlierIQR: 1.5,
  70937. spotRadius: 1.5,
  70938. target: null,
  70939. targetColor: '#4a2',
  70940. chartRangeMin: null,
  70941. chartRangeMax: null
  70942. },
  70943. tipTpl: [
  70944. '{field:this.fields}: {value}',
  70945. {
  70946. fields: function(v) {
  70947. var fields = {
  70948. lq: 'Lower Quartile',
  70949. med: 'Median',
  70950. uq: 'Upper Quartile',
  70951. lo: 'Left Outlier',
  70952. ro: 'Right Outlier',
  70953. lw: 'Left Whisker',
  70954. rw: 'Right Whisker'
  70955. };
  70956. return fields[v];
  70957. }
  70958. }
  70959. ],
  70960. tooltipFormatFieldlistKey: 'field',
  70961. quartile: function(values, q) {
  70962. var vl;
  70963. if (q === 2) {
  70964. vl = Math.floor(values.length / 2);
  70965. return values.length % 2 ? values[vl] : (values[vl - 1] + values[vl]) / 2;
  70966. } else {
  70967. if (values.length % 2) {
  70968. vl = (values.length * q + q) / 4;
  70969. return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl - 1];
  70970. } else {
  70971. vl = (values.length * q + 2) / 4;
  70972. return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl - 1];
  70973. }
  70974. }
  70975. },
  70976. applyValues: function(newValues) {
  70977. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  70978. if (!this.raw) {
  70979. newValues.sort(function(a, b) {
  70980. return a - b;
  70981. });
  70982. }
  70983. this.disabled = !(newValues && newValues.length);
  70984. this.updateConfigChange();
  70985. return newValues;
  70986. },
  70987. getRegion: function() {
  70988. return 1;
  70989. },
  70990. getRegionFields: function() {
  70991. var result = [
  70992. {
  70993. field: 'lq',
  70994. value: this.quartiles[0]
  70995. },
  70996. {
  70997. field: 'med',
  70998. value: this.quartiles[1]
  70999. },
  71000. {
  71001. field: 'uq',
  71002. value: this.quartiles[2]
  71003. }
  71004. ];
  71005. if (this.loutlier !== undefined) {
  71006. result.push({
  71007. field: 'lo',
  71008. value: this.loutlier
  71009. });
  71010. }
  71011. if (this.routlier !== undefined) {
  71012. result.push({
  71013. field: 'ro',
  71014. value: this.routlier
  71015. });
  71016. }
  71017. if (this.lwhisker !== undefined) {
  71018. result.push({
  71019. field: 'lw',
  71020. value: this.lwhisker
  71021. });
  71022. }
  71023. if (this.rwhisker !== undefined) {
  71024. result.push({
  71025. field: 'rw',
  71026. value: this.rwhisker
  71027. });
  71028. }
  71029. return result;
  71030. },
  71031. renderHighlight: Ext.emptyFn,
  71032. renderGraph: function() {
  71033. var me = this,
  71034. canvas = me.canvas,
  71035. values = me.values,
  71036. vlen = values.length,
  71037. canvasWidth = me.getWidth(),
  71038. canvasHeight = me.getHeight(),
  71039. chartRangeMin = me.getChartRangeMin(),
  71040. chartRangeMax = me.getChartRangeMax(),
  71041. minValue = chartRangeMin == null ? Math.min.apply(Math, values) : chartRangeMin,
  71042. maxValue = chartRangeMax == null ? Math.max.apply(Math, values) : chartRangeMax,
  71043. canvasLeft = 0,
  71044. lwhisker, loutlier, iqr, q1, q2, q3, rwhisker, routlier, i, size, unitSize,
  71045. spotRadius = me.getSpotRadius(),
  71046. outlierLineColor = me.getOutlierLineColor(),
  71047. outlierFillColor = me.getOutlierFillColor(),
  71048. showOutliers = me.getShowOutliers(),
  71049. outlierIQR = me.getOutlierIQR(),
  71050. lineColor = me.getLineColor(),
  71051. whiskerColor = me.getWhiskerColor(),
  71052. targetColor = me.getTargetColor();
  71053. if (!me.callParent()) {
  71054. return;
  71055. }
  71056. if (me.raw) {
  71057. if (showOutliers && values.length > 5) {
  71058. loutlier = values[0];
  71059. lwhisker = values[1];
  71060. q1 = values[2];
  71061. q2 = values[3];
  71062. q3 = values[4];
  71063. rwhisker = values[5];
  71064. routlier = values[6];
  71065. } else {
  71066. lwhisker = values[0];
  71067. q1 = values[1];
  71068. q2 = values[2];
  71069. q3 = values[3];
  71070. rwhisker = values[4];
  71071. }
  71072. } else {
  71073. q1 = me.quartile(values, 1);
  71074. q2 = me.quartile(values, 2);
  71075. q3 = me.quartile(values, 3);
  71076. iqr = q3 - q1;
  71077. if (showOutliers) {
  71078. lwhisker = rwhisker = null;
  71079. for (i = 0; i < vlen; i++) {
  71080. if (lwhisker == null && values[i] > q1 - (iqr * outlierIQR)) {
  71081. lwhisker = values[i];
  71082. }
  71083. if (values[i] < q3 + (iqr * outlierIQR)) {
  71084. rwhisker = values[i];
  71085. }
  71086. }
  71087. loutlier = values[0];
  71088. routlier = values[vlen - 1];
  71089. } else {
  71090. lwhisker = values[0];
  71091. rwhisker = values[vlen - 1];
  71092. }
  71093. }
  71094. me.quartiles = [
  71095. q1,
  71096. q2,
  71097. q3
  71098. ];
  71099. me.lwhisker = lwhisker;
  71100. me.rwhisker = rwhisker;
  71101. me.loutlier = loutlier;
  71102. me.routlier = routlier;
  71103. unitSize = canvasWidth / (maxValue - minValue + 1);
  71104. if (showOutliers) {
  71105. canvasLeft = Math.ceil(spotRadius);
  71106. canvasWidth -= 2 * Math.ceil(spotRadius);
  71107. unitSize = canvasWidth / (maxValue - minValue + 1);
  71108. if (loutlier < lwhisker) {
  71109. canvas.drawCircle((loutlier - minValue) * unitSize + canvasLeft, canvasHeight / 2, spotRadius, outlierLineColor, outlierFillColor).append();
  71110. }
  71111. if (routlier > rwhisker) {
  71112. canvas.drawCircle((routlier - minValue) * unitSize + canvasLeft, canvasHeight / 2, spotRadius, outlierLineColor, outlierFillColor).append();
  71113. }
  71114. }
  71115. canvas.drawRect(Math.round((q1 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight * 0.1), Math.round((q3 - q1) * unitSize), Math.round(canvasHeight * 0.8), me.getBoxLineColor(), me.getBoxFillColor()).append();
  71116. canvas.drawLine(Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), Math.round((q1 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), lineColor).append();
  71117. canvas.drawLine(Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 4), Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight - canvasHeight / 4), whiskerColor).append();
  71118. canvas.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), Math.round((q3 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), lineColor).append();
  71119. canvas.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 4), Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight - canvasHeight / 4), whiskerColor).append();
  71120. canvas.drawLine(Math.round((q2 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight * 0.1), Math.round((q2 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight * 0.9), me.getMedianColor()).append();
  71121. if (me.target) {
  71122. size = Math.ceil(me.spotRadius);
  71123. canvas.drawLine(Math.round((me.target - minValue) * unitSize + canvasLeft), Math.round((canvasHeight / 2) - size), Math.round((me.target - minValue) * unitSize + canvasLeft), Math.round((canvasHeight / 2) + size), targetColor).append();
  71124. canvas.drawLine(Math.round((me.target - minValue) * unitSize + canvasLeft - size), Math.round(canvasHeight / 2), Math.round((me.target - minValue) * unitSize + canvasLeft + size), Math.round(canvasHeight / 2), targetColor).append();
  71125. }
  71126. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  71127. me.currentRegion = null;
  71128. me.updateDisplay();
  71129. }
  71130. canvas.render();
  71131. }
  71132. });
  71133. Ext.define('Ext.sparkline.Bullet', {
  71134. extend: Ext.sparkline.Base,
  71135. alias: 'widget.sparklinebullet',
  71136. config: {
  71137. targetColor: '#f33',
  71138. targetWidth: 3,
  71139. performanceColor: '#33f',
  71140. rangeColors: [
  71141. '#d3dafe',
  71142. '#a8b6ff',
  71143. '#7f94ff'
  71144. ],
  71145. base: null
  71146. },
  71147. tipTpl: [
  71148. '{fieldkey:this.fields} - {value}',
  71149. {
  71150. fields: function(v) {
  71151. if (v === 'r') {
  71152. return 'Range';
  71153. }
  71154. if (v === 'p') {
  71155. return 'Performance';
  71156. }
  71157. if (v === 't') {
  71158. return 'Target';
  71159. }
  71160. }
  71161. }
  71162. ],
  71163. applyValues: function(newValues) {
  71164. newValues = Ext.Array.map(Ext.Array.from(newValues), this.normalizeValue);
  71165. this.disabled = !(newValues && newValues.length);
  71166. this.updateConfigChange();
  71167. return newValues;
  71168. },
  71169. onUpdate: function() {
  71170. var me = this,
  71171. values = me.values,
  71172. min, max, vals,
  71173. base = me.getBase();
  71174. me.callParent(arguments);
  71175. vals = values.slice();
  71176. vals[0] = vals[0] === null ? vals[2] : vals[0];
  71177. vals[1] = values[1] === null ? vals[2] : vals[1];
  71178. min = Math.min.apply(Math, values);
  71179. max = Math.max.apply(Math, values);
  71180. if (base == null) {
  71181. min = min < 0 ? min : 0;
  71182. } else {
  71183. min = base;
  71184. }
  71185. me.min = min;
  71186. me.max = max;
  71187. me.range = max - min;
  71188. me.shapes = {};
  71189. me.valueShapes = {};
  71190. me.regiondata = {};
  71191. if (!values.length) {
  71192. me.disabled = true;
  71193. }
  71194. },
  71195. getRegion: function(x, y) {
  71196. var shapeid = this.canvas.getShapeAt(x, y);
  71197. return (shapeid !== undefined && this.shapes[shapeid] !== undefined) ? this.shapes[shapeid] : undefined;
  71198. },
  71199. getRegionFields: function(region) {
  71200. return {
  71201. fieldkey: region.substr(0, 1),
  71202. value: this.values[parseInt(region.substr(1), 10)],
  71203. region: region
  71204. };
  71205. },
  71206. renderHighlight: function(region) {
  71207. var me = this,
  71208. valueShapes = me.valueShapes,
  71209. shapes = me.shapes,
  71210. shapeId = valueShapes[region],
  71211. shape;
  71212. delete shapes[shapeId];
  71213. switch (region.substr(0, 1)) {
  71214. case 'r':
  71215. shape = me.renderRange(parseInt(region.substr(1), 10), true);
  71216. break;
  71217. case 'p':
  71218. shape = me.renderPerformance(true);
  71219. break;
  71220. case 't':
  71221. shape = me.renderTarget(true);
  71222. break;
  71223. }
  71224. valueShapes[region] = shape.id;
  71225. shapes[shape.id] = region;
  71226. me.canvas.replaceWithShape(shapeId, shape);
  71227. },
  71228. renderRange: function(region, highlight) {
  71229. var me = this,
  71230. rangeval = me.values[region],
  71231. rangewidth = Math.round(me.getWidth() * ((rangeval - me.min) / me.range)),
  71232. colors = me.getRangeColors(),
  71233. color = colors[Math.min(region - 2, colors.length - 1)];
  71234. if (highlight) {
  71235. color = me.calcHighlightColor(color);
  71236. }
  71237. return me.canvas.drawRect(0, 0, rangewidth - 1, me.getHeight() - 1, color, color);
  71238. },
  71239. renderPerformance: function(highlight) {
  71240. var perfval = this.values[1],
  71241. perfwidth = Math.round(this.getWidth() * ((perfval - this.min) / this.range)),
  71242. color = this.getPerformanceColor();
  71243. if (highlight) {
  71244. color = this.calcHighlightColor(color);
  71245. }
  71246. return this.canvas.drawRect(0, Math.round(this.getHeight() * 0.3), perfwidth - 1, Math.round(this.getHeight() * 0.4) - 1, color, color);
  71247. },
  71248. renderTarget: function(highlight) {
  71249. var targetval = this.values[0],
  71250. targetWidth = this.getTargetWidth(),
  71251. x = Math.round(this.getWidth() * ((targetval - this.min) / this.range) - (targetWidth / 2)),
  71252. targettop = Math.round(this.getHeight() * 0.1),
  71253. targetheight = this.getHeight() - (targettop * 2),
  71254. color = this.getTargetColor();
  71255. if (highlight) {
  71256. color = this.calcHighlightColor(color);
  71257. }
  71258. return this.canvas.drawRect(x, targettop, targetWidth - 1, targetheight - 1, color, color);
  71259. },
  71260. renderGraph: function() {
  71261. var me = this,
  71262. vlen = me.values.length,
  71263. canvas = me.canvas,
  71264. i, shape,
  71265. shapes = me.shapes || (me.shapes = {}),
  71266. valueShapes = me.valueShapes || (me.valueShapes = {});
  71267. if (!me.callParent()) {
  71268. return;
  71269. }
  71270. for (i = 2; i < vlen; i++) {
  71271. shape = me.renderRange(i).append();
  71272. shapes[shape.id] = 'r' + i;
  71273. valueShapes['r' + i] = shape.id;
  71274. }
  71275. if (me.values[1] !== null) {
  71276. shape = me.renderPerformance().append();
  71277. shapes[shape.id] = 'p1';
  71278. valueShapes.p1 = shape.id;
  71279. }
  71280. if (me.values[0] !== null) {
  71281. shape = this.renderTarget().append();
  71282. shapes[shape.id] = 't0';
  71283. valueShapes.t0 = shape.id;
  71284. }
  71285. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  71286. me.updateDisplay();
  71287. }
  71288. canvas.render();
  71289. },
  71290. privates: {
  71291. isValidRegion: function(region, values) {
  71292. return parseInt(region.substr(1), 10) < values.length;
  71293. }
  71294. }
  71295. });
  71296. Ext.define('Ext.sparkline.Discrete', {
  71297. extend: Ext.sparkline.BarBase,
  71298. alias: 'widget.sparklinediscrete',
  71299. config: {
  71300. lineHeight: 'auto',
  71301. thresholdColor: null,
  71302. thresholdValue: 0,
  71303. chartRangeMax: null,
  71304. chartRangeMin: null,
  71305. chartRangeClip: false
  71306. },
  71307. tipTpl: '{prefix}{value}{suffix}',
  71308. applyValues: function(newValues) {
  71309. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  71310. this.disabled = !(newValues && newValues.length);
  71311. this.updateConfigChange();
  71312. return newValues;
  71313. },
  71314. onUpdate: function() {
  71315. var me = this,
  71316. values = me.values,
  71317. chartRangeMin = me.getChartRangeMin(),
  71318. chartRangeMax = me.getChartRangeMax(),
  71319. chartRangeClip = me.getChartRangeClip();
  71320. me.callParent(arguments);
  71321. me.regionShapes = {};
  71322. me.min = Math.min.apply(Math, values);
  71323. me.max = Math.max.apply(Math, values);
  71324. me.range = me.max - me.min;
  71325. me.width = me.getWidth();
  71326. me.interval = Math.floor(me.width / values.length);
  71327. me.itemWidth = me.width / values.length;
  71328. if (chartRangeMin != null && (chartRangeClip || chartRangeMin < me.min)) {
  71329. me.min = chartRangeMin;
  71330. }
  71331. if (chartRangeMax != null && (chartRangeClip || chartRangeMax > me.max)) {
  71332. me.max = chartRangeMax;
  71333. }
  71334. if (me.canvas) {
  71335. if (me.getLineHeight() === 'auto') {
  71336. me.setLineHeight(Math.round(me.getHeight() * 0.3));
  71337. }
  71338. }
  71339. },
  71340. getRegion: function(x, y) {
  71341. return Math.floor(x / this.itemWidth);
  71342. },
  71343. getRegionFields: function(region) {
  71344. return {
  71345. isNull: this.values[region] === undefined,
  71346. value: this.values[region],
  71347. offset: region
  71348. };
  71349. },
  71350. renderRegion: function(valuenum, highlight) {
  71351. var me = this,
  71352. values = me.values,
  71353. min = me.min,
  71354. max = me.max,
  71355. range = me.range,
  71356. interval = me.interval,
  71357. canvas = me.canvas,
  71358. canvasHeight = me.getHeight(),
  71359. lineHeight = me.getLineHeight(),
  71360. pheight = canvasHeight - lineHeight,
  71361. ytop, val, color, x,
  71362. thresholdColor = me.getThresholdColor();
  71363. val = Ext.Number.constrain(values[valuenum], min, max);
  71364. x = valuenum * interval;
  71365. ytop = Math.round(pheight - pheight * ((val - min) / range));
  71366. color = (thresholdColor && val < me.getThresholdValue()) ? thresholdColor : me.getLineColor();
  71367. if (highlight) {
  71368. color = me.calcHighlightColor(color);
  71369. }
  71370. canvas.drawLine(x, ytop, x, ytop + lineHeight, color).append();
  71371. }
  71372. });
  71373. Ext.define('Ext.sparkline.Line', {
  71374. extend: Ext.sparkline.Base,
  71375. alias: 'widget.sparklineline',
  71376. config: {
  71377. fillColor: '#def',
  71378. spotColor: '#f80',
  71379. highlightSpotColor: '#5f5',
  71380. highlightLineColor: '#f22',
  71381. spotRadius: 1.5,
  71382. minSpotColor: '#f80',
  71383. maxSpotColor: '#f80',
  71384. lineWidth: 1,
  71385. normalRangeMin: null,
  71386. normalRangeMax: null,
  71387. normalRangeColor: '#ccc',
  71388. drawNormalOnTop: false,
  71389. chartRangeMin: null,
  71390. chartRangeMax: null,
  71391. chartRangeMinX: null,
  71392. chartRangeMaxX: null,
  71393. valueSpots: null
  71394. },
  71395. tipTpl: '&#9679; {prefix}{y}{suffix}',
  71396. applyValueSpots: function(valueSpots) {
  71397. if (valueSpots && !valueSpots.get) {
  71398. valueSpots = new Ext.sparkline.RangeMap(valueSpots);
  71399. }
  71400. this.updateConfigChange();
  71401. return valueSpots;
  71402. },
  71403. onUpdate: function() {
  71404. this.vertices = [];
  71405. this.regionMap = [];
  71406. this.xvalues = [];
  71407. this.yvalues = [];
  71408. this.yminmax = [];
  71409. },
  71410. getRegion: function(x, y) {
  71411. var i,
  71412. regionMap = this.regionMap;
  71413. for (i = regionMap.length; i--; ) {
  71414. if (regionMap[i] !== null && x >= regionMap[i][0] && x <= regionMap[i][1]) {
  71415. return regionMap[i][2];
  71416. }
  71417. }
  71418. return undefined;
  71419. },
  71420. getRegionFields: function(region) {
  71421. return {
  71422. isNull: this.yvalues[region] === null,
  71423. x: this.xvalues[region],
  71424. y: this.yvalues[region],
  71425. color: this.getLineColor(),
  71426. fillColor: this.getFillColor(),
  71427. offset: region
  71428. };
  71429. },
  71430. renderHighlight: function(region) {
  71431. var me = this,
  71432. canvas = me.canvas,
  71433. vertex = me.vertices[region],
  71434. spotRadius = me.getSpotRadius(),
  71435. highlightSpotColor = me.getHighlightSpotColor(),
  71436. highlightLineColor = me.getHighlightLineColor();
  71437. if (!vertex) {
  71438. return;
  71439. }
  71440. if (spotRadius && highlightSpotColor) {
  71441. canvas.drawCircle(vertex[0], vertex[1], spotRadius, null, highlightSpotColor).append();
  71442. }
  71443. if (highlightLineColor) {
  71444. canvas.drawLine(vertex[0], me.canvasTop, vertex[0], me.canvasTop + me.getHeight(), highlightLineColor).append();
  71445. }
  71446. },
  71447. scanValues: function() {
  71448. var me = this,
  71449. values = me.values,
  71450. valcount = values.length,
  71451. xvalues = me.xvalues,
  71452. yvalues = me.yvalues,
  71453. yminmax = me.yminmax,
  71454. i, val;
  71455. for (i = 0; i < valcount; i++) {
  71456. val = values[i];
  71457. if (typeof val === 'string') {
  71458. val = val.split(':');
  71459. }
  71460. if (val && val.length === 2) {
  71461. xvalues.push(Number(val[0]));
  71462. yvalues.push(val = Number(val[1]));
  71463. yminmax.push(val);
  71464. } else
  71465. {
  71466. xvalues.push(i);
  71467. if (val == null || val === 'null') {
  71468. yvalues.push(null);
  71469. } else {
  71470. yvalues.push(val = Number(val));
  71471. yminmax.push(val);
  71472. }
  71473. }
  71474. }
  71475. if (me.xvalues) {
  71476. xvalues = me.xvalues;
  71477. }
  71478. me.maxy = me.maxyorg = Math.max.apply(Math, yminmax);
  71479. me.miny = me.minyorg = Math.min.apply(Math, yminmax);
  71480. me.maxx = Math.max.apply(Math, xvalues);
  71481. me.minx = Math.min.apply(Math, xvalues);
  71482. me.xvalues = xvalues;
  71483. me.yvalues = yvalues;
  71484. me.yminmax = yminmax;
  71485. },
  71486. processRangeOptions: function() {
  71487. var me = this,
  71488. normalRangeMin = me.getNormalRangeMin(),
  71489. normalRangeMax = me.getNormalRangeMax(),
  71490. chartRangeMin = me.getChartRangeMin(),
  71491. chartRangeMinX = me.getChartRangeMinX(),
  71492. chartRangeMax = me.getChartRangeMax(),
  71493. chartRangeMaxX = me.getChartRangeMaxX();
  71494. if (normalRangeMin != null) {
  71495. if (normalRangeMin < me.miny) {
  71496. me.miny = normalRangeMin;
  71497. }
  71498. if (normalRangeMax > me.maxy) {
  71499. me.maxy = normalRangeMax;
  71500. }
  71501. }
  71502. if (chartRangeMin != null && (me.chartRangeClip || chartRangeMin < me.miny)) {
  71503. me.miny = chartRangeMin;
  71504. }
  71505. if (chartRangeMax != null && (me.chartRangeClip || chartRangeMax > me.maxy)) {
  71506. this.maxy = chartRangeMax;
  71507. }
  71508. if (chartRangeMinX != null && (me.chartRangeClipX || chartRangeMinX < me.minx)) {
  71509. me.minx = chartRangeMinX;
  71510. }
  71511. if (chartRangeMaxX != null && (me.chartRangeClipX || chartRangeMaxX > me.maxx)) {
  71512. me.maxx = chartRangeMaxX;
  71513. }
  71514. },
  71515. drawNormalRange: function(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey) {
  71516. var normalRangeMin = this.getNormalRangeMin(),
  71517. normalRangeMax = this.getNormalRangeMax(),
  71518. ytop = canvasTop + Math.round(canvasHeight - (canvasHeight * ((normalRangeMax - this.miny) / rangey))),
  71519. height = Math.round((canvasHeight * (normalRangeMax - normalRangeMin)) / rangey);
  71520. this.canvas.drawRect(canvasLeft, ytop, canvasWidth, height, undefined, this.normalRangeColor).append();
  71521. },
  71522. renderGraph: function() {
  71523. var me = this,
  71524. canvas = me.canvas,
  71525. canvasWidth = me.getWidth(),
  71526. canvasHeight = me.getHeight(),
  71527. vertices = me.vertices,
  71528. spotRadius = me.getSpotRadius(),
  71529. regionMap = me.regionMap,
  71530. rangeX, Y, yvallast, canvasTop, canvasLeft, vertex, path, paths, x, y, xNext, xPos, xPosNext, last, next, yValCount, lineShapes, fillShapes, plen,
  71531. valueSpots = me.getValueSpots(),
  71532. hlSpotsEnabled, color, xValues, yValues, i,
  71533. spotColor = me.getSpotColor(),
  71534. minSpotColor = me.getMinSpotColor(),
  71535. maxSpotColor = me.getMaxSpotColor(),
  71536. normalRangeMin = me.getNormalRangeMin(),
  71537. drawNormalOnTop = me.getDrawNormalOnTop();
  71538. if (!me.callParent()) {
  71539. return;
  71540. }
  71541. me.scanValues();
  71542. me.processRangeOptions();
  71543. xValues = me.xvalues;
  71544. yValues = me.yvalues;
  71545. if (!me.yminmax.length || me.yvalues.length < 2) {
  71546. return;
  71547. }
  71548. canvasTop = canvasLeft = 0;
  71549. rangeX = me.maxx - me.minx === 0 ? 1 : me.maxx - me.minx;
  71550. Y = me.maxy - me.miny === 0 ? 1 : me.maxy - me.miny;
  71551. yvallast = me.yvalues.length - 1;
  71552. if (spotRadius && (canvasWidth < (spotRadius * 4) || canvasHeight < (spotRadius * 4))) {
  71553. spotRadius = 0;
  71554. }
  71555. if (spotRadius) {
  71556. hlSpotsEnabled = me.getHighlightSpotColor() && !me.disableInteraction;
  71557. if (hlSpotsEnabled || minSpotColor || (spotColor && yValues[yvallast] === me.miny)) {
  71558. canvasHeight -= Math.ceil(spotRadius);
  71559. }
  71560. if (hlSpotsEnabled || maxSpotColor || (spotColor && yValues[yvallast] === me.maxy)) {
  71561. canvasHeight -= Math.ceil(spotRadius);
  71562. canvasTop += Math.ceil(spotRadius);
  71563. }
  71564. if (hlSpotsEnabled || ((minSpotColor || maxSpotColor) && (yValues[0] === me.miny || yValues[0] === me.maxy))) {
  71565. canvasLeft += Math.ceil(spotRadius);
  71566. canvasWidth -= Math.ceil(spotRadius);
  71567. }
  71568. if (hlSpotsEnabled || spotColor || (minSpotColor || maxSpotColor && (yValues[yvallast] === me.miny || yValues[yvallast] === me.maxy))) {
  71569. canvasWidth -= Math.ceil(spotRadius);
  71570. }
  71571. }
  71572. canvasHeight--;
  71573. if (normalRangeMin != null && !drawNormalOnTop) {
  71574. me.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, Y);
  71575. }
  71576. path = [];
  71577. paths = [
  71578. path
  71579. ];
  71580. last = next = null;
  71581. yValCount = yValues.length;
  71582. for (i = 0; i < yValCount; i++) {
  71583. x = xValues[i];
  71584. xNext = xValues[i + 1];
  71585. y = yValues[i];
  71586. xPos = canvasLeft + Math.round((x - me.minx) * (canvasWidth / rangeX));
  71587. xPosNext = i < yValCount - 1 ? canvasLeft + Math.round((xNext - me.minx) * (canvasWidth / rangeX)) : canvasWidth;
  71588. next = xPos + ((xPosNext - xPos) / 2);
  71589. regionMap[i] = [
  71590. last || 0,
  71591. next,
  71592. i
  71593. ];
  71594. last = next;
  71595. if (y === null) {
  71596. if (i) {
  71597. if (yValues[i - 1] !== null) {
  71598. path = [];
  71599. paths.push(path);
  71600. }
  71601. vertices.push(null);
  71602. }
  71603. } else {
  71604. if (y < me.miny) {
  71605. y = me.miny;
  71606. }
  71607. if (y > me.maxy) {
  71608. y = me.maxy;
  71609. }
  71610. if (!path.length) {
  71611. path.push([
  71612. xPos,
  71613. canvasTop + canvasHeight
  71614. ]);
  71615. }
  71616. vertex = [
  71617. xPos,
  71618. canvasTop + Math.round(canvasHeight - (canvasHeight * ((y - this.miny) / Y)))
  71619. ];
  71620. path.push(vertex);
  71621. vertices.push(vertex);
  71622. }
  71623. }
  71624. lineShapes = [];
  71625. fillShapes = [];
  71626. plen = paths.length;
  71627. for (i = 0; i < plen; i++) {
  71628. path = paths[i];
  71629. if (path.length) {
  71630. if (me.fillColor) {
  71631. path.push([
  71632. path[path.length - 1][0],
  71633. (canvasTop + canvasHeight)
  71634. ]);
  71635. fillShapes.push(path.slice(0));
  71636. path.pop();
  71637. }
  71638. if (path.length > 2) {
  71639. path[0] = [
  71640. path[0][0],
  71641. path[1][1]
  71642. ];
  71643. }
  71644. lineShapes.push(path);
  71645. }
  71646. }
  71647. plen = fillShapes.length;
  71648. for (i = 0; i < plen; i++) {
  71649. canvas.drawShape(fillShapes[i], me.fillColor, me.fillColor).append();
  71650. }
  71651. if (normalRangeMin != null && drawNormalOnTop) {
  71652. me.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, Y);
  71653. }
  71654. plen = lineShapes.length;
  71655. for (i = 0; i < plen; i++) {
  71656. canvas.drawShape(lineShapes[i], me.getLineColor(), null, me.getLineWidth()).append();
  71657. }
  71658. if (spotRadius && valueSpots) {
  71659. if (valueSpots.get == null) {
  71660. valueSpots = new Ext.sparkline.RangeMap(valueSpots);
  71661. }
  71662. for (i = 0; i < yValCount; i++) {
  71663. color = valueSpots.get(yValues[i]);
  71664. if (color) {
  71665. canvas.drawCircle(canvasLeft + Math.round((xValues[i] - me.minx) * (canvasWidth / rangeX)), canvasTop + Math.round(canvasHeight - (canvasHeight * ((yValues[i] - me.miny) / Y))), spotRadius, null, color).append();
  71666. }
  71667. }
  71668. }
  71669. if (spotRadius && spotColor && yValues[yvallast] != null) {
  71670. canvas.drawCircle(canvasLeft + Math.round((xValues[xValues.length - 1] - me.minx) * (canvasWidth / rangeX)), canvasTop + Math.round(canvasHeight - (canvasHeight * ((yValues[yvallast] - me.miny) / Y))), spotRadius, null, spotColor).append();
  71671. }
  71672. if (me.maxy !== me.minyorg) {
  71673. if (spotRadius && minSpotColor) {
  71674. x = xValues[Ext.Array.indexOf(yValues, me.minyorg)];
  71675. canvas.drawCircle(canvasLeft + Math.round((x - me.minx) * (canvasWidth / rangeX)), canvasTop + Math.round(canvasHeight - (canvasHeight * ((me.minyorg - me.miny) / Y))), spotRadius, null, minSpotColor).append();
  71676. }
  71677. if (spotRadius && maxSpotColor) {
  71678. x = xValues[Ext.Array.indexOf(yValues, me.maxyorg)];
  71679. canvas.drawCircle(canvasLeft + Math.round((x - me.minx) * (canvasWidth / rangeX)), canvasTop + Math.round(canvasHeight - (canvasHeight * ((me.maxyorg - me.miny) / Y))), spotRadius, null, maxSpotColor).append();
  71680. }
  71681. }
  71682. me.canvasTop = canvasTop;
  71683. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  71684. me.updateDisplay();
  71685. }
  71686. canvas.render();
  71687. }
  71688. });
  71689. Ext.define('Ext.sparkline.Pie', {
  71690. extend: Ext.sparkline.Base,
  71691. alias: 'widget.sparklinepie',
  71692. config: {
  71693. offset: 0,
  71694. sliceColors: [
  71695. '#3366cc',
  71696. '#dc3912',
  71697. '#ff9900',
  71698. '#109618',
  71699. '#66aa00',
  71700. '#dd4477',
  71701. '#0099c6',
  71702. '#990099'
  71703. ],
  71704. borderWidth: 0,
  71705. borderColor: '#000'
  71706. },
  71707. tipTpl: '&#9679; {value} ({percent:number("0.0")}%)',
  71708. applyValues: function(newValues) {
  71709. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  71710. this.disabled = !(newValues && newValues.length);
  71711. this.updateConfigChange();
  71712. return newValues;
  71713. },
  71714. onUpdate: function() {
  71715. var me = this,
  71716. values = me.values,
  71717. total = 0,
  71718. i;
  71719. me.callParent(arguments);
  71720. me.shapes = {};
  71721. me.valueShapes = {};
  71722. if (values.length > 0) {
  71723. for (i = values.length; i--; ) {
  71724. total += values[i];
  71725. }
  71726. }
  71727. me.total = total;
  71728. me.radius = Math.floor(Math.min(me.getWidth(), me.getHeight()) / 2);
  71729. },
  71730. getRegion: function(x, y) {
  71731. var ratio = window.devicePixelRatio || 1,
  71732. shapeid = this.canvas.getShapeAt(x * ratio, y * ratio);
  71733. return (shapeid != null && this.shapes[shapeid] != null) ? this.shapes[shapeid] : null;
  71734. },
  71735. getRegionFields: function(region) {
  71736. var sliceColors = this.getSliceColors();
  71737. return {
  71738. isNull: this.values[region] == null,
  71739. value: this.values[region],
  71740. percent: this.values[region] / this.total * 100,
  71741. color: sliceColors[region % sliceColors.length],
  71742. offset: region
  71743. };
  71744. },
  71745. renderHighlight: function(region) {
  71746. this.renderSlice(region, true).append();
  71747. },
  71748. renderSlice: function(valuenum, highlight) {
  71749. var me = this,
  71750. canvas = me.canvas,
  71751. radius = me.radius,
  71752. borderWidth = me.getBorderWidth(),
  71753. offset = me.getOffset(),
  71754. circle = 2 * Math.PI,
  71755. values = me.values,
  71756. total = me.total,
  71757. next = offset ? (2 * Math.PI) * (offset / 360) : 0,
  71758. start, end, i, vlen, color,
  71759. sliceColors = this.getSliceColors();
  71760. vlen = values.length;
  71761. for (i = 0; i < vlen; i++) {
  71762. start = next;
  71763. end = next;
  71764. if (total > 0) {
  71765. end = next + (circle * (values[i] / total));
  71766. }
  71767. if (valuenum === i) {
  71768. color = sliceColors[i % sliceColors.length];
  71769. if (highlight) {
  71770. color = me.calcHighlightColor(color);
  71771. }
  71772. return canvas.drawPieSlice(radius, radius, radius - borderWidth, start, end, null, color);
  71773. }
  71774. next = end;
  71775. }
  71776. },
  71777. renderGraph: function() {
  71778. var me = this,
  71779. canvas = me.canvas,
  71780. values = me.values,
  71781. radius = me.radius,
  71782. borderWidth = me.getBorderWidth(),
  71783. shape, i,
  71784. shapes = me.shapes || (me.shapes = {}),
  71785. valueShapes = me.valueShapes || (me.valueShapes = {});
  71786. if (!me.callParent()) {
  71787. return;
  71788. }
  71789. if (borderWidth) {
  71790. canvas.drawCircle(radius, radius, Math.floor(radius - (borderWidth / 2)), me.getBorderColor(), null, borderWidth).append();
  71791. }
  71792. for (i = values.length; i--; ) {
  71793. if (values[i]) {
  71794. shape = me.renderSlice(i).append();
  71795. valueShapes[i] = shape.id;
  71796. shapes[shape.id] = i;
  71797. }
  71798. }
  71799. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  71800. me.currentRegion = null;
  71801. me.updateDisplay();
  71802. }
  71803. canvas.render();
  71804. }
  71805. });
  71806. Ext.define('Ext.sparkline.TriState', {
  71807. extend: Ext.sparkline.BarBase,
  71808. alias: 'widget.sparklinetristate',
  71809. config: {
  71810. barWidth: 4,
  71811. barSpacing: 1,
  71812. posBarColor: '#6f6',
  71813. negBarColor: '#f44',
  71814. zeroBarColor: '#999',
  71815. colorMap: {}
  71816. },
  71817. tipTpl: [
  71818. '&#9679; {value:this.states}',
  71819. {
  71820. states: function(v) {
  71821. var value = Number(v);
  71822. if (value === -1) {
  71823. return 'Loss';
  71824. }
  71825. if (value === 0) {
  71826. return 'Draw';
  71827. }
  71828. if (value === 1) {
  71829. return 'Win';
  71830. }
  71831. return v;
  71832. }
  71833. }
  71834. ],
  71835. applyColorMap: function(colorMap) {
  71836. var me = this;
  71837. if (Ext.isArray(colorMap)) {
  71838. me.colorMapByIndex = colorMap;
  71839. me.colorMapByValue = null;
  71840. } else {
  71841. me.colorMapByIndex = null;
  71842. me.colorMapByValue = colorMap;
  71843. if (me.colorMapByValue && me.colorMapByValue.get == null) {
  71844. me.colorMapByValue = new Ext.sparkline.RangeMap(colorMap);
  71845. }
  71846. }
  71847. me.updateConfigChange();
  71848. return colorMap;
  71849. },
  71850. applyValues: function(newValues) {
  71851. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  71852. this.disabled = !(newValues && newValues.length);
  71853. this.updateConfigChange();
  71854. return newValues;
  71855. },
  71856. onUpdate: function() {
  71857. this.totalBarWidth = this.getBarWidth() + this.getBarSpacing();
  71858. },
  71859. getBarWidth: function() {
  71860. var values = this.values;
  71861. return this._barWidth || (this.getWidth() - (values.length - 1) * this.getBarSpacing()) / values.length;
  71862. },
  71863. getRegion: function(x, y) {
  71864. return Math.floor(x / this.totalBarWidth);
  71865. },
  71866. getRegionFields: function(region) {
  71867. return {
  71868. isNull: this.values[region] == null,
  71869. value: this.values[region],
  71870. color: this.calcColor(this.values[region], region),
  71871. offset: region
  71872. };
  71873. },
  71874. calcColor: function(value, valuenum) {
  71875. var me = this,
  71876. values = me.values,
  71877. colorMapByIndex = me.colorMapByIndex,
  71878. colorMapByValue = me.colorMapByValue,
  71879. color, newColor;
  71880. if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
  71881. color = newColor;
  71882. } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
  71883. color = colorMapByIndex[valuenum];
  71884. } else if (values[valuenum] < 0) {
  71885. color = me.getNegBarColor();
  71886. } else if (values[valuenum] > 0) {
  71887. color = me.getPosBarColor();
  71888. } else {
  71889. color = me.getZeroBarColor();
  71890. }
  71891. return color;
  71892. },
  71893. renderRegion: function(valuenum, highlight) {
  71894. var me = this,
  71895. values = me.values,
  71896. canvas = me.canvas,
  71897. canvasHeight, height, halfHeight, x, y, color;
  71898. canvasHeight = canvas.pixelHeight;
  71899. halfHeight = Math.round(canvasHeight / 2);
  71900. x = valuenum * me.totalBarWidth;
  71901. if (values[valuenum] < 0) {
  71902. y = halfHeight;
  71903. height = halfHeight - 1;
  71904. } else if (values[valuenum] > 0) {
  71905. y = 0;
  71906. height = halfHeight - 1;
  71907. } else {
  71908. y = halfHeight - 1;
  71909. height = 2;
  71910. }
  71911. color = me.calcColor(values[valuenum], valuenum);
  71912. if (color == null) {
  71913. return;
  71914. }
  71915. if (highlight) {
  71916. color = me.calcHighlightColor(color);
  71917. }
  71918. canvas.drawRect(x, y, me.getBarWidth() - 1, height - 1, color, color).append();
  71919. }
  71920. });
  71921. Ext.define('Ext.util.Base64', {
  71922. singleton: true,
  71923. _str: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
  71924. encode: function(input) {
  71925. var me = this,
  71926. output = '',
  71927. i = 0,
  71928. chr1, chr2, chr3, enc1, enc2, enc3, enc4, len;
  71929. input = me._utf8_encode(input);
  71930. len = input.length;
  71931. while (i < len) {
  71932. chr1 = input.charCodeAt(i++);
  71933. chr2 = input.charCodeAt(i++);
  71934. chr3 = input.charCodeAt(i++);
  71935. enc1 = chr1 >> 2;
  71936. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  71937. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  71938. enc4 = chr3 & 63;
  71939. if (isNaN(chr2)) {
  71940. enc3 = enc4 = 64;
  71941. } else if (isNaN(chr3)) {
  71942. enc4 = 64;
  71943. }
  71944. output = output + me._str.charAt(enc1) + me._str.charAt(enc2) + me._str.charAt(enc3) + me._str.charAt(enc4);
  71945. }
  71946. return output;
  71947. },
  71948. decode: function(input) {
  71949. var me = this,
  71950. output = '',
  71951. i = 0,
  71952. chr1, chr2, chr3, enc1, enc2, enc3, enc4, len;
  71953. input = input.replace(/[^A-Za-z0-9+=\/]/g, "");
  71954. len = input.length;
  71955. while (i < len) {
  71956. enc1 = me._str.indexOf(input.charAt(i++));
  71957. enc2 = me._str.indexOf(input.charAt(i++));
  71958. enc3 = me._str.indexOf(input.charAt(i++));
  71959. enc4 = me._str.indexOf(input.charAt(i++));
  71960. chr1 = (enc1 << 2) | (enc2 >> 4);
  71961. chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  71962. chr3 = ((enc3 & 3) << 6) | enc4;
  71963. output = output + String.fromCharCode(chr1);
  71964. if (enc3 !== 64) {
  71965. output = output + String.fromCharCode(chr2);
  71966. }
  71967. if (enc4 !== 64) {
  71968. output = output + String.fromCharCode(chr3);
  71969. }
  71970. }
  71971. output = me._utf8_decode(output);
  71972. return output;
  71973. },
  71974. _utf8_encode: function(string) {
  71975. var utftext = '',
  71976. c, n, len;
  71977. string = string.replace(/\r\n/g, "\n");
  71978. for (n = 0 , len = string.length; n < len; n++) {
  71979. c = string.charCodeAt(n);
  71980. if (c < 128) {
  71981. utftext += String.fromCharCode(c);
  71982. } else if ((c > 127) && (c < 2048)) {
  71983. utftext += String.fromCharCode((c >> 6) | 192);
  71984. utftext += String.fromCharCode((c & 63) | 128);
  71985. } else {
  71986. utftext += String.fromCharCode((c >> 12) | 224);
  71987. utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  71988. utftext += String.fromCharCode((c & 63) | 128);
  71989. }
  71990. }
  71991. return utftext;
  71992. },
  71993. _utf8_decode: function(utftext) {
  71994. var string = '',
  71995. i = 0,
  71996. c = 0,
  71997. c3 = 0,
  71998. c2 = 0,
  71999. len = utftext.length;
  72000. while (i < len) {
  72001. c = utftext.charCodeAt(i);
  72002. if (c < 128) {
  72003. string += String.fromCharCode(c);
  72004. i++;
  72005. } else if ((c > 191) && (c < 224)) {
  72006. c2 = utftext.charCodeAt(i + 1);
  72007. string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
  72008. i += 2;
  72009. } else {
  72010. c2 = utftext.charCodeAt(i + 1);
  72011. c3 = utftext.charCodeAt(i + 2);
  72012. string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
  72013. i += 3;
  72014. }
  72015. }
  72016. return string;
  72017. }
  72018. });
  72019. Ext.define('Ext.util.CSS', function() {
  72020. var CSS,
  72021. rules = null,
  72022. doc = document,
  72023. camelRe = /(-[a-z])/gi,
  72024. camelFn = function(m, a) {
  72025. return a.charAt(1).toUpperCase();
  72026. };
  72027. return {
  72028. singleton: true,
  72029. rules: rules,
  72030. initialized: false,
  72031. constructor: function() {
  72032. CSS = this;
  72033. },
  72034. createStyleSheet: function(cssText, id) {
  72035. var ss,
  72036. head = doc.getElementsByTagName('head')[0],
  72037. styleEl = doc.createElement('style');
  72038. styleEl.setAttribute('type', 'text/css');
  72039. if (id) {
  72040. styleEl.setAttribute('id', id);
  72041. }
  72042. ss = styleEl.styleSheet;
  72043. if (ss) {
  72044. head.appendChild(styleEl);
  72045. ss.cssText = cssText;
  72046. } else {
  72047. styleEl.appendChild(doc.createTextNode(cssText));
  72048. head.appendChild(styleEl);
  72049. ss = styleEl.sheet;
  72050. }
  72051. CSS.cacheStyleSheet(ss);
  72052. return ss;
  72053. },
  72054. removeStyleSheet: function(stylesheet) {
  72055. var styleEl = (typeof stylesheet === 'string') ? doc.getElementById(stylesheet) : stylesheet.ownerNode;
  72056. if (styleEl) {
  72057. styleEl.parentNode.removeChild(styleEl);
  72058. }
  72059. },
  72060. swapStyleSheet: function(id, url) {
  72061. var ss;
  72062. CSS.removeStyleSheet(id);
  72063. ss = doc.createElement("link");
  72064. ss.setAttribute("rel", "stylesheet");
  72065. ss.setAttribute("type", "text/css");
  72066. ss.setAttribute("id", id);
  72067. ss.setAttribute("href", url);
  72068. doc.getElementsByTagName("head")[0].appendChild(ss);
  72069. },
  72070. cacheStyleSheet: function(ss) {
  72071. if (!rules) {
  72072. rules = CSS.rules = {};
  72073. }
  72074. try {
  72075. var ssRules = ss.cssRules || ss.rules,
  72076. i = ssRules.length - 1,
  72077. imports = ss.imports,
  72078. len = imports ? imports.length : 0,
  72079. rule, j;
  72080. for (j = 0; j < len; ++j) {
  72081. CSS.cacheStyleSheet(imports[j]);
  72082. }
  72083. for (; i >= 0; --i) {
  72084. rule = ssRules[i];
  72085. if (rule.styleSheet) {
  72086. CSS.cacheStyleSheet(rule.styleSheet);
  72087. }
  72088. CSS.cacheRule(rule, ss);
  72089. }
  72090. } catch (e) {}
  72091. },
  72092. cacheRule: function(cssRule, styleSheet) {
  72093. var selectorText, selectorCount, j;
  72094. if (cssRule.styleSheet) {
  72095. return CSS.cacheStyleSheet(cssRule.styleSheet);
  72096. }
  72097. selectorText = cssRule.selectorText;
  72098. if (selectorText) {
  72099. selectorText = selectorText.split(',');
  72100. selectorCount = selectorText.length;
  72101. for (j = 0; j < selectorCount; j++) {
  72102. rules[Ext.String.trim(selectorText[j]).toLowerCase()] = {
  72103. parentStyleSheet: styleSheet,
  72104. cssRule: cssRule
  72105. };
  72106. }
  72107. }
  72108. },
  72109. getRules: function(refreshCache) {
  72110. var result = {},
  72111. selector;
  72112. if (rules === null || refreshCache) {
  72113. CSS.refreshCache();
  72114. }
  72115. for (selector in rules) {
  72116. result[selector] = rules[selector].cssRule;
  72117. }
  72118. return result;
  72119. },
  72120. refreshCache: function() {
  72121. var ds = doc.styleSheets,
  72122. i = 0,
  72123. len = ds.length;
  72124. rules = CSS.rules = {};
  72125. for (; i < len; i++) {
  72126. try {
  72127. if (!ds[i].disabled) {
  72128. CSS.cacheStyleSheet(ds[i]);
  72129. }
  72130. } catch (e) {}
  72131. }
  72132. },
  72133. getRule: function(selector, refreshCache, rawCache) {
  72134. var i, result;
  72135. if (!rules || refreshCache) {
  72136. CSS.refreshCache();
  72137. }
  72138. if (!Ext.isArray(selector)) {
  72139. result = rules[selector.toLowerCase()];
  72140. if (result && !rawCache) {
  72141. result = result.cssRule;
  72142. }
  72143. return result || null;
  72144. }
  72145. for (i = 0; i < selector.length; i++) {
  72146. if (rules[selector[i]]) {
  72147. return rawCache ? rules[selector[i].toLowerCase()] : rules[selector[i].toLowerCase()].cssRule;
  72148. }
  72149. }
  72150. return null;
  72151. },
  72152. createRule: function(styleSheet, selector, cssText) {
  72153. var result,
  72154. ruleSet = styleSheet.cssRules || styleSheet.rules,
  72155. index = ruleSet.length;
  72156. if (styleSheet.insertRule) {
  72157. styleSheet.insertRule(selector + ' {' + cssText + '}', index);
  72158. } else {
  72159. styleSheet.addRule(selector, cssText || ' ');
  72160. }
  72161. CSS.cacheRule(result = ruleSet[index], styleSheet);
  72162. return result;
  72163. },
  72164. updateRule: function(selector, property, value) {
  72165. var rule, i, styles;
  72166. if (!Ext.isArray(selector)) {
  72167. rule = CSS.getRule(selector);
  72168. if (rule) {
  72169. if (arguments.length === 2) {
  72170. styles = Ext.Element.parseStyles(property);
  72171. for (property in styles) {
  72172. rule.style[property.replace(camelRe, camelFn)] = styles[property];
  72173. }
  72174. } else {
  72175. rule.style[property.replace(camelRe, camelFn)] = value;
  72176. }
  72177. return true;
  72178. }
  72179. } else {
  72180. for (i = 0; i < selector.length; i++) {
  72181. if (CSS.updateRule(selector[i], property, value)) {
  72182. return true;
  72183. }
  72184. }
  72185. }
  72186. return false;
  72187. },
  72188. deleteRule: function(selector) {
  72189. var rule = CSS.getRule(selector, false, true),
  72190. styleSheet, index;
  72191. if (rule) {
  72192. styleSheet = rule.parentStyleSheet;
  72193. index = Ext.Array.indexOf(styleSheet.cssRules || styleSheet.rules, rule.cssRule);
  72194. if (styleSheet.deleteRule) {
  72195. styleSheet.deleteRule(index);
  72196. } else {
  72197. styleSheet.removeRule(index);
  72198. }
  72199. delete rules[selector];
  72200. }
  72201. }
  72202. };
  72203. });
  72204. Ext.define('Ext.util.DelimitedValue', {
  72205. dateFormat: 'C',
  72206. delimiter: '\t',
  72207. lineBreak: '\n',
  72208. quote: '"',
  72209. lineBreakRe: /\r?\n/g,
  72210. lastLineBreakRe: /(\r?\n|\r)$/,
  72211. constructor: function(config) {
  72212. if (config) {
  72213. Ext.apply(this, config);
  72214. }
  72215. this.parseREs = {};
  72216. this.quoteREs = {};
  72217. },
  72218. decode: function(input, delimiter, quoteChar) {
  72219. if (!input) {
  72220. return [];
  72221. }
  72222. var me = this,
  72223. row = [],
  72224. result = [
  72225. row
  72226. ],
  72227. quote = quoteChar !== undefined ? quoteChar : me.quote,
  72228. quoteREs = me.quoteREs,
  72229. parseREs = me.parseREs,
  72230. parseRE, dblQuoteRE, arrMatches, strMatchedDelimiter, strMatchedValue;
  72231. delimiter = delimiter || me.delimiter;
  72232. parseRE = parseREs[delimiter] || new RegExp(
  72233. '(\\' + delimiter + '|\\r?\\n|\\r|^)' +
  72234. '(?:\\' + quote + '([^\\' + quote + ']*(?:\\' + quote + '\\' + quote + '[^\\' + quote + ']*)*)\\' + quote + '|' +
  72235. '([^\\' + delimiter + '\\r\\n]*))', 'gi');
  72236. dblQuoteRE = quoteREs[quote] || (quoteREs[quote] = new RegExp('\\' + quote + '\\' + quote, 'g'));
  72237. while ((arrMatches = parseRE.exec(input))) {
  72238. strMatchedDelimiter = arrMatches[1];
  72239. if (strMatchedDelimiter.length && strMatchedDelimiter !== delimiter) {
  72240. result.push(row = []);
  72241. }
  72242. if (!arrMatches.index && arrMatches[0].charAt(0) === delimiter) {
  72243. row.push('');
  72244. }
  72245. if (arrMatches[2]) {
  72246. strMatchedValue = arrMatches[2].replace(dblQuoteRE, quote);
  72247. } else {
  72248. strMatchedValue = arrMatches[3];
  72249. }
  72250. row.push(strMatchedValue);
  72251. }
  72252. return result;
  72253. },
  72254. encode: function(input, delimiter, quoteChar) {
  72255. var me = this,
  72256. delim = delimiter || me.delimiter,
  72257. dateFormat = me.dateFormat,
  72258. quote = quoteChar !== undefined ? quoteChar : me.quote,
  72259. twoQuotes = quote + quote,
  72260. rowIndex = input.length,
  72261. lineBreakRe = me.lineBreakRe,
  72262. result = [],
  72263. outputRow = [],
  72264. col, columnIndex, inputRow;
  72265. while (rowIndex-- > 0) {
  72266. inputRow = input[rowIndex];
  72267. outputRow.length = columnIndex = inputRow.length;
  72268. while (columnIndex-- > 0) {
  72269. col = inputRow[columnIndex];
  72270. if (col == null) {
  72271. col = '';
  72272. } else if (typeof col === 'string') {
  72273. if (col && quote !== null) {
  72274. if (col.indexOf(quote) > -1) {
  72275. col = quote + col.split(quote).join(twoQuotes) + quote;
  72276. } else if (col.indexOf(delim) > -1 || lineBreakRe.test(col)) {
  72277. col = quote + col + quote;
  72278. }
  72279. }
  72280. } else if (Ext.isDate(col)) {
  72281. col = Ext.Date.format(col, dateFormat);
  72282. }
  72283. else if (col && (isNaN(col) || Ext.isArray(col))) {
  72284. Ext.raise('Cannot serialize ' + Ext.typeOf(col) + ' into CSV');
  72285. }
  72286. outputRow[columnIndex] = col;
  72287. }
  72288. result[rowIndex] = outputRow.join(delim);
  72289. }
  72290. return result.join(me.lineBreak);
  72291. }
  72292. });
  72293. Ext.define('Ext.util.CSV', {
  72294. extend: Ext.util.DelimitedValue,
  72295. singleton: true,
  72296. delimiter: ','
  72297. });
  72298. Ext.define('Ext.util.ClickRepeater', {
  72299. alternateClassName: 'Ext.util.TapRepeater',
  72300. mixins: [
  72301. Ext.mixin.Observable
  72302. ],
  72303. config: {
  72304. el: null,
  72305. target: null,
  72306. disabled: null
  72307. },
  72308. interval: 20,
  72309. delay: 250,
  72310. preventDefault: true,
  72311. stopDefault: false,
  72312. timer: 0,
  72313. handler: null,
  72314. scope: null,
  72315. constructor: function(config) {
  72316. var me = this;
  72317. if (arguments.length === 2) {
  72318. me.setEl(config);
  72319. config = arguments[1];
  72320. }
  72321. me.mixins.observable.constructor.call(this, config);
  72322. },
  72323. destroy: function() {
  72324. this.setEl(null);
  72325. this.callParent();
  72326. },
  72327. privates: {
  72328. fireClick: function(e) {
  72329. var me = this;
  72330. me.fireEvent("click", me, e);
  72331. Ext.callback(me.handler, me.scope, [
  72332. me,
  72333. e
  72334. ], 0, me.getTarget());
  72335. },
  72336. updateDisabled: function(disabled) {
  72337. var me = this;
  72338. if (disabled) {
  72339. me.savedEl = me.getEl();
  72340. me.setEl(null);
  72341. } else if (me.savedEl) {
  72342. me.setEl(me.savedEl);
  72343. }
  72344. },
  72345. updateTarget: function(target) {
  72346. this.setEl(target.el);
  72347. },
  72348. updateEl: function(newEl, oldEl) {
  72349. var me = this,
  72350. elListeners;
  72351. if (oldEl) {
  72352. oldEl.selectable();
  72353. Ext.undefer(me.timer);
  72354. if (me.pressedCls) {
  72355. oldEl.removeCls(me.pressedCls);
  72356. }
  72357. Ext.getDoc().un('mouseup', me.handleMouseUp, me);
  72358. me.elListeners = Ext.destroy(me.elListeners);
  72359. }
  72360. if (newEl) {
  72361. newEl.unselectable();
  72362. elListeners = {
  72363. mousedown: me.handleMouseDown,
  72364. scope: me,
  72365. destroyable: true
  72366. };
  72367. if (me.preventDefault || me.stopDefault) {
  72368. elListeners.click = me.eventOptions;
  72369. }
  72370. me.elListeners = newEl.on(elListeners);
  72371. }
  72372. },
  72373. eventOptions: function(e) {
  72374. if (this.preventDefault) {
  72375. e.preventDefault();
  72376. }
  72377. if (this.stopDefault) {
  72378. e.stopEvent();
  72379. }
  72380. },
  72381. handleMouseDown: function(e) {
  72382. var me = this,
  72383. el = me.getEl();
  72384. Ext.undefer(me.timer);
  72385. if (me.pressedCls) {
  72386. el.addCls(me.pressedCls);
  72387. }
  72388. me.mousedownTime = Ext.now();
  72389. if (e.pointerType === 'mouse') {
  72390. el.on("mouseout", me.handleMouseOut, me);
  72391. }
  72392. Ext.getDoc().on("mouseup", me.handleMouseUp, me);
  72393. me.fireEvent("mousedown", me, e);
  72394. me.fireClick(e);
  72395. if (me.accelerate) {
  72396. me.delay = 400;
  72397. }
  72398. me.timer = Ext.defer(me.click, me.delay || me.interval, me, [
  72399. e
  72400. ]);
  72401. if (me.mousedownPreventDefault) {
  72402. e.preventDefault();
  72403. }
  72404. if (me.mousedownStopEvent) {
  72405. e.stopEvent();
  72406. }
  72407. },
  72408. click: function(e) {
  72409. var me = this;
  72410. me.fireClick(e);
  72411. me.timer = Ext.defer(me.click, me.accelerate ? me.easeOutExpo(Ext.now() - me.mousedownTime, 400, -390, 12000) : me.interval, me, [
  72412. e
  72413. ]);
  72414. },
  72415. easeOutExpo: function(t, b, c, d) {
  72416. return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
  72417. },
  72418. handleMouseOut: function() {
  72419. var me = this,
  72420. el = me.getEl();
  72421. Ext.undefer(me.timer);
  72422. if (me.pressedCls) {
  72423. el.removeCls(me.pressedCls);
  72424. }
  72425. el.on("mouseover", me.handleMouseReturn, me);
  72426. },
  72427. handleMouseReturn: function(e) {
  72428. var me = this,
  72429. el = me.getEl();
  72430. el.un("mouseover", me.handleMouseReturn, me);
  72431. if (me.pressedCls) {
  72432. el.addCls(me.pressedCls);
  72433. }
  72434. me.click(e);
  72435. },
  72436. handleMouseUp: function(e) {
  72437. var me = this,
  72438. el = me.getEl();
  72439. Ext.undefer(me.timer);
  72440. el.un("mouseover", me.handleMouseReturn, me);
  72441. el.un("mouseout", me.handleMouseOut, me);
  72442. Ext.getDoc().un("mouseup", me.handleMouseUp, me);
  72443. if (me.pressedCls) {
  72444. el.removeCls(me.pressedCls);
  72445. }
  72446. me.fireEvent("mouseup", me, e);
  72447. }
  72448. }
  72449. });
  72450. Ext.define('Ext.util.Cookies', {
  72451. singleton: true,
  72452. set: function(name, value) {
  72453. var argv = arguments,
  72454. argc = argv.length,
  72455. expires = (argc > 2) ? argv[2] : null,
  72456. path = (argc > 3) ? argv[3] : '/',
  72457. domain = (argc > 4) ? argv[4] : null,
  72458. secure = (argc > 5) ? argv[5] : false;
  72459. document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toUTCString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
  72460. },
  72461. get: function(name) {
  72462. var parts = document.cookie.split('; '),
  72463. len = parts.length,
  72464. item, i, ret;
  72465. for (i = 0; i < len; ++i) {
  72466. item = parts[i].split('=');
  72467. if (item[0] === name) {
  72468. ret = item[1];
  72469. return ret ? unescape(ret) : '';
  72470. }
  72471. }
  72472. return null;
  72473. },
  72474. clear: function(name, path) {
  72475. if (this.get(name)) {
  72476. path = path || '/';
  72477. document.cookie = name + '=' + '; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=' + path;
  72478. }
  72479. }
  72480. });
  72481. Ext.define('Ext.util.LocalStorage', {
  72482. id: null,
  72483. destroyed: false,
  72484. lazyKeys: true,
  72485. prefix: '',
  72486. session: false,
  72487. _keys: null,
  72488. _store: null,
  72489. _users: 0,
  72490. statics: {
  72491. cache: {},
  72492. get: function(id) {
  72493. var me = this,
  72494. cache = me.cache,
  72495. config = {
  72496. _users: 1
  72497. },
  72498. instance;
  72499. if (Ext.isString(id)) {
  72500. config.id = id;
  72501. } else {
  72502. Ext.apply(config, id);
  72503. }
  72504. if (!(instance = cache[config.id])) {
  72505. instance = new me(config);
  72506. } else {
  72507. if (instance === true) {
  72508. Ext.raise('Creating a shared instance of private local store "' + me.id + '".');
  72509. }
  72510. ++instance._users;
  72511. }
  72512. return instance;
  72513. },
  72514. supported: true
  72515. },
  72516. constructor: function(config) {
  72517. var me = this;
  72518. Ext.apply(me, config);
  72519. if (!me.hasOwnProperty('id')) {
  72520. Ext.raise("No id was provided to the local store.");
  72521. }
  72522. if (me._users) {
  72523. Ext.util.LocalStorage.cache[me.id] = me;
  72524. } else
  72525. {
  72526. if (Ext.util.LocalStorage.cache[me.id]) {
  72527. Ext.raise('Cannot create duplicate instance of local store "' + me.id + '". Use Ext.util.LocalStorage.get() to share instances.');
  72528. }
  72529. Ext.util.LocalStorage.cache[me.id] = true;
  72530. }
  72531. me.init();
  72532. },
  72533. init: function() {
  72534. var me = this,
  72535. id = me.id;
  72536. if (!me.prefix && id) {
  72537. me.prefix = id + '-';
  72538. }
  72539. me._store = (me.session ? window.sessionStorage : window.localStorage);
  72540. },
  72541. destroy: function() {
  72542. var me = this;
  72543. if (me._users) {
  72544. Ext.log.warn('LocalStorage(id=' + me.id + ') destroyed while in use');
  72545. }
  72546. delete Ext.util.LocalStorage.cache[me.id];
  72547. me._store = me._keys = null;
  72548. me.callParent();
  72549. },
  72550. getKeys: function() {
  72551. var me = this,
  72552. store = me._store,
  72553. prefix = me.prefix,
  72554. keys = me._keys,
  72555. n = prefix.length,
  72556. i, key;
  72557. if (!keys) {
  72558. me._keys = keys = [];
  72559. for (i = store.length; i--; ) {
  72560. key = store.key(i);
  72561. if (key.length > n) {
  72562. if (prefix === key.substring(0, n)) {
  72563. keys.push(key.substring(n));
  72564. }
  72565. }
  72566. }
  72567. }
  72568. return keys;
  72569. },
  72570. release: function() {
  72571. if (!--this._users) {
  72572. this.destroy();
  72573. }
  72574. },
  72575. save: Ext.emptyFn,
  72576. clear: function() {
  72577. var me = this,
  72578. store = me._store,
  72579. prefix = me.prefix,
  72580. keys = me._keys || me.getKeys(),
  72581. i;
  72582. for (i = keys.length; i--; ) {
  72583. store.removeItem(prefix + keys[i]);
  72584. }
  72585. keys.length = 0;
  72586. },
  72587. key: function(index) {
  72588. var keys = this._keys || this.getKeys();
  72589. return (0 <= index && index < keys.length) ? keys[index] : null;
  72590. },
  72591. getItem: function(key) {
  72592. var k = this.prefix + key;
  72593. return this._store.getItem(k);
  72594. },
  72595. removeItem: function(key) {
  72596. var me = this,
  72597. k = me.prefix + key,
  72598. store = me._store,
  72599. keys = me._keys,
  72600. length = store.length;
  72601. store.removeItem(k);
  72602. if (keys && length !== store.length) {
  72603. if (me.lazyKeys) {
  72604. me._keys = null;
  72605. } else {
  72606. Ext.Array.remove(keys, key);
  72607. }
  72608. }
  72609. },
  72610. setItem: function(key, value) {
  72611. var me = this,
  72612. k = me.prefix + key,
  72613. store = me._store,
  72614. length = store.length,
  72615. keys = me._keys;
  72616. store.setItem(k, value);
  72617. if (keys && length !== store.length) {
  72618. keys.push(key);
  72619. }
  72620. }
  72621. });
  72622. Ext.define('Ext.util.Spans', {
  72623. isSpans: true,
  72624. constructor: function() {
  72625. this.spans = this.spans || [];
  72626. },
  72627. clear: function() {
  72628. this.spans.length = 0;
  72629. return this;
  72630. },
  72631. add: function(begin, end) {
  72632. if (end === undefined) {
  72633. if (typeof begin === 'number') {
  72634. end = begin + 1;
  72635. } else {
  72636. end = begin[1];
  72637. begin = begin[0];
  72638. }
  72639. }
  72640. var me = this,
  72641. spans = me.spans,
  72642. b, e, first, last, span;
  72643. first = me.bisect(begin);
  72644. if (first) {
  72645. span = spans[first - 1];
  72646. b = span[0];
  72647. e = span[1];
  72648. if (begin <= e) {
  72649. if (end <= e) {
  72650. return false;
  72651. }
  72652. begin = b;
  72653. spans.splice(--first, 1);
  72654. }
  72655. }
  72656. last = me.bisect(end);
  72657. if (last > first) {
  72658. span = spans[last - 1];
  72659. end = Math.max(end, span[1]);
  72660. }
  72661. if (last < spans.length) {
  72662. span = spans[last];
  72663. if (end === span[0]) {
  72664. end = span[1];
  72665. ++last;
  72666. }
  72667. }
  72668. spans.splice(first, last - first, [
  72669. begin,
  72670. end
  72671. ]);
  72672. return true;
  72673. },
  72674. contains: function(begin, end) {
  72675. if (end === undefined) {
  72676. if (typeof begin === 'number') {
  72677. end = begin + 1;
  72678. } else {
  72679. end = begin[1];
  72680. begin = begin[0];
  72681. }
  72682. }
  72683. var spans = this.spans,
  72684. index = this.bisect(begin),
  72685. ret = false,
  72686. e, span;
  72687. if (index && begin < (e = spans[index - 1][1])) {
  72688. ret = end <= e;
  72689. } else if (index < spans.length) {
  72690. span = spans[index];
  72691. ret = span[0] <= begin && end <= span[1];
  72692. }
  72693. return ret;
  72694. },
  72695. each: function(fn, scope) {
  72696. var spans = this.spans,
  72697. len = spans.length,
  72698. i, span, j;
  72699. for (i = 0; i < len; i++) {
  72700. span = spans[i];
  72701. for (j = span[0]; j < span[1]; j++) {
  72702. if (fn.call(scope || this, i) === false) {
  72703. return;
  72704. }
  72705. }
  72706. }
  72707. },
  72708. intersects: function(begin, end) {
  72709. if (end === undefined) {
  72710. if (typeof begin === 'number') {
  72711. end = begin + 1;
  72712. } else {
  72713. end = begin[1];
  72714. begin = begin[0];
  72715. }
  72716. }
  72717. var spans = this.spans,
  72718. index = this.bisect(begin),
  72719. ret = false;
  72720. if (index && begin < spans[index - 1][1]) {
  72721. ret = true;
  72722. } else if (index < spans.length) {
  72723. ret = spans[index][0] < end;
  72724. }
  72725. return ret;
  72726. },
  72727. remove: function(begin, end) {
  72728. if (end === undefined) {
  72729. if (typeof begin === 'number') {
  72730. end = begin + 1;
  72731. } else {
  72732. end = begin[1];
  72733. begin = begin[0];
  72734. }
  72735. }
  72736. var me = this,
  72737. spans = me.spans,
  72738. first = me.bisect(begin),
  72739. ret = false,
  72740. last, span, tmp;
  72741. if (first) {
  72742. span = spans[first - 1];
  72743. tmp = span[1];
  72744. if (begin < tmp) {
  72745. span[1] = begin;
  72746. if (end < tmp) {
  72747. spans.splice(first, 0, [
  72748. end,
  72749. tmp
  72750. ]);
  72751. return true;
  72752. }
  72753. ret = true;
  72754. }
  72755. }
  72756. last = me.bisect(end);
  72757. if (first < last) {
  72758. ret = true;
  72759. span = spans[last - 1];
  72760. if (end < span[1]) {
  72761. span[0] = end;
  72762. --last;
  72763. }
  72764. last -= first;
  72765. if (last) {
  72766. spans.splice(first, last);
  72767. }
  72768. }
  72769. return ret;
  72770. },
  72771. stash: function() {
  72772. return this.spans.slice();
  72773. },
  72774. unstash: function(pickle) {
  72775. this.spans = pickle;
  72776. return this;
  72777. },
  72778. getCount: function() {
  72779. var spans = this.spans,
  72780. len = spans.length,
  72781. result = 0,
  72782. i, span;
  72783. for (i = 0; i < len; i++) {
  72784. span = spans[i];
  72785. result += span[1] - span[0];
  72786. }
  72787. return result;
  72788. },
  72789. privates: {
  72790. bisect: function(value) {
  72791. return Ext.Number.bisectTuples(this.spans, value, 0);
  72792. }
  72793. }
  72794. });
  72795. Ext.define('Ext.util.TsvDecoder', {
  72796. extend: Ext.util.DelimitedValue,
  72797. alternateClassName: 'Ext.util.TSV',
  72798. delimiter: '\t'
  72799. }, function(TSVClass) {
  72800. Ext.util.TSV = new TSVClass();
  72801. });
  72802. Ext.define('Ext.util.TaskManager', {
  72803. extend: Ext.util.TaskRunner,
  72804. alternateClassName: [
  72805. 'Ext.TaskManager'
  72806. ],
  72807. singleton: true
  72808. });
  72809. Ext.define('Ext.util.TextMetrics', {
  72810. statics: {
  72811. shared: null,
  72812. measure: function(el, text, fixedWidth) {
  72813. var me = this,
  72814. shared = me.shared || (me.shared = new me(el, fixedWidth));
  72815. shared.bind(el);
  72816. shared.setFixedWidth(fixedWidth || 'auto');
  72817. return shared.getSize(text);
  72818. },
  72819. destroy: function() {
  72820. this.shared = Ext.destroy(this.shared);
  72821. }
  72822. },
  72823. constructor: function(bindTo, fixedWidth) {
  72824. var me = this,
  72825. measure = me.measure = Ext.getBody().createChild({
  72826. 'data-sticky': true,
  72827. role: 'presentation',
  72828. cls: Ext.baseCSSPrefix + 'textmetrics',
  72829. style: {
  72830. position: 'absolute',
  72831. left: '-1000px',
  72832. top: '-1000px',
  72833. visibility: 'hidden'
  72834. }
  72835. });
  72836. if (bindTo) {
  72837. me.bind(bindTo);
  72838. }
  72839. if (fixedWidth) {
  72840. measure.setWidth(fixedWidth);
  72841. }
  72842. },
  72843. getSize: function(text) {
  72844. var measure = this.measure,
  72845. size;
  72846. measure.setHtml(text);
  72847. size = measure.getSize();
  72848. measure.setHtml('');
  72849. return size;
  72850. },
  72851. bind: function(el) {
  72852. this.measure.setStyle(
  72853. (this.el || (this.self.prototype.el = new Ext.dom.Fly())).attach(el).getStyle([
  72854. 'font-size',
  72855. 'font-size-adjust',
  72856. 'font-style',
  72857. 'font-weight',
  72858. 'font-family',
  72859. 'font-kerning',
  72860. 'font-stretch',
  72861. 'line-height',
  72862. 'text-transform',
  72863. 'text-decoration',
  72864. 'letter-spacing',
  72865. 'word-break'
  72866. ]));
  72867. },
  72868. setFixedWidth: function(width) {
  72869. this.measure.setWidth(width);
  72870. },
  72871. getWidth: function(text) {
  72872. this.measure.dom.style.width = 'auto';
  72873. return this.getSize(text).width;
  72874. },
  72875. getHeight: function(text) {
  72876. return this.getSize(text).height;
  72877. },
  72878. destroy: function() {
  72879. var me = this;
  72880. me.el = me.measure = Ext.destroy(me.measure);
  72881. me.callParent();
  72882. }
  72883. }, function() {
  72884. Ext.Element.override({
  72885. getTextWidth: function(text, min, max) {
  72886. return Ext.Number.constrain(Ext.util.TextMetrics.measure(this.dom, Ext.valueFrom(text, this.dom.innerHTML, true)).width, min || 0, max || 1000000);
  72887. }
  72888. });
  72889. });
  72890. Ext.define('Ext.util.paintmonitor.OverflowChange', {
  72891. extend: Ext.util.paintmonitor.Abstract,
  72892. eventName: Ext.browser.is.Firefox ? 'overflow' : 'overflowchanged',
  72893. monitorClass: 'overflowchange',
  72894. onElementPainted: function(e) {
  72895. this.getCallback().apply(this.getScope(), this.getArgs());
  72896. }
  72897. });
  72898. Ext.define('Ext.util.sizemonitor.OverflowChange', {
  72899. extend: Ext.util.sizemonitor.Abstract,
  72900. constructor: function(config) {
  72901. this.onExpand = this.onExpand.bind(this);
  72902. this.onShrink = this.onShrink.bind(this);
  72903. this.callParent(arguments);
  72904. },
  72905. getElementConfig: function() {
  72906. return {
  72907. reference: 'detectorsContainer',
  72908. classList: [
  72909. Ext.baseCSSPrefix + 'size-monitors',
  72910. 'overflowchanged'
  72911. ],
  72912. children: [
  72913. {
  72914. reference: 'expandMonitor',
  72915. className: 'expand',
  72916. children: [
  72917. {
  72918. reference: 'expandHelper'
  72919. }
  72920. ]
  72921. },
  72922. {
  72923. reference: 'shrinkMonitor',
  72924. className: 'shrink',
  72925. children: [
  72926. {
  72927. reference: 'shrinkHelper'
  72928. }
  72929. ]
  72930. }
  72931. ]
  72932. };
  72933. },
  72934. bindListeners: function(bind) {
  72935. var method = bind ? 'addEventListener' : 'removeEventListener';
  72936. this.expandMonitor[method](Ext.browser.is.Firefox ? 'underflow' : 'overflowchanged', this.onExpand, true);
  72937. this.shrinkMonitor[method](Ext.browser.is.Firefox ? 'overflow' : 'overflowchanged', this.onShrink, true);
  72938. },
  72939. onExpand: function(e) {
  72940. if (!(this.destroyed || (Ext.browser.is.Webkit && e.horizontalOverflow && e.verticalOverflow))) {
  72941. Ext.TaskQueue.requestRead('refresh', this);
  72942. }
  72943. },
  72944. onShrink: function(e) {
  72945. if (!(this.destroyed || (Ext.browser.is.Webkit && !e.horizontalOverflow && !e.verticalOverflow))) {
  72946. Ext.TaskQueue.requestRead('refresh', this);
  72947. }
  72948. },
  72949. refreshMonitors: function() {
  72950. if (this.destroying || this.destroyed) {
  72951. return;
  72952. }
  72953. var expandHelper = this.expandHelper,
  72954. shrinkHelper = this.shrinkHelper,
  72955. contentBounds = this.getContentBounds(),
  72956. width = contentBounds.width,
  72957. height = contentBounds.height,
  72958. style;
  72959. if (expandHelper && !expandHelper.destroyed) {
  72960. style = expandHelper.style;
  72961. style.width = (width + 1) + 'px';
  72962. style.height = (height + 1) + 'px';
  72963. }
  72964. if (shrinkHelper && !shrinkHelper.destroyed) {
  72965. style = shrinkHelper.style;
  72966. style.width = width + 'px';
  72967. style.height = height + 'px';
  72968. }
  72969. Ext.TaskQueue.requestRead('refresh', this);
  72970. },
  72971. destroy: function() {
  72972. this.onExpand = this.onShrink = null;
  72973. this.callParent();
  72974. }
  72975. });
  72976. Ext.define('Ext.util.translatable.ScrollParent', {
  72977. extend: Ext.util.translatable.Dom,
  72978. alias: 'translatable.scrollparent',
  72979. isScrollParent: true,
  72980. applyElement: function(element) {
  72981. var el = Ext.get(element);
  72982. if (el) {
  72983. this.parent = el.parent();
  72984. }
  72985. return el;
  72986. },
  72987. doTranslate: function(x, y) {
  72988. var parent = this.parent;
  72989. parent.setScrollLeft(Math.round(-x));
  72990. parent.setScrollTop(Math.round(-y));
  72991. },
  72992. getPosition: function() {
  72993. var me = this,
  72994. position = me.position,
  72995. parent = me.parent;
  72996. position.x = parent.getScrollLeft();
  72997. position.y = parent.getScrollTop();
  72998. return position;
  72999. }
  73000. });
  73001. Ext.define('Ext.util.translatable.ScrollPosition', {
  73002. extend: Ext.util.translatable.Dom,
  73003. alias: 'translatable.scrollposition',
  73004. constructor: function(config) {
  73005. if (config && config.element) {
  73006. this.x = config.element.getScrollLeft();
  73007. this.y = config.element.getScrollTop();
  73008. }
  73009. this.callParent([
  73010. config
  73011. ]);
  73012. },
  73013. translateAnimated: function() {
  73014. var element = this.getElement();
  73015. this.x = element.getScrollLeft();
  73016. this.y = element.getScrollTop();
  73017. this.callParent(arguments);
  73018. },
  73019. doTranslate: function(x, y) {
  73020. var element = this.getElement();
  73021. element.setScrollLeft(Math.round(x));
  73022. element.setScrollTop(Math.round(y));
  73023. },
  73024. getPosition: function() {
  73025. var me = this,
  73026. position = me.position,
  73027. element = me.getElement();
  73028. position.x = element.getScrollLeft();
  73029. position.y = element.getScrollTop();
  73030. return position;
  73031. }
  73032. });
  73033. Ext.ClassManager.addNameAlternateMappings({
  73034. "Ext.AbstractComponent": [],
  73035. "Ext.AbstractManager": [],
  73036. "Ext.ActionSheet": [],
  73037. "Ext.Ajax": [],
  73038. "Ext.Anim": [],
  73039. "Ext.AnimationQueue": [],
  73040. "Ext.Audio": [],
  73041. "Ext.BreadcrumbBar": [],
  73042. "Ext.Button": [],
  73043. "Ext.Chip": [],
  73044. "Ext.Component": [
  73045. "Ext.lib.Component",
  73046. "Ext.Gadget"
  73047. ],
  73048. "Ext.ComponentManager": [
  73049. "Ext.ComponentMgr"
  73050. ],
  73051. "Ext.ComponentQuery": [],
  73052. "Ext.Container": [
  73053. "Ext.lib.Container",
  73054. "Ext.container.Container"
  73055. ],
  73056. "Ext.Decorator": [],
  73057. "Ext.Deferred": [],
  73058. "Ext.Dialog": [
  73059. "Ext.Window",
  73060. "Ext.window.Window"
  73061. ],
  73062. "Ext.Editor": [],
  73063. "Ext.Evented": [
  73064. "Ext.EventedBase"
  73065. ],
  73066. "Ext.GlobalEvents": [
  73067. "Ext.globalEvents"
  73068. ],
  73069. "Ext.Glyph": [],
  73070. "Ext.Img": [
  73071. "Ext.Image"
  73072. ],
  73073. "Ext.Indicator": [],
  73074. "Ext.Label": [],
  73075. "Ext.LoadMask": [],
  73076. "Ext.Mask": [],
  73077. "Ext.Media": [],
  73078. "Ext.MessageBox": [],
  73079. "Ext.Mixin": [],
  73080. "Ext.Panel": [
  73081. "Ext.panel.Panel"
  73082. ],
  73083. "Ext.Progress": [
  73084. "Ext.ProgressBarWidget"
  73085. ],
  73086. "Ext.ProgressBase": [],
  73087. "Ext.Promise": [],
  73088. "Ext.Responsive": [],
  73089. "Ext.SegmentedButton": [
  73090. "Ext.button.Segmented"
  73091. ],
  73092. "Ext.Sheet": [],
  73093. "Ext.Spacer": [],
  73094. "Ext.SplitButton": [],
  73095. "Ext.Stateful": [],
  73096. "Ext.TaskQueue": [],
  73097. "Ext.Template": [],
  73098. "Ext.Title": [],
  73099. "Ext.TitleBar": [],
  73100. "Ext.Toast": [],
  73101. "Ext.Tool": [
  73102. "Ext.panel.Tool"
  73103. ],
  73104. "Ext.Toolbar": [],
  73105. "Ext.Video": [],
  73106. "Ext.Widget": [
  73107. "Ext.Gadget"
  73108. ],
  73109. "Ext.XTemplate": [],
  73110. "Ext.app.Application": [],
  73111. "Ext.app.BaseController": [],
  73112. "Ext.app.Controller": [],
  73113. "Ext.app.EventBus": [],
  73114. "Ext.app.EventDomain": [],
  73115. "Ext.app.Profile": [],
  73116. "Ext.app.Util": [],
  73117. "Ext.app.ViewController": [],
  73118. "Ext.app.ViewModel": [],
  73119. "Ext.app.bind.AbstractStub": [],
  73120. "Ext.app.bind.BaseBinding": [],
  73121. "Ext.app.bind.Binding": [],
  73122. "Ext.app.bind.Formula": [],
  73123. "Ext.app.bind.LinkStub": [],
  73124. "Ext.app.bind.Multi": [],
  73125. "Ext.app.bind.Parser": [],
  73126. "Ext.app.bind.RootStub": [],
  73127. "Ext.app.bind.Stub": [],
  73128. "Ext.app.bind.Template": [],
  73129. "Ext.app.bind.TemplateBinding": [],
  73130. "Ext.app.domain.Component": [],
  73131. "Ext.app.domain.Controller": [],
  73132. "Ext.app.domain.Direct": [],
  73133. "Ext.app.domain.Global": [],
  73134. "Ext.app.domain.Store": [],
  73135. "Ext.app.domain.View": [],
  73136. "Ext.behavior.Behavior": [],
  73137. "Ext.carousel.Carousel": [
  73138. "Ext.Carousel"
  73139. ],
  73140. "Ext.carousel.Infinite": [],
  73141. "Ext.carousel.Item": [],
  73142. "Ext.data.AbstractStore": [],
  73143. "Ext.data.ArrayStore": [
  73144. "Ext.data.SimpleStore"
  73145. ],
  73146. "Ext.data.Batch": [],
  73147. "Ext.data.BufferedStore": [],
  73148. "Ext.data.ChainedStore": [],
  73149. "Ext.data.ClientStore": [],
  73150. "Ext.data.Connection": [],
  73151. "Ext.data.DirectStore": [],
  73152. "Ext.data.Error": [],
  73153. "Ext.data.ErrorCollection": [
  73154. "Ext.data.Errors"
  73155. ],
  73156. "Ext.data.Group": [],
  73157. "Ext.data.JsonP": [],
  73158. "Ext.data.JsonPStore": [],
  73159. "Ext.data.JsonStore": [],
  73160. "Ext.data.LocalStore": [],
  73161. "Ext.data.Model": [
  73162. "Ext.data.Record"
  73163. ],
  73164. "Ext.data.ModelManager": [
  73165. "Ext.ModelMgr"
  73166. ],
  73167. "Ext.data.NodeInterface": [],
  73168. "Ext.data.NodeStore": [],
  73169. "Ext.data.PageMap": [],
  73170. "Ext.data.ProxyStore": [],
  73171. "Ext.data.Query": [],
  73172. "Ext.data.Range": [],
  73173. "Ext.data.Request": [],
  73174. "Ext.data.ResultSet": [],
  73175. "Ext.data.Session": [],
  73176. "Ext.data.SortTypes": [],
  73177. "Ext.data.Store": [],
  73178. "Ext.data.StoreManager": [
  73179. "Ext.StoreMgr",
  73180. "Ext.data.StoreMgr",
  73181. "Ext.StoreManager"
  73182. ],
  73183. "Ext.data.TreeModel": [],
  73184. "Ext.data.TreeStore": [],
  73185. "Ext.data.Types": [],
  73186. "Ext.data.Validation": [],
  73187. "Ext.data.XmlStore": [],
  73188. "Ext.data.field.Boolean": [],
  73189. "Ext.data.field.Date": [],
  73190. "Ext.data.field.Field": [
  73191. "Ext.data.Field"
  73192. ],
  73193. "Ext.data.field.Integer": [],
  73194. "Ext.data.field.Number": [],
  73195. "Ext.data.field.String": [],
  73196. "Ext.data.flash.BinaryXhr": [],
  73197. "Ext.data.identifier.Generator": [],
  73198. "Ext.data.identifier.Negative": [],
  73199. "Ext.data.identifier.Sequential": [],
  73200. "Ext.data.identifier.Uuid": [],
  73201. "Ext.data.matrix.Matrix": [],
  73202. "Ext.data.matrix.Side": [],
  73203. "Ext.data.matrix.Slice": [],
  73204. "Ext.data.operation.Create": [],
  73205. "Ext.data.operation.Destroy": [],
  73206. "Ext.data.operation.Operation": [
  73207. "Ext.data.Operation"
  73208. ],
  73209. "Ext.data.operation.Read": [],
  73210. "Ext.data.operation.Update": [],
  73211. "Ext.data.proxy.Ajax": [
  73212. "Ext.data.HttpProxy",
  73213. "Ext.data.AjaxProxy"
  73214. ],
  73215. "Ext.data.proxy.Client": [
  73216. "Ext.data.ClientProxy"
  73217. ],
  73218. "Ext.data.proxy.Direct": [
  73219. "Ext.data.DirectProxy"
  73220. ],
  73221. "Ext.data.proxy.JsonP": [
  73222. "Ext.data.ScriptTagProxy"
  73223. ],
  73224. "Ext.data.proxy.LocalStorage": [
  73225. "Ext.data.LocalStorageProxy"
  73226. ],
  73227. "Ext.data.proxy.Memory": [
  73228. "Ext.data.MemoryProxy"
  73229. ],
  73230. "Ext.data.proxy.Proxy": [
  73231. "Ext.data.DataProxy",
  73232. "Ext.data.Proxy"
  73233. ],
  73234. "Ext.data.proxy.Rest": [
  73235. "Ext.data.RestProxy"
  73236. ],
  73237. "Ext.data.proxy.Server": [
  73238. "Ext.data.ServerProxy"
  73239. ],
  73240. "Ext.data.proxy.SessionStorage": [
  73241. "Ext.data.SessionStorageProxy"
  73242. ],
  73243. "Ext.data.proxy.WebStorage": [
  73244. "Ext.data.WebStorageProxy"
  73245. ],
  73246. "Ext.data.query.Compiler": [],
  73247. "Ext.data.query.Converter": [],
  73248. "Ext.data.query.Parser": [],
  73249. "Ext.data.query.Stringifier": [],
  73250. "Ext.data.reader.Array": [
  73251. "Ext.data.ArrayReader"
  73252. ],
  73253. "Ext.data.reader.Json": [
  73254. "Ext.data.JsonReader"
  73255. ],
  73256. "Ext.data.reader.Reader": [
  73257. "Ext.data.Reader",
  73258. "Ext.data.DataReader"
  73259. ],
  73260. "Ext.data.reader.Xml": [
  73261. "Ext.data.XmlReader"
  73262. ],
  73263. "Ext.data.request.Ajax": [],
  73264. "Ext.data.request.Base": [],
  73265. "Ext.data.request.Form": [],
  73266. "Ext.data.schema.Association": [],
  73267. "Ext.data.schema.ManyToMany": [],
  73268. "Ext.data.schema.ManyToOne": [],
  73269. "Ext.data.schema.Namer": [],
  73270. "Ext.data.schema.OneToOne": [],
  73271. "Ext.data.schema.Role": [],
  73272. "Ext.data.schema.Schema": [],
  73273. "Ext.data.session.BatchVisitor": [],
  73274. "Ext.data.session.ChangesVisitor": [],
  73275. "Ext.data.session.ChildChangesVisitor": [],
  73276. "Ext.data.summary.Average": [],
  73277. "Ext.data.summary.Base": [],
  73278. "Ext.data.summary.Count": [],
  73279. "Ext.data.summary.Max": [],
  73280. "Ext.data.summary.Min": [],
  73281. "Ext.data.summary.None": [],
  73282. "Ext.data.summary.Sum": [],
  73283. "Ext.data.validator.AbstractDate": [],
  73284. "Ext.data.validator.Bound": [],
  73285. "Ext.data.validator.CIDRv4": [],
  73286. "Ext.data.validator.CIDRv6": [],
  73287. "Ext.data.validator.Currency": [],
  73288. "Ext.data.validator.CurrencyUS": [],
  73289. "Ext.data.validator.Date": [],
  73290. "Ext.data.validator.DateTime": [],
  73291. "Ext.data.validator.Email": [],
  73292. "Ext.data.validator.Exclusion": [],
  73293. "Ext.data.validator.Format": [],
  73294. "Ext.data.validator.IPAddress": [],
  73295. "Ext.data.validator.Inclusion": [],
  73296. "Ext.data.validator.Length": [],
  73297. "Ext.data.validator.List": [],
  73298. "Ext.data.validator.NotNull": [],
  73299. "Ext.data.validator.Number": [],
  73300. "Ext.data.validator.Phone": [],
  73301. "Ext.data.validator.Presence": [],
  73302. "Ext.data.validator.Range": [],
  73303. "Ext.data.validator.Time": [],
  73304. "Ext.data.validator.Url": [],
  73305. "Ext.data.validator.Validator": [],
  73306. "Ext.data.virtual.Group": [],
  73307. "Ext.data.virtual.Page": [],
  73308. "Ext.data.virtual.PageMap": [],
  73309. "Ext.data.virtual.Range": [],
  73310. "Ext.data.virtual.Store": [],
  73311. "Ext.data.writer.Json": [
  73312. "Ext.data.JsonWriter"
  73313. ],
  73314. "Ext.data.writer.Writer": [
  73315. "Ext.data.DataWriter",
  73316. "Ext.data.Writer"
  73317. ],
  73318. "Ext.data.writer.Xml": [
  73319. "Ext.data.XmlWriter"
  73320. ],
  73321. "Ext.dataview.Abstract": [],
  73322. "Ext.dataview.BoundList": [],
  73323. "Ext.dataview.BoundListLocation": [],
  73324. "Ext.dataview.BoundListNavigationModel": [],
  73325. "Ext.dataview.ChipView": [],
  73326. "Ext.dataview.Component": [],
  73327. "Ext.dataview.DataItem": [
  73328. "Ext.dataview.component.DataItem"
  73329. ],
  73330. "Ext.dataview.DataView": [
  73331. "Ext.DataView"
  73332. ],
  73333. "Ext.dataview.Disclosable": [],
  73334. "Ext.dataview.EmptyText": [],
  73335. "Ext.dataview.GenericItem": [],
  73336. "Ext.dataview.GroupStore": [],
  73337. "Ext.dataview.IndexBar": [
  73338. "Ext.IndexBar"
  73339. ],
  73340. "Ext.dataview.ItemHeader": [],
  73341. "Ext.dataview.List": [
  73342. "Ext.List"
  73343. ],
  73344. "Ext.dataview.ListCollapser": [],
  73345. "Ext.dataview.ListGroup": [],
  73346. "Ext.dataview.ListItem": [
  73347. "Ext.dataview.component.ListItem"
  73348. ],
  73349. "Ext.dataview.ListItemPlaceholder": [],
  73350. "Ext.dataview.Location": [],
  73351. "Ext.dataview.NavigationModel": [],
  73352. "Ext.dataview.NestedList": [
  73353. "Ext.NestedList"
  73354. ],
  73355. "Ext.dataview.Pinnable": [],
  73356. "Ext.dataview.SimpleListItem": [
  73357. "Ext.dataview.component.SimpleListItem"
  73358. ],
  73359. "Ext.dataview.listswiper.Accordion": [],
  73360. "Ext.dataview.listswiper.Item": [],
  73361. "Ext.dataview.listswiper.ListSwiper": [],
  73362. "Ext.dataview.listswiper.Stepper": [],
  73363. "Ext.dataview.plugin.ItemTip": [],
  73364. "Ext.dataview.plugin.ListPaging": [
  73365. "Ext.plugin.ListPaging"
  73366. ],
  73367. "Ext.dataview.plugin.SortableList": [
  73368. "Ext.plugin.SortableList"
  73369. ],
  73370. "Ext.dataview.pullrefresh.Bar": [],
  73371. "Ext.dataview.pullrefresh.Item": [],
  73372. "Ext.dataview.pullrefresh.PullRefresh": [
  73373. "Ext.plugin.PullRefresh"
  73374. ],
  73375. "Ext.dataview.pullrefresh.Spinner": [],
  73376. "Ext.dataview.selection.Model": [],
  73377. "Ext.dataview.selection.Records": [],
  73378. "Ext.dataview.selection.Rows": [],
  73379. "Ext.dataview.selection.Selection": [],
  73380. "Ext.dd.Manager": [],
  73381. "Ext.dd.ScrollManager": [],
  73382. "Ext.direct.Event": [],
  73383. "Ext.direct.ExceptionEvent": [],
  73384. "Ext.direct.JsonProvider": [],
  73385. "Ext.direct.Manager": [],
  73386. "Ext.direct.PollingProvider": [],
  73387. "Ext.direct.Provider": [],
  73388. "Ext.direct.RemotingEvent": [],
  73389. "Ext.direct.RemotingMethod": [],
  73390. "Ext.direct.RemotingProvider": [],
  73391. "Ext.direct.Transaction": [],
  73392. "Ext.dom.CompositeElement": [
  73393. "Ext.CompositeElement"
  73394. ],
  73395. "Ext.dom.CompositeElementLite": [
  73396. "Ext.CompositeElementLite"
  73397. ],
  73398. "Ext.dom.Element": [
  73399. "Ext.Element"
  73400. ],
  73401. "Ext.dom.ElementEvent": [],
  73402. "Ext.dom.Fly": [
  73403. "Ext.dom.Element.Fly"
  73404. ],
  73405. "Ext.dom.GarbageCollector": [],
  73406. "Ext.dom.Helper": [
  73407. "Ext.DomHelper",
  73408. "Ext.core.DomHelper"
  73409. ],
  73410. "Ext.dom.Query": [
  73411. "Ext.core.DomQuery",
  73412. "Ext.DomQuery"
  73413. ],
  73414. "Ext.dom.Shadow": [
  73415. "Ext.Shadow"
  73416. ],
  73417. "Ext.dom.Shim": [],
  73418. "Ext.dom.TouchAction": [],
  73419. "Ext.dom.Underlay": [],
  73420. "Ext.dom.UnderlayPool": [],
  73421. "Ext.drag.Constraint": [],
  73422. "Ext.drag.Info": [],
  73423. "Ext.drag.Item": [],
  73424. "Ext.drag.Manager": [],
  73425. "Ext.drag.Source": [],
  73426. "Ext.drag.Target": [],
  73427. "Ext.drag.proxy.None": [],
  73428. "Ext.drag.proxy.Original": [],
  73429. "Ext.drag.proxy.Placeholder": [],
  73430. "Ext.event.Event": [
  73431. "Ext.EventObjectImpl"
  73432. ],
  73433. "Ext.event.gesture.DoubleTap": [],
  73434. "Ext.event.gesture.Drag": [],
  73435. "Ext.event.gesture.EdgeSwipe": [],
  73436. "Ext.event.gesture.LongPress": [],
  73437. "Ext.event.gesture.MultiTouch": [],
  73438. "Ext.event.gesture.Pinch": [],
  73439. "Ext.event.gesture.Recognizer": [],
  73440. "Ext.event.gesture.Rotate": [],
  73441. "Ext.event.gesture.SingleTouch": [],
  73442. "Ext.event.gesture.Swipe": [],
  73443. "Ext.event.gesture.Tap": [],
  73444. "Ext.event.publisher.Dom": [],
  73445. "Ext.event.publisher.ElementPaint": [],
  73446. "Ext.event.publisher.ElementSize": [],
  73447. "Ext.event.publisher.Focus": [],
  73448. "Ext.event.publisher.Gesture": [],
  73449. "Ext.event.publisher.Publisher": [],
  73450. "Ext.field.BoxLabelable": [],
  73451. "Ext.field.Checkbox": [
  73452. "Ext.form.Checkbox"
  73453. ],
  73454. "Ext.field.CheckboxGroup": [],
  73455. "Ext.field.ChipViewNavigationModel": [],
  73456. "Ext.field.ComboBox": [
  73457. "Ext.form.field.ComboBox"
  73458. ],
  73459. "Ext.field.Container": [],
  73460. "Ext.field.Date": [
  73461. "Ext.form.DatePicker",
  73462. "Ext.field.DatePicker"
  73463. ],
  73464. "Ext.field.DatePickerNative": [
  73465. "Ext.form.DatePickerNative"
  73466. ],
  73467. "Ext.field.Dirty": [],
  73468. "Ext.field.Display": [
  73469. "Ext.form.Display"
  73470. ],
  73471. "Ext.field.Email": [
  73472. "Ext.form.Email"
  73473. ],
  73474. "Ext.field.Field": [
  73475. "Ext.form.Field"
  73476. ],
  73477. "Ext.field.FieldGroupContainer": [],
  73478. "Ext.field.File": [],
  73479. "Ext.field.FileButton": [],
  73480. "Ext.field.Hidden": [
  73481. "Ext.form.Hidden"
  73482. ],
  73483. "Ext.field.Input": [],
  73484. "Ext.field.InputMask": [],
  73485. "Ext.field.Manager": [],
  73486. "Ext.field.Number": [
  73487. "Ext.form.Number"
  73488. ],
  73489. "Ext.field.Panel": [],
  73490. "Ext.field.Password": [
  73491. "Ext.form.Password"
  73492. ],
  73493. "Ext.field.Picker": [],
  73494. "Ext.field.Radio": [
  73495. "Ext.form.Radio"
  73496. ],
  73497. "Ext.field.RadioGroup": [],
  73498. "Ext.field.Search": [
  73499. "Ext.form.Search"
  73500. ],
  73501. "Ext.field.Select": [
  73502. "Ext.form.Select"
  73503. ],
  73504. "Ext.field.SingleSlider": [],
  73505. "Ext.field.Slider": [
  73506. "Ext.form.Slider"
  73507. ],
  73508. "Ext.field.Spinner": [
  73509. "Ext.form.Spinner"
  73510. ],
  73511. "Ext.field.Text": [
  73512. "Ext.form.Text"
  73513. ],
  73514. "Ext.field.TextArea": [
  73515. "Ext.form.TextArea"
  73516. ],
  73517. "Ext.field.Time": [],
  73518. "Ext.field.Toggle": [
  73519. "Ext.form.Toggle"
  73520. ],
  73521. "Ext.field.Url": [
  73522. "Ext.form.Url"
  73523. ],
  73524. "Ext.field.trigger.Base": [],
  73525. "Ext.field.trigger.Clear": [],
  73526. "Ext.field.trigger.Component": [],
  73527. "Ext.field.trigger.Date": [],
  73528. "Ext.field.trigger.Expand": [],
  73529. "Ext.field.trigger.File": [],
  73530. "Ext.field.trigger.Menu": [],
  73531. "Ext.field.trigger.Reveal": [],
  73532. "Ext.field.trigger.Search": [],
  73533. "Ext.field.trigger.SpinDown": [],
  73534. "Ext.field.trigger.SpinUp": [],
  73535. "Ext.field.trigger.Time": [],
  73536. "Ext.field.trigger.Trigger": [],
  73537. "Ext.form.Borders": [],
  73538. "Ext.form.FieldSet": [],
  73539. "Ext.form.Panel": [
  73540. "Ext.form.FormPanel"
  73541. ],
  73542. "Ext.fx.Animation": [],
  73543. "Ext.fx.Runner": [],
  73544. "Ext.fx.State": [],
  73545. "Ext.fx.animation.Abstract": [],
  73546. "Ext.fx.animation.Cube": [],
  73547. "Ext.fx.animation.Fade": [
  73548. "Ext.fx.animation.FadeIn"
  73549. ],
  73550. "Ext.fx.animation.FadeOut": [],
  73551. "Ext.fx.animation.Flip": [],
  73552. "Ext.fx.animation.Pop": [
  73553. "Ext.fx.animation.PopIn"
  73554. ],
  73555. "Ext.fx.animation.PopOut": [],
  73556. "Ext.fx.animation.Slide": [
  73557. "Ext.fx.animation.SlideIn"
  73558. ],
  73559. "Ext.fx.animation.SlideOut": [],
  73560. "Ext.fx.animation.Wipe": [
  73561. "Ext.fx.animation.WipeIn"
  73562. ],
  73563. "Ext.fx.animation.WipeOut": [],
  73564. "Ext.fx.easing.Abstract": [],
  73565. "Ext.fx.easing.Bounce": [],
  73566. "Ext.fx.easing.BoundMomentum": [],
  73567. "Ext.fx.easing.EaseIn": [],
  73568. "Ext.fx.easing.EaseOut": [],
  73569. "Ext.fx.easing.Easing": [],
  73570. "Ext.fx.easing.Linear": [],
  73571. "Ext.fx.easing.Momentum": [],
  73572. "Ext.fx.runner.Css": [],
  73573. "Ext.fx.runner.CssAnimation": [],
  73574. "Ext.fx.runner.CssTransition": [
  73575. "Ext.Animator"
  73576. ],
  73577. "Ext.grid.CellEditor": [],
  73578. "Ext.grid.Grid": [],
  73579. "Ext.grid.GridDragZone": [],
  73580. "Ext.grid.GridDropZone": [],
  73581. "Ext.grid.HeaderContainer": [],
  73582. "Ext.grid.HeaderDragZone": [],
  73583. "Ext.grid.HeaderDropZone": [],
  73584. "Ext.grid.Location": [],
  73585. "Ext.grid.NavigationModel": [],
  73586. "Ext.grid.PagingToolbar": [],
  73587. "Ext.grid.Row": [],
  73588. "Ext.grid.RowBody": [],
  73589. "Ext.grid.RowHeader": [],
  73590. "Ext.grid.SummaryRow": [],
  73591. "Ext.grid.Tree": [
  73592. "Ext.tree.Tree"
  73593. ],
  73594. "Ext.grid.TreeDragZone": [],
  73595. "Ext.grid.TreeDropZone": [],
  73596. "Ext.grid.cell.Base": [],
  73597. "Ext.grid.cell.Boolean": [],
  73598. "Ext.grid.cell.Cell": [],
  73599. "Ext.grid.cell.Check": [],
  73600. "Ext.grid.cell.Date": [],
  73601. "Ext.grid.cell.Expander": [],
  73602. "Ext.grid.cell.Number": [],
  73603. "Ext.grid.cell.RowNumberer": [],
  73604. "Ext.grid.cell.Text": [],
  73605. "Ext.grid.cell.Tree": [],
  73606. "Ext.grid.cell.Widget": [],
  73607. "Ext.grid.column.Boolean": [],
  73608. "Ext.grid.column.Check": [],
  73609. "Ext.grid.column.Column": [
  73610. "Ext.grid.column.Template"
  73611. ],
  73612. "Ext.grid.column.Date": [],
  73613. "Ext.grid.column.Drag": [],
  73614. "Ext.grid.column.Number": [],
  73615. "Ext.grid.column.RowNumberer": [],
  73616. "Ext.grid.column.Selection": [],
  73617. "Ext.grid.column.Text": [],
  73618. "Ext.grid.column.Tree": [],
  73619. "Ext.grid.filters.Column": [],
  73620. "Ext.grid.filters.Plugin": [],
  73621. "Ext.grid.filters.menu.Base": [],
  73622. "Ext.grid.filters.menu.Boolean": [],
  73623. "Ext.grid.filters.menu.Date": [],
  73624. "Ext.grid.filters.menu.Number": [],
  73625. "Ext.grid.filters.menu.String": [],
  73626. "Ext.grid.locked.Grid": [
  73627. "Ext.grid.LockedGrid"
  73628. ],
  73629. "Ext.grid.locked.Region": [
  73630. "Ext.grid.LockedGridRegion"
  73631. ],
  73632. "Ext.grid.menu.Columns": [],
  73633. "Ext.grid.menu.GroupByThis": [],
  73634. "Ext.grid.menu.Shared": [],
  73635. "Ext.grid.menu.ShowInGroups": [],
  73636. "Ext.grid.menu.SortAsc": [],
  73637. "Ext.grid.menu.SortDesc": [],
  73638. "Ext.grid.plugin.CellEditing": [],
  73639. "Ext.grid.plugin.Clipboard": [],
  73640. "Ext.grid.plugin.ColumnResizing": [],
  73641. "Ext.grid.plugin.Editable": [],
  73642. "Ext.grid.plugin.HeaderReorder": [],
  73643. "Ext.grid.plugin.PagingToolbar": [],
  73644. "Ext.grid.plugin.RowDragDrop": [],
  73645. "Ext.grid.plugin.RowExpander": [],
  73646. "Ext.grid.plugin.RowOperations": [
  73647. "Ext.grid.plugin.MultiSelection"
  73648. ],
  73649. "Ext.grid.plugin.Summary": [
  73650. "Ext.grid.plugin.SummaryRow"
  73651. ],
  73652. "Ext.grid.plugin.TreeDragDrop": [],
  73653. "Ext.grid.plugin.ViewOptions": [],
  73654. "Ext.grid.plugin.ViewOptionsListItem": [],
  73655. "Ext.grid.rowedit.Bar": [],
  73656. "Ext.grid.rowedit.Cell": [],
  73657. "Ext.grid.rowedit.Editor": [],
  73658. "Ext.grid.rowedit.Gap": [],
  73659. "Ext.grid.rowedit.Plugin": [],
  73660. "Ext.grid.selection.Cells": [],
  73661. "Ext.grid.selection.Columns": [],
  73662. "Ext.grid.selection.Model": [],
  73663. "Ext.grid.selection.Replicator": [],
  73664. "Ext.grid.selection.SelectionExtender": [],
  73665. "Ext.layout.Auto": [
  73666. "Ext.layout.Default"
  73667. ],
  73668. "Ext.layout.Box": [],
  73669. "Ext.layout.Card": [],
  73670. "Ext.layout.Carousel": [],
  73671. "Ext.layout.Center": [],
  73672. "Ext.layout.Fit": [],
  73673. "Ext.layout.Float": [],
  73674. "Ext.layout.Form": [],
  73675. "Ext.layout.HBox": [],
  73676. "Ext.layout.VBox": [],
  73677. "Ext.layout.card.fx.Abstract": [],
  73678. "Ext.layout.card.fx.Cover": [],
  73679. "Ext.layout.card.fx.Cube": [],
  73680. "Ext.layout.card.fx.Fade": [],
  73681. "Ext.layout.card.fx.Flip": [],
  73682. "Ext.layout.card.fx.Pop": [],
  73683. "Ext.layout.card.fx.Reveal": [],
  73684. "Ext.layout.card.fx.Scroll": [],
  73685. "Ext.layout.card.fx.ScrollCover": [],
  73686. "Ext.layout.card.fx.ScrollReveal": [],
  73687. "Ext.layout.card.fx.Serial": [],
  73688. "Ext.layout.card.fx.Slide": [],
  73689. "Ext.layout.card.fx.Style": [],
  73690. "Ext.layout.overflow.Scroller": [],
  73691. "Ext.layout.wrapper.BoxDock": [],
  73692. "Ext.layout.wrapper.Inner": [],
  73693. "Ext.list.AbstractTreeItem": [],
  73694. "Ext.list.Location": [],
  73695. "Ext.list.RootTreeItem": [],
  73696. "Ext.list.Tree": [],
  73697. "Ext.list.TreeItem": [],
  73698. "Ext.menu.CheckItem": [],
  73699. "Ext.menu.Item": [
  73700. "Ext.menu.TextItem"
  73701. ],
  73702. "Ext.menu.Manager": [
  73703. "Ext.menu.MenuMgr"
  73704. ],
  73705. "Ext.menu.Menu": [],
  73706. "Ext.menu.RadioItem": [],
  73707. "Ext.menu.Separator": [],
  73708. "Ext.mixin.Accessible": [],
  73709. "Ext.mixin.Bindable": [],
  73710. "Ext.mixin.Bufferable": [],
  73711. "Ext.mixin.ComponentDelegation": [],
  73712. "Ext.mixin.ConfigProxy": [],
  73713. "Ext.mixin.ConfigState": [],
  73714. "Ext.mixin.Container": [],
  73715. "Ext.mixin.Dirty": [],
  73716. "Ext.mixin.Factoryable": [],
  73717. "Ext.mixin.FieldDefaults": [],
  73718. "Ext.mixin.Focusable": [],
  73719. "Ext.mixin.FocusableContainer": [],
  73720. "Ext.mixin.Hookable": [],
  73721. "Ext.mixin.Inheritable": [],
  73722. "Ext.mixin.ItemRippler": [],
  73723. "Ext.mixin.Keyboard": [],
  73724. "Ext.mixin.Mashup": [],
  73725. "Ext.mixin.Pluggable": [],
  73726. "Ext.mixin.Progressable": [],
  73727. "Ext.mixin.Queryable": [],
  73728. "Ext.mixin.Responsive": [],
  73729. "Ext.mixin.Selectable": [],
  73730. "Ext.mixin.StoreWatcher": [],
  73731. "Ext.mixin.StyleCacher": [],
  73732. "Ext.mixin.Templatable": [],
  73733. "Ext.mixin.Toolable": [],
  73734. "Ext.mixin.Traversable": [],
  73735. "Ext.mixin.Watchable": [],
  73736. "Ext.navigation.Bar": [],
  73737. "Ext.navigation.View": [
  73738. "Ext.NavigationView"
  73739. ],
  73740. "Ext.override.sparkline.Base": [],
  73741. "Ext.overrides.Progress": [],
  73742. "Ext.overrides.Widget": [],
  73743. "Ext.overrides.app.Application": [],
  73744. "Ext.overrides.dom.Element": [],
  73745. "Ext.overrides.drag.proxy.Placeholder": [],
  73746. "Ext.overrides.list.Tree": [],
  73747. "Ext.overrides.list.TreeItem": [],
  73748. "Ext.panel.Accordion": [],
  73749. "Ext.panel.Buttons": [],
  73750. "Ext.panel.Collapser": [],
  73751. "Ext.panel.Collapsible": [],
  73752. "Ext.panel.Date": [],
  73753. "Ext.panel.DateTitle": [],
  73754. "Ext.panel.DateView": [],
  73755. "Ext.panel.Header": [],
  73756. "Ext.panel.Resizable": [],
  73757. "Ext.panel.Resizer": [],
  73758. "Ext.panel.Time": [],
  73759. "Ext.panel.TimeHeader": [],
  73760. "Ext.panel.TimeView": [],
  73761. "Ext.panel.Title": [],
  73762. "Ext.panel.YearPicker": [],
  73763. "Ext.parse.Parser": [],
  73764. "Ext.parse.Symbol": [],
  73765. "Ext.parse.Tokenizer": [],
  73766. "Ext.parse.symbol.Constant": [],
  73767. "Ext.parse.symbol.Infix": [],
  73768. "Ext.parse.symbol.InfixRight": [],
  73769. "Ext.parse.symbol.Paren": [],
  73770. "Ext.parse.symbol.Prefix": [],
  73771. "Ext.perf.Accumulator": [],
  73772. "Ext.perf.Monitor": [
  73773. "Ext.Perf"
  73774. ],
  73775. "Ext.picker.Date": [
  73776. "Ext.DatePicker"
  73777. ],
  73778. "Ext.picker.Picker": [
  73779. "Ext.Picker"
  73780. ],
  73781. "Ext.picker.SelectPicker": [],
  73782. "Ext.picker.Slot": [],
  73783. "Ext.picker.Tablet": [],
  73784. "Ext.plugin.Abstract": [
  73785. "Ext.AbstractPlugin"
  73786. ],
  73787. "Ext.plugin.AbstractClipboard": [],
  73788. "Ext.plugin.MouseEnter": [],
  73789. "Ext.plugin.Responsive": [],
  73790. "Ext.plugin.TabGuard": [],
  73791. "Ext.plugin.dd.DragDrop": [],
  73792. "Ext.plugin.dd.DragZone": [],
  73793. "Ext.plugin.dd.DropZone": [],
  73794. "Ext.promise.Consequence": [],
  73795. "Ext.promise.Deferred": [],
  73796. "Ext.promise.Promise": [],
  73797. "Ext.route.Action": [],
  73798. "Ext.route.Handler": [],
  73799. "Ext.route.Mixin": [],
  73800. "Ext.route.Route": [],
  73801. "Ext.route.Router": [],
  73802. "Ext.scroll.NativeScroller": [],
  73803. "Ext.scroll.Scroller": [],
  73804. "Ext.scroll.VirtualScroller": [],
  73805. "Ext.scroll.indicator.Bar": [],
  73806. "Ext.scroll.indicator.Indicator": [],
  73807. "Ext.scroll.indicator.Overlay": [],
  73808. "Ext.slider.Slider": [],
  73809. "Ext.slider.Thumb": [],
  73810. "Ext.slider.Toggle": [],
  73811. "Ext.sparkline.Bar": [],
  73812. "Ext.sparkline.BarBase": [],
  73813. "Ext.sparkline.Base": [],
  73814. "Ext.sparkline.Box": [],
  73815. "Ext.sparkline.Bullet": [],
  73816. "Ext.sparkline.CanvasBase": [],
  73817. "Ext.sparkline.CanvasCanvas": [],
  73818. "Ext.sparkline.Discrete": [],
  73819. "Ext.sparkline.Line": [],
  73820. "Ext.sparkline.Pie": [],
  73821. "Ext.sparkline.RangeMap": [],
  73822. "Ext.sparkline.Shape": [],
  73823. "Ext.sparkline.TriState": [],
  73824. "Ext.sparkline.VmlCanvas": [],
  73825. "Ext.state.Builder": [],
  73826. "Ext.state.LocalStorage": [],
  73827. "Ext.state.Provider": [],
  73828. "Ext.state.Stateful": [],
  73829. "Ext.tab.Bar": [
  73830. "Ext.TabBar"
  73831. ],
  73832. "Ext.tab.Panel": [
  73833. "Ext.TabPanel"
  73834. ],
  73835. "Ext.tab.Tab": [
  73836. "Ext.Tab"
  73837. ],
  73838. "Ext.tip.Manager": [],
  73839. "Ext.tip.ToolTip": [],
  73840. "Ext.util.AbstractMixedCollection": [],
  73841. "Ext.util.Audio": [],
  73842. "Ext.util.Bag": [],
  73843. "Ext.util.Base64": [],
  73844. "Ext.util.BasicFilter": [],
  73845. "Ext.util.CSS": [],
  73846. "Ext.util.CSV": [],
  73847. "Ext.util.ClickRepeater": [
  73848. "Ext.util.TapRepeater"
  73849. ],
  73850. "Ext.util.Collection": [],
  73851. "Ext.util.CollectionKey": [],
  73852. "Ext.util.Color": [
  73853. "Ext.draw.Color"
  73854. ],
  73855. "Ext.util.Cookies": [],
  73856. "Ext.util.DelimitedValue": [],
  73857. "Ext.util.Draggable": [],
  73858. "Ext.util.Filter": [],
  73859. "Ext.util.FilterCollection": [],
  73860. "Ext.util.Fly": [],
  73861. "Ext.util.Format": [],
  73862. "Ext.util.Geolocation": [
  73863. "Ext.util.GeoLocation"
  73864. ],
  73865. "Ext.util.Group": [],
  73866. "Ext.util.GroupCollection": [],
  73867. "Ext.util.Grouper": [],
  73868. "Ext.util.HashMap": [],
  73869. "Ext.util.HeightSynchronizer": [],
  73870. "Ext.util.History": [
  73871. "Ext.History"
  73872. ],
  73873. "Ext.util.Inflector": [],
  73874. "Ext.util.InputBlocker": [],
  73875. "Ext.util.ItemCollection": [
  73876. "Ext.ItemCollection"
  73877. ],
  73878. "Ext.util.KeyMap": [
  73879. "Ext.KeyMap"
  73880. ],
  73881. "Ext.util.KeyNav": [
  73882. "Ext.KeyNav"
  73883. ],
  73884. "Ext.util.LineSegment": [],
  73885. "Ext.util.LocalStorage": [],
  73886. "Ext.util.LruCache": [],
  73887. "Ext.util.MixedCollection": [],
  73888. "Ext.util.ObjectTemplate": [],
  73889. "Ext.util.Observable": [],
  73890. "Ext.util.Offset": [],
  73891. "Ext.util.PaintMonitor": [],
  73892. "Ext.util.Point": [],
  73893. "Ext.util.Positionable": [],
  73894. "Ext.util.Region": [],
  73895. "Ext.util.Schedulable": [],
  73896. "Ext.util.Scheduler": [],
  73897. "Ext.util.SizeMonitor": [],
  73898. "Ext.util.Sortable": [],
  73899. "Ext.util.Sorter": [],
  73900. "Ext.util.SorterCollection": [],
  73901. "Ext.util.Spans": [],
  73902. "Ext.util.TextMetrics": [],
  73903. "Ext.util.TranslatableGroup": [],
  73904. "Ext.util.TranslatableList": [],
  73905. "Ext.util.TsvDecoder": [
  73906. "Ext.util.TSV"
  73907. ],
  73908. "Ext.util.Wrapper": [],
  73909. "Ext.util.XTemplateCompiler": [],
  73910. "Ext.util.XTemplateParser": [],
  73911. "Ext.util.paintmonitor.Abstract": [],
  73912. "Ext.util.paintmonitor.CssAnimation": [],
  73913. "Ext.util.paintmonitor.OverflowChange": [],
  73914. "Ext.util.sizemonitor.Abstract": [],
  73915. "Ext.util.sizemonitor.OverflowChange": [],
  73916. "Ext.util.sizemonitor.Scroll": [],
  73917. "Ext.util.translatable.Abstract": [],
  73918. "Ext.util.translatable.Component": [],
  73919. "Ext.util.translatable.CssPosition": [],
  73920. "Ext.util.translatable.CssTransform": [],
  73921. "Ext.util.translatable.Dom": [],
  73922. "Ext.util.translatable.ScrollParent": [],
  73923. "Ext.util.translatable.ScrollPosition": [],
  73924. "Ext.viewport.Android": [],
  73925. "Ext.viewport.Default": [],
  73926. "Ext.viewport.Ios": [],
  73927. "Ext.viewport.Viewport": [],
  73928. "Ext.viewport.WindowsPhone": [
  73929. "Ext.viewport.WP"
  73930. ]
  73931. });
  73932. Ext.ClassManager.addNameAliasMappings({
  73933. "Ext.AbstractComponent": [],
  73934. "Ext.AbstractManager": [],
  73935. "Ext.ActionSheet": [
  73936. "widget.actionsheet"
  73937. ],
  73938. "Ext.Ajax": [],
  73939. "Ext.Anim": [],
  73940. "Ext.AnimationQueue": [],
  73941. "Ext.Audio": [
  73942. "widget.audio"
  73943. ],
  73944. "Ext.BreadcrumbBar": [
  73945. "widget.breadcrumbbar"
  73946. ],
  73947. "Ext.Button": [
  73948. "widget.button"
  73949. ],
  73950. "Ext.Chip": [
  73951. "widget.chip"
  73952. ],
  73953. "Ext.Component": [
  73954. "widget.component"
  73955. ],
  73956. "Ext.ComponentManager": [],
  73957. "Ext.ComponentQuery": [],
  73958. "Ext.Container": [
  73959. "widget.container"
  73960. ],
  73961. "Ext.Decorator": [],
  73962. "Ext.Deferred": [],
  73963. "Ext.Dialog": [
  73964. "widget.dialog",
  73965. "widget.window"
  73966. ],
  73967. "Ext.Editor": [
  73968. "widget.editor"
  73969. ],
  73970. "Ext.Evented": [],
  73971. "Ext.GlobalEvents": [],
  73972. "Ext.Glyph": [],
  73973. "Ext.Img": [
  73974. "widget.image",
  73975. "widget.img"
  73976. ],
  73977. "Ext.Indicator": [
  73978. "widget.indicator"
  73979. ],
  73980. "Ext.Label": [
  73981. "widget.label"
  73982. ],
  73983. "Ext.LoadMask": [
  73984. "widget.loadmask"
  73985. ],
  73986. "Ext.Mask": [
  73987. "widget.mask"
  73988. ],
  73989. "Ext.Media": [
  73990. "widget.media"
  73991. ],
  73992. "Ext.MessageBox": [
  73993. "widget.messagebox"
  73994. ],
  73995. "Ext.Mixin": [],
  73996. "Ext.Panel": [
  73997. "widget.panel"
  73998. ],
  73999. "Ext.Progress": [
  74000. "widget.progress",
  74001. "widget.progressbarwidget"
  74002. ],
  74003. "Ext.ProgressBase": [],
  74004. "Ext.Promise": [],
  74005. "Ext.Responsive": [],
  74006. "Ext.SegmentedButton": [
  74007. "widget.segmentedbutton"
  74008. ],
  74009. "Ext.Sheet": [
  74010. "widget.sheet"
  74011. ],
  74012. "Ext.Spacer": [
  74013. "widget.spacer"
  74014. ],
  74015. "Ext.SplitButton": [
  74016. "widget.splitbutton"
  74017. ],
  74018. "Ext.Stateful": [],
  74019. "Ext.TaskQueue": [],
  74020. "Ext.Template": [],
  74021. "Ext.Title": [
  74022. "widget.title"
  74023. ],
  74024. "Ext.TitleBar": [
  74025. "widget.titlebar"
  74026. ],
  74027. "Ext.Toast": [],
  74028. "Ext.Tool": [
  74029. "widget.paneltool",
  74030. "widget.tool"
  74031. ],
  74032. "Ext.Toolbar": [
  74033. "widget.toolbar"
  74034. ],
  74035. "Ext.Video": [
  74036. "widget.video"
  74037. ],
  74038. "Ext.Widget": [
  74039. "widget.widget"
  74040. ],
  74041. "Ext.XTemplate": [],
  74042. "Ext.app.Application": [],
  74043. "Ext.app.BaseController": [],
  74044. "Ext.app.Controller": [],
  74045. "Ext.app.EventBus": [],
  74046. "Ext.app.EventDomain": [],
  74047. "Ext.app.Profile": [],
  74048. "Ext.app.Util": [],
  74049. "Ext.app.ViewController": [
  74050. "controller.controller"
  74051. ],
  74052. "Ext.app.ViewModel": [
  74053. "viewmodel.default"
  74054. ],
  74055. "Ext.app.bind.AbstractStub": [],
  74056. "Ext.app.bind.BaseBinding": [],
  74057. "Ext.app.bind.Binding": [],
  74058. "Ext.app.bind.Formula": [],
  74059. "Ext.app.bind.LinkStub": [],
  74060. "Ext.app.bind.Multi": [],
  74061. "Ext.app.bind.Parser": [],
  74062. "Ext.app.bind.RootStub": [],
  74063. "Ext.app.bind.Stub": [],
  74064. "Ext.app.bind.Template": [],
  74065. "Ext.app.bind.TemplateBinding": [],
  74066. "Ext.app.domain.Component": [],
  74067. "Ext.app.domain.Controller": [],
  74068. "Ext.app.domain.Direct": [],
  74069. "Ext.app.domain.Global": [],
  74070. "Ext.app.domain.Store": [],
  74071. "Ext.app.domain.View": [],
  74072. "Ext.behavior.Behavior": [],
  74073. "Ext.carousel.Carousel": [
  74074. "widget.carousel"
  74075. ],
  74076. "Ext.carousel.Infinite": [],
  74077. "Ext.carousel.Item": [],
  74078. "Ext.data.AbstractStore": [],
  74079. "Ext.data.ArrayStore": [
  74080. "store.array"
  74081. ],
  74082. "Ext.data.Batch": [],
  74083. "Ext.data.BufferedStore": [
  74084. "store.buffered"
  74085. ],
  74086. "Ext.data.ChainedStore": [
  74087. "store.chained"
  74088. ],
  74089. "Ext.data.ClientStore": [
  74090. "store.clientstorage"
  74091. ],
  74092. "Ext.data.Connection": [],
  74093. "Ext.data.DirectStore": [
  74094. "store.direct"
  74095. ],
  74096. "Ext.data.Error": [],
  74097. "Ext.data.ErrorCollection": [],
  74098. "Ext.data.Group": [],
  74099. "Ext.data.JsonP": [],
  74100. "Ext.data.JsonPStore": [
  74101. "store.jsonp"
  74102. ],
  74103. "Ext.data.JsonStore": [
  74104. "store.json"
  74105. ],
  74106. "Ext.data.LocalStore": [],
  74107. "Ext.data.Model": [],
  74108. "Ext.data.ModelManager": [],
  74109. "Ext.data.NodeInterface": [],
  74110. "Ext.data.NodeStore": [
  74111. "store.node"
  74112. ],
  74113. "Ext.data.PageMap": [],
  74114. "Ext.data.ProxyStore": [],
  74115. "Ext.data.Query": [
  74116. "query.default"
  74117. ],
  74118. "Ext.data.Range": [],
  74119. "Ext.data.Request": [],
  74120. "Ext.data.ResultSet": [],
  74121. "Ext.data.Session": [],
  74122. "Ext.data.SortTypes": [],
  74123. "Ext.data.Store": [
  74124. "store.store"
  74125. ],
  74126. "Ext.data.StoreManager": [],
  74127. "Ext.data.TreeModel": [],
  74128. "Ext.data.TreeStore": [
  74129. "store.tree"
  74130. ],
  74131. "Ext.data.Types": [],
  74132. "Ext.data.Validation": [],
  74133. "Ext.data.XmlStore": [
  74134. "store.xml"
  74135. ],
  74136. "Ext.data.field.Boolean": [
  74137. "data.field.bool",
  74138. "data.field.boolean"
  74139. ],
  74140. "Ext.data.field.Date": [
  74141. "data.field.date"
  74142. ],
  74143. "Ext.data.field.Field": [
  74144. "data.field.auto"
  74145. ],
  74146. "Ext.data.field.Integer": [
  74147. "data.field.int",
  74148. "data.field.integer"
  74149. ],
  74150. "Ext.data.field.Number": [
  74151. "data.field.float",
  74152. "data.field.number"
  74153. ],
  74154. "Ext.data.field.String": [
  74155. "data.field.string"
  74156. ],
  74157. "Ext.data.flash.BinaryXhr": [],
  74158. "Ext.data.identifier.Generator": [
  74159. "data.identifier.default"
  74160. ],
  74161. "Ext.data.identifier.Negative": [
  74162. "data.identifier.negative"
  74163. ],
  74164. "Ext.data.identifier.Sequential": [
  74165. "data.identifier.sequential"
  74166. ],
  74167. "Ext.data.identifier.Uuid": [
  74168. "data.identifier.uuid"
  74169. ],
  74170. "Ext.data.matrix.Matrix": [],
  74171. "Ext.data.matrix.Side": [],
  74172. "Ext.data.matrix.Slice": [],
  74173. "Ext.data.operation.Create": [
  74174. "data.operation.create"
  74175. ],
  74176. "Ext.data.operation.Destroy": [
  74177. "data.operation.destroy"
  74178. ],
  74179. "Ext.data.operation.Operation": [],
  74180. "Ext.data.operation.Read": [
  74181. "data.operation.read"
  74182. ],
  74183. "Ext.data.operation.Update": [
  74184. "data.operation.update"
  74185. ],
  74186. "Ext.data.proxy.Ajax": [
  74187. "proxy.ajax"
  74188. ],
  74189. "Ext.data.proxy.Client": [],
  74190. "Ext.data.proxy.Direct": [
  74191. "proxy.direct"
  74192. ],
  74193. "Ext.data.proxy.JsonP": [
  74194. "proxy.jsonp",
  74195. "proxy.scripttag"
  74196. ],
  74197. "Ext.data.proxy.LocalStorage": [
  74198. "proxy.localstorage"
  74199. ],
  74200. "Ext.data.proxy.Memory": [
  74201. "proxy.memory"
  74202. ],
  74203. "Ext.data.proxy.Proxy": [
  74204. "proxy.proxy"
  74205. ],
  74206. "Ext.data.proxy.Rest": [
  74207. "proxy.rest"
  74208. ],
  74209. "Ext.data.proxy.Server": [
  74210. "proxy.server"
  74211. ],
  74212. "Ext.data.proxy.SessionStorage": [
  74213. "proxy.sessionstorage"
  74214. ],
  74215. "Ext.data.proxy.WebStorage": [],
  74216. "Ext.data.query.Compiler": [],
  74217. "Ext.data.query.Converter": [],
  74218. "Ext.data.query.Parser": [],
  74219. "Ext.data.query.Stringifier": [],
  74220. "Ext.data.reader.Array": [
  74221. "reader.array"
  74222. ],
  74223. "Ext.data.reader.Json": [
  74224. "reader.json"
  74225. ],
  74226. "Ext.data.reader.Reader": [
  74227. "reader.base"
  74228. ],
  74229. "Ext.data.reader.Xml": [
  74230. "reader.xml"
  74231. ],
  74232. "Ext.data.request.Ajax": [
  74233. "request.ajax"
  74234. ],
  74235. "Ext.data.request.Base": [],
  74236. "Ext.data.request.Form": [
  74237. "request.form"
  74238. ],
  74239. "Ext.data.schema.Association": [],
  74240. "Ext.data.schema.ManyToMany": [],
  74241. "Ext.data.schema.ManyToOne": [],
  74242. "Ext.data.schema.Namer": [
  74243. "namer.default"
  74244. ],
  74245. "Ext.data.schema.OneToOne": [],
  74246. "Ext.data.schema.Role": [],
  74247. "Ext.data.schema.Schema": [
  74248. "schema.default"
  74249. ],
  74250. "Ext.data.session.BatchVisitor": [],
  74251. "Ext.data.session.ChangesVisitor": [],
  74252. "Ext.data.session.ChildChangesVisitor": [],
  74253. "Ext.data.summary.Average": [
  74254. "data.summary.average"
  74255. ],
  74256. "Ext.data.summary.Base": [
  74257. "data.summary.base"
  74258. ],
  74259. "Ext.data.summary.Count": [
  74260. "data.summary.count"
  74261. ],
  74262. "Ext.data.summary.Max": [
  74263. "data.summary.max"
  74264. ],
  74265. "Ext.data.summary.Min": [
  74266. "data.summary.min"
  74267. ],
  74268. "Ext.data.summary.None": [
  74269. "data.summary.none"
  74270. ],
  74271. "Ext.data.summary.Sum": [
  74272. "data.summary.sum"
  74273. ],
  74274. "Ext.data.validator.AbstractDate": [],
  74275. "Ext.data.validator.Bound": [
  74276. "data.validator.bound"
  74277. ],
  74278. "Ext.data.validator.CIDRv4": [
  74279. "data.validator.cidrv4"
  74280. ],
  74281. "Ext.data.validator.CIDRv6": [
  74282. "data.validator.cidrv6"
  74283. ],
  74284. "Ext.data.validator.Currency": [
  74285. "data.validator.currency"
  74286. ],
  74287. "Ext.data.validator.CurrencyUS": [
  74288. "data.validator.currency-us"
  74289. ],
  74290. "Ext.data.validator.Date": [
  74291. "data.validator.date"
  74292. ],
  74293. "Ext.data.validator.DateTime": [
  74294. "data.validator.datetime"
  74295. ],
  74296. "Ext.data.validator.Email": [
  74297. "data.validator.email"
  74298. ],
  74299. "Ext.data.validator.Exclusion": [
  74300. "data.validator.exclusion"
  74301. ],
  74302. "Ext.data.validator.Format": [
  74303. "data.validator.format"
  74304. ],
  74305. "Ext.data.validator.IPAddress": [
  74306. "data.validator.ipaddress"
  74307. ],
  74308. "Ext.data.validator.Inclusion": [
  74309. "data.validator.inclusion"
  74310. ],
  74311. "Ext.data.validator.Length": [
  74312. "data.validator.length"
  74313. ],
  74314. "Ext.data.validator.List": [
  74315. "data.validator.list"
  74316. ],
  74317. "Ext.data.validator.NotNull": [
  74318. "data.validator.notnull"
  74319. ],
  74320. "Ext.data.validator.Number": [
  74321. "data.validator.number"
  74322. ],
  74323. "Ext.data.validator.Phone": [
  74324. "data.validator.phone"
  74325. ],
  74326. "Ext.data.validator.Presence": [
  74327. "data.validator.presence"
  74328. ],
  74329. "Ext.data.validator.Range": [
  74330. "data.validator.range"
  74331. ],
  74332. "Ext.data.validator.Time": [
  74333. "data.validator.time"
  74334. ],
  74335. "Ext.data.validator.Url": [
  74336. "data.validator.url"
  74337. ],
  74338. "Ext.data.validator.Validator": [
  74339. "data.validator.base"
  74340. ],
  74341. "Ext.data.virtual.Group": [],
  74342. "Ext.data.virtual.Page": [],
  74343. "Ext.data.virtual.PageMap": [],
  74344. "Ext.data.virtual.Range": [],
  74345. "Ext.data.virtual.Store": [
  74346. "store.virtual"
  74347. ],
  74348. "Ext.data.writer.Json": [
  74349. "writer.json"
  74350. ],
  74351. "Ext.data.writer.Writer": [
  74352. "writer.base"
  74353. ],
  74354. "Ext.data.writer.Xml": [
  74355. "writer.xml"
  74356. ],
  74357. "Ext.dataview.Abstract": [],
  74358. "Ext.dataview.BoundList": [
  74359. "widget.boundlist"
  74360. ],
  74361. "Ext.dataview.BoundListLocation": [],
  74362. "Ext.dataview.BoundListNavigationModel": [
  74363. "navmodel.boundlist"
  74364. ],
  74365. "Ext.dataview.ChipView": [
  74366. "widget.chipview"
  74367. ],
  74368. "Ext.dataview.Component": [
  74369. "widget.componentdataview"
  74370. ],
  74371. "Ext.dataview.DataItem": [
  74372. "widget.dataitem"
  74373. ],
  74374. "Ext.dataview.DataView": [
  74375. "widget.dataview"
  74376. ],
  74377. "Ext.dataview.Disclosable": [],
  74378. "Ext.dataview.EmptyText": [
  74379. "widget.emptytext"
  74380. ],
  74381. "Ext.dataview.GenericItem": [],
  74382. "Ext.dataview.GroupStore": [],
  74383. "Ext.dataview.IndexBar": [
  74384. "widget.indexbar"
  74385. ],
  74386. "Ext.dataview.ItemHeader": [
  74387. "widget.itemheader"
  74388. ],
  74389. "Ext.dataview.List": [
  74390. "widget.list"
  74391. ],
  74392. "Ext.dataview.ListCollapser": [],
  74393. "Ext.dataview.ListGroup": [],
  74394. "Ext.dataview.ListItem": [
  74395. "widget.listitem"
  74396. ],
  74397. "Ext.dataview.ListItemPlaceholder": [
  74398. "widget.listitemplaceholder"
  74399. ],
  74400. "Ext.dataview.Location": [],
  74401. "Ext.dataview.NavigationModel": [
  74402. "navmodel.dataview"
  74403. ],
  74404. "Ext.dataview.NestedList": [
  74405. "widget.nestedlist"
  74406. ],
  74407. "Ext.dataview.Pinnable": [],
  74408. "Ext.dataview.SimpleListItem": [
  74409. "widget.simplelistitem"
  74410. ],
  74411. "Ext.dataview.listswiper.Accordion": [
  74412. "widget.listswiperaccordion"
  74413. ],
  74414. "Ext.dataview.listswiper.Item": [
  74415. "widget.listswiperitem"
  74416. ],
  74417. "Ext.dataview.listswiper.ListSwiper": [
  74418. "plugin.listswiper"
  74419. ],
  74420. "Ext.dataview.listswiper.Stepper": [
  74421. "widget.listswiperstepper"
  74422. ],
  74423. "Ext.dataview.plugin.ItemTip": [
  74424. "plugin.dataviewtip"
  74425. ],
  74426. "Ext.dataview.plugin.ListPaging": [
  74427. "plugin.listpaging"
  74428. ],
  74429. "Ext.dataview.plugin.SortableList": [
  74430. "plugin.sortablelist"
  74431. ],
  74432. "Ext.dataview.pullrefresh.Bar": [
  74433. "widget.pullrefreshbar"
  74434. ],
  74435. "Ext.dataview.pullrefresh.Item": [],
  74436. "Ext.dataview.pullrefresh.PullRefresh": [
  74437. "plugin.pullrefresh"
  74438. ],
  74439. "Ext.dataview.pullrefresh.Spinner": [
  74440. "widget.pullrefreshspinner"
  74441. ],
  74442. "Ext.dataview.selection.Model": [
  74443. "selmodel.dataview"
  74444. ],
  74445. "Ext.dataview.selection.Records": [
  74446. "selection.records"
  74447. ],
  74448. "Ext.dataview.selection.Rows": [
  74449. "selection.rows"
  74450. ],
  74451. "Ext.dataview.selection.Selection": [],
  74452. "Ext.dd.Manager": [],
  74453. "Ext.dd.ScrollManager": [],
  74454. "Ext.direct.Event": [
  74455. "direct.event"
  74456. ],
  74457. "Ext.direct.ExceptionEvent": [
  74458. "direct.exception"
  74459. ],
  74460. "Ext.direct.JsonProvider": [
  74461. "direct.jsonprovider"
  74462. ],
  74463. "Ext.direct.Manager": [],
  74464. "Ext.direct.PollingProvider": [
  74465. "direct.pollingprovider"
  74466. ],
  74467. "Ext.direct.Provider": [
  74468. "direct.provider"
  74469. ],
  74470. "Ext.direct.RemotingEvent": [
  74471. "direct.rpc"
  74472. ],
  74473. "Ext.direct.RemotingMethod": [],
  74474. "Ext.direct.RemotingProvider": [
  74475. "direct.remotingprovider"
  74476. ],
  74477. "Ext.direct.Transaction": [
  74478. "direct.transaction"
  74479. ],
  74480. "Ext.dom.CompositeElement": [],
  74481. "Ext.dom.CompositeElementLite": [],
  74482. "Ext.dom.Element": [],
  74483. "Ext.dom.ElementEvent": [],
  74484. "Ext.dom.Fly": [],
  74485. "Ext.dom.GarbageCollector": [],
  74486. "Ext.dom.Helper": [],
  74487. "Ext.dom.Query": [],
  74488. "Ext.dom.Shadow": [],
  74489. "Ext.dom.Shim": [],
  74490. "Ext.dom.TouchAction": [],
  74491. "Ext.dom.Underlay": [],
  74492. "Ext.dom.UnderlayPool": [],
  74493. "Ext.drag.Constraint": [
  74494. "drag.constraint.base"
  74495. ],
  74496. "Ext.drag.Info": [],
  74497. "Ext.drag.Item": [],
  74498. "Ext.drag.Manager": [],
  74499. "Ext.drag.Source": [],
  74500. "Ext.drag.Target": [],
  74501. "Ext.drag.proxy.None": [
  74502. "drag.proxy.none"
  74503. ],
  74504. "Ext.drag.proxy.Original": [
  74505. "drag.proxy.original"
  74506. ],
  74507. "Ext.drag.proxy.Placeholder": [
  74508. "drag.proxy.placeholder"
  74509. ],
  74510. "Ext.event.Event": [],
  74511. "Ext.event.gesture.DoubleTap": [],
  74512. "Ext.event.gesture.Drag": [],
  74513. "Ext.event.gesture.EdgeSwipe": [],
  74514. "Ext.event.gesture.LongPress": [],
  74515. "Ext.event.gesture.MultiTouch": [],
  74516. "Ext.event.gesture.Pinch": [],
  74517. "Ext.event.gesture.Recognizer": [],
  74518. "Ext.event.gesture.Rotate": [],
  74519. "Ext.event.gesture.SingleTouch": [],
  74520. "Ext.event.gesture.Swipe": [],
  74521. "Ext.event.gesture.Tap": [],
  74522. "Ext.event.publisher.Dom": [],
  74523. "Ext.event.publisher.ElementPaint": [],
  74524. "Ext.event.publisher.ElementSize": [],
  74525. "Ext.event.publisher.Focus": [],
  74526. "Ext.event.publisher.Gesture": [],
  74527. "Ext.event.publisher.Publisher": [],
  74528. "Ext.field.BoxLabelable": [],
  74529. "Ext.field.Checkbox": [
  74530. "widget.checkbox",
  74531. "widget.checkboxfield"
  74532. ],
  74533. "Ext.field.CheckboxGroup": [
  74534. "widget.checkboxgroup"
  74535. ],
  74536. "Ext.field.ChipViewNavigationModel": [
  74537. "navmodel.fieldchipview"
  74538. ],
  74539. "Ext.field.ComboBox": [
  74540. "widget.combobox",
  74541. "widget.comboboxfield"
  74542. ],
  74543. "Ext.field.Container": [
  74544. "widget.containerfield",
  74545. "widget.fieldcontainer"
  74546. ],
  74547. "Ext.field.Date": [
  74548. "widget.datefield",
  74549. "widget.datepickerfield"
  74550. ],
  74551. "Ext.field.DatePickerNative": [
  74552. "widget.datepickernativefield"
  74553. ],
  74554. "Ext.field.Dirty": [],
  74555. "Ext.field.Display": [
  74556. "widget.displayfield"
  74557. ],
  74558. "Ext.field.Email": [
  74559. "widget.emailfield"
  74560. ],
  74561. "Ext.field.Field": [
  74562. "widget.field"
  74563. ],
  74564. "Ext.field.FieldGroupContainer": [
  74565. "widget.groupcontainer"
  74566. ],
  74567. "Ext.field.File": [
  74568. "widget.filefield"
  74569. ],
  74570. "Ext.field.FileButton": [
  74571. "widget.filebutton"
  74572. ],
  74573. "Ext.field.Hidden": [
  74574. "widget.hiddenfield"
  74575. ],
  74576. "Ext.field.Input": [
  74577. "widget.inputfield"
  74578. ],
  74579. "Ext.field.InputMask": [],
  74580. "Ext.field.Manager": [],
  74581. "Ext.field.Number": [
  74582. "widget.numberfield"
  74583. ],
  74584. "Ext.field.Panel": [
  74585. "widget.fieldpanel"
  74586. ],
  74587. "Ext.field.Password": [
  74588. "widget.passwordfield"
  74589. ],
  74590. "Ext.field.Picker": [
  74591. "widget.pickerfield"
  74592. ],
  74593. "Ext.field.Radio": [
  74594. "widget.radio",
  74595. "widget.radiofield"
  74596. ],
  74597. "Ext.field.RadioGroup": [
  74598. "widget.radiogroup"
  74599. ],
  74600. "Ext.field.Search": [
  74601. "widget.searchfield"
  74602. ],
  74603. "Ext.field.Select": [
  74604. "widget.selectfield"
  74605. ],
  74606. "Ext.field.SingleSlider": [
  74607. "widget.singlesliderfield"
  74608. ],
  74609. "Ext.field.Slider": [
  74610. "widget.sliderfield"
  74611. ],
  74612. "Ext.field.Spinner": [
  74613. "widget.spinnerfield"
  74614. ],
  74615. "Ext.field.Text": [
  74616. "widget.textfield"
  74617. ],
  74618. "Ext.field.TextArea": [
  74619. "widget.textareafield"
  74620. ],
  74621. "Ext.field.Time": [
  74622. "widget.timefield"
  74623. ],
  74624. "Ext.field.Toggle": [
  74625. "widget.togglefield"
  74626. ],
  74627. "Ext.field.Url": [
  74628. "widget.urlfield"
  74629. ],
  74630. "Ext.field.trigger.Base": [
  74631. "trigger.base"
  74632. ],
  74633. "Ext.field.trigger.Clear": [
  74634. "trigger.clear",
  74635. "widget.cleartrigger"
  74636. ],
  74637. "Ext.field.trigger.Component": [
  74638. "trigger.component"
  74639. ],
  74640. "Ext.field.trigger.Date": [
  74641. "trigger.date",
  74642. "widget.datetrigger"
  74643. ],
  74644. "Ext.field.trigger.Expand": [
  74645. "trigger.expand",
  74646. "widget.expandtrigger"
  74647. ],
  74648. "Ext.field.trigger.File": [
  74649. "trigger.file"
  74650. ],
  74651. "Ext.field.trigger.Menu": [
  74652. "trigger.menu",
  74653. "widget.menutrigger"
  74654. ],
  74655. "Ext.field.trigger.Reveal": [
  74656. "trigger.reveal",
  74657. "widget.revealtrigger"
  74658. ],
  74659. "Ext.field.trigger.Search": [
  74660. "trigger.search",
  74661. "widget.searchtrigger"
  74662. ],
  74663. "Ext.field.trigger.SpinDown": [
  74664. "trigger.spindown",
  74665. "widget.spindowntrigger"
  74666. ],
  74667. "Ext.field.trigger.SpinUp": [
  74668. "trigger.spinup",
  74669. "widget.spinuptrigger"
  74670. ],
  74671. "Ext.field.trigger.Time": [
  74672. "trigger.time",
  74673. "widget.timetrigger"
  74674. ],
  74675. "Ext.field.trigger.Trigger": [
  74676. "trigger.trigger",
  74677. "widget.trigger"
  74678. ],
  74679. "Ext.form.Borders": [],
  74680. "Ext.form.FieldSet": [
  74681. "widget.fieldset"
  74682. ],
  74683. "Ext.form.Panel": [
  74684. "widget.formpanel"
  74685. ],
  74686. "Ext.fx.Animation": [],
  74687. "Ext.fx.Runner": [],
  74688. "Ext.fx.State": [],
  74689. "Ext.fx.animation.Abstract": [],
  74690. "Ext.fx.animation.Cube": [
  74691. "animation.cube"
  74692. ],
  74693. "Ext.fx.animation.Fade": [
  74694. "animation.fade",
  74695. "animation.fadeIn"
  74696. ],
  74697. "Ext.fx.animation.FadeOut": [
  74698. "animation.fadeOut"
  74699. ],
  74700. "Ext.fx.animation.Flip": [
  74701. "animation.flip"
  74702. ],
  74703. "Ext.fx.animation.Pop": [
  74704. "animation.pop",
  74705. "animation.popIn"
  74706. ],
  74707. "Ext.fx.animation.PopOut": [
  74708. "animation.popOut"
  74709. ],
  74710. "Ext.fx.animation.Slide": [
  74711. "animation.slide",
  74712. "animation.slideIn"
  74713. ],
  74714. "Ext.fx.animation.SlideOut": [
  74715. "animation.slideOut"
  74716. ],
  74717. "Ext.fx.animation.Wipe": [],
  74718. "Ext.fx.animation.WipeOut": [],
  74719. "Ext.fx.easing.Abstract": [],
  74720. "Ext.fx.easing.Bounce": [],
  74721. "Ext.fx.easing.BoundMomentum": [],
  74722. "Ext.fx.easing.EaseIn": [
  74723. "easing.ease-in"
  74724. ],
  74725. "Ext.fx.easing.EaseOut": [
  74726. "easing.ease-out"
  74727. ],
  74728. "Ext.fx.easing.Easing": [],
  74729. "Ext.fx.easing.Linear": [
  74730. "easing.linear"
  74731. ],
  74732. "Ext.fx.easing.Momentum": [],
  74733. "Ext.fx.runner.Css": [],
  74734. "Ext.fx.runner.CssAnimation": [],
  74735. "Ext.fx.runner.CssTransition": [],
  74736. "Ext.grid.CellEditor": [
  74737. "widget.celleditor"
  74738. ],
  74739. "Ext.grid.Grid": [
  74740. "widget.grid"
  74741. ],
  74742. "Ext.grid.GridDragZone": [],
  74743. "Ext.grid.GridDropZone": [],
  74744. "Ext.grid.HeaderContainer": [
  74745. "widget.headercontainer"
  74746. ],
  74747. "Ext.grid.HeaderDragZone": [],
  74748. "Ext.grid.HeaderDropZone": [],
  74749. "Ext.grid.Location": [],
  74750. "Ext.grid.NavigationModel": [
  74751. "navmodel.grid"
  74752. ],
  74753. "Ext.grid.PagingToolbar": [
  74754. "widget.pagingtoolbar"
  74755. ],
  74756. "Ext.grid.Row": [
  74757. "widget.gridrow"
  74758. ],
  74759. "Ext.grid.RowBody": [
  74760. "widget.rowbody"
  74761. ],
  74762. "Ext.grid.RowHeader": [
  74763. "widget.rowheader"
  74764. ],
  74765. "Ext.grid.SummaryRow": [
  74766. "widget.gridsummaryrow"
  74767. ],
  74768. "Ext.grid.Tree": [
  74769. "widget.tree"
  74770. ],
  74771. "Ext.grid.TreeDragZone": [],
  74772. "Ext.grid.TreeDropZone": [],
  74773. "Ext.grid.cell.Base": [
  74774. "widget.gridcellbase"
  74775. ],
  74776. "Ext.grid.cell.Boolean": [
  74777. "widget.booleancell"
  74778. ],
  74779. "Ext.grid.cell.Cell": [
  74780. "widget.gridcell"
  74781. ],
  74782. "Ext.grid.cell.Check": [
  74783. "widget.checkcell"
  74784. ],
  74785. "Ext.grid.cell.Date": [
  74786. "widget.datecell"
  74787. ],
  74788. "Ext.grid.cell.Expander": [
  74789. "widget.expandercell"
  74790. ],
  74791. "Ext.grid.cell.Number": [
  74792. "widget.numbercell"
  74793. ],
  74794. "Ext.grid.cell.RowNumberer": [
  74795. "widget.rownumberercell"
  74796. ],
  74797. "Ext.grid.cell.Text": [
  74798. "widget.textcell"
  74799. ],
  74800. "Ext.grid.cell.Tree": [
  74801. "widget.treecell"
  74802. ],
  74803. "Ext.grid.cell.Widget": [
  74804. "widget.widgetcell"
  74805. ],
  74806. "Ext.grid.column.Boolean": [
  74807. "widget.booleancolumn"
  74808. ],
  74809. "Ext.grid.column.Check": [
  74810. "widget.checkcolumn"
  74811. ],
  74812. "Ext.grid.column.Column": [
  74813. "widget.column",
  74814. "widget.gridcolumn",
  74815. "widget.templatecolumn"
  74816. ],
  74817. "Ext.grid.column.Date": [
  74818. "widget.datecolumn"
  74819. ],
  74820. "Ext.grid.column.Drag": [
  74821. "widget.dragcolumn"
  74822. ],
  74823. "Ext.grid.column.Number": [
  74824. "widget.numbercolumn"
  74825. ],
  74826. "Ext.grid.column.RowNumberer": [
  74827. "widget.rownumberer"
  74828. ],
  74829. "Ext.grid.column.Selection": [
  74830. "widget.selectioncolumn"
  74831. ],
  74832. "Ext.grid.column.Text": [
  74833. "widget.textcolumn"
  74834. ],
  74835. "Ext.grid.column.Tree": [
  74836. "widget.treecolumn"
  74837. ],
  74838. "Ext.grid.filters.Column": [],
  74839. "Ext.grid.filters.Plugin": [
  74840. "plugin.gridfilters"
  74841. ],
  74842. "Ext.grid.filters.menu.Base": [],
  74843. "Ext.grid.filters.menu.Boolean": [
  74844. "gridFilters.boolean"
  74845. ],
  74846. "Ext.grid.filters.menu.Date": [
  74847. "gridFilters.date"
  74848. ],
  74849. "Ext.grid.filters.menu.Number": [
  74850. "gridFilters.number"
  74851. ],
  74852. "Ext.grid.filters.menu.String": [
  74853. "gridFilters.string"
  74854. ],
  74855. "Ext.grid.locked.Grid": [
  74856. "widget.lockedgrid"
  74857. ],
  74858. "Ext.grid.locked.Region": [
  74859. "widget.lockedgridregion"
  74860. ],
  74861. "Ext.grid.menu.Columns": [
  74862. "widget.gridcolumnsmenu"
  74863. ],
  74864. "Ext.grid.menu.GroupByThis": [
  74865. "widget.gridgroupbythismenuitem"
  74866. ],
  74867. "Ext.grid.menu.Shared": [],
  74868. "Ext.grid.menu.ShowInGroups": [
  74869. "widget.gridshowingroupsmenuitem"
  74870. ],
  74871. "Ext.grid.menu.SortAsc": [
  74872. "widget.gridsortascmenuitem"
  74873. ],
  74874. "Ext.grid.menu.SortDesc": [
  74875. "widget.gridsortdescmenuitem"
  74876. ],
  74877. "Ext.grid.plugin.CellEditing": [
  74878. "plugin.cellediting",
  74879. "plugin.gridcellediting"
  74880. ],
  74881. "Ext.grid.plugin.Clipboard": [
  74882. "plugin.clipboard"
  74883. ],
  74884. "Ext.grid.plugin.ColumnResizing": [
  74885. "plugin.columnresizing",
  74886. "plugin.gridcolumnresizing"
  74887. ],
  74888. "Ext.grid.plugin.Editable": [
  74889. "plugin.grideditable"
  74890. ],
  74891. "Ext.grid.plugin.HeaderReorder": [
  74892. "plugin.headerreorder"
  74893. ],
  74894. "Ext.grid.plugin.PagingToolbar": [
  74895. "plugin.gridpagingtoolbar",
  74896. "plugin.pagingtoolbar"
  74897. ],
  74898. "Ext.grid.plugin.RowDragDrop": [
  74899. "plugin.gridrowdragdrop"
  74900. ],
  74901. "Ext.grid.plugin.RowExpander": [
  74902. "plugin.rowexpander"
  74903. ],
  74904. "Ext.grid.plugin.RowOperations": [
  74905. "plugin.gridmultiselection",
  74906. "plugin.multiselection",
  74907. "plugin.rowoperations"
  74908. ],
  74909. "Ext.grid.plugin.Summary": [
  74910. "plugin.gridsummary",
  74911. "plugin.gridsummaryrow",
  74912. "plugin.summaryrow"
  74913. ],
  74914. "Ext.grid.plugin.TreeDragDrop": [
  74915. "plugin.treedragdrop"
  74916. ],
  74917. "Ext.grid.plugin.ViewOptions": [
  74918. "plugin.gridviewoptions"
  74919. ],
  74920. "Ext.grid.plugin.ViewOptionsListItem": [
  74921. "widget.viewoptionslistitem"
  74922. ],
  74923. "Ext.grid.rowedit.Bar": [
  74924. "widget.roweditorbar"
  74925. ],
  74926. "Ext.grid.rowedit.Cell": [
  74927. "widget.roweditorcell"
  74928. ],
  74929. "Ext.grid.rowedit.Editor": [
  74930. "widget.roweditor"
  74931. ],
  74932. "Ext.grid.rowedit.Gap": [
  74933. "widget.roweditorgap"
  74934. ],
  74935. "Ext.grid.rowedit.Plugin": [
  74936. "plugin.rowedit"
  74937. ],
  74938. "Ext.grid.selection.Cells": [
  74939. "selection.cells"
  74940. ],
  74941. "Ext.grid.selection.Columns": [
  74942. "selection.columns"
  74943. ],
  74944. "Ext.grid.selection.Model": [
  74945. "selmodel.grid"
  74946. ],
  74947. "Ext.grid.selection.Replicator": [
  74948. "plugin.selectionreplicator"
  74949. ],
  74950. "Ext.grid.selection.SelectionExtender": [],
  74951. "Ext.layout.Auto": [
  74952. "layout.auto",
  74953. "layout.default"
  74954. ],
  74955. "Ext.layout.Box": [
  74956. "layout.box"
  74957. ],
  74958. "Ext.layout.Card": [
  74959. "layout.card"
  74960. ],
  74961. "Ext.layout.Carousel": [
  74962. "layout.carousel"
  74963. ],
  74964. "Ext.layout.Center": [
  74965. "layout.center"
  74966. ],
  74967. "Ext.layout.Fit": [
  74968. "layout.fit"
  74969. ],
  74970. "Ext.layout.Float": [
  74971. "layout.float"
  74972. ],
  74973. "Ext.layout.Form": [
  74974. "layout.form"
  74975. ],
  74976. "Ext.layout.HBox": [
  74977. "layout.hbox"
  74978. ],
  74979. "Ext.layout.VBox": [
  74980. "layout.vbox"
  74981. ],
  74982. "Ext.layout.card.fx.Abstract": [
  74983. "layout.card.fx.abstract"
  74984. ],
  74985. "Ext.layout.card.fx.Cover": [
  74986. "layout.card.fx.cover"
  74987. ],
  74988. "Ext.layout.card.fx.Cube": [
  74989. "layout.card.fx.cube"
  74990. ],
  74991. "Ext.layout.card.fx.Fade": [
  74992. "layout.card.fx.fade"
  74993. ],
  74994. "Ext.layout.card.fx.Flip": [
  74995. "layout.card.fx.flip"
  74996. ],
  74997. "Ext.layout.card.fx.Pop": [
  74998. "layout.card.fx.pop"
  74999. ],
  75000. "Ext.layout.card.fx.Reveal": [
  75001. "layout.card.fx.reveal"
  75002. ],
  75003. "Ext.layout.card.fx.Scroll": [
  75004. "layout.card.fx.scroll"
  75005. ],
  75006. "Ext.layout.card.fx.ScrollCover": [
  75007. "layout.card.fx.scrollcover"
  75008. ],
  75009. "Ext.layout.card.fx.ScrollReveal": [
  75010. "layout.card.fx.scrollreveal"
  75011. ],
  75012. "Ext.layout.card.fx.Serial": [],
  75013. "Ext.layout.card.fx.Slide": [
  75014. "layout.card.fx.slide"
  75015. ],
  75016. "Ext.layout.card.fx.Style": [],
  75017. "Ext.layout.overflow.Scroller": [
  75018. "layout.overflow.scroller"
  75019. ],
  75020. "Ext.layout.wrapper.BoxDock": [],
  75021. "Ext.layout.wrapper.Inner": [],
  75022. "Ext.list.AbstractTreeItem": [],
  75023. "Ext.list.Location": [],
  75024. "Ext.list.RootTreeItem": [],
  75025. "Ext.list.Tree": [
  75026. "widget.treelist"
  75027. ],
  75028. "Ext.list.TreeItem": [
  75029. "widget.treelistitem"
  75030. ],
  75031. "Ext.menu.CheckItem": [
  75032. "widget.menucheckitem"
  75033. ],
  75034. "Ext.menu.Item": [
  75035. "widget.menuitem"
  75036. ],
  75037. "Ext.menu.Manager": [],
  75038. "Ext.menu.Menu": [
  75039. "widget.menu"
  75040. ],
  75041. "Ext.menu.RadioItem": [
  75042. "widget.menuradioitem"
  75043. ],
  75044. "Ext.menu.Separator": [
  75045. "widget.menuseparator"
  75046. ],
  75047. "Ext.mixin.Accessible": [],
  75048. "Ext.mixin.Bindable": [],
  75049. "Ext.mixin.Bufferable": [],
  75050. "Ext.mixin.ComponentDelegation": [],
  75051. "Ext.mixin.ConfigProxy": [],
  75052. "Ext.mixin.ConfigState": [],
  75053. "Ext.mixin.Container": [],
  75054. "Ext.mixin.Dirty": [],
  75055. "Ext.mixin.Factoryable": [],
  75056. "Ext.mixin.FieldDefaults": [],
  75057. "Ext.mixin.Focusable": [],
  75058. "Ext.mixin.FocusableContainer": [],
  75059. "Ext.mixin.Hookable": [],
  75060. "Ext.mixin.Inheritable": [],
  75061. "Ext.mixin.ItemRippler": [],
  75062. "Ext.mixin.Keyboard": [],
  75063. "Ext.mixin.Mashup": [],
  75064. "Ext.mixin.Pluggable": [],
  75065. "Ext.mixin.Progressable": [],
  75066. "Ext.mixin.Queryable": [],
  75067. "Ext.mixin.Responsive": [],
  75068. "Ext.mixin.Selectable": [],
  75069. "Ext.mixin.StoreWatcher": [],
  75070. "Ext.mixin.StyleCacher": [],
  75071. "Ext.mixin.Templatable": [],
  75072. "Ext.mixin.Toolable": [],
  75073. "Ext.mixin.Traversable": [],
  75074. "Ext.mixin.Watchable": [],
  75075. "Ext.navigation.Bar": [],
  75076. "Ext.navigation.View": [
  75077. "widget.navigationview"
  75078. ],
  75079. "Ext.override.sparkline.Base": [],
  75080. "Ext.overrides.Progress": [],
  75081. "Ext.overrides.Widget": [],
  75082. "Ext.overrides.app.Application": [],
  75083. "Ext.overrides.dom.Element": [],
  75084. "Ext.overrides.drag.proxy.Placeholder": [],
  75085. "Ext.overrides.list.Tree": [],
  75086. "Ext.overrides.list.TreeItem": [],
  75087. "Ext.panel.Accordion": [
  75088. "widget.accordion"
  75089. ],
  75090. "Ext.panel.Buttons": [],
  75091. "Ext.panel.Collapser": [],
  75092. "Ext.panel.Collapsible": [],
  75093. "Ext.panel.Date": [
  75094. "widget.datepanel"
  75095. ],
  75096. "Ext.panel.DateTitle": [
  75097. "widget.datetitle"
  75098. ],
  75099. "Ext.panel.DateView": [
  75100. "widget.dateview"
  75101. ],
  75102. "Ext.panel.Header": [
  75103. "widget.panelheader"
  75104. ],
  75105. "Ext.panel.Resizable": [],
  75106. "Ext.panel.Resizer": [],
  75107. "Ext.panel.Time": [
  75108. "widget.timepanel"
  75109. ],
  75110. "Ext.panel.TimeHeader": [
  75111. "widget.analogtimeheader"
  75112. ],
  75113. "Ext.panel.TimeView": [
  75114. "widget.analogtime"
  75115. ],
  75116. "Ext.panel.Title": [
  75117. "widget.paneltitle"
  75118. ],
  75119. "Ext.panel.YearPicker": [
  75120. "widget.yearpicker"
  75121. ],
  75122. "Ext.parse.Parser": [],
  75123. "Ext.parse.Symbol": [],
  75124. "Ext.parse.Tokenizer": [],
  75125. "Ext.parse.symbol.Constant": [],
  75126. "Ext.parse.symbol.Infix": [],
  75127. "Ext.parse.symbol.InfixRight": [],
  75128. "Ext.parse.symbol.Paren": [],
  75129. "Ext.parse.symbol.Prefix": [],
  75130. "Ext.perf.Accumulator": [],
  75131. "Ext.perf.Monitor": [],
  75132. "Ext.picker.Date": [
  75133. "widget.datepicker"
  75134. ],
  75135. "Ext.picker.Picker": [
  75136. "widget.picker"
  75137. ],
  75138. "Ext.picker.SelectPicker": [
  75139. "widget.selectpicker"
  75140. ],
  75141. "Ext.picker.Slot": [
  75142. "widget.pickerslot"
  75143. ],
  75144. "Ext.picker.Tablet": [
  75145. "widget.tabletpicker"
  75146. ],
  75147. "Ext.plugin.Abstract": [],
  75148. "Ext.plugin.AbstractClipboard": [],
  75149. "Ext.plugin.MouseEnter": [
  75150. "plugin.mouseenter"
  75151. ],
  75152. "Ext.plugin.Responsive": [
  75153. "plugin.responsive"
  75154. ],
  75155. "Ext.plugin.TabGuard": [
  75156. "plugin.tabguard"
  75157. ],
  75158. "Ext.plugin.dd.DragDrop": [
  75159. "plugin.viewdragdrop"
  75160. ],
  75161. "Ext.plugin.dd.DragZone": [],
  75162. "Ext.plugin.dd.DropZone": [],
  75163. "Ext.promise.Consequence": [],
  75164. "Ext.promise.Deferred": [],
  75165. "Ext.promise.Promise": [],
  75166. "Ext.route.Action": [],
  75167. "Ext.route.Handler": [],
  75168. "Ext.route.Mixin": [],
  75169. "Ext.route.Route": [],
  75170. "Ext.route.Router": [],
  75171. "Ext.scroll.NativeScroller": [
  75172. "scroller.native"
  75173. ],
  75174. "Ext.scroll.Scroller": [
  75175. "scroller.scroller"
  75176. ],
  75177. "Ext.scroll.VirtualScroller": [
  75178. "scroller.virtual"
  75179. ],
  75180. "Ext.scroll.indicator.Bar": [
  75181. "scrollindicator.bar"
  75182. ],
  75183. "Ext.scroll.indicator.Indicator": [
  75184. "scrollindicator.indicator"
  75185. ],
  75186. "Ext.scroll.indicator.Overlay": [
  75187. "scrollindicator.overlay"
  75188. ],
  75189. "Ext.slider.Slider": [
  75190. "widget.slider"
  75191. ],
  75192. "Ext.slider.Thumb": [
  75193. "widget.thumb"
  75194. ],
  75195. "Ext.slider.Toggle": [
  75196. "widget.toggleslider"
  75197. ],
  75198. "Ext.sparkline.Bar": [
  75199. "widget.sparklinebar"
  75200. ],
  75201. "Ext.sparkline.BarBase": [],
  75202. "Ext.sparkline.Base": [
  75203. "widget.sparkline"
  75204. ],
  75205. "Ext.sparkline.Box": [
  75206. "widget.sparklinebox"
  75207. ],
  75208. "Ext.sparkline.Bullet": [
  75209. "widget.sparklinebullet"
  75210. ],
  75211. "Ext.sparkline.CanvasBase": [],
  75212. "Ext.sparkline.CanvasCanvas": [],
  75213. "Ext.sparkline.Discrete": [
  75214. "widget.sparklinediscrete"
  75215. ],
  75216. "Ext.sparkline.Line": [
  75217. "widget.sparklineline"
  75218. ],
  75219. "Ext.sparkline.Pie": [
  75220. "widget.sparklinepie"
  75221. ],
  75222. "Ext.sparkline.RangeMap": [],
  75223. "Ext.sparkline.Shape": [],
  75224. "Ext.sparkline.TriState": [
  75225. "widget.sparklinetristate"
  75226. ],
  75227. "Ext.sparkline.VmlCanvas": [],
  75228. "Ext.state.Builder": [],
  75229. "Ext.state.LocalStorage": [],
  75230. "Ext.state.Provider": [],
  75231. "Ext.state.Stateful": [],
  75232. "Ext.tab.Bar": [
  75233. "widget.tabbar"
  75234. ],
  75235. "Ext.tab.Panel": [
  75236. "widget.tabpanel"
  75237. ],
  75238. "Ext.tab.Tab": [
  75239. "widget.tab"
  75240. ],
  75241. "Ext.tip.Manager": [],
  75242. "Ext.tip.ToolTip": [
  75243. "widget.tooltip"
  75244. ],
  75245. "Ext.util.AbstractMixedCollection": [],
  75246. "Ext.util.Audio": [],
  75247. "Ext.util.Bag": [],
  75248. "Ext.util.Base64": [],
  75249. "Ext.util.BasicFilter": [],
  75250. "Ext.util.CSS": [],
  75251. "Ext.util.CSV": [],
  75252. "Ext.util.ClickRepeater": [],
  75253. "Ext.util.Collection": [],
  75254. "Ext.util.CollectionKey": [],
  75255. "Ext.util.Color": [],
  75256. "Ext.util.Cookies": [],
  75257. "Ext.util.DelimitedValue": [],
  75258. "Ext.util.Draggable": [],
  75259. "Ext.util.Filter": [],
  75260. "Ext.util.FilterCollection": [],
  75261. "Ext.util.Fly": [],
  75262. "Ext.util.Format": [],
  75263. "Ext.util.Geolocation": [],
  75264. "Ext.util.Group": [],
  75265. "Ext.util.GroupCollection": [],
  75266. "Ext.util.Grouper": [],
  75267. "Ext.util.HashMap": [],
  75268. "Ext.util.HeightSynchronizer": [],
  75269. "Ext.util.History": [],
  75270. "Ext.util.Inflector": [],
  75271. "Ext.util.InputBlocker": [],
  75272. "Ext.util.ItemCollection": [],
  75273. "Ext.util.KeyMap": [],
  75274. "Ext.util.KeyNav": [],
  75275. "Ext.util.LineSegment": [],
  75276. "Ext.util.LocalStorage": [],
  75277. "Ext.util.LruCache": [],
  75278. "Ext.util.MixedCollection": [],
  75279. "Ext.util.ObjectTemplate": [],
  75280. "Ext.util.Observable": [],
  75281. "Ext.util.Offset": [],
  75282. "Ext.util.PaintMonitor": [],
  75283. "Ext.util.Point": [],
  75284. "Ext.util.Positionable": [],
  75285. "Ext.util.Region": [],
  75286. "Ext.util.Schedulable": [],
  75287. "Ext.util.Scheduler": [],
  75288. "Ext.util.SizeMonitor": [],
  75289. "Ext.util.Sortable": [],
  75290. "Ext.util.Sorter": [],
  75291. "Ext.util.SorterCollection": [],
  75292. "Ext.util.Spans": [],
  75293. "Ext.util.TextMetrics": [],
  75294. "Ext.util.TranslatableGroup": [],
  75295. "Ext.util.TranslatableList": [],
  75296. "Ext.util.TsvDecoder": [],
  75297. "Ext.util.Wrapper": [],
  75298. "Ext.util.XTemplateCompiler": [],
  75299. "Ext.util.XTemplateParser": [],
  75300. "Ext.util.paintmonitor.Abstract": [],
  75301. "Ext.util.paintmonitor.CssAnimation": [],
  75302. "Ext.util.paintmonitor.OverflowChange": [],
  75303. "Ext.util.sizemonitor.Abstract": [],
  75304. "Ext.util.sizemonitor.OverflowChange": [],
  75305. "Ext.util.sizemonitor.Scroll": [],
  75306. "Ext.util.translatable.Abstract": [],
  75307. "Ext.util.translatable.Component": [
  75308. "translatable.component"
  75309. ],
  75310. "Ext.util.translatable.CssPosition": [
  75311. "translatable.cssposition"
  75312. ],
  75313. "Ext.util.translatable.CssTransform": [
  75314. "translatable.csstransform"
  75315. ],
  75316. "Ext.util.translatable.Dom": [
  75317. "translatable.dom"
  75318. ],
  75319. "Ext.util.translatable.ScrollParent": [
  75320. "translatable.scrollparent"
  75321. ],
  75322. "Ext.util.translatable.ScrollPosition": [
  75323. "translatable.scrollposition"
  75324. ],
  75325. "Ext.viewport.Android": [],
  75326. "Ext.viewport.Default": [
  75327. "widget.viewport"
  75328. ],
  75329. "Ext.viewport.Ios": [],
  75330. "Ext.viewport.Viewport": [],
  75331. "Ext.viewport.WindowsPhone": []
  75332. });